?? bscolorctrls.pas
字號:
else
if C_X > PosCar+RectPSP.Right
then
C_X := PosCar+RectPSP.Right;
if C_Y < RectPSP.Top
then
C_Y := RectPSP.Top
else
if C_Y > RectPSP.Bottom
then
C_Y := RectPSP.Bottom;
HSLPSP := PSPColor.HSLPSP;
HSLPSP.S := Round(255 * ((C_X-(PosCar+RectPSP.Left)) / (RectPSP.Right-RectPSP.Left)));
HSLPSP.L := Round(255 * ((C_Y-RectPSP.Top) / (RectPSP.Bottom-RectPSP.Top)));
DrawCursor;
PSPColor.HSLPSP := HSLPSP;
ChangeEdits;
DrawCursor;
PalettePSP.Repaint;
end;
end;
end;
procedure TbsSkinColorDialog.PalettePSPMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
HSLPSP : THSLPSP;
C_X,C_Y : Integer;
Angle : Integer;
begin
if mbLeft=Button then
case ClickImg of
czpspPCircle :
begin
C_X := PosCar+RectPSP.Left+(RectPSP.Right-RectPSP.Left)div 2;
C_Y := RectPSP.Top+(RectPSP.Bottom-RectPSP.Top)div 2;;
Angle := Round(CalcAngle3Points(C_X, 0, C_X, C_Y, X,Y));
if Angle = 360 then Angle := 0;
Angle := 359 - Angle;
HSLPSP := PSPColor.HSLPSP;
HSLPSP.H := Round(255 * (Angle / 359));
if HSLPSP.H <> PSPColor.HSLPSP.H
then
begin
DrawCursor;
PSPColor.HSLPSP := HSLPSP;
ChangeEdits;
DrawPSPPalette;
end;
end;
czpspPCar :
begin
C_X := X;
C_Y := Y;
if C_X<PosCar+RectPSP.Left
then
C_X:= PosCar+RectPSP.Left
else
if C_X>PosCar+RectPSP.Right
then
C_X:= PosCar+RectPSP.Right;
if C_Y<RectPSP.Top
then
C_Y:= RectPSP.Top
else
if C_Y>RectPSP.Bottom
then
C_Y:= RectPSP.Bottom;
HSLPSP := PSPColor.HSLPSP;
HSLPSP.S := Round(255 * ((C_X - (PosCar + RectPSP.Left)) / (RectPSP.Right - RectPSP.Left)));
HSLPSP.L := Round(255 * ((C_Y - RectPSP.Top) / (RectPSP.Bottom-RectPSP.Top)));
DrawCursor;
PSPColor.HSLPSP := HSLPSP;
ChangeEdits;
DrawCursor;
PalettePSP.Repaint;
end;
end;
ClickImg := czpspPnone;
end;
constructor TbsSkinCustomColorGrid.Create(AOwner: TComponent);
var
i: Integer;
begin
inherited;
ControlStyle := ControlStyle - [csAcceptsControls];
FForceBackground := False;
CaptionMode := True;
Caption := BS_CUSTOMCOLORGRID_CAP;
BorderStyle := bvFrame;
Width := 280;
Height := 115;
FColorValue := 0;
FColCount := 6;
FRowCount := 2;
for i := 1 to 12 do CustomColorValues[I] := clWhite;
FColorsCount := 0;
FColorIndex := 0;
end;
destructor TbsSkinCustomColorGrid.Destroy;
begin
inherited;
end;
procedure TbsSkinCustomColorGrid.PaintTransparent;
begin
PaintGrid(C);
end;
procedure TbsSkinCustomColorGrid.WMEraseBkgnd;
begin
if not FromWMPaint
then
begin
PaintWindow(Msg.DC);
end;
end;
procedure TbsSkinCustomColorGrid.AddColor(AColor: TColor);
begin
if FColorsCount = 12 then FColorsCount := 0;
Inc(FColorsCount);
CustomColorValues[FColorsCount] := AColor;
RePaint;
end;
procedure TbsSkinCustomColorGrid.SetColCount(Value: Integer);
begin
if Value < 1 then Exit;
FColCount := Value;
RePaint;
end;
procedure TbsSkinCustomColorGrid.SetRowCount(Value: Integer);
begin
FRowCount := Value;
RePaint;
end;
procedure TbsSkinCustomColorGrid.DrawCursor;
var
Buffer: TBitMap;
CIndex: Integer;
ButtonData: TbsDataSkinButtonControl;
BtnSkinPicture: TBitMap;
BtnLtPoint, BtnRTPoint, BtnLBPoint, BtnRBPoint: TPoint;
BtnCLRect: TRect;
XO, YO: Integer;
SR: TRect;
begin
if FIndex = -1
then
begin
Buffer := TBitMap.Create;
Buffer.Width := RectWidth(R);
Buffer.Height := RectHeight(R);
with Buffer.Canvas do
begin
Brush.Color := BS_XP_BTNDOWNCOLOR;
Pen.Color := BS_XP_BTNFRAMECOLOR;
Rectangle(0, 0, Buffer.Width, Buffer.Height);
end;
Cnvs.Draw(R.Left, R.Top, Buffer);
Buffer.Free;
Exit;
end;
CIndex := SkinData.GetControlIndex('resizebutton');
if CIndex = -1
then
Exit
else
ButtonData := TbsDataSkinButtonControl(SkinData.CtrlList[CIndex]);
Buffer := TBitMap.Create;
Buffer.Width := RectWidth(R);
Buffer.Height := RectHeight(R);
//
with ButtonData do
begin
XO := RectWidth(R) - RectWidth(SkinRect);
YO := RectHeight(R) - RectHeight(SkinRect);
BtnLTPoint := LTPoint;
BtnRTPoint := Point(RTPoint.X + XO, RTPoint.Y);
BtnLBPoint := Point(LBPoint.X, LBPoint.Y + YO);
BtnRBPoint := Point(RBPoint.X + XO, RBPoint.Y + YO);
BtnClRect := Rect(CLRect.Left, ClRect.Top,
CLRect.Right + XO, ClRect.Bottom + YO);
BtnSkinPicture := TBitMap(SkinData.FActivePictures.Items[ButtonData.PictureIndex]);
SR := DownSkinRect;
if IsNullRect(SR) then SR := ActiveSkinRect;
CreateSkinImage(LTPoint, RTPoint, LBPoint, RBPoint, CLRect,
BtnLtPoint, BtnRTPoint, BtnLBPoint, BtnRBPoint, BtnCLRect,
Buffer, BtnSkinPicture, SR, Buffer.Width, Buffer.Height, True,
LeftStretch, TopStretch, RightStretch, BottomStretch,
StretchEffect, StretchType);
end;
//
Cnvs.Draw(R.Left, R.Top, Buffer);
Buffer.Free;
end;
procedure TbsSkinCustomColorGrid.PaintGrid(Cnvs: TCanvas);
var
RX, RY, X, Y, CW, CH, i, j, k: Integer;
R, R1, 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;
R1 := Rect(0, 0, (CW + 2) * ColCount, (CH + 2) * RowCount);
RX := R.Left + RectWidth(R) div 2 - RectWidth(R1) div 2;
RY := R.Top + RectHeight(R) div 2 - RectHeight(R1) div 2;
R := Rect(RX, RY, RX + RectWidth(R1), RectHeight(R1));
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 := CustomColorValues[k];
Rct := Rect(X - 1, Y -1 , X + CW + 1, Y + CH + 1);
if k = FColorIndex
then
begin
DrawCursor(Cnvs, Rct);
end;
if k = FColorIndex
then
Rct := Rect(X + 3, Y + 3 , X + CW - 3, Y + CH - 3)
else
Rct := Rect(X + 2, Y + 2 , X + CW - 2, Y + CH - 2);
InflateRect(Rct, -1, -1);
FillRect(Rct);
InflateRect(Rct, 1, 1);
end;
Inc(X, CW + 2);
end;
Inc(Y, CH + 2);
end;
end;
procedure TbsSkinCustomColorGrid.CreateControlDefaultImage;
begin
inherited;
PaintGrid(B.Canvas);
end;
procedure TbsSkinCustomColorGrid.CreateControlSkinImage;
begin
inherited;
PaintGrid(B.Canvas);
end;
procedure TbsSkinCustomColorGrid.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
var
RX, RY, X1, Y1, CW, CH, i, j, k: Integer;
R, R1, 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;
R1 := Rect(0, 0, (CW + 2) * ColCount, (CH + 2) * RowCount);
RX := R.Left + RectWidth(R) div 2 - RectWidth(R1) div 2;
RY := R.Top + RectHeight(R) div 2 - RectHeight(R1) div 2;
R := Rect(RX, RY, RX + RectWidth(R1), RectHeight(R1));
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
FColorValue := CustomColorValues[k];
FColorIndex := k;
RePaint;
if Assigned(FOnChange) then FOnChange(Self);
Break;
end;
Inc(X1, CW + 2);
end;
Inc(Y1, CH + 2);
end;
end;
constructor TbsSkinColorButton.Create(AOwner: TComponent);
begin
inherited;
FDrawColorMarker := True;
ColorDialog := nil;
FColorMarkerValue := 0;
FColorImages := TCustomImageList.Create(Self);
FColorMenu := TbsSkinImagesMenu.Create(Self);
FColorMenu.Images := FColorImages;
FColorMenu.OnItemClick := OnImagesMenuClick;
FColorMenu.OnMenuPopup := OnImagesMenuPopup;
FAutoColor := 0;
FShowAutoColor := True;
FShowMoreColor := True;
InitColors;
end;
procedure TbsSkinColorButton.SetShowAutoColor(Value: Boolean);
begin
if FShowAutoColor <> Value
then
begin
FShowAutoColor := Value;
if not (csDesigning in ComponentState) and
not (csLoading in ComponentState)
then
InitColors;
end;
end;
procedure TbsSkinColorButton.SetShowMoreColor(Value: Boolean);
begin
if FShowMoreColor <> Value
then
begin
FShowMoreColor := Value;
if not (csDesigning in ComponentState) and
not (csLoading in ComponentState)
then
InitColors;
end;
end;
procedure TbsSkinColorButton.SetColorValue;
begin
FColorMarkerValue := Value;
RePaint;
if not (csDesigning in ComponentState) and
not (csLoading in ComponentState)
then
if Assigned(FOnChangeColor) then FOnChangeColor(Self);
end;
procedure TbsSkinColorButton.InitColors;
var
B: TBitMap;
Item: TbsImagesMenuItem;
I: Integer;
begin
//
FSkinImagesMenu := FColorMenu;
FSkinPopupMenu := nil;
//
if FColorImages.Count <> 0 then FColorImages.Clear;
if FColorMenu.ImagesItems.Count <> 0 then FColorMenu.ImagesItems.Clear;
// init menu
FColorMenu.ColumnsCount := 8;
FColorMenu.SkinData := Self.SkinData;
FColorMenu.ItemIndex := 0;
// 1
if FShowAutoColor
then
begin
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 0;
FColor := FAutoColor;
if (FColorMenu.SkinData <> nil) and
(FColorMenu.SkinData.ResourceStrData <> nil)
then
Caption := FColorMenu.SkinData.ResourceStrData.GetResStr('AUTOCOLOR')
else
Caption := BS_AUTOCOLOR;
Button := True;
end;
end;
// 2
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 1;
FColor := clBlack;
end;
// 3
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 2;
FColor := $00003399;;
end;
// 4
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 3;
FColor := $00003333;
end;
// 5
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 4;
FColor := $00003300;
end;
// 6
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 5;
FColor := $00663300;
end;
// 7
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 6;
FColor := clNavy;
end;
// 8
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 7;
FColor := $00353333;
end;
// 9
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 8;
FColor := $00333333;
end;
// 10
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 9;
FColor := RGB(128, 0, 0);
end;
// 11
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 10;
FColor := RGB(255, 102, 0);
end;
// 12
Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
with Item do
begin
ImageIndex := 11;
FColor := RGB(128, 12
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -