PageRenderTime 27ms CodeModel.GetById 19ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_drawing_area.e

http://github.com/tybor/Liberty
Specman e | 117 lines | 38 code | 25 blank | 54 comment | 3 complexity | f1302e8a95a98185589fb72cab5346f7 MD5 | raw file
  1indexing
  2	description: "GtkDrawingArea - A widget for custom user interface elements."
  3	copyright: "[
  4					Copyright (C) 2007 Paolo Redaelli, GTK+ team
  5					
  6					This library is free software; you can redistribute it and/or
  7					modify it under the terms of the GNU Lesser General Public License
  8					as published by the Free Software Foundation; either version 2.1 of
  9					the License, or (at your option) any later version.
 10					
 11					This library is distributed in the hopeOA that it will be useful, but
 12					WITHOUT ANY WARRANTY; without even the implied warranty of
 13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14					Lesser General Public License for more details.
 15
 16					You should have received a copy of the GNU Lesser General Public
 17					License along with this library; if not, write to the Free Software
 18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 19					02110-1301 USA
 20			]"
 21
 22class GTK_DRAWING_AREA
 23	-- The GtkDrawingArea widget is used for creating custom user
 24	-- interface elements. It's essentially a blank widget; you can
 25	-- draw on widget->window.  After creating a drawing area, the
 26	-- application may want to connect to:
 27
 28	-- o Mouse and button press signals to respond to input from the
 29	-- user. (Use `add_events' to enable events you wish to receive.)
 30
 31	-- o The "realize" signal to take any necessary actions when the
 32	-- widget is instantiated on a particular display. (Create GDK
 33	-- resources in response to this signal.)
 34
 35	-- o The "configure_event" signal to take any necessary actions
 36	-- when the widget changes size.
 37
 38	-- o The "expose_event" signal to handle redrawing the contents of
 39	-- the widget.
 40
 41	-- The following code portion demonstrates using a drawing area to
 42	-- display a circle in the normal widget foreground color. Note
 43	-- that GDK automatically clears the exposed area to the background
 44	-- color before sending the expose event, and that drawing is
 45	-- implicitly clipped to the exposed area.
 46
 47	-- Example 1. Simple GtkDrawingArea usage.
 48	
 49	-- gboolean expose_event_callback (GtkWidget *widget,
 50	-- GdkEventExpose *event, gpointer data) { gdk_draw_arc
 51	-- (widget->window, widget->style->fg_gc[GTK_WIDGET_STATE
 52	-- (widget)], TRUE, 0, 0, widget->allocation.width,
 53	-- widget->allocation.height, 0, 64 * 360); return TRUE; } [...]
 54	
 55	-- GtkWidget *drawing_area = gtk_drawing_area_new ();
 56	-- gtk_widget_set_size_request (drawing_area, 100, 100);
 57	-- g_signal_connect (G_OBJECT (drawing_area), "expose_event",
 58	-- G_CALLBACK (expose_event_callback), NULL);
 59
 60	-- Expose events are normally delivered when a drawing area first
 61	-- comes onscreen, or when it's covered by another window and then
 62	-- uncovered (exposed). You can also force an expose event by
 63	-- adding to the "damage region" of the drawing area's window;
 64	-- `queue_draw_area' and GDK_WINDOW. `invalidate_rect'
 65	-- are equally good ways to do this. You'll then get an expose
 66	-- event for the invalid region.
 67
 68	-- The available routines for drawing are documented on the GDK
 69	-- Drawing Primitives page. See also
 70	-- gdk_pixbuf_render_to_drawable() for drawing a GdkPixbuf.
 71
 72	-- To receive mouse events on a drawing area, you will need to
 73	-- enable them with gtk_widget_add_events(). To receive keyboard
 74	-- events, you will need to set the GTK_CAN_FOCUS flag on the
 75	-- drawing area, and should probably draw some user-visible
 76	-- indication that the drawing area is focused. Use the
 77	-- GTK_HAS_FOCUS() macro in your expose event handler to decide
 78	-- whether to draw the focus indicator. See gtk_paint_focus() for
 79	-- one way to draw focus.
 80
 81	-- See Also: Sometimes GtkImage is a useful alternative to a
 82	-- drawing area. You can put a GdkPixmap in the GtkImage and draw
 83	-- to the GdkPixmap, calling gtk_widget_queue_draw() on the
 84	-- GtkImage when you want to refresh to the screen.
 85
 86inherit GTK_WIDGET
 87
 88	-- GtkDrawingArea implements AtkImplementorIface.
 89
 90creation make, from_external_pointer
 91
 92feature {} -- Creation
 93	make is
 94			-- Creates a new drawing area.
 95		do
 96			from_external_pointer(gtk_drawing_area_new)
 97		end
 98
 99feature -- size
100	struct_size: INTEGER is
101		external "C inline use <gtk/gtk.h>"
102		alias "sizeof(GtkDrawingArea)"
103		end
104
105feature {} -- External calls
106
107	gtk_drawing_area_new: POINTER is
108		external "C use <gtk/gtk.h>"
109		end
110
111	gtk_drawing_area_size (a_darea: POINTER; a_width, an_height: INTEGER) is
112			-- gtk_drawing_area_size (GtkDrawingArea *darea, gint width, gint 
113			-- height);
114		external "C use <gtk/gtk.h>"
115		end
116		
117end -- class GTK_DRAWING_AREA