mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 16:48:27 +02:00
lcl: Themes
- redo TThemeServices.GetDetailSize to return TSize instead of Integer - improve toolbutton drawing git-svn-id: trunk@20213 -
This commit is contained in:
parent
a2f39228ab
commit
597eb84d8c
@ -42,7 +42,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, LConvEncoding, Forms, Controls, LCLType, LCLIntf,
|
||||
Graphics, GraphType, StdCtrls, ExtCtrls, Buttons, FileUtil, Dialogs,
|
||||
Graphics, GraphType, StdCtrls, ExtCtrls, Buttons, FileUtil, Dialogs, Types,
|
||||
LResources, Laz_XMLCfg, InterfaceBase, Themes, ComCtrls,
|
||||
LazarusIDEStrConsts, TransferMacros, LazConf, IDEProcs, DialogProcs,
|
||||
IDEWindowIntf, IDEMsgIntf, InputHistory, ExtToolDialog, ExtToolEditDlg,
|
||||
@ -902,13 +902,14 @@ procedure TConfigureBuildLazarusDlg.ItemsListBoxDrawItem(Control: TWinControl;
|
||||
var
|
||||
ButtonState: TThemedButton;
|
||||
ButtonDetails: TThemedElementDetails;
|
||||
x, RadioSize: Integer;
|
||||
x: Integer;
|
||||
ButtonRect: TRect;
|
||||
CurItem: TBuildLazarusItem;
|
||||
CurStr: String;
|
||||
TxtH: Integer;
|
||||
CurRect: TRect;
|
||||
mm: TMakeMode;
|
||||
RadioSize: TSize;
|
||||
begin
|
||||
if (Index<0) or (Index>=Options.Count) then exit;
|
||||
CurItem:=Options.Items[Index];
|
||||
@ -937,12 +938,12 @@ begin
|
||||
ItemsListBox.Canvas.FillRect(ButtonRect);
|
||||
|
||||
RadioSize := ThemeServices.GetDetailSize(ButtonDetails);
|
||||
if (RadioSize <> -1) then
|
||||
if (RadioSize.cx <> -1) and (RadioSize.cy <> -1) then
|
||||
begin
|
||||
ButtonRect.Left := (ButtonRect.Left + ButtonRect.Right - RadioSize) div 2;
|
||||
ButtonRect.Right := ButtonRect.Left + RadioSize;
|
||||
ButtonRect.Top := (ButtonRect.Top + ButtonRect.Bottom - RadioSize) div 2;
|
||||
ButtonRect.Bottom := ButtonRect.Top + RadioSize;
|
||||
ButtonRect.Left := (ButtonRect.Left + ButtonRect.Right - RadioSize.cx) div 2;
|
||||
ButtonRect.Right := ButtonRect.Left + RadioSize.cx;
|
||||
ButtonRect.Top := (ButtonRect.Top + ButtonRect.Bottom - RadioSize.cy) div 2;
|
||||
ButtonRect.Bottom := ButtonRect.Top + RadioSize.cy;
|
||||
end;
|
||||
|
||||
ThemeServices.DrawElement(ItemsListBox.Canvas.GetUpdatedHandle([csBrushValid,csPenValid]), ButtonDetails, ButtonRect);
|
||||
|
@ -112,9 +112,9 @@ begin
|
||||
if (AEditor <> nil) and (AEditor <> PrevEditor) then
|
||||
begin
|
||||
if PrevEditor <> nil then
|
||||
PrevEditor.Parent := nil;
|
||||
PrevEditor.Visible := False;
|
||||
//PrevEditor.Parent := nil;
|
||||
|
||||
AEditor.Parent := Self;
|
||||
AEditor.Anchors := [akLeft, akTop, akRight, akBottom];
|
||||
AEditor.AnchorSideLeft.Side := asrBottom;
|
||||
AEditor.AnchorSideLeft.Control := CategoryTree;
|
||||
@ -124,6 +124,7 @@ begin
|
||||
AEditor.AnchorSideBottom.Side := asrTop;
|
||||
AEditor.AnchorSideBottom.Control := ButtonPanel;
|
||||
AEditor.BorderSpacing.Around := 6;
|
||||
//AEditor.Parent := Self;
|
||||
AEditor.Visible := True;
|
||||
|
||||
PrevEditor := AEditor;
|
||||
@ -281,6 +282,8 @@ begin
|
||||
Instance.OnSaveIDEOptions := @SaveIDEOptions;
|
||||
Instance.Setup(Self);
|
||||
Instance.Tag := Rec^.Items[j]^.Index;
|
||||
Instance.Visible := False;
|
||||
Instance.Parent := Self;
|
||||
|
||||
if Rec^.Items[j]^.Parent = NoParent then
|
||||
ItemParent := GroupNode
|
||||
|
@ -33,7 +33,7 @@ interface
|
||||
{$endif}
|
||||
|
||||
uses
|
||||
SysUtils, Classes, LCLStrConsts, LCLType, LCLProc, LResources, Controls,
|
||||
SysUtils, Types, Classes, LCLStrConsts, LCLType, LCLProc, LResources, Controls,
|
||||
Forms, StdCtrls, lMessages, GraphType, Graphics, LCLIntf, CustomTimer, Themes,
|
||||
LCLClasses, Menus, popupnotifier;
|
||||
|
||||
|
@ -3488,17 +3488,18 @@ const
|
||||
(tbCheckBoxUncheckedNormal, tbCheckBoxCheckedNormal, tbCheckBoxMixedNormal);
|
||||
var
|
||||
ChkBitmap: TBitmap;
|
||||
XPos,YPos,CSize: Integer;
|
||||
XPos,YPos: Integer;
|
||||
details: TThemedElementDetails;
|
||||
PaintRect: TRect;
|
||||
CSize: TSize;
|
||||
begin
|
||||
if (TitleStyle=tsNative) and not assigned(OnUserCheckboxBitmap) then begin
|
||||
Details := ThemeServices.GetElementDetails(arrtb[AState]);
|
||||
CSize:= ThemeServices.GetDetailSize(Details);
|
||||
CSize := ThemeServices.GetDetailSize(Details);
|
||||
with PaintRect do begin
|
||||
Left := Trunc((aRect.Left + aRect.Right - CSize)/2);
|
||||
Top := Trunc((aRect.Top + aRect.Bottom - CSize)/2);
|
||||
PaintRect := Bounds(Left, Top, CSize, CSize);
|
||||
Left := Trunc((aRect.Left + aRect.Right - CSize.cx)/2);
|
||||
Top := Trunc((aRect.Top + aRect.Bottom - CSize.cy)/2);
|
||||
PaintRect := Bounds(Left, Top, CSize.cx, CSize.cy);
|
||||
end;
|
||||
ThemeServices.DrawElement(Canvas.Handle, Details, PaintRect, nil);
|
||||
end else begin
|
||||
|
@ -756,7 +756,7 @@ procedure TCustomSplitter.Paint;
|
||||
GripperRect: TRect;
|
||||
BgPart: TThemedRebar;
|
||||
BgDetails, GripperDetails: TThemedElementDetails;
|
||||
GripperSize: Integer;
|
||||
GripperSize: TSize;
|
||||
begin
|
||||
GripperDetails := ThemeServices.GetElementDetails(GripperDetailsPart[ResizeAnchor in [akLeft,akRight]]);
|
||||
|
||||
@ -777,22 +777,22 @@ procedure TCustomSplitter.Paint;
|
||||
|
||||
GripperRect := ARect;
|
||||
GripperSize := ThemeServices.GetDetailSize(GripperDetails);
|
||||
if GripperSize <> -1 then
|
||||
if (GripperSize.cx <> -1) or (GripperSize.cy <> -1) then
|
||||
begin
|
||||
if ResizeAnchor in [akLeft,akRight] then
|
||||
begin
|
||||
if (GripperRect.Bottom - GripperRect.Top) > GripperSize then
|
||||
if (GripperRect.Bottom - GripperRect.Top) > GripperSize.cy then
|
||||
begin
|
||||
GripperRect.Top := (GripperRect.Top + GripperRect.Bottom - GripperSize) div 2;
|
||||
GripperRect.Bottom := GripperRect.Top + GripperSize;
|
||||
GripperRect.Top := (GripperRect.Top + GripperRect.Bottom - GripperSize.cy) div 2;
|
||||
GripperRect.Bottom := GripperRect.Top + GripperSize.cy;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if (GripperRect.Right - GripperRect.Left) > GripperSize then
|
||||
if (GripperRect.Right - GripperRect.Left) > GripperSize.cx then
|
||||
begin
|
||||
GripperRect.Left := (GripperRect.Left + GripperRect.Right - GripperSize) div 2;
|
||||
GripperRect.Right := GripperRect.Left + GripperSize;
|
||||
GripperRect.Left := (GripperRect.Left + GripperRect.Right - GripperSize.cx) div 2;
|
||||
GripperRect.Right := GripperRect.Left + GripperSize.cx;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -55,6 +55,8 @@ end;
|
||||
Constructor for the class.
|
||||
------------------------------------------------------------------------------}
|
||||
constructor TToolbar.Create(TheOwner : TComponent);
|
||||
var
|
||||
Details: TThemedElementDetails;
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
ControlStyle := [csAcceptsControls, csCaptureMouse, csClickEvents,
|
||||
@ -62,7 +64,8 @@ begin
|
||||
FFlat := True;
|
||||
FButtonWidth := 23;
|
||||
FButtonHeight := 22;
|
||||
FDropDownWidth := 12;
|
||||
Details := ThemeServices.GetElementDetails(ttbSplitButtonDropDownNormal);
|
||||
FDropDownWidth := ThemeServices.GetDetailSize(Details).cx;
|
||||
FNewStyle := True;
|
||||
FWrapable := True;
|
||||
FButtons := TList.Create;
|
||||
|
@ -164,6 +164,8 @@ procedure TToolButton.Paint;
|
||||
if (tbfArrowPressed in FToolButtonFlags) and FMouseInControl and Enabled then
|
||||
ArrowState := ttbSplitButtonDropDownPressed;
|
||||
Details := ThemeServices.GetElementDetails(ArrowState);
|
||||
if ((FToolBar <> nil) and not FToolBar.Flat) and (Details.State in [1, 4]) then
|
||||
Details.State := 2;
|
||||
ThemeServices.DrawElement(Canvas.Handle, Details, DropDownButtonRect);
|
||||
end;
|
||||
|
||||
|
@ -46,7 +46,7 @@ type
|
||||
|
||||
function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override;
|
||||
function HasTransparentParts(Details: TThemedElementDetails): Boolean; override;
|
||||
function GetDetailSize(Details: TThemedElementDetails): Integer; override;
|
||||
function GetDetailSize(Details: TThemedElementDetails): TSize; override;
|
||||
function GetOption(AOption: TThemeOption): Integer; override;
|
||||
end;
|
||||
|
||||
@ -417,12 +417,11 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function TCarbonThemeServices.GetDetailSize(Details: TThemedElementDetails
|
||||
): Integer;
|
||||
function TCarbonThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
|
||||
begin
|
||||
if (Details.Element = teTreeView) and (Details.Part = TVP_GLYPH) then
|
||||
begin
|
||||
Result := Max(GetCarbonThemeMetric(kThemeMetricDisclosureTriangleWidth),
|
||||
Result := Size(GetCarbonThemeMetric(kThemeMetricDisclosureTriangleWidth),
|
||||
GetCarbonThemeMetric(kThemeMetricDisclosureTriangleHeight));
|
||||
end
|
||||
else
|
||||
|
@ -82,9 +82,9 @@ type
|
||||
function ThemedControlsEnabled: Boolean; override;
|
||||
|
||||
procedure InternalDrawParentBackground(Window: HWND; Target: HDC; Bounds: PRect); override;
|
||||
function GetBaseDetailsSize(Details: TThemedElementDetails): Integer;
|
||||
function GetBaseDetailsSize(Details: TThemedElementDetails): TSize;
|
||||
public
|
||||
function GetDetailSize(Details: TThemedElementDetails): Integer; override;
|
||||
function GetDetailSize(Details: TThemedElementDetails): TSize; override;
|
||||
|
||||
procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect); override;
|
||||
procedure DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST; Index: Integer); override;
|
||||
@ -604,17 +604,17 @@ begin
|
||||
// ?
|
||||
end;
|
||||
|
||||
function TGtkThemeServices.GetBaseDetailsSize(Details: TThemedElementDetails): Integer;
|
||||
function TGtkThemeServices.GetBaseDetailsSize(Details: TThemedElementDetails): TSize;
|
||||
begin
|
||||
Result := inherited GetDetailSize(Details);
|
||||
end;
|
||||
|
||||
function TGtkThemeServices.GetDetailSize(Details: TThemedElementDetails): Integer;
|
||||
function TGtkThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
|
||||
begin
|
||||
case Details.Element of
|
||||
teRebar :
|
||||
if Details.Part in [RP_GRIPPER, RP_GRIPPERVERT] then
|
||||
Result := -1;
|
||||
Result := Size(-1, -1);
|
||||
else
|
||||
Result := GetBaseDetailsSize(Details);
|
||||
end;
|
||||
|
@ -21,7 +21,7 @@ type
|
||||
protected
|
||||
function GetGtkStyleParams(DC: HDC; Details: TThemedElementDetails; AIndex: Integer): TGtkStyleParams; override;
|
||||
public
|
||||
function GetDetailSize(Details: TThemedElementDetails): Integer; override;
|
||||
function GetDetailSize(Details: TThemedElementDetails): TSize; override;
|
||||
function GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean; override;
|
||||
function GetOption(AOption: TThemeOption): Integer; override;
|
||||
end;
|
||||
@ -112,13 +112,13 @@ begin
|
||||
else
|
||||
Result.Expander := GTK_EXPANDER_EXPANDED;
|
||||
|
||||
Result.ExpanderSize := GetDetailSize(Details);
|
||||
Result.ExpanderSize := GetDetailSize(Details).cx;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TGtk2ThemeServices.GetDetailSize(Details: TThemedElementDetails): Integer;
|
||||
function TGtk2ThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
|
||||
var
|
||||
AValue: TGValue;
|
||||
begin
|
||||
@ -127,7 +127,7 @@ begin
|
||||
FillChar(AValue, SizeOf(AValue), 0);
|
||||
g_value_init(@AValue, G_TYPE_INT);
|
||||
gtk_widget_style_get_property(GetStyleWidget(lgsTreeView), 'expander-size', @AValue);
|
||||
Result := AValue.data[0].v_int;
|
||||
Result := Size(AValue.data[0].v_int, AValue.data[0].v_int);
|
||||
end
|
||||
else
|
||||
Result := GetBaseDetailsSize(Details);
|
||||
|
@ -58,7 +58,7 @@ type
|
||||
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;
|
||||
function GetDetailSize(Details: TThemedElementDetails): Integer; override;
|
||||
function GetDetailSize(Details: TThemedElementDetails): TSize; override;
|
||||
function GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean; override;
|
||||
|
||||
function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect; override;
|
||||
@ -322,12 +322,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQtThemeServices.GetDetailSize(Details: TThemedElementDetails): Integer;
|
||||
function TQtThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
|
||||
begin
|
||||
case Details.Element of
|
||||
teRebar :
|
||||
if Details.Part in [RP_GRIPPER, RP_GRIPPERVERT] then
|
||||
Result := -1;
|
||||
Result := Size(-1, -1);
|
||||
else
|
||||
Result := inherited;
|
||||
end;
|
||||
|
@ -34,7 +34,7 @@ type
|
||||
public
|
||||
destructor Destroy; override;
|
||||
|
||||
function GetDetailSize(Details: TThemedElementDetails): Integer; override;
|
||||
function GetDetailSize(Details: TThemedElementDetails): TSize; override;
|
||||
function GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean; override;
|
||||
function GetOption(AOption: TThemeOption): Integer; override;
|
||||
|
||||
@ -131,19 +131,19 @@ begin
|
||||
FreeThemeLibrary;
|
||||
end;
|
||||
|
||||
function TWin32ThemeServices.GetDetailSize(Details: TThemedElementDetails): Integer;
|
||||
function TWin32ThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
|
||||
begin
|
||||
// GetThemeInt(Theme[Details.Element], Details.Part, Details.State, TMT_HEIGHT, Result);
|
||||
// does not work for some reason
|
||||
if ThemesEnabled then
|
||||
begin
|
||||
if (Details.Element = teToolBar) and (Details.Part = TP_SPLITBUTTONDROPDOWN) then
|
||||
Result := 12
|
||||
Result.cx := 12
|
||||
else
|
||||
Result:=inherited GetDetailSize(Details);
|
||||
Result := inherited GetDetailSize(Details);
|
||||
end
|
||||
else
|
||||
Result:=inherited GetDetailSize(Details);
|
||||
Result := inherited GetDetailSize(Details);
|
||||
end;
|
||||
|
||||
function TWin32ThemeServices.GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean;
|
||||
|
@ -459,7 +459,7 @@ type
|
||||
function GetElementDetails(Detail: TThemedTreeview): TThemedElementDetails; overload;
|
||||
function GetElementDetails(Detail: TThemedWindow): TThemedElementDetails; overload;
|
||||
|
||||
function GetDetailSize(Details: TThemedElementDetails): Integer; virtual;
|
||||
function GetDetailSize(Details: TThemedElementDetails): TSize; virtual;
|
||||
function GetStockImage(StockID: LongInt; out Image, Mask: HBitmap): Boolean; virtual;
|
||||
function GetOption(AOption: TThemeOption): Integer; virtual;
|
||||
|
||||
@ -1766,24 +1766,27 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TThemeServices.GetDetailSize(Details: TThemedElementDetails): Integer;
|
||||
function TThemeServices.GetDetailSize(Details: TThemedElementDetails): TSize;
|
||||
begin
|
||||
// default values here
|
||||
// -1 mean that we dont know size of detail
|
||||
Result := -1;
|
||||
Result := Size(-1, -1);
|
||||
case Details.Element of
|
||||
teButton:
|
||||
if Details.Part in [BP_RADIOBUTTON, BP_CHECKBOX] then
|
||||
Result := 13;
|
||||
Result := Size(13, 13);
|
||||
teRebar:
|
||||
if Details.Part in [RP_GRIPPER, RP_GRIPPERVERT] then
|
||||
Result := 30;
|
||||
if Details.Part = RP_GRIPPER then
|
||||
Result.cy := 30
|
||||
else
|
||||
if Details.Part = RP_GRIPPERVERT then
|
||||
Result.cx := 30;
|
||||
teToolBar:
|
||||
if Details.Part = TP_SPLITBUTTONDROPDOWN then
|
||||
Result := 10;
|
||||
Result.cx := 12;
|
||||
teTreeView:
|
||||
if Details.Part = TVP_GLYPH then
|
||||
Result := 9;
|
||||
Result := Size(9, 9);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1851,17 +1854,17 @@ procedure TThemeServices.DrawElement(DC: HDC; Details: TThemedElementDetails; co
|
||||
OldBrush, Brush: HBrush;
|
||||
begin
|
||||
ArrowRect := DropDownButtonRect;
|
||||
ArrowRect.Left:=DropDownButtonRect.Left+2;
|
||||
ArrowRect.Right:=Max(DropDownButtonRect.Right - 3, ArrowRect.Left);
|
||||
ArrowRect.Top:=(DropDownButtonRect.Top+DropDownButtonRect.Bottom
|
||||
+ArrowRect.Left-ArrowRect.Right) div 2;
|
||||
ArrowRect.Bottom:=ArrowRect.Top-ArrowRect.Left+ArrowRect.Right;
|
||||
Points[1] := Point(ArrowRect.Left,ArrowRect.Top);
|
||||
Points[2] := Point((ArrowRect.Left+ArrowRect.Right) div 2,ArrowRect.Bottom);
|
||||
Points[3] := Point(ArrowRect.Right,ArrowRect.Top);
|
||||
ArrowRect.Left := DropDownButtonRect.Left + 3;
|
||||
ArrowRect.Right := Max(DropDownButtonRect.Right - 3, ArrowRect.Left);
|
||||
ArrowRect.Top := (DropDownButtonRect.Top + DropDownButtonRect.Bottom +
|
||||
ArrowRect.Left - ArrowRect.Right) div 2;
|
||||
ArrowRect.Bottom := ArrowRect.Top + Min(2, ArrowRect.Right - ArrowRect.Left);
|
||||
Points[1] := Point(ArrowRect.Left, ArrowRect.Top);
|
||||
Points[2] := Point((ArrowRect.Left + ArrowRect.Right) div 2, ArrowRect.Bottom);
|
||||
Points[3] := Point(ArrowRect.Right, ArrowRect.Top);
|
||||
Brush := CreateSolidBrush(clBlack);
|
||||
OldBrush := SelectObject(DC, Brush);
|
||||
Polygon(Dc, @Points[1], 3, false);
|
||||
Polygon(Dc, @Points[1], 3, False);
|
||||
DeleteObject(SelectObject(DC, OldBrush));
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user