- merging part of gtk2themes with gtkthemes

- adjusting splitter drawing (may fix gtk bug with wrong dots alignment)

git-svn-id: trunk@11277 -
This commit is contained in:
paul 2007-06-04 09:38:47 +00:00
parent 7523e184b2
commit d30b9718ac
4 changed files with 48 additions and 137 deletions

View File

@ -715,7 +715,7 @@ begin
begin begin
if (GripperRect.Bottom - GripperRect.Top) > GripperSize then if (GripperRect.Bottom - GripperRect.Top) > GripperSize then
begin begin
GripperRect.Top := (GripperRect.Top + GripperRect.Bottom - GripperSize) shr 1; GripperRect.Top := (GripperRect.Top + GripperRect.Bottom - GripperSize) div 2;
GripperRect.Bottom := GripperRect.Top + GripperSize; GripperRect.Bottom := GripperRect.Top + GripperSize;
end; end;
end end
@ -723,12 +723,12 @@ begin
begin begin
if (GripperRect.Right - GripperRect.Left) > GripperSize then if (GripperRect.Right - GripperRect.Left) > GripperSize then
begin begin
GripperRect.Left := (GripperRect.Left + GripperRect.Right - GripperSize) shr 1; GripperRect.Left := (GripperRect.Left + GripperRect.Right - GripperSize) div 2;
GripperRect.Right := GripperRect.Left + GripperSize; GripperRect.Right := GripperRect.Left + GripperSize;
end; end;
end; end;
ThemeServices.DrawElement(Canvas.Handle, GripperDetails, GripperRect, nil); ThemeServices.DrawElement(Canvas.Handle, GripperDetails, GripperRect, @GripperRect);
end; end;
procedure TCustomSplitter.MouseEnter; procedure TCustomSplitter.MouseEnter;

View File

@ -188,7 +188,7 @@ begin
Result.IsHot:= Result.State = GTK_STATE_PRELIGHT; Result.IsHot:= Result.State = GTK_STATE_PRELIGHT;
Result.Detail := 'treeview'; Result.Detail := 'button';
Result.Painter := gptBox; Result.Painter := gptBox;
end; end;
teToolBar: teToolBar:
@ -264,7 +264,9 @@ begin
Result := BoundingRect; Result := BoundingRect;
StyleParams := GetGtkStyleParams(DC, Details); StyleParams := GetGtkStyleParams(DC, Details);
if StyleParams.Style <> nil then if StyleParams.Style <> nil then
InflateRect(Result, -1, -1); InflateRect(Result,
-StyleParams.Style^.{$ifndef gtk2}klass^.{$endif}xthickness,
-StyleParams.Style^.{$ifndef gtk2}klass^.{$endif}ythickness);
end; end;
procedure TGtkThemeServices.DrawElement(DC: HDC; procedure TGtkThemeServices.DrawElement(DC: HDC;

View File

@ -21,7 +21,6 @@ type
protected protected
function GetGtkStyleParams(DC: HDC; Details: TThemedElementDetails): TGtkStyleParams; override; function GetGtkStyleParams(DC: HDC; Details: TThemedElementDetails): TGtkStyleParams; override;
public public
function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override;
end; end;
implementation implementation
@ -33,66 +32,11 @@ function TGtk2ThemeServices.GetGtkStyleParams(DC: HDC;
var var
ClientWidget: PGtkWidget; ClientWidget: PGtkWidget;
begin begin
Result.Style := nil; Result := inherited GetGtkStyleParams(DC, Details);
if GTK2WidgetSet.IsValidDC(DC) then
with TDeviceContext(DC) do
begin
Result.Widget := DCWidget;
ClientWidget := GetFixedWidget(Result.Widget);
if ClientWidget <> nil then
Result.Widget := ClientWidget;
Result.Window := Drawable;
Result.Origin := GetDCOffset(TDeviceContext(DC));
Result.Style := gtk_widget_get_style(Result.Widget);
if Result.Style = nil then
Result.Style := gtk_widget_get_default_style();
Result.Painter := gptDefault;
Result.State := GTK_STATE_NORMAL;
Result.Detail := '';
Result.Shadow := GTK_SHADOW_NONE;
Result.IsHot := False;
// override some styles
if Result.Style <> nil then
case Details.Element of case Details.Element of
teButton:
begin
case Details.Part of
BP_PUSHBUTTON:
begin
Result.State := GtkButtonMap[Details.State];
if Details.State = PBS_PRESSED then
Result.Shadow := GTK_SHADOW_IN
else
Result.Shadow := GTK_SHADOW_OUT;
Result.IsHot:= Result.State = GTK_STATE_PRELIGHT;
Result.Detail := 'button';
Result.Painter := gptBox;
end;
BP_RADIOBUTTON:
begin
Result.State := GtkRadioMap[Details.State];
if Details.State >= RBS_CHECKEDNORMAL then
Result.Shadow := GTK_SHADOW_IN
else
Result.Shadow := GTK_SHADOW_OUT;
Result.Detail := 'radiobutton';
Result.Painter := gptOption;
end;
BP_CHECKBOX:
begin
Result.State := GtkRadioMap[Details.State];
Result.Detail := 'checkbutton';
if Details.State >= CBS_CHECKEDNORMAL then
Result.Shadow := GTK_SHADOW_IN
else
Result.Shadow := GTK_SHADOW_OUT;
Result.Painter := gptCheck;
end;
end;
end;
teHeader: teHeader:
begin begin
Result.State := GtkButtonMap[Details.State]; Result.State := GtkButtonMap[Details.State];
@ -106,30 +50,6 @@ begin
Result.Detail := 'treeview'; Result.Detail := 'treeview';
Result.Painter := gptBox; Result.Painter := gptBox;
end; end;
teToolBar:
begin
case Details.Part of
TP_BUTTON:
begin
Result.State := GtkButtonMap[Details.State];
if Details.State in [TS_PRESSED, TS_CHECKED, TS_HOTCHECKED] then
Result.Shadow := GTK_SHADOW_IN
else
if Details.State in [TS_HOT] then
Result.Shadow := GTK_SHADOW_ETCHED_IN
else
Result.Shadow := GTK_SHADOW_NONE;
Result.IsHot := Details.State in [TS_HOT, TS_HOTCHECKED];
Result.Detail := 'togglebutton';
if Result.Shadow = GTK_SHADOW_NONE then
Result.Painter := gptNone
else
Result.Painter := gptBox;
end;
end;
end;
teRebar: teRebar:
begin begin
case Details.Part of case Details.Part of
@ -155,20 +75,6 @@ begin
end; end;
end; end;
end; end;
end;
function TGtk2ThemeServices.ContentRect(DC: HDC;
Details: TThemedElementDetails; BoundingRect: TRect): TRect;
var
StyleParams: TGtkStyleParams;
begin
Result := BoundingRect;
StyleParams := GetGtkStyleParams(DC, Details);
if StyleParams.Style <> nil then
InflateRect(Result,
-StyleParams.Style^.xthickness,
-StyleParams.Style^.ythickness);
end;
end. end.

View File

@ -1744,6 +1744,9 @@ end;
function TThemeServices.ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; function TThemeServices.ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect;
begin begin
Result := BoundingRect; Result := BoundingRect;
if Details.Element in [teHeader, teButton] then
InflateRect(Result, -2, -2)
else
InflateRect(Result, -1, -1); InflateRect(Result, -1, -1);
end; end;