diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2012-07-06 12:25:33 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2012-07-06 12:25:33 +0100 |
commit | dae265d4b311f55e77fdde2d5fa29f6e239bbfc1 (patch) | |
tree | 89948a34efba728a3ea03aa0e6e1eeee81951afe | |
parent | c8bd7e968ed5fdc6276aff17ab0aef5855525d4a (diff) | |
download | fpGUI-dae265d4b311f55e77fdde2d5fa29f6e239bbfc1.tar.xz |
uidesigner: improves Color Property Editor display in Object Inspector window
The Object Inspector now paints a square with the selected color, so it is
much easier to see at a glance what colors are choosen in the various
properties.
-rw-r--r-- | uidesigner/vfdprops.pas | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/uidesigner/vfdprops.pas b/uidesigner/vfdprops.pas index b0c659fe..faf4d858 100644 --- a/uidesigner/vfdprops.pas +++ b/uidesigner/vfdprops.pas @@ -25,6 +25,7 @@ uses Classes, SysUtils, fpg_base, + fpg_main, fpg_widget, vfdwidgetclass, fpg_edit, @@ -96,6 +97,7 @@ type TPropertyColor = class(TVFDWidgetProperty) public + procedure DrawValue(wg: TfpgWidget; Canvas: TfpgCanvas; rect: TfpgRect; flags: integer); override; function ParseSourceLine(wg: TfpgWidget; const line: string): boolean; override; function GetPropertySource(wg: TfpgWidget; const ident: string): string; override; function GetValueText(wg: TfpgWidget): string; override; @@ -174,7 +176,6 @@ uses TypInfo, vfdformparser, vfdeditors, - fpg_main, fpg_dialogs; @@ -794,6 +795,34 @@ end; { TPropertyColor } +procedure TPropertyColor.DrawValue(wg: TfpgWidget; Canvas: TfpgCanvas; + rect: TfpgRect; flags: integer); +const + BLOCK_SIZE = 10; { for margin and square size } +var + s: TfpgString; + dx: integer; + i: integer; + c: TfpgColor; +begin + inherited DrawValue(wg, Canvas, rect, flags); + try + s := GetValueText(wg); + except + on E: Exception do + debugln('Detected an error: ', E.Message); + end; + dx := Canvas.Font.TextWidth(s) + BLOCK_SIZE; + i := GetOrdProp(wg, Name); + c := fpgColorToRGB(TfpgColor(i)); + { paint the color square } + Canvas.Color := c; + Canvas.FillRectangle(rect.Left+dx, rect.Top+((rect.Height-BLOCK_SIZE) div 2), BLOCK_SIZE, BLOCK_SIZE); + { paint a block border around the square } + Canvas.Color := clBlack; + Canvas.DrawRectangle(rect.Left+dx, rect.Top+((rect.Height-BLOCK_SIZE) div 2), BLOCK_SIZE, BLOCK_SIZE); +end; + function TPropertyColor.ParseSourceLine(wg: TfpgWidget; const line: string): boolean; var s: string; |