Gtk2::Gdk modules are not often used, but there are places and situations where you have to use it, especially when you want to do lower level functions. To find lots of information on
Gtk2::Gdk is not very easy. (This is not just
Gtk2::Gdk but GDK in general, especially!).
This lesson will first look at
Gtk2::Gdk in general. We will then look at two programs that will introduce the reader to more fancy tricks that will use
Gtk2::Gdk classes in combination with
If you followed the lessons up to now, you have already used
Gtk2::Gdk in a few places, although it was just for basic things. The following is a table of
Gtk2::Gdk classes that we used and what we used it for.
Gtk2::Gdk object classes used
|Used to do:|
|Getting the X-Window that a widget is displayed in.|
|Setting the cursor when the mouse hovered over a widget's |
|The first event used was the "delete_event", which happens when the |
|This was used to check which button was clicked. It is a sub-class of |
|This was used to check which key was pressed. It is a sub-class of |
|This is a hash of names and key numbers. Used for lookups to catch certain key strokes|
We will discuss
Gtk2::Gdk::Pixmap here. This is done prior to discussing
Gtk2::Image in depth, since
Gtk2::Image can use them to create a visible image.
Gtk2::Gdk, as stated at the start of the document is an abstraction layer between the lower level windowing system of the OS and the widgets. This allows you do do things like image manipulation, event blocking and handling, the shape of your windows, the color scheme of the widgets.
Since it is an abstraction layer, it allows you to write your application once, and it will be able to run on different OS'es with different windowing systems. You will be able to do the same tricks using X's API on Linux for instance, but this will not work if you run the program on a Windows machine, since it does not use X as a graphical system.