Debian Codegraph @

tools/castle-editor/components/mbColorLib/mbOfficeColorDialog.pas

raw
1 unit mbOfficeColorDialog;
2
3 {$MODE DELPHI}
4
5 interface
6
7 uses
8 LCLIntf, LCLType,
9 SysUtils, Classes, Graphics, Forms, OfficeMoreColorsDialog;
10
11 type
12 TmbOfficeColorDialog = class(TComponent)
13 private
14 FWin: TOfficeMoreColorsWin;
15 FSelColor: TColor;
16 FUseHint: boolean;
17 FMaxHue, FMaxSat, FMaxLum: Integer;
18 FPickerIndex: Integer;
19 public
20 constructor Create(AOwner: TComponent); override;
21 function Execute: boolean; overload;
22 function Execute(AColor: TColor): boolean; overload;
23 published
24 property SelectedColor: TColor read FSelColor write FSelColor default clWhite;
25 property MaxHue: Integer read FMaxHue write FMaxHue default 360;
26 property MaxSaturation: Integer read FMaxSat write FMaxSat default 255;
27 property MaxLuminance: Integer read FMaxLum write FMaxLum default 255;
28 property UseHints: boolean read FUseHint write FUseHint default false;
29 end;
30
31 implementation
32
33 { TmbOfficeColorDialog }
34
35 constructor TmbOfficeColorDialog.Create(AOwner: TComponent);
36 begin
37 inherited;
38 FSelColor := clWhite;
39 FUseHint := false;
40 FMaxHue := 360;
41 FMaxSat := 255;
42 FMaxLum := 255;
43 end;
44
45 function TmbOfficeColorDialog.Execute: boolean;
46 begin
47 Result := Execute(FSelColor);
48 end;
49
50 function TmbOfficeColorDialog.Execute(AColor: TColor): boolean;
51 begin
52 FWin := TOfficeMoreColorsWin.Create(Application);
53 try
54 FWin.ShowHint := FUseHint;
55 FWin.MaxHue := FMaxHue;
56 FWin.MaxSaturation := FMaxSat;
57 FWin.MaxLuminance := FMaxLum;
58 FWin.PickerIndex := FPickerIndex;
59 // FWin.OldSwatch.Color := AColor;
60 FWin.SelectedColor := AColor;
61 Result := (FWin.ShowModal = IdOK);
62 if Result then
63 FSelColor := FWin.SelectedColor //FWin.NewSwatch.Color
64 else
65 FSelColor := clNone;
66 FPickerIndex := FWin.PickerIndex;
67 finally
68 FWin.Free;
69 end;
70 end;
71
72 end.