GTK Containers as Resizer Controls

only for RuBoard - do not distribute or recompile

GTK+ Containers as Resizer Controls

Certain widgets act like third-party resizer controls that are sold for VB development (including the GtkWindow widget, which also acts like a resizer control if you think about it). Among these widgets are the GtkButtonBox, the GtkVBox and GtkHBox, and the GtkTable. When resized, they automatically resize their child widgets. (A parent widget is one that contains children widgets.) The following sections describe the most common of these packing widgets.

The GtkVBox and GtkHBox Widgets

The GtkVBox widget creates a vertical box that will contain child widgets; the GtkHBox is horizontal. You can set policies, such as whether or not all children should remain the same size and how much spacing there should be between child widgets. See the sample program at the end of the chapter to get a feel for how to use and control these widgets.

Additionally, you can pack the boxes from either the start (top, or left) or the end (bottom, or right).

The GtkTable Widget

The GtkTable widget is what you would get if you crossed a GtkVBox widget with a GtkHBox widget: a widget with both rows and columns , into which you could place child widgets. You can set the same options you could for the preceding widgets, and you can specify that certain widgets should occupy more than one space in the grid.

GtkWindow

This is the main window widget; note that it is not a window into which you can add controls, but it is only a container (meaning that you can add one widget to it ”for example, a command button as in HelloWorld). If you want to add more than one widget, you must add another container control to the window, such as a GtkTable widget, into which you can add multiple widgets. With the window widget, you have your basic window frame, with window handles around the edges of the window and the Close, Minimize, and Maximize buttons . That s it! In GTK+, you have to add your own child widgets. The types of windows are GTK_WINDOW_TOPLEVEL, GTK_WINDOW_POPUP, and GTK_WINDOW_DIALOG. The default size is 200 — 200 pixels. The usage is

 my_window = gtk_window_new( GTK_WINDOW_TOPLEVEL); 

where my_window has been declared as a GtkWidget type or GtkWindow. See Listing 2.2 at the end of the chapter for an example.

A Note About Instantiation

Generally, you can substitute the name of the widget type you want to instantiate as gtk_xxxxx_new ”where xxxxx is the widget type, such as label, or vbox, or whatever.

A Note on Multiple Window Programs

If your program uses several windows and you need to pass data back and forth between the windows, you have a couple of choices. First, of course, you can make the necessary widgets (or all of them, for that matter) global in scope. This, of course, allows you the most and quickest flexibility, but it will also get you into trouble eventually with a program of any size or complexity. The other choice is to keep your global objects (in other words, the top-level windows) to a minimum and query them for the values in the child widgets they contain. This second option will be covered in more detail in Chapter 5. The first option is used in the tour de widgets program that follows because it is a rather simple program and its purpose is to demonstrate widget functionality, not give a lesson in variable scope. Although the global- variables option may seem easy and quick, the Glade paradigm of interrogating window widgets for child widgets is actually extremely simple and easy to implement, as you shall see. Actually, this makes sense from a software engineering standpoint: What could be more global than your top-level windows? This is explained in more detail in Chapter 5

A Note About Multiple Document Interface (MDI)

GTK+ doesn t have an inherent way to create MDI applications, as you might be used to doing in Visual Basic. That is, it does not have one large container window in which the multiple windows of the application float, or dock, but still contains the multiple windows in one top-level window and shows one item on the taskbar. Instead, with GTK+, each window will show on the taskbar by default, and multiple windows will instantiate on the desktop as individual windows. Glade is a good example of this; see the figures in Chapter 5.

only for RuBoard - do not distribute or recompile


MySQL Building User Interfaces
MySQL: Building User Interfaces (Landmark)
ISBN: 073571049X
EAN: 2147483647
Year: 2001
Pages: 119

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net