📄 tbxmacosxg32theme.pas
字号:
BtnDisabled := (ButtonInfo.ButtonState and EBSS_DISABLED) <> 0;
BtnHot := (ButtonInfo.ButtonState and EBSS_HOT) <> 0;
BtnPressed := (ButtonInfo.ButtonState and EBDS_PRESSED) <> 0;
//if BtnHot then InflateRect(R, 1, 1);
if BtnHot or BtnPressed then InflateRect(R, -1, -1)
else InflateRect(R, -2, -2);
{ Upper }
BR := R;
BR.Bottom := (R.Top + R.Bottom - 1) div 2;
BtnPressed := (ButtonInfo.ButtonState and EBSS_UP) <> 0;
{if BtnDisabled then StateFlags := UPS_DISABLED
else if BtnPressed then StateFlags := UPS_PRESSED
else if BtnHot then StateFlags := UPS_HOT
else StateFlags := UPS_NORMAL;
DrawThemeBackground(SPIN_THEME, Handle, SPNP_UP, StateFlags, BR, nil);}
yInc:= SPINBUTTONBACKGROUNDUP.Height div 4;
if BtnDisabled then y:=3
else if BtnPressed then y:=2
else if BtnHot then y:=1
else if Embedded then y:= 1
else y:= 0;
biRect:= Rect(0,yInc*y,SPINBUTTONBACKGROUNDUP.Width,yInc*(y+1));
EnlargeBitmap(SPINBUTTONBACKGROUNDUP, Canvas, biRect, BR, 4, 3);
X := (BR.Left + BR.Right) div 2;
Y := (BR.Top + BR.Bottom - 1) div 2;
If BtnDisabled then Pen.Color := clBtnShadow
Else Pen.Color := clBtnText;
Brush.Color := Pen.Color;
Polygon([Point(X - 2, Y + 1), Point(X + 2, Y + 1), Point(X, Y - 1)]);
{ Lower }
BR := R;
BR.Top := (R.Top + R.Bottom) div 2;
BtnPressed := (ButtonInfo.ButtonState and EBSS_DOWN) <> 0;
{if BtnDisabled then StateFlags := DNS_DISABLED
else if BtnPressed then StateFlags := DNS_PRESSED
else if BtnHot then StateFlags := DNS_HOT
else StateFlags := DNS_NORMAL;
DrawThemeBackground(SPIN_THEME, Handle, SPNP_DOWN, StateFlags, BR, nil);}
yInc:= SPINBUTTONBACKGROUNDDOWN.Height div 4;
if BtnDisabled then y:=3
else if BtnPressed then y:=2
else if BtnHot then y:=1
else if Embedded then y:= 1
else y:= 0;
biRect:= Rect(0,yInc*y,SPINBUTTONBACKGROUNDDOWN.Width,yInc*(y+1));
EnlargeBitmap(SPINBUTTONBACKGROUNDDOWN, Canvas, biRect, BR, 4, 3);
X := (BR.Left + BR.Right) div 2;
Y := (BR.Top + BR.Bottom) div 2;
If BtnDisabled then Pen.Color := clBtnShadow
Else Pen.Color := clBtnText;
Brush.Color := Pen.Color;
Polygon([Point(X - 2, Y - 1), Point(X + 2, Y - 1), Point(X, Y + 1)]);
end;
end;
end;
procedure TTBXMacOSXg32Theme.PaintEditFrame(Canvas: TCanvas;
const ARect: TRect; var ItemInfo: TTBXItemInfo;
const EditInfo: TTBXEditInfo);
Var
// C:TColor;
R: TRect;
begin
//inherited;
R:= ARect;
with ItemInfo do
Begin
if Enabled then
begin
if not ((ViewType and TVT_EMBEDDED) = TVT_EMBEDDED) and
not (Pushed or Selected or (HoverKind <> hkNone)) then
begin
InflateRect(R, -1, -1);
Canvas.Brush.Color:= clWindow;
Canvas.Brush.Style:= bsSolid;
Canvas.FillRect(R);
end Else
Begin
If not (Pushed or Selected or (HoverKind <> hkNone)) then
InflateRect(R, -1, -1);
EnlargeBitmap(COMBOBOX, Canvas, Rect(0,0,COMBOBOX.Width,COMBOBOX.Height), R, 6, 3);
End;
end Else
Begin
InflateRect(R, -1, -1);
Canvas.Pen.Color:= clWhite;
Canvas.Brush.Style:= bsClear;
Canvas.Rectangle(R);
End;
End;
if EditInfo.RightBtnWidth > 0 then
Begin
R := ARect;
R.Left := R.Right - EditInfo.RightBtnWidth;
PaintEditButton(Canvas, R, ItemInfo, EditInfo.RightBtnInfo);
End;
// Canvas.Rectangle(ARect);
end;
procedure TTBXMacOSXg32Theme.PaintFloatingBorder(Canvas: TCanvas;
const ARect: TRect; const WindowInfo: TTBXWindowInfo);
var
DC: HDC;
BorderColor, C: TColor;
I: Integer;
Sz: TPoint;
R,R2: TRect;
Size: TSize;
CaptionString: string;
IsPushed, IsHovered: Boolean;
BtnItemState: TBtnItemState;
SaveIndex: Integer;
y, yStart, yInc:Integer;
CloseButtonDown, CloseButtonHover: Boolean;
biRect:TRect;
Flags: Integer;
function GetBtnItemState(BtnState: Integer): TBtnItemState;
begin
if not WindowInfo.Active then Result := bisDisabled
else if (BtnState and CDBS_PRESSED) <> 0 then Result := bisPressed
else if (BtnState and CDBS_HOT) <> 0 then Result := bisHot
else Result := bisNormal;
end;
begin
DC := Canvas.Handle;
with Canvas do
begin
if (WRP_BORDER and WindowInfo.RedrawPart) <> 0 then
begin
R := ARect;
FrameRectEx(DC, R, WinFrameColors[wfsActive, wfpBorder], True);
FillRectEx(DC, R, GetViewColor(WindowInfo.ViewType));
//BtnItemColors[bisSelected, ipFrame]
end;
if not WindowInfo.ShowCaption then Exit;
{ Caption }
if (WRP_CAPTION and WindowInfo.RedrawPart) <> 0 then
begin
R:= ARect;
R.Bottom:= R.Top+GetSystemMetrics(SM_CYSMCAPTION)+WindowInfo.FloatingBorderSize.Y;
FrameRectEx(DC, R, BtnItemColors[bisSelected, ipFrame], True);
DrawCaptionArea(Handle, R, WinFrameColors[wfsActive, wfpBorder], True);
Font.Assign(SmCaptionFont);
Font.Color := clBtnText;
CaptionString := string(WindowInfo.Caption);
Size := TextExtent(CaptionString);
if Size.cx > 0 then Inc(Size.cx, 16);
InflateRect(R, -2, 0);
Dec(R.Top, 2);
Brush.Style := bsClear;
DrawText(Canvas.Handle, PChar(CaptionString), Length(CaptionString), R,
DT_SINGLELINE or DT_CENTER or DT_VCENTER or DT_END_ELLIPSIS or DT_HIDEPREFIX);
Brush.Style := bsSolid;
end;
{ Close button }
if (CDBS_VISIBLE and WindowInfo.CloseButtonState) <> 0 then
begin
CloseButtonDown := (WindowInfo.CloseButtonState and CDBS_PRESSED) <> 0;
CloseButtonHover := (WindowInfo.CloseButtonState and CDBS_HOT) <> 0;
R := Rect(0, 0, WindowInfo.ClientWidth, GetSystemMetrics(SM_CYSMCAPTION));
with Windowinfo.FloatingBorderSize do OffsetRect(R, X, Y);
R.Left := R.Right - (R.Bottom - R.Top) - 1;
{Dec(R.Bottom, 2);
Inc(R.Left, 3); Dec(R.Right);
Inc(R.Top);
Dec(R.Bottom);}
Flags := TS_NORMAL;
if CloseButtonDown then Flags := TS_PRESSED
else if CloseButtonHover then Flags := TS_HOT;
yStart:= 0;
yInc:= MDICLOSE.Height div 4;
// y:=0;
Case Flags of
TS_NORMAL : y:=0;
TS_PRESSED: y:=2;
TS_HOT : y:=1;
Else y:=3;
End;//CASE
biRect:= Rect(0,yStart+yInc*y,MDICLOSE.Width,yStart+yInc*(y+1));
InflateRect(R, (((biRect.Right-biRect.Left)-(R.Right-R.Left)) div 2), (((biRect.Bottom-biRect.Top)-(R.Bottom-R.Top)) div 2));
OffsetRect(R, 0, -1);
//EnlargeBitmap(MDICLOSE, Canvas, biRect, R, 8,8);
DrawImage(MDICLOSE, Canvas, biRect, R.Left, R.Top);
end;
end;
end;
procedure TTBXMacOSXg32Theme.PaintFrameControl(Canvas: TCanvas; R: TRect;
Kind, State: Integer; Params: Pointer);
Var
// graphic: TGPgraphics;
y, yInc, yStart: Integer;
DrawStyle: TDrawStyle;
biRect: TRect;
begin
with Canvas do
begin
//graphic:= TGPgraphics.Create(Canvas.Handle);
//graphic.SetInterpolationMode(FInterpolationMode);
DrawStyle:= bsDefault;
If Boolean(State and PFS_DISABLED) then
DrawStyle:= bsDisabled
Else If Boolean(State and PFS_PUSHED) then
DrawStyle:= bsPushed
Else If Boolean(State and PFS_HOT) then
DrawStyle:= bsHover
;
case Kind of
PFC_CHECKBOX:
Begin
if Boolean(State and PFS_CHECKED) then
yStart:= CheckM.Height div 3
Else if Boolean(State and PFS_MIXED) then
yStart:= (CheckM.Height div 3) * 2
Else
yStart:= 0;
yInc:= CheckM.Height div 12;
y:= 0;
Case DrawStyle of
bsDefault: y:= 0;
//graphic.DrawImage(CheckM, Rect(R), 0,yStart+yInc*0,CheckM.Width,yInc, UnitPixel);
//graphic.DrawImage(CheckM, R.Left,R.Top, 0,yStart+yInc*0,CheckM.Width,yInc, UnitPixel);
bsHover: y:= 2;
//graphic.DrawImage(CheckM, Rect(R), 0,yStart+yInc*2,CheckM.Width,yInc, UnitPixel);
//graphic.DrawImage(CheckM, R.Left,R.Top, 0,yStart+yInc*2,CheckM.Width,yInc, UnitPixel);
bsDisabled: y:= 3;
//graphic.DrawImage(CheckM, Rect(R), 0,yStart+yInc*3,CheckM.Width,yInc, UnitPixel);
//graphic.DrawImage(CheckM, R.Left,R.Top, 0,yStart+yInc*3,CheckM.Width,yInc, UnitPixel);
bsPushed: y:= 1;
//graphic.DrawImage(CheckM, Rect(R), 0,yStart+yInc*1,CheckM.Width,yInc, UnitPixel);
//graphic.DrawImage(CheckM, R.Left,R.Top, 0,yStart+yInc*1,CheckM.Width,yInc, UnitPixel);
End;//CASE
biRect:= Rect(0,yStart+yInc*y,CheckM.Width,yStart+yInc*(y+1));
DrawImage(CheckM, Canvas, biRect, R.Left, R.Top);
End;
PFC_RADIOBUTTON:
Begin
if Boolean(State and PFS_CHECKED) then
yStart:= RadioM.Height div 2
Else
yStart:= 0;
yInc:= RadioM.Height div 8;
Case DrawStyle of
bsDefault: y:= 0;
//graphic.DrawImage(RadioM, Rect(R), 0,yStart+yInc*0,RadioM.Width,yInc, UnitPixel);
//graphic.DrawImage(RadioM, R.Left,R.Top, 0,yStart+yInc*0,RadioM.Width,yInc, UnitPixel);
bsHover: y:= 2;
//graphic.DrawImage(RadioM, Rect(R), 0,yStart+yInc*2,RadioM.Width,yInc, UnitPixel);
//graphic.DrawImage(RadioM, R.Left,R.Top, 0,yStart+yInc*2,RadioM.Width,yInc, UnitPixel);
bsDisabled: y:= 3;
//graphic.DrawImage(RadioM, Rect(R), 0,yStart+yInc*3,RadioM.Width,yInc, UnitPixel);
//graphic.DrawImage(RadioM, R.Left,R.Top, 0,yStart+yInc*3,RadioM.Width,yInc, UnitPixel);
bsPushed: y:= 1;
//graphic.DrawImage(RadioM, Rect(R), 0,yStart+yInc*1,RadioM.Width,yInc, UnitPixel);
//graphic.DrawImage(RadioM, R.Left,R.Top, 0,yStart+yInc*1,RadioM.Width,yInc, UnitPixel);
End;//CASE
biRect:= Rect(0,yStart+yInc*y,RadioM.Width,yStart+yInc*(y+1));
DrawImage(RadioM, Canvas, biRect, R.Left, R.Top);
End;
Else
inherited;
end;//case
// graphic.Free;{}
End;
end;
procedure TTBXMacOSXg32Theme.PaintImage(Canvas: TCanvas; ARect: TRect;
const ItemInfo: TTBXItemInfo; ImageList: TCustomImageList;
ImageIndex: Integer);
var
HiContrast: Boolean;
begin
with ItemInfo do
begin
if ImageList is TTBCustomImageList then
begin
TTBCustomImageList(ImageList).DrawState(Canvas, ARect.Left, ARect.Top,
ImageIndex, Enabled, (HoverKind <> hkNone), Selected);
Exit;
end;
HiContrast := ColorIntensity(GetItemImageBackground(ItemInfo)) < 80;
if not Enabled then
begin
if not HiContrast then
DrawTBXIconShadow(Canvas, ARect, ImageList, ImageIndex, 0)
else
DrawTBXIconFlatShadow(Canvas, ARect, ImageList, ImageIndex, clBtnShadow);
end
else if Selected or Pushed or (HoverKind <> hkNone) then
begin
if not (Selected or Pushed and not IsPopupParent) then
begin
DrawTBXIconShadow(Canvas, ARect, ImageList, ImageIndex, 1);
OffsetRect(ARect, 1, 1);
DrawTBXIconShadow(Canvas, ARect, ImageList, ImageIndex, 1);
OffsetRect(ARect, -2, -2);
end;
DrawTBXIcon(Canvas, ARect, ImageList, ImageIndex, HiContrast);
end
else if HiContrast or TBXHiContrast or TBXLoColor then
DrawTBXIcon(Canvas, ARect, ImageList, ImageIndex, HiContrast)
else
//HighlightTBXIcon(Canvas, ARect, ImageList, ImageIndex, clWindow, 178);
BlendTBXIcon(Canvas, ARect, ImageList, ImageIndex, 178);
end;
end;
procedure TTBXMacOSXg32Theme.PaintMDIButton(Canvas: TCanvas; ARect: TRect;
const ItemInfo: TTBXItemInfo; ButtonKind: Cardinal);
Var
y, yinc:Integer;
img: TBitmap32;
biRect, r: TRect;
begin
case ButtonKind of
DFCS_CAPTIONMIN: img:= MINIMIZEGLYPH;
DFCS_CAPTIONRESTORE: img:= MAXIMIZEGLYPH;
DFCS_CAPTIONCLOSE: img:= CLOSEGLYPH;
else
Exit;
end;
yinc:= img.Height div 4;
If Not ItemInfo.Enabled then
y:= 3
Else If ItemInfo.Pushed or ItemInfo.Selected then
y:= 2
Else If ItemInfo.HoverKind<>hkNone then
y:= 1
Else
y:= 0;
biRect:= Rect(0,0+yInc*y,img.Width,0+yInc*(y+1));
R:= ARect;
InflateRect(R, (((biRect.Right-biRect.Left)-(R.Right-R.Left)) div 2), (((biRect.Bottom-biRect.Top)-(R.Bottom-R.Top)) div 2));
OffsetRect(R, 0, -1);
DrawImage(img, Canvas, biRect, R.Left, R.Top);
end;
procedure TTBXMacOSXg32Theme.PaintMenuItem(Canvas: TCanvas; const ARect: TRect; var ItemInfo: TTBXItemInfo);
var
R, R2: TRect;
X, Y: Integer;
ArrowWidth: Integer;
ClrText: TColor;
procedure DrawArrow(AColor: TColor);
begin
Canvas.Pen.Color := AColor;
Canvas.Brush.Color := AColor;
Canvas.Polygon([Point(X, Y - 3), Point(X, Y + 3), Point(X + 3, Y)]);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -