ThemePageControl.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //---------------------------------------------------------------------------
  2. #ifndef ThemePageControlH
  3. #define ThemePageControlH
  4. //---------------------------------------------------------------------------
  5. #include <ComCtrls.hpp>
  6. //---------------------------------------------------------------------------
  7. enum TThemeTabSheetButtons { ttbNone, ttbClose, ttbDropDown };
  8. enum TThemeTabCaptionTruncation { tttNone, tttEllipsis, tttNoText };
  9. class TThemePageControl;
  10. //---------------------------------------------------------------------------
  11. class TThemeTabSheet : public TTabSheet
  12. {
  13. friend class TThemePageControl;
  14. public:
  15. __fastcall TThemeTabSheet(TComponent * Owner);
  16. __property UnicodeString BaseCaption = { read = GetBaseCaption, write = SetBaseCaption };
  17. __property bool Shadowed = { read = FShadowed, write = SetShadowed };
  18. __property TThemeTabSheetButtons Button = { read = FButton, write = SetButton };
  19. __property TThemeTabCaptionTruncation CaptionTruncation = { read = FCaptionTruncation, write = SetCaptionTruncation };
  20. private:
  21. void __fastcall SetShadowed(bool Value);
  22. void __fastcall SetButton(TThemeTabSheetButtons Value);
  23. void __fastcall Invalidate();
  24. void SetBaseCaption(const UnicodeString & value);
  25. UnicodeString GetBaseCaption();
  26. TThemePageControl * GetParentPageControl();
  27. void SetCaptionTruncation(TThemeTabCaptionTruncation Value);
  28. void UpdateCaption();
  29. UnicodeString TruncatedCaption();
  30. bool FShadowed;
  31. TThemeTabSheetButtons FButton;
  32. UnicodeString FBaseCaption;
  33. TThemeTabCaptionTruncation FCaptionTruncation;
  34. };
  35. //---------------------------------------------------------------------------
  36. typedef void __fastcall (__closure *TPageControlTabButtonClick)(TPageControl * Sender, int Index);
  37. typedef void __fastcall (__closure *TPageControlTabHint)(TPageControl * Sender, int Index, UnicodeString & Hint);
  38. namespace Tbxthemes
  39. {
  40. class TTBXTheme;
  41. }
  42. //---------------------------------------------------------------------------
  43. class TThemePageControl : public TPageControl
  44. {
  45. friend class TThemeTabSheet;
  46. __published:
  47. __property TPageControlTabButtonClick OnTabButtonClick = { read = FOnTabButtonClick, write = FOnTabButtonClick };
  48. __property TPageControlTabHint OnTabHint = { read = FOnTabHint, write = FOnTabHint };
  49. public:
  50. __fastcall TThemePageControl(TComponent * Owner);
  51. __property TThemeTabSheet * Pages[int Index] = { read = GetPage };
  52. __property TThemeTabSheet * ActivePage = { read = GetActivePage };
  53. __property TTBXTheme * ActiveTabTheme = { read = FActiveTabTheme, write = SetActiveTabTheme };
  54. int __fastcall GetTabsHeight();
  55. TRect __fastcall TabButtonRect(int Index);
  56. int TotalTabsWidth();
  57. void UpdateTabsCaptionTruncation();
  58. protected:
  59. virtual void __fastcall PaintWindow(HDC DC);
  60. DYNAMIC bool __fastcall CanChange();
  61. DYNAMIC void __fastcall Change();
  62. DYNAMIC void __fastcall MouseMove(TShiftState Shift, int X, int Y);
  63. virtual void __fastcall Dispatch(void * Message);
  64. void TabChanged(int Index);
  65. #ifdef _DEBUG
  66. virtual void __fastcall RequestAlign();
  67. #endif
  68. private:
  69. void __fastcall DrawThemesXpTab(HDC DC, HTHEME Theme, int Tab);
  70. void __fastcall DrawThemesXpTabItem(HDC DC, HTHEME Theme, int Item, const TRect & Rect, int State, bool Selected);
  71. void __fastcall DrawTabItem(HDC DC, int Item, TRect Rect, int State, bool Shadowed);
  72. void __fastcall InvalidateTab(int Index);
  73. int __fastcall TabButtonSize();
  74. int __fastcall GetCrossPadding();
  75. int __fastcall IndexOfTabButtonAt(int X, int Y);
  76. void __fastcall ItemContentsRect(int Item, TRect & Rect);
  77. bool __fastcall HasItemImage(int Item);
  78. void __fastcall ItemTextRect(int Item, TRect & Rect);
  79. void __fastcall ItemTabRect(int Item, TRect & Rect);
  80. TThemeTabSheetButtons __fastcall GetTabButton(int Index);
  81. void UpdateHotButton(int & Ref, int Index);
  82. void DrawCross(HDC DC, int Width, COLORREF Color, const TRect & Rect);
  83. void DrawDropDown(HDC DC, int Radius, int X, int Y, COLORREF Color, int Grow);
  84. void __fastcall WMLButtonDown(TWMLButtonDown & Message);
  85. bool IsHotButton(int Index);
  86. TThemeTabSheet * GetPage(int Index);
  87. TThemeTabSheet * GetActivePage();
  88. void CMHintShow(TCMHintShow & Message);
  89. void SetActiveTabTheme(TTBXTheme * value);
  90. int FOldTabIndex;
  91. int FHotTabButton;
  92. int FClickedButton;
  93. TPageControlTabButtonClick FOnTabButtonClick;
  94. TPageControlTabHint FOnTabHint;
  95. int FSessionTabShrink;
  96. TTBXTheme * FActiveTabTheme;
  97. };
  98. //---------------------------------------------------------------------------
  99. #endif