2008-09-09 [colin] 3.5.0cvs96
[claws.git] / src / gtk / gtkcmclist.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball, Josh MacDonald
3  * Copyright (C) 1997-1998 Jay Painter <jpaint@serv.net><jpaint@gimp.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 /*
22  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
23  * file for a list of people on the GTK+ Team.  See the ChangeLog
24  * files for a list of changes.  These files are distributed with
25  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
26  */
27
28 #ifndef __GTK_CMCLIST_H__
29 #define __GTK_CMCLIST_H__
30
31 #include <gdk/gdk.h>
32 #include <gtk/gtk.h>
33
34
35 G_BEGIN_DECLS
36
37
38 /* clist flags */
39 enum {
40   GTK_CMCLIST_IN_DRAG             = 1 <<  0,
41   GTK_CMCLIST_ROW_HEIGHT_SET      = 1 <<  1,
42   GTK_CMCLIST_SHOW_TITLES         = 1 <<  2,
43   /* Unused */
44   GTK_CMCLIST_ADD_MODE            = 1 <<  4,
45   GTK_CMCLIST_AUTO_SORT           = 1 <<  5,
46   GTK_CMCLIST_AUTO_RESIZE_BLOCKED = 1 <<  6,
47   GTK_CMCLIST_REORDERABLE         = 1 <<  7,
48   GTK_CMCLIST_USE_DRAG_ICONS      = 1 <<  8,
49   GTK_CMCLIST_DRAW_DRAG_LINE      = 1 <<  9,
50   GTK_CMCLIST_DRAW_DRAG_RECT      = 1 << 10
51 }; 
52
53 /* cell types */
54 typedef enum
55 {
56   GTK_CMCELL_EMPTY,
57   GTK_CMCELL_TEXT,
58   GTK_CMCELL_PIXMAP,
59   GTK_CMCELL_PIXTEXT,
60   GTK_CMCELL_WIDGET
61 } GtkCMCellType;
62
63 typedef enum
64 {
65   GTK_CMCLIST_DRAG_NONE,
66   GTK_CMCLIST_DRAG_BEFORE,
67   GTK_CMCLIST_DRAG_INTO,
68   GTK_CMCLIST_DRAG_AFTER
69 } GtkCMCListDragPos;
70
71 typedef enum
72 {
73   GTK_CMBUTTON_IGNORED = 0,
74   GTK_CMBUTTON_SELECTS = 1 << 0,
75   GTK_CMBUTTON_DRAGS   = 1 << 1,
76   GTK_CMBUTTON_EXPANDS = 1 << 2
77 } GtkCMButtonAction;
78
79 #define GTK_TYPE_CMCLIST            (gtk_cmclist_get_type ())
80 #define GTK_CMCLIST(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CMCLIST, GtkCMCList))
81 #define GTK_CMCLIST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CMCLIST, GtkCMCListClass))
82 #define GTK_IS_CMCLIST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CMCLIST))
83 #define GTK_IS_CMCLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CMCLIST))
84 #define GTK_CMCLIST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CMCLIST, GtkCMCListClass))
85
86
87 #define GTK_CMCLIST_FLAGS(clist)             (GTK_CMCLIST (clist)->flags)
88 #define GTK_CMCLIST_SET_FLAG(clist,flag)     (GTK_CMCLIST_FLAGS (clist) |= (GTK_ ## flag))
89 #define GTK_CMCLIST_UNSET_FLAG(clist,flag)   (GTK_CMCLIST_FLAGS (clist) &= ~(GTK_ ## flag))
90
91 #define GTK_CMCLIST_IN_DRAG(clist)           (GTK_CMCLIST_FLAGS (clist) & GTK_CMCLIST_IN_DRAG)
92 #define GTK_CMCLIST_ROW_HEIGHT_SET(clist)    (GTK_CMCLIST_FLAGS (clist) & GTK_CMCLIST_ROW_HEIGHT_SET)
93 #define GTK_CMCLIST_SHOW_TITLES(clist)       (GTK_CMCLIST_FLAGS (clist) & GTK_CMCLIST_SHOW_TITLES)
94 #define GTK_CMCLIST_ADD_MODE(clist)          (GTK_CMCLIST_FLAGS (clist) & GTK_CMCLIST_ADD_MODE)
95 #define GTK_CMCLIST_AUTO_SORT(clist)         (GTK_CMCLIST_FLAGS (clist) & GTK_CMCLIST_AUTO_SORT)
96 #define GTK_CMCLIST_AUTO_RESIZE_BLOCKED(clist) (GTK_CMCLIST_FLAGS (clist) & GTK_CMCLIST_AUTO_RESIZE_BLOCKED)
97 #define GTK_CMCLIST_REORDERABLE(clist)       (GTK_CMCLIST_FLAGS (clist) & GTK_CMCLIST_REORDERABLE)
98 #define GTK_CMCLIST_USE_DRAG_ICONS(clist)    (GTK_CMCLIST_FLAGS (clist) & GTK_CMCLIST_USE_DRAG_ICONS)
99 #define GTK_CMCLIST_DRAW_DRAG_LINE(clist)    (GTK_CMCLIST_FLAGS (clist) & GTK_CMCLIST_DRAW_DRAG_LINE)
100 #define GTK_CMCLIST_DRAW_DRAG_RECT(clist)    (GTK_CMCLIST_FLAGS (clist) & GTK_CMCLIST_DRAW_DRAG_RECT)
101
102 #define GTK_CMCLIST_ROW(_glist_) ((GtkCMCListRow *)((_glist_)->data))
103
104 /* pointer casting for cells */
105 #define GTK_CMCELL_TEXT(cell)     (((GtkCMCellText *) &(cell)))
106 #define GTK_CMCELL_PIXMAP(cell)   (((GtkCMCellPixmap *) &(cell)))
107 #define GTK_CMCELL_PIXTEXT(cell)  (((GtkCMCellPixText *) &(cell)))
108 #define GTK_CMCELL_WIDGET(cell)   (((GtkCMCellWidget *) &(cell)))
109
110 typedef struct _GtkCMCList GtkCMCList;
111 typedef struct _GtkCMCListClass GtkCMCListClass;
112 typedef struct _GtkCMCListColumn GtkCMCListColumn;
113 typedef struct _GtkCMCListRow GtkCMCListRow;
114
115 typedef struct _GtkCMCell GtkCMCell;
116 typedef struct _GtkCMCellText GtkCMCellText;
117 typedef struct _GtkCMCellPixmap GtkCMCellPixmap;
118 typedef struct _GtkCMCellPixText GtkCMCellPixText;
119 typedef struct _GtkCMCellWidget GtkCMCellWidget;
120
121 typedef gint (*GtkCMCListCompareFunc) (GtkCMCList     *clist,
122                                      gconstpointer ptr1,
123                                      gconstpointer ptr2);
124
125 typedef struct _GtkCMCListCellInfo GtkCMCListCellInfo;
126 typedef struct _GtkCMCListDestInfo GtkCMCListDestInfo;
127
128 struct _GtkCMCListCellInfo
129 {
130   gint row;
131   gint column;
132 };
133
134 struct _GtkCMCListDestInfo
135 {
136   GtkCMCListCellInfo cell;
137   GtkCMCListDragPos  insert_pos;
138 };
139
140 struct _GtkCMCList
141 {
142   GtkContainer container;
143   
144   guint16 flags;
145   
146 #if !GLIB_CHECK_VERSION(2,10,0)
147   GMemChunk *row_mem_chunk;
148   GMemChunk *cell_mem_chunk;
149 #else
150   gpointer reserved1;
151   gpointer reserved2;
152 #endif
153   guint freeze_count;
154   
155   /* allocation rectangle after the conatiner_border_width
156    * and the width of the shadow border */
157   GdkRectangle internal_allocation;
158   
159   /* rows */
160   gint rows;
161   gint row_height;
162   GList *row_list;
163   GList *row_list_end;
164   
165   /* columns */
166   gint columns;
167   GdkRectangle column_title_area;
168   GdkWindow *title_window;
169   
170   /* dynamicly allocated array of column structures */
171   GtkCMCListColumn *column;
172   
173   /* the scrolling window and its height and width to
174    * make things a little speedier */
175   GdkWindow *clist_window;
176   gint clist_window_width;
177   gint clist_window_height;
178   
179   /* offsets for scrolling */
180   gint hoffset;
181   gint voffset;
182   
183   /* border shadow style */
184   GtkShadowType shadow_type;
185   
186   /* the list's selection mode (gtkenums.h) */
187   GtkSelectionMode selection_mode;
188   
189   /* list of selected rows */
190   GList *selection;
191   GList *selection_end;
192   
193   GList *undo_selection;
194   GList *undo_unselection;
195   gint undo_anchor;
196   
197   /* mouse buttons */
198   guint8 button_actions[5];
199
200   guint8 drag_button;
201
202   /* dnd */
203   GtkCMCListCellInfo click_cell;
204
205   /* scroll adjustments */
206   GtkAdjustment *hadjustment;
207   GtkAdjustment *vadjustment;
208   
209   /* xor GC for the vertical drag line */
210   GdkGC *xor_gc;
211   
212   /* gc for drawing unselected cells */
213   GdkGC *fg_gc;
214   GdkGC *bg_gc;
215   
216   /* cursor used to indicate dragging */
217   GdkCursor *cursor_drag;
218   
219   /* the current x-pixel location of the xor-drag line */
220   gint x_drag;
221   
222   /* focus handling */
223   gint focus_row;
224
225   gint focus_header_column;
226   
227   /* dragging the selection */
228   gint anchor;
229   GtkStateType anchor_state;
230   gint drag_pos;
231   gint htimer;
232   gint vtimer;
233   
234   GtkSortType sort_type;
235   GtkCMCListCompareFunc compare;
236   gint sort_column;
237
238   gint drag_highlight_row;
239   GtkCMCListDragPos drag_highlight_pos;
240 };
241
242 struct _GtkCMCListClass
243 {
244   GtkContainerClass parent_class;
245   
246   void  (*set_scroll_adjustments) (GtkCMCList       *clist,
247                                    GtkAdjustment  *hadjustment,
248                                    GtkAdjustment  *vadjustment);
249   void   (*refresh)             (GtkCMCList       *clist);
250   void   (*select_row)          (GtkCMCList       *clist,
251                                  gint            row,
252                                  gint            column,
253                                  GdkEvent       *event);
254   void   (*unselect_row)        (GtkCMCList       *clist,
255                                  gint            row,
256                                  gint            column,
257                                  GdkEvent       *event);
258   void   (*row_move)            (GtkCMCList       *clist,
259                                  gint            source_row,
260                                  gint            dest_row);
261   void   (*click_column)        (GtkCMCList       *clist,
262                                  gint            column);
263   void   (*resize_column)       (GtkCMCList       *clist,
264                                  gint            column,
265                                  gint            width);
266   void   (*toggle_focus_row)    (GtkCMCList       *clist);
267   void   (*select_all)          (GtkCMCList       *clist);
268   void   (*unselect_all)        (GtkCMCList       *clist);
269   void   (*undo_selection)      (GtkCMCList       *clist);
270   void   (*start_selection)     (GtkCMCList       *clist);
271   void   (*end_selection)       (GtkCMCList       *clist);
272   void   (*extend_selection)    (GtkCMCList       *clist,
273                                  GtkScrollType   scroll_type,
274                                  gfloat          position,
275                                  gboolean        auto_start_selection);
276   void   (*scroll_horizontal)   (GtkCMCList       *clist,
277                                  GtkScrollType   scroll_type,
278                                  gfloat          position);
279   void   (*scroll_vertical)     (GtkCMCList       *clist,
280                                  GtkScrollType   scroll_type,
281                                  gfloat          position);
282   void   (*toggle_add_mode)     (GtkCMCList       *clist);
283   void   (*abort_column_resize) (GtkCMCList       *clist);
284   void   (*resync_selection)    (GtkCMCList       *clist,
285                                  GdkEvent       *event);
286   GList* (*selection_find)      (GtkCMCList       *clist,
287                                  gint            row_number,
288                                  GList          *row_list_element);
289   void   (*draw_row)            (GtkCMCList       *clist,
290                                  GdkRectangle   *area,
291                                  gint            row,
292                                  GtkCMCListRow    *clist_row);
293   void   (*draw_drag_highlight) (GtkCMCList        *clist,
294                                  GtkCMCListRow     *target_row,
295                                  gint             target_row_number,
296                                  GtkCMCListDragPos  drag_pos);
297   void   (*clear)               (GtkCMCList       *clist);
298   void   (*fake_unselect_all)   (GtkCMCList       *clist,
299                                  gint            row);
300   void   (*sort_list)           (GtkCMCList       *clist);
301   gint   (*insert_row)          (GtkCMCList       *clist,
302                                  gint            row,
303                                  gchar          *text[]);
304   void   (*remove_row)          (GtkCMCList       *clist,
305                                  gint            row);
306   void   (*set_cell_contents)   (GtkCMCList       *clist,
307                                  GtkCMCListRow    *clist_row,
308                                  gint            column,
309                                  GtkCMCellType     type,
310                                  const gchar    *text,
311                                  guint8          spacing,
312                                  GdkPixmap      *pixmap,
313                                  GdkBitmap      *mask);
314   void   (*cell_size_request)   (GtkCMCList       *clist,
315                                  GtkCMCListRow    *clist_row,
316                                  gint            column,
317                                  GtkRequisition *requisition);
318
319 };
320
321 struct _GtkCMCListColumn
322 {
323   gchar *title;
324   GdkRectangle area;
325   
326   GtkWidget *button;
327   GdkWindow *window;
328   
329   gint width;
330   gint min_width;
331   gint max_width;
332   GtkJustification justification;
333   
334   guint visible        : 1;  
335   guint width_set      : 1;
336   guint resizeable     : 1;
337   guint auto_resize    : 1;
338   guint button_passive : 1;
339 };
340
341 struct _GtkCMCListRow
342 {
343   GtkCMCell *cell;
344   GtkStateType state;
345   
346   GdkColor foreground;
347   GdkColor background;
348   
349   GtkStyle *style;
350
351   gpointer data;
352   GDestroyNotify destroy;
353   
354   guint fg_set     : 1;
355   guint bg_set     : 1;
356   guint selectable : 1;
357 };
358
359 /* Cell Structures */
360 struct _GtkCMCellText
361 {
362   GtkCMCellType type;
363   
364   gint16 vertical;
365   gint16 horizontal;
366   
367   GtkStyle *style;
368
369   gchar *text;
370 };
371
372 struct _GtkCMCellPixmap
373 {
374   GtkCMCellType type;
375   
376   gint16 vertical;
377   gint16 horizontal;
378   
379   GtkStyle *style;
380
381   GdkPixmap *pixmap;
382   GdkBitmap *mask;
383 };
384
385 struct _GtkCMCellPixText
386 {
387   GtkCMCellType type;
388   
389   gint16 vertical;
390   gint16 horizontal;
391   
392   GtkStyle *style;
393
394   gchar *text;
395   guint8 spacing;
396   GdkPixmap *pixmap;
397   GdkBitmap *mask;
398 };
399
400 struct _GtkCMCellWidget
401 {
402   GtkCMCellType type;
403   
404   gint16 vertical;
405   gint16 horizontal;
406   
407   GtkStyle *style;
408
409   GtkWidget *widget;
410 };
411
412 struct _GtkCMCell
413 {
414   GtkCMCellType type;
415   
416   gint16 vertical;
417   gint16 horizontal;
418   
419   GtkStyle *style;
420
421   union {
422     gchar *text;
423     
424     struct {
425       GdkPixmap *pixmap;
426       GdkBitmap *mask;
427     } pm;
428     
429     struct {
430       gchar *text;
431       guint8 spacing;
432       GdkPixmap *pixmap;
433       GdkBitmap *mask;
434     } pt;
435     
436     GtkWidget *widget;
437   } u;
438 };
439
440 GType gtk_cmclist_get_type (void);
441
442 /* create a new GtkCMCList */
443 GtkWidget* gtk_cmclist_new             (gint   columns);
444 GtkWidget* gtk_cmclist_new_with_titles (gint   columns,
445                                       gchar *titles[]);
446
447 /* set adjustments of clist */
448 void gtk_cmclist_set_hadjustment (GtkCMCList      *clist,
449                                 GtkAdjustment *adjustment);
450 void gtk_cmclist_set_vadjustment (GtkCMCList      *clist,
451                                 GtkAdjustment *adjustment);
452
453 /* get adjustments of clist */
454 GtkAdjustment* gtk_cmclist_get_hadjustment (GtkCMCList *clist);
455 GtkAdjustment* gtk_cmclist_get_vadjustment (GtkCMCList *clist);
456
457 /* set the border style of the clist */
458 void gtk_cmclist_set_shadow_type (GtkCMCList      *clist,
459                                 GtkShadowType  type);
460
461 /* set the clist's selection mode */
462 void gtk_cmclist_set_selection_mode (GtkCMCList         *clist,
463                                    GtkSelectionMode  mode);
464
465 /* enable clists reorder ability */
466 void gtk_cmclist_set_reorderable (GtkCMCList *clist,
467                                 gboolean  reorderable);
468 void gtk_cmclist_set_use_drag_icons (GtkCMCList *clist,
469                                    gboolean  use_icons);
470 void gtk_cmclist_set_button_actions (GtkCMCList *clist,
471                                    guint     button,
472                                    guint8    button_actions);
473
474 /* freeze all visual updates of the list, and then thaw the list after
475  * you have made a number of changes and the updates wil occure in a
476  * more efficent mannor than if you made them on a unfrozen list
477  */
478 void gtk_cmclist_freeze (GtkCMCList *clist);
479 void gtk_cmclist_thaw   (GtkCMCList *clist);
480
481 /* show and hide the column title buttons */
482 void gtk_cmclist_column_titles_show (GtkCMCList *clist);
483 void gtk_cmclist_column_titles_hide (GtkCMCList *clist);
484
485 /* set the column title to be a active title (responds to button presses, 
486  * prelights, and grabs keyboard focus), or passive where it acts as just
487  * a title
488  */
489 void gtk_cmclist_column_title_active   (GtkCMCList *clist,
490                                       gint      column);
491 void gtk_cmclist_column_title_passive  (GtkCMCList *clist,
492                                       gint      column);
493 void gtk_cmclist_column_titles_active  (GtkCMCList *clist);
494 void gtk_cmclist_column_titles_passive (GtkCMCList *clist);
495
496 /* set the title in the column title button */
497 void gtk_cmclist_set_column_title (GtkCMCList    *clist,
498                                  gint         column,
499                                  const gchar *title);
500
501 /* returns the title of column. Returns NULL if title is not set */
502 gchar * gtk_cmclist_get_column_title (GtkCMCList *clist,
503                                     gint      column);
504
505 /* set a widget instead of a title for the column title button */
506 void gtk_cmclist_set_column_widget (GtkCMCList  *clist,
507                                   gint       column,
508                                   GtkWidget *widget);
509
510 /* returns the column widget */
511 GtkWidget * gtk_cmclist_get_column_widget (GtkCMCList *clist,
512                                          gint      column);
513
514 /* set the justification on a column */
515 void gtk_cmclist_set_column_justification (GtkCMCList         *clist,
516                                          gint              column,
517                                          GtkJustification  justification);
518
519 /* set visibility of a column */
520 void gtk_cmclist_set_column_visibility (GtkCMCList *clist,
521                                       gint      column,
522                                       gboolean  visible);
523
524 /* enable/disable column resize operations by mouse */
525 void gtk_cmclist_set_column_resizeable (GtkCMCList *clist,
526                                       gint      column,
527                                       gboolean  resizeable);
528
529 /* resize column automatically to its optimal width */
530 void gtk_cmclist_set_column_auto_resize (GtkCMCList *clist,
531                                        gint      column,
532                                        gboolean  auto_resize);
533
534 gint gtk_cmclist_columns_autosize (GtkCMCList *clist);
535
536 /* return the optimal column width, i.e. maximum of all cell widths */
537 gint gtk_cmclist_optimal_column_width (GtkCMCList *clist,
538                                      gint      column);
539
540 /* set the pixel width of a column; this is a necessary step in
541  * creating a CList because otherwise the column width is chozen from
542  * the width of the column title, which will never be right
543  */
544 void gtk_cmclist_set_column_width (GtkCMCList *clist,
545                                  gint      column,
546                                  gint      width);
547
548 /* set column minimum/maximum width. min/max_width < 0 => no restriction */
549 void gtk_cmclist_set_column_min_width (GtkCMCList *clist,
550                                      gint      column,
551                                      gint      min_width);
552 void gtk_cmclist_set_column_max_width (GtkCMCList *clist,
553                                      gint      column,
554                                      gint      max_width);
555
556 /* change the height of the rows, the default (height=0) is
557  * the hight of the current font.
558  */
559 void gtk_cmclist_set_row_height (GtkCMCList *clist,
560                                guint     height);
561
562 /* scroll the viewing area of the list to the given column and row;
563  * row_align and col_align are between 0-1 representing the location the
564  * row should appear on the screnn, 0.0 being top or left, 1.0 being
565  * bottom or right; if row or column is -1 then then there is no change
566  */
567 void gtk_cmclist_moveto (GtkCMCList *clist,
568                        gint      row,
569                        gint      column,
570                        gfloat    row_align,
571                        gfloat    col_align);
572
573 /* returns whether the row is visible */
574 GtkVisibility gtk_cmclist_row_is_visible (GtkCMCList *clist,
575                                         gint      row);
576
577 /* returns the cell type */
578 GtkCMCellType gtk_cmclist_get_cell_type (GtkCMCList *clist,
579                                      gint      row,
580                                      gint      column);
581
582 /* sets a given cell's text, replacing its current contents */
583 void gtk_cmclist_set_text (GtkCMCList    *clist,
584                          gint         row,
585                          gint         column,
586                          const gchar *text);
587
588 /* for the "get" functions, any of the return pointer can be
589  * NULL if you are not interested
590  */
591 gint gtk_cmclist_get_text (GtkCMCList  *clist,
592                          gint       row,
593                          gint       column,
594                          gchar    **text);
595
596 /* sets a given cell's pixmap, replacing its current contents */
597 void gtk_cmclist_set_pixmap (GtkCMCList  *clist,
598                            gint       row,
599                            gint       column,
600                            GdkPixmap *pixmap,
601                            GdkBitmap *mask);
602
603 gint gtk_cmclist_get_pixmap (GtkCMCList   *clist,
604                            gint        row,
605                            gint        column,
606                            GdkPixmap **pixmap,
607                            GdkBitmap **mask);
608
609 /* sets a given cell's pixmap and text, replacing its current contents */
610 void gtk_cmclist_set_pixtext (GtkCMCList    *clist,
611                             gint         row,
612                             gint         column,
613                             const gchar *text,
614                             guint8       spacing,
615                             GdkPixmap   *pixmap,
616                             GdkBitmap   *mask);
617
618 gint gtk_cmclist_get_pixtext (GtkCMCList   *clist,
619                             gint        row,
620                             gint        column,
621                             gchar     **text,
622                             guint8     *spacing,
623                             GdkPixmap **pixmap,
624                             GdkBitmap **mask);
625
626 /* sets the foreground color of a row, the color must already
627  * be allocated
628  */
629 void gtk_cmclist_set_foreground (GtkCMCList       *clist,
630                                gint            row,
631                                const GdkColor *color);
632
633 /* sets the background color of a row, the color must already
634  * be allocated
635  */
636 void gtk_cmclist_set_background (GtkCMCList       *clist,
637                                gint            row,
638                                const GdkColor *color);
639
640 /* set / get cell styles */
641 void gtk_cmclist_set_cell_style (GtkCMCList *clist,
642                                gint      row,
643                                gint      column,
644                                GtkStyle *style);
645
646 GtkStyle *gtk_cmclist_get_cell_style (GtkCMCList *clist,
647                                     gint      row,
648                                     gint      column);
649
650 void gtk_cmclist_set_row_style (GtkCMCList *clist,
651                               gint      row,
652                               GtkStyle *style);
653
654 GtkStyle *gtk_cmclist_get_row_style (GtkCMCList *clist,
655                                    gint      row);
656
657 /* this sets a horizontal and vertical shift for drawing
658  * the contents of a cell; it can be positive or negitive;
659  * this is particulary useful for indenting items in a column
660  */
661 void gtk_cmclist_set_shift (GtkCMCList *clist,
662                           gint      row,
663                           gint      column,
664                           gint      vertical,
665                           gint      horizontal);
666
667 /* set/get selectable flag of a single row */
668 void gtk_cmclist_set_selectable (GtkCMCList *clist,
669                                gint      row,
670                                gboolean  selectable);
671 gboolean gtk_cmclist_get_selectable (GtkCMCList *clist,
672                                    gint      row);
673
674 /* prepend/append returns the index of the row you just added,
675  * making it easier to append and modify a row
676  */
677 gint gtk_cmclist_prepend (GtkCMCList    *clist,
678                         gchar       *text[]);
679 gint gtk_cmclist_append  (GtkCMCList    *clist,
680                         gchar       *text[]);
681
682 /* inserts a row at index row and returns the row where it was
683  * actually inserted (may be different from "row" in auto_sort mode)
684  */
685 gint gtk_cmclist_insert (GtkCMCList    *clist,
686                        gint         row,
687                        gchar       *text[]);
688
689 /* removes row at index row */
690 void gtk_cmclist_remove (GtkCMCList *clist,
691                        gint      row);
692
693 /* sets a arbitrary data pointer for a given row */
694 void gtk_cmclist_set_row_data (GtkCMCList *clist,
695                              gint      row,
696                              gpointer  data);
697
698 /* sets a data pointer for a given row with destroy notification */
699 void gtk_cmclist_set_row_data_full (GtkCMCList         *clist,
700                                   gint              row,
701                                   gpointer          data,
702                                   GDestroyNotify  destroy);
703
704 /* returns the data set for a row */
705 gpointer gtk_cmclist_get_row_data (GtkCMCList *clist,
706                                  gint      row);
707
708 /* givin a data pointer, find the first (and hopefully only!)
709  * row that points to that data, or -1 if none do
710  */
711 gint gtk_cmclist_find_row_from_data (GtkCMCList *clist,
712                                    gpointer  data);
713
714 /* force selection of a row */
715 void gtk_cmclist_select_row (GtkCMCList *clist,
716                            gint      row,
717                            gint      column);
718
719 /* force unselection of a row */
720 void gtk_cmclist_unselect_row (GtkCMCList *clist,
721                              gint      row,
722                              gint      column);
723
724 /* undo the last select/unselect operation */
725 void gtk_cmclist_undo_selection (GtkCMCList *clist);
726
727 /* clear the entire list -- this is much faster than removing
728  * each item with gtk_cmclist_remove
729  */
730 void gtk_cmclist_clear (GtkCMCList *clist);
731
732 /* return the row column corresponding to the x and y coordinates,
733  * the returned values are only valid if the x and y coordinates
734  * are respectively to a window == clist->clist_window
735  */
736 gint gtk_cmclist_get_selection_info (GtkCMCList *clist,
737                                    gint      x,
738                                    gint      y,
739                                    gint     *row,
740                                    gint     *column);
741
742 /* in multiple or extended mode, select all rows */
743 void gtk_cmclist_select_all (GtkCMCList *clist);
744
745 /* in all modes except browse mode, deselect all rows */
746 void gtk_cmclist_unselect_all (GtkCMCList *clist);
747
748 /* swap the position of two rows */
749 void gtk_cmclist_swap_rows (GtkCMCList *clist,
750                           gint      row1,
751                           gint      row2);
752
753 /* move row from source_row position to dest_row position */
754 void gtk_cmclist_row_move (GtkCMCList *clist,
755                          gint      source_row,
756                          gint      dest_row);
757
758 /* sets a compare function different to the default */
759 void gtk_cmclist_set_compare_func (GtkCMCList            *clist,
760                                  GtkCMCListCompareFunc  cmp_func);
761
762 /* the column to sort by */
763 void gtk_cmclist_set_sort_column (GtkCMCList *clist,
764                                 gint      column);
765
766 /* how to sort : ascending or descending */
767 void gtk_cmclist_set_sort_type (GtkCMCList    *clist,
768                               GtkSortType  sort_type);
769
770 /* sort the list with the current compare function */
771 void gtk_cmclist_sort (GtkCMCList *clist);
772
773 /* Automatically sort upon insertion */
774 void gtk_cmclist_set_auto_sort (GtkCMCList *clist,
775                               gboolean  auto_sort);
776
777 /* Private function for clist, ctree */
778
779 PangoLayout *_gtk_cmclist_create_cell_layout (GtkCMCList       *clist,
780                                             GtkCMCListRow    *clist_row,
781                                             gint            column);
782
783
784 G_END_DECLS
785
786
787 #endif                          /* __GTK_CMCLIST_H__ */