📄 cxpcpainters.pas
字号:
begin
if Left = 0 then
begin
InternalPolyLine([Point(Left, Bottom), Point(Left, Bottom)], cxPCLightestEdgeColor);
InternalPolyLine([Point(Left + 1, Bottom), Point(Left + 1, Bottom)], cxPCLightEdgeColor);
end
// if not((Tab.PaintingPositionIndex in [1, 2]) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Left) or
// (Tab.PaintingPositionIndex = 3) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Right)) then
else
InternalPolyLine([Point(Left, Bottom), Point(Left + 1, Bottom)], cxPCLightEdgeColor);
if Right = ParentInfo.Width then
// if (Tab.PaintingPositionIndex in [1, 2]) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Right) or
// (Tab.PaintingPositionIndex = 3) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Left) then
begin
InternalPolyLine([Point(Left + 2, Bottom), Point(Right - 3, Bottom)], cxPCTabBodyColor);
InternalPolyLine([Point(Right - 2, Bottom), Point(Right - 2, Bottom)], cxPCDarkEdgeColor);
InternalPolyLine([Point(Right - 1, Bottom), Point(Right - 1, Bottom)], cxPCDarkestEdgeColor);
end
else
InternalPolyLine([Point(Left + 2, Bottom), Point(Right - 1, Bottom)], cxPCTabBodyColor);
end;
end;
tppBottom:
begin
InternalPolyLine([Point(Left, Top), Point(Left, Bottom - 3), Point(Left + 1, Bottom - 2)], cxPCLightestEdgeColor);
InternalPolyLine([Point(Left + 1, Top), Point(Left + 1, Bottom - 3)], cxPCLightEdgeColor);
InternalPolyLine([Point(Left + 2, Bottom - 1), Point(Right - 3, Bottom - 1), Point(Right - 1, Bottom - 3), Point(Right - 1, Top)], cxPCDarkestEdgeColor);
InternalPolyLine([Point(Left + 2, Bottom - 2), Point(Right - 3, Bottom - 2), Point(Right - 2, Bottom - 3), Point(Right - 2, Top)], cxPCDarkEdgeColor);
if MainTab then
begin
if Left = 0 then
// if (Tab.PaintingPositionIndex in [10, 11]) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Left) or
// (Tab.PaintingPositionIndex = 12) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Right) then
begin
InternalPolyLine([Point(Left, Top - 1), Point(Left, Top - 1)], cxPCLightestEdgeColor);
InternalPolyLine([Point(Left + 1, Top - 1), Point(Left + 1, Top - 1)], cxPCLightEdgeColor);
InternalPolyLine([Point(Left + 2, Top - 1), Point(Right - 3, Top - 1)], cxPCTabBodyColor);
end
else
InternalPolyLine([Point(Left, Top - 1), Point(Right - 3, Top - 1)], cxPCTabBodyColor);
if Right = ParentInfo.Width then
// if (Tab.PaintingPositionIndex in [10, 11]) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Right) or
// (Tab.PaintingPositionIndex = 12) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Left) then
begin
InternalPolyLine([Point(Right - 2, Top - 1), Point(Right - 2, Top - 1)], cxPCDarkEdgeColor);
InternalPolyLine([Point(Right - 1, Top - 1), Point(Right - 1, Top - 1)], cxPCDarkestEdgeColor);
end
else
InternalPolyLine([Point(Right - 2, Top - 1), Point(Right - 1, Top - 1)], cxPCDarkEdgeColor);
end;
end;
tppLeft:
begin
InternalPolyLine([Point(Left, Bottom - 3), Point(Left, Top + 2), Point(Left + 2, Top), Point(Right - 1, Top)], cxPCLightestEdgeColor);
InternalPolyLine([Point(Left + 1, Bottom - 3), Point(Left + 1, Top + 2), Point(Left + 2, Top + 1), Point(Right - 1, Top + 1)], cxPCLightEdgeColor);
InternalPolyLine([Point(Left + 2, Bottom - 2), Point(Left + 3, Bottom - 1), Point(Right - 1, Bottom - 1)], cxPCDarkestEdgeColor);
InternalPolyLine([Point(Left + 1, Bottom - 2), Point(Left + 2, Bottom - 1), Point(Left + 3, Bottom - 2), Point(Right - 1, Bottom - 2)], cxPCDarkEdgeColor);
if MainTab then
begin
if Top = 0 then
// if (Tab.PaintingPositionIndex in [5, 6]) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Left) or
// (Tab.PaintingPositionIndex = 4) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Right) then
begin
InternalPolyLine([Point(Right, Top), Point(Right, Top)], cxPCLightestEdgeColor);
InternalPolyLine([Point(Right, Top + 1), Point(Right, Top + 1)], cxPCLightEdgeColor);
end
else
InternalPolyLine([Point(Right, Top), Point(Right, Top + 1)], cxPCLightEdgeColor);
if Bottom = ParentInfo.Height then
// if (Tab.PaintingPositionIndex in [5, 6]) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Right) or
// (Tab.PaintingPositionIndex = 4) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Left) then
begin
InternalPolyLine([Point(Right, Top + 2), Point(Right, Bottom - 3)], cxPCTabBodyColor);
InternalPolyLine([Point(Right, Bottom - 2), Point(Right, Bottom - 2)], cxPCDarkEdgeColor);
InternalPolyLine([Point(Right, Bottom - 1), Point(Right, Bottom - 1)], cxPCDarkestEdgeColor);
end
else
InternalPolyLine([Point(Right, Top + 2), Point(Right, Bottom - 1)], cxPCTabBodyColor);
end;
end;
tppRight:
begin
InternalPolyLine([Point(Left, Top), Point(Right - 3, Top), Point(Right - 2, Top + 1)], cxPCLightestEdgeColor);
InternalPolyLine([Point(Left, Top + 1), Point(Right - 3, Top + 1)], cxPCLightEdgeColor);
InternalPolyLine([Point(Left, Bottom - 1), Point(Right - 3, Bottom - 1), Point(Right - 1, Bottom - 3), Point(Right - 1, Top + 2)], cxPCDarkestEdgeColor);
InternalPolyLine([Point(Left, Bottom - 2), Point(Right - 3, Bottom - 2), Point(Right - 2, Bottom - 3), Point(Right - 2, Top + 2)], cxPCDarkEdgeColor);
if MainTab then
begin
if Top = 0 then
// if (Tab.PaintingPositionIndex in [8, 9]) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Left) or
// (Tab.PaintingPositionIndex = 7) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Right) then
begin
InternalPolyLine([Point(Left - 1, Top), Point(Left - 1, Top)], cxPCLightestEdgeColor);
InternalPolyLine([Point(Left - 1, Top + 1), Point(Left - 1, Top + 1)], cxPCLightEdgeColor);
InternalPolyLine([Point(Left - 1, Top + 2), Point(Left - 1, Bottom - 3)], cxPCTabBodyColor);
end
else
InternalPolyLine([Point(Left - 1, Top), Point(Left - 1, Bottom - 3)], cxPCTabBodyColor);
// if not((Tab.PaintingPositionIndex in [8, 9]) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Right) or
// (Tab.PaintingPositionIndex = 7) and (Tab.VisibleIndex = ALineIndexBoundsA[Tab.VisibleRow].Left)) then
if Bottom = ParentInfo.Height then
begin
InternalPolyLine([Point(Left - 1, Bottom - 2), Point(Left - 1, Bottom - 2)], cxPCDarkEdgeColor);
InternalPolyLine([Point(Left - 1, Bottom - 1), Point(Left - 1, Bottom - 1)], cxPCDarkestEdgeColor);
end
else
InternalPolyLine([Point(Left - 1, Bottom - 2), Point(Left - 1, Bottom - 1)], cxPCDarkEdgeColor);
end;
end;
end;
// draws corners
if TabPaintingPosition in [tppTop, tppLeft] then
InternalPolyLine([Point(Left, Top + 1), Point(Left, Top), Point(Left + 1, Top)],
cxPCTabBodyColor);
if TabPaintingPosition in [tppBottom, tppLeft] then
InternalPolyLine([Point(Left, Bottom - 2), Point(Left, Bottom - 1),
Point(Left + 1, Bottom - 1)], cxPCTabBodyColor);
if TabPaintingPosition in [tppTop, tppRight] then
InternalPolyLine([Point(Right - 2, Top), Point(Right - 1, Top),
Point(Right - 1, Top + 1)], cxPCTabBodyColor);
if TabPaintingPosition in [tppBottom, tppRight] then
InternalPolyLine([Point(Right - 2, Bottom - 1), Point(Right - 1, Bottom - 1),
Point(Right - 1, Bottom - 2)], cxPCTabBodyColor);
end;
end;
procedure TcxPCTabsPainter.PaintTabsRegion;
var
I: Integer;
FirstIndex, LastIndex: Integer;
MainTabVisibleIndex: Integer;
SpecialTab: TcxTab;
begin
MainTabVisibleIndex := ParentInfo.MainTabVisibleIndex;
if MainTabVisibleIndex <> -1 then
begin
SpecialTab := ParentInfo.VisibleTabs[MainTabVisibleIndex];
if SpecialTab.RealVisible then
PaintTab(MainTabVisibleIndex);
end;
InitializeVisibleTabRange(ParentControl, FirstIndex, LastIndex);
for I := FirstIndex to LastIndex do
if I <> MainTabVisibleIndex then
PaintTab(I);
end;
procedure TcxPCTabsPainter.RepaintTab(TabVisibleIndex: Integer;
TabPropertyChanged: TcxPCTabPropertyChanged);
begin
if (TabPropertyChanged = tpcIsMainTab) and
(not ParentInfo.VisibleTabs[TabVisibleIndex].IsMainTab) then
InvalidateTabExtendedTabsRect(TabVisibleIndex)
else
begin
if IsVerticalText(ParentControl) then
ParentInfo.VisibleTabs[TabVisibleIndex].ResetVerticalTextBitmap;
InvalidateTabRect(TabVisibleIndex);
end;
end;
procedure TcxPCTabsPainter.RepaintTabsRegion;
var
R: TRect;
begin
inherited;
with ParentInfo, R do
if not MultiLine then
begin
if TopOrLeftPartRowCount = 0 then
R := ExtendedBottomOrRightTabsRect
else
R := ExtendedTopOrLeftTabsRect;
case TabPosition of
tpTop:
begin
Top := Bottom;
Inc(Bottom);
end;
tpBottom:
begin
Bottom := Top;
Dec(Top);
end;
tpLeft:
begin
Left := Right;
Inc(Right);
end;
tpRight:
begin
Right := Left;
Dec(Left);
end;
end;
end;
InternalInvalidateRect(R);
end;
{$IFDEF VCL}
procedure TcxPCTabsPainter.PrepareTabBackground(ATabVisibleIndex: Integer);
const
RRectNativePaintingCorrectionA: array[TcxPCTabPaintingPosition] of TcxPCRectCorrection = (
(dLeft: 0; dTop: 0; dRight: 0; dBottom: 1),
(dLeft: 0; dTop: -1; dRight: 0; dBottom: 0),
(dLeft: 0; dTop: 0; dRight: 1; dBottom: 0),
(dLeft: -1; dTop: 0; dRight: 0; dBottom: 0)
);
var
Tab: TcxTab;
MainTab: Boolean;
FullRect, R: TRect;
TabPaintingPosition: TcxPCTabPaintingPosition;
ABitmap: TBitmap;
APartId, AStateId: Integer;
ATheme: TTheme;
R1: TRect;
begin
Tab := ParentInfo.VisibleTabs[ATabVisibleIndex];
MainTab := Tab.IsMainTab;
FullRect := Tab.FullRect;
TabPaintingPosition := Tab.PaintingPosition;
with ParentInfo.Canvas do
begin
R := FullRect;
if MainTab then
CorrectRect(R, RRectNativePaintingCorrectionA[TabPaintingPosition]);
GetTabNativePartAndState(ATabVisibleIndex, APartId, AStateId);
ATheme := OpenTheme(totTab);
TcxTabAccess(Tab).InitializePaintBitmap;
ABitmap := TcxTabAccess(Tab).PaintBitmap;
R1 := Rect(0, 0, R.Right - R.Left, R.Bottom - R.Top);
if TabPaintingPosition in [tppLeft, tppRight] then
begin
ABitmap.Width := R1.Bottom;
ABitmap.Height := R1.Right;
end else
begin
ABitmap.Width := R1.Right;
ABitmap.Height := R1.Bottom;
end;
// if IsThemeBackgroundPartiallyTransparent(ATheme, APartId, AStateId) then
if (ParentInfo.TabPosition = tpTop) and (not ParentInfo.MultiLine or
not TcxCustomTabControlAccess(ParentControl).ScrollOpposite) then
begin
BitBlt(ABitmap.Canvas.Handle, 0, 0, ABitmap.Width, ABitmap.Height,
FMDC, R.Left, R.Top, SRCCOPY);
end
else
begin
ABitmap.Canvas.Brush.Color := TWinControlAccess(ParentControl.Parent).Color;
ABitmap.Canvas.FillRect(Rect(0, 0, ABitmap.Width, ABitmap.Height));
end;
R1 := Rect(0, 0, ABitmap.Width, ABitmap.Height);
DrawThemeBackground(ATheme, ABitmap.Canvas.Handle, APartId, AStateId, @R1);
case Tab.PaintingPositionIndex of
3, 6, 11:
RotateBitmap(ABitmap, raPlus90);
2, 9, 12:
RotateBitmap(ABitmap, raMinus90);
5, 7, 10:
RotateBitmap(ABitmap, ra180);
end;
end;
end;
procedure TcxPCTabsPainter.InternalPaintFrame(ACanvas: TCanvas);
var
ATheme: TTheme;
R: TRect;
begin
R := GetDisplayRect;
InflateRect(R, StandardPainterTabControlFrameBorderWidth,
StandardPainterTabControlFrameBorderWidth);
if IsRectEmpty(R) then
Exit;
ATheme := OpenTheme(totTab);
with ACanvas do
begin
if (ACanvas.Handle = ParentInfo.Canvas.Handle) and
IsThemeBackgroundPartiallyTransparent(ATheme, TABP_PANE, 0) then
DrawThemeParentBackground(ParentControl.Handle, Handle, @R);
DrawThemeBackground(ATheme, Handle, TABP_PANE, 0, @R);
if ACanvas.Handle = ParentInfo.Canvas.Handle then
with R do
Windows.ExcludeClipRect(Handle, Left, Top, Right, Bottom);
end;
end;
{$ENDIF}
{ TcxPCFlatButtonsPainter }
class function TcxPCFlatButtonsPainter.GetStandardStyle: TcxPCStandardStyle;
begin
Result := tsFlatButtons;
end;
class function TcxPCFlatButtonsPainter.GetStyleID: TcxPCStyleID;
begin
Result := cxPCFlatButtonsStyle;
end;
class function TcxPCFlatButtonsPainter.GetStyleName: TCaption;
begin
Result := 'FlatButtons';
end;
class function TcxPCFlatButtonsPainter.HasLookAndFeel(ALookAndFeel: TcxLookAndFeel): Boolean;
begin
with ALookAndFeel do
Result := {$IFDEF VCL}(not NativeStyle or not AreVisualStylesAvailable([totTab])) and
({$ENDIF}Kind = lfFlat{$IFDEF VCL}){$ENDIF};
end;
procedure TcxPCFlatButtonsPainter.PaintTab(TabVisibleIndex: Integer);
var
Tab: TcxTab;
procedure InternalPaintTabsDelimiter;
function IsDelimiterNeeded: Boolean;
var
FirstIndex, LastIndex, I: Integer;
NextRow: Integer;
IsY: Boolean;
c: Integer; // coordinate
begin
Result := False;
InitializeVisibleTabRange(ParentControl, FirstIndex, LastIndex);
with ParentInfo do
if Rotate then
begin
if (RowCount = 1) or (Tab.VisibleRow = RowCount - 1) then Exit;
NextRow := Tab.VisibleRow + 1;
IsY := TabPosition in [tpLeft, tpRight];
c := PointGetter(Tab.FullRect.TopLeft, IsY);
for I := FirstIndex to LastIndex do
with VisibleTabs[I] do
if (VisibleRow = NextRow) and (PointGetter(FullRect.TopLeft, IsY) = c) then
begin
Result := True;
Break;
end;
end else
if (TabVisibleIndex < LastIndex) and
(VisibleTabs[TabVisibleIndex + 1].VisibleRow = Tab.VisibleRow) then
Result := True;
end;
const
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -