Programming with gtkmm2

Michael Ashton

Murray Cumming

Bernhard Rieder

Chapter on "Timeouts".

Jason M'Sadoques

Chapter on "Drawing Area".

Ole Laursen

Chapter on "Internationalization".

August 2000

Abstract

Not all sections have been completed - some have not been started. Some chapters have been written, but not edited or proofread. Since they do contain helpful information, they have been included, and are marked "draft". We are working hard to make this helpful and accurate. We would very much appreciate any reports of inaccuracies or other errors in this document. Contributions are also most welcome. Post your suggestions, critiques or addenda to the gtkmm mailing list -- The gtkmm Development Team


Table of Contents

1. Introduction
This book
gtkmm
Why use gtkmm instead of GTK+?
gtkmm compared to QT
gtkmm is a wrapper
2. Installation
Dependencies
From Source
Prebuilt packages
Debian Linux
Redhat Linux
3. Basics
Simple Example
Widgets
Signals
Glib::ustring
Intermediate types
Hello World in gtkmm
4. Buttons
Button
Constuctors
Example
Signals
ToggleButton
CheckButton
Example
RadioButton
Groups
Methods
Example
5. Range Widgets
Scrollbar Widgets
Scale Widgets
Useful methods
Update Policies
Example
6. Miscellaneous Widgets
Label
Example
Entry
Example
Combo
Example
SpinButton
Methods
Example
ProgressBar
Activity Mode
Example
Tooltips
7. Container Widgets
Single-item Containers
Frame
Example
Paned
Example
ScrolledWindow
Example
AspectFrame
Example
Alignment
Example
Multiple-item widgets
Packing
An improved Hello World
STL-style APIs
Adding items
Boxes
Adding widgets
Per-child packing options
Per-container packing options
Example
ButtonBoxes
Example
Table
Constructor
Adding widgets
Other methods
Example
Notebook
Example
STL-style API
8. The TreeView widget
The Model
ListStore, for rows
TreeStore, for a hierarchy
Model Columns
Adding Rows
Adding child rows
Setting values
Getting values
"Hidden" Columns
The View
Using a Model
Adding View Columns
More than one Model Column per View Column
Specifying CellRenderer details
Editable Cells
Automatically-stored editable cells.
Implementing custom logic for editable cells.
Iterating over Model Rows
Row children
The Selection
Single or multiple selection
The selected rows
The "changed" signal
Changing the selection
Examples
ListStore
TreeStore
Editable Cells
9. TreeView
10. Menus and Toolbars
Menus
Examples
Main Menu example
Popup Menu example
Toolbars
Example
11. Adjustments
Creating an Adjustment
Using Adjustments the Easy Way
Adjustment Internals
12. Widgets Without X-Windows
13. Dialogs
MessageDialog
FileSelection
ColorSelectionDialog
FontSelectionDialog
14. The Drawing Area Widget
Graphics Contexts
Drawing Pixels
Drawing Lines
Drawing Rectangles and Polygons
Drawing Ellipses and Arcs
Drawing Text
Draw Images
15. Drag and Drop
Sources and Destinations
Methods
Signals
Copy
Move
Link
DragContext
Example
16. The Clipboard
17. Timeouts, I/O and Idle Functions
Timeouts
Monitoring I/O
Idle Functions
18. Memory management
Widgets
Normal C++ memory management
Class Scope widgets
Function scope widgets
Dynamic allocation with new and delete
Managed Widgets
Dynamic allocation with manage() and add()
Shared resources
19. Internationalization and Translation
English in the source code, translations in the .po files.
gettext
How the gettext system works
Expecting UTF8
Glib::ustring and std::iostreams
Pitfalls
Same strings, different semantics
Composition of strings
Assuming the displayed size of strings
Unusual words
Using non-ASCII characters in strings
Getting help with translations
20. Recommended Techniques
Application lifetime
Using a gtkmm widget
21. Contributing
22. Copyright and Permissions Notice
A. The RefPtr smartpointer
B. Signals
Connecting signal handlers
Writing signal handlers
Disconnecting signal handlers
Overriding default signal handlers
Binding extra arguments
X Event signals
C. Creating your own signals
D. Comparison with other signalling systems