* Copyright (C) 1997-1998 Jay Painter <jpaint@serv.net><jpaint@gimp.org>
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#if !defined (GTK_DISABLE_DEPRECATED) || defined (__GTK_CLIST_C__) || defined (__GTK_CTREE_C__)
+
#ifndef __GTK_CLIST_H__
#define __GTK_CLIST_H__
-#include <gdk/gdk.h>
+
#include <gtk/gtksignal.h>
#include <gtk/gtkalignment.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkhscrollbar.h>
#include <gtk/gtkvscrollbar.h>
-#include <gtk/gtkenums.h>
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
+
+G_BEGIN_DECLS
+
/* clist flags */
-enum
-{
- GTK_CLIST_FROZEN = 1 << 0,
- GTK_CLIST_IN_DRAG = 1 << 1,
- GTK_CLIST_DRAG_SELECTION = 1 << 2,
- GTK_CLIST_ROW_HEIGHT_SET = 1 << 3,
- GTK_CLIST_SHOW_TITLES = 1 << 4,
- GTK_CLIST_CONSTRUCTED = 1 << 5,
- GTK_CLIST_CHILD_HAS_FOCUS = 1 << 6,
- GTK_CLIST_ADD_MODE = 1 << 7,
- GTK_CLIST_AUTO_SORT = 1 << 8,
- GTK_CLIST_AUTO_RESIZE_BLOCKED = 1 << 9
-};
+enum {
+ GTK_CLIST_IN_DRAG = 1 << 0,
+ GTK_CLIST_ROW_HEIGHT_SET = 1 << 1,
+ GTK_CLIST_SHOW_TITLES = 1 << 2,
+ /* Unused */
+ GTK_CLIST_ADD_MODE = 1 << 4,
+ GTK_CLIST_AUTO_SORT = 1 << 5,
+ GTK_CLIST_AUTO_RESIZE_BLOCKED = 1 << 6,
+ GTK_CLIST_REORDERABLE = 1 << 7,
+ GTK_CLIST_USE_DRAG_ICONS = 1 << 8,
+ GTK_CLIST_DRAW_DRAG_LINE = 1 << 9,
+ GTK_CLIST_DRAW_DRAG_RECT = 1 << 10
+};
/* cell types */
typedef enum
GTK_CELL_WIDGET
} GtkCellType;
+typedef enum
+{
+ GTK_CLIST_DRAG_NONE,
+ GTK_CLIST_DRAG_BEFORE,
+ GTK_CLIST_DRAG_INTO,
+ GTK_CLIST_DRAG_AFTER
+} GtkCListDragPos;
+
+typedef enum
+{
+ GTK_BUTTON_IGNORED = 0,
+ GTK_BUTTON_SELECTS = 1 << 0,
+ GTK_BUTTON_DRAGS = 1 << 1,
+ GTK_BUTTON_EXPANDS = 1 << 2
+} GtkButtonAction;
+
#define GTK_TYPE_CLIST (gtk_clist_get_type ())
-#define GTK_CLIST(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_CLIST, GtkCList))
-#define GTK_CLIST_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_CLIST, GtkCListClass))
-#define GTK_IS_CLIST(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_CLIST))
-#define GTK_IS_CLIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CLIST))
+#define GTK_CLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CLIST, GtkCList))
+#define GTK_CLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CLIST, GtkCListClass))
+#define GTK_IS_CLIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CLIST))
+#define GTK_IS_CLIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CLIST))
+#define GTK_CLIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CLIST, GtkCListClass))
+
#define GTK_CLIST_FLAGS(clist) (GTK_CLIST (clist)->flags)
#define GTK_CLIST_SET_FLAG(clist,flag) (GTK_CLIST_FLAGS (clist) |= (GTK_ ## flag))
#define GTK_CLIST_UNSET_FLAG(clist,flag) (GTK_CLIST_FLAGS (clist) &= ~(GTK_ ## flag))
-#define GTK_CLIST_FROZEN(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_FROZEN)
#define GTK_CLIST_IN_DRAG(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_IN_DRAG)
#define GTK_CLIST_ROW_HEIGHT_SET(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_ROW_HEIGHT_SET)
#define GTK_CLIST_SHOW_TITLES(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_SHOW_TITLES)
-#define GTK_CLIST_CONSTRUCTED(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_CONSTRUCTED)
-#define GTK_CLIST_CHILD_HAS_FOCUS(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_CHILD_HAS_FOCUS)
-#define GTK_CLIST_DRAG_SELECTION(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_DRAG_SELECTION)
#define GTK_CLIST_ADD_MODE(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_ADD_MODE)
#define GTK_CLIST_AUTO_SORT(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_AUTO_SORT)
#define GTK_CLIST_AUTO_RESIZE_BLOCKED(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_AUTO_RESIZE_BLOCKED)
+#define GTK_CLIST_REORDERABLE(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_REORDERABLE)
+#define GTK_CLIST_USE_DRAG_ICONS(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_USE_DRAG_ICONS)
+#define GTK_CLIST_DRAW_DRAG_LINE(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_DRAW_DRAG_LINE)
+#define GTK_CLIST_DRAW_DRAG_RECT(clist) (GTK_CLIST_FLAGS (clist) & GTK_CLIST_DRAW_DRAG_RECT)
#define GTK_CLIST_ROW(_glist_) ((GtkCListRow *)((_glist_)->data))
gconstpointer ptr1,
gconstpointer ptr2);
+typedef struct _GtkCListCellInfo GtkCListCellInfo;
+typedef struct _GtkCListDestInfo GtkCListDestInfo;
+
+struct _GtkCListCellInfo
+{
+ gint row;
+ gint column;
+};
+
+struct _GtkCListDestInfo
+{
+ GtkCListCellInfo cell;
+ GtkCListDragPos insert_pos;
+};
+
struct _GtkCList
{
GtkContainer container;
guint16 flags;
- /* mem chunks */
- GMemChunk *row_mem_chunk;
- GMemChunk *cell_mem_chunk;
+ gpointer reserved1;
+ gpointer reserved2;
+
+ guint freeze_count;
- /* allocation rectangle after the conatiner_border_width
+ /* allocation rectangle after the container_border_width
* and the width of the shadow border */
GdkRectangle internal_allocation;
/* rows */
gint rows;
- gint row_center_offset;
gint row_height;
GList *row_list;
GList *row_list_end;
/* dynamicly allocated array of column structures */
GtkCListColumn *column;
- /*the scrolling window and it's height and width to
+ /* the scrolling window and its height and width to
* make things a little speedier */
GdkWindow *clist_window;
gint clist_window_width;
GList *undo_unselection;
gint undo_anchor;
- /* scrollbars */
+ /* mouse buttons */
+ guint8 button_actions[5];
+
+ guint8 drag_button;
+
+ /* dnd */
+ GtkCListCellInfo click_cell;
+
+ /* scroll adjustments */
GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment;
/* focus handling */
gint focus_row;
+
+ gint focus_header_column;
/* dragging the selection */
gint anchor;
GtkSortType sort_type;
GtkCListCompareFunc compare;
gint sort_column;
+
+ gint drag_highlight_row;
+ GtkCListDragPos drag_highlight_pos;
};
struct _GtkCListClass
{
GtkContainerClass parent_class;
+ void (*set_scroll_adjustments) (GtkCList *clist,
+ GtkAdjustment *hadjustment,
+ GtkAdjustment *vadjustment);
+ void (*refresh) (GtkCList *clist);
void (*select_row) (GtkCList *clist,
gint row,
gint column,
gint row,
gint column,
GdkEvent *event);
+ void (*row_move) (GtkCList *clist,
+ gint source_row,
+ gint dest_row);
void (*click_column) (GtkCList *clist,
gint column);
void (*resize_column) (GtkCList *clist,
GdkRectangle *area,
gint row,
GtkCListRow *clist_row);
+ void (*draw_drag_highlight) (GtkCList *clist,
+ GtkCListRow *target_row,
+ gint target_row_number,
+ GtkCListDragPos drag_pos);
void (*clear) (GtkCList *clist);
void (*fake_unselect_all) (GtkCList *clist,
gint row);
GtkCListRow *clist_row,
gint column,
GtkRequisition *requisition);
+
};
struct _GtkCListColumn
gint max_width;
GtkJustification justification;
- guint visible : 1;
- guint width_set : 1;
- guint resizeable : 1;
- guint auto_resize : 1;
+ guint visible : 1;
+ guint width_set : 1;
+ guint resizeable : 1;
+ guint auto_resize : 1;
+ guint button_passive : 1;
};
struct _GtkCListRow
GtkStyle *style;
gpointer data;
- GtkDestroyNotify destroy;
+ GDestroyNotify destroy;
guint fg_set : 1;
guint bg_set : 1;
} u;
};
-GtkType gtk_clist_get_type (void);
-
-/* constructers useful for gtk-- wrappers */
-void gtk_clist_construct (GtkCList *clist,
- gint columns,
- gchar *titles[]);
+GType gtk_clist_get_type (void) G_GNUC_CONST;
/* create a new GtkCList */
GtkWidget* gtk_clist_new (gint columns);
void gtk_clist_set_selection_mode (GtkCList *clist,
GtkSelectionMode mode);
+/* enable clists reorder ability */
+void gtk_clist_set_reorderable (GtkCList *clist,
+ gboolean reorderable);
+void gtk_clist_set_use_drag_icons (GtkCList *clist,
+ gboolean use_icons);
+void gtk_clist_set_button_actions (GtkCList *clist,
+ guint button,
+ guint8 button_actions);
+
/* freeze all visual updates of the list, and then thaw the list after
* you have made a number of changes and the updates wil occure in a
* more efficent mannor than if you made them on a unfrozen list
gint column,
const gchar *title);
+/* returns the title of column. Returns NULL if title is not set */
+gchar * gtk_clist_get_column_title (GtkCList *clist,
+ gint column);
+
/* set a widget instead of a title for the column title button */
void gtk_clist_set_column_widget (GtkCList *clist,
gint column,
GtkWidget *widget);
+/* returns the column widget */
+GtkWidget * gtk_clist_get_column_widget (GtkCList *clist,
+ gint column);
+
/* set the justification on a column */
void gtk_clist_set_column_justification (GtkCList *clist,
gint column,
gint column,
gboolean auto_resize);
+gint gtk_clist_columns_autosize (GtkCList *clist);
+
/* return the optimal column width, i.e. maximum of all cell widths */
gint gtk_clist_optimal_column_width (GtkCList *clist,
gint column);
gint column,
gint max_width);
-/* change the height of the rows, the default is the hight
- * of the current font
+/* change the height of the rows, the default (height=0) is
+ * the hight of the current font.
*/
void gtk_clist_set_row_height (GtkCList *clist,
- gint height);
+ guint height);
/* scroll the viewing area of the list to the given column and row;
* row_align and col_align are between 0-1 representing the location the
gint row,
gint column);
-/* sets a given cell's text, replacing it's current contents */
+/* sets a given cell's text, replacing its current contents */
void gtk_clist_set_text (GtkCList *clist,
gint row,
gint column,
gint column,
gchar **text);
-/* sets a given cell's pixmap, replacing it's current contents */
+/* sets a given cell's pixmap, replacing its current contents */
void gtk_clist_set_pixmap (GtkCList *clist,
gint row,
gint column,
GdkPixmap **pixmap,
GdkBitmap **mask);
-/* sets a given cell's pixmap and text, replacing it's current contents */
+/* sets a given cell's pixmap and text, replacing its current contents */
void gtk_clist_set_pixtext (GtkCList *clist,
gint row,
gint column,
GdkPixmap **pixmap,
GdkBitmap **mask);
-/* sets the foreground color of a row, the colar must already
+/* sets the foreground color of a row, the color must already
* be allocated
*/
-void gtk_clist_set_foreground (GtkCList *clist,
- gint row,
- GdkColor *color);
+void gtk_clist_set_foreground (GtkCList *clist,
+ gint row,
+ const GdkColor *color);
-/* sets the background color of a row, the colar must already
+/* sets the background color of a row, the color must already
* be allocated
*/
-void gtk_clist_set_background (GtkCList *clist,
- gint row,
- GdkColor *color);
+void gtk_clist_set_background (GtkCList *clist,
+ gint row,
+ const GdkColor *color);
/* set / get cell styles */
void gtk_clist_set_cell_style (GtkCList *clist,
/* prepend/append returns the index of the row you just added,
* making it easier to append and modify a row
*/
-gint gtk_clist_prepend (GtkCList *clist,
- gchar *text[]);
-gint gtk_clist_append (GtkCList *clist,
- gchar *text[]);
+gint gtk_clist_prepend (GtkCList *clist,
+ gchar *text[]);
+gint gtk_clist_append (GtkCList *clist,
+ gchar *text[]);
/* inserts a row at index row and returns the row where it was
* actually inserted (may be different from "row" in auto_sort mode)
*/
-gint gtk_clist_insert (GtkCList *clist,
- gint row,
- gchar *text[]);
+gint gtk_clist_insert (GtkCList *clist,
+ gint row,
+ gchar *text[]);
/* removes row at index row */
void gtk_clist_remove (GtkCList *clist,
gpointer data);
/* sets a data pointer for a given row with destroy notification */
-void gtk_clist_set_row_data_full (GtkCList *clist,
- gint row,
- gpointer data,
- GtkDestroyNotify destroy);
+void gtk_clist_set_row_data_full (GtkCList *clist,
+ gint row,
+ gpointer data,
+ GDestroyNotify destroy);
/* returns the data set for a row */
gpointer gtk_clist_get_row_data (GtkCList *clist,
gint row1,
gint row2);
+/* move row from source_row position to dest_row position */
+void gtk_clist_row_move (GtkCList *clist,
+ gint source_row,
+ gint dest_row);
+
/* sets a compare function different to the default */
void gtk_clist_set_compare_func (GtkCList *clist,
GtkCListCompareFunc cmp_func);
void gtk_clist_set_auto_sort (GtkCList *clist,
gboolean auto_sort);
+/* Private function for clist, ctree */
-/* Deprecated methods */
+PangoLayout *_gtk_clist_create_cell_layout (GtkCList *clist,
+ GtkCListRow *clist_row,
+ gint column);
-/* Use gtk_clist_set_shadow_type instead. */
-void gtk_clist_set_border (GtkCList *clist,
- GtkShadowType border);
-/* Completely non-functional */
-void gtk_clist_set_policy (GtkCList *clist,
- GtkPolicyType vscrollbar_policy,
- GtkPolicyType hscrollbar_policy);
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
+G_END_DECLS
+
#endif /* __GTK_CLIST_H__ */
+
+#endif /* GTK_DISABLE_DEPRECATED */