- carbon header painting

git-svn-id: trunk@11288 -
This commit is contained in:
paul 2007-06-06 03:24:08 +00:00
parent 59aa486876
commit 4512cc87b8
2 changed files with 37 additions and 2 deletions

View File

@ -34,6 +34,7 @@ type
function GetDrawState(Details: TThemedElementDetails): ThemeDrawState;
procedure DrawButtonElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect);
procedure DrawHeaderElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect);
procedure DrawRebarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect);
procedure DrawToolBarElement(DC: TCarbonDeviceContext; Details: TThemedElementDetails; R: TRect; ClipRect: PRect);
public
@ -128,6 +129,31 @@ begin
Self, 'DrawButtonElement', 'HIThemeDrawButton');
end;
{------------------------------------------------------------------------------
Method: TCarbonThemeServices.DrawHeaderElement
Params: DC - Carbon device context
Details - Details for themed element
R - Bounding rectangle
ClipRect - Clipping rectangle
Draws a header (THeaderControl same as ListView header) element with native Carbon look
------------------------------------------------------------------------------}
procedure TCarbonThemeServices.DrawHeaderElement(DC: TCarbonDeviceContext;
Details: TThemedElementDetails; R: TRect; ClipRect: PRect);
var
HeaderDrawInfo: HiThemeHeaderDrawInfo;
PaintRect: HIRect;
begin
HeaderDrawInfo.version := 0;
HeaderDrawInfo.State := GetDrawState(Details);
HeaderDrawInfo.kind := kHiThemeHeaderKindList;
PaintRect := RectToCGRect(R);
OSError(
HIThemeDrawHeader(PaintRect, HeaderDrawInfo, DC.CGContext,
kHIThemeOrientationNormal),
Self, 'DrawHeaderElement', 'HIThemeDrawHeader')
end;
{------------------------------------------------------------------------------
Method: TCarbonThemeServices.DrawRebarElement
Params: DC - Carbon device context
@ -243,6 +269,13 @@ function TCarbonThemeServices.ContentRect(DC: HDC;
Details: TThemedElementDetails; BoundingRect: TRect): TRect;
begin
Result := BoundingRect;
// If you know how to get actual value, please do
// This should be one of theme metric
case Details.Element of
teHeader: InflateRect(Result, -2, -2);
end;
end;
{------------------------------------------------------------------------------
@ -280,7 +313,7 @@ begin
begin
case Details.Element of
teButton: DrawButtonElement(Context, Details, R, ClipRect);
// teHeader: TODO: for grid
teHeader: DrawHeaderElement(Context, Details, R, ClipRect);
teRebar: DrawRebarElement(Context, Details, R, ClipRect);
teToolBar: DrawToolBarElement(Context, Details, R, ClipRect);
end;

View File

@ -1883,8 +1883,10 @@ end;
function TThemeServices.IsDisabled(Details: TThemedElementDetails): Boolean;
begin
// teHeader should not be here, it has no disabled state
Result := False;
if (Details.Element in [teButton, teToolBar, teHeader]) or
if (Details.Element in [teButton, teToolBar]) or
((Details.Element = teRebar) and (Details.Part >= RP_BAND)) then
Result := (Details.State mod 4) = 0; // usual disabled = 4 / 8 / 12
end;