1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD 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 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gsv.SourceGutterRenderer; 26 27 private import cairo.Context; 28 private import gdk.Event; 29 private import gdk.RGBA; 30 private import glib.MemorySlice; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gsv.c.functions; 34 public import gsv.c.types; 35 public import gsvc.gsvtypes; 36 private import gtk.TextIter; 37 private import gtk.TextView; 38 private import gtk.Tooltip; 39 private import std.algorithm; 40 41 42 /** */ 43 public class SourceGutterRenderer : ObjectG 44 { 45 /** the main Gtk struct */ 46 protected GtkSourceGutterRenderer* gtkSourceGutterRenderer; 47 48 /** Get the main Gtk struct */ 49 public GtkSourceGutterRenderer* getSourceGutterRendererStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return gtkSourceGutterRenderer; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)gtkSourceGutterRenderer; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (GtkSourceGutterRenderer* gtkSourceGutterRenderer, bool ownedRef = false) 66 { 67 this.gtkSourceGutterRenderer = gtkSourceGutterRenderer; 68 super(cast(GObject*)gtkSourceGutterRenderer, ownedRef); 69 } 70 71 72 /** */ 73 public static GType getType() 74 { 75 return gtk_source_gutter_renderer_get_type(); 76 } 77 78 /** 79 * Emits the #GtkSourceGutterRenderer::activate signal of the renderer. This is 80 * called from #GtkSourceGutter and should never have to be called manually. 81 * 82 * Params: 83 * iter = a #GtkTextIter at the start of the line where the renderer is activated 84 * area = a #GdkRectangle of the cell area where the renderer is activated 85 * event = the event that triggered the activation 86 */ 87 public void activate(TextIter iter, GdkRectangle* area, Event event) 88 { 89 gtk_source_gutter_renderer_activate(gtkSourceGutterRenderer, (iter is null) ? null : iter.getTextIterStruct(), area, (event is null) ? null : event.getEventStruct()); 90 } 91 92 /** 93 * Called when drawing a region begins. The region to be drawn is indicated 94 * by @start and @end. The purpose is to allow the implementation to precompute 95 * some state before the draw method is called for each cell. 96 * 97 * Params: 98 * cr = a #cairo_t 99 * backgroundArea = a #GdkRectangle 100 * cellArea = a #GdkRectangle 101 * start = a #GtkTextIter 102 * end = a #GtkTextIter 103 */ 104 public void begin(Context cr, GdkRectangle* backgroundArea, GdkRectangle* cellArea, TextIter start, TextIter end) 105 { 106 gtk_source_gutter_renderer_begin(gtkSourceGutterRenderer, (cr is null) ? null : cr.getContextStruct(), backgroundArea, cellArea, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct()); 107 } 108 109 /** 110 * Main renderering method. Implementations should implement this method to draw 111 * onto the cairo context. The @background_area indicates the total area of the 112 * cell to be drawn. The @cell_area indicates the area where content can be 113 * drawn (text, images, etc). 114 * 115 * The @background_area is the @cell_area plus the padding on each side (two 116 * times the #GtkSourceGutterRenderer:xpad horizontally and two times the 117 * #GtkSourceGutterRenderer:ypad vertically, so that the @cell_area is centered 118 * inside @background_area). 119 * 120 * The @state argument indicates the current state of the renderer and should 121 * be taken into account to properly draw the different possible states 122 * (cursor, prelit, selected) if appropriate. 123 * 124 * Params: 125 * cr = the cairo render context 126 * backgroundArea = a #GdkRectangle indicating the total area to be drawn 127 * cellArea = a #GdkRectangle indicating the area to draw content 128 * start = a #GtkTextIter 129 * end = a #GtkTextIter 130 * state = a #GtkSourceGutterRendererState 131 */ 132 public void draw(Context cr, GdkRectangle* backgroundArea, GdkRectangle* cellArea, TextIter start, TextIter end, GtkSourceGutterRendererState state) 133 { 134 gtk_source_gutter_renderer_draw(gtkSourceGutterRenderer, (cr is null) ? null : cr.getContextStruct(), backgroundArea, cellArea, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), state); 135 } 136 137 /** 138 * Called when drawing a region of lines has ended. 139 */ 140 public void end() 141 { 142 gtk_source_gutter_renderer_end(gtkSourceGutterRenderer); 143 } 144 145 /** 146 * Get the x-alignment and y-alignment of the gutter renderer. 147 * 148 * Params: 149 * xalign = return location for the x-alignment, 150 * or %NULL to ignore. 151 * yalign = return location for the y-alignment, 152 * or %NULL to ignore. 153 */ 154 public void getAlignment(out float xalign, out float yalign) 155 { 156 gtk_source_gutter_renderer_get_alignment(gtkSourceGutterRenderer, &xalign, &yalign); 157 } 158 159 /** 160 * Get the alignment mode. The alignment mode describes the manner in which the 161 * renderer is aligned (see :xalign and :yalign). 162 * 163 * Returns: a #GtkSourceGutterRendererAlignmentMode 164 */ 165 public GtkSourceGutterRendererAlignmentMode getAlignmentMode() 166 { 167 return gtk_source_gutter_renderer_get_alignment_mode(gtkSourceGutterRenderer); 168 } 169 170 /** 171 * Get the background color of the renderer. 172 * 173 * Params: 174 * color = return value for a #GdkRGBA 175 * 176 * Returns: %TRUE if the background color is set, %FALSE otherwise 177 */ 178 public bool getBackground(out RGBA color) 179 { 180 GdkRGBA* outcolor = sliceNew!GdkRGBA(); 181 182 auto p = gtk_source_gutter_renderer_get_background(gtkSourceGutterRenderer, outcolor) != 0; 183 184 color = ObjectG.getDObject!(RGBA)(outcolor, true); 185 186 return p; 187 } 188 189 /** 190 * Get the x-padding and y-padding of the gutter renderer. 191 * 192 * Params: 193 * xpad = return location for the x-padding, 194 * or %NULL to ignore. 195 * ypad = return location for the y-padding, 196 * or %NULL to ignore. 197 */ 198 public void getPadding(out int xpad, out int ypad) 199 { 200 gtk_source_gutter_renderer_get_padding(gtkSourceGutterRenderer, &xpad, &ypad); 201 } 202 203 /** 204 * Get the size of the renderer. 205 * 206 * Returns: the size of the renderer. 207 */ 208 public int getSize() 209 { 210 return gtk_source_gutter_renderer_get_size(gtkSourceGutterRenderer); 211 } 212 213 /** 214 * Get the view associated to the gutter renderer 215 * 216 * Returns: a #GtkTextView 217 */ 218 public TextView getView() 219 { 220 auto p = gtk_source_gutter_renderer_get_view(gtkSourceGutterRenderer); 221 222 if(p is null) 223 { 224 return null; 225 } 226 227 return ObjectG.getDObject!(TextView)(cast(GtkTextView*) p); 228 } 229 230 /** 231 * Get whether the gutter renderer is visible. 232 * 233 * Returns: %TRUE if the renderer is visible, %FALSE otherwise 234 */ 235 public bool getVisible() 236 { 237 return gtk_source_gutter_renderer_get_visible(gtkSourceGutterRenderer) != 0; 238 } 239 240 /** 241 * Get the #GtkTextWindowType associated with the gutter renderer. 242 * 243 * Returns: a #GtkTextWindowType 244 */ 245 public GtkTextWindowType getWindowType() 246 { 247 return gtk_source_gutter_renderer_get_window_type(gtkSourceGutterRenderer); 248 } 249 250 /** 251 * Get whether the renderer is activatable at the location in @event. This is 252 * called from #GtkSourceGutter to determine whether a renderer is activatable 253 * using the mouse pointer. 254 * 255 * Params: 256 * iter = a #GtkTextIter at the start of the line to be activated 257 * area = a #GdkRectangle of the cell area to be activated 258 * event = the event that triggered the query 259 * 260 * Returns: %TRUE if the renderer can be activated, %FALSE otherwise 261 */ 262 public bool queryActivatable(TextIter iter, GdkRectangle* area, Event event) 263 { 264 return gtk_source_gutter_renderer_query_activatable(gtkSourceGutterRenderer, (iter is null) ? null : iter.getTextIterStruct(), area, (event is null) ? null : event.getEventStruct()) != 0; 265 } 266 267 /** 268 * Emit the #GtkSourceGutterRenderer::query-data signal. This function is called 269 * to query for data just before rendering a cell. This is called from the 270 * #GtkSourceGutter. Implementations can override the default signal handler or 271 * can connect a signal handler externally to the 272 * #GtkSourceGutterRenderer::query-data signal. 273 * 274 * Params: 275 * start = a #GtkTextIter. 276 * end = a #GtkTextIter. 277 * state = a #GtkSourceGutterRendererState. 278 */ 279 public void queryData(TextIter start, TextIter end, GtkSourceGutterRendererState state) 280 { 281 gtk_source_gutter_renderer_query_data(gtkSourceGutterRenderer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), state); 282 } 283 284 /** 285 * Emits the #GtkSourceGutterRenderer::query-tooltip signal. This function is 286 * called from #GtkSourceGutter. Implementations can override the default signal 287 * handler or can connect to the signal externally. 288 * 289 * Params: 290 * iter = a #GtkTextIter. 291 * area = a #GdkRectangle. 292 * x = The x position of the tooltip. 293 * y = The y position of the tooltip. 294 * tooltip = a #GtkTooltip. 295 * 296 * Returns: %TRUE if the tooltip has been set, %FALSE otherwise 297 */ 298 public bool queryTooltip(TextIter iter, GdkRectangle* area, int x, int y, Tooltip tooltip) 299 { 300 return gtk_source_gutter_renderer_query_tooltip(gtkSourceGutterRenderer, (iter is null) ? null : iter.getTextIterStruct(), area, x, y, (tooltip is null) ? null : tooltip.getTooltipStruct()) != 0; 301 } 302 303 /** 304 * Emits the #GtkSourceGutterRenderer::queue-draw signal of the renderer. Call 305 * this from an implementation to inform that the renderer has changed such that 306 * it needs to redraw. 307 */ 308 public void queueDraw() 309 { 310 gtk_source_gutter_renderer_queue_draw(gtkSourceGutterRenderer); 311 } 312 313 /** 314 * Set the alignment of the gutter renderer. Both @xalign and @yalign can be 315 * -1, which means the values will not be changed (this allows changing only 316 * one of the values). 317 * 318 * @xalign is the horizontal alignment. Set to 0 for a left alignment. 1 for a 319 * right alignment. And 0.5 for centering the cells. @yalign is the vertical 320 * alignment. Set to 0 for a top alignment. 1 for a bottom alignment. 321 * 322 * Params: 323 * xalign = the x-alignment 324 * yalign = the y-alignment 325 */ 326 public void setAlignment(float xalign, float yalign) 327 { 328 gtk_source_gutter_renderer_set_alignment(gtkSourceGutterRenderer, xalign, yalign); 329 } 330 331 /** 332 * Set the alignment mode. The alignment mode describes the manner in which the 333 * renderer is aligned (see :xalign and :yalign). 334 * 335 * Params: 336 * mode = a #GtkSourceGutterRendererAlignmentMode 337 */ 338 public void setAlignmentMode(GtkSourceGutterRendererAlignmentMode mode) 339 { 340 gtk_source_gutter_renderer_set_alignment_mode(gtkSourceGutterRenderer, mode); 341 } 342 343 /** 344 * Set the background color of the renderer. If @color is set to %NULL, the 345 * renderer will not have a background color. 346 * 347 * Params: 348 * color = a #GdkRGBA or %NULL 349 */ 350 public void setBackground(RGBA color) 351 { 352 gtk_source_gutter_renderer_set_background(gtkSourceGutterRenderer, (color is null) ? null : color.getRGBAStruct()); 353 } 354 355 /** 356 * Set the padding of the gutter renderer. Both @xpad and @ypad can be 357 * -1, which means the values will not be changed (this allows changing only 358 * one of the values). 359 * 360 * @xpad is the left and right padding. @ypad is the top and bottom padding. 361 * 362 * Params: 363 * xpad = the x-padding 364 * ypad = the y-padding 365 */ 366 public void setPadding(int xpad, int ypad) 367 { 368 gtk_source_gutter_renderer_set_padding(gtkSourceGutterRenderer, xpad, ypad); 369 } 370 371 /** 372 * Sets the size of the renderer. A value of -1 specifies that the size 373 * is to be determined dynamically. 374 * 375 * Params: 376 * size = the size 377 */ 378 public void setSize(int size) 379 { 380 gtk_source_gutter_renderer_set_size(gtkSourceGutterRenderer, size); 381 } 382 383 /** 384 * Set whether the gutter renderer is visible. 385 * 386 * Params: 387 * visible = the visibility 388 */ 389 public void setVisible(bool visible) 390 { 391 gtk_source_gutter_renderer_set_visible(gtkSourceGutterRenderer, visible); 392 } 393 394 /** 395 * The ::activate signal is emitted when the renderer is 396 * activated. 397 * 398 * Params: 399 * iter = a #GtkTextIter 400 * area = a #GdkRectangle 401 * event = the event that caused the activation 402 */ 403 gulong addOnActivate(void delegate(TextIter, GdkRectangle*, Event, SourceGutterRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 404 { 405 return Signals.connect(this, "activate", dlg, connectFlags ^ ConnectFlags.SWAPPED); 406 } 407 408 /** 409 * The ::query-activatable signal is emitted when the renderer 410 * can possibly be activated. 411 * 412 * Params: 413 * iter = a #GtkTextIter 414 * area = a #GdkRectangle 415 * event = the #GdkEvent that is causing the activatable query 416 */ 417 gulong addOnQueryActivatable(bool delegate(TextIter, GdkRectangle*, Event, SourceGutterRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 418 { 419 return Signals.connect(this, "query-activatable", dlg, connectFlags ^ ConnectFlags.SWAPPED); 420 } 421 422 /** 423 * The ::query-data signal is emitted when the renderer needs 424 * to be filled with data just before a cell is drawn. This can 425 * be used by general renderer implementations to allow render 426 * data to be filled in externally. 427 * 428 * Params: 429 * start = a #GtkTextIter 430 * end = a #GtkTextIter 431 * state = the renderer state 432 */ 433 gulong addOnQueryData(void delegate(TextIter, TextIter, GtkSourceGutterRendererState, SourceGutterRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 434 { 435 return Signals.connect(this, "query-data", dlg, connectFlags ^ ConnectFlags.SWAPPED); 436 } 437 438 /** 439 * The ::query-tooltip signal is emitted when the renderer can 440 * show a tooltip. 441 * 442 * Params: 443 * iter = a #GtkTextIter 444 * area = a #GdkRectangle 445 * x = the x position (in window coordinates) 446 * y = the y position (in window coordinates) 447 * tooltip = a #GtkTooltip 448 */ 449 gulong addOnQueryTooltip(bool delegate(TextIter, GdkRectangle*, int, int, Tooltip, SourceGutterRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 450 { 451 return Signals.connect(this, "query-tooltip", dlg, connectFlags ^ ConnectFlags.SWAPPED); 452 } 453 454 /** 455 * The ::queue-draw signal is emitted when the renderer needs 456 * to be redrawn. Use gtk_source_gutter_renderer_queue_draw() 457 * to emit this signal from an implementation of the 458 * #GtkSourceGutterRenderer interface. 459 */ 460 gulong addOnQueueDraw(void delegate(SourceGutterRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 461 { 462 return Signals.connect(this, "queue-draw", dlg, connectFlags ^ ConnectFlags.SWAPPED); 463 } 464 }