LogMemo.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. //---------------------------------------------------------------------------
  2. #ifndef LogMemoH
  3. #define LogMemoH
  4. //---------------------------------------------------------------------------
  5. #include <SysUtils.hpp>
  6. #include <Controls.hpp>
  7. #include <Classes.hpp>
  8. #include <Forms.hpp>
  9. #include <StdCtrls.hpp>
  10. #include <ComCtrls.hpp>
  11. #define WM_WINSCP_USER (WM_USER + 0x2000)
  12. #define WM_LOG_UPDATE (WM_WINSCP_USER + 6)
  13. #ifndef DESIGN_ONLY
  14. #include <SessionInfo.h>
  15. #else
  16. enum TLogLineType {llOutput, llInput, llStdError, llMessage, llException};
  17. #endif
  18. typedef Set<TLogLineType, llOutput, llException> TLogLineTypes;
  19. //---------------------------------------------------------------------------
  20. #define DEFAULT_LOGMEMO_FONT L"Courier New"
  21. #define DEFAULT_LOGMEMO_SHOWTYPES (TLogLineTypes() << llOutput << llInput << \
  22. llStdError << llMessage << llException)
  23. class PACKAGE TLogMemo : public TCustomRichEdit
  24. {
  25. private:
  26. #ifndef DESIGN_ONLY
  27. TSessionLog * FSessionLog;
  28. #endif
  29. TLogLineTypes FShowTypes;
  30. TList *FIndexes;
  31. bool FUpdating;
  32. bool FWantScrollToEnd;
  33. bool FNeedsRepaint;
  34. unsigned int FLastUpdate;
  35. DWORD FThread;
  36. bool FReloading;
  37. void __fastcall CMShowingChanged(TMessage & Message);
  38. void CMVisibleChanged(TMessage & Message);
  39. void WMLogUpdate(TMessage & Message);
  40. int __fastcall GetIndexes(int Index);
  41. int __fastcall GetLinesVisible();
  42. bool __fastcall IsFontStored();
  43. #ifndef DESIGN_ONLY
  44. void __fastcall SetSessionLog(TSessionLog * value);
  45. #endif
  46. void __fastcall SetShowTypes(TLogLineTypes value);
  47. bool __fastcall StoreShowTypes();
  48. void __fastcall WMPaint(TWMPaint & Message);
  49. MESSAGE void __fastcall WMSetFocus(TWMSetFocus & Message);
  50. protected:
  51. DYNAMIC void __fastcall Change();
  52. DYNAMIC void __fastcall KeyDown(Word & Key, TShiftState Shift);
  53. DYNAMIC void __fastcall MouseDown(TMouseButton Button, TShiftState Shift, int X, int Y);
  54. void __fastcall ReloadFromLog();
  55. void __fastcall ScrollToEnd();
  56. void __fastcall SessionLogChange(TObject * Sender);
  57. virtual void __fastcall SetParent(TWinControl * AParent);
  58. void __fastcall UpdateFromLog();
  59. void __fastcall WMKeyDown(TWMKeyDown & Message);
  60. __property int Indexes[Integer Index] = { read = GetIndexes };
  61. #pragma warn -8118
  62. #pragma warn -inl
  63. virtual void __fastcall Dispatch(void *Message) {
  64. if (Parent)
  65. switch (((PMessage)Message)->Msg) {
  66. VCL_MESSAGE_HANDLER(WM_SETFOCUS, TWMSetFocus, WMSetFocus)
  67. VCL_MESSAGE_HANDLER(CM_VISIBLECHANGED, TMessage, CMVisibleChanged)
  68. VCL_MESSAGE_HANDLER(CM_SHOWINGCHANGED, TMessage, CMShowingChanged)
  69. VCL_MESSAGE_HANDLER(WM_KEYDOWN, TWMKeyDown, WMKeyDown)
  70. VCL_MESSAGE_HANDLER(WM_PAINT, TWMPaint, WMPaint)
  71. VCL_MESSAGE_HANDLER(WM_LOG_UPDATE, TMessage, WMLogUpdate)
  72. END_MESSAGE_MAP(TCustomRichEdit)
  73. #pragma warn .inl
  74. #pragma warn .8118
  75. public:
  76. virtual __fastcall ~TLogMemo();
  77. __fastcall TLogMemo(TComponent* Owner);
  78. __property int LinesVisible = { read = GetLinesVisible };
  79. #ifndef DESIGN_ONLY
  80. __property TSessionLog * SessionLog = { read = FSessionLog, write = SetSessionLog };
  81. #endif
  82. __property Lines;
  83. __published:
  84. __property TLogLineTypes ShowTypes = { read = FShowTypes, write = SetShowTypes,
  85. stored = StoreShowTypes };
  86. __property Align;
  87. __property Alignment;
  88. __property Anchors;
  89. __property BiDiMode;
  90. __property BorderStyle;
  91. __property BorderWidth;
  92. __property Color;
  93. __property Constraints;
  94. __property Ctl3D;
  95. __property DragCursor;
  96. __property DragKind;
  97. __property DragMode;
  98. __property Enabled;
  99. __property Font = { stored = IsFontStored };
  100. __property HideSelection;
  101. __property HideScrollBars;
  102. __property ImeMode;
  103. __property ImeName;
  104. __property ParentBiDiMode;
  105. __property ParentColor = {default = False };
  106. __property ParentCtl3D;
  107. __property ParentFont = { default = False };
  108. __property ParentShowHint;
  109. __property PopupMenu;
  110. __property ReadOnly = { default = True };
  111. __property ScrollBars = { default = ssBoth };
  112. __property ShowHint;
  113. __property TabOrder;
  114. __property TabStop;
  115. __property Visible;
  116. __property WantReturns = { default = False };
  117. __property WantTabs;
  118. __property WordWrap = { default = False };
  119. __property OnChange;
  120. __property OnContextPopup;
  121. __property OnDragDrop;
  122. __property OnDragOver;
  123. __property OnEndDock;
  124. __property OnEndDrag;
  125. __property OnEnter;
  126. __property OnExit;
  127. __property OnKeyDown;
  128. __property OnKeyPress;
  129. __property OnKeyUp;
  130. __property OnMouseDown;
  131. __property OnMouseMove;
  132. __property OnMouseUp;
  133. __property OnMouseWheel;
  134. __property OnMouseWheelDown;
  135. __property OnMouseWheelUp;
  136. __property OnProtectChange;
  137. __property OnResizeRequest;
  138. __property OnSaveClipboard;
  139. __property OnSelectionChange;
  140. __property OnStartDock;
  141. __property OnStartDrag;
  142. };
  143. //---------------------------------------------------------------------------
  144. #endif