[Lazarus] Alternative component palette layout

Sandro Cumerlato sandro.cumerlato at gmail.com
Wed Dec 31 18:46:24 CET 2014


Hello Juha,
I've implemented (auto) resize of Components list columns.

Please review attached patch and apply if OK.

Sandro


On 28 December 2014 at 21:11, Juha Manninen <juha.manninen62 at gmail.com>
wrote:

> On Sun, Dec 28, 2014 at 1:08 PM, zeljko <zeljko at holobit.net> wrote:
> > I'm against such workarounds since it can hide bug. Is it enough to
> comment
> > code LCLQt to completely disable LCLQt ifdef ?
> > I'll try to debug and see what exactly happens, since it's impossible to
> > reproduce it with simple example project.
>
> I already thought I spotted the error and I almost opened a bug
> report. Unneeded pages are deleted like :
>   Application.ReleaseComponent(Sheet);
> I could reproduce the error in a small test project and then fix it using :
>   TabControl := TCustomTabControl(PageControl1);
>   TabControl.Pages.Delete(0);
> But ... I tried to use it in the component palette code and it didn't
> work. I am puzzled and will not touch this issue for a while.
>
> TPageControl API sucks badly.
> TPageControl inherits from TCustomTabControl. They both have "Pages"
> but with different meaning. There is Pages[] and Page[].
> I think it should be fixed even if it breaks Delphi compatibility.
>
> Anyway, the palette reordering works pretty much perfectly now!
> Giuliano made a workaround for the QT issue and I fixed a last
> remaining bug related to saving the configuration.
> Please everybody test and create alternative palette layouts.
>
> Juha
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20141231/a022a26e/attachment-0003.html>
-------------- next part --------------
Index: ide/frames/componentpalette_options.lfm
===================================================================
--- ide/frames/componentpalette_options.lfm	(revisione 47273)
+++ ide/frames/componentpalette_options.lfm	(copia locale)
@@ -216,17 +216,17 @@
         end      
         item
           Caption = 'Name'
-          MaxWidth = 300
           MinWidth = 50
           Width = 145
         end      
         item
           Caption = 'Page'
-          MaxWidth = 1000
+          MinWidth = 50
           Width = 201
         end      
         item
-          Caption = 'Package'
+          Caption = 'Unit'
+          MinWidth = 50
           Width = 301
         end>
       DragMode = dmAutomatic
Index: ide/frames/componentpalette_options.pas
===================================================================
--- ide/frames/componentpalette_options.pas	(revisione 47273)
+++ ide/frames/componentpalette_options.pas	(copia locale)
@@ -313,9 +313,18 @@
   PageCnt, CompCnt: Integer;
   StartInd, EndInd: Integer;
   RealPageName, CompName: String;
+  bListAll : Boolean;
+  TempWidth,
+  NameWidth,
+  PageWidth,
+  UnitWidth : Integer;
 begin
-  if aPageName = lis_All_ then
+  bListAll := aPageName = lis_All_;
+  if bListAll then
   begin
+    NameWidth := 50;
+    PageWidth := 50;
+    UnitWidth := 50;
     StartInd := 1;                // Skip the first entry for all components.
     EndInd := PagesListBox.Count-1;
   end
@@ -338,8 +347,23 @@
       Item.SubItems.Add(RealPageName);
       Item.SubItems.Add(Comp.GetUnitName);
       Item.Data := Comp;
+      if bListAll then
+      begin
+        TempWidth := 20 + ComponentsListView.Canvas.GetTextWidth(CompName);
+        if TempWidth > NameWidth then NameWidth := TempWidth;
+        TempWidth := 20 + ComponentsListView.Canvas.GetTextWidth(RealPageName);
+        if TempWidth > PageWidth then PageWidth := TempWidth;
+        TempWidth := 20 + ComponentsListView.Canvas.GetTextWidth(Comp.GetUnitName);
+        if TempWidth > UnitWidth then UnitWidth := TempWidth;
+      end;
     end;
   end;
+  if bListAll then
+  begin
+    ComponentsListView.Column[1].Width := NameWidth;
+    ComponentsListView.Column[2].Width := PageWidth;
+    ComponentsListView.Column[3].Width := UnitWidth;
+  end;
   ComponentsListView.Items.EndUpdate;
 end;
 


More information about the Lazarus mailing list