📄 tbxmacosxg32theme.pas
字号:
SPINBUTTONBACKGROUNDRIGHT.StretchFilter:= FStretchFilter;
End;
If Not Assigned(COMBOBOX) then
Begin
ResStream:= TResourceStream.Create(HInstance, 'COMBOBOX', RT_RCDATA);
P.LoadFromStream(ResStream);
ResStream.Free;
COMBOBOX:= TBitmap32.Create;
PngObjectToBitmap32(P, COMBOBOX);
COMBOBOX.DrawMode:=dmBlend;
COMBOBOX.StretchFilter:= FStretchFilter;
End;
If Not Assigned(MDICLOSE) then
Begin
ResStream:= TResourceStream.Create(HInstance, 'MDICLOSE', RT_RCDATA);
P.LoadFromStream(ResStream);
ResStream.Free;
MDICLOSE:= TBitmap32.Create;
PngObjectToBitmap32(P, MDICLOSE);
MDICLOSE.DrawMode:=dmBlend;
MDICLOSE.StretchFilter:= FStretchFilter;
End;
If Not Assigned(SPINBUTTONBACKGROUNDUP) then
Begin
ResStream:= TResourceStream.Create(HInstance, 'SPINBUTTONBACKGROUNDUP', RT_RCDATA);
P.LoadFromStream(ResStream);
ResStream.Free;
SPINBUTTONBACKGROUNDUP:= TBitmap32.Create;
PngObjectToBitmap32(P, SPINBUTTONBACKGROUNDUP);
SPINBUTTONBACKGROUNDUP.DrawMode:=dmBlend;
SPINBUTTONBACKGROUNDUP.StretchFilter:= FStretchFilter;
End;
If Not Assigned(SPINBUTTONBACKGROUNDDOWN) then
Begin
ResStream:= TResourceStream.Create(HInstance, 'SPINBUTTONBACKGROUNDDOWN', RT_RCDATA);
P.LoadFromStream(ResStream);
ResStream.Free;
SPINBUTTONBACKGROUNDDOWN:= TBitmap32.Create;
PngObjectToBitmap32(P, SPINBUTTONBACKGROUNDDOWN);
SPINBUTTONBACKGROUNDDOWN.DrawMode:=dmBlend;
SPINBUTTONBACKGROUNDDOWN.StretchFilter:= FStretchFilter;
End;
If Not Assigned(CLOSEGLYPH) then
Begin
ResStream:= TResourceStream.Create(HInstance, 'CLOSEGLYPH', RT_RCDATA);
P.LoadFromStream(ResStream);
ResStream.Free;
CLOSEGLYPH:= TBitmap32.Create;
PngObjectToBitmap32(P, CLOSEGLYPH);
CLOSEGLYPH.DrawMode:=dmBlend;
CLOSEGLYPH.StretchFilter:= FStretchFilter;
End;
If Not Assigned(MINIMIZEGLYPH) then
Begin
ResStream:= TResourceStream.Create(HInstance, 'MINIMIZEGLYPH', RT_RCDATA);
P.LoadFromStream(ResStream);
ResStream.Free;
MINIMIZEGLYPH:= TBitmap32.Create;
PngObjectToBitmap32(P, MINIMIZEGLYPH);
MINIMIZEGLYPH.DrawMode:=dmBlend;
MINIMIZEGLYPH.StretchFilter:= FStretchFilter;
End;
If Not Assigned(MAXIMIZEGLYPH) then
Begin
ResStream:= TResourceStream.Create(HInstance, 'MAXIMIZEGLYPH', RT_RCDATA);
P.LoadFromStream(ResStream);
ResStream.Free;
MAXIMIZEGLYPH:= TBitmap32.Create;
PngObjectToBitmap32(P, MAXIMIZEGLYPH);
MAXIMIZEGLYPH.DrawMode:=dmBlend;
MAXIMIZEGLYPH.StretchFilter:= FStretchFilter;
End;
P.Free;
end;
procedure FinalizeStock;
begin
end;
procedure DrawCaptionArea(DC: HDC; R: TRect; Color: TColor; Vertical: Boolean);
var
T: Integer;
begin
if Vertical then
begin
T := (2 * R.Top + R.Bottom) div 3;
GradFill(DC, Rect(R.Left, R.Top, R.Right, T), Lighten(Color, 24), Color, gkVert);
GradFill(DC, Rect(R.Left, T, R.Right, R.Bottom), Color, Lighten(Color, -8), gkVert);
end
else
begin
T := (2 * R.Left + R.Right) div 3;
GradFill(DC, Rect(R.Left, R.Top, T, R.Bottom), Lighten(Color, 24), Color, gkHorz);
GradFill(DC, Rect(T, R.Top, R.Right, R.Bottom), Color, Lighten(Color, -8), gkHorz);
end;
end;
constructor TTBXMacOSXg32Theme.Create(const AName: string);
begin
inherited;
if CounterLock = 0 then InitializeStock;
Inc(CounterLock);
// FInterpolationMode:= InterpolationModeHighQuality;//InterpolationModeHighQualityBicubic;//InterpolationModeNearestNeighbor;//
SetupColorCache;
end;
destructor TTBXMacOSXg32Theme.Destroy;
begin
Dec(CounterLock);
if CounterLock = 0 then FinalizeStock;
inherited;
end;
procedure TTBXMacOSXg32Theme.DrawImage(Source: TBitmap32; Target: TCanvas;
SourceRect:TRect; x, y: Integer);
begin
//DrawBitmap32(Target.Handle, Rect(x,y,x+Source.
DrawBitmap32Rect(Target.Handle, x,y, Source, SourceRect);
{ graphic:= TGPgraphics.Create(Target.Handle);
//graphic.SetInterpolationMode(FInterpolationMode);
With SourceRect do
graphic.DrawImage(Source,x,y,
Left,Top,Right-Left,Bottom-Top,UnitPixel);
graphic.Free;{}
end;
procedure TTBXMacOSXg32Theme.DrawStripeBG(Target: TCanvas; R: TRect; AColor:TColor);
const
STRIPE_STEP = 4; {3}
var
Y, I: Integer;
HighlightColor,ShadowColor:TColor;
DC: HDC;
Begin
DC:= Target.Handle;
I := ColorIntensity(AColor);
if I < 200 then I := (200 - I) div 20
else I := 0;
HighlightColor := GetNearestColor(DC, Lighten(AColor, 11 + I));
ShadowColor := GetNearestColor(DC, Lighten(AColor, -8)); {8}
//if not Transparent then
begin
{Target.Brush.Color := AColor;
Target.FillRect(R);}
FillRectEx(DC, R, AColor);
end;
Y:= R.Top mod (STRIPE_STEP);
Y := R.Top - Y;
while Y < R.Bottom do
begin
DrawLineEx(DC, R.Left, Y, R.Right, Y, ShadowColor);
Inc(Y, 2);
DrawLineEx(DC, R.Left, Y, R.Right, Y, HighlightColor);
Inc(Y, 2);
end;
{ Y:= R.Top mod (STRIPE_STEP*2);
Y := R.Top - Y;
R1:= Rect(R.Left,Y,R.Right,Y+STRIPE_STEP);
while R1.Bottom< R.Bottom do
begin
FillRectEx(DC,R1,HighlightColor);
OffsetRect(R1,0,STRIPE_STEP);
// Inc(Y,STRIPE_STEP);
FillRectEx(DC,R1,ShadowColor);
OffsetRect(R1,0,STRIPE_STEP);
// Inc(Y,STRIPE_STEP);
end;}
end;
procedure TTBXMacOSXg32Theme.EnlargeBitmap(Source: TBitmap32; Target: TCanvas;
SourceRect, TargetRect: TRect; VSideSize, HSideSize: Integer);
Var
R1:TRect;
R2:TRect;
tv2, th2: Integer;
trgWidth, trgHeight: Integer;
srcWidth, srcHeight: Integer;
begin
srcWidth:= SourceRect.Right-SourceRect.Left;
srcHeight:= SourceRect.Bottom-SourceRect.Top;
If srcWidth-HSideSize*2<2 then
HSideSize:=(srcWidth div 2)-1;
If srcHeight-VSideSize*2<2 then
VSideSize:=(srcHeight div 2)-1;
trgWidth := TargetRect.Right- TargetRect.Left;
trgHeight:= TargetRect.Bottom-TargetRect.Top;
tv2:= trgHeight div 2;
tv2:= Min(tv2, VSideSize);
th2:= trgWidth div 2;
th2:= Min(th2, HSideSize);
StockBitmap321.SetSize(trgWidth, trgHeight);
StockBitmap321.Clear($00000000);
With SourceRect do
Begin
//Source.DrawTo(StockBitmap321, StockBitmap321.BoundsRect, SourceRect);
// center
r1:= Rect(th2,tv2,trgWidth-th2,trgHeight-tv2);
r2:= Rect(Left+HSideSize,Top+VSideSize,Right-HSideSize,Bottom-VSideSize);
Source.DrawTo(StockBitmap321, R1, R2);
// left
r1:= Rect(0,tv2,th2,trgHeight-tv2);
r2:= Rect(Left,Top+VSideSize,Left+HSideSize,Bottom-VSideSize);
Source.DrawTo(StockBitmap321, R1, R2);
// top
r1:= Rect(th2,0,trgWidth-th2,tv2);
r2:= Rect(Left+HSideSize,Top,Right-HSideSize,Top+VSideSize);
Source.DrawTo(StockBitmap321, R1, R2);
// right
r1:= Rect(trgWidth-th2,tv2,trgWidth,trgHeight-tv2);
r2:= Rect(Right-HSideSize,Top+VSideSize,Right,Bottom-VSideSize);
Source.DrawTo(StockBitmap321, R1, R2);
// bottom
r1:= Rect(th2,trgHeight-tv2,trgWidth-th2,trgHeight);
r2:= Rect(Left+HSideSize,Bottom-VSideSize,Right-HSideSize,Bottom);
Source.DrawTo(StockBitmap321, R1, R2);
// left top
r1:= Rect(0, 0, th2, tv2);
r2:= Rect(Left,Top,Left+HSideSize,Top+VSideSize);
Source.DrawTo(StockBitmap321, R1, R2);
// right top
r1:= Rect(trgWidth-th2, 0, trgWidth, tv2);
r2:= Rect(Right-HSideSize,Top,Right,Top+VSideSize);
Source.DrawTo(StockBitmap321, R1, R2);
// left bottom
r1:= Rect(0, trgHeight-tv2, th2, trgHeight);
r2:= Rect(Left,Bottom-VSideSize,Left+HSideSize,Bottom);
Source.DrawTo(StockBitmap321, R1, R2);
// right bottom
r1:= Rect(trgWidth-th2,trgHeight-tv2, trgWidth, trgHeight);
r2:= Rect(Right-HSideSize,Bottom-VSideSize,Right,Bottom);
Source.DrawTo(StockBitmap321, R1, R2);
End;
DrawBitmap32(Target.Handle, TargetRect, StockBitmap321);
end;
function TTBXMacOSXg32Theme.GetBtnColor(const ItemInfo: TTBXItemInfo;
ItemPart: TItemPart): TColor;
const
BFlags1: array[Boolean] of TBtnItemState = (bisDisabled, bisDisabledHot);
BFlags2: array[Boolean] of TBtnItemState = (bisSelected, bisSelectedHot);
BFlags3: array[Boolean] of TBtnItemState = (bisNormal, bisHot);
var
B: TBtnItemState;
Embedded: Boolean;
begin
with ItemInfo do
begin
Embedded := (ViewType and VT_TOOLBAR = VT_TOOLBAR) and
(ViewType and TVT_EMBEDDED = TVT_EMBEDDED);
if not Enabled then B := BFlags1[HoverKind = hkKeyboardHover]
else if ItemInfo.IsPopupParent then
B := bisPopupParent
else if Pushed then B := bisPressed
else if Selected then B := BFlags2[HoverKind <> hkNone]
else B := BFlags3[HoverKind <> hkNone];
Result := BtnItemColors[B, ItemPart];
if Embedded then
begin
if (ItemPart = ipBody) and (Result = clNone) then Result := ToolbarColor;
if ItemPart = ipFrame then
begin
if Selected then Result := clWindowFrame
else if (Result = clNone) then Result := clBtnShadow;
end;
end;
end;
end;
function TTBXMacOSXg32Theme.GetIntegerMetrics(Index: Integer): Integer;
begin
case Index of
TMI_EDIT_BTNWIDTH: Result := 18;
else
Result := Inherited GetIntegerMetrics(Index);
end;
end;
function TTBXMacOSXg32Theme.GetItemColor(
const ItemInfo: TTBXItemInfo): TColor;
begin
Result := GetPartColor(ItemInfo, ipBody);
if Result = clNone then Result := GetViewColor(ItemInfo.ViewType);
end;
function TTBXMacOSXg32Theme.GetItemImageBackground(
const ItemInfo: TTBXItemInfo): TColor;
begin
Result := GetBtnColor(ItemInfo, ipBody);
if Result = clNone then result := GetViewColor(ItemInfo.ViewType);
end;
function TTBXMacOSXg32Theme.GetItemTextColor(
const ItemInfo: TTBXItemInfo): TColor;
begin
Result := GetPartColor(ItemInfo, ipText);
end;
function TTBXMacOSXg32Theme.GetPartColor(const ItemInfo: TTBXItemInfo;
ItemPart: TItemPart): TColor;
const
MFlags1: array[Boolean] of TMenuItemState = (misDisabled, misDisabledHot);
MFlags2: array[Boolean] of TMenuItemState = (misNormal, misHot);
BFlags1: array[Boolean] of TBtnItemState = (bisDisabled, bisDisabledHot);
BFlags2: array[Boolean] of TBtnItemState = (bisSelected, bisSelectedHot);
BFlags3: array[Boolean] of TBtnItemState = (bisNormal, bisHot);
var
IsMenuItem, Embedded: Boolean;
M: TMenuItemState;
B: TBtnItemState;
begin
with ItemInfo do
begin
IsMenuItem := ((ViewType and PVT_POPUPMENU) = PVT_POPUPMENU) and
((ItemOptions and IO_TOOLBARSTYLE) = 0);
Embedded := ((ViewType and VT_TOOLBAR) = VT_TOOLBAR) and
((ViewType and TVT_EMBEDDED) = TVT_EMBEDDED);
if IsMenuItem then
begin
if not Enabled then M := MFlags1[HoverKind = hkKeyboardHover]
else M := MFlags2[HoverKind <> hkNone];
Result := MenuItemColors[M, ItemPart];
end
else
begin
if not Enabled then B := BFlags1[HoverKind = hkKeyboardHover]
else if ItemInfo.IsPopupParent then B := bisPopupParent
else if Pushed then B := bisPressed
else if Selected then B := BFlags2[HoverKind <> hkNone]
else B := BFlags3[HoverKind <> hkNone];
Result := BtnItemColors[B, ItemPart];
if Embedded and (Result = clNone) then
begin
if ItemPart = ipBody then Result := ToolbarColor;
if ItemPart = ipFrame then Result := clBtnShadow;
end;
end;
end;
end;
function TTBXMacOSXg32Theme.GetViewColor(AViewType: Integer): TColor;
begin
Result := clBtnFace;
if (AViewType and VT_TOOLBAR) = VT_TOOLBAR then
begin
if (AViewType and TVT_MENUBAR) = TVT_MENUBAR then Result := MenubarColor
else Result := ToolbarColor;
end
else if (AViewType and VT_POPUP) = VT_POPUP then
begin
if (AViewType and PVT_LISTBOX) = PVT_LISTBOX then Result := clWindow
else Result := PopupColor;
end
else if (AViewType and VT_DOCKPANEL) = VT_DOCKPANEL then Result := DockPanelColor;
end;
procedure TTBXMacOSXg32Theme.PaintBackgnd(Canvas: TCanvas; const ADockRect,
ARect, AClipRect: TRect; AColor: TColor; Transparent: Boolean;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -