mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-06 08:47:18 +01:00
IDE: Implement Boolean CheckBox editor better in OI. Draw a fake Checkbox when not editing. Requires UseOICheckBox DEFINE
git-svn-id: trunk@37832 -
This commit is contained in:
parent
9f3c8533e3
commit
d4e4a800c9
@ -450,7 +450,8 @@ type
|
||||
procedure ScrollToItem(NewIndex: Integer);
|
||||
procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); override;
|
||||
procedure SetCurrentRowValue(const NewValue: string);
|
||||
procedure SetItemIndexAndFocus(NewItemIndex: integer);
|
||||
procedure SetItemIndexAndFocus(NewItemIndex: integer;
|
||||
WasMouseClick: Boolean = False);
|
||||
|
||||
property BackgroundColor: TColor read FBackgroundColor
|
||||
write SetBackgroundColor default DefBackgroundColor;
|
||||
@ -1929,7 +1930,8 @@ begin
|
||||
SetRowValue;
|
||||
end;
|
||||
|
||||
procedure TOICustomPropertyGrid.SetItemIndexAndFocus(NewItemIndex: integer);
|
||||
procedure TOICustomPropertyGrid.SetItemIndexAndFocus(NewItemIndex: integer;
|
||||
WasMouseClick: Boolean);
|
||||
begin
|
||||
if not InRange(NewItemIndex, 0, FRows.Count - 1) then exit;
|
||||
ItemIndex:=NewItemIndex;
|
||||
@ -1937,7 +1939,9 @@ begin
|
||||
begin
|
||||
SetActiveControl(FCurrentEdit);
|
||||
if (FCurrentEdit is TCustomEdit) then
|
||||
TCustomEdit(FCurrentEdit).SelectAll;
|
||||
TCustomEdit(FCurrentEdit).SelectAll
|
||||
else if WasMouseClick and (FCurrentEdit is TCheckBox) then
|
||||
TCheckBox(FCurrentEdit).Checked:=not TCheckBox(FCurrentEdit).Checked;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -2023,7 +2027,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
SetItemIndexAndFocus(Index);
|
||||
SetItemIndexAndFocus(Index, True);
|
||||
SetCaptureControl(Self);
|
||||
Column := oipgcValue;
|
||||
end;
|
||||
|
||||
@ -33,7 +33,7 @@ unit PropEdits;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, TypInfo, SysUtils,
|
||||
Classes, TypInfo, SysUtils, types,
|
||||
FPCAdds, // for StrToQWord in older fpc versions
|
||||
LCLProc, Forms, Controls, GraphType, StringHashList, ButtonPanel,
|
||||
Graphics, StdCtrls, Buttons, Menus, LCLType, ExtCtrls, LCLIntf,
|
||||
@ -446,6 +446,10 @@ type
|
||||
function OrdValueToVisualValue(OrdValue: longint): string; override;
|
||||
procedure GetValues(Proc: TGetStrProc); override;
|
||||
procedure SetValue(const NewValue: ansistring); override;
|
||||
{$IFDEF UseOICheckBox}
|
||||
procedure PropDrawValue(ACanvas: TCanvas; const ARect: TRect;
|
||||
AState: TPropEditDrawState); override;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{ TInt64PropertyEditor
|
||||
@ -3101,6 +3105,76 @@ begin
|
||||
SetOrdValue(I);
|
||||
end;
|
||||
|
||||
{$IFDEF UseOICheckBox}
|
||||
procedure TBoolPropertyEditor.PropDrawValue(ACanvas: TCanvas; const ARect: TRect;
|
||||
AState: TPropEditDrawState);
|
||||
const
|
||||
FRAME_LIGHT_GRAY = $00E2EFF1;
|
||||
FRAME_GRAY = $0099A8AC;
|
||||
FRAME_DARK_GRAY = $00646F71;
|
||||
var
|
||||
BRect: TRect;
|
||||
DestPos: TPoint;
|
||||
i: Integer;
|
||||
begin
|
||||
// Draw a fake checkbox image (partly copied and modified from CustomDrawn code)
|
||||
// first the square background
|
||||
ACanvas.Pen.Style := psClear;
|
||||
ACanvas.Brush.Style := bsSolid;
|
||||
ACanvas.Brush.Color := clWhite;
|
||||
BRect := ARect;
|
||||
BRect.Right:=BRect.Left+15;
|
||||
Inc(BRect.Top);
|
||||
Dec(BRect.Bottom,3);
|
||||
ACanvas.Rectangle(BRect);
|
||||
// the square frame
|
||||
Inc(BRect.Left);
|
||||
Dec(BRect.Right);
|
||||
Inc(BRect.Top);
|
||||
Dec(BRect.Bottom);
|
||||
// The Frame, except the lower-bottom which is white anyway
|
||||
// outter top-right
|
||||
ACanvas.Pen.Style := psSolid;
|
||||
ACanvas.Pen.Color := FRAME_GRAY;
|
||||
ACanvas.MoveTo(BRect.Left, BRect.Bottom);
|
||||
ACanvas.LineTo(BRect.Left, BRect.Top);
|
||||
ACanvas.LineTo(BRect.Right, BRect.Top);
|
||||
// inner top-right
|
||||
ACanvas.Pen.Color := FRAME_DARK_GRAY;
|
||||
ACanvas.MoveTo(BRect.Left+1, BRect.Bottom-1);
|
||||
ACanvas.LineTo(BRect.Left+1, BRect.Top+1);
|
||||
ACanvas.LineTo(BRect.Right-1, BRect.Top+1);
|
||||
// inner bottom-right
|
||||
ACanvas.Pen.Color := FRAME_LIGHT_GRAY;
|
||||
ACanvas.MoveTo(BRect.Left+1, BRect.Bottom-1);
|
||||
ACanvas.LineTo(BRect.Right-1, BRect.Bottom-1);
|
||||
ACanvas.LineTo(BRect.Right-1, BRect.Top);
|
||||
// outter bottom-right
|
||||
ACanvas.Pen.Color := clWhite;
|
||||
ACanvas.MoveTo(BRect.Left, BRect.Bottom);
|
||||
ACanvas.LineTo(BRect.Right, BRect.Bottom);
|
||||
ACanvas.LineTo(BRect.Right, BRect.Top);
|
||||
// The Tickmark
|
||||
if GetOrdValue <> 0 then begin
|
||||
ACanvas.Pen.Color := clGray;
|
||||
ACanvas.Pen.Style := psSolid;
|
||||
DestPos.X := BRect.Left+3;
|
||||
DestPos.Y := BRect.Top+6;
|
||||
// 4 lines going down and to the right
|
||||
for i := 0 to 3 do
|
||||
ACanvas.Line(DestPos.X+i, DestPos.Y+i, DestPos.X+i, DestPos.Y+3+i);
|
||||
// Now 5 lines going up and to the right
|
||||
for i := 4 to 8 do
|
||||
ACanvas.Line(DestPos.X+i, DestPos.Y+6-i, DestPos.X+i, DestPos.Y+9-i);
|
||||
end;
|
||||
|
||||
// Write text after the image
|
||||
BRect := ARect;
|
||||
Inc(BRect.Left, 17);
|
||||
inherited PropDrawValue(ACanvas, BRect, AState);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{ TInt64PropertyEditor }
|
||||
|
||||
function TInt64PropertyEditor.AllEqual: Boolean;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user