What is a Gtk+ Widget
Gtk+ was created to allow programmers to create good looking applications in the X Window System on Linux or other UNIX platforms. A graphical interface is composed by a set of UI elements that work together to provide a seamless user experience.
In the Gtk+ world, the ways one can define user interface (GUI) elements is through the use of Widgets. A Widget is a concept introduced by the X Window System, and it corresponds in general to the notion of client window in other systems such as Windows or Mac OS.
A Widget is the most primitive window that can be presented by an application. By itself it corresponds only to a simple rectangle on the screen, which can be painted by the application to achieve a specific user interface effect.
All graphical elements in a Gtk+ application are defined as specializations of a generic Widget. For example, an input field is define as a Widget that can receive input and displays a string as part of its content. Similarly, more complex GUI elements are defined based on the simple Widget structure.
Gtk+ provides a complex hierarchy of Widgets, that encompass everything that can be used on graphical applications. Moreover, Gtk+ provides the means to create new widgets, in other words, defining specialized graphical elements to satisfy the needs of a particular application.
It can be seen that the concept of Widget is at the center of GUI development using Gtk+. It is also part of most functions that compose the Gtk+ API.
Widgets a concept of Xt, the core toolkit library in X. Therefore it is possible to create Widgets without the use of Gtk+. For example, here is the code necessary to create a simple Widget:
Widget mywidget = XtVaCreateManagedWidget( "button", xmPushButtonWidgetClass, parent, NULL);
With this code, one can create a simple push button. The look and feel of the button, however, is defined by the toolkit library in use, which can be something such as Motif, Gtk+, or Qt.
Post a comment