/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

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