1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- * 2 * gtksourcegutterrenderer.h 3 * This file is part of GtkSourceView 4 * 5 * Copyright (C) 2010 - Jesse van den Kieboom 6 * 7 * GtkSourceView is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * GtkSourceView is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef GTK_SOURCE_GUTTER_RENDERER_H 23 #define GTK_SOURCE_GUTTER_RENDERER_H 24 25 #if !defined (GTK_SOURCE_H_INSIDE) && !defined (GTK_SOURCE_COMPILATION) 26 # if defined (__GNUC__) 27 # warning "Only <gtksourceview/gtksource.h> can be included directly." 28 # elif defined (G_OS_WIN32) 29 # pragma message("Only <gtksourceview/gtksource.h> can be included directly.") 30 # endif 31 #endif 32 33 #include <gtk/gtk.h> 34 #include <gtksourceview/gtksourcetypes.h> 35 36 G_BEGIN_DECLS 37 38 #define GTK_SOURCE_TYPE_GUTTER_RENDERER (gtk_source_gutter_renderer_get_type ()) 39 #define GTK_SOURCE_GUTTER_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_SOURCE_TYPE_GUTTER_RENDERER, GtkSourceGutterRenderer)) 40 #define GTK_SOURCE_GUTTER_RENDERER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_SOURCE_TYPE_GUTTER_RENDERER, GtkSourceGutterRenderer const)) 41 #define GTK_SOURCE_GUTTER_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_SOURCE_TYPE_GUTTER_RENDERER, GtkSourceGutterRendererClass)) 42 #define GTK_SOURCE_IS_GUTTER_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_SOURCE_TYPE_GUTTER_RENDERER)) 43 #define GTK_SOURCE_IS_GUTTER_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_SOURCE_TYPE_GUTTER_RENDERER)) 44 #define GTK_SOURCE_GUTTER_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_SOURCE_TYPE_GUTTER_RENDERER, GtkSourceGutterRendererClass)) 45 46 typedef struct _GtkSourceGutterRendererClass GtkSourceGutterRendererClass; 47 typedef struct _GtkSourceGutterRendererPrivate GtkSourceGutterRendererPrivate; 48 49 /** 50 * GtkSourceGutterRendererState: 51 * @GTK_SOURCE_GUTTER_RENDERER_STATE_NORMAL: normal state 52 * @GTK_SOURCE_GUTTER_RENDERER_STATE_CURSOR: area in the renderer represents the 53 * line on which the insert cursor is currently positioned 54 * @GTK_SOURCE_GUTTER_RENDERER_STATE_PRELIT: the mouse pointer is currently 55 * over the activatable area of the renderer 56 * @GTK_SOURCE_GUTTER_RENDERER_STATE_SELECTED: area in the renderer represents 57 * a line in the buffer which contains part of the selection 58 **/ 59 typedef enum _GtkSourceGutterRendererState 60 { 61 GTK_SOURCE_GUTTER_RENDERER_STATE_NORMAL = 0, 62 GTK_SOURCE_GUTTER_RENDERER_STATE_CURSOR = 1 << 0, 63 GTK_SOURCE_GUTTER_RENDERER_STATE_PRELIT = 1 << 1, 64 GTK_SOURCE_GUTTER_RENDERER_STATE_SELECTED = 1 << 2 65 } GtkSourceGutterRendererState; 66 67 /** 68 * GtkSourceGutterRendererAlignmentMode: 69 * @GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_CELL: The full cell. 70 * @GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_FIRST: The first line. 71 * @GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_LAST: The last line. 72 * 73 * The alignment mode of the renderer, when a cell spans multiple lines (due to 74 * text wrapping). 75 **/ 76 typedef enum _GtkSourceGutterRendererAlignmentMode 77 { 78 GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_CELL, 79 GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_FIRST, 80 GTK_SOURCE_GUTTER_RENDERER_ALIGNMENT_MODE_LAST 81 } GtkSourceGutterRendererAlignmentMode; 82 83 struct _GtkSourceGutterRenderer 84 { 85 GInitiallyUnowned parent; 86 87 /*< private >*/ 88 GtkSourceGutterRendererPrivate *priv; 89 }; 90 91 struct _GtkSourceGutterRendererClass 92 { 93 GInitiallyUnownedClass parent_class; 94 95 /*< public >*/ 96 void (*begin) (GtkSourceGutterRenderer *renderer, 97 cairo_t *cr, 98 GdkRectangle *background_area, 99 GdkRectangle *cell_area, 100 GtkTextIter *start, 101 GtkTextIter *end); 102 103 void (*draw) (GtkSourceGutterRenderer *renderer, 104 cairo_t *cr, 105 GdkRectangle *background_area, 106 GdkRectangle *cell_area, 107 GtkTextIter *start, 108 GtkTextIter *end, 109 GtkSourceGutterRendererState state); 110 111 void (*end) (GtkSourceGutterRenderer *renderer); 112 113 /** 114 * GtkSourceGutterRendererClass::change_view: 115 * @renderer: a #GtkSourceGutterRenderer. 116 * @old_view: (nullable): the old #GtkTextView. 117 * 118 * This is called when the text view changes for @renderer. 119 */ 120 void (*change_view) (GtkSourceGutterRenderer *renderer, 121 GtkTextView *old_view); 122 123 /** 124 * GtkSourceGutterRendererClass::change_buffer: 125 * @renderer: a #GtkSourceGutterRenderer. 126 * @old_buffer: (nullable): the old #GtkTextBuffer. 127 * 128 * This is called when the text buffer changes for @renderer. 129 */ 130 void (*change_buffer) (GtkSourceGutterRenderer *renderer, 131 GtkTextBuffer *old_buffer); 132 133 /* Signal handlers */ 134 gboolean (*query_activatable) (GtkSourceGutterRenderer *renderer, 135 GtkTextIter *iter, 136 GdkRectangle *area, 137 GdkEvent *event); 138 139 void (*activate) (GtkSourceGutterRenderer *renderer, 140 GtkTextIter *iter, 141 GdkRectangle *area, 142 GdkEvent *event); 143 144 void (*queue_draw) (GtkSourceGutterRenderer *renderer); 145 146 gboolean (*query_tooltip) (GtkSourceGutterRenderer *renderer, 147 GtkTextIter *iter, 148 GdkRectangle *area, 149 gint x, 150 gint y, 151 GtkTooltip *tooltip); 152 153 void (*query_data) (GtkSourceGutterRenderer *renderer, 154 GtkTextIter *start, 155 GtkTextIter *end, 156 GtkSourceGutterRendererState state); 157 }; 158 159 GTK_SOURCE_AVAILABLE_IN_ALL 160 GType gtk_source_gutter_renderer_get_type (void) G_GNUC_CONST; 161 162 GTK_SOURCE_AVAILABLE_IN_ALL 163 void gtk_source_gutter_renderer_begin (GtkSourceGutterRenderer *renderer, 164 cairo_t *cr, 165 GdkRectangle *background_area, 166 GdkRectangle *cell_area, 167 GtkTextIter *start, 168 GtkTextIter *end); 169 170 GTK_SOURCE_AVAILABLE_IN_ALL 171 void gtk_source_gutter_renderer_draw (GtkSourceGutterRenderer *renderer, 172 cairo_t *cr, 173 GdkRectangle *background_area, 174 GdkRectangle *cell_area, 175 GtkTextIter *start, 176 GtkTextIter *end, 177 GtkSourceGutterRendererState state); 178 179 GTK_SOURCE_AVAILABLE_IN_ALL 180 void gtk_source_gutter_renderer_end (GtkSourceGutterRenderer *renderer); 181 182 GTK_SOURCE_AVAILABLE_IN_ALL 183 gint gtk_source_gutter_renderer_get_size (GtkSourceGutterRenderer *renderer); 184 185 GTK_SOURCE_AVAILABLE_IN_ALL 186 void gtk_source_gutter_renderer_set_size (GtkSourceGutterRenderer *renderer, 187 gint size); 188 189 GTK_SOURCE_AVAILABLE_IN_ALL 190 void gtk_source_gutter_renderer_set_visible (GtkSourceGutterRenderer *renderer, 191 gboolean visible); 192 193 GTK_SOURCE_AVAILABLE_IN_ALL 194 gboolean gtk_source_gutter_renderer_get_visible (GtkSourceGutterRenderer *renderer); 195 196 GTK_SOURCE_AVAILABLE_IN_ALL 197 void gtk_source_gutter_renderer_get_padding (GtkSourceGutterRenderer *renderer, 198 gint *xpad, 199 gint *ypad); 200 201 GTK_SOURCE_AVAILABLE_IN_ALL 202 void gtk_source_gutter_renderer_set_padding (GtkSourceGutterRenderer *renderer, 203 gint xpad, 204 gint ypad); 205 206 GTK_SOURCE_AVAILABLE_IN_ALL 207 void gtk_source_gutter_renderer_get_alignment (GtkSourceGutterRenderer *renderer, 208 gfloat *xalign, 209 gfloat *yalign); 210 211 GTK_SOURCE_AVAILABLE_IN_ALL 212 void gtk_source_gutter_renderer_set_alignment (GtkSourceGutterRenderer *renderer, 213 gfloat xalign, 214 gfloat yalign); 215 216 GTK_SOURCE_AVAILABLE_IN_ALL 217 void gtk_source_gutter_renderer_set_alignment_mode (GtkSourceGutterRenderer *renderer, 218 GtkSourceGutterRendererAlignmentMode mode); 219 220 GTK_SOURCE_AVAILABLE_IN_ALL 221 GtkTextWindowType 222 gtk_source_gutter_renderer_get_window_type (GtkSourceGutterRenderer *renderer); 223 224 GTK_SOURCE_AVAILABLE_IN_ALL 225 GtkTextView *gtk_source_gutter_renderer_get_view (GtkSourceGutterRenderer *renderer); 226 227 GTK_SOURCE_AVAILABLE_IN_ALL 228 GtkSourceGutterRendererAlignmentMode 229 gtk_source_gutter_renderer_get_alignment_mode (GtkSourceGutterRenderer *renderer); 230 231 GTK_SOURCE_AVAILABLE_IN_ALL 232 gboolean gtk_source_gutter_renderer_get_background (GtkSourceGutterRenderer *renderer, 233 GdkRGBA *color); 234 235 GTK_SOURCE_AVAILABLE_IN_ALL 236 void gtk_source_gutter_renderer_set_background (GtkSourceGutterRenderer *renderer, 237 const GdkRGBA *color); 238 239 /* Emits the 'activate' signal */ 240 GTK_SOURCE_AVAILABLE_IN_ALL 241 void gtk_source_gutter_renderer_activate (GtkSourceGutterRenderer *renderer, 242 GtkTextIter *iter, 243 GdkRectangle *area, 244 GdkEvent *event); 245 246 /* Emits the 'query-activatable' signal */ 247 GTK_SOURCE_AVAILABLE_IN_ALL 248 gboolean gtk_source_gutter_renderer_query_activatable (GtkSourceGutterRenderer *renderer, 249 GtkTextIter *iter, 250 GdkRectangle *area, 251 GdkEvent *event); 252 253 /* Emits the 'queue-draw' signal */ 254 GTK_SOURCE_AVAILABLE_IN_ALL 255 void gtk_source_gutter_renderer_queue_draw (GtkSourceGutterRenderer *renderer); 256 257 /* Emits the 'query-tooltip' signal */ 258 GTK_SOURCE_AVAILABLE_IN_ALL 259 gboolean gtk_source_gutter_renderer_query_tooltip (GtkSourceGutterRenderer *renderer, 260 GtkTextIter *iter, 261 GdkRectangle *area, 262 gint x, 263 gint y, 264 GtkTooltip *tooltip); 265 266 /* Emits the 'query-data' signal */ 267 GTK_SOURCE_AVAILABLE_IN_ALL 268 void gtk_source_gutter_renderer_query_data (GtkSourceGutterRenderer *renderer, 269 GtkTextIter *start, 270 GtkTextIter *end, 271 GtkSourceGutterRendererState state); 272 273 G_END_DECLS 274 275 #endif /* GTK_SOURCE_GUTTER_RENDERER_H */ 276