]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkclist.h
Correctly select default printer when there is more than one (CUPS)
[~andy/gtk] / gtk / gtkclist.h
index 2323b3481bb2ff17239fde8bc1114086a9001e44..d97b5473ee11c7fc96a453297afaed79bad5308b 100644 (file)
@@ -3,49 +3,59 @@
  * 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_CHILD_HAS_FOCUS     = 1 << 5,
-  GTK_CLIST_ADD_MODE            = 1 << 6,
-  GTK_CLIST_AUTO_SORT           = 1 << 7,
-  GTK_CLIST_AUTO_RESIZE_BLOCKED = 1 << 8
-}; 
+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
@@ -57,25 +67,44 @@ 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_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))
 
@@ -100,23 +129,38 @@ typedef gint (*GtkCListCompareFunc) (GtkCList     *clist,
                                     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;
@@ -129,7 +173,7 @@ struct _GtkCList
   /* 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;
@@ -153,6 +197,14 @@ struct _GtkCList
   GList *undo_unselection;
   gint undo_anchor;
   
+  /* mouse buttons */
+  guint8 button_actions[5];
+
+  guint8 drag_button;
+
+  /* dnd */
+  GtkCListCellInfo click_cell;
+
   /* scroll adjustments */
   GtkAdjustment *hadjustment;
   GtkAdjustment *vadjustment;
@@ -172,6 +224,8 @@ struct _GtkCList
   
   /* focus handling */
   gint focus_row;
+
+  gint focus_header_column;
   
   /* dragging the selection */
   gint anchor;
@@ -183,15 +237,19 @@ struct _GtkCList
   GtkSortType sort_type;
   GtkCListCompareFunc compare;
   gint sort_column;
+
+  gint drag_highlight_row;
+  GtkCListDragPos drag_highlight_pos;
 };
 
 struct _GtkCListClass
 {
   GtkContainerClass parent_class;
   
-  void  (*scroll_adjustments)   (GtkCList       *clist,
-                                GtkAdjustment  *hadjustment,
-                                GtkAdjustment  *vadjustment);
+  void  (*set_scroll_adjustments) (GtkCList       *clist,
+                                  GtkAdjustment  *hadjustment,
+                                  GtkAdjustment  *vadjustment);
+  void   (*refresh)             (GtkCList       *clist);
   void   (*select_row)          (GtkCList       *clist,
                                 gint            row,
                                 gint            column,
@@ -200,6 +258,9 @@ struct _GtkCListClass
                                 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,
@@ -232,6 +293,10 @@ struct _GtkCListClass
                                 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);
@@ -253,6 +318,7 @@ struct _GtkCListClass
                                 GtkCListRow    *clist_row,
                                 gint            column,
                                 GtkRequisition *requisition);
+
 };
 
 struct _GtkCListColumn
@@ -268,10 +334,11 @@ 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
@@ -285,7 +352,7 @@ struct _GtkCListRow
   GtkStyle *style;
 
   gpointer data;
-  GtkDestroyNotify destroy;
+  GDestroyNotify destroy;
   
   guint fg_set     : 1;
   guint bg_set     : 1;
@@ -373,17 +440,12 @@ struct _GtkCell
   } u;
 };
 
-GtkType gtk_clist_get_type (void);
-
-/* constructors useful for gtk-- wrappers */
-void gtk_clist_construct (GtkCList *clist,
-                         gint      columns,
-                         const gchar *titles[]);
+GType gtk_clist_get_type (void) G_GNUC_CONST;
 
 /* create a new GtkCList */
 GtkWidget* gtk_clist_new             (gint   columns);
 GtkWidget* gtk_clist_new_with_titles (gint   columns,
-                                     const gchar *titles[]);
+                                     gchar *titles[]);
 
 /* set adjustments of clist */
 void gtk_clist_set_hadjustment (GtkCList      *clist,
@@ -403,6 +465,15 @@ void gtk_clist_set_shadow_type (GtkCList      *clist,
 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
@@ -463,6 +534,8 @@ void gtk_clist_set_column_auto_resize (GtkCList *clist,
                                       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);
@@ -509,7 +582,7 @@ GtkCellType gtk_clist_get_cell_type (GtkCList *clist,
                                     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,
@@ -523,7 +596,7 @@ gint gtk_clist_get_text (GtkCList  *clist,
                         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,
@@ -536,7 +609,7 @@ gint gtk_clist_get_pixmap (GtkCList   *clist,
                           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,
@@ -553,19 +626,19 @@ gint gtk_clist_get_pixtext (GtkCList   *clist,
                            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,
@@ -605,16 +678,16 @@ gboolean gtk_clist_get_selectable (GtkCList *clist,
  * making it easier to append and modify a row
  */
 gint gtk_clist_prepend (GtkCList    *clist,
-                       const gchar *text[]);
+                       gchar       *text[]);
 gint gtk_clist_append  (GtkCList    *clist,
-                       const gchar *text[]);
+                       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,
-                      const gchar *text[]);
+                      gchar       *text[]);
 
 /* removes row at index row */
 void gtk_clist_remove (GtkCList *clist,
@@ -626,10 +699,10 @@ void gtk_clist_set_row_data (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,
@@ -680,6 +753,11 @@ void gtk_clist_swap_rows (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);
@@ -699,15 +777,16 @@ void gtk_clist_sort (GtkCList *clist);
 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);
 
-#ifdef __cplusplus
-}
-#endif                         /* __cplusplus */
+G_END_DECLS
+
 
 #endif                         /* __GTK_CLIST_H__ */
+
+#endif /* GTK_DISABLE_DEPRECATED */