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>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library 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.
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 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __GTK_CLIST_H__
20 #define __GTK_CLIST_H__
23 #include <gtk/gtksignal.h>
24 #include <gtk/gtkalignment.h>
25 #include <gtk/gtklabel.h>
26 #include <gtk/gtkbutton.h>
27 #include <gtk/gtkhscrollbar.h>
28 #include <gtk/gtkvscrollbar.h>
34 #endif /* __cplusplus */
39 CLIST_FROZEN = 1 << 0,
40 CLIST_IN_DRAG = 1 << 1,
41 CLIST_ROW_HEIGHT_SET = 1 << 2
54 #define GTK_CLIST(obj) GTK_CHECK_CAST (obj, gtk_clist_get_type (), GtkCList)
55 #define GTK_CLIST_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_clist_get_type (), GtkCListClass)
56 #define GTK_IS_CLIST(obj) GTK_CHECK_TYPE (obj, gtk_clist_get_type ())
58 #define GTK_CLIST_FLAGS(clist) (GTK_CLIST (clist)->flags)
59 #define GTK_CLIST_SET_FLAGS(clist,flag) (GTK_CLIST_FLAGS (clist) |= (flag))
60 #define GTK_CLIST_UNSET_FLAGS(clist,flag) (GTK_CLIST_FLAGS (clist) &= ~(flag))
62 #define GTK_CLIST_FROZEN(clist) (GTK_CLIST_FLAGS (clist) & CLIST_FROZEN)
63 #define GTK_CLIST_IN_DRAG(clist) (GTK_CLIST_FLAGS (clist) & CLIST_IN_DRAG)
64 #define GTK_CLIST_ROW_HEIGHT_SET(clist) (GTK_CLIST_FLAGS (clist) & CLIST_ROW_HEIGHT_SET)
66 /* pointer casting for cells */
67 #define GTK_CELL_TEXT(cell) (((GtkCellText *) &(cell)))
68 #define GTK_CELL_PIXMAP(cell) (((GtkCellPixmap *) &(cell)))
69 #define GTK_CELL_PIXTEXT(cell) (((GtkCellPixText *) &(cell)))
70 #define GTK_CELL_WIDGET(cell) (((GtkCellWidget *) &(cell)))
72 typedef struct _GtkCList GtkCList;
73 typedef struct _GtkCListClass GtkCListClass;
74 typedef struct _GtkCListColumn GtkCListColumn;
75 typedef struct _GtkCListRow GtkCListRow;
77 typedef struct _GtkCell GtkCell;
78 typedef struct _GtkCellText GtkCellText;
79 typedef struct _GtkCellPixmap GtkCellPixmap;
80 typedef struct _GtkCellPixText GtkCellPixText;
81 typedef struct _GtkCellWidget GtkCellWidget;
85 GtkContainer container;
89 /* allocation rectangle after the conatiner_border_width
90 * and the width of the shadow border */
91 GdkRectangle internal_allocation;
94 GMemChunk *row_mem_chunk;
95 GMemChunk *cell_mem_chunk;
99 gint row_center_offset;
106 GdkRectangle column_title_area;
107 GdkWindow *title_window;
109 /* dynamicly allocated array of column structures */
110 GtkCListColumn *column;
112 /*the scrolling window and it's height and width to
113 * make things a little speedier */
114 GdkWindow *clist_window;
115 gint clist_window_width;
116 gint clist_window_height;
118 /* offsets for scrolling */
122 /* border shadow style */
123 GtkShadowType shadow_type;
125 /* the list's selection mode (gtkenums.h) */
126 GtkSelectionMode selection_mode;
129 GtkWidget *vscrollbar;
130 GtkWidget *hscrollbar;
131 guint8 vscrollbar_policy;
132 guint8 hscrollbar_policy;
134 /* xor GC for the verticle drag line */
137 /* gc for drawing unselected cells */
141 /* cursor used to indicate dragging */
142 GdkCursor *cursor_drag;
144 /* the current x-pixel location of the xor-drag line */
148 struct _GtkCListClass
150 GtkContainerClass parent_class;
152 void (*select_row) (GtkCList * clist,
155 GdkEventButton * event);
156 void (*unselect_row) (GtkCList * clist,
159 GdkEventButton * event);
160 void (*click_column) (GtkCList * clist,
164 struct _GtkCListColumn
171 GtkJustification justification;
185 /* Cell Structures */
196 struct _GtkCellPixmap
207 struct _GtkCellPixText
220 struct _GtkCellWidget
256 guint gtk_clist_get_type (void);
258 /* create a new GtkCList */
259 GtkWidget *gtk_clist_new (int columns,
262 /* set the border style of the clist */
263 void gtk_clist_set_border (GtkCList * clist,
264 GtkShadowType border);
266 /* set the clist's selection mode */
267 void gtk_clist_set_selection_mode (GtkCList * clist,
268 GtkSelectionMode mode);
270 /* set policy on the scrollbar, to either show them all the time
271 * or show them only when they are needed, ie., when there is more than one page
273 void gtk_clist_set_policy (GtkCList * clist,
274 GtkPolicyType vscrollbar_policy,
275 GtkPolicyType hscrollbar_policy);
277 /* freeze all visual updates of the list, and then thaw the list after you have made
278 * a number of changes and the updates wil occure in a more efficent mannor than if
279 * you made them on a unfrozen list */
280 void gtk_clist_freeze (GtkCList * clist);
281 void gtk_clist_thaw (GtkCList * clist);
283 /* set the title in the column title button */
284 void gtk_clist_set_column_title (GtkCList * clist,
288 /* set a widget instead of a title for the column title button */
289 void gtk_clist_set_column_widget (GtkCList * clist,
293 /* set the justification on a column */
294 void gtk_clist_set_column_justification (GtkCList * clist,
296 GtkJustification justification);
298 /* set the pixel width of a column; this is a necessary step in
299 * creating a CList because otherwise the column width is chozen from
300 * the width of the column title, which will never be right */
301 void gtk_clist_set_column_width (GtkCList * clist,
305 /* change the height of the rows, the default is the hight of the current
307 void gtk_clist_set_row_height (GtkCList * clist,
310 /* scroll the viewing area of the list to the given column
311 * and row; row_align and col_align are between 0-1 representing the
312 * location the row should appear on the screnn, 0.0 being top or left,
313 * 1.0 being bottom or right */
314 void gtk_clist_moveto (GtkCList * clist,
320 /* sets a given cell's text, replacing it's current contents */
321 void gtk_clist_set_text (GtkCList * clist,
326 /* sets a given cell's pixmap, replacing it's current contents */
327 void gtk_clist_set_pixmap (GtkCList * clist,
333 /* sets a given cell's pixmap and text, replacing it's current contents */
334 void gtk_clist_set_pixtext (GtkCList * clist,
342 /* sets the foreground color of a row, the colar must already
344 void gtk_clist_set_foreground (GtkCList * clist,
348 /* sets the background color of a row, the colar must already
350 void gtk_clist_set_background (GtkCList * clist,
354 /* this sets a horizontal and verticle shift for drawing
355 * the contents of a cell; it can be positive or negitive; this is
356 * partuculary useful for indenting items in a column */
357 void gtk_clist_set_shift (GtkCList * clist,
363 /* append returns the index of the row you just added, making
364 * it easier to append and modify a row */
365 gint gtk_clist_append (GtkCList * clist,
368 /* inserts a row at index row */
369 void gtk_clist_insert (GtkCList * clist,
373 /* removes row at index row */
374 void gtk_clist_remove (GtkCList * clist,
377 /* sets a arbitrary data pointer for a given row */
378 void gtk_clist_set_row_data (GtkCList * clist,
382 /* returns the data set for a row */
383 gpointer gtk_clist_get_row_data (GtkCList * clist,
386 /* force selection of a row */
387 void gtk_clist_select_row (GtkCList * clist,
391 /* force unselection of a row */
392 void gtk_clist_unselect_row (GtkCList * clist,
396 /* clear the entire list -- this is much faster than removing each item
397 * with gtk_clist_remove */
398 void gtk_clist_clear (GtkCList * clist);
402 #endif /* __cplusplus */
405 #endif /* __GTK_CLIST_H__ */