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 gobject.ObjectG; 31 private import gobject.Signals; 32 private import gsvc.gsv; 33 public import gsvc.gsvtypes; 34 private import gtk.TextIter; 35 private import gtk.TextView; 36 private import gtk.Tooltip; 37 public import gtkc.gdktypes; 38 39 40 /** */ 41 public class SourceGutterRenderer : ObjectG 42 { 43 /** the main Gtk struct */ 44 protected GtkSourceGutterRenderer* gtkSourceGutterRenderer; 45 46 /** Get the main Gtk struct */ 47 public GtkSourceGutterRenderer* getSourceGutterRendererStruct() 48 { 49 return gtkSourceGutterRenderer; 50 } 51 52 /** the main Gtk struct as a void* */ 53 protected override void* getStruct() 54 { 55 return cast(void*)gtkSourceGutterRenderer; 56 } 57 58 protected override void setStruct(GObject* obj) 59 { 60 gtkSourceGutterRenderer = cast(GtkSourceGutterRenderer*)obj; 61 super.setStruct(obj); 62 } 63 64 /** 65 * Sets our main struct and passes it to the parent class. 66 */ 67 public this (GtkSourceGutterRenderer* gtkSourceGutterRenderer, bool ownedRef = false) 68 { 69 this.gtkSourceGutterRenderer = gtkSourceGutterRenderer; 70 super(cast(GObject*)gtkSourceGutterRenderer, ownedRef); 71 } 72 73 74 /** */ 75 public static GType getType() 76 { 77 return gtk_source_gutter_renderer_get_type(); 78 } 79 80 /** 81 * Emits the #GtkSourceGutterRenderer::activate signal of the renderer. This is 82 * called from #GtkSourceGutter and should never have to be called manually. 83 * 84 * Params: 85 * iter = a #GtkTextIter at the start of the line where the renderer is activated 86 * area = a #GdkRectangle of the cell area where the renderer is activated 87 * event = the event that triggered the activation 88 */ 89 public void activate(TextIter iter, GdkRectangle* area, Event event) 90 { 91 gtk_source_gutter_renderer_activate(gtkSourceGutterRenderer, (iter is null) ? null : iter.getTextIterStruct(), area, (event is null) ? null : event.getEventStruct()); 92 } 93 94 /** 95 * Called when drawing a region begins. The region to be drawn is indicated 96 * by @start and @end. The purpose is to allow the implementation to precompute 97 * some state before the draw method is called for each cell. 98 * 99 * Params: 100 * cr = a #cairo_t 101 * backgroundArea = a #GdkRectangle 102 * cellArea = a #GdkRectangle 103 * start = a #GtkTextIter 104 * end = a #GtkTextIter 105 */ 106 public void begin(Context cr, GdkRectangle* backgroundArea, GdkRectangle* cellArea, TextIter start, TextIter end) 107 { 108 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()); 109 } 110 111 /** 112 * Main renderering method. Implementations should implement this method to draw 113 * onto the cairo context. The @background_area indicates the total area of the 114 * cell to be drawn. The @cell_area indicates the area where content can be 115 * drawn (text, images, etc). 116 * 117 * The @background_area is the @cell_area plus the padding on each side (two 118 * times the #GtkSourceGutterRenderer:xpad horizontally and two times the 119 * #GtkSourceGutterRenderer:ypad vertically, so that the @cell_area is centered 120 * inside @background_area). 121 * 122 * The @state argument indicates the current state of the renderer and should 123 * be taken into account to properly draw the different possible states 124 * (cursor, prelit, selected) if appropriate. 125 * 126 * Params: 127 * cr = the cairo render context 128 * backgroundArea = a #GdkRectangle indicating the total area to be drawn 129 * cellArea = a #GdkRectangle indicating the area to draw content 130 * start = a #GtkTextIter 131 * end = a #GtkTextIter 132 * state = a #GtkSourceGutterRendererState 133 */ 134 public void draw(Context cr, GdkRectangle* backgroundArea, GdkRectangle* cellArea, TextIter start, TextIter end, GtkSourceGutterRendererState state) 135 { 136 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); 137 } 138 139 /** 140 * Called when drawing a region of lines has ended. 141 */ 142 public void end() 143 { 144 gtk_source_gutter_renderer_end(gtkSourceGutterRenderer); 145 } 146 147 /** 148 * Get the x-alignment and y-alignment of the gutter renderer. 149 * 150 * Params: 151 * xalign = return location for the x-alignment, 152 * or %NULL to ignore. 153 * yalign = return location for the y-alignment, 154 * or %NULL to ignore. 155 */ 156 public void getAlignment(out float xalign, out float yalign) 157 { 158 gtk_source_gutter_renderer_get_alignment(gtkSourceGutterRenderer, &xalign, &yalign); 159 } 160 161 /** 162 * Get the alignment mode. The alignment mode describes the manner in which the 163 * renderer is aligned (see :xalign and :yalign). 164 * 165 * Return: a #GtkSourceGutterRendererAlignmentMode 166 */ 167 public GtkSourceGutterRendererAlignmentMode getAlignmentMode() 168 { 169 return gtk_source_gutter_renderer_get_alignment_mode(gtkSourceGutterRenderer); 170 } 171 172 /** 173 * Get the background color of the renderer. 174 * 175 * Params: 176 * color = return value for a #GdkRGBA 177 * 178 * Return: %TRUE if the background color is set, %FALSE otherwise 179 */ 180 public bool getBackground(out RGBA color) 181 { 182 GdkRGBA* outcolor = gMalloc!GdkRGBA(); 183 184 auto p = gtk_source_gutter_renderer_get_background(gtkSourceGutterRenderer, outcolor) != 0; 185 186 color = ObjectG.getDObject!(RGBA)(outcolor, true); 187 188 return p; 189 } 190 191 /** 192 * Get the x-padding and y-padding of the gutter renderer. 193 * 194 * Params: 195 * xpad = return location for the x-padding, 196 * or %NULL to ignore. 197 * ypad = return location for the y-padding, 198 * or %NULL to ignore. 199 */ 200 public void getPadding(out int xpad, out int ypad) 201 { 202 gtk_source_gutter_renderer_get_padding(gtkSourceGutterRenderer, &xpad, &ypad); 203 } 204 205 /** 206 * Get the size of the renderer. 207 * 208 * Return: the size of the renderer. 209 */ 210 public int getSize() 211 { 212 return gtk_source_gutter_renderer_get_size(gtkSourceGutterRenderer); 213 } 214 215 /** 216 * Get the view associated to the gutter renderer 217 * 218 * Return: a #GtkTextView 219 */ 220 public TextView getView() 221 { 222 auto p = gtk_source_gutter_renderer_get_view(gtkSourceGutterRenderer); 223 224 if(p is null) 225 { 226 return null; 227 } 228 229 return ObjectG.getDObject!(TextView)(cast(GtkTextView*) p); 230 } 231 232 /** 233 * Get whether the gutter renderer is visible. 234 * 235 * Return: %TRUE if the renderer is visible, %FALSE otherwise 236 */ 237 public bool getVisible() 238 { 239 return gtk_source_gutter_renderer_get_visible(gtkSourceGutterRenderer) != 0; 240 } 241 242 /** 243 * Get the #GtkTextWindowType associated with the gutter renderer. 244 * 245 * Return: a #GtkTextWindowType 246 */ 247 public GtkTextWindowType getWindowType() 248 { 249 return gtk_source_gutter_renderer_get_window_type(gtkSourceGutterRenderer); 250 } 251 252 /** 253 * Get whether the renderer is activatable at the location in @event. This is 254 * called from #GtkSourceGutter to determine whether a renderer is activatable 255 * using the mouse pointer. 256 * 257 * Params: 258 * iter = a #GtkTextIter at the start of the line to be activated 259 * area = a #GdkRectangle of the cell area to be activated 260 * event = the event that triggered the query 261 * 262 * Return: %TRUE if the renderer can be activated, %FALSE otherwise 263 */ 264 public bool queryActivatable(TextIter iter, GdkRectangle* area, Event event) 265 { 266 return gtk_source_gutter_renderer_query_activatable(gtkSourceGutterRenderer, (iter is null) ? null : iter.getTextIterStruct(), area, (event is null) ? null : event.getEventStruct()) != 0; 267 } 268 269 /** 270 * Emit the #GtkSourceGutterRenderer::query-data signal. This function is called 271 * to query for data just before rendering a cell. This is called from the 272 * #GtkSourceGutter. Implementations can override the default signal handler or 273 * can connect a signal handler externally to the 274 * #GtkSourceGutterRenderer::query-data signal. 275 * 276 * Params: 277 * start = a #GtkTextIter. 278 * end = a #GtkTextIter. 279 * state = a #GtkSourceGutterRendererState. 280 */ 281 public void queryData(TextIter start, TextIter end, GtkSourceGutterRendererState state) 282 { 283 gtk_source_gutter_renderer_query_data(gtkSourceGutterRenderer, (start is null) ? null : start.getTextIterStruct(), (end is null) ? null : end.getTextIterStruct(), state); 284 } 285 286 /** 287 * Emits the #GtkSourceGutterRenderer::query-tooltip signal. This function is 288 * called from #GtkSourceGutter. Implementations can override the default signal 289 * handler or can connect to the signal externally. 290 * 291 * Params: 292 * iter = a #GtkTextIter. 293 * area = a #GdkRectangle. 294 * x = The x position of the tooltip. 295 * y = The y position of the tooltip. 296 * tooltip = a #GtkTooltip. 297 * 298 * Return: %TRUE if the tooltip has been set, %FALSE otherwise 299 */ 300 public bool queryTooltip(TextIter iter, GdkRectangle* area, int x, int y, Tooltip tooltip) 301 { 302 return gtk_source_gutter_renderer_query_tooltip(gtkSourceGutterRenderer, (iter is null) ? null : iter.getTextIterStruct(), area, x, y, (tooltip is null) ? null : tooltip.getTooltipStruct()) != 0; 303 } 304 305 /** 306 * Emits the #GtkSourceGutterRenderer::queue-draw signal of the renderer. Call 307 * this from an implementation to inform that the renderer has changed such that 308 * it needs to redraw. 309 */ 310 public void queueDraw() 311 { 312 gtk_source_gutter_renderer_queue_draw(gtkSourceGutterRenderer); 313 } 314 315 /** 316 * Set the alignment of the gutter renderer. Both @xalign and @yalign can be 317 * -1, which means the values will not be changed (this allows changing only 318 * one of the values). 319 * 320 * @xalign is the horizontal alignment. Set to 0 for a left alignment. 1 for a 321 * right alignment. And 0.5 for centering the cells. @yalign is the vertical 322 * alignment. Set to 0 for a top alignment. 1 for a bottom alignment. 323 * 324 * Params: 325 * xalign = the x-alignment 326 * yalign = the y-alignment 327 */ 328 public void setAlignment(float xalign, float yalign) 329 { 330 gtk_source_gutter_renderer_set_alignment(gtkSourceGutterRenderer, xalign, yalign); 331 } 332 333 /** 334 * Set the alignment mode. The alignment mode describes the manner in which the 335 * renderer is aligned (see :xalign and :yalign). 336 * 337 * Params: 338 * mode = a #GtkSourceGutterRendererAlignmentMode 339 */ 340 public void setAlignmentMode(GtkSourceGutterRendererAlignmentMode mode) 341 { 342 gtk_source_gutter_renderer_set_alignment_mode(gtkSourceGutterRenderer, mode); 343 } 344 345 /** 346 * Set the background color of the renderer. If @color is set to %NULL, the 347 * renderer will not have a background color. 348 * 349 * Params: 350 * color = a #GdkRGBA or %NULL 351 */ 352 public void setBackground(RGBA color) 353 { 354 gtk_source_gutter_renderer_set_background(gtkSourceGutterRenderer, (color is null) ? null : color.getRGBAStruct()); 355 } 356 357 /** 358 * Set the padding of the gutter renderer. Both @xpad and @ypad can be 359 * -1, which means the values will not be changed (this allows changing only 360 * one of the values). 361 * 362 * @xpad is the left and right padding. @ypad is the top and bottom padding. 363 * 364 * Params: 365 * xpad = the x-padding 366 * ypad = the y-padding 367 */ 368 public void setPadding(int xpad, int ypad) 369 { 370 gtk_source_gutter_renderer_set_padding(gtkSourceGutterRenderer, xpad, ypad); 371 } 372 373 /** 374 * Sets the size of the renderer. A value of -1 specifies that the size 375 * is to be determined dynamically. 376 * 377 * Params: 378 * size = the size 379 */ 380 public void setSize(int size) 381 { 382 gtk_source_gutter_renderer_set_size(gtkSourceGutterRenderer, size); 383 } 384 385 /** 386 * Set whether the gutter renderer is visible. 387 * 388 * Params: 389 * visible = the visibility 390 */ 391 public void setVisible(bool visible) 392 { 393 gtk_source_gutter_renderer_set_visible(gtkSourceGutterRenderer, visible); 394 } 395 396 int[string] connectedSignals; 397 398 void delegate(TextIter, GdkRectangle*, Event, SourceGutterRenderer)[] onActivateListeners; 399 /** 400 * The ::activate signal is emitted when the renderer is 401 * activated. 402 * 403 * Params: 404 * iter = a #GtkTextIter 405 * area = a #GdkRectangle 406 * event = the event that caused the activation 407 */ 408 void addOnActivate(void delegate(TextIter, GdkRectangle*, Event, SourceGutterRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 409 { 410 if ( "activate" !in connectedSignals ) 411 { 412 Signals.connectData( 413 this, 414 "activate", 415 cast(GCallback)&callBackActivate, 416 cast(void*)this, 417 null, 418 connectFlags); 419 connectedSignals["activate"] = 1; 420 } 421 onActivateListeners ~= dlg; 422 } 423 extern(C) static void callBackActivate(GtkSourceGutterRenderer* sourcegutterrendererStruct, GtkTextIter* iter, GdkRectangle* area, GdkEvent* event, SourceGutterRenderer _sourcegutterrenderer) 424 { 425 foreach ( void delegate(TextIter, GdkRectangle*, Event, SourceGutterRenderer) dlg; _sourcegutterrenderer.onActivateListeners ) 426 { 427 dlg(ObjectG.getDObject!(TextIter)(iter), area, ObjectG.getDObject!(Event)(event), _sourcegutterrenderer); 428 } 429 } 430 431 bool delegate(TextIter, GdkRectangle*, Event, SourceGutterRenderer)[] onQueryActivatableListeners; 432 /** 433 * The ::query-activatable signal is emitted when the renderer 434 * can possibly be activated. 435 * 436 * Params: 437 * iter = a #GtkTextIter 438 * area = a #GdkRectangle 439 * event = the #GdkEvent that is causing the activatable query 440 */ 441 void addOnQueryActivatable(bool delegate(TextIter, GdkRectangle*, Event, SourceGutterRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 442 { 443 if ( "query-activatable" !in connectedSignals ) 444 { 445 Signals.connectData( 446 this, 447 "query-activatable", 448 cast(GCallback)&callBackQueryActivatable, 449 cast(void*)this, 450 null, 451 connectFlags); 452 connectedSignals["query-activatable"] = 1; 453 } 454 onQueryActivatableListeners ~= dlg; 455 } 456 extern(C) static int callBackQueryActivatable(GtkSourceGutterRenderer* sourcegutterrendererStruct, GtkTextIter* iter, GdkRectangle* area, GdkEvent* event, SourceGutterRenderer _sourcegutterrenderer) 457 { 458 foreach ( bool delegate(TextIter, GdkRectangle*, Event, SourceGutterRenderer) dlg; _sourcegutterrenderer.onQueryActivatableListeners ) 459 { 460 if ( dlg(ObjectG.getDObject!(TextIter)(iter), area, ObjectG.getDObject!(Event)(event), _sourcegutterrenderer) ) 461 { 462 return 1; 463 } 464 } 465 466 return 0; 467 } 468 469 void delegate(TextIter, TextIter, GtkSourceGutterRendererState, SourceGutterRenderer)[] onQueryDataListeners; 470 /** 471 * The ::query-data signal is emitted when the renderer needs 472 * to be filled with data just before a cell is drawn. This can 473 * be used by general renderer implementations to allow render 474 * data to be filled in externally. 475 * 476 * Params: 477 * start = a #GtkTextIter 478 * end = a #GtkTextIter 479 * state = the renderer state 480 */ 481 void addOnQueryData(void delegate(TextIter, TextIter, GtkSourceGutterRendererState, SourceGutterRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 482 { 483 if ( "query-data" !in connectedSignals ) 484 { 485 Signals.connectData( 486 this, 487 "query-data", 488 cast(GCallback)&callBackQueryData, 489 cast(void*)this, 490 null, 491 connectFlags); 492 connectedSignals["query-data"] = 1; 493 } 494 onQueryDataListeners ~= dlg; 495 } 496 extern(C) static void callBackQueryData(GtkSourceGutterRenderer* sourcegutterrendererStruct, GtkTextIter* start, GtkTextIter* end, GtkSourceGutterRendererState state, SourceGutterRenderer _sourcegutterrenderer) 497 { 498 foreach ( void delegate(TextIter, TextIter, GtkSourceGutterRendererState, SourceGutterRenderer) dlg; _sourcegutterrenderer.onQueryDataListeners ) 499 { 500 dlg(ObjectG.getDObject!(TextIter)(start), ObjectG.getDObject!(TextIter)(end), state, _sourcegutterrenderer); 501 } 502 } 503 504 bool delegate(TextIter, GdkRectangle*, int, int, Tooltip, SourceGutterRenderer)[] onQueryTooltipListeners; 505 /** 506 * The ::query-tooltip signal is emitted when the renderer can 507 * show a tooltip. 508 * 509 * Params: 510 * iter = a #GtkTextIter 511 * area = a #GdkRectangle 512 * x = the x position (in window coordinates) 513 * y = the y position (in window coordinates) 514 * tooltip = a #GtkTooltip 515 */ 516 void addOnQueryTooltip(bool delegate(TextIter, GdkRectangle*, int, int, Tooltip, SourceGutterRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 517 { 518 if ( "query-tooltip" !in connectedSignals ) 519 { 520 Signals.connectData( 521 this, 522 "query-tooltip", 523 cast(GCallback)&callBackQueryTooltip, 524 cast(void*)this, 525 null, 526 connectFlags); 527 connectedSignals["query-tooltip"] = 1; 528 } 529 onQueryTooltipListeners ~= dlg; 530 } 531 extern(C) static int callBackQueryTooltip(GtkSourceGutterRenderer* sourcegutterrendererStruct, GtkTextIter* iter, GdkRectangle* area, int x, int y, GtkTooltip* tooltip, SourceGutterRenderer _sourcegutterrenderer) 532 { 533 foreach ( bool delegate(TextIter, GdkRectangle*, int, int, Tooltip, SourceGutterRenderer) dlg; _sourcegutterrenderer.onQueryTooltipListeners ) 534 { 535 if ( dlg(ObjectG.getDObject!(TextIter)(iter), area, x, y, ObjectG.getDObject!(Tooltip)(tooltip), _sourcegutterrenderer) ) 536 { 537 return 1; 538 } 539 } 540 541 return 0; 542 } 543 544 void delegate(SourceGutterRenderer)[] onQueueDrawListeners; 545 /** 546 * The ::queue-draw signal is emitted when the renderer needs 547 * to be redrawn. Use gtk_source_gutter_renderer_queue_draw() 548 * to emit this signal from an implementation of the 549 * #GtkSourceGutterRenderer interface. 550 */ 551 void addOnQueueDraw(void delegate(SourceGutterRenderer) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 552 { 553 if ( "queue-draw" !in connectedSignals ) 554 { 555 Signals.connectData( 556 this, 557 "queue-draw", 558 cast(GCallback)&callBackQueueDraw, 559 cast(void*)this, 560 null, 561 connectFlags); 562 connectedSignals["queue-draw"] = 1; 563 } 564 onQueueDrawListeners ~= dlg; 565 } 566 extern(C) static void callBackQueueDraw(GtkSourceGutterRenderer* sourcegutterrendererStruct, SourceGutterRenderer _sourcegutterrenderer) 567 { 568 foreach ( void delegate(SourceGutterRenderer) dlg; _sourcegutterrenderer.onQueueDrawListeners ) 569 { 570 dlg(_sourcegutterrenderer); 571 } 572 } 573 }