diff --git a/components/mbColorLib/OfficeMoreColorsDialog.pas b/components/mbColorLib/OfficeMoreColorsDialog.pas index 1fcb7a044..1c19a606d 100644 --- a/components/mbColorLib/OfficeMoreColorsDialog.pas +++ b/components/mbColorLib/OfficeMoreColorsDialog.pas @@ -79,6 +79,9 @@ type ERed, EGreen, EBlue: TSpinEdit; EHue, ESat, ELum: TSpinEdit; {$ENDIF} + FMaxHue: Integer; + FMaxSat: Integer; + FMaxLum: Integer; FLockChange: Integer; function GetShowHint: Boolean; procedure SetAllCustom(c: TColor); @@ -87,6 +90,10 @@ type protected procedure CreateParams(var Params: TCreateParams); override; // procedure CreateWnd; override; + public + property MaxHue: Integer read FMaxHue write FMaxHue; + property MaxSaturation: Integer read FMaxSat write FMaxSat; + property MaxLuminance: Integer read FMaxLum write FMaxLum; published property ShowHint: Boolean read GetShowHint write SetShowHint; end; @@ -176,7 +183,7 @@ begin try HSL.Hue := EHue.Value; SLH.Hue := EHue.Value; - NewSwatch.Color := HSLRangeToRGB(EHue.Value, ESat.Value, ELum.Value); + NewSwatch.Color := HSLToRGB(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELum.Value/FMaxLum); finally dec(FLockChange); end; @@ -190,7 +197,7 @@ begin inc(FLockChange); try HSL.Luminance := ELum.Value; - NewSwatch.Color := HSLRangeToRGB(EHue.Value, ESat.Value, ELum.Value); + NewSwatch.Color := HSLToRGB(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELum.Value/FMaxLum); finally dec(FLockChange); end; @@ -220,7 +227,7 @@ begin try HSL.Saturation := ESat.Value; SLH.Saturation := ESat.Value; - NewSwatch.Color := HSLRangeToRGB(EHue.Value, ESat.Value, ELum.Value); + NewSwatch.Color := HSLToRGB(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELum.Value/FMaxLum); finally dec(FLockChange); end; @@ -229,6 +236,22 @@ end; procedure TOfficeMoreColorsWin.FormCreate(Sender: TObject); begin + FMaxHue := 359; + FMaxSat := 240; + FMaxLum := 240; + + HSL.MaxHue := FMaxHue; + HSL.MaxSaturation := FMaxSat; + HSL.MaxLuminance := FMaxLum; + + HSLRing.MaxHue := FMaxHue; + HSLRing.MaxSaturation := FMaxSat; + HSLRing.MaxLuminance := FMaxLum; + + SLH.MaxHue := FMaxHue; + SLH.MaxSaturation := FMaxSat; + SLH.MaxLuminance := FMaxLum; + {$IFDEF mbXP_Lib} ERed := TmbXPSpinEdit.CreateParented(Custom.Handle); EGreen := TmbXPSpinEdit.CreateParented(Custom.Handle); @@ -296,7 +319,7 @@ begin Top := ERed.Top; Alignment := taRightJustify; Anchors := [akLeft, akBottom]; - MaxValue := MaxHue; + MaxValue := FMaxHue; MinValue := 0; Value := 0; OnChange := @EHueChange; @@ -311,7 +334,7 @@ begin Top := EGreen.Top; Alignment := taRightJustify; Anchors := [akLeft, akBottom]; - MaxValue := MaxSat; + MaxValue := FMaxSat; MinValue := 0; Value := 0; OnChange := @ESatChange; @@ -326,7 +349,7 @@ begin Top := EBlue.Top; Alignment := taRightJustify; Anchors := [akLeft, akBottom]; - MaxValue := MaxLum; + MaxValue := FMaxLum; MinValue := 0; Value := 0; OnChange := @ELumChange; @@ -445,14 +468,12 @@ var begin if (ERed = nil) or (EGreen = nil) or (EBlue = nil) or (EHue = nil) or (ESat = nil) or (ELum = nil) or - (PickerNotebook = nil) or (HSL = nil) or (HSLRing = nil) or (SLH = nil) or - (FLockChange > 0) + (PickerNotebook = nil) or (HSL = nil) or (HSLRing = nil) or (SLH = nil) then exit; NewSwatch.Color := c; -// inc(FLockChange); r := GetRValue(c); g := GetGValue(c); b := GetBValue(c); @@ -483,8 +504,6 @@ begin EHue.Value := H * HSL.MaxHue; ESat.Value := S * HSL.MaxSaturation; ELum.Value := L * HSL.MaxLuminance; - -// dec(FLockChange); end; procedure TOfficeMoreColorsWin.SetAllToSel(c: TColor); diff --git a/components/mbColorLib/examples/fulldemo/main.pas b/components/mbColorLib/examples/fulldemo/main.pas index 659f7b36f..f77a21430 100644 --- a/components/mbColorLib/examples/fulldemo/main.pas +++ b/components/mbColorLib/examples/fulldemo/main.pas @@ -330,9 +330,9 @@ end; // only for internet shortcuts procedure TForm1.FormCreate(Sender: TObject); begin - MaxHue := 360; - MaxSat := 240; - MaxLum := 240; +// MaxHue := 360; +// MaxSat := 240; +// MaxLum := 240; with TIniFile.Create(ExtractFilePath(Application.ExeName) + '\MXS Website.url') do try WriteString('InternetShortcut','URL', 'http://mxs.bergsoft.net'); diff --git a/components/mbColorLib/mbOfficeColorDialog.pas b/components/mbColorLib/mbOfficeColorDialog.pas index 82f068f60..3f84ac31a 100644 --- a/components/mbColorLib/mbOfficeColorDialog.pas +++ b/components/mbColorLib/mbOfficeColorDialog.pas @@ -14,12 +14,16 @@ type FWin: TOfficeMoreColorsWin; FSelColor: TColor; FUseHint: boolean; + FMaxHue, FMaxSat, FMaxLum: Integer; public constructor Create(AOwner: TComponent); override; function Execute: boolean; overload; function Execute(AColor: TColor): boolean; overload; published property SelectedColor: TColor read FSelColor write FSelColor default clWhite; + property MaxHue: Integer read FMaxHue write FMaxHue default 359; + property MaxSaturation: Integer read FMaxSat write FMaxSat default 240; + property MaxLuminance: Integer read FMaxLum write FMaxLum default 240; property UseHints: boolean read FUseHint write FUseHint default false; end; @@ -32,25 +36,14 @@ begin inherited; FSelColor := clWhite; FUseHint := false; + FMaxHue := 359; + FMaxSat := 240; + FMaxLum := 240; end; function TmbOfficeColorDialog.Execute: boolean; begin Result := Execute(FSelColor); - { - FWin := TOfficeMoreColorsWin.Create(Application); - try - FWin.OldSwatch.Color := FSelColor; - FWin.ShowHint := FUseHint; - Result := (FWin.ShowModal = IdOK); - if Result then - FSelColor := FWin.NewSwatch.Color - else - FSelColor := clNone; - finally - FWin.Free; - end; - } end; function TmbOfficeColorDialog.Execute(AColor: TColor): boolean; @@ -59,6 +52,9 @@ begin try FWin.OldSwatch.Color := AColor; FWin.ShowHint := FUseHint; + FWin.MaxHue := FMaxHue; + FWin.MaxSaturation := FMaxSat; + FWin.MaxLuminance := FMaxLum; Result := (FWin.ShowModal = IdOK); if Result then FSelColor := FWin.NewSwatch.Color