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