LogMemo.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. void __fastcall CMShowingChanged(TMessage & Message);
  37. void CMVisibleChanged(TMessage & Message);
  38. void WMLogUpdate(TMessage & Message);
  39. int __fastcall GetIndexes(int Index);
  40. int __fastcall GetLinesVisible();
  41. bool __fastcall IsFontStored();
  42. #ifndef DESIGN_ONLY
  43. void __fastcall SetSessionLog(TSessionLog * value);
  44. #endif
  45. void __fastcall SetShowTypes(TLogLineTypes value);
  46. bool __fastcall StoreShowTypes();
  47. void __fastcall WMPaint(TWMPaint & Message);
  48. MESSAGE void __fastcall WMSetFocus(TWMSetFocus & Message);
  49. protected:
  50. DYNAMIC void __fastcall Change();
  51. DYNAMIC void __fastcall KeyDown(Word & Key, TShiftState Shift);
  52. DYNAMIC void __fastcall MouseDown(TMouseButton Button, TShiftState Shift, int X, int Y);
  53. void __fastcall ReloadFromLog();
  54. void __fastcall ScrollToEnd();
  55. void __fastcall SessionLogChange(TObject * Sender);
  56. virtual void __fastcall SetParent(TWinControl * AParent);
  57. void __fastcall UpdateFromLog();
  58. void __fastcall WMKeyDown(TWMKeyDown & Message);
  59. __property int Indexes[Integer Index] = { read = GetIndexes };
  60. #pragma warn -8118
  61. #pragma warn -inl
  62. virtual void __fastcall Dispatch(void *Message) {
  63. if (Parent)
  64. switch (((PMessage)Message)->Msg) {
  65. VCL_MESSAGE_HANDLER(WM_SETFOCUS, TWMSetFocus, WMSetFocus)
  66. VCL_MESSAGE_HANDLER(CM_VISIBLECHANGED, TMessage, CMVisibleChanged)
  67. VCL_MESSAGE_HANDLER(CM_SHOWINGCHANGED, TMessage, CMShowingChanged)
  68. VCL_MESSAGE_HANDLER(WM_KEYDOWN, TWMKeyDown, WMKeyDown)
  69. VCL_MESSAGE_HANDLER(WM_PAINT, TWMPaint, WMPaint)
  70. VCL_MESSAGE_HANDLER(WM_LOG_UPDATE, TMessage, WMLogUpdate)
  71. END_MESSAGE_MAP(TCustomRichEdit)
  72. #pragma warn .inl
  73. #pragma warn .8118
  74. public:
  75. virtual __fastcall ~TLogMemo();
  76. __fastcall TLogMemo(TComponent* Owner);
  77. __property int LinesVisible = { read = GetLinesVisible };
  78. #ifndef DESIGN_ONLY
  79. __property TSessionLog * SessionLog = { read = FSessionLog, write = SetSessionLog };
  80. #endif
  81. __property Lines;
  82. __published:
  83. __property TLogLineTypes ShowTypes = { read = FShowTypes, write = SetShowTypes,
  84. stored = StoreShowTypes };
  85. __property Align;
  86. __property Alignment;
  87. __property Anchors;
  88. __property BiDiMode;
  89. __property BorderStyle;
  90. __property BorderWidth;
  91. __property Color;
  92. __property Constraints;
  93. __property Ctl3D;
  94. __property DragCursor;
  95. __property DragKind;
  96. __property DragMode;
  97. __property Enabled;
  98. __property Font = { stored = IsFontStored };
  99. __property HideSelection;
  100. __property HideScrollBars;
  101. __property ImeMode;
  102. __property ImeName;
  103. __property ParentBiDiMode;
  104. __property ParentColor = {default = False };
  105. __property ParentCtl3D;
  106. __property ParentFont = { default = False };
  107. __property ParentShowHint;
  108. __property PopupMenu;
  109. __property ReadOnly = { default = True };
  110. __property ScrollBars = { default = ssBoth };
  111. __property ShowHint;
  112. __property TabOrder;
  113. __property TabStop;
  114. __property Visible;
  115. __property WantReturns = { default = False };
  116. __property WantTabs;
  117. __property WordWrap = { default = False };
  118. __property OnChange;
  119. __property OnContextPopup;
  120. __property OnDragDrop;
  121. __property OnDragOver;
  122. __property OnEndDock;
  123. __property OnEndDrag;
  124. __property OnEnter;
  125. __property OnExit;
  126. __property OnKeyDown;
  127. __property OnKeyPress;
  128. __property OnKeyUp;
  129. __property OnMouseDown;
  130. __property OnMouseMove;
  131. __property OnMouseUp;
  132. __property OnMouseWheel;
  133. __property OnMouseWheelDown;
  134. __property OnMouseWheelUp;
  135. __property OnProtectChange;
  136. __property OnResizeRequest;
  137. __property OnSaveClipboard;
  138. __property OnSelectionChange;
  139. __property OnStartDock;
  140. __property OnStartDrag;
  141. };
  142. //---------------------------------------------------------------------------
  143. #endif