Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses
- JvTabBar;
- type
- TJvModernTabBarPainter = class(JvTabBar.TJvModernTabBarPainter)
- protected
- procedure DrawTab(Canvas: TCanvas; Tab: TJvTabBarItem; R: TRect); override;
- function GetCloseRect(Canvas: TCanvas; Tab: TJvTabBarItem; R: TRect): TRect; override;
- end;
- implementation
- { TJvModernTabBarPainter }
- procedure TJvModernTabBarPainter.DrawTab(Canvas: TCanvas; Tab: TJvTabBarItem; R: TRect);
- var
- CloseR: TRect;
- begin
- with Canvas do
- begin
- Brush.Style := bsSolid;
- Brush.Color := Color;
- Pen.Mode := pmCopy;
- Pen.Style := psSolid;
- Pen.Width := 1;
- if Tab.Selected then
- begin
- Brush.Style := bsSolid;
- Brush.Color := TabColor;
- FillRect(R);
- Pen.Color := ControlDivideColor;
- if Tab.TabBar.Orientation = toBottom then
- begin
- MoveTo(R.Left, R.Top);
- LineTo(R.Left, R.Bottom - 1);
- LineTo(R.Right - 1, R.Bottom - 1);
- LineTo(R.Right - 1, R.Top - 1{end});
- end
- else // toTop
- begin
- MoveTo(R.Left, R.Bottom - 1);
- LineTo(R.Left, R.Top);
- LineTo(R.Right - 1, R.Top);
- LineTo(R.Right - 1, R.Bottom - 1 + 1{end});
- end;
- end;
- if Tab.Enabled and not Tab.Selected and Tab.Hot then
- begin
- // hot
- Pen.Color := DividerColor;
- MoveTo(R.Left, R.Top);
- LineTo(R.Right - 1 - 1, R.Top);
- end;
- if Tab.TabBar.CloseButton then
- begin
- // close button color
- if Tab.Selected then
- Brush.Color := CloseColorSelected
- else
- Brush.Color := CloseColor;
- CloseR := GetCloseRect(Canvas, Tab, R);
- Pen.Color := CloseRectColor;
- if not Tab.Enabled then
- Pen.Color := CloseRectColorDisabled;
- if Tab.Closing then
- // shrink
- Rectangle(CloseR.Left + 1, CloseR.Top + 1, CloseR.Right - 1, CloseR.Bottom - 1)
- else
- Rectangle(CloseR);
- if Tab.Modified then
- Pen.Color := ModifiedCrossColor
- else
- if Tab.Selected and not Tab.Closing then
- Pen.Color := CloseCrossColorSelected
- else
- if Tab.Enabled then
- Pen.Color := CloseCrossColor
- else
- Pen.Color := CloseCrossColorDisabled;
- // close cross
- MoveTo(CloseR.Left + 3, CloseR.Top + 3);
- LineTo(CloseR.Right - 3, CloseR.Bottom - 3);
- MoveTo(CloseR.Left + 4, CloseR.Top + 3);
- LineTo(CloseR.Right - 4, CloseR.Bottom - 3);
- MoveTo(CloseR.Right - 4, CloseR.Top + 3);
- LineTo(CloseR.Left + 2, CloseR.Bottom - 3);
- MoveTo(CloseR.Right - 5, CloseR.Top + 3);
- LineTo(CloseR.Left + 3, CloseR.Bottom - 3);
- // remove intersection
- if Tab.Modified then
- FillRect(Rect(CloseR.Left + 5, CloseR.Top + 4, CloseR.Right - 5, CloseR.Bottom - 4));
- R.Right := CloseR.Left;
- end;
- InflateRect(R, -1, -1);
- if not Tab.TabBar.CloseButton then
- Inc(R.Left, 2);
- if (Tab.ImageIndex <> -1) and (Tab.GetImages <> nil) then
- begin
- Tab.GetImages.Draw(Canvas, R.Left, R.Top + (R.Bottom - R.Top - Tab.GetImages.Height) div 2,
- Tab.ImageIndex, Tab.Enabled);
- Inc(R.Left, Tab.GetImages.Width + 2);
- end;
- if Tab.Enabled then
- begin
- if Tab.Selected then
- Font.Assign(Self.SelectedFont)
- else
- Font.Assign(Self.Font);
- end
- else
- Font.Assign(Self.DisabledFont);
- Brush.Style := bsClear;
- TextRect(R, R.Left + 3, R.Top + 3, Tab.Caption);
- end;
- end;
- function TJvModernTabBarPainter.GetCloseRect(Canvas: TCanvas; Tab: TJvTabBarItem;
- R: TRect): TRect;
- begin
- Result.Left := R.Right - 17;
- Result.Top := R.Top + 5;
- Result.Right := Result.Left + 12;
- Result.Bottom := Result.Top + 11;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement