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 * Conversion parameters: 26 * inFile = GtkDrawingArea.html 27 * outPack = gtk 28 * outFile = DrawingArea 29 * strct = GtkDrawingArea 30 * realStrct= 31 * ctorStrct= 32 * clss = DrawingArea 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_drawing_area_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * structWrap: 48 * module aliases: 49 * local aliases: 50 * overrides: 51 */ 52 53 module gtk.DrawingArea; 54 55 public import gtkc.gtktypes; 56 57 private import gtkc.gtk; 58 private import glib.ConstructionException; 59 private import gobject.ObjectG; 60 61 62 63 64 65 private import gtk.Widget; 66 67 /** 68 * Description 69 * The GtkDrawingArea widget is used for creating custom user interface 70 * elements. It's essentially a blank widget; you can draw on 71 * widget->window. After creating a drawing area, 72 * the application may want to connect to: 73 * Mouse and button press signals to respond to input from 74 * the user. (Use gtk_widget_add_events() to enable events 75 * you wish to receive.) 76 * The "realize" signal to take any necessary actions 77 * when the widget is instantiated on a particular display. 78 * (Create GDK resources in response to this signal.) 79 * The "configure_event" signal to take any necessary actions 80 * when the widget changes size. 81 * The "expose_event" signal to handle redrawing the 82 * contents of the widget. 83 * The following code portion demonstrates using a drawing 84 * area to display a circle in the normal widget foreground 85 * color. 86 * Note that GDK automatically clears the exposed area 87 * to the background color before sending the expose event, and 88 * that drawing is implicitly clipped to the exposed area. 89 * $(DDOC_COMMENT example) 90 * Expose events are normally delivered when a drawing area first comes 91 * onscreen, or when it's covered by another window and then uncovered 92 * (exposed). You can also force an expose event by adding to the "damage 93 * region" of the drawing area's window; gtk_widget_queue_draw_area() and 94 * gdk_window_invalidate_rect() are equally good ways to do this. You'll 95 * then get an expose event for the invalid region. 96 * The available routines for drawing are documented on the GDK Drawing Primitives page. 97 * See also gdk_draw_pixbuf() for drawing a GdkPixbuf. 98 * To receive mouse events on a drawing area, you will need to enable 99 * them with gtk_widget_add_events(). To receive keyboard events, you 100 * will need to set the GTK_CAN_FOCUS flag on the drawing area, and 101 * should probably draw some user-visible indication that the drawing 102 * area is focused. Use the GTK_HAS_FOCUS() macro in your expose event 103 * handler to decide whether to draw the focus indicator. See 104 * gtk_paint_focus() for one way to draw focus. 105 */ 106 public class DrawingArea : Widget 107 { 108 109 /** the main Gtk struct */ 110 protected GtkDrawingArea* gtkDrawingArea; 111 112 113 public GtkDrawingArea* getDrawingAreaStruct() 114 { 115 return gtkDrawingArea; 116 } 117 118 119 /** the main Gtk struct as a void* */ 120 protected override void* getStruct() 121 { 122 return cast(void*)gtkDrawingArea; 123 } 124 125 /** 126 * Sets our main struct and passes it to the parent class 127 */ 128 public this (GtkDrawingArea* gtkDrawingArea) 129 { 130 super(cast(GtkWidget*)gtkDrawingArea); 131 this.gtkDrawingArea = gtkDrawingArea; 132 } 133 134 protected override void setStruct(GObject* obj) 135 { 136 super.setStruct(obj); 137 gtkDrawingArea = cast(GtkDrawingArea*)obj; 138 } 139 140 /** 141 * Create a new DrawingArea and sets the SizeRequest 142 * Params: 143 * width = 144 * height = 145 */ 146 this(int width, int height) 147 { 148 this(); 149 setSizeRequest(width, height); 150 } 151 152 153 /** 154 */ 155 156 /** 157 * Creates a new drawing area. 158 * Throws: ConstructionException GTK+ fails to create the object. 159 */ 160 public this () 161 { 162 // GtkWidget * gtk_drawing_area_new (void); 163 auto p = gtk_drawing_area_new(); 164 if(p is null) 165 { 166 throw new ConstructionException("null returned by gtk_drawing_area_new()"); 167 } 168 this(cast(GtkDrawingArea*) p); 169 } 170 171 /** 172 * Warning 173 * gtk_drawing_area_size is deprecated and should not be used in newly-written code. Use gtk_widget_set_size_request() instead. 174 * Sets the size that the drawing area will request 175 * in response to a "size_request" signal. The 176 * drawing area may actually be allocated a size 177 * larger than this depending on how it is packed 178 * within the enclosing containers. 179 * Params: 180 * width = the width to request 181 * height = the height to request 182 */ 183 public void size(int width, int height) 184 { 185 // void gtk_drawing_area_size (GtkDrawingArea *darea, gint width, gint height); 186 gtk_drawing_area_size(gtkDrawingArea, width, height); 187 } 188 }