diff --git a/components/spktoolbar/SpkToolbar/SpkToolbar.pas b/components/spktoolbar/SpkToolbar/SpkToolbar.pas index b4ed5bba3..aa46b612d 100644 --- a/components/spktoolbar/SpkToolbar/SpkToolbar.pas +++ b/components/spktoolbar/SpkToolbar/SpkToolbar.pas @@ -317,6 +317,9 @@ type { Setter for toolbar style, i.e. quick selection of new appearance theme } procedure SetStyle(const Value: TSpkStyle); + { Calculates the height of the entire toolbar } + function CalcToolbarHeight: Integer; + { LCL Scaling } {$IF lcl_fullversion >= 1080000} procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; @@ -565,7 +568,7 @@ begin if (AOwner is TForm) then SpkInitLayoutConsts(96); // This default dpi value is ignored for LCL scaling - Height := ToolbarHeight; +// Height := CalcToolbarHeight; //inherited Doublebuffered:=true; @@ -611,6 +614,13 @@ begin FDelayRunTimer.Enabled := False; FDelayRunTimer.OnTimer := DelayRunTimer {$ENDIF} + + Height := CalcToolbarHeight; +end; + +function TSpkToolbar.CalcToolbarHeight: Integer; +begin + Result := FAppearance.Tab.CalcCaptionHeight + TabHeight; end; {$IFDEF DELAYRUNTIMER} @@ -1081,8 +1091,10 @@ end; procedure TSpkToolbar.DoOnResize; begin + { if Height <> ToolbarHeight then Height := ToolbarHeight; + } {$IFDEF DELAYRUNTIMER} FDelayRunTimer.Enabled := False; @@ -1326,6 +1338,7 @@ procedure TSpkToolbar.ValidateBuffer; var FocusedAppearance: TSpkToolbarAppearance; i: integer; + tabHeight: Integer; begin //Loading appearance of selected tab //or FToolbarAppearance if selected tab has no set OverrideAppearance @@ -1334,11 +1347,13 @@ procedure TSpkToolbar.ValidateBuffer; else FocusedAppearance := FAppearance; + tabHeight := FocusedAppearance.Tab.CalcCaptionHeight; + TGuiTools.DrawRoundRect(FBuffer.Canvas, {$IFDEF EnhancedRecordSupport} - T2DIntRect.Create(0, ToolbarTabCaptionsHeight, self.Width - 1, self.Height - 1), + T2DIntRect.Create(0, tabHeight, self.Width - 1, self.Height - 1), {$ELSE} - Create2DIntRect(0, ToolbarTabCaptionsHeight, self.Width - 1, self.Height - 1), + Create2DIntRect(0, tabHeight, self.Width - 1, self.Height - 1), {$ENDIF} FocusedAppearance.Tab.CornerRadius, FocusedAppearance.Tab.GradientFromColor, @@ -1347,9 +1362,9 @@ procedure TSpkToolbar.ValidateBuffer; TGuiTools.DrawAARoundCorner(FBuffer, {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(0, ToolbarTabCaptionsHeight), + T2DIntPoint.Create(0, tabHeight), {$ELSE} - Create2DIntPoint(0, ToolbarTabCaptionsHeight), + Create2DIntPoint(0, tabHeight), {$ENDIF} FocusedAppearance.Tab.CornerRadius, cpLeftTop, @@ -1357,9 +1372,9 @@ procedure TSpkToolbar.ValidateBuffer; TGuiTools.DrawAARoundCorner(FBuffer, {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(self.Width - FocusedAppearance.Tab.CornerRadius, ToolbarTabCaptionsHeight), + T2DIntPoint.Create(self.Width - FocusedAppearance.Tab.CornerRadius, tabHeight), {$ELSE} - Create2DIntPoint(self.Width - FocusedAppearance.Tab.CornerRadius, ToolbarTabCaptionsHeight), + Create2DIntPoint(self.Width - FocusedAppearance.Tab.CornerRadius, tabHeight), {$ENDIF} FocusedAppearance.Tab.CornerRadius, cpRightTop, @@ -1385,15 +1400,18 @@ procedure TSpkToolbar.ValidateBuffer; cpRightBottom, FocusedAppearance.Tab.BorderColor); - TGuiTools.DrawVLine(FBuffer, 0, ToolbarTabCaptionsHeight + - FocusedAppearance.Tab.CornerRadius, self.Height - FocusedAppearance.Tab.CornerRadius, + TGuiTools.DrawVLine(FBuffer, 0, + tabHeight + FocusedAppearance.Tab.CornerRadius, + self.Height - FocusedAppearance.Tab.CornerRadius, FocusedAppearance.Tab.BorderColor); - TGuiTools.DrawHLine(FBuffer, FocusedAppearance.Tab.CornerRadius, self.Width - FocusedAppearance.Tab.CornerRadius, + TGuiTools.DrawHLine(FBuffer, FocusedAppearance.Tab.CornerRadius, + self.Width - FocusedAppearance.Tab.CornerRadius, self.Height - 1, FocusedAppearance.Tab.BorderColor); - TGuiTools.DrawVLine(FBuffer, self.Width - 1, ToolbarTabCaptionsHeight + - FocusedAppearance.Tab.CornerRadius, self.Height - FocusedAppearance.Tab.CornerRadius, + TGuiTools.DrawVLine(FBuffer, self.Width - 1, + tabHeight + FocusedAppearance.Tab.CornerRadius, + self.Height - FocusedAppearance.Tab.CornerRadius, FocusedAppearance.Tab.BorderColor); if not (AtLeastOneTabVisible) then @@ -1401,7 +1419,7 @@ procedure TSpkToolbar.ValidateBuffer; //If there are no tabs then the horizontal line will be drawn TGuiTools.DrawHLine(FBuffer, FocusedAppearance.Tab.CornerRadius, self.Width - - FocusedAppearance.Tab.CornerRadius, ToolbarTabCaptionsHeight, FocusedAppearance.Tab.BorderColor); + FocusedAppearance.Tab.CornerRadius, tabHeight, FocusedAppearance.Tab.BorderColor); end else begin @@ -1414,7 +1432,7 @@ procedure TSpkToolbar.ValidateBuffer; //Only right part, the rest will be drawn with tabs if FTabRects[i].Right < self.Width - FocusedAppearance.Tab.CornerRadius - 1 then TGuiTools.DrawHLine(FBuffer, FTabRects[i].Right + 1, self.Width - - FocusedAppearance.Tab.CornerRadius, ToolbarTabCaptionsHeight, FocusedAppearance.Tab.BorderColor); + FocusedAppearance.Tab.CornerRadius, tabHeight, FocusedAppearance.Tab.BorderColor); end; end; @@ -1746,23 +1764,26 @@ begin FBuffer.Free; FBuffer := TBitmap.Create; - FBuffer.SetSize(self.Width, self.Height); + FBuffer.SetSize(self.Width, CalcToolbarHeight); //Height); + SetBounds(Left, Top, FBuffer.Width, FBuffer.Height); // *** Tabs *** + TabAppearance := FAppearance; + // Cliprect of tabs (containg top frame of component) {$IFDEF EnhancedRecordSupport} FTabClipRect := T2DIntRect.Create( ToolbarCornerRadius, 0, self.Width - ToolbarCornerRadius - 1, - ToolbarTabCaptionsHeight); + TabAppearance.Tab.CalcCaptionHeight); {$ELSE} FTabClipRect.Create( ToolbarCornerRadius, 0, self.Width - ToolbarCornerRadius - 1, - ToolbarTabCaptionsHeight); + TabAppearance.Tab.CalcCaptionHeight); {$ENDIF} // Rects of tabs headings (containg top frame of component) @@ -1792,7 +1813,7 @@ begin FTabRects[i].Left := x; FTabRects[i].Right := x + TabWidth - 1; FTabRects[i].Top := 0; - FTabRects[i].Bottom := ToolbarTabCaptionsHeight; + FTabRects[i].Bottom := TabAppearance.Tab.CalcCaptionHeight; x := FTabRects[i].right + 1; end @@ -1813,12 +1834,12 @@ begin // Rect of tab region {$IFDEF EnhancedRecordSupport} FTabContentsClipRect := T2DIntRect.Create(ToolbarBorderWidth + TabPaneLeftPadding, - ToolbarTabCaptionsHeight + ToolbarBorderWidth + TabPaneTopPadding, + TabAppearance.Tab.CalcCaptionHeight + ToolbarBorderWidth + TabPaneTopPadding, self.Width - 1 - ToolbarBorderWidth - TabPaneRightPadding, self.Height - 1 - ToolbarBorderWidth - TabPaneBottomPadding); {$ELSE} FTabContentsClipRect.Create(ToolbarBorderWidth + TabPaneLeftPadding, - ToolbarTabCaptionsHeight + ToolbarBorderWidth + TabPaneTopPadding, + TabAppearance.Tab.CalcCaptionHeight + ToolbarBorderWidth + TabPaneTopPadding, self.Width - 1 - ToolbarBorderWidth - TabPaneRightPadding, self.Height - 1 - ToolbarBorderWidth - TabPaneBottomPadding); {$ENDIF} @@ -1892,10 +1913,10 @@ begin ToolbarBorderWidth := round(TOOLBAR_BORDER_WIDTH * AXProportion); ToolbarCornerRadius := TOOLBAR_CORNER_RADIUS; - ToolbarTabCaptionsHeight := round(TOOLBAR_TAB_CAPTIONS_HEIGHT * AYProportion); +// ToolbarTabCaptionsHeight := round(TOOLBAR_TAB_CAPTIONS_HEIGHT * AYProportion); ToolbarTabCaptionsTextHPadding := round(TOOLBAR_TAB_CAPTIONS_TEXT_HPADDING * AXProportion); ToolbarMinTabCaptionWidth := round(TOOLBAR_MIN_TAB_CAPTION_WIDTH * AXProportion); - ToolbarHeight := ToolbarTabCaptionsHeight + TabHeight; +// ToolbarHeight := ToolbarTabCaptionsHeight + TabHeight; // scaling radius if not square if LargeButtonRadius > 1 then diff --git a/components/spktoolbar/SpkToolbar/spkt_Appearance.pas b/components/spktoolbar/SpkToolbar/spkt_Appearance.pas index 0860da5b6..c1b57fba4 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Appearance.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Appearance.pas @@ -46,9 +46,11 @@ type FGradientType: TBackgroundKind; FInactiveHeaderFontColor: TColor; FCornerRadius: Integer; + FCaptionHeight: Integer; // Getter & setter methods procedure SetHeaderFont(const Value: TFont); procedure SetBorderColor(const Value: TColor); + procedure SetCaptionHeight(const Value: Integer); procedure SetCornerRadius(const Value: Integer); procedure SetGradientFromColor(const Value: TColor); procedure SetGradientToColor(const Value: TColor); @@ -65,6 +67,7 @@ type destructor Destroy; override; procedure Assign(Source: TPersistent); override; + function CalcCaptionHeight: Integer; procedure LoadFromXML(Node: TSpkXMLNode); procedure SaveToPascal(AList: TStrings); procedure SaveToXML(Node: TSpkXMLNode); @@ -73,6 +76,7 @@ type published property TabHeaderFont: TFont read FTabHeaderFont write SetHeaderFont; property BorderColor: TColor read FBorderColor write SetBorderColor; + property CaptionHeight: Integer read FCaptionHeight write SetCaptionHeight default -1; property CornerRadius: Integer read FCornerRadius write SetCornerRadius; property GradientFromColor: TColor read FGradientFromColor write SetGradientFromColor; property GradientToColor: TColor read FGradientToColor write SetGradientToColor; @@ -304,6 +308,7 @@ constructor TSpkTabAppearance.Create(ADispatch: TSpkBaseAppearanceDispatch); begin inherited Create; FDispatch := ADispatch; + FCaptionHeight := -1; FCornerRadius := 0; FTabHeaderFont := TFont.Create; FTabHeaderFont.OnChange := TabHeaderFontChange; @@ -325,6 +330,7 @@ begin SrcAppearance := TSpkTabAppearance(Source); FTabHeaderFont.Assign(SrcAppearance.TabHeaderFont); FBorderColor := SrcAppearance.BorderColor; + FCaptionHeight := SrcAppearance.CaptionHeight; FCornerRadius := SrcAppearance.CornerRadius; FGradientFromColor := SrcAppearance.GradientFromColor; FGradientToColor := SrcAppearance.GradientToColor; @@ -337,6 +343,22 @@ begin raise AssignException.Create('TSpkToolbarAppearance.Assign: Cannot assign the object '+Source.ClassName+' to TSpkToolbarAppearance!'); end; +function TSpkTabAppearance.CalcCaptionHeight: Integer; +var + h: Integer; +begin + if FCaptionHeight < 0 then + begin + if FTabHeaderFont.Size = 0 then + h := GetFontData(FTabHeaderFont.Handle).Height + else + h := FTabHeaderFont.Height; + Result := abs(h) + 10; + end + else + Result := FCaptionHeight; +end; + procedure TSpkTabAppearance.LoadFromXML(Node: TSpkXMLNode); var Subnode: TSpkXMLNode; @@ -352,6 +374,10 @@ begin if Assigned(Subnode) then FBorderColor := Subnode.TextAsColor; + SubNode := Node['CaptionHeight', false]; + if Assigned(SubNode) then + FCaptionHeight := SubNode.TextAsInteger; + SubNode := Node['CornerRadius', false]; if Assigned(SubNode) then FCornerRadius := SubNode.TextAsInteger; @@ -382,6 +408,7 @@ begin begin FTabHeaderFont.Color := rgb(21, 66, 139); FBorderColor := rgb(141, 178, 227); + FCaptionHeight := -1; FCornerRadius := spkt_Const.TabCornerRadius; FGradientFromColor := rgb(222, 232, 245); FGradientToColor := rgb(199, 216, 237); @@ -395,6 +422,7 @@ begin FTabHeaderFont.Style := []; FTabHeaderFont.Color := $007A534C; FBorderColor := $00BEBEBE; + FCaptionHeight := -1; FCornerRadius := spkt_Const.TabCornerRadius; FGradientFromColor := $00F4F2F2; FGradientToColor := $00EFE6E1; @@ -407,6 +435,7 @@ begin FTabHeaderFont.Style := []; FTabHeaderFont.Color := $0095572A; FBorderColor := $00D2D0CF; + FCaptionHeight := -1; FCornerRadius := 0; FGradientFromColor := $00F1F1F1; FGradientToColor := $00F1F1F1; @@ -419,6 +448,7 @@ begin FTabHeaderFont.Style := []; FTabHeaderFont.Color := $00FFFFFF; FBorderColor := $00000000; + FCaptionHeight := -1; FCornerRadius := 0; FGradientFromColor := $00464646; FGradientToColor := $00464646; @@ -434,6 +464,7 @@ begin Add(' with Tab do begin'); SaveFontToPascal(AList, FTabHeaderFont, ' TabHeaderFont'); Add(' BorderColor := $' + IntToHex(FBorderColor, 8) + ';'); + Add(' CaptionHeight := ' + IntToStr(FCaptionHeight) + ';'); Add(' CornerRadius := ' + IntToStr(FCornerRadius) + ';'); Add(' GradientFromColor := $' + IntToHex(FGradientFromColor, 8) + ';'); Add(' GradientToColor := $' + IntToHex(FGradientToColor, 8) + ';'); @@ -456,6 +487,9 @@ begin Subnode := Node['BorderColor',true]; Subnode.TextAsColor := FBorderColor; + SubNode := Node['CaptionHeight', true]; + SubNode.TextAsInteger := FCaptionHeight; + SubNode := Node['CornerRadius',true]; SubNode.TextAsInteger := FCornerRadius; @@ -479,6 +513,13 @@ begin FDispatch.NotifyAppearanceChanged; end; +procedure TSpkTabAppearance.SetCaptionHeight(const Value: Integer); +begin + if Value < -1 then FCaptionHeight := -1 else FCaptionHeight := Value; + if FDispatch <> nil then + FDispatch.NotifyAppearanceChanged; +end; + procedure TSpkTabAppearance.SetCornerRadius(const Value: Integer); begin FCornerRadius := Value; diff --git a/components/spktoolbar/SpkToolbar/spkt_Const.pas b/components/spktoolbar/SpkToolbar/spkt_Const.pas index 0325b6a3d..b514c7e57 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Const.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Const.pas @@ -134,7 +134,7 @@ const TOOLBAR_BORDER_WIDTH = 1; TOOLBAR_CORNER_RADIUS = 0; //was: 3; /// Tab caption height - TOOLBAR_TAB_CAPTIONS_HEIGHT = 22; +// TOOLBAR_TAB_CAPTIONS_HEIGHT = 22; /// Tab caption horizontal padding TOOLBAR_TAB_CAPTIONS_TEXT_HPADDING = 4; /// Min tab caption width @@ -259,12 +259,12 @@ var ToolbarBorderWidth: Integer; ToolbarCornerRadius: Integer; /// Tab caption height - ToolbarTabCaptionsHeight: Integer; +// ToolbarTabCaptionsHeight: Integer; /// Tab caption horizontal padding ToolbarTabCaptionsTextHPadding: Integer; ToolbarMinTabCaptionWidth: Integer; /// Toolbar total height - ToolbarHeight: Integer; + //ToolbarHeight: Integer; implementation @@ -338,10 +338,10 @@ begin ToolbarBorderWidth := SpkScaleX(TOOLBAR_BORDER_WIDTH, FromDPI, ToDPI); ToolbarCornerRadius := TOOLBAR_CORNER_RADIUS; - ToolbarTabCaptionsHeight := SpkScaleY(TOOLBAR_TAB_CAPTIONS_HEIGHT, FromDPI, ToDPI); +// ToolbarTabCaptionsHeight := SpkScaleY(TOOLBAR_TAB_CAPTIONS_HEIGHT, FromDPI, ToDPI); ToolbarTabCaptionsTextHPadding := SpkScaleX(TOOLBAR_TAB_CAPTIONS_TEXT_HPADDING, FromDPI, ToDPI); ToolbarMinTabCaptionWidth := SpkScaleX(TOOLBAR_MIN_TAB_CAPTION_WIDTH, FromDPI, ToDPI); - ToolbarHeight := ToolbarTabCaptionsHeight + TabHeight; +// ToolbarHeight := ToolbarTabCaptionsHeight + TabHeight; // scaling radius if not square if LargeButtonRadius > 1 then