diff --git a/components/spktoolbar/SpkGUITools/SpkGUITools.pas b/components/spktoolbar/SpkGUITools/SpkGUITools.pas index d1c161114..57b250cd2 100644 --- a/components/spktoolbar/SpkGUITools/SpkGUITools.pas +++ b/components/spktoolbar/SpkGUITools/SpkGUITools.pas @@ -9,7 +9,7 @@ interface -{$MESSAGE HINT 'W tym module konsekwentnie ka¿dy rect opisuje dok³adny prostok¹t (a nie, jak w przypadku WINAPI - bez dolnej i prawej krawêdzi)'} +{$MESSAGE HINT 'Every rect in this module are exact rectanges (not like in WINAPI without right and bottom)'} uses LCLType, Graphics, SysUtils, Classes, Controls, StdCtrls, SpkGraphTools, SpkMath; @@ -1905,9 +1905,11 @@ class procedure TGUITools.DrawImage(ACanvas: TCanvas; Imagelist: TImageList; var UseOrgClipRgn: Boolean; OrgRgn: HRGN; ClipRgn: HRGN; + ImageIcon: TIcon; + ImageBitmap: TBitmap; begin -// Zapamiêtywanie oryginalnego ClipRgn i ustawianie nowego +// Storing original ClipRgn and applying a new one SaveClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); ClipRgn:=CreateRectRgn(ClipRect.left, ClipRect.Top, ClipRect.Right+1, ClipRect.Bottom+1); @@ -1916,7 +1918,19 @@ if UseOrgClipRgn then SelectClipRgn(ACanvas.Handle, ClipRgn); -ImageList.Draw(ACanvas, Point.x, Point.y, ImageIndex); +// avoid exclusive draw. draw with local canvas itself. +//ImageList.Draw(ACanvas, Point.x, Point.y, ImageIndex); +{$IfDef LCLWin32} +ImageIcon := TIcon.Create; +ImageList.GetIcon(ImageIndex, ImageIcon); +ACanvas.Draw(Point.x, Point.y, ImageIcon); +ImageIcon.Free; +{$Else} +ImageBitmap := TBitmap.Create; +ImageList.GetBitmap(ImageIndex, ImageBitmap); +ACanvas.Draw(Point.x, Point.y, ImageBitmap); +ImageBitmap.Free; +{$EndIf} RestoreClipRgn(ACanvas.Handle, UseOrgClipRgn, OrgRgn); DeleteObject(ClipRgn); diff --git a/components/spktoolbar/SpkToolbar/SpkToolbar.pas b/components/spktoolbar/SpkToolbar/SpkToolbar.pas index 22807ce70..5f384c47c 100644 --- a/components/spktoolbar/SpkToolbar/SpkToolbar.pas +++ b/components/spktoolbar/SpkToolbar/SpkToolbar.pas @@ -19,7 +19,7 @@ interface uses LCLType, LMessages, Graphics, SysUtils, Controls, Classes, Math, Dialogs, - Types, SpkGraphTools, SpkGUITools, SpkMath, ExtCtrls, + Forms, Types, SpkGraphTools, SpkGUITools, SpkMath, ExtCtrls, spkt_Appearance, spkt_BaseItem, spkt_Const, spkt_Dispatch, spkt_Tab, spkt_Pane, spkt_Types; @@ -453,6 +453,8 @@ begin end; constructor TSpkToolbar.Create(AOwner: TComponent); +var + DesignDPI: Integer; begin inherited Create(AOwner); @@ -460,7 +462,15 @@ begin inherited Align := alTop; //todo: not found in lcl //inherited AlignWithMargins:=true; - inherited Height := TOOLBAR_HEIGHT; + + if AOwner is TForm then + DesignDPI := TForm(AOwner).DesignTimeDPI + else + DesignDPI := ScreenInfo.PixelsPerInchX; + + SpkInitLayoutConsts(DesignDPI); + inherited Height := ToolbarHeight; + //inherited Doublebuffered:=true; // Inicjacja wewnêtrznych pól danych @@ -990,7 +1000,7 @@ end; procedure TSpkToolbar.DoOnResize; begin - inherited Height := TOOLBAR_HEIGHT; + inherited Height := ToolbarHeight; {$IFDEF DELAYRUNTIMER} FDelayRunTimer.Enabled := False; @@ -1252,74 +1262,64 @@ procedure TSpkToolbar.ValidateBuffer; TGuiTools.DrawRoundRect(FBuffer.Canvas, {$IFDEF EnhancedRecordSupport} - T2DIntRect.Create(0, - TOOLBAR_TAB_CAPTIONS_HEIGHT, - self.Width - 1, - self.Height - 1), + T2DIntRect.Create(0, ToolbarTabCaptionsHeight, self.Width - 1, self.Height - 1), {$ELSE} - Create2DIntRect(0, - TOOLBAR_TAB_CAPTIONS_HEIGHT, - self.Width - 1, - self.Height - 1), + Create2DIntRect(0, ToolbarTabCaptionsHeight, self.Width - 1, self.Height - 1), {$ENDIF} - TOOLBAR_CORNER_RADIUS, + ToolbarCornerRadius, FocusedAppearance.Tab.GradientFromColor, FocusedAppearance.Tab.GradientToColor, FocusedAppearance.Tab.GradientType); TGuiTools.DrawAARoundCorner(FBuffer, {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(0, TOOLBAR_TAB_CAPTIONS_HEIGHT), + T2DIntPoint.Create(0, ToolbarTabCaptionsHeight), {$ELSE} - Create2DIntPoint(0, TOOLBAR_TAB_CAPTIONS_HEIGHT), + Create2DIntPoint(0, ToolbarTabCaptionsHeight), {$ENDIF} - TOOLBAR_CORNER_RADIUS, + ToolbarCornerRadius, cpLeftTop, FocusedAppearance.Tab.BorderColor); TGuiTools.DrawAARoundCorner(FBuffer, {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(self.Width - - TOOLBAR_CORNER_RADIUS, TOOLBAR_TAB_CAPTIONS_HEIGHT), + T2DIntPoint.Create(self.Width - ToolbarCornerRadius, ToolbarTabCaptionsHeight), {$ELSE} - Create2DIntPoint(self.Width - - TOOLBAR_CORNER_RADIUS, TOOLBAR_TAB_CAPTIONS_HEIGHT), + Create2DIntPoint(self.Width - ToolbarCornerRadius, ToolbarTabCaptionsHeight), {$ENDIF} - TOOLBAR_CORNER_RADIUS, + ToolbarCornerRadius, cpRightTop, FocusedAppearance.Tab.BorderColor); TGuiTools.DrawAARoundCorner(FBuffer, {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(0, self.Height - TOOLBAR_CORNER_RADIUS), + T2DIntPoint.Create(0, self.Height - ToolbarCornerRadius), {$ELSE} - Create2DIntPoint(0, self.Height - TOOLBAR_CORNER_RADIUS), + Create2DIntPoint(0, self.Height - ToolbarCornerRadius), {$ENDIF} - TOOLBAR_CORNER_RADIUS, + ToolbarCornerRadius, cpLeftBottom, FocusedAppearance.Tab.BorderColor); TGuiTools.DrawAARoundCorner(FBuffer, {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(self.Width - - TOOLBAR_CORNER_RADIUS, self.Height - TOOLBAR_CORNER_RADIUS), + T2DIntPoint.Create(self.Width - ToolbarCornerRadius, self.Height - ToolbarCornerRadius), {$ELSE} - Create2DIntPoint(self.Width - - TOOLBAR_CORNER_RADIUS, self.Height - TOOLBAR_CORNER_RADIUS), + Create2DIntPoint(self.Width - ToolbarCornerRadius, self.Height - ToolbarCornerRadius), {$ENDIF} - TOOLBAR_CORNER_RADIUS, + ToolbarCornerRadius, cpRightBottom, FocusedAppearance.Tab.BorderColor); - TGuiTools.DrawVLine(FBuffer, 0, TOOLBAR_TAB_CAPTIONS_HEIGHT + - TOOLBAR_CORNER_RADIUS, self.Height - TOOLBAR_CORNER_RADIUS, + TGuiTools.DrawVLine(FBuffer, 0, ToolbarTabCaptionsHeight + + ToolbarCornerRadius, self.Height - ToolbarCornerRadius, FocusedAppearance.Tab.BorderColor); - TGuiTools.DrawHLine(FBuffer, TOOLBAR_CORNER_RADIUS, self.Width - TOOLBAR_CORNER_RADIUS, + TGuiTools.DrawHLine(FBuffer, ToolbarCornerRadius, self.Width - ToolbarCornerRadius, self.Height - 1, FocusedAppearance.Tab.BorderColor); - TGuiTools.DrawVLine(FBuffer, self.Width - 1, TOOLBAR_TAB_CAPTIONS_HEIGHT + - TOOLBAR_CORNER_RADIUS, self.Height - TOOLBAR_CORNER_RADIUS, + TGuiTools.DrawVLine(FBuffer, self.Width - 1, ToolbarTabCaptionsHeight + + ToolbarCornerRadius, self.Height - ToolbarCornerRadius, FocusedAppearance.Tab.BorderColor); if not (AtLeastOneTabVisible) then begin // Jeœli nie ma zak³adek, rysujemy poziom¹ liniê - TGuiTools.DrawHLine(FBuffer, TOOLBAR_CORNER_RADIUS, self.Width - - TOOLBAR_CORNER_RADIUS, TOOLBAR_TAB_CAPTIONS_HEIGHT, FocusedAppearance.Tab.BorderColor); + TGuiTools.DrawHLine(FBuffer, ToolbarCornerRadius, self.Width - + ToolbarCornerRadius, ToolbarTabCaptionsHeight, FocusedAppearance.Tab.BorderColor); end else begin @@ -1330,9 +1330,9 @@ procedure TSpkToolbar.ValidateBuffer; Dec(i); // Tylko prawa czêœæ, reszta bêdzie narysowana wraz z zak³adkami - if FTabRects[i].Right < self.Width - TOOLBAR_CORNER_RADIUS - 1 then + if FTabRects[i].Right < self.Width - ToolbarCornerRadius - 1 then TGuiTools.DrawHLine(FBuffer, FTabRects[i].Right + 1, self.Width - - TOOLBAR_CORNER_RADIUS, TOOLBAR_TAB_CAPTIONS_HEIGHT, FocusedAppearance.Tab.BorderColor); + ToolbarCornerRadius, ToolbarTabCaptionsHeight, FocusedAppearance.Tab.BorderColor); end; end; @@ -1380,49 +1380,49 @@ procedure TSpkToolbar.ValidateBuffer; TabRect := FTabRects[index]; // Œrodkowy prostok¹t - TabRegion := CreateRectRgn(TabRect.Left + TAB_CORNER_RADIUS - 1, - TabRect.Top + TAB_CORNER_RADIUS, - TabRect.Right - TAB_CORNER_RADIUS + 1 + + TabRegion := CreateRectRgn(TabRect.Left + TabCornerRadius - 1, + TabRect.Top + TabCornerRadius, + TabRect.Right - TabCornerRadius + 1 + 1, TabRect.Bottom + 1); // Górna czêœæ z górnymi zaokr¹gleniami wypuk³ymi - TmpRegion := CreateRectRgn(TabRect.Left + 2 * TAB_CORNER_RADIUS - 1, + TmpRegion := CreateRectRgn(TabRect.Left + 2 * TabCornerRadius - 1, TabRect.Top, TabRect.Right - - 2 * TAB_CORNER_RADIUS + 1 + 1, TabRect.Top + - TAB_CORNER_RADIUS); + 2 * TabCornerRadius + 1 + 1, TabRect.Top + + TabCornerRadius); CombineRgn(TabRegion, TabRegion, TmpRegion, RGN_OR); DeleteObject(TmpRegion); - TmpRegion := CreateEllipticRgn(TabRect.Left + TAB_CORNER_RADIUS - + TmpRegion := CreateEllipticRgn(TabRect.Left + TabCornerRadius - 1, TabRect.Top, - TabRect.Left + 3 * TAB_CORNER_RADIUS, - TabRect.Top + 2 * TAB_CORNER_RADIUS + 1); + TabRect.Left + 3 * TabCornerRadius, + TabRect.Top + 2 * TabCornerRadius + 1); CombineRgn(TabRegion, TabRegion, TmpRegion, RGN_OR); DeleteObject(TmpRegion); - TmpRegion := CreateEllipticRgn(TabRect.Right - 3 * TAB_CORNER_RADIUS + 2, + TmpRegion := CreateEllipticRgn(TabRect.Right - 3 * TabCornerRadius + 2, TabRect.Top, - TabRect.Right - TAB_CORNER_RADIUS + - 3, TabRect.Top + 2 * TAB_CORNER_RADIUS + 1); + TabRect.Right - TabCornerRadius + + 3, TabRect.Top + 2 * TabCornerRadius + 1); CombineRgn(TabRegion, TabRegion, TmpRegion, RGN_OR); DeleteObject(TmpRegion); // Dolna czêœæ z dolnymi zaokr¹gleniami wklês³ymi TmpRegion := CreateRectRgn(TabRect.Left, TabRect.Bottom - - TAB_CORNER_RADIUS, TabRect.Right + 1, + TabCornerRadius, TabRect.Right + 1, TabRect.Bottom + 1); - TmpRegion2 := CreateEllipticRgn(TabRect.Left - TAB_CORNER_RADIUS, - TabRect.Bottom - 2 * TAB_CORNER_RADIUS + 1, - TabRect.Left + TAB_CORNER_RADIUS + + TmpRegion2 := CreateEllipticRgn(TabRect.Left - TabCornerRadius, + TabRect.Bottom - 2 * TabCornerRadius + 1, + TabRect.Left + TabCornerRadius + 1, TabRect.Bottom + 2); CombineRgn(TmpRegion, TmpRegion, TmpRegion2, RGN_DIFF); DeleteObject(TmpRegion2); - TmpRegion2 := CreateEllipticRgn(TabRect.Right - TAB_CORNER_RADIUS + - 1, TabRect.Bottom - 2 * TAB_CORNER_RADIUS + - 1, TabRect.Right + TAB_CORNER_RADIUS + 2, + TmpRegion2 := CreateEllipticRgn(TabRect.Right - TabCornerRadius + + 1, TabRect.Bottom - 2 * TabCornerRadius + + 1, TabRect.Right + TabCornerRadius + 2, TabRect.Bottom + 2); CombineRgn(TmpRegion, TmpRegion, TmpRegion2, RGN_DIFF); DeleteObject(TmpRegion2); @@ -1442,70 +1442,62 @@ procedure TSpkToolbar.ValidateBuffer; // Ramka TGuiTools.DrawAARoundCorner(FBuffer, {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(TabRect.left, - TabRect.bottom - TAB_CORNER_RADIUS + 1), + T2DIntPoint.Create(TabRect.left, TabRect.bottom - TabCornerRadius + 1), {$ELSE} - Create2DIntPoint(TabRect.left, - TabRect.bottom - TAB_CORNER_RADIUS + 1), + Create2DIntPoint(TabRect.left, TabRect.bottom - TabCornerRadius + 1), {$ENDIF} - TAB_CORNER_RADIUS, + TabCornerRadius, cpRightBottom, Border, FTabClipRect); TGuiTools.DrawAARoundCorner(FBuffer, {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(TabRect.right - - TAB_CORNER_RADIUS + 1, TabRect.bottom - TAB_CORNER_RADIUS + 1), + T2DIntPoint.Create(TabRect.right - TabCornerRadius + 1, TabRect.bottom - TabCornerRadius + 1), {$ELSE} - Create2DIntPoint(TabRect.right - - TAB_CORNER_RADIUS + 1, TabRect.bottom - TAB_CORNER_RADIUS + 1), + Create2DIntPoint(TabRect.right - TabCornerRadius + 1, TabRect.bottom - TabCornerRadius + 1), {$ENDIF} - TAB_CORNER_RADIUS, + TabCornerRadius, cpLeftBottom, Border, FTabClipRect); TGuiTools.DrawVLine(FBuffer, - TabRect.left + TAB_CORNER_RADIUS - 1, - TabRect.top + TAB_CORNER_RADIUS, - TabRect.Bottom - TAB_CORNER_RADIUS + 1, + TabRect.left + TabCornerRadius - 1, + TabRect.top + TabCornerRadius, + TabRect.Bottom - TabCornerRadius + 1, Border, FTabClipRect); TGuiTools.DrawVLine(FBuffer, - TabRect.Right - TAB_CORNER_RADIUS + 1, - TabRect.top + TAB_CORNER_RADIUS, - TabRect.Bottom - TAB_CORNER_RADIUS + 1, + TabRect.Right - TabCornerRadius + 1, + TabRect.top + TabCornerRadius, + TabRect.Bottom - TabCornerRadius + 1, Border, FTabClipRect); TGuiTools.DrawAARoundCorner(FBuffer, {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(TabRect.left + - TAB_CORNER_RADIUS - 1, 0), + T2DIntPoint.Create(TabRect.left + TabCornerRadius - 1, 0), {$ELSE} - Create2DIntPoint(TabRect.left + - TAB_CORNER_RADIUS - 1, 0), + Create2DIntPoint(TabRect.left + TabCornerRadius - 1, 0), {$ENDIF} - TAB_CORNER_RADIUS, + TabCornerRadius, cpLeftTop, Border, FTabClipRect); TGuiTools.DrawAARoundCorner(FBuffer, {$IFDEF EnhancedRecordSupport} - T2DIntPoint.Create(TabRect.right - - 2 * TAB_CORNER_RADIUS + 2, 0), + T2DIntPoint.Create(TabRect.right - 2 * TabCornerRadius + 2, 0), {$ELSE} - Create2DIntPoint(TabRect.right - - 2 * TAB_CORNER_RADIUS + 2, 0), + Create2DIntPoint(TabRect.right - 2 * TabCornerRadius + 2, 0), {$ENDIF} - TAB_CORNER_RADIUS, + TabCornerRadius, cpRightTop, Border, FTabClipRect); TGuiTools.DrawHLine(FBuffer, - TabRect.left + 2 * TAB_CORNER_RADIUS - 1, - TabRect.right - 2 * TAB_CORNER_RADIUS + 2, + TabRect.left + 2 * TabCornerRadius - 1, + TabRect.right - 2 * TabCornerRadius + 2, 0, Border, FTabClipRect); @@ -1660,21 +1652,24 @@ begin // Cliprect zak³adek (zawgórn¹ ramkê komponentu) {$IFDEF EnhancedRecordSupport} - FTabClipRect := T2DIntRect.Create(TOOLBAR_CORNER_RADIUS, - 0, self.Width - - TOOLBAR_CORNER_RADIUS - 1, TOOLBAR_TAB_CAPTIONS_HEIGHT); -{$ELSE} - FTabClipRect.Create(TOOLBAR_CORNER_RADIUS, + FTabClipRect := T2DIntRect.Create( + ToolbarCornerRadius, 0, - self.Width - TOOLBAR_CORNER_RADIUS - 1, - TOOLBAR_TAB_CAPTIONS_HEIGHT); + self.Width - ToolbarCornerRadius - 1, + ToolbarTabCaptionsHeight); +{$ELSE} + FTabClipRect.Create( + ToolbarCornerRadius, + 0, + self.Width - ToolbarCornerRadius - 1, + ToolbarTabCaptionsHeight); {$ENDIF} // Recty nag³ówków zak³adek (zawieraj¹ górn¹ ramkê komponentu) setlength(FTabRects, FTabs.Count); if FTabs.Count > 0 then begin - x := TOOLBAR_CORNER_RADIUS; + x := ToolbarCornerRadius; for i := 0 to FTabs.Count - 1 do if FTabs[i].Visible then begin @@ -1686,18 +1681,18 @@ begin FBuffer.Canvas.font.Assign(TabAppearance.Tab.TabHeaderFont); TabWidth := 2 + // Ramka - 2 * TAB_CORNER_RADIUS + + 2 * TabCornerRadius + // Zaokr¹glenia - 2 * TOOLBAR_TAB_CAPTIONS_TEXT_HPADDING + + 2 * ToolbarTabCaptionsTextHPadding + // Wewnêtrzne marginesy - max(TOOLBAR_MIN_TAB_CAPTION_WIDTH, + max(ToolbarMinTabCaptionWidth, FBuffer.Canvas.TextWidth(FTabs.Items[i].Caption)); // Szerokoœæ tekstu FTabRects[i].Left := x; FTabRects[i].Right := x + TabWidth - 1; FTabRects[i].Top := 0; - FTabRects[i].Bottom := TOOLBAR_TAB_CAPTIONS_HEIGHT; + FTabRects[i].Bottom := ToolbarTabCaptionsHeight; x := FTabRects[i].right + 1; end @@ -1717,20 +1712,15 @@ begin begin // Rect obszaru zak³adki {$IFDEF EnhancedRecordSupport} - FTabContentsClipRect := T2DIntRect.Create(TOOLBAR_BORDER_WIDTH + - TAB_PANE_LEFTPADDING, TOOLBAR_TAB_CAPTIONS_HEIGHT + - TOOLBAR_BORDER_WIDTH + TAB_PANE_TOPPADDING, - self.Width - 1 - TOOLBAR_BORDER_WIDTH - - TAB_PANE_RIGHTPADDING, self.Height - - 1 - TOOLBAR_BORDER_WIDTH - TAB_PANE_BOTTOMPADDING); + FTabContentsClipRect := T2DIntRect.Create(ToolbarBorderWidth + TabPaneLeftPadding, + ToolbarTabCaptionsHeight + ToolbarBorderWidth + TabPaneTopPadding, + self.Width - 1 - ToolbarBorderWidth - TabPaneRightPadding, + self.Height - 1 - ToolbarBorderWidth - TabPaneBottomPadding); {$ELSE} - FTabContentsClipRect.Create(TOOLBAR_BORDER_WIDTH + TAB_PANE_LEFTPADDING, - TOOLBAR_TAB_CAPTIONS_HEIGHT + - TOOLBAR_BORDER_WIDTH + TAB_PANE_TOPPADDING, - self.Width - 1 - TOOLBAR_BORDER_WIDTH - - TAB_PANE_RIGHTPADDING, - self.Height - 1 - TOOLBAR_BORDER_WIDTH - - TAB_PANE_BOTTOMPADDING); + FTabContentsClipRect.Create(ToolbarBorderWidth + TabPaneLeftPadding, + ToolbarTabCaptionsHeight + ToolbarBorderWidth + TabPaneTopPadding, + self.Width - 1 - ToolbarBorderWidth - TabPaneRightPadding, + self.Height - 1 - ToolbarBorderWidth - TabPaneBottomPadding); {$ENDIF} FTabs[FTabIndex].Rect := FTabContentsClipRect; diff --git a/components/spktoolbar/SpkToolbar/spkt_Appearance.pas b/components/spktoolbar/SpkToolbar/spkt_Appearance.pas index a9c3bdbbd..6ccd24bb7 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Appearance.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Appearance.pas @@ -16,7 +16,7 @@ interface uses Graphics, Classes, Forms, SysUtils, SpkGUITools, SpkXMLParser, SpkXMLTools, - spkt_Dispatch, spkt_Exceptions; + spkt_Dispatch, spkt_Exceptions, spkt_Const; type TSpkTabAppearance = class(TPersistent) private @@ -31,6 +31,7 @@ type TSpkTabAppearance = class(TPersistent) // *** Gettery i settery *** procedure SetHeaderFont(const Value: TFont); + function GetTabHeaderFont: TFont; procedure SetBorderColor(const Value: TColor); procedure SetGradientFromColor(const Value: TColor); procedure SetGradientToColor(const Value: TColor); @@ -46,7 +47,7 @@ type TSpkTabAppearance = class(TPersistent) destructor Destroy; override; procedure Reset; published - property TabHeaderFont : TFont read FTabHeaderFont write SetHeaderFont; + property TabHeaderFont : TFont read GetTabHeaderFont write SetHeaderFont; property BorderColor : TColor read FBorderColor write SetBorderColor; property GradientFromColor : TColor read FGradientFromColor write SetGradientFromColor; property GradientToColor : TColor read FGradientToColor write SetGradientToColor; @@ -66,6 +67,7 @@ type TSpkPaneAppearance = class(TPersistent) FGradientType : TBackgroundKind; procedure SetCaptionFont(const Value: TFont); + function GetCaptionFont: TFont; procedure SetBorderDarkColor(const Value: TColor); procedure SetBorderLightColor(const Value: TColor); procedure SetGradientFromColor(const Value: TColor); @@ -80,7 +82,7 @@ type TSpkPaneAppearance = class(TPersistent) destructor Destroy; override; procedure Reset; published - property CaptionFont : TFont read FCaptionFont write SetCaptionFont; + property CaptionFont : TFont read GetCaptionFont write SetCaptionFont; property BorderDarkColor : TColor read FBorderDarkColor write SetBorderDarkColor; property BorderLightColor : TColor read FBorderLightColor write SetBorderLightColor; property GradientFromColor : TColor read FGradientFromColor write SetGradientFromColor; @@ -124,6 +126,7 @@ type TSpkElementAppearance = class(TPersistent) procedure SetActiveInnerDarkColor(const Value: TColor); procedure SetActiveInnerLightColor(const Value: TColor); procedure SetCaptionFont(const Value: TFont); + function GetCaptionFont: TFont; procedure SetHotTrackCaptionColor(const Value: TColor); procedure SetHotTrackFrameColor(const Value: TColor); procedure SetHotTrackGradientFromColor(const Value: TColor); @@ -146,7 +149,7 @@ type TSpkElementAppearance = class(TPersistent) destructor Destroy; override; procedure Reset; published - property CaptionFont : TFont read FCaptionFont write SetCaptionFont; + property CaptionFont : TFont read GetCaptionFont write SetCaptionFont; property IdleFrameColor : TColor read FIdleFrameColor write SetIdleFrameColor; property IdleGradientFromColor : TColor read FIdleGradientFromColor write SetIdleGradientFromColor; property IdleGradientToColor : TColor read FIdleGradientToColor write SetIdleGradientToColor; @@ -380,6 +383,23 @@ begin FDispatch.NotifyAppearanceChanged; end; +function TSpkTabAppearance.GetTabHeaderFont: TFont; +var + ScaledFont: TFont; +begin + if DPI_AWARE then + begin + ScaledFont := TFont.Create; + ScaledFont.Assign(FTabHeaderFont); + //ScaledFont.Height := SpkScaleY(ScaledFont.Height, 96); // leave it to uscaledpi + Result := ScaledFont; + end + else + Result := FTabHeaderFont; +end; + + + { TSpkPaneAppearance } procedure TSpkPaneAppearance.Assign(Source: TPersistent); @@ -578,6 +598,23 @@ begin FDispatch.NotifyAppearanceChanged; end; +function TSpkPaneAppearance.GetCaptionFont: TFont; +var + ScaledFont: TFont; +begin + if DPI_AWARE then + begin + ScaledFont := TFont.Create; + ScaledFont.Assign(FCaptionFont); + //ScaledFont.Height := SpkScaleY(ScaledFont.Height, 96); // leave it to uscaledpi + Result := ScaledFont; + end + else + Result := FCaptionFont; +end; + + + { TSpkElementAppearance } procedure TSpkElementAppearance.Assign(Source: TPersistent); @@ -937,6 +974,21 @@ begin FDispatch.NotifyAppearanceChanged; end; +function TSpkElementAppearance.GetCaptionFont: TFont; +var + ScaledFont: TFont; +begin + if DPI_AWARE then + begin + ScaledFont := TFont.Create; + ScaledFont.Assign(FCaptionFont); + //ScaledFont.Height := SpkScaleY(ScaledFont.Height, 96); // leave it to uscaledpi + Result := ScaledFont; + end + else + Result := FCaptionFont; +end; + procedure TSpkElementAppearance.SetHotTrackCaptionColor( const Value: TColor); begin diff --git a/components/spktoolbar/SpkToolbar/spkt_Buttons.pas b/components/spktoolbar/SpkToolbar/spkt_Buttons.pas index 0a00589fb..5200c5699 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Buttons.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Buttons.pas @@ -727,8 +727,8 @@ begin {$IFDEF EnhancedRecordSupport} if FButtonKind = bkButtonDropdown then begin - FButtonRect:=T2DIntRect.Create(FRect.Left, FRect.Top, FRect.Right, FRect.Bottom - LARGEBUTTON_DROPDOWN_FIELD_SIZE); - FDropdownRect:=T2DIntRect.Create(FRect.Left, FRect.Bottom - LARGEBUTTON_DROPDOWN_FIELD_SIZE + 1, FRect.Right, FRect.Bottom); + FButtonRect:=T2DIntRect.Create(FRect.Left, FRect.Top, FRect.Right, FRect.Bottom - SpkLayoutSizes.LARGEBUTTON_DROPDOWN_FIELD_SIZE); + FDropdownRect:=T2DIntRect.Create(FRect.Left, FRect.Bottom - SpkLayoutSizes.LARGEBUTTON_DROPDOWN_FIELD_SIZE + 1, FRect.Right, FRect.Bottom); end else begin @@ -738,8 +738,8 @@ else {$ELSE} if FButtonKind = bkButtonDropdown then begin - FButtonRect.Create(FRect.Left, FRect.Top, FRect.Right, FRect.Bottom - LARGEBUTTON_DROPDOWN_FIELD_SIZE); - FDropdownRect.Create(FRect.Left, FRect.Bottom - LARGEBUTTON_DROPDOWN_FIELD_SIZE + 1, FRect.Right, FRect.Bottom); + FButtonRect.Create(FRect.Left, FRect.Top, FRect.Right, FRect.Bottom - LargeButtonDropdownFieldSize); + FDropdownRect.Create(FRect.Left, FRect.Bottom - LargeButtonDropdownFieldSize + 1, FRect.Right, FRect.Bottom); end else begin @@ -779,7 +779,7 @@ if FToolbarDispatch=nil then if FAppearance=nil then exit; -if (FRect.width<2*LARGEBUTTON_RADIUS) or (FRect.Height<2*LARGEBUTTON_RADIUS) then +if (FRect.width<2*LargeButtonRadius) or (FRect.Height<2*LargeButtonRadius) then exit; if FButtonKind in [bkButton, bkDropdown] then @@ -813,7 +813,7 @@ if FButtonKind in [bkButton, bkDropdown] then FButtonRect.Right, FButtonRect.Bottom), {$ENDIF} - LARGEBUTTON_RADIUS, + LargeButtonRadius, FAppearance.Element.HotTrackGradientFromColor, FAppearance.Element.HotTrackGradientToColor, FAppearance.Element.HotTrackGradientType, @@ -831,12 +831,12 @@ if FButtonKind in [bkButton, bkDropdown] then FButtonRect.right-1, FButtonRect.Bottom-1), {$ENDIF} - LARGEBUTTON_RADIUS, + LargeButtonRadius, FAppearance.Element.HotTrackInnerLightColor, ClipRect); TGuiTools.DrawAARoundFrame(ABuffer, FButtonRect, - LARGEBUTTON_RADIUS, + LargeButtonRadius, FAppearance.Element.HotTrackFrameColor, ClipRect); {$ENDREGION} @@ -856,7 +856,7 @@ if FButtonKind in [bkButton, bkDropdown] then FButtonRect.Right, FButtonRect.Bottom), {$ENDIF} - LARGEBUTTON_RADIUS, + LargeButtonRadius, FAppearance.Element.ActiveGradientFromColor, FAppearance.Element.ActiveGradientToColor, FAppearance.Element.ActiveGradientType, @@ -875,12 +875,12 @@ if FButtonKind in [bkButton, bkDropdown] then FButtonRect.right-1, FButtonRect.Bottom-1), {$ENDIF} - LARGEBUTTON_RADIUS, + LargeButtonRadius, FAppearance.Element.ActiveInnerLightColor, ClipRect); TGuiTools.DrawAARoundFrame(ABuffer, FButtonRect, - LARGEBUTTON_RADIUS, + LargeButtonRadius, FAppearance.Element.ActiveFrameColor, ClipRect); {$ENDREGION} @@ -896,7 +896,7 @@ if FButtonKind in [bkButton, bkDropdown] then (FLargeImageIndexnil then - GlyphWidth:=2 * LARGEBUTTON_GLYPH_MARGIN + FLargeImages.Width else + GlyphWidth:=2 * LargeButtonGlyphMargin + FLargeImages.Width else GlyphWidth:=0; // *** Tekst *** @@ -1635,16 +1635,16 @@ if FButtonKind = bkButton then begin // £amiemy etykietê FindBreakPlace(FCaption,BreakPos,RowWidth); - TextWidth:=2 * LARGEBUTTON_CAPTION_HMARGIN + RowWidth; + TextWidth:=2 * LargeButtonCaptionHMargin + RowWidth; end else begin // Nie ³amiemy etykiety Bitmap.canvas.font.assign(FAppearance.Element.CaptionFont); - TextWidth:=2 * LARGEBUTTON_CAPTION_HMARGIN + Bitmap.Canvas.TextWidth(FCaption); + TextWidth:=2 * LargeButtonCaptionHMargin + Bitmap.Canvas.TextWidth(FCaption); end; -result:=max(LARGEBUTTON_MIN_WIDTH, max(GlyphWidth, TextWidth)); +result := Max(LargeButtonMinWidth, max(GlyphWidth, TextWidth)); end; procedure TSpkLargeButton.SetLargeImageIndex(const Value: TImageIndex); @@ -1706,7 +1706,7 @@ AdditionalPadding:=false; // Ikona if FImageIndex<>-1 then begin - BtnWidth:=BtnWidth + SMALLBUTTON_PADDING + SMALLBUTTON_GLYPH_WIDTH; + BtnWidth:=BtnWidth + SmallButtonPadding + SmallButtonGlyphWidth; AdditionalPadding:=true; end; @@ -1716,87 +1716,87 @@ if FShowCaption then Bitmap.Canvas.Font.assign(FAppearance.Element.CaptionFont); TextWidth:=Bitmap.Canvas.TextWidth(FCaption); - BtnWidth:=BtnWidth + SMALLBUTTON_PADDING + TextWidth; + BtnWidth:=BtnWidth + SmallButtonPadding + TextWidth; AdditionalPadding:=true; end; // Padding za tekstem lub ikon¹ if AdditionalPadding then - BtnWidth:=BtnWidth + SMALLBUTTON_PADDING; + BtnWidth:=BtnWidth + SmallButtonPadding; // Szerokoœæ zawartoœci przycisku musi wynosiæ co najmniej SMALLBUTTON_MIN_WIDTH -BtnWidth:=max(SMALLBUTTON_MIN_WIDTH, BtnWidth); +BtnWidth := Max(SmallButtonMinWidth, BtnWidth); // *** Dropdown *** case FButtonKind of bkButton: begin // Lewa krawêdŸ przycisku if FGroupBehaviour in [gbContinuesGroup, gbEndsGroup] then - BtnWidth:=BtnWidth + SMALLBUTTON_HALF_BORDER_WIDTH else - BtnWidth:=BtnWidth + SMALLBUTTON_BORDER_WIDTH; + BtnWidth:=BtnWidth + SmallButtonHalfBorderWidth else + BtnWidth:=BtnWidth + SmallButtonBorderWidth; // Prawa krawêdŸ przycisku if (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) then - BtnWidth:=BtnWidth + SMALLBUTTON_HALF_BORDER_WIDTH else - BtnWidth:=BtnWidth + SMALLBUTTON_BORDER_WIDTH; + BtnWidth:=BtnWidth + SmallButtonHalfBorderWidth else + BtnWidth:=BtnWidth + SmallButtonBorderWidth; {$IFDEF EnhancedRecordSupport} - BtnRect:=T2DIntRect.Create(0, 0, BtnWidth - 1, PANE_ROW_HEIGHT - 1); + BtnRect:=T2DIntRect.Create(0, 0, BtnWidth - 1, SpkLayoutSizes.PANE_ROW_HEIGHT - 1); DropRect:=T2DIntRect.Create(0, 0, 0, 0); {$ELSE} - BtnRect.Create(0, 0, BtnWidth - 1, PANE_ROW_HEIGHT - 1); + BtnRect.Create(0, 0, BtnWidth - 1, PaneRowHeight - 1); DropRect.Create(0, 0, 0, 0); {$ENDIF} end; bkButtonDropdown: begin // Lewa krawêdŸ przycisku if FGroupBehaviour in [gbContinuesGroup, gbEndsGroup] then - BtnWidth:=BtnWidth + SMALLBUTTON_HALF_BORDER_WIDTH else - BtnWidth:=BtnWidth + SMALLBUTTON_BORDER_WIDTH; + BtnWidth:=BtnWidth + SmallButtonHalfBorderWidth else + BtnWidth:=BtnWidth + SmallButtonBorderWidth; // Prawa krawêdŸ przycisku - BtnWidth:=BtnWidth + SMALLBUTTON_HALF_BORDER_WIDTH; + BtnWidth:=BtnWidth + SmallButtonHalfBorderWidth; // Lewa krawêdŸ i zawartoœæ pola dropdown - DropdownWidth:=SMALLBUTTON_HALF_BORDER_WIDTH + SMALLBUTTON_DROPDOWN_WIDTH; + DropdownWidth := SmallButtonHalfBorderWidth + SmallButtonDropdownWidth; // Prawa krawêdŸ pola dropdown if (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) then - DropdownWidth:=DropdownWidth + SMALLBUTTON_HALF_BORDER_WIDTH else - DropdownWidth:=DropdownWidth + SMALLBUTTON_BORDER_WIDTH; + DropdownWidth:=DropdownWidth + SmallButtonHalfBorderWidth else + DropdownWidth:=DropdownWidth + SmallButtonBorderWidth; {$IFDEF EnhancedRecordSupport} - BtnRect:=T2DIntRect.Create(0, 0, BtnWidth - 1, PANE_ROW_HEIGHT - 1); + BtnRect:=T2DIntRect.Create(0, 0, BtnWidth - 1, PaneRowHeightT - 1); DropRect:=T2DIntRect.Create(BtnRect.right+1, 0, BtnRect.right+DropdownWidth, - PANE_ROW_HEIGHT - 1); + PaneRowHeight - 1); {$ELSE} - BtnRect.Create(0, 0, BtnWidth - 1, PANE_ROW_HEIGHT - 1); + BtnRect.Create(0, 0, BtnWidth - 1, PaneRowHeight - 1); DropRect.Create(BtnRect.right+1, 0, - BtnRect.right+DropdownWidth, PANE_ROW_HEIGHT - 1); + BtnRect.right+DropdownWidth, PaneRowHeight - 1); {$ENDIF} end; bkDropdown: begin // Lewa krawêdŸ przycisku if FGroupBehaviour in [gbContinuesGroup, gbEndsGroup] then - BtnWidth:=BtnWidth + SMALLBUTTON_HALF_BORDER_WIDTH else - BtnWidth:=BtnWidth + SMALLBUTTON_BORDER_WIDTH; + BtnWidth:=BtnWidth + SmallButtonHalfBorderWidth else + BtnWidth:=BtnWidth + SmallButtonBorderWidth; // Prawa krawêdŸ przycisku if (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) then - BtnWidth:=BtnWidth + SMALLBUTTON_HALF_BORDER_WIDTH else - BtnWidth:=BtnWidth + SMALLBUTTON_BORDER_WIDTH; + BtnWidth:=BtnWidth + SmallButtonHalfBorderWidth else + BtnWidth:=BtnWidth + SmallButtonBorderWidth; // Dodatkowy obszar na dropdown + miejsce na œrodkow¹ krawêdŸ, // dla kompatybilnoœci wymiarów z dkButtonDropdown - BtnWidth:=BtnWidth + SMALLBUTTON_BORDER_WIDTH + SMALLBUTTON_DROPDOWN_WIDTH; + BtnWidth:=BtnWidth + SmallButtonBorderWidth + SmallButtonDropdownWidth; {$IFDEF EnhancedRecordSupport} - BtnRect:=T2DIntRect.Create(0, 0, BtnWidth - 1, PANE_ROW_HEIGHT - 1); + BtnRect:=T2DIntRect.Create(0, 0, BtnWidth - 1, PaneRowHeight - 1); DropRect:=T2DIntRect.Create(0, 0, 0, 0); {$ELSE} - BtnRect.Create(0, 0, BtnWidth - 1, PANE_ROW_HEIGHT - 1); + BtnRect.Create(0, 0, BtnWidth - 1, PaneRowHeight - 1); DropRect.Create(0, 0, 0, 0); {$ENDIF} end; @@ -1824,7 +1824,7 @@ if FToolbarDispatch=nil then if FAppearance=nil then exit; -if (FRect.width<2*LARGEBUTTON_RADIUS) or (FRect.Height<2*LARGEBUTTON_RADIUS) then +if (FRect.width < 2*LargeButtonRadius) or (FRect.Height < 2*LargeButtonRadius) then exit; // *** Przycisk *** @@ -1846,7 +1846,7 @@ if (FButtonState = bsIdle) and (not(FHideFrameWhenIdle)) then (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect); end else if (FButtonState=bsBtnHottrack) then @@ -1864,7 +1864,7 @@ if (FButtonState=bsBtnHottrack) then (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect); end else if (FButtonState = bsBtnPressed) then @@ -1882,7 +1882,7 @@ if (FButtonState = bsBtnPressed) then (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect); end else if (FButtonState in [bsDropdownHottrack, bsDropdownPressed]) then @@ -1900,7 +1900,7 @@ if (FButtonState in [bsDropdownHottrack, bsDropdownPressed]) then (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect); end; {$ENDREGION} @@ -1914,8 +1914,8 @@ if not(FEnabled) then (FImageIndex-1 then - x:=x + 2 * SMALLBUTTON_PADDING + SMALLBUTTON_GLYPH_WIDTH else - x:=x + SMALLBUTTON_PADDING; + x:=x + 2 * SmallButtonPadding + SmallButtonGlyphWidth else + x:=x + SmallButtonPadding; y:=FButtonRect.Top + (FButtonRect.Height - ABuffer.Canvas.TextHeight('Wy')) div 2; TGUITools.DrawText(ABuffer.Canvas, @@ -2043,7 +2043,7 @@ if FButtonKind = bkButtonDropdown then (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect); end else if (FButtonState in [bsBtnHottrack, bsBtnPressed]) then @@ -2061,7 +2061,7 @@ if FButtonKind = bkButtonDropdown then (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect); end else @@ -2080,7 +2080,7 @@ if FButtonKind = bkButtonDropdown then (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect); end else if (FButtonState = bsDropdownPressed) then @@ -2098,7 +2098,7 @@ if FButtonKind = bkButtonDropdown then (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect); end; @@ -2133,8 +2133,8 @@ if FButtonKind = bkButtonDropdown then ABuffer.Canvas.Font.Orientation:=0; if FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup] then - x:=FDropdownRect.Right - SMALLBUTTON_HALF_BORDER_WIDTH - (SMALLBUTTON_DROPDOWN_WIDTH + ABuffer.Canvas.Textwidth('u')) div 2 + 1 else - x:=FDropdownRect.Right - SMALLBUTTON_BORDER_WIDTH - (SMALLBUTTON_DROPDOWN_WIDTH + ABuffer.Canvas.Textwidth('u')) div 2 + 1; + x:=FDropdownRect.Right - SmallButtonHalfBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1 else + x:=FDropdownRect.Right - SmallButtonBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1; y:=FDropdownRect.top + (FDropdownRect.height - ABuffer.Canvas.Textheight('u')) div 2; TGUITools.DrawText(ABuffer.Canvas, x, y, 'u', FontColor, ClipRect); {$ENDREGION} @@ -2173,8 +2173,8 @@ if FButtonKind = bkDropdown then ABuffer.Canvas.Font.Orientation:=0; if FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup] then - x:=FButtonRect.Right - SMALLBUTTON_HALF_BORDER_WIDTH - (SMALLBUTTON_DROPDOWN_WIDTH + ABuffer.Canvas.Textwidth('u')) div 2 + 1 else - x:=FButtonRect.Right - SMALLBUTTON_BORDER_WIDTH - (SMALLBUTTON_DROPDOWN_WIDTH + ABuffer.Canvas.Textwidth('u')) div 2 + 1; + x:=FButtonRect.Right - SmallButtonHalfBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1 else + x:=FButtonRect.Right - SmallButtonBorderWidth - (SmallButtonDropdownWidth + ABuffer.Canvas.Textwidth('u')) div 2 + 1; y:=FButtonRect.top + (FButtonRect.height - ABuffer.Canvas.Textheight('u')) div 2; TGUITools.DrawText(ABuffer.Canvas, x, y, 'u', FontColor, ClipRect); end; diff --git a/components/spktoolbar/SpkToolbar/spkt_Checkboxes.pas b/components/spktoolbar/SpkToolbar/spkt_Checkboxes.pas index d3da53340..822db395a 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Checkboxes.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Checkboxes.pas @@ -201,25 +201,25 @@ begin Bitmap.Canvas.Font.Assign(FAppearance.Element.CaptionFont); TextWidth := Bitmap.Canvas.TextWidth(FCaption); - BtnWidth := SMALLBUTTON_PADDING + SMALLBUTTON_GLYPH_WIDTH + - SMALLBUTTON_PADDING + TextWidth + SMALLBUTTON_PADDING; - BtnWidth := Max(SMALLBUTTON_MIN_WIDTH, BtnWidth); + BtnWidth := SmallButtonPadding + SmallButtonGlyphWidth + + SmallButtonPadding + TextWidth + SmallButtonPadding; + BtnWidth := Max(SmallButtonMinWidth, BtnWidth); if FGroupBehaviour in [gbContinuesGroup, gbEndsGroup] then - BtnWidth := BtnWidth + SMALLBUTTON_HALF_BORDER_WIDTH + BtnWidth := BtnWidth + SmallButtonHalfBorderWidth else - BtnWidth := BtnWidth + SMALLBUTTON_BORDER_WIDTH; + BtnWidth := BtnWidth + SmallButtonBorderWidth; // Prawa krawêdŸ przycisku if (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) then - BtnWidth := BtnWidth + SMALLBUTTON_HALF_BORDER_WIDTH + BtnWidth := BtnWidth + SmallButtonHalfBorderWidth else - BtnWidth := BtnWidth + SMALLBUTTON_BORDER_WIDTH; + BtnWidth := BtnWidth + SmallButtonBorderWidth; {$IFDEF EnhancedRecordSupport} - BtnRect := T2DIntRect.Create(0, 0, BtnWidth - 1, PANE_ROW_HEIGHT - 1); + BtnRect := T2DIntRect.Create(0, 0, BtnWidth - 1, PaneRowHeight - 1); {$ELSE} - BtnRect.Create(0, 0, BtnWidth - 1, PANE_ROW_HEIGHT - 1); + BtnRect.Create(0, 0, BtnWidth - 1, PaneRowHeight - 1); {$ENDIF} end; @@ -234,7 +234,7 @@ begin exit; if FAppearance = nil then exit; - if (FRect.Width < 2*LARGEBUTTON_RADIUS) or (FRect.Height < 2*LARGEBUTTON_RADIUS) then + if (FRect.Width < 2*LargeButtonRadius) or (FRect.Height < 2*LargeButtonRadius) then exit; // Border @@ -253,7 +253,7 @@ begin (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect ); end else @@ -272,7 +272,7 @@ begin (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect ); end else @@ -291,7 +291,7 @@ begin (FGroupBehaviour in [gbBeginsGroup, gbContinuesGroup]) or (FButtonKind = bkButtonDropdown), false, false, - SMALLBUTTON_RADIUS, + SmallButtonRadius, ClipRect ); end; @@ -303,9 +303,9 @@ begin end else h := GetSystemMetrics(SM_CYMENUCHECK); if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then - x := FButtonRect.Left + SMALLBUTTON_HALF_BORDER_WIDTH + SMALLBUTTON_PADDING + x := FButtonRect.Left + SmallButtonHalfBorderWidth + SmallButtonPadding else - x := FButtonRect.Left + SMALLBUTTON_BORDER_WIDTH + SMALLBUTTON_PADDING; + x := FButtonRect.Left + SmallButtonBorderWidth + SmallButtonPadding; y := FButtonRect.Top + (FButtonRect.Height - h) div 2; TGUITools.DrawCheckbox( @@ -339,10 +339,10 @@ begin end; if (FGroupBehaviour in [gbContinuesGroup, gbEndsGroup]) then - x := FButtonRect.Left + SMALLBUTTON_HALF_BORDER_WIDTH + x := FButtonRect.Left + SmallButtonHalfBorderWidth else - x := FButtonRect.Left + SMALLBUTTON_BORDER_WIDTH; - x := x + 2 * SMALLBUTTON_PADDING + SMALLBUTTON_GLYPH_WIDTH; + x := FButtonRect.Left + SmallButtonBorderWidth; + x := x + 2 * SmallButtonPadding + SmallButtonGlyphWidth; y := FButtonRect.Top + (FButtonRect.Height - ABuffer.Canvas.TextHeight('Wy')) div 2; TGUITools.DrawText( diff --git a/components/spktoolbar/SpkToolbar/spkt_Const.pas b/components/spktoolbar/SpkToolbar/spkt_Const.pas index 2cf7eda88..b854b6c6f 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Const.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Const.pas @@ -14,155 +14,377 @@ unit spkt_Const; interface -const // **************** - // *** Elementy *** - // **************** +procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0); +function SpkScaleX(Size: Integer; FromDPI: Integer; ToDPI: Integer = 0): integer; +function SpkScaleY(Size: Integer; FromDPI: Integer; ToDPI: Integer = 0): integer; - LARGEBUTTON_DROPDOWN_FIELD_SIZE = 29; - LARGEBUTTON_GLYPH_MARGIN = 1; - LARGEBUTTON_CAPTION_HMARGIN = 3; - LARGEBUTTON_MIN_WIDTH = 24; - LARGEBUTTON_RADIUS = 4; - LARGEBUTTON_BORDER_SIZE = 2; - LARGEBUTTON_CHEVRON_HMARGIN = 4; - LARGEBUTTON_CAPTION_TOP_RAIL = 45; - LARGEBUTTON_CAPTION_BOTTOM_RAIL = 58; +const + // **************** + // *** Elements *** + // **************** - SMALLBUTTON_GLYPH_WIDTH = 20; //16; - SMALLBUTTON_BORDER_WIDTH = 2; - SMALLBUTTON_HALF_BORDER_WIDTH = 1; - SMALLBUTTON_PADDING = 2; - SMALLBUTTON_DROPDOWN_WIDTH = 11; - SMALLBUTTON_RADIUS = 4; - SMALLBUTTON_MIN_WIDTH = 2 * SMALLBUTTON_PADDING + SMALLBUTTON_GLYPH_WIDTH; + LARGEBUTTON_DROPDOWN_FIELD_SIZE = 29; + LARGEBUTTON_GLYPH_MARGIN = 1; + LARGEBUTTON_CAPTION_HMARGIN = 3; + LARGEBUTTON_MIN_WIDTH = 24; + LARGEBUTTON_RADIUS = 4; + LARGEBUTTON_BORDER_SIZE = 2; + LARGEBUTTON_CHEVRON_HMARGIN = 4; + LARGEBUTTON_CAPTION_TOP_RAIL = 45; + LARGEBUTTON_CAPTION_BOTTOM_RAIL = 58; - // ******************** - // *** Obszar tafli *** - // ******************** + SMALLBUTTON_GLYPH_WIDTH = 16; //was: 20; //16; + SMALLBUTTON_BORDER_WIDTH = 2; + SMALLBUTTON_HALF_BORDER_WIDTH = 1; + SMALLBUTTON_PADDING = 2; + SMALLBUTTON_DROPDOWN_WIDTH = 11; + SMALLBUTTON_RADIUS = 4; - /// Maksymalna wysokoœæ obszaru, który mo¿e zaj¹æ zawartoœæ - /// tafli z elementami - MAX_ELEMENT_HEIGHT = 67; + // *********************** + // *** Tab page layout *** + // *********************** - /// Wysokoœæ pojedynczego wiersza elementów tafli - PANE_ROW_HEIGHT = 22; + /// Maximum area height that can be used by an element + MAX_ELEMENT_HEIGHT = 67; - PANE_FULL_ROW_HEIGHT = 3 * PANE_ROW_HEIGHT; + /// Maximum row height + PANE_ROW_HEIGHT = 22; - /// Wewnêtrzny pionowy margines pomiêdzy pierwszym elementem a - /// tafl¹ w przypadku wersji jednowierszowej - PANE_ONE_ROW_TOPPADDING = 22; - /// Wewnêtrzny pionowy margines pomiêdzy ostatnim elementem - /// a tafl¹ w przypadku wersji jednowierszowej - PANE_ONE_ROW_BOTTOMPADDING = 23; + /// Single row top margin + PANE_ONE_ROW_TOPPADDING = 22; + /// Single row bottom margin + PANE_ONE_ROW_BOTTOMPADDING = 23; - /// Odleg³oœæ pomiêdzy wierszami w przypadku wersji dwuwierszowej - /// - PANE_TWO_ROWS_VSPACER = 7; - /// Wewnêtrzny pionowy margines pomiêdzy pierwszym elementem a - /// tafl¹ w przypadku wersji dwuwierszowej - PANE_TWO_ROWS_TOPPADDING = 8; - /// Wewnêtrzny pionowy margines pomiêdzy ostatnim elementem - /// a tafl¹ w przypadku wersji dwuwierszowej - PANE_TWO_ROWS_BOTTOMPADDING = 8; + /// Space between rows in a double row layout + PANE_TWO_ROWS_VSPACER = 7; + /// Double row layout top margin + PANE_TWO_ROWS_TOPPADDING = 8; + /// Double row layout bottom margin + PANE_TWO_ROWS_BOTTOMPADDING = 8; - /// Odleg³oœæ pomiêdzy wierszami w przypadku wersji - /// trzywierszowej - PANE_THREE_ROWS_VSPACER = 0; - /// Wewnêtrzny pionowy margines pomiêdzy pierwszym elementem a - /// tafl¹ w przypadku wersji trzywierszowej - PANE_THREE_ROWS_TOPPADDING = 0; - /// Wewnêtrzny pionowy margines pomiêdzy ostatnim elementem - /// a tafl¹ w przypadku wersji trzywierszowej - PANE_THREE_ROWS_BOTTOMPADDING = 1; + /// Space between rows in triple row layout + PANE_THREE_ROWS_VSPACER = 0; + /// Triple row layout top margin + PANE_THREE_ROWS_TOPPADDING = 0; + /// Triple row layout bottom margin + PANE_THREE_ROWS_BOTTOMPADDING = 1; - PANE_FULL_ROW_TOPPADDING = PANE_THREE_ROWS_TOPPADDING; + /// Pane left padding, space between left pane border and left element border + PANE_LEFT_PADDING = 2; + /// Pane right padding, space between right pane border and right element border + PANE_RIGHT_PADDING = 2; + /// Space between two columns inside the pane + PANE_COLUMN_SPACER = 4; + /// Space between groups on a row in pane + PANE_GROUP_SPACER = 4; - PANE_FULL_ROW_BOTTOMPADDING = PANE_THREE_ROWS_BOTTOMPADDING; - /// Odleg³oœæ pomiêdzy lew¹ krawêdzi¹ a pierwszym elementem - /// tafli - PANE_LEFT_PADDING = 2; + // ******************* + // *** Pane layout *** + // ******************* - /// Odleg³oœæ pomiêdzy ostatnim elementem tafli a praw¹ krawêdzi¹ - /// - PANE_RIGHT_PADDING = 2; + /// Pane caption height + PANE_CAPTION_HEIGHT = 15; + /// Pane corner radius + PANE_CORNER_RADIUS = 3; + /// Pane border size. + /// Do not change? + PANE_BORDER_SIZE = 2; + /// Half width of pane border? + /// Do not change? + PANE_BORDER_HALF_SIZE = 1; + /// Pane caption horizontal padding + PANE_CAPTION_HMARGIN = 6; - /// Odleg³oœæ pomiêdzy dwoma kolumnami wewn¹trz tafli - PANE_COLUMN_SPACER = 4; - /// Odleg³oœæ pomiêdzy dwoma osobnymi grupami wewnêtrz wiersza - /// w tafli - PANE_GROUP_SPACER = 4; + // ************ + // *** Tabs *** + // ************ - // ************* - // *** Tafla *** - // ************* + /// Tab corner radius + TAB_CORNER_RADIUS = 4; + /// Tab page left margin + TAB_PANE_LEFTPADDING = 2; + /// Tab page right margin + TAB_PANE_RIGHTPADDING = 2; + /// Tab page top margin + TAB_PANE_TOPPADDING = 2; + /// Tab page bottom margin + TAB_PANE_BOTTOMPADDING = 1; + /// Space between panes + TAB_PANE_HSPACING = 3; + /// Tab border size + TAB_BORDER_SIZE = 1; - /// Wysokoœæ obszaru tytu³u tafli - PANE_CAPTION_HEIGHT = 15; - PANE_CORNER_RADIUS = 3; + // *************** + // *** Toolbar *** + // *************** - /// Szerokoœæ/wysokoœæ ramki tafli - /// Nie nale¿y zmieniaæ tej sta³ej! - PANE_BORDER_SIZE = 2; + /// Pane padding? + TOOLBAR_BORDER_WIDTH = 1; + TOOLBAR_CORNER_RADIUS = 3; + /// Tab caption height + TOOLBAR_TAB_CAPTIONS_HEIGHT = 22; + /// Tab caption horizontal padding + TOOLBAR_TAB_CAPTIONS_TEXT_HPADDING = 4; + /// Min tab caption width + TOOLBAR_MIN_TAB_CAPTION_WIDTH = 32; - /// Po³owa szerokoœci ramki tafli - /// Nie nale¿y zmieniaæ tej sta³ej! - PANE_BORDER_HALF_SIZE = 1; +var + // **************** + // *** Elements *** + // **************** + LargeButtonDropdownFieldSize: Integer; + LargeButtonGlyphMargin: Integer; + LargeButtonCaptionHMargin: Integer; + LargeButtonMinWidth: Integer; + LargeButtonRadius: Integer; + LargeButtonBorderSize: Integer; + LargeButtonChevronHMargin: Integer; + LargeButtonCaptionTopRail: Integer; + LargeButtonCaptionButtomRail: Integer; - /// Wysokoœæ ca³ej tafli (uwzglêdniaj¹c ramkê) - PANE_HEIGHT = MAX_ELEMENT_HEIGHT + PANE_CAPTION_HEIGHT + 2 * PANE_BORDER_SIZE; + SmallButtonGlyphWidth: Integer; + SmallButtonBorderWidth: Integer; + SmallButtonHalfBorderWidth: Integer; + SmallButtonPadding: Integer; + SmallButtonDropdownWidth: Integer; + SmallButtonRadius: Integer; + SmallButtonMinWidth: Integer; - /// Poziomy margines etykiety zak³adki - PANE_CAPTION_HMARGIN = 6; - // *********************** - // *** Obszar zak³adki *** - // *********************** + // *********************** + // *** Tab page layout *** + // *********************** - /// Promieñ zaokr¹glenia zak³adki - TAB_CORNER_RADIUS = 4; + /// Maximum area height that can be used by an element + MaxElementHeight: Integer; - /// Lewy wewnêtrzny margines zak³adki - TAB_PANE_LEFTPADDING = 2; - /// Prawy wewnêtrzny margines zak³adki - TAB_PANE_RIGHTPADDING = 2; - /// Górny wewnêtrzny margines zak³adki - TAB_PANE_TOPPADDING = 2; - /// Dolny wewnêtrzny margines zak³adki - TAB_PANE_BOTTOMPADDING = 1; - /// Odleg³oœæ pomiêdzy taflami - TAB_PANE_HSPACING = 3; + /// Maximum row height + PaneRowHeight: Integer; + PaneFullRowHeight: Integer; - /// Szerokoœæ/wysokoœæ ramki zak³adki (nie nale¿y zmieniaæ!) - /// - TAB_BORDER_SIZE = 1; - /// Wysokoœæ zak³adki - TAB_HEIGHT = PANE_HEIGHT + TAB_PANE_TOPPADDING + TAB_PANE_BOTTOMPADDING + TAB_BORDER_SIZE; + /// Single row top margin + PaneOneRowTopPadding: Integer; + /// Single row bottom margin + PaneOneRowBottomPadding: Integer; - // *************** - // *** Toolbar *** - // *************** + /// Space between rows in a double row layout + PaneTwoRowsVSpacer: Integer; + /// Double row layout top margin + PaneTwoRowsTopPadding: Integer; + /// Double row layout bottom margin + PaneTwoRowsBottomPadding: Integer; - TOOLBAR_BORDER_WIDTH = 1; + /// Space between rows in triple row layout + PaneThreeRowsVSpacer: Integer; + /// Triple row layout top margin + PaneThreeRowsTopPadding: Integer; + /// Triple row layout bottom margin + PaneThreeRowsBottomPadding: Integer; - TOOLBAR_CORNER_RADIUS = 3; + PaneFullRowTopPadding: Integer; + PaneFullRowBottomPadding: Integer; - /// Wysokoœæ etykiet z nazwami zak³adek - TOOLBAR_TAB_CAPTIONS_HEIGHT = 22; - /// Poziomy margines wewnêtrznego tytu³u zak³adki - TOOLBAR_TAB_CAPTIONS_TEXT_HPADDING = 4; + /// Pane left padding, space between left pane border and left element border + PaneLeftPadding: Integer; + /// Pane right padding, space between right pane border and right element border + PaneRightPadding: Integer; + /// Space between two columns inside the pane + PaneColumnSpacer: Integer; + /// Space between groups on a row in pane + PaneGroupSpacer: Integer; - TOOLBAR_MIN_TAB_CAPTION_WIDTH = 32; - /// Sumaryczna wysokoœæ toolbara - TOOLBAR_HEIGHT = TOOLBAR_TAB_CAPTIONS_HEIGHT + - TAB_HEIGHT; + // ******************* + // *** Pane layout *** + // ******************* + + /// Pane caption height + PaneCaptionHeight: Integer; + /// Pane corner radius + PaneCornerRadius: Integer; + /// Pane border size + /// Do not change? + PaneBorderSize: Integer; + /// Half width of pane border? + /// Do not change? + PaneBorderHalfSize: Integer; + /// Height of pane + PaneHeight: Integer; + /// Pane caption horizontal padding + PaneCaptionHMargin: Integer; + + + // ************ + // *** Tabs *** + // ************ + + /// Tab corner radius + TabCornerRadius: Integer; + /// Tab page left margin + TabPaneLeftPadding: Integer; + /// Tab page right margin/summary> + TabPaneRightPadding: Integer; + /// Tab page top margin + TabPaneTopPadding: Integer; + /// Tab page bottom margin + TabPaneBottomPadding: Integer; + /// Space between panes + TabPaneHSpacing: Integer; + /// Tab border size + TabBorderSize: Integer; + /// Tab height + TabHeight: Integer; + + + // *************** + // *** Toolbar *** + // *************** + + /// Pane padding? + ToolbarBorderWidth: Integer; + ToolbarCornerRadius: Integer; + /// Tab caption height + ToolbarTabCaptionsHeight: Integer; + /// Tab caption horizontal padding + ToolbarTabCaptionsTextHPadding: Integer; + ToolbarMinTabCaptionWidth: Integer; + /// Toolbar total height + ToolbarHeight: Integer; + + +const + DPI_AWARE = true; + implementation +uses + Graphics, LCLType; + +procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0); +begin + + if not(DPI_AWARE) then + ToDPI := FromDPI; + + {$IfDef Darwin} + ToDPI := FromDPI; //macOS raster scales by itself + {$EndIf} + + LargeButtonDropdownFieldSize := SpkScaleX(LARGEBUTTON_DROPDOWN_FIELD_SIZE, FromDPI, ToDPI); + LargeButtonGlyphMargin := SpkScaleX(LARGEBUTTON_GLYPH_MARGIN, FromDPI, ToDPI); + LargeButtonCaptionHMargin := SpkScaleX(LARGEBUTTON_CAPTION_HMARGIN, FromDPI, ToDPI); + LargeButtonMinWidth := SpkScaleX(LARGEBUTTON_MIN_WIDTH, FromDPI, ToDPI); + LargeButtonRadius := LARGEBUTTON_RADIUS; + LargeButtonBorderSize := SpkScaleX(LARGEBUTTON_BORDER_SIZE, FromDPI, ToDPI); + LargeButtonChevronHMargin := SpkScaleX(LARGEBUTTON_CHEVRON_HMARGIN, FromDPI, ToDPI); + LargeButtonCaptionTopRail := SpkScaleY(LARGEBUTTON_CAPTION_TOP_RAIL, FromDPI, ToDPI); + LargeButtonCaptionButtomRail := SpkScaleY(LARGEBUTTON_CAPTION_BOTTOM_RAIL, FromDPI, ToDPI); + + SmallButtonGlyphWidth := SpkScaleX(SMALLBUTTON_GLYPH_WIDTH, FromDPI, ToDPI); + SmallButtonBorderWidth := SpkScaleX(SMALLBUTTON_BORDER_WIDTH, FromDPI, ToDPI); + SmallButtonHalfBorderWidth := SpkScaleX(SMALLBUTTON_HALF_BORDER_WIDTH, FromDPI, ToDPI); + SmallButtonPadding := SpkScaleX(SMALLBUTTON_PADDING, FromDPI, ToDPI); + SmallButtonDropdownWidth := SpkScaleX(SMALLBUTTON_DROPDOWN_WIDTH, FromDPI, ToDPI); + SmallButtonRadius := SMALLBUTTON_RADIUS; + SmallButtonMinWidth := 2 * SmallButtonPadding + SmallButtonGlyphWidth; + + MaxElementHeight := SpkScaleY(MAX_ELEMENT_HEIGHT, FromDPI, ToDPI); + PaneRowHeight := SpkScaleY(PANE_ROW_HEIGHT, FromDPI, ToDPI); + PaneFullRowHeight := 3 * PaneRowHeight; + PaneOneRowTopPadding := SpkScaleY(PANE_ONE_ROW_TOPPADDING, FromDPI, ToDPI); + PaneOneRowBottomPadding := SpkScaleY(PANE_ONE_ROW_BOTTOMPADDING, FromDPI, ToDPI); + PaneTwoRowsVSpacer := SpkScaleY(PANE_TWO_ROWS_VSPACER, FromDPI, ToDPI); + PaneTwoRowsTopPadding := SpkScaleY(PANE_TWO_ROWS_TOPPADDING, FromDPI, ToDPI); + PaneTwoRowsBottomPadding := SpkScaleY(PANE_TWO_ROWS_BOTTOMPADDING, FromDPI, ToDPI); + PaneThreeRowsVSpacer := SpkScaleY(PANE_THREE_ROWS_VSPACER, FromDPI, ToDPI); + PaneThreeRowsTopPadding := SpkScaleY(PANE_THREE_ROWS_TOPPADDING, FromDPI, ToDPI); + PaneThreeRowsBottomPadding := SpkScaleY(PANE_THREE_ROWS_BOTTOMPADDING, FromDPI, ToDPI); + PaneFullRowTopPadding := PaneThreeRowsTopPadding; + PaneFullRowBottomPadding := PaneThreeRowsBottomPadding; + PaneLeftPadding := SpkScaleX(PANE_LEFT_PADDING, FromDPI, ToDPI); + PaneRightPadding := SpkScaleX(PANE_RIGHT_PADDING, FromDPI, ToDPI); + PaneColumnSpacer := SpkScaleX(PANE_COLUMN_SPACER, FromDPI, ToDPI); + PaneGroupSpacer := SpkScaleX(PANE_GROUP_SPACER, FromDPI, ToDPI); + + PaneCaptionHeight := SpkScaleY(PANE_CAPTION_HEIGHT, FromDPI, ToDPI); + PaneCornerRadius := PANE_CORNER_RADIUS; + PaneBorderSize := SpkScaleX(PANE_BORDER_SIZE, FromDPI, ToDPI); + PaneBorderHalfSize := SpkScaleX(PANE_BORDER_HALF_SIZE, FromDPI, ToDPI); + PaneHeight := MaxElementHeight + PaneCaptionHeight + 2 * PaneBorderSize; + PaneCaptionHMargin := SpkScaleX(PANE_CAPTION_HMARGIN, FromDPI, ToDPI); + + TabCornerRadius := TAB_CORNER_RADIUS; + TabPaneLeftPadding := SpkScaleX(TAB_PANE_LEFTPADDING, FromDPI, ToDPI); + TabPaneRightPadding := SpkScaleX(TAB_PANE_RIGHTPADDING, FromDPI, ToDPI); + TabPaneTopPadding := SpkScaleY(TAB_PANE_TOPPADDING, FromDPI, ToDPI); + TabPaneBottomPadding := SpkScaleY(TAB_PANE_BOTTOMPADDING, FromDPI, ToDPI); + TabPaneHSpacing := SpkScaleX(TAB_PANE_HSPACING, FromDPI, ToDPI); + TabBorderSize := SpkScaleX(TAB_BORDER_SIZE, FromDPI, ToDPI); + TabHeight := PaneHeight + TabPaneTopPadding + TabPaneBottomPadding + TabBorderSize; + + ToolbarBorderWidth := SpkScaleX(TOOLBAR_BORDER_WIDTH, FromDPI, ToDPI); + ToolbarCornerRadius := TOOLBAR_CORNER_RADIUS; + 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; + + // scaling radius if not square + if LargeButtonRadius > 1 then + LargeButtonRadius := SpkScaleX(LargeButtonRadius, FromDPI, ToDPI); + + if SmallButtonRadius > 1 then + SmallButtonRadius := SpkScaleX(SmallButtonRadius, FromDPI, ToDPI); + + if PaneCornerRadius > 1 then + PaneCornerRadius := SpkScaleX(PaneCornerRadius, FromDPI, ToDPI); + + if TabCornerRadius > 1 then + TabCornerRadius := SpkScaleX(TabCornerRadius, FromDPI, ToDPI); + + if ToolbarCornerRadius > 1 then + ToolbarCornerRadius := SpkScaleX(ToolbarCornerRadius, FromDPI, ToDPI); +end; + +function SpkScaleX(Size: Integer; FromDPI: Integer; ToDPI: Integer): integer; +begin + if ToDPI = 0 then + ToDPI := ScreenInfo.PixelsPerInchX; + + if not(DPI_AWARE) or (ToDPI = FromDPI) then + Result := Size + else + begin + if (ToDPI/FromDPI <= 1.5) and (Size = 1) then + Result := 1 //maintaining 1px on 150% scale for crispness + else + Result := MulDiv(Size, ToDPI, FromDPI); + end; + +end; + +function SpkScaleY(Size: Integer; FromDPI: Integer; ToDPI: Integer): integer; +begin + if ToDPI = 0 then + ToDPI := ScreenInfo.PixelsPerInchY; + + if not(DPI_AWARE) or (ToDPI = FromDPI) then + Result := Size + else + begin + if (ToDPI/FromDPI <= 1.5) and (Size = 1) then + Result := 1 //maintaining 1px on 150% scale for crispness + else + Result := MulDiv(Size, ToDPI, FromDPI); + end; + +end; + + initialization {$IFDEF DEBUG} diff --git a/components/spktoolbar/SpkToolbar/spkt_Pane.pas b/components/spktoolbar/SpkToolbar/spkt_Pane.pas index 57b5c4625..430a6d6cd 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Pane.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Pane.pas @@ -160,9 +160,9 @@ FRect:=ARect; Layout:=GenerateLayout; {$IFDEF EnhancedRecordSupport} -Pt:=T2DIntPoint.create(ARect.left + PANE_BORDER_SIZE + PANE_LEFT_PADDING, ARect.top + PANE_BORDER_SIZE); +Pt:=T2DIntPoint.create(ARect.left + SpkLayoutSizes.PANE_BORDER_SIZE + SpkLayoutSizes.PANE_LEFT_PADDING, ARect.top + SpkLayoutSizes.PANE_BORDER_SIZE); {$ELSE} -Pt.create(ARect.left + PANE_BORDER_SIZE + PANE_LEFT_PADDING, ARect.top + PANE_BORDER_SIZE); +Pt.create(ARect.left + PaneBorderSize + PaneLeftPadding, ARect.top + PaneBorderSize); {$ENDIF} if length(Layout.Rects)>0 then @@ -265,15 +265,15 @@ TGuiTools.DrawRoundRect(ABuffer.Canvas, {$IFDEF EnhancedRecordSupport} T2DIntRect.Create(FRect.left, FRect.top, - FRect.right - PANE_BORDER_HALF_SIZE, - FRect.Bottom - PANE_BORDER_HALF_SIZE), + FRect.right - PaneBorderHalfSize, + FRect.Bottom - PaneBorderHalfSize), {$ELSE} Create2DIntRect(FRect.left, FRect.top, - FRect.right - PANE_BORDER_HALF_SIZE, - FRect.Bottom - PANE_BORDER_HALF_SIZE), + FRect.right - PaneBorderHalfSize, + FRect.Bottom - PaneBorderHalfSize), {$ENDIF} - PANE_CORNER_RADIUS, + PaneCornerRadius, BgFromColor, BgToColor, FAppearance.Pane.GradientType, @@ -283,16 +283,16 @@ TGuiTools.DrawRoundRect(ABuffer.Canvas, TGuiTools.DrawRoundRect(ABuffer.Canvas, {$IFDEF EnhancedRecordSupport} T2DIntRect.Create(FRect.Left, - FRect.Bottom - PANE_CAPTION_HEIGHT - PANE_BORDER_HALF_SIZE, - FRect.right - PANE_BORDER_HALF_SIZE, - FRect.bottom - PANE_BORDER_HALF_SIZE), + FRect.Bottom - PaneCaptionHeight - PaneBorderHalfSize, + FRect.right - PaneBorderHalfSize, + FRect.bottom - PaneBorderHalfSize), {$ELSE} Create2DIntRect(FRect.Left, - FRect.Bottom - PANE_CAPTION_HEIGHT - PANE_BORDER_HALF_SIZE, - FRect.right - PANE_BORDER_HALF_SIZE, - FRect.bottom - PANE_BORDER_HALF_SIZE), + FRect.Bottom - PaneCaptionHeight - PaneBorderHalfSize, + FRect.Right - PaneBorderHalfSize, + FRect.Bottom - PaneBorderHalfSize), {$ENDIF} - PANE_CORNER_RADIUS, + PaneCornerRadius, CaptionColor, clNone, bkSolid, @@ -305,8 +305,8 @@ TGuiTools.DrawRoundRect(ABuffer.Canvas, // Etykieta tafli ABuffer.Canvas.Font.assign(FAppearance.Pane.CaptionFont); x:=FRect.left + (FRect.width - ABuffer.Canvas.TextWidth(FCaption)) div 2; -y:=FRect.Bottom - PANE_BORDER_SIZE - PANE_CAPTION_HEIGHT + 1 + - (PANE_CAPTION_HEIGHT - ABuffer.Canvas.TextHeight('Wy')) div 2; +y:=FRect.Bottom - PaneBorderSize - PaneCaptionHeight + 1 + + (PaneCaptionHeight - ABuffer.Canvas.TextHeight('Wy')) div 2; TGUITools.DrawText(ABuffer.Canvas, x, @@ -328,7 +328,7 @@ TGUITools.DrawAARoundFrame(ABuffer, FRect.Right, FRect.bottom), {$ENDIF} - PANE_CORNER_RADIUS, + PaneCornerRadius, BorderLightColor, ClipRect); TGUITools.DrawAARoundFrame(ABuffer, @@ -343,7 +343,7 @@ TGUITools.DrawAARoundFrame(ABuffer, FRect.Right-1, FRect.bottom-1), {$ENDIF} - PANE_CORNER_RADIUS, + PaneCornerRadius, BorderDarkColor, ClipRect); @@ -498,7 +498,7 @@ if length(Layout)>0 then begin if c>0 then begin - LastX:=MaxRowX + PANE_COLUMN_SPACER; + LastX:=MaxRowX + PaneColumnSpacer; MaxRowX:=LastX; end else @@ -523,8 +523,8 @@ if length(Layout)>0 then if ItemSize = isLarge then begin - tmpRect.top:=PANE_FULL_ROW_TOPPADDING; - tmpRect.bottom:=tmpRect.top + PANE_FULL_ROW_HEIGHT - 1; + tmpRect.top:=PaneFullRowTopPadding; + tmpRect.bottom:=tmpRect.top + PaneFullRowHeight - 1; tmpRect.left:=LastX; tmpRect.right:=LastX + ItemWidth - 1; @@ -544,7 +544,7 @@ if length(Layout)>0 then // Jeœli element nie jest pierwszy, musi zostaæ // odsuniêty marginesem od poprzedniego if i>0 then - tmpRect.Left:=LastX + PANE_GROUP_SPACER else + tmpRect.Left:=LastX + PaneGroupSpacer else tmpRect.Left:=LastX; tmpRect.right:=tmpRect.Left + ItemWidth - 1; end; @@ -552,34 +552,34 @@ if length(Layout)>0 then {$REGION 'Obliczanie tmpRect.top i bottom'} case rows of 1 : begin - tmpRect.top:=PANE_ONE_ROW_TOPPADDING; - tmpRect.bottom:=tmpRect.top + PANE_ROW_HEIGHT - 1; + tmpRect.top:=PaneOneRowTopPadding; + tmpRect.bottom:=tmpRect.top + PaneRowHeight - 1; end; 2 : begin case r of 0 : begin - tmpRect.top:=PANE_TWO_ROWS_TOPPADDING; - tmpRect.bottom:=tmpRect.top + PANE_ROW_HEIGHT - 1; + tmpRect.top:=PaneTwoRowsTopPadding; + tmpRect.bottom:=tmpRect.top + PaneRowHeight - 1; end; 1 : begin - tmpRect.top:=PANE_TWO_ROWS_TOPPADDING + PANE_ROW_HEIGHT + PANE_TWO_ROWS_VSPACER; - tmpRect.bottom:=tmpRect.top + PANE_ROW_HEIGHT - 1; + tmpRect.top:=PaneTwoRowsTopPadding + PaneRowHeight + PaneTwoRowsVSpacer; + tmpRect.bottom:=tmpRect.top + PaneRowHeight - 1; end; end; end; 3 : begin case r of 0 : begin - tmpRect.top:=PANE_THREE_ROWS_TOPPADDING; - tmpRect.bottom:=tmpRect.top + PANE_ROW_HEIGHT - 1; + tmpRect.top:=PaneThreeRowsTopPadding; + tmpRect.bottom:=tmpRect.top + PaneRowHeight - 1; end; 1 : begin - tmpRect.top:=PANE_THREE_ROWS_TOPPADDING + PANE_ROW_HEIGHT + PANE_THREE_ROWS_VSPACER; - tmpRect.bottom:=tmpRect.top + PANE_ROW_HEIGHT - 1; + tmpRect.top:=PaneThreeRowsTopPadding + PaneRowHeight + PaneThreeRowsVSpacer; + tmpRect.bottom:=tmpRect.top + PaneRowHeight - 1; end; 2 : begin - tmpRect.top:=PANE_THREE_ROWS_TOPPADDING + 2 * PANE_ROW_HEIGHT + 2 * PANE_THREE_ROWS_VSPACER; - tmpRect.bottom:=tmpRect.top + PANE_ROW_HEIGHT - 1; + tmpRect.top:=PaneThreeRowsTopPadding + 2 * PaneRowHeight + 2 * PaneThreeRowsVSpacer; + tmpRect.bottom:=tmpRect.top + PaneRowHeight - 1; end; end; end; @@ -634,14 +634,12 @@ tmpBitmap.Canvas.font.assign(FAppearance.Pane.CaptionFont); // *** Minimalna szerokoœæ tafli (tekstu) *** TextW:=tmpBitmap.Canvas.TextWidth(FCaption); -PaneCaptionWidth:=2*PANE_BORDER_SIZE + - 2*PANE_CAPTION_HMARGIN + - TextW; +PaneCaptionWidth := 2*PaneBorderSize + 2*PaneCaptionHMargin + TextW; // *** Szerokoœæ elementów tafli *** Layout:=GenerateLayout; ElementsW:=Layout.Width; -PaneElementsWidth:=PANE_BORDER_SIZE + PANE_LEFT_PADDING + ElementsW + PANE_RIGHT_PADDING + PANE_BORDER_SIZE; +PaneElementsWidth:=PaneBorderSize + PaneLeftPadding + ElementsW + PaneRightPadding + PaneBorderSize; // *** Ustawianie szerokoœci tafli *** result:=max(PaneCaptionWidth, PaneElementsWidth); diff --git a/components/spktoolbar/SpkToolbar/spkt_Tab.pas b/components/spktoolbar/SpkToolbar/spkt_Tab.pas index 1721775b8..b649f00a2 100644 --- a/components/spktoolbar/SpkToolbar/spkt_Tab.pas +++ b/components/spktoolbar/SpkToolbar/spkt_Tab.pas @@ -226,7 +226,7 @@ if AtLeastOnePaneVisible then FPanes[i].Rect:=tmpRect; - x:=x + tw + TAB_PANE_HSPACING; + x:=x + tw + TabPaneHSpacing; end else begin