spktoolbar: Fix LCLScaling (minor issue remaining when form is loaded from hi-dpi system into low-dpi system: modify form a bit, save and load again).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6196 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-02-12 09:29:36 +00:00
parent 38fc173d25
commit f17eb37074
8 changed files with 122 additions and 70 deletions

View File

@ -290,9 +290,6 @@ type
// *** Getters and setters *** // *** Getters and setters ***
// *************************** // ***************************
{Getter for property Height }
function GetHeight: integer;
{ Setter for property Appearance } { Setter for property Appearance }
procedure SetAppearance(const Value: TSpkToolbarAppearance); procedure SetAppearance(const Value: TSpkToolbarAppearance);
@ -418,9 +415,6 @@ type
{ Object containing attributes of toolbar appearance } { Object containing attributes of toolbar appearance }
property Appearance: TSpkToolbarAppearance read FAppearance write SetAppearance; property Appearance: TSpkToolbarAppearance read FAppearance write SetAppearance;
{ Height of toolbar (read-only) }
property Height: integer read GetHeight;
{ Index of active tab } { Index of active tab }
property TabIndex: integer read FTabIndex write SetTabIndex; property TabIndex: integer read FTabIndex write SetTabIndex;
@ -572,7 +566,7 @@ begin
if (AOwner is TForm) then if (AOwner is TForm) then
SpkInitLayoutConsts(96); // This default dpi value is ignored for LCL scaling SpkInitLayoutConsts(96); // This default dpi value is ignored for LCL scaling
inherited Height := ToolbarHeight; Height := ToolbarHeight;
//inherited Doublebuffered:=true; //inherited Doublebuffered:=true;
@ -688,11 +682,6 @@ begin
Result := inherited Color; Result := inherited Color;
end; end;
function TSpkToolbar.GetHeight: integer;
begin
Result := inherited Height;
end;
function TSpkToolbar.GetTempBitmap: TBitmap; function TSpkToolbar.GetTempBitmap: TBitmap;
begin begin
Result := FTemporary; Result := FTemporary;
@ -1081,7 +1070,8 @@ end;
procedure TSpkToolbar.DoOnResize; procedure TSpkToolbar.DoOnResize;
begin begin
inherited Height := ToolbarHeight; if Height <> ToolbarHeight then
Height := ToolbarHeight;
{$IFDEF DELAYRUNTIMER} {$IFDEF DELAYRUNTIMER}
FDelayRunTimer.Enabled := False; FDelayRunTimer.Enabled := False;

View File

@ -18,11 +18,7 @@ uses
Graphics, LCLVersion; Graphics, LCLVersion;
const const
{$IF lcl_fullversion < 1080000}
SPK_DPI_AWARE = true; SPK_DPI_AWARE = true;
{$ELSE}
SPK_DPI_AWARE = false; // use lcl scaling instead
{$ENDIF}
procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0); procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0);
function SpkScaleX(Size: Integer; FromDPI: Integer; ToDPI: Integer = 0): integer; function SpkScaleX(Size: Integer; FromDPI: Integer; ToDPI: Integer = 0): integer;

View File

@ -1,23 +1,25 @@
object Form1: TForm1 object Form1: TForm1
Left = 301 Left = 368
Height = 378 Height = 304
Top = 242 Top = 248
Width = 585 Width = 501
Caption = 'Form1' Caption = 'Form1'
ClientHeight = 358 ClientHeight = 284
ClientWidth = 585 ClientWidth = 501
Menu = MainMenu Menu = MainMenu
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '1.9.0.0' LCLVersion = '1.9.0.0'
object ToolBar1: TToolBar object ToolBar1: TToolBar
Left = 0 Left = 0
Height = 26 Height = 24
Top = 0 Top = 0
Width = 585 Width = 501
AutoSize = True
Caption = 'ToolBar1' Caption = 'ToolBar1'
EdgeBorders = [ebBottom] EdgeBorders = [ebBottom]
Images = ImageList Images = ImageList
ParentFont = False
TabOrder = 0 TabOrder = 0
object ToolButton1: TToolButton object ToolButton1: TToolButton
Left = 1 Left = 1
@ -30,71 +32,71 @@ object Form1: TForm1
Action = AcSave Action = AcSave
end end
object ToolButton3: TToolButton object ToolButton3: TToolButton
Left = 47 Left = 70
Height = 22 Height = 22
Top = 0 Top = 0
Caption = 'ToolButton3' Caption = 'ToolButton3'
Style = tbsDivider Style = tbsDivider
end end
object ToolButton4: TToolButton object ToolButton4: TToolButton
Left = 52 Left = 47
Top = 0 Top = 0
Action = AcEditCut Action = AcEditCut
end end
object ToolButton5: TToolButton object ToolButton5: TToolButton
Left = 75 Left = 73
Top = 0 Top = 0
Action = AcEditCopy Action = AcEditCopy
end end
object ToolButton6: TToolButton object ToolButton6: TToolButton
Left = 98 Left = 96
Top = 0 Top = 0
Action = AcEditPaste Action = AcEditPaste
end end
object ToolButton7: TToolButton object ToolButton7: TToolButton
Left = 121 Left = 188
Height = 22 Height = 22
Top = 0 Top = 0
Caption = 'ToolButton7' Caption = 'ToolButton7'
Style = tbsDivider Style = tbsDivider
end end
object ToolButton8: TToolButton object ToolButton8: TToolButton
Left = 269 Left = 260
Top = 0 Top = 0
Action = AcQuit Action = AcQuit
end end
object ToolButton9: TToolButton object ToolButton9: TToolButton
Left = 126 Left = 119
Top = 0 Top = 0
Action = AcBold Action = AcBold
end end
object ToolButton10: TToolButton object ToolButton10: TToolButton
Left = 149 Left = 142
Top = 0 Top = 0
Action = AcItalic Action = AcItalic
end end
object ToolButton11: TToolButton object ToolButton11: TToolButton
Left = 195 Left = 191
Top = 0 Top = 0
Action = AcLeftJustify Action = AcLeftJustify
end end
object ToolButton12: TToolButton object ToolButton12: TToolButton
Left = 172 Left = 165
Top = 0 Top = 0
Action = AcUnderline Action = AcUnderline
end end
object ToolButton13: TToolButton object ToolButton13: TToolButton
Left = 218 Left = 214
Top = 0 Top = 0
Action = AcCenter Action = AcCenter
end end
object ToolButton14: TToolButton object ToolButton14: TToolButton
Left = 241 Left = 237
Top = 0 Top = 0
Action = AcRightJustify Action = AcRightJustify
end end
object ToolButton15: TToolButton object ToolButton15: TToolButton
Left = 264 Left = 283
Height = 22 Height = 22
Top = 0 Top = 0
Caption = 'ToolButton15' Caption = 'ToolButton15'
@ -103,27 +105,30 @@ object Form1: TForm1
end end
object Panel1: TPanel object Panel1: TPanel
Left = 0 Left = 0
Height = 220 Height = 185
Top = 138 Top = 99
Width = 585 Width = 501
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 220 ClientHeight = 185
ClientWidth = 585 ClientWidth = 501
ParentFont = False
TabOrder = 1 TabOrder = 1
object Label1: TLabel object Label1: TLabel
Left = 16 Left = 24
Height = 15 Height = 15
Top = 8 Top = 12
Width = 34 Width = 34
Caption = 'Label1' Caption = 'Label1'
ParentColor = False ParentColor = False
ParentFont = False
end end
end end
object SpkToolbar1: TSpkToolbar object SpkToolbar1: TSpkToolbar
Left = 0 Left = 0
Top = 26 Height = 75
Width = 585 Top = 24
Width = 501
Appearance.Tab.TabHeaderFont.Color = 9126421 Appearance.Tab.TabHeaderFont.Color = 9126421
Appearance.Tab.BorderColor = 14922381 Appearance.Tab.BorderColor = 14922381
Appearance.Tab.GradientFromColor = 16115934 Appearance.Tab.GradientFromColor = 16115934

View File

@ -10,9 +10,10 @@ object Form2: TForm2
Font.Color = clWindowText Font.Color = clWindowText
Font.Height = -11 Font.Height = -11
Font.Name = 'Tahoma' Font.Name = 'Tahoma'
LCLVersion = '1.9.0.0' LCLVersion = '1.6.4.0'
object SpkToolbar1: TSpkToolbar object SpkToolbar1: TSpkToolbar
Left = 0 Left = 0
Height = 112
Top = 0 Top = 0
Width = 777 Width = 777
Color = clBtnFace Color = clBtnFace

View File

@ -1,26 +1,27 @@
object Form1: TForm1 object Form1: TForm1
Left = 280 Left = 280
Height = 667 Height = 614
Top = 130 Top = 130
Width = 636 Width = 636
Caption = 'spkToolbar Styles' Caption = 'spkToolbar Styles'
ClientHeight = 667 ClientHeight = 614
ClientWidth = 636 ClientWidth = 636
Color = clMedGray Color = clMedGray
LCLVersion = '1.9.0.0' LCLVersion = '1.6.4.0'
object ScrollBox1: TScrollBox object ScrollBox1: TScrollBox
Left = 0 Left = 0
Height = 667 Height = 614
Top = 0 Top = 0
Width = 636 Width = 636
HorzScrollBar.Page = 75 HorzScrollBar.Page = 75
VertScrollBar.Page = 660 VertScrollBar.Page = 608
Align = alClient Align = alClient
ClientHeight = 663 ClientHeight = 610
ClientWidth = 632 ClientWidth = 632
TabOrder = 0 TabOrder = 0
object SpkToolbar1: TSpkToolbar object SpkToolbar1: TSpkToolbar
Left = 0 Left = 0
Height = 112
Top = 0 Top = 0
Width = 632 Width = 632
Color = clMedGray Color = clMedGray
@ -268,7 +269,8 @@ object Form1: TForm1
end end
object SpkToolbar2: TSpkToolbar object SpkToolbar2: TSpkToolbar
Left = 0 Left = 0
Top = 137 Height = 112
Top = 124
Width = 632 Width = 632
Color = clMedGray Color = clMedGray
Style = spkOffice2007Silver Style = spkOffice2007Silver
@ -515,7 +517,8 @@ object Form1: TForm1
end end
object SpkToolbar3: TSpkToolbar object SpkToolbar3: TSpkToolbar
Left = 0 Left = 0
Top = 274 Height = 112
Top = 248
Width = 632 Width = 632
Color = clMedGray Color = clMedGray
Style = spkOffice2007SilverTurquoise Style = spkOffice2007SilverTurquoise
@ -762,7 +765,7 @@ object Form1: TForm1
end end
object Panel1: TPanel object Panel1: TPanel
Left = 0 Left = 0
Height = 25 Height = 12
Top = 112 Top = 112
Width = 632 Width = 632
Align = alTop Align = alTop
@ -771,8 +774,8 @@ object Form1: TForm1
end end
object Panel4: TPanel object Panel4: TPanel
Left = 0 Left = 0
Height = 25 Height = 12
Top = 523 Top = 484
Width = 632 Width = 632
Align = alTop Align = alTop
BevelOuter = bvNone BevelOuter = bvNone
@ -780,8 +783,8 @@ object Form1: TForm1
end end
object Panel3: TPanel object Panel3: TPanel
Left = 0 Left = 0
Height = 25 Height = 12
Top = 386 Top = 360
Width = 632 Width = 632
Align = alTop Align = alTop
BevelOuter = bvNone BevelOuter = bvNone
@ -789,7 +792,8 @@ object Form1: TForm1
end end
object SpkToolbar4: TSpkToolbar object SpkToolbar4: TSpkToolbar
Left = 0 Left = 0
Top = 411 Height = 112
Top = 372
Width = 632 Width = 632
Color = clMedGray Color = clMedGray
Style = spkMetroLight Style = spkMetroLight
@ -1038,8 +1042,8 @@ object Form1: TForm1
end end
object Panel2: TPanel object Panel2: TPanel
Left = 0 Left = 0
Height = 25 Height = 12
Top = 249 Top = 236
Width = 632 Width = 632
Align = alTop Align = alTop
BevelOuter = bvNone BevelOuter = bvNone
@ -1049,7 +1053,8 @@ object Form1: TForm1
end end
object SpkToolbar5: TSpkToolbar object SpkToolbar5: TSpkToolbar
Left = 0 Left = 0
Top = 548 Height = 112
Top = 496
Width = 632 Width = 632
Color = clMedGray Color = clMedGray
Style = spkMetroDark Style = spkMetroDark

View File

@ -13,7 +13,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow OnShow = FormShow
ShowHint = True ShowHint = True
LCLVersion = '1.9.0.0' LCLVersion = '1.6.4.0'
object gbPreview: TGroupBox object gbPreview: TGroupBox
Left = 0 Left = 0
Height = 132 Height = 132
@ -125,6 +125,8 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
CustomAppearance.Element.ActiveCaptionColor = 8405614 CustomAppearance.Element.ActiveCaptionColor = 8405614
CustomAppearance.Element.Style = esRounded CustomAppearance.Element.Style = esRounded
Caption = 'Sample toolbar' Caption = 'Sample toolbar'
OverrideAppearance = False
Visible = True
Panes = ( Panes = (
'SpkPane1' 'SpkPane1'
'SpkPane2' 'SpkPane2'
@ -132,21 +134,29 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
) )
object SpkPane1: TSpkPane object SpkPane1: TSpkPane
Caption = 'Sample large buttons' Caption = 'Sample large buttons'
Visible = True
Items = ( Items = (
'SpkLargeButton1' 'SpkLargeButton1'
'SpkLargeButton3' 'SpkLargeButton3'
'SpkLargeButton2' 'SpkLargeButton2'
) )
object SpkLargeButton1: TSpkLargeButton object SpkLargeButton1: TSpkLargeButton
Visible = True
Enabled = True
Caption = 'Default' Caption = 'Default'
LargeImageIndex = 0 LargeImageIndex = 0
ButtonKind = bkButton
end end
object SpkLargeButton3: TSpkLargeButton object SpkLargeButton3: TSpkLargeButton
Visible = True
Enabled = True
Caption = 'Button and dropdown' Caption = 'Button and dropdown'
LargeImageIndex = 0 LargeImageIndex = 0
ButtonKind = bkButtonDropdown ButtonKind = bkButtonDropdown
end end
object SpkLargeButton2: TSpkLargeButton object SpkLargeButton2: TSpkLargeButton
Visible = True
Enabled = True
Caption = 'Dropdown' Caption = 'Dropdown'
LargeImageIndex = 0 LargeImageIndex = 0
ButtonKind = bkDropdown ButtonKind = bkDropdown
@ -154,34 +164,49 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
end end
object SpkPane2: TSpkPane object SpkPane2: TSpkPane
Caption = 'Sample small buttons' Caption = 'Sample small buttons'
Visible = True
Items = ( Items = (
'SpkSmallButton1' 'SpkSmallButton1'
'SpkSmallButton2' 'SpkSmallButton2'
'SpkSmallButton3' 'SpkSmallButton3'
) )
object SpkSmallButton1: TSpkSmallButton object SpkSmallButton1: TSpkSmallButton
Visible = True
Enabled = True
Caption = 'Default' Caption = 'Default'
GroupBehaviour = gbSingleItem
HideFrameWhenIdle = True HideFrameWhenIdle = True
ImageIndex = 0 ImageIndex = 0
ShowCaption = True
TableBehaviour = tbBeginsRow TableBehaviour = tbBeginsRow
ButtonKind = bkButton
end end
object SpkSmallButton2: TSpkSmallButton object SpkSmallButton2: TSpkSmallButton
Visible = True
Enabled = True
Caption = 'Button and dropdown' Caption = 'Button and dropdown'
GroupBehaviour = gbSingleItem
HideFrameWhenIdle = True HideFrameWhenIdle = True
ImageIndex = 0 ImageIndex = 0
ShowCaption = True
TableBehaviour = tbBeginsRow TableBehaviour = tbBeginsRow
ButtonKind = bkButtonDropdown ButtonKind = bkButtonDropdown
end end
object SpkSmallButton3: TSpkSmallButton object SpkSmallButton3: TSpkSmallButton
Visible = True
Enabled = True
Caption = 'Dropdown' Caption = 'Dropdown'
GroupBehaviour = gbSingleItem
HideFrameWhenIdle = True HideFrameWhenIdle = True
ImageIndex = 0 ImageIndex = 0
ShowCaption = True
TableBehaviour = tbBeginsRow TableBehaviour = tbBeginsRow
ButtonKind = bkDropdown ButtonKind = bkDropdown
end end
end end
object SpkPane3: TSpkPane object SpkPane3: TSpkPane
Caption = 'Tool buttons' Caption = 'Tool buttons'
Visible = True
Items = ( Items = (
'SpkSmallButton4' 'SpkSmallButton4'
'SpkSmallButton5' 'SpkSmallButton5'
@ -190,31 +215,59 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
'SpkSmallButton8' 'SpkSmallButton8'
) )
object SpkSmallButton4: TSpkSmallButton object SpkSmallButton4: TSpkSmallButton
Visible = True
Enabled = True
Caption = 'Button' Caption = 'Button'
GroupBehaviour = gbBeginsGroup GroupBehaviour = gbBeginsGroup
HideFrameWhenIdle = False
ImageIndex = 0 ImageIndex = 0
ShowCaption = False ShowCaption = False
TableBehaviour = tbContinuesRow
ButtonKind = bkButton
end end
object SpkSmallButton5: TSpkSmallButton object SpkSmallButton5: TSpkSmallButton
Visible = True
Enabled = True
Caption = 'Button' Caption = 'Button'
GroupBehaviour = gbContinuesGroup GroupBehaviour = gbContinuesGroup
HideFrameWhenIdle = False
ImageIndex = 0 ImageIndex = 0
ShowCaption = False ShowCaption = False
TableBehaviour = tbContinuesRow
ButtonKind = bkButton
end end
object SpkSmallButton6: TSpkSmallButton object SpkSmallButton6: TSpkSmallButton
Visible = True
Enabled = True
Caption = 'Button' Caption = 'Button'
GroupBehaviour = gbEndsGroup GroupBehaviour = gbEndsGroup
HideFrameWhenIdle = False
ImageIndex = 0 ImageIndex = 0
ShowCaption = False ShowCaption = False
TableBehaviour = tbContinuesRow
ButtonKind = bkButton
end end
object SpkSmallButton7: TSpkSmallButton object SpkSmallButton7: TSpkSmallButton
Visible = True
Enabled = True
Caption = 'Btn1' Caption = 'Btn1'
GroupBehaviour = gbSingleItem
HideFrameWhenIdle = False
ImageIndex = 0 ImageIndex = 0
ShowCaption = True
TableBehaviour = tbBeginsRow TableBehaviour = tbBeginsRow
ButtonKind = bkButton
end end
object SpkSmallButton8: TSpkSmallButton object SpkSmallButton8: TSpkSmallButton
Visible = True
Enabled = True
Caption = 'Btn2' Caption = 'Btn2'
GroupBehaviour = gbSingleItem
HideFrameWhenIdle = False
ImageIndex = 0 ImageIndex = 0
ShowCaption = True
TableBehaviour = tbContinuesRow
ButtonKind = bkButton
end end
end end
end end
@ -263,6 +316,8 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
CustomAppearance.Element.ActiveCaptionColor = 8405614 CustomAppearance.Element.ActiveCaptionColor = 8405614
CustomAppearance.Element.Style = esRounded CustomAppearance.Element.Style = esRounded
Caption = 'Another tab' Caption = 'Another tab'
OverrideAppearance = False
Visible = True
Panes = ( ) Panes = ( )
end end
end end
@ -272,13 +327,13 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Height = 382 Height = 382
Top = 132 Top = 132
Width = 552 Width = 552
ActivePage = TabSheet2 ActivePage = TabSheet1
Align = alClient Align = alClient
TabIndex = 1 TabIndex = 0
TabOrder = 1 TabOrder = 1
object TabSheet1: TTabSheet object TabSheet1: TTabSheet
Caption = 'Tab' Caption = 'Tab'
ClientHeight = 360 ClientHeight = 354
ClientWidth = 544 ClientWidth = 544
object sTabRectangle: TShape object sTabRectangle: TShape
AnchorSideLeft.Control = LblInactiveTabHeaderFontColor AnchorSideLeft.Control = LblInactiveTabHeaderFontColor

View File

@ -321,7 +321,7 @@ implementation
{$R *.lfm} {$R *.lfm}
uses uses
Types, clipbrd; Types, clipbrd, spkt_Const;
var var
CurrPageIndex: Integer = 0; CurrPageIndex: Integer = 0;