Gtkmm Lab
Description
gtkmm is a C++ wrapper for
GTK+, a library used to create graphical user
interfaces. gtkmm was originally named gtk-- because GTK+ already has a
+ in the name. However, as -- is not easily indexed by search engines,
the package generally went by the name gtkmm, and that’s what they stuck
with.
We will be using gtkmm in a future homework assignment.
Tasks
- Go to http://www.gtkmm.org/documentation.shtml and
find the Programming with gtkmm online book.
- In Chapter 3, Basics, there is a simple example that
creates an empty 200×200 window.
- You can download the source code, which might be easier
than copy-and-paste.
- Note the use of pkg-config. Try running
pkg-config
alone,
just to see the work that it saves you:
pkg-config gtkmm-2.4 --cflags --libs
- Now, compile the program as shown, and execute it.
- Farther down in the same chapter, there is a “Hello World” example.
- Compile it and execute it.
- Change the button label to “Die, ye scurvy dogs!”, recompile and execute.
- Try resizing the window.
- In the second half of Chapter 7, Multiple-item widgets,
there is an improved “Hello World” example.
- Download it (don’t get it mixed up with the earlier “Hello World”).
- Compile and execute it.
- Add a third button, below the first two, like this,
whose width spans both existing buttons:
+--------+ +--------+
|Button 1| |Button 2|
+--------+ +--------+
+--------------------+
| Big Shot |
+--------------------+
For Fame & Glory
- Change the improved “Hello World” example so that,
when you press Button 1, the border width of the window increases,
and when you press Button 2, the border width of the window decreases.
- Change the improved “Hello World” example so that pressing
the “Big Shot” button changes its own background color randomly.