IdeIntf: Use TCheckBoxThemed as a Boolean property editor in OI. Issue #28518, patch from Vojtech Cihak.

git-svn-id: trunk@49677 -
This commit is contained in:
juha 2015-08-15 21:40:16 +00:00
parent e4d78f8e95
commit 7ef382f0bd
2 changed files with 33 additions and 3 deletions

View File

@ -32,6 +32,7 @@ uses
// FCL // FCL
SysUtils, Types, Classes, TypInfo, FPCanvas, SysUtils, Types, Classes, TypInfo, FPCanvas,
// LCL // LCL
{$IFDEF UseOIThemedCheckBox} CheckBoxThemed, {$ENDIF}
InterfaceBase, Forms, Buttons, Graphics, GraphType, LCLProc, StdCtrls, InterfaceBase, Forms, Buttons, Graphics, GraphType, LCLProc, StdCtrls,
LCLType, LCLIntf, Controls, ComCtrls, ExtCtrls, LMessages, LCLType, LCLIntf, Controls, ComCtrls, ExtCtrls, LMessages,
LazConfigStorage, Menus, Dialogs, Themes, TreeFilterEdit, ObjInspStrConsts, LazConfigStorage, Menus, Dialogs, Themes, TreeFilterEdit, ObjInspStrConsts,
@ -303,7 +304,11 @@ type
ValueEdit: TEdit; ValueEdit: TEdit;
ValueComboBox: TComboBox; ValueComboBox: TComboBox;
{$IFDEF UseOIThemedCheckBox}
ValueCheckBox: TCheckBoxThemed;
{$ELSE}
ValueCheckBox: TCheckBox; ValueCheckBox: TCheckBox;
{$ENDIF}
ValueButton: TSpeedButton; ValueButton: TSpeedButton;
procedure HintTimer(Sender: TObject); procedure HintTimer(Sender: TObject);
@ -961,13 +966,17 @@ begin
OnMouseWheel:=@OnGridMouseWheel; OnMouseWheel:=@OnGridMouseWheel;
end; end;
ValueCheckBox:=TCheckBox.Create(Self); ValueCheckBox:={$IFDEF UseOIThemedCheckBox} TCheckBoxThemed.Create(Self); {$ELSE} TCheckBox.Create(Self); {$ENDIF}
with ValueCheckBox do with ValueCheckBox do
begin begin
Name:='ValueCheckBox'; Name:='ValueCheckBox';
Visible:=false; Visible:=false;
Enabled:=false; Enabled:=false;
AutoSize:=true; // SetBounds does not work for CheckBox, AutoSize does. {$IFDEF UseOIThemedCheckBox}
AutoSize := false;
{$ELSE}
AutoSize := true; // SetBounds does not work for CheckBox, AutoSize does.
{$ENDIF}
Parent:=Self; Parent:=Self;
Top := -30; Top := -30;
OnMouseDown := @ValueControlMouseDown; OnMouseDown := @ValueControlMouseDown;
@ -2081,8 +2090,13 @@ begin
SetActiveControl(FCurrentEdit); SetActiveControl(FCurrentEdit);
if (FCurrentEdit is TCustomEdit) then if (FCurrentEdit is TCustomEdit) then
TCustomEdit(FCurrentEdit).SelectAll TCustomEdit(FCurrentEdit).SelectAll
{$IFDEF UseOIThemedCheckBox}
else if (FCurrentEdit is TCheckBoxThemed) and WasValueClick then
TCheckBoxThemed(FCurrentEdit).Checked:=not TCheckBoxThemed(FCurrentEdit).Checked;
{$ELSE}
else if (FCurrentEdit is TCheckBox) and WasValueClick then else if (FCurrentEdit is TCheckBox) and WasValueClick then
TCheckBox(FCurrentEdit).Checked:=not TCheckBox(FCurrentEdit).Checked; TCheckBox(FCurrentEdit).Checked:=not TCheckBox(FCurrentEdit).Checked;
{$ENDIF}
end; end;
end; end;
@ -2654,7 +2668,7 @@ begin
{$ENDIF} {$ENDIF}
Dec(EditCompRect.Top); Dec(EditCompRect.Top);
end end
else if FCurrentEdit is TCheckBox then else if FCurrentEdit is {$IFDEF UseOICheckBoxThemed} TCheckBoxThemed {$ELSE} TCheckBox {$ENDIF} then
begin // Align CheckBox to the middle vertically begin // Align CheckBox to the middle vertically
TopMargin := (EditCompRect.Bottom - EditCompRect.Top - ValueCheckBox.Height) div 2; TopMargin := (EditCompRect.Bottom - EditCompRect.Top - ValueCheckBox.Height) div 2;
Inc(EditCompRect.Top, TopMargin); Inc(EditCompRect.Top, TopMargin);

View File

@ -23,6 +23,7 @@ interface
uses uses
Classes, TypInfo, SysUtils, types, RtlConsts, Forms, Controls, LCLProc, Classes, TypInfo, SysUtils, types, RtlConsts, Forms, Controls, LCLProc,
{$IFDEF UseOIThemedCheckBox} CheckBoxThemed, {$ENDIF}
GraphType, FPCAdds, // for StrToQWord in older fpc versions GraphType, FPCAdds, // for StrToQWord in older fpc versions
StringHashList, ButtonPanel, Graphics, StdCtrls, Buttons, Menus, LCLType, StringHashList, ButtonPanel, Graphics, StdCtrls, Buttons, Menus, LCLType,
ExtCtrls, ComCtrls, LCLIntf, Dialogs, EditBtn, PropertyStorage, Grids, ValEdit, ExtCtrls, ComCtrls, LCLIntf, Dialogs, EditBtn, PropertyStorage, Grids, ValEdit,
@ -3466,12 +3467,27 @@ procedure TBoolPropertyEditor.PropDrawValue(ACanvas: TCanvas; const ARect: TRect
AState: TPropEditDrawState); AState: TPropEditDrawState);
var var
TxtRect: TRect; TxtRect: TRect;
str: string;
stat: TCheckBoxState;
begin begin
{$IFDEF UseOIThemedCheckBox}
if FPropertyHook.GetCheckboxForBoolean then begin
if GetOrdValue<>0 then begin
stat := cbChecked;
str := '(True)';
end else begin
stat := cbUnchecked;
str := '(False)';
end;
TCheckBoxThemed.PaintSelf(ACanvas, str, ARect, stat, False, False, False, False, taRightJustify);
end;
{$ELSE}
if FPropertyHook.GetCheckboxForBoolean then if FPropertyHook.GetCheckboxForBoolean then
TxtRect := DrawCheckbox(ACanvas, ARect, GetOrdValue<>0) TxtRect := DrawCheckbox(ACanvas, ARect, GetOrdValue<>0)
else else
TxtRect := ARect; TxtRect := ARect;
inherited PropDrawValue(ACanvas, TxtRect, AState); inherited PropDrawValue(ACanvas, TxtRect, AState);
{$ENDIF}
end; end;
{ TInt64PropertyEditor } { TInt64PropertyEditor }