gtkcellrenderer.h 17.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* gtkcellrenderer.h
 * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb@redhat.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library 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.
 *
 * You should have received a copy of the GNU Library General Public
Javier Jardón's avatar
Javier Jardón committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 17
 */

18 19 20
#ifndef __GTK_CELL_RENDERER_H__
#define __GTK_CELL_RENDERER_H__

21
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22 23 24
#error "Only <gtk/gtk.h> can be included directly."
#endif

25
#include <gtk/gtkcelleditable.h>
26

27
G_BEGIN_DECLS
28

29 30 31 32 33 34 35 36 37

/**
 * GtkCellRendererState:
 * @GTK_CELL_RENDERER_SELECTED: The cell is currently selected, and
 *  probably has a selection colored background to render to.
 * @GTK_CELL_RENDERER_PRELIT: The mouse is hovering over the cell.
 * @GTK_CELL_RENDERER_INSENSITIVE: The cell is drawn in an insensitive manner
 * @GTK_CELL_RENDERER_SORTED: The cell is in a sorted row
 * @GTK_CELL_RENDERER_FOCUSED: The cell is in the focus row.
38 39
 * @GTK_CELL_RENDERER_EXPANDABLE: The cell is in a row that can be expanded. Since 3.4
 * @GTK_CELL_RENDERER_EXPANDED: The cell is in a row that is expanded. Since 3.4
40
 *
Matthias Clasen's avatar
Matthias Clasen committed
41
 * Tells how a cell is to be rendered.
42
 */
43 44
typedef enum
{
Havoc Pennington's avatar
Havoc Pennington committed
45 46
  GTK_CELL_RENDERER_SELECTED    = 1 << 0,
  GTK_CELL_RENDERER_PRELIT      = 1 << 1,
47 48
  GTK_CELL_RENDERER_INSENSITIVE = 1 << 2,
  /* this flag means the cell is in the sort column/row */
49
  GTK_CELL_RENDERER_SORTED      = 1 << 3,
50 51 52
  GTK_CELL_RENDERER_FOCUSED     = 1 << 4,
  GTK_CELL_RENDERER_EXPANDABLE  = 1 << 5,
  GTK_CELL_RENDERER_EXPANDED    = 1 << 6
Havoc Pennington's avatar
Havoc Pennington committed
53
} GtkCellRendererState;
54

55 56 57
/**
 * GtkCellRendererMode:
 * @GTK_CELL_RENDERER_MODE_INERT: The cell is just for display
58 59
 *  and cannot be interacted with.  Note that this doesn’t mean that eg. the
 *  row being drawn can’t be selected -- just that a particular element of
60 61 62 63 64 65
 *  it cannot be individually modified.
 * @GTK_CELL_RENDERER_MODE_ACTIVATABLE: The cell can be clicked.
 * @GTK_CELL_RENDERER_MODE_EDITABLE: The cell can be edited or otherwise modified.
 *
 * Identifies how the user can interact with a particular cell.
 */
66 67 68 69
typedef enum
{
  GTK_CELL_RENDERER_MODE_INERT,
  GTK_CELL_RENDERER_MODE_ACTIVATABLE,
70
  GTK_CELL_RENDERER_MODE_EDITABLE
71 72
} GtkCellRendererMode;

73
#define GTK_TYPE_CELL_RENDERER		  (gtk_cell_renderer_get_type ())
Manish Singh's avatar
Manish Singh committed
74 75 76 77 78
#define GTK_CELL_RENDERER(obj)		  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_RENDERER, GtkCellRenderer))
#define GTK_CELL_RENDERER_CLASS(klass)	  (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_RENDERER, GtkCellRendererClass))
#define GTK_IS_CELL_RENDERER(obj)	  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_RENDERER))
#define GTK_IS_CELL_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER))
#define GTK_CELL_RENDERER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER, GtkCellRendererClass))
79

80 81 82
typedef struct _GtkCellRenderer              GtkCellRenderer;
typedef struct _GtkCellRendererPrivate       GtkCellRendererPrivate;
typedef struct _GtkCellRendererClass         GtkCellRendererClass;
83
typedef struct _GtkCellRendererClassPrivate  GtkCellRendererClassPrivate;
84 85 86

struct _GtkCellRenderer
{
87
  GInitiallyUnowned parent_instance;
88

89
  /*< private >*/
90
  GtkCellRendererPrivate *priv;
91 92
};

93 94 95 96
/**
 * GtkCellRendererClass:
 * @get_request_mode: Called to gets whether the cell renderer prefers
 *    a height-for-width layout or a width-for-height layout.
97 98 99 100
 * @get_preferred_width: Called to get a renderer’s natural width.
 * @get_preferred_height_for_width: Called to get a renderer’s natural height for width.
 * @get_preferred_height: Called to get a renderer’s natural height.
 * @get_preferred_width_for_height: Called to get a renderer’s natural width for height.
101 102 103 104 105 106 107 108
 * @get_aligned_area: Called to get the aligned area used by @cell inside @cell_area.
 * @get_size: Called to get the width and height needed to render the cell. Deprecated: 3.0.
 * @render: Called to render the content of the #GtkCellRenderer.
 * @activate: Called to activate the content of the #GtkCellRenderer.
 * @start_editing: Called to initiate editing the content of the #GtkCellRenderer.
 * @editing_canceled: Signal gets emitted when the user cancels the process of editing a cell.
 * @editing_started: Signal gets emitted when a cell starts to be edited.
 */
109 110
struct _GtkCellRendererClass
{
111
  /*< private >*/
112
  GInitiallyUnownedClass parent_class;
113

114 115
  /*< public >*/

116
  /* vtable - not signals */
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
  GtkSizeRequestMode (* get_request_mode)                (GtkCellRenderer      *cell);
  void               (* get_preferred_width)             (GtkCellRenderer      *cell,
                                                          GtkWidget            *widget,
                                                          gint                 *minimum_size,
                                                          gint                 *natural_size);
  void               (* get_preferred_height_for_width)  (GtkCellRenderer      *cell,
                                                          GtkWidget            *widget,
                                                          gint                  width,
                                                          gint                 *minimum_height,
                                                          gint                 *natural_height);
  void               (* get_preferred_height)            (GtkCellRenderer      *cell,
                                                          GtkWidget            *widget,
                                                          gint                 *minimum_size,
                                                          gint                 *natural_size);
  void               (* get_preferred_width_for_height)  (GtkCellRenderer      *cell,
                                                          GtkWidget            *widget,
                                                          gint                  height,
                                                          gint                 *minimum_width,
                                                          gint                 *natural_width);
136 137 138 139 140
  void               (* get_aligned_area)                (GtkCellRenderer      *cell,
                                                          GtkWidget            *widget,
							  GtkCellRendererState  flags,
                                                          const GdkRectangle   *cell_area,
                                                          GdkRectangle         *aligned_area);
141 142
  void               (* get_size)                        (GtkCellRenderer      *cell,
                                                          GtkWidget            *widget,
143
                                                          const GdkRectangle   *cell_area,
144 145 146 147 148 149 150 151 152 153 154 155 156 157
                                                          gint                 *x_offset,
                                                          gint                 *y_offset,
                                                          gint                 *width,
                                                          gint                 *height);
  void               (* render)                          (GtkCellRenderer      *cell,
                                                          cairo_t              *cr,
                                                          GtkWidget            *widget,
                                                          const GdkRectangle   *background_area,
                                                          const GdkRectangle   *cell_area,
                                                          GtkCellRendererState  flags);
  gboolean           (* activate)                        (GtkCellRenderer      *cell,
                                                          GdkEvent             *event,
                                                          GtkWidget            *widget,
                                                          const gchar          *path,
158 159
                                                          const GdkRectangle   *background_area,
                                                          const GdkRectangle   *cell_area,
160 161 162 163 164
                                                          GtkCellRendererState  flags);
  GtkCellEditable *  (* start_editing)                   (GtkCellRenderer      *cell,
                                                          GdkEvent             *event,
                                                          GtkWidget            *widget,
                                                          const gchar          *path,
165 166
                                                          const GdkRectangle   *background_area,
                                                          const GdkRectangle   *cell_area,
167
                                                          GtkCellRendererState  flags);
168

Federico Mena Quintero's avatar
Federico Mena Quintero committed
169 170
  /* Signals */
  void (* editing_canceled) (GtkCellRenderer *cell);
171 172 173
  void (* editing_started)  (GtkCellRenderer *cell,
			     GtkCellEditable *editable,
			     const gchar     *path);
Federico Mena Quintero's avatar
Federico Mena Quintero committed
174

175 176
  /*< private >*/

177 178
  GtkCellRendererClassPrivate *priv;

179 180
  /* Padding for future expansion */
  void (*_gtk_reserved2) (void);
181 182
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
183 184
};

185
GDK_AVAILABLE_IN_ALL
186 187
GType              gtk_cell_renderer_get_type       (void) G_GNUC_CONST;

188
GDK_AVAILABLE_IN_ALL
189
GtkSizeRequestMode gtk_cell_renderer_get_request_mode               (GtkCellRenderer    *cell);
190
GDK_AVAILABLE_IN_ALL
191 192 193 194
void               gtk_cell_renderer_get_preferred_width            (GtkCellRenderer    *cell,
                                                                     GtkWidget          *widget,
                                                                     gint               *minimum_size,
                                                                     gint               *natural_size);
195
GDK_AVAILABLE_IN_ALL
196 197 198 199 200
void               gtk_cell_renderer_get_preferred_height_for_width (GtkCellRenderer    *cell,
                                                                     GtkWidget          *widget,
                                                                     gint                width,
                                                                     gint               *minimum_height,
                                                                     gint               *natural_height);
201
GDK_AVAILABLE_IN_ALL
202 203 204 205
void               gtk_cell_renderer_get_preferred_height           (GtkCellRenderer    *cell,
                                                                     GtkWidget          *widget,
                                                                     gint               *minimum_size,
                                                                     gint               *natural_size);
206
GDK_AVAILABLE_IN_ALL
207 208 209 210 211
void               gtk_cell_renderer_get_preferred_width_for_height (GtkCellRenderer    *cell,
                                                                     GtkWidget          *widget,
                                                                     gint                height,
                                                                     gint               *minimum_width,
                                                                     gint               *natural_width);
212
GDK_AVAILABLE_IN_ALL
213 214 215 216
void               gtk_cell_renderer_get_preferred_size             (GtkCellRenderer    *cell,
                                                                     GtkWidget          *widget,
                                                                     GtkRequisition     *minimum_size,
                                                                     GtkRequisition     *natural_size);
217
GDK_AVAILABLE_IN_ALL
218 219 220 221 222 223
void               gtk_cell_renderer_get_aligned_area               (GtkCellRenderer    *cell,
								     GtkWidget          *widget,
								     GtkCellRendererState flags,
								     const GdkRectangle *cell_area,
								     GdkRectangle       *aligned_area);

224
GDK_DEPRECATED_IN_3_0_FOR(gtk_cell_renderer_get_preferred_size)
225
void             gtk_cell_renderer_get_size       (GtkCellRenderer      *cell,
226 227 228 229 230 231
                                                   GtkWidget            *widget,
                                                   const GdkRectangle   *cell_area,
                                                   gint                 *x_offset,
                                                   gint                 *y_offset,
                                                   gint                 *width,
                                                   gint                 *height);
232
GDK_AVAILABLE_IN_ALL
233
void             gtk_cell_renderer_render         (GtkCellRenderer      *cell,
234 235 236 237 238
                                                   cairo_t              *cr,
						   GtkWidget            *widget,
						   const GdkRectangle   *background_area,
						   const GdkRectangle   *cell_area,
						   GtkCellRendererState  flags);
239
GDK_AVAILABLE_IN_ALL
240 241 242
gboolean         gtk_cell_renderer_activate       (GtkCellRenderer      *cell,
						   GdkEvent             *event,
						   GtkWidget            *widget,
243
						   const gchar          *path,
244 245
						   const GdkRectangle   *background_area,
						   const GdkRectangle   *cell_area,
246
						   GtkCellRendererState  flags);
247
GDK_AVAILABLE_IN_ALL
248 249 250
GtkCellEditable *gtk_cell_renderer_start_editing  (GtkCellRenderer      *cell,
						   GdkEvent             *event,
						   GtkWidget            *widget,
251
						   const gchar          *path,
252 253
						   const GdkRectangle   *background_area,
						   const GdkRectangle   *cell_area,
254
						   GtkCellRendererState  flags);
255

256
GDK_AVAILABLE_IN_ALL
257 258 259
void             gtk_cell_renderer_set_fixed_size (GtkCellRenderer      *cell,
						   gint                  width,
						   gint                  height);
260
GDK_AVAILABLE_IN_ALL
261 262 263 264
void             gtk_cell_renderer_get_fixed_size (GtkCellRenderer      *cell,
						   gint                 *width,
						   gint                 *height);

265
GDK_AVAILABLE_IN_ALL
266 267 268
void             gtk_cell_renderer_set_alignment  (GtkCellRenderer      *cell,
                                                   gfloat                xalign,
                                                   gfloat                yalign);
269
GDK_AVAILABLE_IN_ALL
270 271 272 273
void             gtk_cell_renderer_get_alignment  (GtkCellRenderer      *cell,
                                                   gfloat               *xalign,
                                                   gfloat               *yalign);

274
GDK_AVAILABLE_IN_ALL
275 276 277
void             gtk_cell_renderer_set_padding    (GtkCellRenderer      *cell,
                                                   gint                  xpad,
                                                   gint                  ypad);
278
GDK_AVAILABLE_IN_ALL
279 280 281 282
void             gtk_cell_renderer_get_padding    (GtkCellRenderer      *cell,
                                                   gint                 *xpad,
                                                   gint                 *ypad);

283
GDK_AVAILABLE_IN_ALL
284 285
void             gtk_cell_renderer_set_visible    (GtkCellRenderer      *cell,
                                                   gboolean              visible);
286
GDK_AVAILABLE_IN_ALL
287 288
gboolean         gtk_cell_renderer_get_visible    (GtkCellRenderer      *cell);

289
GDK_AVAILABLE_IN_ALL
290 291
void             gtk_cell_renderer_set_sensitive  (GtkCellRenderer      *cell,
                                                   gboolean              sensitive);
292
GDK_AVAILABLE_IN_ALL
293 294
gboolean         gtk_cell_renderer_get_sensitive  (GtkCellRenderer      *cell);

295
GDK_AVAILABLE_IN_ALL
296
gboolean         gtk_cell_renderer_is_activatable (GtkCellRenderer      *cell);
297

Federico Mena Quintero's avatar
Federico Mena Quintero committed
298
/* For use by cell renderer implementations only */
299
GDK_AVAILABLE_IN_ALL
300 301
void             gtk_cell_renderer_stop_editing   (GtkCellRenderer      *cell,
                                                   gboolean              canceled);
Federico Mena Quintero's avatar
Federico Mena Quintero committed
302

303

304
void            _gtk_cell_renderer_calc_offset    (GtkCellRenderer      *cell,
305 306 307 308 309 310
                                                   const GdkRectangle   *cell_area,
                                                   GtkTextDirection      direction,
                                                   gint                  width,
                                                   gint                  height,
                                                   gint                 *x_offset,
                                                   gint                 *y_offset);
311

312
GDK_AVAILABLE_IN_ALL
313 314 315 316
GtkStateFlags   gtk_cell_renderer_get_state       (GtkCellRenderer      *cell,
                                                   GtkWidget            *widget,
                                                   GtkCellRendererState  cell_state);

317
GDK_AVAILABLE_IN_ALL
318
void            gtk_cell_renderer_class_set_accessible_type 
319 320 321 322 323
                                                  (GtkCellRendererClass *renderer_class,
                                                   GType                 type);
GType           _gtk_cell_renderer_get_accessible_type
                                                  (GtkCellRenderer *     renderer);

324
G_END_DECLS
325 326

#endif /* __GTK_CELL_RENDERER_H__ */