mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 22:20:26 +02:00
LazControls: TCheckBoxThemed improvements. Issue #28517, patch from Vojtech Cihak.
git-svn-id: trunk@49676 -
This commit is contained in:
parent
7d5464d379
commit
e4d78f8e95
@ -14,7 +14,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Controls, StdCtrls, Graphics, Math, ActnList, Forms, Menus,
|
Classes, SysUtils, Controls, StdCtrls, Graphics, Math, ActnList, Forms, Menus,
|
||||||
LCLIntf, LMessages, LCLProc, LResources, LCLType, Themes, Types; //PropEdits,
|
LCLIntf, LMessages, LCLProc, LResources, LCLType, Themes, Types;
|
||||||
|
|
||||||
type
|
type
|
||||||
TCustomCheckBoxThemed = class;
|
TCustomCheckBoxThemed = class;
|
||||||
@ -66,9 +66,6 @@ type
|
|||||||
procedure MouseEnter; override;
|
procedure MouseEnter; override;
|
||||||
procedure MouseLeave; override;
|
procedure MouseLeave; override;
|
||||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||||
class procedure PaintSelf(ACanvas: TCanvas; ACaption: string; ARect: TRect;
|
|
||||||
AState: TCheckBoxState; ARightToLeft, AHovered, APressed, AFocused: Boolean;
|
|
||||||
AAlignment: TLeftRight; AEnabled: Boolean = True);
|
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
procedure TextChanged; override;
|
procedure TextChanged; override;
|
||||||
procedure WMSize(var Message: TLMSize); message LM_SIZE;
|
procedure WMSize(var Message: TLMSize); message LM_SIZE;
|
||||||
@ -78,6 +75,9 @@ type
|
|||||||
cFocusBorder: SmallInt = 2;
|
cFocusBorder: SmallInt = 2;
|
||||||
cIndent: SmallInt = 5;
|
cIndent: SmallInt = 5;
|
||||||
public
|
public
|
||||||
|
class procedure PaintSelf(ACanvas: TCanvas; ACaption: string; ARect: TRect;
|
||||||
|
AState: TCheckBoxState; ARightToLeft, AHovered, APressed, AFocused: Boolean;
|
||||||
|
AAlignment: TLeftRight; AEnabled: Boolean = True);
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
property Alignment: TLeftRight read FAlignment write SetAlignment default taRightJustify;
|
property Alignment: TLeftRight read FAlignment write SetAlignment default taRightJustify;
|
||||||
property AllowGrayed: Boolean read FAllowGrayed write FAllowGrayed default False;
|
property AllowGrayed: Boolean read FAllowGrayed write FAllowGrayed default False;
|
||||||
@ -362,31 +362,18 @@ begin
|
|||||||
aTextSize.cx := Right;
|
aTextSize.cx := Right;
|
||||||
aTextSize.cy := Bottom + 2 * cFocusBorder;
|
aTextSize.cy := Bottom + 2 * cFocusBorder;
|
||||||
end;
|
end;
|
||||||
aCaptionPoint.Y := (ARect.Bottom - aTextSize.cy) div 2;
|
aCaptionPoint.Y := (ARect.Bottom + ARect.Top - aTextSize.cy) div 2;
|
||||||
aCheckBoxPoint.Y := (ARect.Bottom - CheckBoxSize.cy) div 2;
|
aCheckBoxPoint.Y := (ARect.Bottom + ARect.Top - CheckBoxSize.cy) div 2;
|
||||||
case AAlignment of
|
if ARightToLeft xor (AAlignment = taLeftJustify) then begin { Caption is on the Left }
|
||||||
taLeftJustify: begin
|
aCheckBoxPoint.X := ARect.Right - CheckBoxSize.cx;
|
||||||
if not ARightToLeft then begin { Caption is on the Left, aligned to the Left }
|
aCaptionPoint.X := aCheckBoxPoint.X - cIndent - aTextSize.cx;
|
||||||
aCaptionPoint.X := cFocusBorder;
|
end else begin { Caption is on the Right }
|
||||||
aCheckBoxPoint.X := ARect.Right - CheckBoxSize.cx ;//cFocusBorder + aTextSize.cx + cIndent;
|
aCheckBoxPoint.X := ARect.Left;
|
||||||
end else begin { Caption is on the Right, aligned to the Right }
|
aCaptionPoint.X := aCheckBoxPoint.X + cIndent + CheckBoxSize.cx;
|
||||||
aCaptionPoint.X := ARect.Right - aTextSize.cx - cFocusBorder;
|
|
||||||
aCheckBoxPoint.X := 0;//aCaptionPoint.X - cIndent - CheckBoxSize.cx;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
taRightJustify: begin
|
|
||||||
if not ARightToLeft then begin { Caption is on the Right, aligned to the Left }
|
|
||||||
aCaptionPoint.X := CheckBoxSize.cx + cIndent;
|
|
||||||
aCheckBoxPoint.X := 0;
|
|
||||||
end else begin { Caption is on the Left, aligned to the Right }
|
|
||||||
aCheckBoxPoint.X := ARect.Right - CheckBoxSize.cx;
|
|
||||||
aCaptionPoint.X := aCheckBoxPoint.X - cIndent - aTextSize.cx;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
if not ARightToLeft then
|
if not ARightToLeft then
|
||||||
aCheckBoxPoint.X := 0
|
aCheckBoxPoint.X := ARect.Left
|
||||||
else
|
else
|
||||||
aCheckBoxPoint.X := ARect.Right - CheckBoxSize.cx;
|
aCheckBoxPoint.X := ARect.Right - CheckBoxSize.cx;
|
||||||
aCheckBoxPoint.Y := (ARect.Bottom - CheckBoxSize.cy) div 2;
|
aCheckBoxPoint.Y := (ARect.Bottom - CheckBoxSize.cy) div 2;
|
||||||
|
Loading…
Reference in New Issue
Block a user