Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Gtk+/Gnome Application Development
Prev Home Next

Drawing

The relationship between draw, draw_focus, draw_default, and expose_event was discussed in the section called Drawing. All four class functions are registered as default handlers for a signal of the same name. The "draw" signal redraws a portion of the widget; it is emitted by GTK+ or by widget implementations.

Widget implementations should emit the "draw_focus" signal themselves, generally in response to focus events; the signal draws or undraws a frame indicating that the widget is focused. gtk_window_set_default() emits the "draw_default" signal for both the widget losing default status and the widget gaining it. (gtk_widget_grab_default() calls gtk_window_set_default().) Only widgets with the GTK_CAN_FOCUS or GTK_CAN_DEFAULT flag set need to worry about the draw_focus and draw_default methods. These flags should be set in a widget's instance initialization function.

Only the draw method has a default implementation in GtkWidget; the default implementation synthesizes an expose event covering the widget's entire allocation. This allows you to write an expose event handler that also handles the draw signal.

GTK+ normally emits the "draw" signal in an idle function. That is, it keeps a list of widgets (and regions of them) that need to be redrawn; when no events are pending, the GTK+ main loop runs an idle function that traverses the list and emits the "draw" signal for each widget. Redraw areas are merged as much as possible to avoid multiple redraws, and the idle function is removed after it runs once. This arrangement minimizes the number of redraws and reduces flicker.

Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire