alternative to assert
[gtkD.git] / src / gtk / DrawingArea.d
blob03a40bb23da105ef5ac16812886fdebb031e39f3
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkDrawingArea.html
26 * outPack = gtk
27 * outFile = DrawingArea
28 * strct = GtkDrawingArea
29 * realStrct=
30 * ctorStrct=
31 * clss = DrawingArea
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_drawing_area_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * structWrap:
46 * local aliases:
49 module gtk.DrawingArea;
51 private import gtk.gtktypes;
53 private import lib.gtk;
56 /**
57 * Description
58 * The GtkDrawingArea widget is used for creating custom user interface
59 * elements. It's essentially a blank widget; you can draw on
60 * widget->window. After creating a drawing area,
61 * the application may want to connect to:
62 * Mouse and button press signals to respond to input from
63 * the user. (Use gtk_widget_add_events() to enable events
64 * you wish to receive.)
65 * The "realize" signal to take any necessary actions
66 * when the widget is instantiated on a particular display.
67 * (Create GDK resources in response to this signal.)
68 * The "configure_event" signal to take any necessary actions
69 * when the widget changes size.
70 * The "expose_event" signal to handle redrawing the
71 * contents of the widget.
72 * The following code portion demonstrates using a drawing
73 * area to display a circle in the normal widget foreground
74 * color.
75 * Note that GDK automatically clears the exposed area
76 * to the background color before sending the expose event, and
77 * that drawing is implicitly clipped to the exposed area.
78 * Example1.Simple GtkDrawingArea usage.
79 * gboolean
80 * expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
81 * {
82 * gdk_draw_arc (widget->window,
83 * widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
84 * TRUE,
85 * 0, 0, widget->allocation.width, widget->allocation.height,
86 * 0, 64 * 360);
87 * return TRUE;
88 * }
89 * [...]
90 * GtkWidget *drawing_area = gtk_drawing_area_new ();
91 * gtk_widget_set_size_request (drawing_area, 100, 100);
92 * g_signal_connect (G_OBJECT (drawing_area), "expose_event",
93 * G_CALLBACK (expose_event_callback), NULL);
94 * Expose events are normally delivered when a drawing area first comes
95 * onscreen, or when it's covered by another window and then uncovered
96 * (exposed). You can also force an expose event by adding to the "damage
97 * region" of the drawing area's window; gtk_widget_queue_draw_area() and
98 * gdk_window_invalidate_rect() are equally good ways to do this. You'll
99 * then get an expose event for the invalid region.
100 * The available routines for drawing are documented on the GDK Drawing Primitives page.
101 * See also gdk_pixbuf_render_to_drawable() for drawing a GdkPixbuf.
102 * To receive mouse events on a drawing area, you will need to enable
103 * them with gtk_widget_add_events(). To receive keyboard events, you
104 * will need to set the GTK_CAN_FOCUS flag on the drawing area, and
105 * should probably draw some user-visible indication that the drawing
106 * area is focused. Use the GTK_HAS_FOCUS() macro in your expose event
107 * handler to decide whether to draw the focus indicator. See
108 * gtk_paint_focus() for one way to draw focus.
110 private import gtk.Widget;
111 public class DrawingArea : Widget
114 /** the main Gtk struct */
115 protected GtkDrawingArea* gtkDrawingArea;
118 public GtkDrawingArea* getDrawingAreaStruct()
120 return gtkDrawingArea;
124 /** the main Gtk struct as a void* */
125 protected void* getStruct()
127 return cast(void*)gtkDrawingArea;
131 * Sets our main struct and passes it to the parent class
133 public this (GtkDrawingArea* gtkDrawingArea)
135 super(cast(GtkWidget*)gtkDrawingArea);
136 this.gtkDrawingArea = gtkDrawingArea;
140 * Create a new DrawingArea and sets the SizeRequest
141 * Params:
142 * width =
143 * height =
144 * Returns:
146 this(int width, int height)
148 this();
149 setSizeRequest(width, height);
158 * Creates a new drawing area.
159 * Returns:
160 * a new GtkDrawingArea
162 public this ()
164 // GtkWidget* gtk_drawing_area_new (void);
165 this(cast(GtkDrawingArea*)gtk_drawing_area_new() );
169 * Warning
170 * gtk_drawing_area_size is deprecated and should not be used in newly-written code.
171 * (Use gtk_widget_set_size_request() instead.)
172 * Sets the size that the drawing area will request
173 * in response to a "size_request" signal. The
174 * drawing area may actually be allocated a size
175 * larger than this depending on how it is packed
176 * within the enclosing containers.
177 * darea:
178 * a GtkDrawingArea.
179 * width:
180 * the width to request.
181 * height:
182 * the height to request.
183 * See Also
184 * Sometimes GtkImage is a useful alternative to a drawing area.
185 * You can put a GdkPixmap in the GtkImage and draw to the GdkPixmap,
186 * calling gtk_widget_queue_draw() on the GtkImage when you want to
187 * refresh to the screen.
189 public void size(int width, int height)
191 // void gtk_drawing_area_size (GtkDrawingArea *darea, gint width, gint height);
192 gtk_drawing_area_size(gtkDrawingArea, width, height);