From cc2abec65b0143280af704f2e97381f75b4d2e2b Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 16 Jun 2017 18:01:08 +0000 Subject: [PATCH] colorpalette: Activate LCL scaling of Laz 1.8. Replace .lrs resource by .res. Add highDPI component palette icons (see image_sources). Set version no 0.2.3. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5940 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/colorpalette/colorpalette.lrs | 14 -------- components/colorpalette/colorpalette.pas | 30 +++++++++++++++--- components/colorpalette/colorpalette.res | Bin 0 -> 1251 bytes .../demo/GeneralDemo/project1.lpi | 4 +++ .../demo/GeneralDemo/project1.lpr | 1 + .../colorpalette/demo/GeneralDemo/unit1.lfm | 11 ++++--- .../demo/ToolbarDemo/project1.lpi | 4 +++ .../demo/ToolbarDemo/project1.lpr | 1 + .../colorpalette/demo/ToolbarDemo/unit1.lfm | 9 +++--- components/colorpalette/lazcolorpalette.lpk | 13 +++++--- components/colorpalette/lazcolorpalette.pas | 1 - components/colorpalette/tcolorpalette.png | Bin 199 -> 0 bytes 12 files changed, 54 insertions(+), 34 deletions(-) delete mode 100644 components/colorpalette/colorpalette.lrs create mode 100644 components/colorpalette/colorpalette.res delete mode 100644 components/colorpalette/tcolorpalette.png diff --git a/components/colorpalette/colorpalette.lrs b/components/colorpalette/colorpalette.lrs deleted file mode 100644 index b7bf25dd3..000000000 --- a/components/colorpalette/colorpalette.lrs +++ /dev/null @@ -1,14 +0,0 @@ -LazarusResources.Add('tcolorpalette','XPM',[ - '/* XPM */'#10'static char *graphic[] = {'#10'"20 21 13 1",'#10'". c #848484"' - +','#10'", c None",'#10'"- c #FFFFFF",'#10'"* c #C6C6C6",'#10'"a c #000000",' - +#10'"b c #840000",'#10'"c c #848400",'#10'"d c #808000",'#10'"e c #FF0000",' - +#10'"f c #FFFF00",'#10'"g c #008400",'#10'"h c #008484",'#10'"i c #000084",' - +#10'"...................,",'#10'".-----------------*-",'#10'".-aaaaaaaaaaaaa' - +'aaa.-",'#10'".-aaaaaabbbbacccca.-",'#10'".-aaaaaabbbbacccca.-",'#10'".-aaaa' - +'aabbbbacccca.-",'#10'".-aaaaaabbbbaddcca.-",'#10'".-aaaaaaaaaaaaaaaa.-",'#10 - +'".-a----aeeeeaffffa.-",'#10'".-a----aeeeeaffffa.-",'#10'".-a----aeeeeaffffa' - +'.-",'#10'".-a----aeeeeaffffa.-",'#10'".-aaaaaaaaaaaaaaaa.-",'#10'".-aggggah' - +'hhhaiiiia.-",'#10'".-aggggahhhhaiiiia.-",'#10'".-aggggahhhhaiiiia.-",'#10'"' - +'.-aggggahhhhaiiiia.-",'#10'".-aaaaaaaaaaaaaaaa.-",'#10'".*.................' - +'-",'#10'",-------------------",'#10'",,,,,,,,,,,,,,,,,,,,"}'#10 -]); diff --git a/components/colorpalette/colorpalette.pas b/components/colorpalette/colorpalette.pas index 69f2198f6..ff017136a 100644 --- a/components/colorpalette/colorpalette.pas +++ b/components/colorpalette/colorpalette.pas @@ -48,7 +48,7 @@ unit ColorPalette; interface uses - Classes, SysUtils, LResources, Controls, Forms, Graphics, Math, + Classes, SysUtils, LResources, LCLVersion, Controls, Forms, Graphics, Math, LCLType; type @@ -138,6 +138,10 @@ type procedure ColorPick(AIndex: Integer; Shift: TShiftState); virtual; procedure ColorMouseMove(AColor: TColor; Shift: TShiftState); virtual; procedure DoAddColor(AColor: TColor; AColorName: String = ''); virtual; + {$IF LCL_FULLVERSION >= 1080000} + procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy; + const AXProportion, AYProportion: Double); override; + {$ENDIF} procedure DoColorPick(AColor: TColor; AShift: TShiftState); virtual; procedure DoDeleteColor(AIndex: Integer); virtual; procedure DoInsertColor(AIndex: Integer; AColor: TColor; AColorName: String = ''); virtual; @@ -251,8 +255,10 @@ type implementation +{$R colorpalette.res} + uses - LCLIntf, StrUtils; + LCLIntf; const SELKIND_NAMES: Array[TPaletteSelectionKind] of String = ( @@ -363,6 +369,23 @@ begin FColors.AddObject(AColorName, TObject(PtrInt(AColor))); end; +{$IF LCL_FULLVERSION >= 1080000} +procedure TCustomColorPalette.DoAutoAdjustLayout( + const AMode: TLayoutAdjustmentPolicy; const AXProportion, AYProportion: Double); +begin + inherited DoAutoAdjustLayout(AMode, AXProportion, AYProportion); + + if AMode = lapAutoAdjustForDPI then + begin + FButtonWidth := Round(FButtonWidth * AXProportion); + FButtonHeight := Round(FButtonHeight * AYProportion); + FButtonDistance := Round(FButtonDistance * AXProportion); + UpdateSize; + Invalidate; + end; +end; +{$ENDIF} + procedure TCustomColorPalette.DoColorPick(AColor: TColor; AShift: TShiftState); begin if Assigned(FOnColorPick) then @@ -1318,8 +1341,5 @@ begin end; -initialization -{$I colorpalette.lrs} - end. diff --git a/components/colorpalette/colorpalette.res b/components/colorpalette/colorpalette.res new file mode 100644 index 0000000000000000000000000000000000000000..d3b7f1db36db64a2def6cef30903194d31935be1 GIT binary patch literal 1251 zcmZQzU|>)H;{X347|28cHyIfiEPx{a|8p^fFgP>#Gxz{;5JLciBar0^6bk{85Fj9c z(ApW`=g!L|#RU}M_4IHF0@4y7%)tgEAC%kv08(s8-tI08?hGCb?yU>WbAck91s;*b zK)MWs8U3o&IDicH5>H=O_J?c&g1Si-7OrlIta6lQT^8(p(I>_r!*lhwfb!&ia3c z*%i+CJt=a?Ctzx_RDvEpBt&b-FT+Dqwx5)pq+|t%_qdxetqgnP&59w9YzjIq#IFWLNi{jE1cjUOKD|vp6#?LeYS2PkYwZf*E?{POqxl>in>#i_bnAS#hm#y`+&SZYz`oVBf@4-s`1`oHz6B)V$ zymBrU?M``neaWOvUg4GD*FL?IS;-+E&${JWj@djD(K+1L1%Jw4Kd!!>d!G4^pIITm zNMP`E^>bP0l+XlZas$(Z1CYj_CgK?k8B7@rfa*YiK-y3NDp3KajfV^~W&k-PrwtwB z&@*?+vgv;Ec4rGonN<3X}BnI zeKcfh_`Yj$#{ucZ#-DrIr8+*efrS4)F?^Q1&TP%qt|hNSo@GRf99?2`I_MKvuJ)aw zkxz!-vqf^&_wGCc1|CvqDiax&M!=9HGAu#L48UO-&h)b#$RRl_bvgbv+*ShW+yDy8 zjC*gdZRBk>5NUZ>Ef}5B6kx#2y}{{L%ORn~3OgC1!V(zM7AOd(@GbWiUh=}zq~pI= z_vW7}(N#i<&--%MELHwnyzQ%N&&93D9FDc~c3Yh<4ZVIhX6~-KziVRq>RN%efB{c& zHGi?@PoA`8A)))unVhWbIa9$5lWg0$|8R_<$U52S#}{Sa-evWESzu(}x^p)7D-lX8 Volcm`hf2r=d)-;h3epHmu>d7~mlyy5 literal 0 HcmV?d00001 diff --git a/components/colorpalette/demo/GeneralDemo/project1.lpi b/components/colorpalette/demo/GeneralDemo/project1.lpi index 381cdf14d..15d92cbb2 100644 --- a/components/colorpalette/demo/GeneralDemo/project1.lpi +++ b/components/colorpalette/demo/GeneralDemo/project1.lpi @@ -7,8 +7,12 @@ + <Scaled Value="True"/> <ResourceType Value="res"/> <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> <Icon Value="0"/> </General> <i18n> diff --git a/components/colorpalette/demo/GeneralDemo/project1.lpr b/components/colorpalette/demo/GeneralDemo/project1.lpr index 763ef168f..64e77a7c8 100644 --- a/components/colorpalette/demo/GeneralDemo/project1.lpr +++ b/components/colorpalette/demo/GeneralDemo/project1.lpr @@ -13,6 +13,7 @@ uses {$R *.res} begin + Application.Scaled := True; RequireDerivedFormResource:=True; Application.Initialize; Application.CreateForm(TMainForm, MainForm); diff --git a/components/colorpalette/demo/GeneralDemo/unit1.lfm b/components/colorpalette/demo/GeneralDemo/unit1.lfm index 99ceb11c8..e8f7b81af 100644 --- a/components/colorpalette/demo/GeneralDemo/unit1.lfm +++ b/components/colorpalette/demo/GeneralDemo/unit1.lfm @@ -7,8 +7,9 @@ object MainForm: TMainForm ClientHeight = 586 ClientWidth = 625 OnCreate = FormCreate + Position = poScreenCenter ShowHint = True - LCLVersion = '1.5' + LCLVersion = '1.9.0.0' object LeftPanel: TPanel Left = 0 Height = 586 @@ -439,11 +440,11 @@ object MainForm: TMainForm Top = 8 Width = 287 HorzScrollBar.Increment = 15 - HorzScrollBar.Page = 155 + HorzScrollBar.Page = 154 HorzScrollBar.Smooth = True HorzScrollBar.Tracking = True VertScrollBar.Increment = 4 - VertScrollBar.Page = 42 + VertScrollBar.Page = 41 VertScrollBar.Smooth = True VertScrollBar.Tracking = True Anchors = [akTop, akLeft, akRight, akBottom] @@ -453,10 +454,10 @@ object MainForm: TMainForm TabOrder = 2 object ColorPalette: TColorPalette Left = 0 - Height = 41 + Height = 40 Hint = 'Click to select a color' Top = 1 - Width = 155 + Width = 154 ButtonHeight = 20 ButtonWidth = 20 ColumnCount = 8 diff --git a/components/colorpalette/demo/ToolbarDemo/project1.lpi b/components/colorpalette/demo/ToolbarDemo/project1.lpi index 62d4d921d..8624c9238 100644 --- a/components/colorpalette/demo/ToolbarDemo/project1.lpi +++ b/components/colorpalette/demo/ToolbarDemo/project1.lpi @@ -7,8 +7,12 @@ <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> <Title Value="project1"/> + <Scaled Value="True"/> <ResourceType Value="res"/> <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> <Icon Value="0"/> </General> <i18n> diff --git a/components/colorpalette/demo/ToolbarDemo/project1.lpr b/components/colorpalette/demo/ToolbarDemo/project1.lpr index 6b4af373b..d7241c65b 100644 --- a/components/colorpalette/demo/ToolbarDemo/project1.lpr +++ b/components/colorpalette/demo/ToolbarDemo/project1.lpr @@ -13,6 +13,7 @@ uses {$R *.res} begin + Application.Scaled := True; RequireDerivedFormResource:=True; Application.Initialize; Application.CreateForm(TMainForm, MainForm); diff --git a/components/colorpalette/demo/ToolbarDemo/unit1.lfm b/components/colorpalette/demo/ToolbarDemo/unit1.lfm index 59f5a949e..b2ce0caaa 100644 --- a/components/colorpalette/demo/ToolbarDemo/unit1.lfm +++ b/components/colorpalette/demo/ToolbarDemo/unit1.lfm @@ -8,7 +8,7 @@ object MainForm: TMainForm ClientWidth = 633 OnCreate = FormCreate ShowHint = True - LCLVersion = '1.5' + LCLVersion = '1.9.0.0' object MainPanel: TPanel Left = 0 Height = 432 @@ -110,10 +110,11 @@ object MainForm: TMainForm AnchorSideLeft.Control = CoolBar AnchorSideTop.Control = CoolBar Left = 13 - Height = 49 + Height = 45 Top = 5 - Width = 50 + Width = 46 Align = alNone + AutoSize = True BorderSpacing.Left = 11 BorderSpacing.Top = 3 ButtonHeight = 45 @@ -141,7 +142,7 @@ object MainForm: TMainForm AnchorSideLeft.Control = CoolBar AnchorSideTop.Control = CoolBar Left = 78 - Height = 45 + Height = 44 Top = 7 Width = 385 ButtonHeight = 15 diff --git a/components/colorpalette/lazcolorpalette.lpk b/components/colorpalette/lazcolorpalette.lpk index 1ba1cba12..c6a907c6c 100644 --- a/components/colorpalette/lazcolorpalette.lpk +++ b/components/colorpalette/lazcolorpalette.lpk @@ -20,16 +20,16 @@ </CompilerOptions> <Description Value="This package contains a color palette component."/> <License Value="Modified LGPL"/> - <Version Minor="2" Release="2"/> + <Version Minor="2" Release="3"/> <Files Count="2"> <Item1> - <Filename Value="colorpalette.lrs"/> - <Type Value="LRS"/> - </Item1> - <Item2> <Filename Value="colorpalette.pas"/> <HasRegisterProc Value="True"/> <UnitName Value="ColorPalette"/> + </Item1> + <Item2> + <Filename Value="colorpalette.res"/> + <Type Value="Binary"/> </Item2> </Files> <RequiredPkgs Count="2"> @@ -48,5 +48,8 @@ <Version Value="2"/> <IgnoreBinaries Value="False"/> </PublishOptions> + <CustomOptions Items="ExternHelp" Version="2"> + <_ExternHelp Items="Count"/> + </CustomOptions> </Package> </CONFIG> diff --git a/components/colorpalette/lazcolorpalette.pas b/components/colorpalette/lazcolorpalette.pas index 501a70953..bebe4b715 100644 --- a/components/colorpalette/lazcolorpalette.pas +++ b/components/colorpalette/lazcolorpalette.pas @@ -4,7 +4,6 @@ unit LazColorPalette; -{$warn 5023 off : no warning about unused units} interface uses diff --git a/components/colorpalette/tcolorpalette.png b/components/colorpalette/tcolorpalette.png deleted file mode 100644 index 12c78709ed31e12be21c8f7771f26785126a32de..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^B0wz4!3HGVuAW-~q&N#aB8!1^83;4_RjYA;1WQ~a zN}Tg^b5rw57#KRWdO;deJY5_^D(1YM;>dMCfrsUD3IFeHHLG(cDWzy~_*SjrZWbyL zSj5$^n0w=mCCaN_Jr;?3Cv<tUP*ca*nerURIpR3IeIHizc9hQ4{qt#Q!v`rNJ%){~ pZ+$nO-}w0WKK^e7jNB97&FOH-;CkEqViwRo22WQ%mvv4FO#rxrM5+J)