drawing carbon splitter through ThemeServices (with -dUseThemes)

git-svn-id: trunk@11235 -
This commit is contained in:
paul 2007-05-31 07:31:16 +00:00
parent 6ab44daa2b
commit 8fc54eb966
2 changed files with 39 additions and 12 deletions

View File

@ -28,9 +28,9 @@ type
function GetDrawState(Details: TThemedElementDetails): ThemeDrawState;
procedure DrawButtonElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect);
procedure DrawToolBarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect);
procedure DrawReBarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect);
public
procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect); override;
procedure DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal; AContentRect: PRect); override;
procedure DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST; Index: Integer); override;
procedure DrawText(DC: HDC; Details: TThemedElementDetails; const S: WideString; R: TRect; Flags, Flags2: Cardinal); override;
@ -114,7 +114,6 @@ var
begin
if Details.Part = TP_BUTTON then
begin
// TODO: if state is inactive or normal button should not have borders (or maybe I am wrong for mac?)
ButtonDrawInfo.version := 0;
@ -133,6 +132,36 @@ begin
end;
end;
procedure TCarbonThemeServices.DrawReBarElement(DC: TCarbonDeviceContext;
Details: TThemedElementDetails; R: TRect; ClipRect: PRect);
var
SplitterInfo: HIThemeSplitterDrawInfo;
PlacardInfo: HIThemePlacardDrawInfo;
ARect: HIRect;
begin
ARect := RectToCGRect(R);
if Details.Part in [RP_GRIPPER, RP_GRIPPERVERT] then
begin
SplitterInfo.version := 0;
SplitterInfo.State := kThemeStateActive;
SplitterInfo.adornment := kHiThemeSplitterAdornmentNone;
OSError(
HIThemeDrawPaneSplitter(ARect, SplitterInfo, DC.CGContext, kHIThemeOrientationNormal),
Self, 'DrawReBarElement', 'HIThemeDrawPaneSplitter');
end
else
if Details.Part = RP_BAND then
begin
PlacardInfo.version := 0;
PlacardInfo.State := GetDrawState(Details);
OSError(
HIThemeDrawPlacard(ARect, PlacardInfo, DC.CGContext, kHIThemeOrientationNormal),
Self, 'DrawReBarElement', 'HIThemeDrawPlacard');
end;
end;
function TCarbonThemeServices.InitThemes: Boolean;
begin
Result := True;
@ -154,13 +183,6 @@ begin
Result := BoundingRect;
end;
procedure TCarbonThemeServices.DrawEdge(DC: HDC;
Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal;
AContentRect: PRect);
begin
end;
procedure TCarbonThemeServices.DrawElement(DC: HDC;
Details: TThemedElementDetails; const R: TRect; ClipRect: PRect);
var
@ -171,6 +193,8 @@ begin
case Details.Element of
teButton: DrawButtonElement(Context, Details, R, ClipRect);
teToolBar: DrawToolBarElement(Context, Details, R, ClipRect);
// teHeader: TODO: for grid
teRebar: DrawRebarElement(Context, Details, R, ClipRect);
end;
end;
end;

View File

@ -1837,21 +1837,24 @@ end;
function TThemeServices.IsDisabled(Details: TThemedElementDetails): Boolean;
begin
Result := False;
if (Details.Element in [teButton, teToolBar]) then
if (Details.Element in [teButton, teToolBar, teHeader]) or
((Details.Element = teRebar) and (Details.Part >= RP_BAND)) then
Result := (Details.State mod 4) = 0; // usual disabled = 4 / 8 / 12
end;
function TThemeServices.IsPushed(Details: TThemedElementDetails): Boolean;
begin
Result := False;
if (Details.Element in [teButton, teToolBar, teHeader]) then
if (Details.Element in [teButton, teToolBar, teHeader]) or
((Details.Element = teRebar) and (Details.Part >= RP_BAND)) then
Result := Details.State in [3, 5, 6];
end;
function TThemeServices.IsHot(Details: TThemedElementDetails): Boolean;
begin
Result := False;
if (Details.Element in [teButton, teToolBar, teHeader]) then
if (Details.Element in [teButton, teToolBar, teHeader]) or
((Details.Element = teRebar) and (Details.Part >= RP_BAND)) then
Result := Details.State in [2, 6];
end;