📄 dxbarcustform.pas
字号:
end;
end;
class procedure TdxBarCustomizingFormFlatPainter.DrawComboBoxButton(
ACanvas: TCanvas; AItem: TdxBarItem; ARect: TRect; ASelected: Boolean);
begin
with ACanvas do
begin
Inc(ARect.Left);
if ASelected then
begin
InflateRect(ARect, 1, 1);
FrameFlatSelRect(Handle, ARect);
end
else
begin
Brush.Color := clBtnHighlight;
FrameRect(ARect);
Pen.Color := Brush.Color;
end;
if not ASelected then
begin
MoveTo(ARect.Left - 1, ARect.Top);
LineTo(ARect.Left - 1, ARect.Bottom);
end;
InflateRect(ARect, -1, -1);
if ASelected then
Brush.Color := TdxBarManagerAccess(AItem.BarManager).FlatToolbarsSelColor
else
Brush.Color := BrushColors(False, AItem);
FillRect(ARect);
Pen.Color := clBtnText;
if ASelected then
InflateRect(ARect, -1, -1);
InflateRect(ARect, 2, 0);
DrawItemArrow(Handle, ARect, adDown, True, ASelected and IsHighContrastWhite, True{Flat});
end;
end;
class procedure TdxBarCustomizingFormFlatPainter.DrawFocusedRect(ACanvas: TCanvas; ARect: TRect; AItem: TdxBarItem);
begin
// do nothing
end;
class function TdxBarCustomizingFormFlatPainter.FontColors(Selected: Boolean): TColor;
begin
Result := clBtnText;
if Selected and IsHighContrastWhite then
Result := clBtnFace;
end;
class procedure TdxBarCustomizingFormFlatPainter.DrawEditEdge(ACanvas: TCanvas;
var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean);
begin
ACanvas.Brush.Color := BrushColors(False, AItem);
if ASelected then
FrameFlatSelRect(ACanvas.Handle, AItemRect)
else
Windows.FrameRect(ACanvas.Handle, AItemRect, GetSysColorBrush(COLOR_BTNSHADOW));
InflateRect(AItemRect, -1, -1);
end;
class procedure TdxBarCustomizingFormFlatPainter.InternalDrawCaption(ACanvas: TCanvas;
var ATextRect: TRect; const AText: string; AItem: TdxCustomBarEdit; ASelected: Boolean);
const
ATextOffset = 5;
var
ARect: TRect;
begin
ARect := ATextRect;
ACanvas.Brush.Color := BrushColors(ASelected, AItem);
Inc(ARect.Right, 1 + ATextOffset + 5);
ACanvas.FillRect(ARect);
if ASelected then
begin
Inc(ARect.Right);
FrameFlatSelRect(ACanvas.Handle, ARect);
Dec(ARect.Right);
end;
Inc(ARect.Left, ATextOffset);
ACanvas.Font.Color := FontColors(ASelected);
cxDrawText(ACanvas.Handle, AText, ARect, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER);
ATextRect.Right := ARect.Right;
end;
{ TdxBarCustomizingFormOffice11Painter }
class function TdxBarCustomizingFormOffice11Painter.BrushColors(
Selected: Boolean; AItem: TdxBarItem): TColor;
begin
if Selected then
Result := dxOffice11ToolbarSelectedColor
else
Result := dxOffice11MenuColor;
end;
class procedure TdxBarCustomizingFormOffice11Painter.DrawButtonOrSubItem(ACanvas: TCanvas;
ARect: TRect; AItem: TdxBarItem; ACaption: string; Selected: Boolean);
var
R: TRect;
S: string;
IsGlyph: Boolean;
W, H: Integer;
FullImageRect: TRect;
begin
R := ARect;
with TdxBarItemAccess(AItem) do
IsGlyph := not Glyph.Empty or CurImageIndexLinked;
with ACanvas, R do
begin
Brush.Color := BrushColors(Selected, AItem);
if Selected then
begin
FillRect(R);
Right := Left + Bottom - Top;
end
else
begin
Inc(Left, Bottom - Top);
FillRect(R);
Right := Left;
Left := ARect.Left;
FillTubeGradientRect(Handle, R, dxOffice11MenuIndentColor1, dxOffice11MenuIndentColor2, True);
end;
if IsGlyph then
begin
if AItem.Glyph.Empty then
with AItem.GetCurImages do
begin
W := Width;
H := Height;
end
else
with AItem.Glyph do
begin
W := Width;
H := Height;
end;
with R do
R := Bounds((Left + Right - W) div 2, (Top + Bottom - H) div 2, W, H);
FullImageRect := R;
InflateRect(FullImageRect, 1, 1);
TransparentDraw(Handle, 0, FullImageRect, R, AItem.Glyph,
AItem.GetCurImages, AItem.ImageIndex, AItem.BarManager.ImageListBkColor,
True, False, False{Flat}, Selected, False, False, False{Shadow}, False{Faded},
AItem.BarManager.ImageOptions.UseLeftBottomPixelAsTransparent);
end;
Font.Color := FontColors(Selected);
Brush.Color := BrushColors(Selected, AItem);
R := ARect;
if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then
Dec(R.Right, 4 + 4 + 5);
Left := Bottom - Top + 10;
S := ACaption;
if (AItem is TCustomdxBarContainerItem) and
TCustomdxBarContainerItemAccess(AItem).HideWhenRun then
S := '(' + ACaption + ')';
cxDrawText(Handle, S, R, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER);
if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then
begin
R.Left := R.Right;
R.Right := ARect.Right;
if Selected then
Office11FrameSelectedRect(Handle, R)
else
Windows.FrameRect(Handle, R, dxOffice11BarSeparatorBrush1);
InflateRect(R, -1, -1);
Brush.Color := BrushColors(Selected, AItem);
FillRect(R);
Font.Color := FontColors(False);
DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, Selected);
end
else
if (AItem is TCustomdxBarSubItem) and not (AItem is TCustomdxBarContainerItem) or
(AItem is TCustomdxBarContainerItem) and not TCustomdxBarContainerItemAccess(AItem).HideWhenRun then
DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, Selected);
if Selected then
Office11FrameSelectedRect(Handle, ARect);
end;
end;
class procedure TdxBarCustomizingFormOffice11Painter.DrawComboBoxButton(
ACanvas: TCanvas; AItem: TdxBarItem; ARect: TRect; ASelected: Boolean);
begin
with ACanvas do
begin
Inc(ARect.Left);
if ASelected then
begin
InflateRect(ARect, 1, 1);
Office11FrameSelectedRect(Handle, ARect);
end
else
begin
Brush.Color := clWindow;
FrameRect(ARect);
Pen.Color := Brush.Color;
end;
if not ASelected then
begin
MoveTo(ARect.Left - 1, ARect.Top);
LineTo(ARect.Left - 1, ARect.Bottom);
end;
InflateRect(ARect, -1, -1);
if ASelected then
Brush.Color := dxOffice11ToolbarSelectedColor
else
Brush.Color := dxOffice11OwnerControlDownedColor;
FillRect(ARect);
Pen.Color := clBtnText;
if ASelected then
InflateRect(ARect, -1, -1);
InflateRect(ARect, 2, 0);
DrawItemArrow(Handle, ARect, adDown, True, ASelected and IsHighContrastWhite, True{Flat});
end;
end;
class function TdxBarCustomizingFormOffice11Painter.FontColors(
Selected: Boolean): TColor;
begin
Result := dxOffice11TextEnabledColor;
if Selected and IsHighContrastWhite then
Result := clBtnFace;
end;
class function TdxBarCustomizingFormOffice11Painter.GetButtonColor(
AItem: TdxBarItem; ASelected: Boolean): Integer;
begin
Result := dxOffice11OwnerControlDownedColor;
end;
class procedure TdxBarCustomizingFormOffice11Painter.DrawEditEdge(ACanvas: TCanvas;
var AItemRect: TRect; AItem: TdxCustomBarEdit; ASelected: Boolean);
begin
ACanvas.Brush.Color := BrushColors(False, AItem);
if ASelected then
Office11FrameSelectedRect(ACanvas.Handle, AItemRect)
else
Windows.FrameRect(ACanvas.Handle, AItemRect, dxOffice11OwnerControlDownedBrush);
InflateRect(AItemRect, -1, -1);
end;
class procedure TdxBarCustomizingFormOffice11Painter.InternalDrawCaption(ACanvas: TCanvas;
var ATextRect: TRect; const AText: string; AItem: TdxCustomBarEdit; ASelected: Boolean);
const
ATextOffset = 10;
var
AItemHeight: Integer;
ARect, AIndentRect: TRect;
begin
ARect := ATextRect;
AItemHeight := ARect.Bottom - ARect.Top;
ACanvas.Brush.Color := BrushColors(ASelected, AItem);
Inc(ARect.Right, 1 + 5 + ATextOffset + AItemHeight);
if ASelected then
begin
ACanvas.FillRect(ARect);
Inc(ARect.Right);
Office11FrameSelectedRect(ACanvas.Handle, ARect);
Dec(ARect.Right);
end
else
begin
AIndentRect := ARect;
AIndentRect.Right := AIndentRect.Left + AItemHeight;
FillTubeGradientRect(ACanvas.Handle, AIndentRect, dxOffice11MenuIndentColor1, dxOffice11MenuIndentColor2, True);
Inc(ARect.Left, AItemHeight);
ACanvas.FillRect(ARect);
Dec(ARect.Left, AItemHeight);
end;
Inc(ARect.Left, ATextOffset + AItemHeight);
ACanvas.Font.Color := FontColors(ASelected);
cxDrawText(ACanvas.Handle, AText, ARect, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER);
ATextRect.Right := ARect.Right;
end;
{ TdxBarCustomizingFormXPPainter }
class procedure TdxBarCustomizingFormXPPainter.DrawButtonOrSubItem(ACanvas: TCanvas;
ARect: TRect; AItem: TdxBarItem; ACaption: string; Selected: Boolean);
var
R: TRect;
S: string;
IsGlyph: Boolean;
W, H: Integer;
FullImageRect: TRect;
ATheme: TdxTheme;
begin
R := ARect;
with TdxBarItemAccess(AItem) do
IsGlyph := not Glyph.Empty or CurImageIndexLinked;
with ACanvas, R do
begin
Right := Left + dxBarButtonWidth;
Brush.Color := BrushColors(not IsGlyph and Selected, AItem);
FillRect(R);
Pen.Color := Brush.Color;
MoveTo(Right, Top);
LineTo(Right, Bottom);
if IsGlyph then
begin
if Selected and (AItem is TdxBarButton) then
begin
// xp
ATheme := OpenTheme(totToolBar);
DrawThemeBackground(ATheme, Handle, TP_BUTTON, TS_HOT, @R);
// xp end
end;
if AItem.Glyph.Empty then
with AItem.GetCurImages do
begin
W := Width;
H := Height;
end
else
with AItem.Glyph do
begin
W := Width;
H := Height;
end;
with R do
R := Bounds((Left + Right - W) div 2, (Top + Bottom - H) div 2, W, H);
FullImageRect := R;
TransparentDraw(Handle, 0, FullImageRect, R, AItem.Glyph,
AItem.GetCurImages, AItem.ImageIndex, AItem.BarManager.ImageListBkColor,
True, False, False{Flat}, Selected, False, False, False{Shadow}, False{Faded},
AItem.BarManager.ImageOptions.UseLeftBottomPixelAsTransparent);
end;
Font.Color := FontColors(Selected);
Brush.Color := BrushColors(Selected, AItem);
R := ARect;
if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then
Dec(R.Right, 4 + 4 + 5);
Inc(Left, dxBarButtonWidth + 1);
FillRect(R);
Inc(Left, 2);
S := ACaption;
if (AItem is TCustomdxBarContainerItem) and
TCustomdxBarContainerItemAccess(AItem).HideWhenRun then
S := '(' + ACaption + ')';
cxDrawText(Handle, S, R, DT_NOCLIP or DT_NOPREFIX or DT_SINGLELINE or DT_LEFT or DT_VCENTER);
if (AItem is TdxBarButton) and (TdxBarButton(AItem).ButtonStyle = bsDropDown) then
begin
R.Left := R.Right;
R.Right := ARect.Right;
Brush.Color := BrushColors(False, AItem);
FillRect(R);
// xp
ATheme := OpenTheme(totToolBar);
DrawThemeBackground(ATheme, Handle, TP_BUTTON, TS_HOT, @R);
// xp end
Font.Color := FontColors(False);
DrawSubItemArrow(ACanvas, ARect.Right - (4 + 5), ARect.Top + (dxBarButtonHeight - 7) div 2, False);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -