jvcllaz: Support fixed tab height in JvTabBar.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6367 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-05-01 22:55:16 +00:00
parent a4e69c5dbf
commit 06000dcd6c

View File

@ -148,6 +148,7 @@ type
private private
FOnChangeList: TList; FOnChangeList: TList;
protected protected
procedure AutoSize; virtual;
procedure Changed; virtual; procedure Changed; virtual;
procedure DrawBackground(Canvas: TCanvas; TabBar: TJvCustomTabBar; R: TRect); virtual; abstract; procedure DrawBackground(Canvas: TCanvas; TabBar: TJvCustomTabBar; R: TRect); virtual; abstract;
procedure DrawDivider(Canvas: TCanvas; LeftTab: TJvTabBarItem; R: TRect); virtual; abstract; procedure DrawDivider(Canvas: TCanvas; LeftTab: TJvTabBarItem; R: TRect); virtual; abstract;
@ -188,6 +189,7 @@ type
FCloseColorSelected: TColor; FCloseColorSelected: TColor;
FDividerColor: TColor; FDividerColor: TColor;
FMoveDividerColor: TColor; FMoveDividerColor: TColor;
FTabHeight: Integer;
FTabWidth: Integer; FTabWidth: Integer;
procedure SetCloseRectColorDisabled(const Value: TColor); procedure SetCloseRectColorDisabled(const Value: TColor);
procedure SetCloseColor(const Value: TColor); procedure SetCloseColor(const Value: TColor);
@ -206,8 +208,10 @@ type
procedure FontChanged(Sender: TObject); procedure FontChanged(Sender: TObject);
procedure SetDividerColor(const Value: TColor); procedure SetDividerColor(const Value: TColor);
procedure SetCloseCrossColorSelected(const Value: TColor); procedure SetCloseCrossColorSelected(const Value: TColor);
procedure SetTabHeight(Value: Integer);
procedure SetTabWidth(Value: Integer); procedure SetTabWidth(Value: Integer);
protected protected
procedure AutoSize; override;
procedure DrawBackground(Canvas: TCanvas; TabBar: TJvCustomTabBar; R: TRect); override; procedure DrawBackground(Canvas: TCanvas; TabBar: TJvCustomTabBar; R: TRect); override;
procedure DrawDivider(Canvas: TCanvas; LeftTab: TJvTabBarItem; R: TRect); override; procedure DrawDivider(Canvas: TCanvas; LeftTab: TJvTabBarItem; R: TRect); override;
procedure DrawMoveDivider(Canvas: TCanvas; Tab: TJvTabBarItem; MoveLeft: Boolean); override; procedure DrawMoveDivider(Canvas: TCanvas; Tab: TJvTabBarItem; MoveLeft: Boolean); override;
@ -235,6 +239,7 @@ type
property CloseRectColorDisabled: TColor read FCloseRectColorDisabled write SetCloseRectColorDisabled default $D6D6D6; property CloseRectColorDisabled: TColor read FCloseRectColorDisabled write SetCloseRectColorDisabled default $D6D6D6;
property DividerColor: TColor read FDividerColor write SetDividerColor default $99A8AC; property DividerColor: TColor read FDividerColor write SetDividerColor default $99A8AC;
property MoveDividerColor: TColor read FMoveDividerColor write FMoveDividerColor default clBlack; property MoveDividerColor: TColor read FMoveDividerColor write FMoveDividerColor default clBlack;
property TabHeight: Integer read FTabHeight write SetTabHeight default 0;
property TabWidth: Integer read FTabWidth write SetTabWidth default 0; property TabWidth: Integer read FTabWidth write SetTabWidth default 0;
property Font: TFont read FFont write SetFont; property Font: TFont read FFont write SetFont;
property DisabledFont: TFont read FDisabledFont write SetDisabledFont; property DisabledFont: TFont read FDisabledFont write SetDisabledFont;
@ -1424,6 +1429,8 @@ var
imgRes: TScaledImageListResolution; imgRes: TScaledImageListResolution;
{$ENDIF} {$ENDIF}
begin begin
CurrentPainter.AutoSize;
// Text height // Text height
Canvas.Font.Assign(Font); Canvas.Font.Assign(Font);
PreferredHeight := Canvas.TextHeight('Tg'); PreferredHeight := Canvas.TextHeight('Tg');
@ -2161,6 +2168,10 @@ begin
FOnChangeList.Free; FOnChangeList.Free;
end; end;
procedure TJvTabBarPainter.AutoSize;
begin
end;
procedure TJvTabBarPainter.Changed; procedure TJvTabBarPainter.Changed;
var var
i: Integer; i: Integer;
@ -2280,6 +2291,12 @@ begin
inherited Destroy; inherited Destroy;
end; end;
procedure TJvModernTabBarPainter.AutoSize;
begin
FTabHeight := 0;
FTabWidth := 0;
end;
procedure TJvModernTabBarPainter.DrawBackground(Canvas: TCanvas; TabBar: TJvCustomTabBar; R: TRect); procedure TJvModernTabBarPainter.DrawBackground(Canvas: TCanvas; TabBar: TJvCustomTabBar; R: TRect);
begin begin
with Canvas do with Canvas do
@ -2557,9 +2574,11 @@ begin
end; end;
inc(Result.CY, Scale96(TOP_MARGIN) + Scale96(BOTTOM_MARGIN)); inc(Result.CY, Scale96(TOP_MARGIN) + Scale96(BOTTOM_MARGIN));
// Override width if TabWidth is fixed. // Override width if TabWidth/TabHeight is fixed.
if TabWidth > 0 then if TabWidth > 0 then
Result.cx := TabWidth; Result.CX := TabWidth;
if TabHeight > 0 then
Result.CY := TabHeight;
end; end;
function TJvModernTabBarPainter.Options: TJvTabBarPainterOptions; function TJvModernTabBarPainter.Options: TJvTabBarPainterOptions;
@ -2689,6 +2708,17 @@ begin
end; end;
end; end;
procedure TJvModernTabBarPainter.SetTabHeight(Value: Integer);
begin
if Value < 0 then
Value := 0;
if Value <> FTabHeight then
begin
FTabHeight := Value;
Changed;
end;
end;
procedure TJvModernTabBarPainter.SetTabWidth(Value: Integer); procedure TJvModernTabBarPainter.SetTabWidth(Value: Integer);
begin begin
if Value < 0 then if Value < 0 then