LogMemo.h 4.6 KB

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