mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-07 02:45:56 +02:00
LCL: implement TColorDialog.Options. Currently only supported for Win32/Win64 widgetset. Issue #22717.
The default value differs from Delphi (7) for backwards compatibility (CC_FULLOPEN flag was always set in Windows).
This commit is contained in:
parent
f41f2bded2
commit
9077ef32a2
@ -287,12 +287,27 @@ type
|
|||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TColorDialogOption = (
|
||||||
|
cdFullOpen, // Causes the dialog box to display the additional controls that allow the user to create custom colors.
|
||||||
|
cdPreventFullOpen, // Disables the Define Custom Color button.
|
||||||
|
cdShowHelp, // Causes the dialog box to display the Help button.
|
||||||
|
cdSolidColor, // Causes the dialog box to display only solid colors in the set of basic colors.
|
||||||
|
cdAnyColor // Causes the dialog box to display all available colors in the set of basic colors.
|
||||||
|
);
|
||||||
|
TColorDialogOptions = set of TColorDialogOption;
|
||||||
|
|
||||||
|
const
|
||||||
|
DefaultColorDialogOptions = [cdFullOpen]; //for backwards compatibility, probably not Delphi compatible
|
||||||
|
|
||||||
{ TColorDialog }
|
{ TColorDialog }
|
||||||
|
type
|
||||||
|
|
||||||
TColorDialog = class(TCommonDialog)
|
TColorDialog = class(TCommonDialog)
|
||||||
private
|
private
|
||||||
FColor: TColor;
|
FColor: TColor;
|
||||||
FCustomColors: TStrings;
|
FCustomColors: TStrings;
|
||||||
|
FOptions: TColorDialogOptions;
|
||||||
|
|
||||||
procedure SetCustomColors(const AValue: TStrings);
|
procedure SetCustomColors(const AValue: TStrings);
|
||||||
procedure AddDefaultColor(const s: AnsiString);
|
procedure AddDefaultColor(const s: AnsiString);
|
||||||
protected
|
protected
|
||||||
@ -306,6 +321,7 @@ type
|
|||||||
property Color: TColor read FColor write FColor;
|
property Color: TColor read FColor write FColor;
|
||||||
// entry looks like ColorA = FFFF00 ... ColorX = C0C0C0
|
// entry looks like ColorA = FFFF00 ... ColorX = C0C0C0
|
||||||
property CustomColors: TStrings read FCustomColors write SetCustomColors;
|
property CustomColors: TStrings read FCustomColors write SetCustomColors;
|
||||||
|
property Options: TColorDialogOptions read FOptions write FOptions default DefaultColorDialogOptions;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ begin
|
|||||||
// add default colors
|
// add default colors
|
||||||
GetColorValues(@AddDefaultColor);
|
GetColorValues(@AddDefaultColor);
|
||||||
fCompStyle := csColorDialog;
|
fCompStyle := csColorDialog;
|
||||||
|
FOptions := DefaultColorDialogOptions;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TColorDialog.Destroy;
|
destructor TColorDialog.Destroy;
|
||||||
|
@ -114,6 +114,8 @@ type
|
|||||||
{ TWin32WSColorDialog }
|
{ TWin32WSColorDialog }
|
||||||
|
|
||||||
TWin32WSColorDialog = class(TWSColorDialog)
|
TWin32WSColorDialog = class(TWSColorDialog)
|
||||||
|
public
|
||||||
|
class function ColorDialogOptionsToFlags(Options: TColorDialogOptions): DWORD;
|
||||||
published
|
published
|
||||||
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
||||||
class procedure ShowModal(const ACommonDialog: TCommonDialog); override;
|
class procedure ShowModal(const ACommonDialog: TCommonDialog); override;
|
||||||
@ -369,6 +371,18 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class function TWin32WSColorDialog.ColorDialogOptionsToFlags(Options: TColorDialogOptions): DWORD;
|
||||||
|
const
|
||||||
|
CC_ANYCOLOR = $00000100;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
if cdFullOpen in Options then Result := Result or CC_FULLOPEN;
|
||||||
|
if cdPreventFullOpen in Options then Result := Result or CC_PREVENTFULLOPEN;
|
||||||
|
if cdShowHelp in Options then Result := Result or CC_SHOWHELP;
|
||||||
|
if cdSolidColor in Options then Result := Result or CC_SOLIDCOLOR;
|
||||||
|
if cdAnyColor in Options then Result := Result or CC_ANYCOLOR;
|
||||||
|
end;
|
||||||
|
|
||||||
class function TWin32WSColorDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
class function TWin32WSColorDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
||||||
var
|
var
|
||||||
CC: PChooseColor;
|
CC: PChooseColor;
|
||||||
@ -398,7 +412,8 @@ begin
|
|||||||
FillCustomColors;
|
FillCustomColors;
|
||||||
lCustData := LParam(ACommonDialog);
|
lCustData := LParam(ACommonDialog);
|
||||||
lpfnHook := @CCHookProc;
|
lpfnHook := @CCHookProc;
|
||||||
Flags := CC_FULLOPEN or CC_RGBINIT or CC_ENABLEHOOK;
|
Flags := {CC_FULLOPEN or }CC_RGBINIT or CC_ENABLEHOOK;
|
||||||
|
Flags := Flags or ColorDialogOptionsToFlags(ColorDialog.Options);
|
||||||
end;
|
end;
|
||||||
Result := THandle(CC);
|
Result := THandle(CC);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user