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

Containers And Widget Layout

There are two kinds of container widgets in GTK+. All of them are subclasses of the abstract GtkContainer. The first type of container widget always descends from GtkBin, another abstract base class. Descendents of GtkBin can contain only one child widget; these containers add some kind of functionality to the child. For example, GtkButton is a GtkBin which makes the child into a clickable button. GtkFrame is a GtkBin which draws a relieved border around the child. GtkWindow allows the child to appear in a toplevel window.

The second type of container widget often has GtkContainer as its immediate parent. These containers can have more than one child, and their purpose is to manage layout. "Manage layout" means that these containers assign sizes and positions to the widgets they contain. For example, GtkVBox arranges its children in a vertical stack. GtkFixed allows you to position children at arbitrary coordinates. GtkPacker gives you Tk-style layout management.

This chapter is about the second kind of container. To produce the layout you want without hard-coding any sizes, you'll need to understand how to use these. The goal is to avoid making assumptions about window size, screen size, widget appearance, fonts, and so on. Your application should automatically adapt if these factors change.

Size Allocation

To understand layout containers, you first have to understand how GTK+ widgets negotiate their size. It's quite simple really; there are only two concepts, requisition and allocation. These correspond to the two phases of layout.

Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire