ThemePageControl.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 * TabTheme = { read = FTabTheme, write = SetTabTheme };
  54. __property TTBXTheme * ActiveTabTheme = { read = FActiveTabTheme, write = SetActiveTabTheme };
  55. int __fastcall GetTabsHeight();
  56. TRect __fastcall TabButtonRect(int Index);
  57. int TotalTabsWidth();
  58. void UpdateTabsCaptionTruncation();
  59. protected:
  60. virtual void __fastcall PaintWindow(HDC DC);
  61. DYNAMIC bool __fastcall CanChange();
  62. DYNAMIC void __fastcall Change();
  63. DYNAMIC void __fastcall MouseMove(TShiftState Shift, int X, int Y);
  64. virtual void __fastcall Dispatch(void * Message);
  65. void TabChanged(int Index);
  66. #ifdef _DEBUG
  67. virtual void __fastcall RequestAlign();
  68. #endif
  69. private:
  70. void __fastcall DrawThemesXpTab(HDC DC, HTHEME Theme, int Tab);
  71. void __fastcall DrawThemesXpTabItem(
  72. HDC DC, HTHEME Theme, int Item, const TRect & Rect, int State, bool Selected, TTBXTheme * ATabTheme);
  73. void __fastcall DrawTabItem(HDC DC, int Item, TRect Rect, int State, bool Shadowed, TTBXTheme * ATabTheme);
  74. void __fastcall InvalidateTab(int Index);
  75. int __fastcall TabButtonSize();
  76. int __fastcall GetCrossPadding();
  77. int __fastcall IndexOfTabButtonAt(int X, int Y);
  78. void __fastcall ItemContentsRect(int Item, TRect & Rect);
  79. bool __fastcall HasItemImage(int Item);
  80. void __fastcall ItemTextRect(int Item, TRect & Rect);
  81. void __fastcall ItemTabRect(int Item, TRect & Rect);
  82. TThemeTabSheetButtons __fastcall GetTabButton(int Index);
  83. void UpdateHotButton(int & Ref, int Index);
  84. void DrawCross(HDC DC, int Width, COLORREF Color, const TRect & Rect);
  85. void DrawDropDown(HDC DC, int Radius, int X, int Y, COLORREF Color, int Grow);
  86. void __fastcall WMLButtonDown(TWMLButtonDown & Message);
  87. bool IsHotButton(int Index);
  88. TThemeTabSheet * GetPage(int Index);
  89. TThemeTabSheet * GetActivePage();
  90. void CMHintShow(TCMHintShow & Message);
  91. void SetTabTheme(TTBXTheme * value);
  92. void SetActiveTabTheme(TTBXTheme * value);
  93. int FOldTabIndex;
  94. int FHotTabButton;
  95. int FClickedButton;
  96. TPageControlTabButtonClick FOnTabButtonClick;
  97. TPageControlTabHint FOnTabHint;
  98. int FSessionTabShrink;
  99. TTBXTheme * FTabTheme;
  100. TTBXTheme * FActiveTabTheme;
  101. int FTextHeight;
  102. };
  103. //---------------------------------------------------------------------------
  104. #endif