16
Types, Classes, SysUtils, Math,
15
Types, Classes, SysUtils,
30
29
function InitThemes: Boolean; override;
31
30
function UseThemes: Boolean; override;
32
31
function ThemedControlsEnabled: Boolean; override;
33
procedure InternalDrawParentBackground(Window: HWND; Target: HDC; Bounds: PRect); override;
32
procedure InternalDrawParentBackground({%H-}Window: HWND; {%H-}Target: HDC; {%H-}Bounds: PRect); override;
35
34
function GetDrawState(Details: TThemedElementDetails): ThemeDrawState;
36
function DrawButtonElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
37
function DrawHeaderElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
38
function DrawRebarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
39
function DrawToolBarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
40
function DrawTreeviewElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
35
function DrawButtonElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
36
function DrawComboBoxElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
37
function DrawHeaderElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
38
function DrawRebarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
39
function DrawToolBarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
40
function DrawTreeviewElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; {%H-}ClipRect: PRect): TRect;
42
42
procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect); override;
43
procedure DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal; AContentRect: PRect); override;
44
procedure DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST; Index: Integer); override;
45
procedure DrawText(DC: HDC; Details: TThemedElementDetails; const S: String; R: TRect; Flags, Flags2: Cardinal); override;
43
procedure DrawEdge({%H-}DC: HDC; {%H-}Details: TThemedElementDetails; const {%H-}R: TRect; {%H-}Edge, {%H-}Flags: Cardinal; {%H-}AContentRect: PRect); override;
44
procedure DrawIcon({%H-}DC: HDC; {%H-}Details: TThemedElementDetails; const {%H-}R: TRect; {%H-}himl: HIMAGELIST; {%H-}Index: Integer); override;
45
procedure DrawText({%H-}DC: HDC; {%H-}Details: TThemedElementDetails; const {%H-}S: String; {%H-}R: TRect; {%H-}Flags, {%H-}Flags2: Cardinal); override;
47
function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override;
48
function HasTransparentParts(Details: TThemedElementDetails): Boolean; override;
47
function ContentRect({%H-}DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override;
48
function HasTransparentParts({%H-}Details: TThemedElementDetails): Boolean; override;
49
49
function GetDetailSize(Details: TThemedElementDetails): TSize; override;
50
50
function GetOption(AOption: TThemeOption): Integer; override;
88
88
{------------------------------------------------------------------------------
89
Method: TCarbonThemeServices.DrawComboBoxElement
90
Params: DC - Carbon device context
91
Details - Details for themed element
92
R - Bounding rectangle
93
ClipRect - Clipping rectangle
96
Draws a ComboBox element with native Carbon look
97
------------------------------------------------------------------------------}
98
function TCarbonThemeServices.DrawComboBoxElement(DC: TCarbonDeviceContext;
99
Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
101
ButtonDrawInfo: HIThemeButtonDrawInfo;
106
ButtonDrawInfo.version := 0;
107
ButtonDrawInfo.State := GetDrawState(Details);
108
ButtonDrawInfo.value := kThemeButtonOn;
109
ButtonDrawInfo.adornment := kThemeAdornmentNone;
111
BoundsRect := RectToCGRect(R);
113
NewHeight := GetCarbonThemeMetric(kThemeMetricPopupButtonHeight);
114
BtnWidth := GetCarbonThemeMetric(kThemeMetricComboBoxLargeDisclosureWidth);
115
ButtonDrawInfo.kind := kThemeComboBox;
116
if BoundsRect.size.height < NewHeight then begin
117
NewHeight := GetCarbonThemeMetric(kThemeMetricSmallPopupButtonHeight);
118
BtnWidth := GetCarbonThemeMetric(kThemeMetricComboBoxSmallDisclosureWidth);
119
ButtonDrawInfo.kind := kThemeComboBoxSmall;
121
if BoundsRect.size.height < NewHeight then begin
122
NewHeight := GetCarbonThemeMetric(kThemeMetricMiniPopupButtonHeight);
123
BtnWidth := GetCarbonThemeMetric(kThemeMetricComboBoxMiniDisclosureWidth);
124
ButtonDrawInfo.kind := kThemeComboBoxMini;
128
HIThemeDrawButton(BoundsRect, ButtonDrawInfo, DC.CGContext,
129
kHIThemeOrientationNormal, nil),
130
Self, 'DrawComboBoxElement', 'HIThemeDrawButton');
132
BoundsRect.size.height := NewHeight + 1;
133
BoundsRect.size.width := BoundsRect.size.width - BtnWidth;
134
Result := CGRectToRect(BoundsRect);
137
{------------------------------------------------------------------------------
89
138
Method: TCarbonThemeServices.DrawButtonElement
90
139
Params: DC - Carbon device context
91
140
Details - Details for themed element
101
150
ButtonMap: array[BP_PUSHBUTTON..BP_USERBUTTON] of ThemeButtonKind =
103
{BP_PUSHBUTTON } kThemeBevelButtonSmall,
152
{BP_PUSHBUTTON } kThemeRoundedBevelButton,
104
153
{BP_RADIOBUTTON} kThemeRadioButton,
105
154
{BP_CHECKBOX } kThemeCheckBox,
106
155
{BP_GROUPBOX } kHIThemeGroupBoxKindPrimary, // ??
107
{BP_USERBUTTON } kThemeBevelButtonSmall
156
{BP_USERBUTTON } kThemeRoundedBevelButton
110
159
ButtonDrawInfo: HIThemeButtonDrawInfo;
153
202
function TCarbonThemeServices.DrawHeaderElement(DC: TCarbonDeviceContext;
154
203
Details: TThemedElementDetails; R: TRect; ClipRect: PRect): TRect;
156
HeaderDrawInfo: HiThemeHeaderDrawInfo;
205
ButtonDrawInfo: HIThemeButtonDrawInfo;
157
206
PaintRect: HIRect;
159
if (R.Bottom - R.Top = 0) or (R.Right - R.Left = 0) then
208
ButtonDrawInfo.version := 0;
209
ButtonDrawInfo.State := GetDrawState(Details);
210
ButtonDrawInfo.kind := kThemeBevelButtonSmall;//kThemeListHeaderButton;
211
ButtonDrawInfo.adornment := kThemeAdornmentNone;
165
HeaderDrawInfo.version := 0;
166
HeaderDrawInfo.State := GetDrawState(Details);
167
HeaderDrawInfo.kind := kHiThemeHeaderKindList;
168
213
PaintRect := RectToCGRect(R);
171
HIThemeDrawHeader(PaintRect, HeaderDrawInfo, DC.CGContext,
172
kHIThemeOrientationNormal),
173
Self, 'DrawHeaderElement', 'HIThemeDrawHeader');
216
HIThemeDrawButton(PaintRect, ButtonDrawInfo, DC.CGContext,
217
kHIThemeOrientationNormal, @PaintRect),
218
Self, 'DrawButtonElement', 'HIThemeDrawButton');
175
220
Result := CGRectToRect(PaintRect);
176
InflateRect(Result, -2, -2);
179
223
{------------------------------------------------------------------------------
292
336
b:=TCarbonBrush.Create(False);
293
b.SetColor( ColorToRGB(clHighlight), True);
337
case Details.State of
338
TREIS_NORMAL: b.SetColor( ColorToRGB(clWindow), True);
339
TREIS_HOT: b.SetColor( ColorToRGB(clHotLight), True);
340
TREIS_SELECTED: b.SetColor( ColorToRGB(clHighlight), True);
341
TREIS_DISABLED: b.SetColor( ColorToRGB(clWindow), True);
342
TREIS_SELECTEDNOTFOCUS: b.SetColor( ColorToRGB(clBtnFace), True);
343
TREIS_HOTSELECTED: b.SetColor( ColorToRGB(clHighlight), True);
294
345
DC.FillRect(R, b);
355
406
Details: TThemedElementDetails; BoundingRect: TRect): TRect;
357
408
case Details.Element of
409
teComboBox: Result := DrawComboBoxElement(DefaultContext, Details, BoundingRect, nil);
358
410
teHeader: Result := DrawHeaderElement(DefaultContext, Details, BoundingRect, nil);
359
411
teButton: Result := DrawButtonElement(DefaultContext, Details, BoundingRect, nil);
360
412
teRebar: Result := DrawRebarElement(DefaultContext, Details, BoundingRect, nil);
396
448
if CheckDC(DC, 'TCarbonThemeServices.DrawElement') then
398
450
case Details.Element of
451
teComboBox: DrawComboBoxElement(Context, Details, R, ClipRect);
399
452
teButton: DrawButtonElement(Context, Details, R, ClipRect);
400
453
teHeader: DrawHeaderElement(Context, Details, R, ClipRect);
401
454
teRebar: DrawRebarElement(Context, Details, R, ClipRect);