View Issue Details

IDProjectCategoryView StatusLast Update
0025952LazarusLCLpublic2018-01-31 14:15
Reporterxterro Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformLazarus 1.2OSLinux  
Summary0025952: TCheckListBox OnDrawItem method incorrect draw when setted style "lbOwnerDrawFixed"
DescriptionOn Linux, custom drawings of listbox items are not very correct. Despite of I have set style as "lbOwnerDrawFixed", TCheckListBox draws standard checkbox next to my custom checkbox.
screenshot: http://forum.lazarus.freepascal.org/index.php?action=dlattach;topic=24049.0;attach=8435;image

 
Steps To ReproduceLoad project on Linux in Lazarus v.1.2, Build and Run.(this problem reprodused on Linux in Lazarus 1.2)
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetGTK 2
Attached Files

Relationships

related to 0029525 new TCheckListBox dos not act like I expect. Check boxes are missing. 
related to 0033104 new GTK2: Listview with checks: click on 1st column changes checkbox 

Activities

xterro

2014-03-31 12:00

reporter  

list.zip (387,124 bytes)

Bart Broersma

2014-03-31 12:08

developer   ~0074086

Please move to Lazarus.

Zeljan Rikalo

2014-03-31 14:14

developer   ~0074094

What widgetset ?

xterro

2014-03-31 14:26

reporter   ~0074095

Gtk2

Zeljan Rikalo

2014-03-31 18:55

developer  

gtk2checklistboxdiff.diff (3,392 bytes)   
Index: lcl/interfaces/gtk2/gtk2wschecklst.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wschecklst.pp	(revision 44563)
+++ lcl/interfaces/gtk2/gtk2wschecklst.pp	(working copy)
@@ -177,26 +177,39 @@
   // standard indicator size = 13 and its looks ugly under windows
   g_object_set(renderer, 'indicator-size', [14, nil]);
   {$endif}
-  column := gtk_tree_view_column_new;
-  gtk_tree_view_column_set_title(column, 'CHECKBTNS');
-  gtk_tree_view_column_pack_start(column, renderer, True);
-  gtk_tree_view_column_set_cell_data_func(column, renderer,
-    @Gtk2WS_CheckListBoxDataFunc, WidgetInfo, nil);
-  gtk_cell_renderer_toggle_set_active(GTK_CELL_RENDERER_TOGGLE(renderer), True);
-  gtk_tree_view_append_column(GTK_TREE_VIEW(TreeViewWidget), column);
-  gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(column), True);
+  if TCheckListBox(AWinControl).Style in [lbStandard, lbVirtual] then
+  begin
+    column := gtk_tree_view_column_new;
+    gtk_tree_view_column_set_title(column, 'CHECKBTNS');
+    gtk_tree_view_column_pack_start(column, renderer, True);
+    gtk_tree_view_column_set_cell_data_func(column, renderer,
+      @Gtk2WS_CheckListBoxDataFunc, WidgetInfo, nil);
+    gtk_cell_renderer_toggle_set_active(GTK_CELL_RENDERER_TOGGLE(renderer), True);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(TreeViewWidget), column);
+    gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(column), True);
 
-  SignalConnect(PGtkWidget(renderer), 'toggled', @Gtk2WS_CheckListBoxToggle, WidgetInfo);
+    SignalConnect(PGtkWidget(renderer), 'toggled', @Gtk2WS_CheckListBoxToggle, WidgetInfo);
 
-  // Text Column
-  renderer := LCLIntfCellRenderer_New; // gtk_cell_renderer_text_new();
-  column := gtk_tree_view_column_new_with_attributes(
-                             'LISTITEMS', renderer, ['text', gtk2CLBText, nil]);
+    // Text Column
+    renderer := LCLIntfCellRenderer_New; // gtk_cell_renderer_text_new();
+    column := gtk_tree_view_column_new_with_attributes(
+                               'LISTITEMS', renderer, ['text', gtk2CLBText, nil]);
 
-  gtk_tree_view_column_set_cell_data_func(Column, renderer, TGtkTreeCellDataFunc(@LCLIntfCellRenderer_CellDataFunc), WidgetInfo, nil);
-  gtk_tree_view_append_column(GTK_TREE_VIEW(TreeViewWidget), column);
-  gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(column), True);
+    gtk_tree_view_column_set_cell_data_func(Column, renderer, TGtkTreeCellDataFunc(@LCLIntfCellRenderer_CellDataFunc), WidgetInfo, nil);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(TreeViewWidget), column);
+    gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(column), True);
+  end else
+  begin
+    // Text Column
+    renderer := LCLIntfCellRenderer_New; // gtk_cell_renderer_text_new();
+    column := gtk_tree_view_column_new_with_attributes(
+                               'LISTITEMS', renderer, ['text', gtk2CLBText, nil]);
 
+    gtk_tree_view_column_set_cell_data_func(Column, renderer, TGtkTreeCellDataFunc(@LCLIntfCellRenderer_CellDataFunc), WidgetInfo, nil);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(TreeViewWidget), column);
+    gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(column), True);
+  end;
+
   gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(TreeViewWidget), False);
 
   gtk_container_add(GTK_CONTAINER(p), TreeViewWidget);
gtk2checklistboxdiff.diff (3,392 bytes)   

Zeljan Rikalo

2014-03-31 18:57

developer   ~0074100

Patch (but not correct) attached. It just shows how gtk2 checklistbox should look and nothing else. With this patch there's no Checked[] or OnCheckItem from WS since gtk2 uses 2 columns in TCheckListBox. 1st is checkbox and second is text, so in this patch 1st column is not created.
Must try to create completely new custom renderer for toggle type which will contain checkbox + text, so in that case it will be equal to qt or win32 ws.

xterro

2014-05-07 11:04

reporter   ~0074825

Will it be fixed in new versions? Include the necessity of corrections to the roadmap... plz :)

Zeljan Rikalo

2014-05-07 11:38

developer   ~0074826

@xterro, I've created attached patch just as an example about real problem. Feel free to dig into gtk2 code and create good patch so then it will be commited (you must create completely new renderer in that case).

Bart Broersma

2017-02-18 22:40

developer   ~0098301

Delphi draws a checkbox in this case, regardless of the code in OnDrawItem event.
AFAICS the OnDrawItem is only used to draw the caption of the item.

Issue History

Date Modified Username Field Change
2014-03-31 12:00 xterro New Issue
2014-03-31 12:00 xterro File Added: list.zip
2014-03-31 12:08 Bart Broersma Note Added: 0074086
2014-03-31 13:05 Marco van de Voort Project FPC => Lazarus
2014-03-31 14:14 Zeljan Rikalo Note Added: 0074094
2014-03-31 14:26 xterro Note Added: 0074095
2014-03-31 18:55 Zeljan Rikalo File Added: gtk2checklistboxdiff.diff
2014-03-31 18:57 Zeljan Rikalo Note Added: 0074100
2014-05-07 11:04 xterro Note Added: 0074825
2014-05-07 11:38 Zeljan Rikalo Note Added: 0074826
2016-03-12 12:34 Juha Manninen Relationship added related to 0029525
2016-03-12 12:35 Juha Manninen LazTarget => -
2016-03-12 12:35 Juha Manninen Widgetset => GTK 2
2016-03-12 12:35 Juha Manninen Product Version 2.6.2 =>
2017-02-18 22:40 Bart Broersma Note Added: 0098301
2018-01-31 14:15 Zeljan Rikalo Relationship added related to 0033104