?? bscolorctrls.pas
字號:
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;
for I := 1 to 12 do CustomColorValues[I] := clWhite;
CustomColorValuesCount := 0;
end;
destructor TbsSkinColorDialog.Destroy;
begin
PSPColor.Free;
FDefaultLabelFont.Free;
FDefaultButtonFont.Free;
FDefaultEditFont.Free;
inherited;
end;
procedure TbsSkinColorDialog.ChangeEdits;
var
R, G, B: Byte;
begin
FromPSP := True;
R := PSPColor.FRGB.R;
G := PSPColor.FRGB.G;
B := PSPColor.FRGB.B;
REdit.Value := R;
GEdit.Value := G;
BEdit.Value := B;
FromPSP := False;
end;
procedure TbsSkinColorDialog.HSLEditChange(Sender: TObject);
var
R, G, B: Byte;
RGB: TRGB;
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;
//
if not FromPSP
then
begin
DrawCursor;
RGB.R := R;
RGB.G := G;
RGB.B := B;
PSPColor.SetRGB(RGB);
DrawPSPPalette;
end;
//
RGBStopCheck := False;
end;
procedure TbsSkinColorDialog.AddCustomColorButtonClick(Sender: TObject);
begin
CustomColorGrid.AddColor(ColorViewer.ColorValue);
end;
procedure TbsSkinColorDialog.RGBEditChange(Sender: TObject);
var
R, G, B: Byte;
H, S, L: Integer;
RGB: TRGB;
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;
//
if not FromPSP
then
begin
DrawCursor;
RGB.R := R;
RGB.G := G;
RGB.B := B;
PSPColor.SetRGB(RGB);
DrawPSPPalette;
end;
//
HSLStopCheck := False;
end;
procedure TbsSkinColorDialog.CustomColorGridChange(Sender: TObject);
var
R, G, B: Byte;
H, S, L: Integer;
RGB: TRGB;
begin
ColorToR_G_B(CustomColorGrid.ColorValue, R, G, B);
RGBStopCheck := True;
REdit.Value := R;
GEdit.Value := G;
BEdit.Value := B;
RGBStopCheck := False;
ColorViewer.ColorValue := CustomColorGrid.ColorValue;
RGBToHSL(R, G, B, H, S, L);
HSLStopCheck := True;
HEdit.Value := H;
SEdit.Value := S;
LEdit.Value := L;
if not FromPSP
then
begin
DrawCursor;
RGB.R := R;
RGB.G := G;
RGB.B := B;
PSPColor.SetRGB(RGB);
DrawPSPPalette;
end;
HSLStopCheck := False;
end;
procedure TbsSkinColorDialog.ColorGridChange(Sender: TObject);
var
R, G, B: Byte;
H, S, L: Integer;
RGB: TRGB;
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;
if not FromPSP
then
begin
DrawCursor;
RGB.R := R;
RGB.G := G;
RGB.B := B;
PSPColor.SetRGB(RGB);
DrawPSPPalette;
end;
HSLStopCheck := False;
end;
procedure TbsSkinColorDialog.SetDefaultLabelFont;
begin
FDefaultLabelFont.Assign(Value);
end;
procedure TbsSkinColorDialog.SetDefaultEditFont;
begin
FDefaultEditFont.Assign(Value);
end;
procedure TbsSkinColorDialog.SetDefaultButtonFont;
begin
FDefaultButtonFont.Assign(Value);
end;
procedure TbsSkinColorDialog.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 TbsSkinColorDialog.Execute: Boolean;
var
Form: TForm;
BSF: TbsBusinessSkinForm;
ButtonTop, ButtonWidth, ButtonHeight: Integer;
R, G, B: Byte;
Temp : TRGB;
I: Integer;
PSPBGColor: TColor;
begin
Form := TForm.Create(Application);
Form.BorderStyle := bsDialog;
Form.Caption := FCaption;
Form.Position := poScreenCenter;
BSF := TbsBusinessSkinForm.Create(Form);
BSF.BorderIcons := [];
BSF.SkinData := SkinData;
BSF.MenusSkinData := CtrlSkinData;
BSF.AlphaBlend := AlphaBlend;
BSF.AlphaBlendAnimation := AlphaBlendAnimation;
BSF.AlphaBlendValue := AlphaBlendValue;
try
Form.ClientWidth := 378;
ColorGrid := TbsSkinColorGrid.Create(Form);
with ColorGrid do
begin
Parent := Form;
if FGroupBoxTransparentMode
then
TransparentMode := FGroupBoxTransparentMode;
CaptionMode := True;
RowCount := 8;
ColCount := 6;
Left := 5;
Top := 5;
Width := 167;
Height := 195;
SkinDataName := 'groupbox';
SkinData := CtrlSkinData;
if (SkinData <> nil) and (SkinData.ResourceStrData <> nil)
then
Caption := SkinData.ResourceStrData.GetResStr('COLORGRID_CAP')
else
Caption := BS_COLORGRID_CAP;
OnChange := ColorGridChange;
end;
CustomColorGrid := TbsSkinCustomColorGrid.Create(Form);
with CustomColorGrid do
begin
Parent := Form;
if FGroupBoxTransparentMode
then
TransparentMode := FGroupBoxTransparentMode;
CaptionMode := True;
Left := 5;
Top := ColorGrid.Top + ColorGrid.Height + 10;
Width := 167;
Height := 68;
SkinDataName := 'groupbox';
SkinData := CtrlSkinData;
if (SkinData <> nil) and (SkinData.ResourceStrData <> nil)
then
Caption := SkinData.ResourceStrData.GetResStr('CUSTOMCOLORGRID_CAP')
else
Caption := BS_CUSTOMCOLORGRID_CAP;
OnChange := CustomColorGridChange;
end;
for I := 1 to 12 do
CustomColorGrid.CustomColorValues[I] := Self.CustomColorValues[I];
CustomColorGrid.FColorsCount := CustomColorValuesCount;
//
PalettePSPPanel:= TbsEmptyControl.Create(Form);
with PalettePSPPanel do
begin
Parent := Form;
Top := 5;
Left := ColorGrid.Left + ColorGrid.Width + 5;
Width := 195;
Height := 195;
end;
PalettePSP := TImage.Create(Form);
with PalettePSP do
begin
Parent := PalettePSPPanel;
Top := 0;
Left := 0;
Width := 195;
Height := 195;
OnMouseMove := PalettePSPMouseMove;
OnMouseUp := PalettePSPMouseUp;
OnMouseDown := PalettePSPMouseDown;
Picture.Bitmap.PixelFormat := pf32bit;
Picture.Bitmap.width := PalettePSP.width;
Picture.Bitmap.height := PalettePSP.Height;
end;
ClickImg := czpspPnone;
Temp.R := 0;
Temp.G := 0;
Temp.B := 0;
PSPColor.RGB := Temp;
PosCircle := (PalettePSP.Width-PalettePSPCoord.Right)div 2;
PosCar := PosCircle;
//
RLabel := TbsSkinStdLabel.Create(Form);
with RLabel do
begin
Parent := Form;
Left := PalettePSPPanel.Left;
Top := ColorGrid.Top + ColorGrid.Height + 12;
DefaultFont := DefaultLabelFont;
UseSkinFont := Self.UseSkinFont;
SkinData := CtrlSkinData;
Caption := 'R:';
end;
REdit := TbsSkinTrackEdit.Create(Self);
with REdit do
begin
Parent := Form;
PopupKind := tbpLeft;
SetBounds(RLabel.Left + RLabel.Width + 5, ColorGrid.Top + ColorGrid.Height + 10, 50, 21);
TrackBarWidth := 200;
MinValue := 0;
MaxValue := 255;
Value := 0;
SkinData := CtrlSkinData;
JumpWhenClick := True;
OnChange := RGBEditChange;
end;
GLabel := TbsSkinStdLabel.Create(Form);
with GLabel do
begin
Parent := Form;
Left := PalettePSPPanel.Left;
Top := REdit.Top + REdit.Height + 12;
DefaultFont := DefaultLabelFont;
UseSkinFont := Self.UseSkinFont;
SkinData := CtrlSkinData;
Caption := 'G:';
end;
GEdit := TbsSkinTrackEdit.Create(Self);
with GEdit do
begin
Parent := Form;
PopupKind := tbpLeft;
SetBounds(REdit.Left, REdit.Top + REdit.Height + 10, 50, 21);
TrackBarWidth := 200;
MinValue := 0;
MaxValue := 255;
Value := 0;
SkinData := CtrlSkinData;
JumpWhenClick := True;
OnChange := RGBEditChange;
end;
BLabel := TbsSkinStdLabel.Create(Form);
with BLabel do
begin
Parent := Form;
Left := PalettePSPPanel.Left;
Top := GEdit.Top + GEdit.Height + 12;
DefaultFont := DefaultLabelFont;
UseSkinFont := Self.UseSkinFont;
SkinData := CtrlSkinData;
Caption := 'B:';
end;
BEdit := TbsSkinTrackEdit.Create(Self);
with BEdit do
begin
Parent := Form;
PopupKind := tbpLeft;
SetBounds(REdit.Left, GEdit.Top + GEdit.Height + 10, 50, 21);
TrackBarWidth := 200;
MinValue := 0;
MaxValue := 255;
Value := 0;
SkinData := CtrlSkinData;
JumpWhenClick := True;
OnChange := RGBEditChange;
end;
HLabel := TbsSkinStdLabel.Create(Form);
with HLabel do
begin
Parent := Form;
Left := REdit.Left + REdit.Width + 5;
Top := ColorGrid.Top + ColorGrid.Height + 12;
DefaultFont := DefaultLabelFont;
UseSkinFont := Self.UseSkinFont;
SkinData := CtrlSkinData;
Caption := 'H:';
end;
HEdit := TbsSkinTrackEdit.Create(Self);
with HEdit do
begin
Parent := Form;
PopupKind := tbpLeft;
SetBounds(HLabel.Left + HLabel.Width + 5, ColorGrid.Top + ColorGrid.Height + 10, 50, 21);
TrackBarWidth := 250;
MinValue := 0;
MaxValue := 359;
Value := 0;
SkinData := CtrlSkinData;
JumpWhenClick := True;
OnChange := HSLEditChange;
end;
SLabel := TbsSkinStdLabel.Create(Form);
with SLabel do
begin
Parent := Form;
Left := REdit.Left + REdit.Width + 5;
Top := HEdit.Top + HEdit.Height + 12;
DefaultFont := DefaultLabelFont;
UseSkinFont := Self.UseSkinFont;
SkinData := CtrlSkinData;
Caption := 'S:';
end;
SEdit := TbsSkinTrackEdit.Create(Self);
with SEdit do
begin
Parent := Form;
PopupKind := tbpLeft;
SetBounds(HEdit.Left, HEdit.Top + HEdit.Height + 10, 50, 21);
TrackBarWidth := 120;
MinValue := 0;
MaxValue := 100;
Value := 0;
SkinData := CtrlSkinData;
JumpWhenClick := True;
OnChange := HSLEditChange;
end;
LLabel := TbsSkinStdLabel.Create(Form);
with LLabel do
begin
Parent := Form;
Left := REdit.Left + REdit.Width + 5;
Top := SEdit.Top + SEdit.Height + 12;
DefaultFont := DefaultLabelFont;
UseSkinFont := Self.UseSkinFont;
SkinData := CtrlSkinData;
Caption := 'L:';
end;
LEdit := TbsSkinTrackEdit.Create(Self);
with LEdit do
begin
Parent := Form;
PopupKind := tbpLeft;
SetBounds(HEdit.Left, SEdit.Top + SEdit.Height + 10, 50, 21);
TrackBarWidth := 120;
MinValue := 0;
MaxValue := 100;
Value := 0;
SkinData := CtrlSkinData;
JumpWhenClick := True;
OnChange := HSLEditChange;
end;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -