LogMemo.h 4.8 KB

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