spColorCtrls.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:23k
- {*******************************************************************}
- { }
- { Almediadev Visual Component Library }
- { DynamicSkinForm }
- { Version 5.60 }
- { }
- { Copyright (c) 2000-2003 Almediadev }
- { ALL RIGHTS RESERVED }
- { }
- { Home: http://www.almdev.com }
- { Support: support@almdev.com }
- { }
- {*******************************************************************}
- unit spColorCtrls;
- interface
- uses Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms,
- DynamicSkinForm, SkinData, SkinCtrls, SkinBoxCtrls, Dialogs,
- StdCtrls, ExtCtrls, spEffBmp;
- type
- TspSkinColorGrid = class(TspSkinPanel)
- private
- FColorValue: TColor;
- FOnChange: TNotifyEvent;
- FColCount, FRowCount: Integer;
- procedure SetColCount(Value: Integer);
- procedure SetRowCount(Value: Integer);
- procedure SetColorValue(Value: TColor);
- protected
- procedure DrawCursor(Cnvs: TCanvas; R: TRect; pmNotMode: Boolean);
- function CheckColor(Value: TColor): boolean;
- procedure CreateControlDefaultImage(B: TBitMap); override;
- procedure CreateControlSkinImage(B: TBitMap); override;
- procedure PaintGrid(Cnvs: TCanvas);
- procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
- X, Y: Integer); override;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- published
- property RowCount: Integer read FRowCount write SetRowCount;
- property ColCount: Integer read FColCount write SetColCount;
- property ColorValue: TColor read FColorValue write SetColorValue;
- property OnChange: TNotifyEvent read FOnChange write FOnChange;
- end;
- TspColorViewer = class(TGraphicControl)
- private
- FColorValue: TColor;
- procedure SetColorValue(Value: TColor);
- public
- constructor Create(AOwner: TComponent); override;
- procedure Paint; override;
- published
- property ColorValue: TColor read FColorValue write SetColorValue;
- end;
- TspSkinColorDialog = class(TComponent)
- private
- RGBStopCheck: Boolean;
- HSLStopCheck: Boolean;
- protected
- FColor: TColor;
- FCaption: String;
- FSD: TspSkinData;
- FCtrlFSD: TspSkinData;
- FButtonSkinDataName: String;
- FEditSkinDataName: String;
- FLabelSkinDataName: String;
- FDefaultLabelFont: TFont;
- FDefaultEditFont: TFont;
- FDefaultButtonFont: TFont;
- FAlphaBlend: Boolean;
- FAlphaBlendAnimation: Boolean;
- FAlphaBlendValue: Byte;
- FUseSkinFont: Boolean;
- //
- ColorGrid: TspSkinColorGrid;
- OkButton, CancelButton: TspSkinButton;
- ColorViewer: TspColorViewer;
- REdit, GEdit, BEdit: TspSkinTrackEdit;
- RLabel, GLabel, BLabel, EQLabel: TspSkinStdLabel;
- HEdit, LEdit, SEdit: TspSkinTrackEdit;
- HLabel, LLabel, SLabel: TspSkinStdLabel;
- //
- procedure SetDefaultLabelFont(Value: TFont);
- procedure SetDefaultButtonFont(Value: TFont);
- procedure SetDefaultEditFont(Value: TFont);
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- procedure ColorGridChange(Sender: TObject);
- procedure RGBEditChange(Sender: TObject);
- procedure HSLEditChange(Sender: TObject);
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function Execute: Boolean;
- published
- property Color: TColor read FColor write FColor;
- property Caption: String read FCaption write FCaption;
- property AlphaBlend: Boolean read FAlphaBlend write FAlphaBlend;
- property AlphaBlendValue: Byte read FAlphaBlendValue write FAlphaBlendValue;
- property AlphaBlendAnimation: Boolean
- read FAlphaBlendAnimation write FAlphaBlendAnimation;
- property SkinData: TspSkinData read FSD write FSD;
- property CtrlSkinData: TspSkinData read FCtrlFSD write FCtrlFSD;
- property ButtonSkinDataName: String
- read FButtonSkinDataName write FButtonSkinDataName;
- property LabelSkinDataName: String
- read FLabelSkinDataName write FLabelSkinDataName;
- property EditSkinDataName: String
- read FEditSkinDataName write FEditSkinDataName;
- property DefaultLabelFont: TFont read FDefaultLabelFont write SetDefaultLabelFont;
- property DefaultButtonFont: TFont read FDefaultButtonFont write SetDefaultButtonFont;
- property DefaultEditFont: TFont read FDefaultEditFont write SetDefaultEditFont;
- property UseSkinFont: Boolean read FUseSkinFont write FUseSkinFont;
- end;
- implementation
- Uses spUtils, Math, spConst;
- const
- ColorValues: array[1..48] of TColor =
- (0, 64, 128, 4210816, 255, 8421631, 32896, 16512, 33023, 4227327, 65535, 8454143,
- 4227200, 16384, 32768, 65280, 65408, 8454016, 8421504, 4210688, 4227072, 8421376, 4259584, 8453888,
- 8421440, 8388608, 16711680, 8404992, 16776960, 16777088, 12632256, 4194304, 10485760, 16744576, 12615680, 16744448,
- 4194368, 5194368, 8388736, 4194432, 12615808, 12615935, 16777215, 8388672, 16711808, 8388863, 16711935, 16744703);
- procedure ColorToR_G_B(C: TColor; var R, G, B: Byte);
- begin
- R := C and $FF;
- G := (C shr 8) and $FF;
- B := (C shr 16) and $FF;
- end;
- function R_G_BToColor(R, G, B: Byte): TColor;
- begin
- Result := RGB(R, G, B);
- end;
- procedure RGBToHSL1(AR, AV, AB: Byte; var H, S, L: Double);
- var
- R,
- G,
- B,
- D,
- Cmax,
- Cmin: double;
- begin
- R := AR / 255;
- G := AV / 255;
- B := AB / 255;
- Cmax := Max (R, Max (G, B));
- Cmin := Min (R, Min (G, B));
- // calculate luminosity
- L := (Cmax + Cmin) / 2;
- if Cmax = Cmin then // it's grey
- begin
- H := 0; // it's actually undefined
- S := 0
- end else begin
- D := Cmax - Cmin;
- // calculate Saturation
- if L < 0.5 then
- S := D / (Cmax + Cmin)
- else
- S := D / (2 - Cmax - Cmin);
- // calculate Hue
- if R = Cmax then
- H := (G - B) / D
- else
- if G = Cmax then
- H := 2 + (B - R) /D
- else
- H := 4 + (R - G) / D;
- H := H / 6;
- if H < 0 then
- H := H + 1;
- end;
- end;
- procedure RGBToHSL2(AR, AG, AB: Byte; var H, S, L: Integer);
- var
- RGB: array[0..2] of Double;
- MinIndex, MaxIndex: Integer;
- Range: Double;
- H1 : Double;
- begin
- RGB[0]:= AR;
- RGB[1]:= AG;
- RGB[2]:= AB;
- MinIndex:= 0;
- if AG < AR then MinIndex:= 1;
- if AB < RGB[MinIndex] then MinIndex:= 2;
- MaxIndex:= 0;
- if AG > AR then MaxIndex:= 1;
- if AB > RGB[MaxIndex] then MaxIndex:= 2;
- Range:= RGB[MaxIndex] - RGB[MinIndex];
- if Range = 0
- then
- begin
- S := 0;
- L := Round(100 * AR / 255);
- end
- else
- begin
- H1 := MaxIndex * 2 + (AR - AG) / Range;
- S := Round(Range / RGB[MaxIndex] * 100);
- L := Round(100 * (RGB[MaxIndex] / 255));
- H1 := H1 / 6;
- if H1 < 0 then H1 := H1 + 1;
- H := Round(H1 * 359);
- end;
- end;
- procedure RGBToHSL(AR, AG, AB: Byte; var RH, RS, RL: Integer);
- var
- H, S, L: Double;
- begin
- RGBToHSL1(AR, AG, AB, H, S, L);
- RGBToHSL2(AR, AG, AB, RH, RS, RL);
- if RS <> 0 then RH := Round(H * 359);
- end;
- procedure HSLToRGB(var R, G, B: Byte; RH, RS, RL: Integer);
- const
- SectionSize = 60/360;
- var
- Section: Double;
- SectionIndex: Integer;
- f, p, q, t, H, S, L: Double;
- begin
- H := RH / 360;
- S := RS / 100;
- L := (255 * RL / 100);
- if S = 0
- then
- begin
- R := Round(L);
- G := R;
- B := R;
- end
- else
- begin
- Section := H / SectionSize;
- SectionIndex := Floor(Section);
- f := Section - SectionIndex;
- p := L * ( 1 - S );
- q := L * ( 1 - S * f );
- t := L * ( 1 - S * ( 1 - f ) );
- case SectionIndex of
- 0:
- begin
- R := Round(L);
- G := Round(t);
- B := Round(p);
- end;
- 1:
- begin
- R:= Round(q);
- G:= Round(L);
- B:= Round(p);
- end;
- 2:
- begin
- R := Round(p);
- G := Round(L);
- B := Round(t);
- end;
- 3:
- begin
- R := Round(p);
- G := Round(q);
- B := Round(L);
- end;
- 4:
- begin
- R:= Round(t);
- G:= Round(p);
- B:= Round(L);
- end;
- else
- R := Round(L);
- G := Round(p);
- B := Round(q);
- end;
- end;
- end;
- constructor TspSkinColorGrid.Create(AOwner: TComponent);
- begin
- inherited;
- ControlStyle := ControlStyle - [csAcceptsControls];
- CaptionMode := True;
- Caption := SP_COLORGRID_CAP;
- BorderStyle := bvFrame;
- Width := 280;
- Height := 115;
- FColorValue := 0;
- FColCount := 12;
- FRowCount := 4;
- end;
- destructor TspSkinColorGrid.Destroy;
- begin
- inherited;
- end;
- procedure TspSkinColorGrid.SetColCount(Value: Integer);
- begin
- if Value < 1 then Exit;
- FColCount := Value;
- RePaint;
- end;
- procedure TspSkinColorGrid.SetRowCount(Value: Integer);
- begin
- FRowCount := Value;
- RePaint;
- end;
- procedure TspSkinColorGrid.DrawCursor;
- var
- CX, CY, Rd: Integer;
- begin
- CX := R.Left + RectWidth(R) div 2;
- CY := R.Top + RectHeight(R) div 2;
- if RectWidth(R) > RectHeight(R)
- then
- Rd := RectHeight(R) div 2 - 2
- else
- Rd := RectWidth(R) div 2 - 2;
- with Cnvs do
- begin
- if pmNotMode then Pen.Mode := pmNot else Pen.Color := 0;
- MoveTo(CX - rd, CY); LineTo(CX - 2, CY);
- MoveTo(CX + 3, CY); LineTo(CX + rd + 1, CY);
- MoveTo(CX, CY - rd); LineTo(CX, CY - 2);
- MoveTo(CX, CY + 3); LineTo(CX, CY + rd);
- end;
- end;
- procedure TspSkinColorGrid.PaintGrid(Cnvs: TCanvas);
- var
- X, Y, CW, CH, i, j, k: Integer;
- R, Rct: TRect;
- begin
- R := Rect(0, 0, Width, Height);
- AdjustClientRect(R);
- CW := (RectWidth(R) - ColCount * 2) div ColCount;
- CH := (RectHeight(R) - RowCount * 2) div RowCount;
- Y := R.Top + 1;
- k := 0;
- for i := 1 to RowCount do
- begin
- X := R.Left + 1;
- for j := 1 to ColCount do
- begin
- Inc(k);
- with Cnvs do
- begin
- Brush.Color := ColorValues[k];
- Rct := Rect(X, Y, X + CW, Y + CH);
- FillRect(Rct);
- if FColorValue = ColorValues[k]
- then
- begin
- if ColorValues[k] <> clGray
- then
- DrawCursor(Cnvs, Rct, True)
- else
- DrawCursor(Cnvs, Rct, False);
- end
- end;
- Inc(X, CW + 2);
- end;
- Inc(Y, CH + 2);
- end;
- end;
- procedure TspSkinColorGrid.CreateControlDefaultImage;
- begin
- inherited;
- PaintGrid(B.Canvas);
- end;
- procedure TspSkinColorGrid.CreateControlSkinImage;
- begin
- inherited;
- PaintGrid(B.Canvas);
- end;
- function TspSkinColorGrid.CheckColor(Value: TColor): boolean;
- var
- I: Integer;
- begin
- Result := False;
- for I := 1 to 48 do
- if ColorValues[I] = Value
- then
- begin
- Result := True;
- Break;
- end;
- end;
- procedure TspSkinColorGrid.SetColorValue(Value: TColor);
- begin
- FColorValue := Value;
- if CheckColor(FColorValue)
- then
- begin
- if Assigned(FOnChange) then FOnChange(Self);
- RePaint;
- end;
- end;
- procedure TspSkinColorGrid.MouseDown(Button: TMouseButton; Shift: TShiftState;
- X, Y: Integer);
- var
- X1, Y1, CW, CH, i, j, k: Integer;
- R, Rct: TRect;
- begin
- inherited;
- R := Rect(0, 0, Width, Height);
- AdjustClientRect(R);
- CW := (RectWidth(R) - ColCount * 2) div ColCount;
- CH := (RectHeight(R) - RowCount * 2) div RowCount;
- Y1 := R.Top + 1;
- k := 0;
- for i := 1 to RowCount do
- begin
- X1 := R.Left + 1;
- for j := 1 to ColCount do
- begin
- Inc(k);
- Rct := Rect(X1, Y1, X1 + CW, Y1 + CH);
- if PtInRect(Rct, Point(X, Y))
- then
- begin
- ColorValue := ColorValues[k];
- Break;
- end;
- Inc(X1, CW + 2);
- end;
- Inc(Y1, CH + 2);
- end;
- end;
- constructor TspColorViewer.Create(AOwner: TComponent);
- begin
- inherited;
- ControlStyle := ControlStyle + [csOpaque];
- FColorValue := 0;
- end;
- procedure TspColorViewer.Paint;
- var
- B: TBitMap;
- begin
- B := TBitMap.Create;
- B.Width := Width;
- B.Height := Height;
- with B.Canvas do
- begin
- Pen.Color := clBlack;
- Brush.Color := FColorValue;
- Rectangle(0, 0, Width, Height);
- end;
- Canvas.Draw(0, 0, B);
- B.Free;
- end;
- procedure TspColorViewer.SetColorValue;
- begin
- if FColorValue = Value then Exit;
- FColorValue := Value;
- RePaint;
- end;
- constructor TspSkinColorDialog.Create;
- begin
- inherited Create(AOwner);
- RGBStopCheck := False;
- HSLStopCheck := False;
- FColor := 0;
- FAlphaBlend := False;
- FAlphaBlendAnimation := False;
- FAlphaBlendValue := 200;
- FCaption := 'Set color';
- FButtonSkinDataName := 'button';
- FLabelSkinDataName := 'stdlabel';
- FEditSkinDataName := 'edit';
- FDefaultLabelFont := TFont.Create;
- FDefaultButtonFont := TFont.Create;
- FDefaultEditFont := TFont.Create;
- FUseSkinFont := True;
- with FDefaultLabelFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- with FDefaultButtonFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- with FDefaultEditFont do
- begin
- Name := 'Arial';
- Style := [];
- Height := 14;
- end;
- end;
- destructor TspSkinColorDialog.Destroy;
- begin
- FDefaultLabelFont.Free;
- FDefaultButtonFont.Free;
- FDefaultEditFont.Free;
- inherited;
- end;
- procedure TspSkinColorDialog.HSLEditChange(Sender: TObject);
- var
- R, G, B: Byte;
- begin
- if HSLStopCheck then Exit;
- HSLTORGB(R, G, B, HEdit.Value, SEdit.Value, LEdit.Value);
- ColorViewer.ColorValue := R_G_BToColor(R, G, B);
- RGBStopCheck := True;
- REdit.Value := R;
- GEdit.Value := G;
- BEdit.Value := B;
- RGBStopCheck := False;
- end;
- procedure TspSkinColorDialog.RGBEditChange(Sender: TObject);
- var
- R, G, B: Byte;
- H, S, L: Integer;
- begin
- if RGBStopCheck then Exit;
- ColorViewer.ColorValue := R_G_BToColor(REdit.Value, GEdit.Value, BEdit.Value);
- ColorToR_G_B(ColorViewer.ColorValue, R, G, B);
- HSLStopCheck := True;
- RGBToHSL(R, G, B, H, S, L);
- HEdit.Value := H;
- SEdit.Value := S;
- LEdit.Value := L;
- HSLStopCheck := False;
- end;
- procedure TspSkinColorDialog.ColorGridChange(Sender: TObject);
- var
- R, G, B: Byte;
- H, S, L: Integer;
- begin
- ColorToR_G_B(ColorGrid.ColorValue, R, G, B);
- RGBStopCheck := True;
- REdit.Value := R;
- GEdit.Value := G;
- BEdit.Value := B;
- RGBStopCheck := False;
- ColorViewer.ColorValue := ColorGrid.ColorValue;
- RGBToHSL(R, G, B, H, S, L);
- HSLStopCheck := True;
- HEdit.Value := H;
- SEdit.Value := S;
- LEdit.Value := L;
- HSLStopCheck := False;
- end;
- procedure TspSkinColorDialog.SetDefaultLabelFont;
- begin
- FDefaultLabelFont.Assign(Value);
- end;
- procedure TspSkinColorDialog.SetDefaultEditFont;
- begin
- FDefaultEditFont.Assign(Value);
- end;
- procedure TspSkinColorDialog.SetDefaultButtonFont;
- begin
- FDefaultButtonFont.Assign(Value);
- end;
- procedure TspSkinColorDialog.Notification;
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) and (AComponent = FSD) then FSD := nil;
- if (Operation = opRemove) and (AComponent = FCtrlFSD) then FCtrlFSD := nil;
- end;
- function TspSkinColorDialog.Execute: Boolean;
- var
- Form: TForm;
- DSF: TspDynamicSkinForm;
- ButtonTop, ButtonWidth, ButtonHeight: Integer;
- R, G, B: Byte;
- begin
- Form := TForm.Create(Application);
- Form.BorderStyle := bsDialog;
- Form.Caption := FCaption;
- Form.Position := poScreenCenter;
- DSF := TspDynamicSkinForm.Create(Form);
- DSF.BorderIcons := [];
- DSF.SkinData := SkinData;
- DSF.MenusSkinData := CtrlSkinData;
- DSF.AlphaBlend := AlphaBlend;
- DSF.AlphaBlendAnimation := AlphaBlendAnimation;
- DSF.AlphaBlendValue := AlphaBlendValue;
- DSF.Sizeable := False;
-
- try
- with Form do
- begin
- ClientWidth := 280;
- end;
- ColorGrid := TspSkinColorGrid.Create(Form);
- with ColorGrid do
- begin
- Parent := Form;
- Align := alTop;
- Height := 105;
- SkinDataName := 'groupbox';
- SkinData := CtrlSkinData;
- OnChange := ColorGridChange;
- end;
- RLabel := TspSkinStdLabel.Create(Form);
- with RLabel do
- begin
- Parent := Form;
- Left := 5;
- Top := ColorGrid.Top + ColorGrid.Height + 12;
- DefaultFont := DefaultLabelFont;
- UseSkinFont := Self.UseSkinFont;
- SkinData := CtrlSkinData;
- Caption := 'R:';
- end;
- REdit := TspSkinTrackEdit.Create(Self);
- with REdit do
- begin
- Parent := Form;
- JumpWhenClick := True;
- SetBounds(RLabel.Left + RLabel.Width + 5, ColorGrid.Top + ColorGrid.Height + 10, 50, 21);
- TrackBarWidth := 260;
- MinValue := 0;
- MaxValue := 255;
- Value := 0;
- SkinData := CtrlSkinData;
- OnChange := RGBEditChange;
- end;
- GLabel := TspSkinStdLabel.Create(Form);
- with GLabel do
- begin
- Parent := Form;
- Left := REdit.Left + REdit.Width + 5;
- Top := ColorGrid.Top + ColorGrid.Height + 12;
- DefaultFont := DefaultLabelFont;
- UseSkinFont := Self.UseSkinFont;
- SkinData := CtrlSkinData;
- Caption := 'G:';
- end;
- GEdit := TspSkinTrackEdit.Create(Self);
- with GEdit do
- begin
- Parent := Form;
- JumpWhenClick := True;
- SetBounds(GLabel.Left + GLabel.Width + 5, ColorGrid.Top + ColorGrid.Height + 10, 50, 21);
- TrackBarWidth := 260;
- MinValue := 0;
- MaxValue := 255;
- Value := 0;
- SkinData := CtrlSkinData;
- OnChange := RGBEditChange;
- end;
- BLabel := TspSkinStdLabel.Create(Form);
- with BLabel do
- begin
- Parent := Form;
- Left := GEdit.Left + GEdit.Width + 5;
- Top := ColorGrid.Top + ColorGrid.Height + 12;
- DefaultFont := DefaultLabelFont;
- UseSkinFont := Self.UseSkinFont;
- SkinData := CtrlSkinData;
- Caption := 'B:';
- end;
- BEdit := TspSkinTrackEdit.Create(Self);
- with BEdit do
- begin
- Parent := Form;
- JumpWhenClick := True;
- SetBounds(BLabel.Left + BLabel.Width + 5, ColorGrid.Top + ColorGrid.Height + 10, 50, 21);
- TrackBarWidth := 260;
- MinValue := 0;
- MaxValue := 255;
- Value := 0;
- SkinData := CtrlSkinData;
- OnChange := RGBEditChange;
- end;
- EqLabel := TspSkinStdLabel.Create(Form);
- with EqLabel do
- begin
- Parent := Form;
- Left := BEdit.Left + BEdit.Width + 5;;
- Top := ColorGrid.Top + ColorGrid.Height + 12;
- DefaultFont := DefaultLabelFont;
- UseSkinFont := Self.UseSkinFont;
- SkinData := CtrlSkinData;
- Caption := '=';
- end;
- ColorViewer := TspColorViewer.Create(Form);
- with ColorViewer do
- begin
- Parent := Form;
- SetBounds(EqLabel.Left + EqLabel.Width + 5, ColorGrid.Top + ColorGrid.Height + 10,
- BEdit.Width, BEdit.Height);
- end;
- HLabel := TspSkinStdLabel.Create(Form);
- with HLabel do
- begin
- Parent := Form;
- Left := 5;
- Top := ColorViewer.Top + ColorViewer.Height + 12;
- DefaultFont := DefaultLabelFont;
- UseSkinFont := Self.UseSkinFont;
- SkinData := CtrlSkinData;
- Caption := 'H:';
- end;
- HEdit := TspSkinTrackEdit.Create(Self);
- with HEdit do
- begin
- Parent := Form;
- JumpWhenClick := True;
- SetBounds(HLabel.Left + HLabel.Width + 5, ColorViewer.Top + ColorViewer.Height + 10, 50, 21);
- TrackBarWidth := 260;
- MinValue := 0;
- MaxValue := 359;
- Value := 0;
- SkinData := CtrlSkinData;
- OnChange := HSLEditChange;
- end;
- SLabel := TspSkinStdLabel.Create(Form);
- with SLabel do
- begin
- Parent := Form;
- Left := HEdit.Left + HEdit.Width + 5;
- Top := ColorViewer.Top + ColorViewer.Height + 12;
- DefaultFont := DefaultLabelFont;
- UseSkinFont := Self.UseSkinFont;
- SkinData := CtrlSkinData;
- Caption := 'S:';
- end;
- SEdit := TspSkinTrackEdit.Create(Self);
- with SEdit do
- begin
- Parent := Form;
- JumpWhenClick := True;
- SetBounds(SLabel.Left + SLabel.Width + 6, ColorViewer.Top + ColorViewer.Height + 10, 50, 21);
- TrackBarWidth := 120;
- MinValue := 0;
- MaxValue := 100;
- Value := 0;
- SkinData := CtrlSkinData;
- OnChange := HSLEditChange;
- end;
- LLabel := TspSkinStdLabel.Create(Form);
- with LLabel do
- begin
- Parent := Form;
- Left := SEdit.Left + SEdit.Width + 5;
- Top := ColorViewer.Top + ColorViewer.Height + 12;
- DefaultFont := DefaultLabelFont;
- UseSkinFont := Self.UseSkinFont;
- SkinData := CtrlSkinData;
- Caption := 'L:';
- end;
- LEdit := TspSkinTrackEdit.Create(Self);
- with LEdit do
- begin
- Parent := Form;
- JumpWhenClick := True;
- SetBounds(LLabel.Left + LLabel.Width + 6, ColorViewer.Top + ColorViewer.Height + 10, 50, 21);
- TrackBarWidth := 120;
- MinValue := 0;
- MaxValue := 100;
- Value := 0;
- SkinData := CtrlSkinData;
- OnChange := HSLEditChange;
- end;
- ButtonTop := HEdit.Top + HEdit.Height + 20;
- ButtonWidth := 70;
- ButtonHeight := 25;
- OkButton := TspSkinButton.Create(Form);
- with OkButton do
- begin
- Parent := Form;
- DefaultFont := DefaultButtonFont;
- UseSkinFont := Self.UseSkinFont;
- Caption := SP_MSG_BTN_OK;
- ModalResult := mrOk;
- Default := True;
- SetBounds(Form.ClientWidth - ButtonWidth * 2 - 20, ButtonTop, ButtonWidth,
- ButtonHeight);
- DefaultHeight := ButtonHeight;
- SkinDataName := FButtonSkinDataName;
- SkinData := CtrlSkinData;
- end;
- CancelButton := TspSkinButton.Create(Form);
- with CancelButton do
- begin
- Parent := Form;
- DefaultFont := DefaultButtonFont;
- UseSkinFont := Self.UseSkinFont;
- Caption := SP_MSG_BTN_CANCEL;
- ModalResult := mrCancel;
- Cancel := True;
- SetBounds(Form.ClientWidth - ButtonWidth - 10, ButtonTop, ButtonWidth,
- ButtonHeight);
- DefaultHeight := ButtonHeight;
- SkinDataName := FButtonSkinDataName;
- SkinData := CtrlSkinData;
- end;
- with Form do
- begin
- ClientHeight := CancelButton.Top + CancelButton.Height + 10;
- end;
- ColorViewer.ColorValue := Color;
- ColorGrid.ColorValue := Color;
- ColorToR_G_B(Color, R, G, B);
- REdit.Value := R;
- GEdit.Value := G;
- BEdit.Value := B;
- if Form.ShowModal = mrOk
- then
- begin
- Color := ColorViewer.ColorValue;
- Result := True;
- end
- else
- Result := False;
- finally
- Form.Free;
- end;
- end;
- end.