Copyright ⌐ 2001 by the PHP-GTK Documentation Group
Copyright
This manual is ⌐2001 by the PHP-GTK Documentation Group. The members and editors are listed on the front page of this manual.
Copyright (c) 2001 PHP-GTK Documentation Group. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License Version 1.1 published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover texts and with no Back-Cover texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
Sun Jul 7 00:36:42 PDT 2002
Table of Contents
Table of Contents
This manual is split into two main parts.
The first part is the Userguide. This discusses the general concepts behind creating a Graphical User Interface (GUI) application. The second part is the Reference section. This part of the manual details each of the GTK objects and the individual methods and signals that can be used with them.
This manual is written using a modified version of the Docbook DTD. The modifications that have been made allow the documentation of the object system used by PHP-GTK. The XML basis for each of the classes and their methods is generated automagically from the PHP-GTK source code. Note that it is not possible to generate signal information in this way, i.e. if there is no accompanying textual description then signal information is ispo facto incomplete for that class.
The XML Generator was written by Andrei Zmievski, the original author of PHP-GTK itself. The documentation is transformed from its XML source into various other formats using XSL as well as a host of other tools.
The manual build system was created and is maintained by James Moore.
The manual is currently available in plain text, single HTML or multiple HTML formats, all of which are downloadable from the PHP-GTK website.
Table of Contents
Table of Contents
Table of Contents
This section of the manual will introduce you to the ideas and the technologies behind PHP-GTK as well as its uses.
PHP-GTK is a PHP extension that enables you to write client-side, cross-platform GUI applications. This is the first extension for PHP of its kind, and was written in part to prove that PHP is a capable general-purpose language that is suited to more than just the web application environment.
This extension will not allow you to display GTK+ applications in a web browser. It is intended for creating standalone GUI applications.
GTK+ was originally developed for GIMP, the GNU Image Manipulation Program. GTK+ stands for the GIMP Tool Kit. GTK+ has grown from these beginnings and is now used as a central part of Gnome, the GNU Projects desktop environment. GTK+ has also been ported to BeOS and Win32, making it the perfect choice to use as the basis for a PHP extension, keeping PHP as cross-platform as possible and allowing the creation of windowed applications in PHP for Linux, BeOS and Windows.
PHP started life and is still primarily used as a server-side HTML-embedded scripting language.
PHP, known originally as Personal Home Pages, was first conceived in the autumn of 1994 by Rasmus Lerdorf. He wrote it as a way to track visitors to his online CV. The first version was released in early 1995, by which time Rasmus had found that by making the project open-source, people would fix his bugs. The first version was very straightforward and had a simple parser which recognised a few special macros and provided some of the utilities which were in common usage on homepages back then.
The parser was rewritten in mid-1995 and renamed PHP/FI version 2. The "FI" in this version stood for the Form Interpreter which Rasmus had added to PHP to cope with the growing needs of webpages. mSQL support was also added at this time. PHP/FI underwent massive growth, and other people started to contribute code to it regularly.
In mid-1997 Zeev Suraski and Andi Gutmans rewrote the main parser, and PHP shifted from being Rasmus' own to a more group orientated project. This formed the basis for PHP3, now named PHP: Hypertext Preprocessor - a recursive acronym.
The latest version, PHP4, is another rewrite by Suraski and Gutmans and is based around the Zend engine. PHP now has over two hundred regular contributors working on various parts of the project. It has a massive amount of third party extension modules, supports all popular servers natively, and has inbuilt MySql and ODBC support.
The latest statistics show that PHP is now in use on over 5.5 million domains, and has had a steady usage growth rate over the past year. It is far and away the single most popular Apache module; to give this some perspective, Apache currently holds nearly 60% of the market share of Internet webservers, whereas IIS servers (natively supporting ASP) hold less than half that proportion of the market. (Figures taken from http://www.securityspace.com/ March 2001.)
PHP is a general purpose language. It is normally put to use as an html-embedded scripting language for use on the web, but it can also be used as a shell scripting language or even as a language to write windowed applications, in the form of PHP-GTK.
Due to PHP's open-source nature, if there is something you can't currently do in PHP itself there is nothing stopping you from writing a PHP module or extension in C code to extend its functionality so that you can do what you want from within PHP itself. This is made possible through the well-documented API which is available to all.
PHP4 has two main parts to it:
The Zend Engine
is the part of the PHP package that keeps track of the requests, processes scripting files, and handles variables and resources. Its homepage can be found at http://www.zend.com/.
PHP
implements 90% of the functionality seen by the end user. It provides a wide range of modules such as MySQL, ODBC and XML support.
The person I would like to thank most is James Henstridge <james@daa.com.au>, the author of PyGTK (Python GTK+ Bindings). His help and advice have proved invaluable during the development of this extension, and a fair amount of the source code is based on or inspired by what he has developed for PyGTK.
I would also like to thank the PHP Team for making such a great language, and the GTK+ Team for developing what has to be the best C-based GUI toolkit.
- Feb 2001
Table of Contents
widget is a term used in the world of X for any user interface. A widget can be a text box, label, frame, window or any other GUI component. GTK widgets are all derived from the abstract base class GtkWidget, and inherit the methods, signals and properties implemented therein.
From a programming point of view a widget has five parts to its life cycle:
Creation
In PHP-GTK this is done by creating an object, e.g. $window = &new GtkWindow();
Placement
This is the step of adding a widget to a container. This is achieved most straightforwardly in PHP-GTK by using the syntax $container->add($widget);
Signal Connection
This is the step of setting up callback functions for use. An example of this might be $widget->connect("event", "my_focus_func"); , where "event" is a predefined state such as clicked and "my_focus_func" is the called subroutine.
Display
This describes whether the widget is on display to the user. It is started by calling $widget->show(); and finished by $widget->hide();.
Destruction
This occurs when the gtk::main_quit() function is called. All actions that are necessary here are handled internally.
A container is simply a widget that is able to contain another widget. The vast majority of widgets fall into this class; obvious examples include GtkWindow, GtkTable and GtkBox. Other than this property they are exactly the same as any other widget, and may be added to other containers as well as supporting child widgets of their own. They are derived from the GtkContainer base class, which is itself derived from the GtkWidget class.
Table of Contents
Signals are notifications emitted by widgets.
When programming Graphical User Interfaces (GUI), it is often necessary to respond to actions performed by the user or initiated within the program itself. GNOME and GTK+ do this via the use of signals. Signals are used to let the program know that something happened. This might be, for example, a user clicking on a GtkButton, or a change being made to a GtkAdjustment value.
A program may, for instance, cause GtkAdjustment to emit its value-changed signal when a widget changes one of its adjustment values. This particular signal is used both internally and externally in GtkAdjustment, so that it is not always necessary to write that signal into your code for, say, a GtkProgressBar to use it. A more obvious situation may occur when a user clicks on an instance of GtkButton, causing the button widget to emit the clicked signal. As a programmer, you can set up callbacks to react to any signal emitted by a widget.
Callbacks are functions that are invoked when signals are emitted by widgets.
Callbacks are functions that are set up by the programmer to react to signals emitted by widgets. You specify the function that should be called by connecting the function to the signal.
The callback is also known as the signal handler function. This can be either the widget's default handler or a user-defined handler, that is, a function written by the programmer.
Signals are inherited by objects, just as methods are. A widget can emit any signals that its ancestor objects have defined, as well as its own specific signals.
In cases where the signal is not relevant to the widget but is nonetheless inherited by it, there will be no error message when the signal is called - but equally, there will be no obvious means for the widget to emit that particular signal.
To react to a signal you must connect to it by specifying a callback function for PHP-GTK to call when that signal is emitted.
Connecting a function to a signal is achieved by calling the connect() method of the object.
The function that you register as the callback for a signal must have the correct prototype. You can find what the prototype should be from the reference section of this manual.
For example, if you wanted to connect to the clicked signal of an instance of GtkButton you should define a function that accepts one parameter, which will be the button that was clicked.
The code below shows how you might create a window, add a button to it, wait for it to be clicked and then, when it is clicked, open a new GtkWindow containing a message.
Example 3.0. Signals and Callbacks
function shutdown() { print("Shutting down...\n"); gtk::main_quit(); } function you_clicked($button) { $window = &new GtkWindow(); $label = &new GtkLabel("You clicked the button"); $window->add($label); $window->connect("destroy","shutdown"); $window->show_all(); return false; } $window = &new GtkWindow(); $window->connect("destroy", "shutdown"); $window->set_border_width(10); $button = &new GtkButton("Click Me!!"); $button->connect("clicked", "you_clicked"); $window->add($button); $window->show_all(); gtk::main(); |
The important part here is where we call
The connect method here registers the you_clicked() function as the callback that will be invoked when the clicked signal is emitted by the GtkButton widget. We also register the shutdown() function as the handler for the destroy signal for both windows so that we can shut down the application properly.With PHP-GTK you can register more than one function to be invoked when a signal is emitted by a widget. This allows you to set up a whole set of functions to be called in response to an expected action.
When more than one function is connected to a signal, the functions are called in the order in which they were registered when that signal is emitted.
Example 3.1. Signal Callback Order
function first($button) { print "First function has been called\n"; } function second($button) { print "Second function has been called\n"; } $window = &new GtkWindow(); $window->connect_object("destroy", array("gtk", "main_quit")); $button = &new GtkButton("Click Me!!"); $button->connect("clicked","first"); $button->connect("clicked","second"); $window->add($button); $window->show_all(); gtk::main(); |
The output from this program would be:
First function has been called. Second function has been called. |
When connecting signals, it is possible to add an extra custom parameter to the callback. This is useful for passing the object you want to perform an action on, to your callback function.
For example, when a button is pressed we might want to destroy the parent instance of GtkWindow that that instance of GtkButton has been added to.
You can do this by including an optional third parameter to the connect() call. This will then be passed to your signal handler function as the final callback parameter.
Example 3.2. Using Custom Parameters with the connect() method.
function button_clicked($button, $window) { $window->destroy(); gtk::main_quit(); } $window = &new GtkWindow(); $button = &new GtkButton("exit"); $button->connect("clicked","button_clicked", $window); $window->add($button); $window->show_all(); gtk::main(); |
By passing the $button variable as our calling object parameter and the $window variable as our custom parameter, we could use this same callback for more than one GtkButton on more than one GtkWindow. Note that the names given to the parameters within the callback are irrelevant outside the callback function; PHP-GTK picks up on the positions of the parameters in the connect* method calls and passes these to the variables listed in the callback declaration as an array, so that any instance of a connection using the same parameter structure can use that same callback. This is demonstrated in the code below using a single custom parameter, but is equally true for more than one.
Example 3.3. Using the same callback for more than one window
function button_clicked($button, $window) { $window->set_title("titled"); } $window1 = &new GtkWindow(); $window1->connect_object("destroy", array("gtk", "main_quit")); $window2 = &new GtkWindow(); $window2->connect_object("destroy", array("gtk", "main_quit")); $button1 = &new GtkButton("click me"); $button2 = &new GtkButton("or me"); $button1->connect("clicked", "button_clicked", $window1); $button2->connect("clicked", "button_clicked", $window2); $window1->add($button1); $window2->add($button2); $window1->show_all(); $window2->show_all(); gtk::main(); |
Both connect_object() and connect_object_after() allow you to pass an object other than the calling object as the first parameter to your callback function. This is mainly used for calling static PHP-GTK functions, as in (for example) the gtk::main_quit() function:
Example 3.4. Using the connect_object() method to specify a built-in function as callback.
$window = &new GtkWindow(); $window->connect_object("destroy", array("gtk", "main_quit")); $window->show(); gtk::main(); |
It also means you can have a single callback for multiple signals. For example; you might create a window containing (within the necessary container widgets) a GtkMenuBar, a GtkToolbar and a GtkButton. When Exit is chosen by the user through any of these widgets, a shutdown function could be invoked by passing the instance of GtkWindow as its first parameter, allowing the window to be destroyed from any of those connections. The callback function and the connections in this instance would look like this:
Example 3.5. Using the connect_object() method to pass another object as first parameter.
function destroy_window($window) { $window->destroy(); gtk::main_quit(); } $exit_button->connect_object("clicked", "destroy_window", $window); |
The connect_after* methods allow callbacks to be "run after" the default signal handler for that signal. This can be useful in some situations; for example, where you want to destroy only one of several windows in a given circumstance. However, connect_after* methods will only work when a signal has been created in the GTK source with a GTK_RUN_LAST flag. The destroy signal and all the 'event' signals have this flag; beyond that, the only way to check is to either test the signal within PHP-GTK or read the GTK source.
Example 3.6. Using the connect_after() method.
function quit_routine($window) { print("Shutting down...\n"); gtk::main_quit(); } $window1 = &new GtkWindow(); $window1->set_title("Quit the main loop"); $window1->connect("destroy", "quit_routine"); $window2 = &new GtkWindow(); $window2->set_title("Destroy this window"); $window2->connect_after("destroy", "quit_routine"); $window1->show(); $window2->show(); gtk::main(); |
See also: GtkObject, connect_after() connect_object() and connect_object_after() .
GTK Signals, GDK Events.
Signals are not events, and events are not signals. A signal is a message emitted by an instance of a GtkObject in response to some predetermined element in its environment, e.g. an action by the end user, or an instruction from a function or method. Signals are always programmed into the code, either internally within GTK or externally by the PHP-GTK programmer.
Events, on the other hand, are a continual stream of impulses communicating messages concerning environmental changes in the underlying windowing system. The GTK main loop is made up of this stream of events, among other things.
Any widget having its own GdkWindow may capture events that are relevant to it. Widgets lacking a GdkWindow - those created with the GTK_NO_WINDOW flag - cannot do so, unless they are housed within a GtkEventBox - a widget created for this specific purpose. There are occasions when it is useful to be able to capture events; one obvious example would be the creation of an instance of GtkToolTips which is triggered when its subject widget captures the GDK_ENTER_NOTIFY event and destroyed when the same widget captures the GDK_LEAVE_NOTIFY event.
Although it is not possible to use an event to trigger a callback in the same way as a signal, there are a series of signals derived from GtkWidget collectively known as 'event' signals. These are effectively ways of describing an event in terms of a signal, allowing callbacks to be indirectly triggered through a captured occurrence of most of the GdkEventTypes. The GtkTooltips object itself uses the connect_object() method and the generic event signal in order to monitor its subject widget.
The concept of events is not an easy one to grasp. Please copy, paste and run the following script in order to see the flow of events over a widget in action.
Example 3.7. Demonstration of the flow of events across a GtkButton
dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" : "so")) || die("Can't load php_gtk module!\n"); function show_event_type($button, $event, $text) { $event_type = $event->type; $insert = $text->get_length(); $text->freeze(); switch($event_type) { case 2: $text->insert_text("GDK_EXPOSE\n", $insert); break; case 3: $text->insert_text("GDK_MOTION_NOTIFY\n", $insert); break; case 4: $text->insert_text("GDK_BUTTON_PRESS\n", $insert); break; case 5: $text->insert_text("GDK_2BUTTON_PRESS\n", $insert); $button->hide(); break; case 7: $text->insert_text("GDK_BUTTON_RELEASE\n", $insert); break; case 8: $text->insert_text("GDK_KEY_PRESS\n", $insert); break; case 9: $text->insert_text("GDK_KEY_RELEASE\n", $insert); break; case 10: $text->insert_text("GDK_ENTER_NOTIFY\n", $insert); break; case 11: $text->insert_text("GDK_LEAVE_NOTIFY\n", $insert); break; case 12: $text->insert_text("GDK_FOCUS_CHANGE\n", $insert); break; case 14: $text->insert_text("GDK_MAP\n", $insert); break; case 15: $text->insert_text("GDK_UNMAP\n", $insert); $button->destroy(); $text->insert_text( "\n* GDK EVENTS AND GTK SIGNALS - background stream vs foreground messaging * \n * Most GdkEventTypes have counterpart GTK signals, known as 'event' signals, implemented in GtkWidget. The types on your screen are there because the GtkButton was programmed to emit the generic 'event' signal each time it captured one of the stream of GDK events that makes up the GTK main loop. In each case, the captured GdkEvent was passed as a callback parameter so that its enumerated type value could be determined within the signal handler function. Scroll down to see the series of event values captured during your recent interaction with the GtkButton widget. * \n * Please note that the majority of GTK signals do NOT correspond to GDK events in this or any other way! For example, the signal connection \$button->connect('pressed', 'whatever'); has no relationship to the GDK_BUTTON_PRESS event it generates, which refers to mouse-button activity and not to the GtkButton 'pressed' signal. * \n", 0); break; } $text->thaw(); return false; } $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->set_default_size((gdk::screen_width()/1.5), (gdk::screen_height()-20)); $window->connect_object("destroy", array("gtk", "main_quit")); $window->realize(); $box = &new GtkVBox(false, 5); $window->add($box); $scrlwin = &new GtkScrolledWindow(); $box->pack_start($scrlwin, true, true, 0); $text = &new GtkText(); $scrlwin->add($text); $button = &new GtkButton("Double-click here for information.."); $button->add_events(GDK_ALL_EVENTS_MASK); $button->connect("event", "show_event_type", $text); $box->pack_end($button, false, false, 5); $window->show_all(); gtk::main(); |
Table of Contents
Table of Contents
PHP-GTK 0.5.0 source and the binaries for Windows can be found at http://gtk.php.net/. Source users will also need to install the latest version of PHP from CVS - see http://www.php.net/anoncvs.php.
Download PHP-GTK 0.5.0 win32 binaries from http://gtk.php.net/. You may also want to check out the latest sources from php.net's CVS server. See http://www.php.net/anoncvs.php for more information.
Copy \php4 to your existing php directory. If this is a new installation you should create c:\php4 and copy the files to this directory.
Copy \winnt to your windows directory. On Windows NT and Windows 2000 that is c:\winnt. On Windows 95/98 that is c:\windows. If you have an existing php.ini you don't need to copy this file.
Copy \winnt\system32 to your windows system32 directory. On Windows NT and Windows 2000 that is c:\winnt\system32. On Windows 95/98 that is c:\windows\system32.
Copy \test to the location where you want to run your scripts (e.g. c:\php4\test).
Debian users can now download a PHP-GTK binary from http://www.debian.org/.
PHP GTK depends on a number of packages, which need to be installed before starting the PHP-GTK installation:
The GTK+ libraries, available from http://www.gtk.org/download/, or you can use the packaged versions for your system, e.g. gtk and gtk-devel
libtool, automake and autoconf. The combination of libtool 1.4.2, automake 1.4 and autoconf 2.13 is known to work; mileage may vary with other version combinations.
For the optional extras, download GtkHTML libraries, GtkScintilla libraries and Gdk-Pixbuf libraries. Again, these may be available packaged on your system, just ensure that you also install the development package. GtkHTML, notably, has a number of sub-dependencies, e.g. GAL, that can also be obtained from the Gnome ftp site.
We suggest you get the latest source from http://gtk.php.net/ or from anonymous CVS http://www.php.net/anoncvs.php.
Run the ./buildconf script that is inside the distribution. This will set up the necessary files and create the configure script. Next, run ./configure. This will check that you have a correct version of GTK+ 1.2.x (1.2.6 or above, available from http://www.gtk.org/download/) and other files required for compilation, and will then create the needed Makefiles.
./configure can also be used to build the extra widgets, e.g. ./configure --enable-scintilla --enable-gtkhtml. To list all the available options use ./configure --help. Remember that each extra widget may have a number of dependencies that need to be available for the build to be successful.
Finally, run make to compile the extension. Some source files are generated from .defs files by the code generator. If you see messages like "Could not write...", it means that the listed GTK+ objects or features are not yet supported. If the compilation is successful, run make install to install the extension into your default PHP extension directory (usually /usr/local/lib/php/extensions).
Troubleshooting: common problems from ./configure or make
./ltconfig: ltconfig : No such file or directory, configure: error: libtool configure failed is caused by not having one of libtool, automake or autoconf installed.
./aclocal.m4:813: error: m4_defn: undefined: _m4_divert_diversion is caused by an incompatible version of autoconf, see the recommended versions above.
php_gtk+.c:33: parse error before `TSRMLS_DC' is caused by either an old version of php being found by the build system or trying to build php-gtk with an old version of PHP - please upgrade to PHP version 4.1.1 to fix this.
gen_gtk.c:1: parse error before '<' is caused by an error occurring in the generator. Usually this error is resolved by adding the line ini_set("memory_limit", "32M"); to the first line of generator/generator.php. You will need to remove all the gen_* files from all directories after changing this.
checking for gnome-config... Unknown library `gtkhtml' (from ./configure) is due to an old or unavailable development header file - if you installed by rpm or a similar package system you will need the -devel packages
Unable to find -lgal or similar message is caused by a missing gal-devel or similar library. Usually this will be a sub dependancy of some of the more complex widgets, like gtkhtml.
To test the extension, try running the example scripts in the test/ directory. These also provide demonstrations of some of the ways in which PHP-GTK and its extensions can be used.
Table of Contents
When you begin to learn a programming language, the first program you often write is a 'hello world' program. So, just to fit in with everyone else, the first tutorial in this manual just happens to be a 'hello world' tutorial!
Throughout the tutorials we expect a reasonable grasp of PHP itself. The tutorials are designed to give the user an idea of how to use PHP-GTK, and the ideas and techniques behind it.
In this tutorial we will create a simple window with the text "Hello World!" in it.
We will start by listing the program and will then explain each line of the program, giving an overview of a very basic PHP-GTK application.
Example 1.0. PHP-GTK Hello World Program Listing
if (!class_exists('gtk')) { if (strtoupper(substr(PHP_OS, 0,3) == 'WIN')) dl('php_gtk.dll'); else dl('php_gtk.so'); } function delete_event() { return false; } function shutdown() { print("Shutting down...\n"); gtk::main_quit(); } function hello() { global $window; print "Hello World!\n"; $window->destroy(); } $window = &new GtkWindow(); $window->connect('destroy', 'shutdown'); $window->connect('delete-event', 'delete_event'); $window->set_border_width(10); $button = &new GtkButton('Hello World!'); $button->connect('clicked', 'hello'); $window->add($button); $window->show_all(); gtk::main(); |
if (!class_exists('gtk')) { if (strtoupper(substr(PHP_OS, 0,3) == 'WIN')) dl('php_gtk.dll'); else dl('php_gtk.so'); } |
The delete_event() function is registered as a handler (see below) for the delete-event signal. It returns false, telling PHP-GTK to fire the event's default signal handler, which in this case is the destroy() method. If the function were to return true, PHP-GTK would stop the default signal handler running at this point. This is useful to know if you need to write a user-defined function in place of destroy() - for example, to produce a dialog box confirming that the user intends to close down the application.
It is not strictly necessary to return false in order to connect the delete-event signal to the destroy() method, as this particular signal returns false by default. It is possible to not specify any behaviour at all for a window's delete-event signal, just so long as the destroy signal is handled in the correct way, as it is here.
Example 1.3. The shutdown() function
function shutdown() { print("Shutting down...\n"); gtk::main_quit(); } |
Example 1.4. The hello() function
function hello() { global $window; print "Hello World!\n"; $window->destroy(); } |
Another way that the hello() function would be able to access the $window variable is if the variable were passed as a custom parameter.
Example 1.5. Setting up the Window
$window = &new GtkWindow(); $window->connect('destroy', 'shutdown'); $window->connect('delete-event', 'delete_event'); $window->set_border_width(10); |
Example 1.6. Setting up the Button
$button = &new GtkButton('Hello World!'); $button->connect('clicked', 'hello'); $window->add($button); $window->show_all(); |
The final line of the script calls the static gtk::main() function. This tells PHP-GTK that we have finished setting up our interface, and that the main loop can begin listening for the events fired by user interaction so that the callback functions we defined earlier can be called and the various actions carried out.
Table of Contents
Table of Contents
A structure containing accelerator key data.
Constructor
— Provides the structure for a hash table of accelerator key information.
GtkAccelGroup
();
GtkAccelGroup is a struct class that is able to hold the accelerator key data for all the menus in a GtkWindow. It is usually attached to that window to avoid any confusion within an application. The information is held as a hash table of GtkAccelEntry entries, one of which needs to be created for each accelerator. In PHP-GTK there is no direct access to these entries.
Note
An accelerator key is the keyboard shortcut for a GtkMenuItem.
See also: add_accel_group() , add_accelerator() , GtkAccelLabel, GtkMenuItem.
GtkAccelGroup
();
Although not a part of the GTK object hierarchy, GtkAccelGroup can be constructed in the same way as most GTK classes, i.e.
In most cases, the newly-constructed GtkAccelGroup would be used by all the menus belonging to that toplevel window, and should be added to it using add_accel_group() .
It is not always necessary to create an accelerator group in this way. The GtkMenu method ensure_uline_accel_group() calls the GtkAccelGroup used internally by the menu for underline accelerators for the duration of the period that the menu is popped up. If none is designated, a new accelerator group is created and used.
lock() prevents further changes to the accelerator entries in the calling GtkAccelGroup.
To prevent further keys being altered, added to or removed from a single existing GtkAccelEntry, use lock_accelerators() .
unlock() allows accelerator entries to be altered, added to or removed from a previously locked GtkAccelGroup.
To allow a secondary key in a GtkAccelEntry to be designated by the user, use unlock_accelerators() .
A label that can display an accelerator key next to the text.
GtkObject
`-- GtkWidget
áááááá`-- GtkMisc
áááááááááááá`-- GtkLabel
áááááááááááááááááá`-- GtkAccelLabel
Constructor
— Constructs a label for displaying accelerator information.
GtkAccelLabel
(string string);Methods
get_accel_width()
Sets width to accommodate accelerator information. set_accel_widget()
Associates accelerator label with specified widget. refetch()
Recreates accelerator information.
A GtkAccelLabel is a label capable of displaying any accelerator, modifier keys and signal set on a GtkMenuItem or similar widget.
In PHP-GTK this is effectively an internal widget, as an accelerator label is created the moment a text string is passed to a menu item. It is therefore unlikely that you will ever need to use the constructor, or any of the methods that this class directly provides. However, you may need to access it, for instance to parse an underline in a label's text string or to retrieve a menu's textual content.
To access the GtkAccelLabel within an existing menu item, use the following code:
You will then be able to call most of the methods available to a new instance of a GtkAccelLabel.
GtkAccelLabel
(string string);
This is effectively an internal construct in PHP-GTK, and there should be no reason to use it unless you are writing an original widget.
See instead: GtkAccelLabel description, GtkLabel, add_accelerator() , parse_uline() .
get_accel_width() is used within GTK+ in order to find the width needed by the target menu item to accommodate any accelerator information displayed on the label.
There should be no reason to call this method unless you are writing an original widget.
void set_accel_widget
(
GtkWidget
accel_widget
);
set_accel_widget() is called within GTK+ at the point where a GtkAccelLabel is added to a menu item.
There should be no reason to call this method unless you are writing an original widget.
refetch() is called within GTK+ in order to create new accelerator information on a GtkAccelLabel following changes made to that information.
There should be no reason to call this method unless you are writing an original widget.
Represents an adjustable bounded value.
Constructor
— Creates the basis for an adjustable widget.
GtkAdjustment
(double value, double lower, double upper, double step_increment, double page_increment, double page_size);Methods
changed()
Emits changed signal. value_changed()
Emits value-changed signal. clamp_page()
Prevents bounds being exceeded. set_value()
Sets adjustment value. Signals
changed: Emitted when a property other than value changes. value_changed: Emitted when Properties
value : Current value. lower : Lower bound. upper : Upper bound. step_increment : Smaller incremental step value. page_increment : Larger incremental step value. page_size : Displayed area.
Any widget with a moving part has a GtkAdjustment at work behind it somewhere. The adjustment object is used to limit the range of values used by that moving part and also, in some widgets, to determine the size of the steps by which the value may be increased or decreased.
GtkAdjustment
(double value, double lower, double upper, double step_increment, double page_increment, double page_size);
Not every widget with an underlying adjustment object uses all six of the properties available. Where this occurs, null is not a valid parameter option; all the adjustment parameters take double values, and you will need to set them as 0.0 where they are not needed.
The first parameter, value, is used by every widget with an adjustable part. It represents the current value, and should be set to the value that you want to see displayed on opening. That setting will most often be 0.0 for percentage-based values (e.g. in a GtkProgressBar or in a GtkScrollbar), or 1.0 for literal values (e.g. in GtkSpinButton.
lower and upper are the next two parameters. These represent the limitations on the changing value; what is the lowest possible value, and what is the highest? Very often, the opening value is at the start of the rising scale, and will in that case be equal in value to the lower parameter setting. The way you choose to express the upper bound may depend on the step_increment, which is defined in the fourth parameter when it is used at all. For instance, you could set the upper bound at 100.0 and increment the value in steps of 1.0, or set it at 1.0 and increment the value in steps of 0.01, depending on what it is you are measuring or on your mood. Either goes the same distance.
The final two parameters are page_increment and page_size. Where these are used, the page_increment should have roughly 90% of the page_size value. If you set the page size to the same value as the upper bound, a GtkScrollbar using these values will be extended so that it cannot be scrolled. This can be a way to test whether your values are being set. In some widgets - GtkCList, GtkLayout, GtkText and GtkViewport - the adjustment values can be set internally by scrolling-aware container widgets, and these will override settings that are made manually. A GtkScrollbar, conversely, has no adjustment values until you set them. Caveat: if a scrollbar shares a GtkAdjustment object with a widget that has overriding pre-set values, the scrollbar will share the widget's adjustment settings as part of the process of becoming associated with that widget.
See also: GtkCList, GtkLayout, GtkProgressBar, GtkRange, GtkScale, GtkScrollbar, GtkScrolledWindow, GtkSpinButton, GtkText, GtkViewport, set_focus_hadjustment() , set_focus_vadjustment() .
The changed() method makes the adjustment object fire the changed signal. This method is called internally whenever there is a change to any of the GtkAdjustment's properties.
The value_changed() method is called internally whereever a signal emission is needed. It causes the value-changed signal to be emitted.
clamp_page() is used internally to ensure that, if a page is being scrolled down, the incremental value is not added to the end of the page in terms of extra space at the bottom. It compares the set bounds and the page size with the current adjustment value and prevents them from adding up to more than the sum of their parts.
This method sets the adjustment value to a new level. It doesn't work where that value has already been set by a widget or widgets; widget settings always take precedence over manual settings. Where it is allowed, it causes a value-changed signal to be emitted, if the value is within the adjustment range.
Adjustable widgets generally have their own wrapper method for setting the adjustment value, which should be used in preference where it exists.
The changed signal is emitted when any of the properties other than the value is altered in a GtkAdjustment. This happens when the adjustment object has its values initialised or unset, or when a widget-owned scrollable object is resized, or when the adjustable widget has a configure() method and calls it.
Note that a value-changed signal is also emitted under the same circumstances, regardless of whether the value itself has been changed.
Callback function:
void callback
(GtkAdjustment button);
The value-changed signal is emitted when there is a change to any of the values in a GtkAdjustment. If the signal is accompanied by a changed emission, the altered property was something other than value.
Callback function:
void callback
(GtkAdjustment button);
Type: Read Only
The value property represents the current value of a GtkAdjustment. This may be initialized manually or, in some instances, by a scrolling-aware parent widget. Anything descended from GtkContainer falls into the latter category.
In most cases, the value does not need any more attention after it has been set, and will be incremented or decremented purely through GdkEvents initiated by the user and controlled by the other adjustment settings. This property gives a means of accessing that information across all adjustable widgets.
Type: Read Only
lower is the lowest value that will be accepted by the GtkAdjustment.
Type: Read Only
upper is the highest value that will be accepted by the GtkAdjustment.
Type: Read Only
The step_increment is the smaller of the two incremental values, made manifest as a left click on a GtkSpinButton or GtkScrollbar arrow. This property is not used across the full range of adjustable widgets, and should return 0 when queried where this is the case.
Type: Read Only
The page_increment is the larger of the two incremental values, responding to a right click on a GtkSpinButton arrow or as a click in the trough belonging to a GtkScrollbar. This property is not used across the full range of adjustable widgets, and should return 0 when queried where this is the case.
Type: Read Only
The page_size is the area of (for instance) text that is displayed at any given time. This property is not used across the full range of adjustable widgets, and should return 0 when queried where this is the case.
A container that controls the alignment and scale of its child.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkAlignment
Constructor
— Creates a container that determines its child's alignment and scale.
GtkAlignment
(double xalign, double yalign, double xscale, double yscale);Methods
set()
Sets new parameter values for an existing GtkAlignment.
GtkAlignment is a container class that controls the alignment and scale of its child widget, relative to its own dimensions.
Where the child widget has sizing responsibilites to a child or children of its own, these are fulfilled as a priority. For example, a GtkButton with a label will never be scaled down to the minimal size that the same widget with no label can; the label is the button's child, and the button must honour its size request.
See also: GtkAspectFrame, GtkContainer, set_uposition() , set_usize() .
GtkAlignment
(double xalign, double yalign, double xscale, double yscale);
A GtkAlignment object has control over its child widget's relative position and size. Each parameter is a double, with the minimum value being 0.0 and the maximum value being 1.0.
The first two parameters describe the positioning of the child widget, with 0.0 being the left or top of the containing GtkAlignment and 1.0 being the right or bottom. A child with the setting 0.5, 0.5 as the first two parameters is fully centred, with scale being taken into consideration throughout.
The second pair of parameters determine the scale of the child widget, with the setting 1.0, 1.0 having the child widget fill the available area and the setting 0.0, 0.0 shrinking the child to its minimum possible size. If the widget has no children of its own, that can be just a couple of pixels in each direction - but it must obey the size requests made by any such children.
This method sets new values for a GtkAlignment's parameters.
Example 8. Resetting GtkAlignment parameters.
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); function change_it($align, &$i) { if($i%2) $align->set(1.0, 1.0, 0.4, 0.3); elseif($i%3) $align->set(0.0, 0.0, 0.6, 0.2); else $align->set(0.0, 1.0, 0.1, 0.2); $i++; } $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->set_default_size((gdk::screen_width()-10), (gdk::screen_height()-30)); $window->connect_object('destroy', array('gtk', 'main_quit')); $align = &new GtkAlignment(0.5, 0.5, 1.0, 1.0); $button = &new GtkButton("Click Here"); $i = 0; $button->connect_object('enter', 'change_it', $align, &$i); $align->add($button); $align->show_all(); $window->add($align); $window->show_all(); gtk::main(); |
An arrow pointing in one of the four cardinal directions.
Constructor
— Displays an arrow pointing in one of the four cardinal directions.
GtkArrow
( GtkArrowType arrow_type , GtkShadowType shadow_type );Properties
arrow_type : Direction of arrow's nose. shadow_type : Appearance of arrow.
The GtkArrow widget is a drawn triangle that has its "nose" pointing in the direction specified during construction. The look of the arrow is varied through the choice of GtkShadowType, and it inherits from the GtkMisc class the ability to have its own padding and alignment properties altered directly, both of which can also have a surprisingly big impact on the arrow's appearance.
GtkArrow
(
GtkArrowType
arrow_type
,
GtkShadowType
shadow_type
);
For a simple widget, there are a lot of options in the construction of the GtkArrow - twenty different combinations in all.
It may not be immediately obvious that the GtkArrow is made up entirely of lines of shadow. As a result of this, the GtkShadowType option GTK_SHADOW_NONE actually creates an invisible arrow - a potentially useful option to have, given that the parameters of the arrow can be redefined at any point using the set() method.
The syntax to create a right-pointing, etched arrow would be:
void set
(
GtkArrowType
arrow_type
,
GtkShadowType
shadow_type
);
This method redefines the parameters for an existing GtkArrow. It would typically be used within a callback function where the arrow was required to point in another direction, change its appearance and/or vanish.
Type: Read Only
The arrow_type property is a GtkArrowType enumerated value which can be queried to test in which direction the arrow is currently pointing.
Type: Read Only
The shadow_type property is a GtkShadowType enumerated value which can be queried to test the current style of the arrow's appearance.
A frame that constrains its child to a particular aspect ratio.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkFrame
áááááááááááááááááááááááá`-- GtkAspectFrame
Constructor
—
GtkAspectFrame
([string label = NULL, [double xalign = 0.5, [double yalign = 0.5, [double ratio = 1.0, [bool obey_child = TRUE]]]]]);Methods
set()
GtkAspectFrame
([string label = NULL, [double xalign = 0.5, [double yalign = 0.5, [double ratio = 1.0, [bool obey_child = TRUE]]]]]);
Base class for containers with just one child.
Properties
child : The child widget.
GtkBin is a container widget that is capable of holding only one child. All widgets derived from GtkBin therefore also can only contain one immediate child, although this child may itself contain multiple widgets.
Note that GtkBin is an abstract base class and cannot be constructed directly.
See also: GtkBox, GtkContainer.
Type: Read Only
This property allows access to the child widget contained by the GtkBin object. It can be treated like any other GtkWidget. If the value of this property is NULL, then GtkBin object does not contain a child widget.
Base class for box containers.
Methods
pack_start()
Packs from top or left of box container. pack_end()
Packs from bottom or right of box container. pack_start_defaults()
Packs from top or right using default settings. pack_end_defaults()
Packs from bottom or left using default settings. set_homogeneous()
Toggles equality of child sizing. set_spacing()
Sets spacing between children. reorder_child()
Sets new position for child. set_child_packing()
Sets packing parameters for child. query_child_packing()
Queries packing parameters for child. Properties
children : Array of child packing information. spacing : Universal spacing policy. homogeneous : Universal sizing policy.
GtkBox is a base class providing box containers GtkHBox and GtkVBox with properties and methods for packing any number of child widgets.
Note that GtkBox is an abstract class and cannot be constructed directly.
See also: GtkBin, GtkBoxChild, GtkContainer, GtkTable.
void pack_start
(
GtkWidget child
, [bool
expand = true
, [bool
fill = true
, [int
padding = 0
]]]);
pack_start() packs the child widget from the top or left of the box container. The expand parameter is a boolean value that determines whether the child can expand when the parent container is resized. The second parameter fill is also a boolean value, and determines whether the child should fill the space available to it. The third parameter padding is an integer describing the padding around the child widget, in pixels. The default values are true, true, 0.
Calls to pack_start() can be mixed with calls to pack_end() or even add() , within the same box container.
void pack_end
(
GtkWidget child
, [bool
expand = true
, [bool
fill = true
, [int
padding = 0
]]]);
pack_end() packs the child widget from the bottom or right of the box container. The expand parameter is a boolean value that determines whether the child can expand when the parent container is resized. The second parameter fill is also a boolean value, and determines whether the child should fill the space available to it. The third parameter padding is an integer descrbing the padding around the child widget, in pixels. The default values are true, true, 0.
pack_end() calls may be interspersed with pack_start() calls within the same box container widget.
void pack_start_defaults
(
GtkWidget widget
);
pack_start_defaults() packs the given child widget from the top or from the left of the box container using the default parameter values true, true, 0.
The same result can be achieved by using
without specifying any further parameters.
void pack_end_defaults
(
GtkWidget widget
);
pack_end_defaults() packs the given child widget from the bottom or from the right of the box container using the default parameter values true, true, 0.
The same result can be achieved by using
without specifying any further parameters.set_homogeneous() sizes all the child widgets in the container to the dimensions of the largest child widget if set to true. The default setting is false.
Note that the homogeneous property corresponding to this function refers to the child sizing in only one dimension, that is, the height in a row or the width in a column.
set_spacing() is used to set the universal minimum spacing between the child widgets, in pixels.
The default setting is 0.
void reorder_child
(
GtkWidget child
, int position);
reorder_child() moves the child's position in the children array to the position given as the second parameter.
void set_child_packing
(
GtkWidget child
, bool expand, bool fill, int padding,
GtkPackType pack_type
);
set_child_packing() sets the GtkBoxChild parameters for the child widget.
array query_child_packing
(
GtkWidget child
);
query_child_packing is a way to query the GtkBoxChild parameters expand, fill, padding and pack_type for an individual child widget.
Type: Read Only
The packing information for the individual child widgets is stored in children as an array of GtkBoxChild objects.
Type: Read Only
The spacing property represents the minimum amount of space between the child widgets, in pixels. This setting is universal across the box container.
To set the spacing for an individual child widget, use pack_start() , pack_end() , set_child_packing() , or the padding property in GtkBoxChild.
Type: Read Only
The homogeneous property is a boolean value which, when set to true, will make all child widgets in the container the same size as the largest child.
Use set_homogeneous() to set the value.
Note that the value of this property only affects one dimension, as the children will always fit the height of a row, or the width of a column, regardless of settings.
Helper class for GtkBox.
Properties
widget : Child widget. padding : Child padding. expand : Child expand toggle. fill : Child fill toggle. pack : Child packing type.
GtkBox is a base class providing box container widgets with properties and methods related to packing multiple child widgets.
GtkBoxChild is a helper class that allows access to the widget and packing information for each individual child. The children property in GtkBox is an array of GtkBoxChild objects corresponding to packed child widgets.
Note that neither GtkBox nor GtkBoxChild can be constructed directly.
Type: Read Only
The widget property provides access to the child widget object.
It is possible to access methods, properties and signals belonging to widget as with any GtkWidget of the same type.
$button = $vbox->children[5]->widget; $label = $button->child; $label->set_text("New Button Label"); |
Type: Read Only
The padding property is an integer showing the padding around the widget , in pixels.
The default setting for padding is 0.
Type: Read Only
The expand property is a boolean value describing whether or not the space around the widget should be allowed to expand when the parent container is resized.
The child widget is centered within its available space.
The default setting for expand is true.
Type: Read Only
The fill property is a boolean value describing whether or not the widget should be allowed to fill the space available to it.
Where the expand property is false and the fill property is true, the child widget is positioned as close as its padding will allow to that edge of its available space determined by its pack value.
Type: Read Only
The pack property is a GtkPackType enum indicating where the child widget is packed in reference to the parent widget - start or end.
A container widget that emits a signal when clicked on.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkButton
Constructor
— Creates a button.
GtkButton
([string label ]);Methods
pressed()
Emits pressed signal. released()
Emits released signal. clicked()
Emits clicked signal. enter()
Emits enter signal. leave()
Emits leave signal. set_relief()
Sets the button relief style. get_relief()
Gets the button relief style. Signals
enter: Emitted when the cursor is over the button. pressed: Emitted when the button is initially pressed. clicked: Emitted when the button is clicked. released: Emitted when the button is released. leave: Emitted when the cursor leaves the button area.
The GtkButton widget is a container widget that can hold any valid child widget derived from GtkWidget. The most commonly used child widget is a GtkLabel. This is therefore built into the constructor as an optional parameter.
The GtkButton widget is mainly used to call some function when the button is pressed.
GtkButton
([string
label
]);
This function creates and returns a GtkButton widget. If the optional label is passed, the button will contain a GtkLabel widget with the given text. If the parameter is left empty, there will be no child widget.
Note that, as GtkButton is descended from GtkBin, it may contain only one child.
Example 9. Adding more than one widget to a GtkButton
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); $window = &new GtkWindow(GTK_WINDOW_DIALOG); $window->set_position(GTK_WIN_POS_MOUSE); $window->connect_object('destroy', array('gtk', 'main_quit')); $window->realize(); list ($gdkpixmap, $mask) = gdk::pixmap_create_from_xpm($window->window, null, "test.xpm"); $pixmap = &new GtkPixmap($gdkpixmap, $mask); $label = &new GtkLabel("Open"); $vbox = &new GtkVBox(); $vbox->pack_start($pixmap); $vbox->pack_start($label); $button = &new GtkButton(); $button->add($vbox); $vbox->show_all(); $window->add($button); $window->show_all(); gtk::main(); |
Makes the button emit the pressed signal.
Makes the button emit the released signal.
Makes the button emit the clicked signal.
Makes the button emit the enter signal.
Makes the button emit the leave signal.
void set_relief
(
GtkReliefStyle
newstyle
);
Sets the relief style of the button widget edges using one of the three GtkReliefStyle settings. The default relief style is GTK_RELIEF_NORMAL.
GtkReliefStyle
get_relief
(void);
Returns the current GtkReliefStyle setting for the button.
The enter signal is emitted when the cursor enters the area of the screen where the button is positioned.
Callback function:
void callback
(GtkButton button);
The pressed signal is emitted when the user presses down the mouse-button and the cursor is over the widget.
Callback function:
void callback
(GtkButton button);
The clicked signal is emitted at the midpoint between pressing and releasing the mouse-button. This is the most commonly used GtkButton signal, and holds an advantage over the other signals listed here in that it also responds to enter or spacebar keypresses as though they were mouse-clicks. Signals that have this property have a direct relationship with GtkWidget's activate signal; all interactive widgets contain one such method/signal pair.
Note that the clicked signal will not fire when the mouse-button is released after the cursor has left the widget's region. The activate type of signals are by nature region-specific.
Use one of the connect() methods in order to emit the signal and connect it to your function. The connected function is known as the callback or signal-handler function:
Example 10. Making a simple connection
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); function my_function() { echo "The button was clicked\n"; } $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_MOUSE); $window->connect_object('destroy', array('gtk', 'main_quit')); $button = &new GtkButton("Click Me"); $button->connect('clicked', 'my_function'); $window->add($button); $window->show_all(); gtk::main(); |
Callback function:
void callback
(GtkButton button);
The released signal is emitted when the user releases the mouse-button, regardless of the cursor position.
Callback function:
void callback
(GtkButton button);
The leave signal is emitted when the cursor leaves the area of the screen where the button is positioned.
Callback function:
void callback
(GtkButton button);
Base class for GtkHButtonBox and GtkVButtonBox.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkButtonBox
Methods
get_spacing()
Returns spacing between buttons. *deprecated in GTK2* get_layout()
Retrieves the layout style setting. set_spacing()
Sets spacing between buttons. *deprecated in GTK2* set_layout()
Sets the button layout style. set_child_size()
Sets minimum child size. *deprecated in GTK2* set_child_ipadding()
Sets child's internal padding. *deprecated in GTK2*
GtkButtonBox is a base class providing a series of layout options for buttons packed into GtkHButtonBox and GtkVButtonBox container widgets.
Note
Please note that in GTK+ 2.0 all reference to spacing will be completely removed; this is because these values are always relative in GtkButtonBox classes, and should be adjusted internally.
get_spacing() returns the integer value representing the spacing in pixels between the buttons contained in a GtkButtonBox.
Note that this method is deprecated in GTK+ 2.0 and should not be used where forward compatibility is an issue.
GtkButtonBoxStyle
get_layout
(void);
get_layout() retrieves the current GtkButtonBoxStyle setting.
set_spacing() sets the spacing between the buttons, in pixels. See also gtk::hbutton_box_set_spacing_default() or gtk::vbutton_box_set_spacing_default() to set the spacing default across an entire application. If you don't change it, the default setting is currently 10 pixels for GtkVButtonBox, or 30 for GtkHButtonBox.
Note that this method is deprecated in GTK+ 2.0. Where forward compatibility is an issue, use set_layout() instead.
void set_layout
(
GtkButtonBoxStyle
layout_style
);
set_layout() sets the spacing arrangement of the buttons in accordance with one of the five GtkButtonBoxStyle settings.
The default setting is always the GTK_BUTTONBOX_DEFAULT_STYLE, which is itself pre-set to GTK_BUTTONBOX_EDGE. This can be reset for an entire application by using gtk::hbutton_box_set_layout_default() or gtk::vbutton_box_set_layout_default() .
set_child_size() sets the minimum size for any child in the GtkButtonBox widget, in pixels.
The default setting is (85, 27).
Note that this method is deprecated, and that minimum sizing will be set internally in future versions of GTK+.
set_child_ipadding() sets the amount to increase the width and height of the space requested by the buttons.
The default settings are currently (7, 0).
Note that this method is deprecated, and that internal padding will be set by the widget itself in future versions of GTK+.
A calendar offering dates that can be selected and marked.
Constructor
— Creates a calendar widget.
GtkCalendar
(void);Methods
select_month()
Determines the month and year displayed. select_day()
Determines the selected day. mark_day()
Marks the given day. unmark_day()
Unmarks the given day, if marked. clear_marks()
Clears all marked dates. display_options()
Sets flags determining the appearance of the calendar. get_date()
Returns currently selected date. freeze()
Freezes the display to allow updates. thaw()
Thaws the display following updates. Signals
month-changed: Emitted whenever the displayed month is changed. day-selected: Emitted when a day is selected. day-selected-double-click: Emitted when the mouse is clicked twice on a day. prev-month: Emitted when user chooses to go back one month. next-month: Emitted when user chooses to go forward one month. prev-year: Emitted when user chooses to go back one year. next-year: Emitted when user chooses to go forward one year. Properties
month : Currently selected month. year : Currently selected year. selected_day : Currently selected day. num_marked_dates : Number of marked dates held. marked_date : Array of marked dates.
A GtkCalendar is a widget consisting of a grid container displaying a calendar, with an optional label allowing month/year navigation and an optional header giving abbreviated day names.
Both the day and the month names are supplied by the system locale, and cannot be overwritten. Unfortunately, under win32 there are severe problems with internationalization in the GDK source currently used by PHP-GTK. Non-standard ISO8859-1/2 characters cannot be drawn in this widget as a result of a wide character conversion failure under Windows. Multibyte characters are not recognised, and as they are supplied directly by the system to the widget there is no option to convert them using PHP. This issue is gradually being addressed by the PHP-GTK development team on a widget-by-widget basis.
Assuming that your locale and your operating system will allow you to use this widget's headers, the only other point to keep in mind is that a marked date is differentiated from the other dates by being drawn on a slightly bigger base rectangle, making it appear bold while actually using the same font as the rest of the widget. This is less effective in some fonts than in others, and can become a very negligable distinction.
GtkCalendar
(void);
Creates a calendar widget, set to display the current month and year.
Example 11. Changing the style of a GtkCalendar
dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" : "so")); $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object("destroy", array("gtk", "main_quit")); /* create the calendar and add it to the window. */ $calendar = &new GtkCalendar(); $window->add($calendar); /* create a new style for the calendar, based on the old one */ $oldstyle = $calendar->style; $newstyle = $oldstyle->copy(); $font = gdk::font_load('-unknown-Arial-normal-r-normal--*-160-*-*-p-0-iso8859-1'); $red = &new GdkColor(255*255, 0, 0); $newstyle->font = $font; $newstyle->fg[GTK_STATE_SELECTED] = $red; $calendar->set_style($newstyle); /* have today's date highlighted on opening */ $calendar->select_day(date('d')); $window->show_all(); gtk::main(); |
This method determines the month and year displayed on opening. The default setting is the current month and year, taken from the operating system.
If the display option flag GTK_CALENDAR_NO_MONTH_CHANGE is set, the user will be unable to switch from the month and year passed as parameters.
Note that the month must be in the range 0 to 11, similar to PHP's date('m'). The year is in 4-digit format, as in 2002 the format returned by date('Y').
select_day() specifies the day number that will be selected (i.e. highlighted).
Note that if there are no further instructions, the same day will be highlighted throughout the months and years in the calendar.
The default selected day is 1, with the range being 1 to 31. Selecting an impossible day within that range - e.g. February 30th - does not return an error message, as the day number is not associated with the month and year information in this method.
Switches the appropriate marked_date to true and marks the day number by making it appear bold. If no further instructions are given, the same day number will be marked throughout the calendar.
There is no limit to the number of marked days in a month. There is also no limit to the range.
Switches the appropriate marked_date to false, if it is true, and unmarks the day.
If the day was not marked, this method has no effect whatever.
Given that marked dates are identical on every calendar page, you will probably need to clear them and set a new bunch of marked dates when the month is changed. These are best stored in a file or files, e.g.
function new_month($calendar) { $calendar->clear_marks(); $selected = $calendar->get_date(); $month = ($selected[1]+1); $year = $selected[0]; if(file_exists("diary/$year/marked_dates_$month.txt")) { $dates = fopen("diary/$year/marked_dates_$month.txt", 'r'); $string = explode(',', fgets($dates)); $calendar->freeze(); for($i = 0; $i < 31; $i++) { if($string[$i]==true) $calendar->mark_day($i+1); } $calendar->thaw(); fclose($dates); } } $calendar->connect('month-changed', 'new_month'); |
void display_options
(
GtkCalendarDisplayOptions
flags
);
Use display_options() to choose which elements of the calendar should be displayed via GtkCalendarDisplayOptions.
The default setting is GTK_CALENDAR_SHOW_HEADING | GTK_CALENDAR_SHOW_DAY_NAMES.
get_date() returns the currently selected calendar date as an array. The contents are the year (e.g. 2002), the month (1 - 12), and the day (1 - 31), in that order.
The range for the month is 1 - 12 here, but 0 - 11 in the select_month() method. Marked dates also run from 0. Beware!
freeze() is used to prevent the screen flickering during an update as each string in the monthly array is evaluated and redrawn. Place it before an update loop.
See also: thaw() .
thaw() is the corollary to freeze() , and is placed after an update routine.
The month-changed signal is emitted whenever the month on display changes, regardless of the way in which this is achieved. As the month and year information are tied, January 2002 is not the same month as January 2003 - the signal will be fired for a year change, too.
Callback function:
void callback
(GtkCalendar calendar);
The day-selected signal is emitted when a day has been selected, regardless of the way in which this is achieved.
Callback function:
void callback
(GtkCalendar calendar);
The day-selected-double-click signal is fired when the user clicks the mouse on a day number twice in quick succession.
Callback function:
void callback
(GtkCalendar calendar);
The prev-month signal is emitted when the user either clicks on the month arrow back, or when the user selects a greyed-out day from the previous month. It cannot be emitted through the program itself; use month-changed if you need to do this.
Callback function:
void callback
(GtkCalendar calendar);
The next-month signal is emitted when the user either clicks on the month arrow forward, or when the user selects a greyed-out day from the following month. It cannot be emitted through the program itself; use month-changed if you need to do this.
Callback function:
void callback
(GtkCalendar calendar);
The prev-year signal is emitted when the user either clicks on the year arrow back, or when the user selects a greyed-out day from the previous December when January is currently displayed. It cannot be emitted through the program itself; use month-changed if you need to do this.
Callback function:
void callback
(GtkCalendar calendar);
The next-year signal is emitted when the user either clicks on the year arrow forward, or when the user selects a greyed-out day from the following January when December is currently displayed. It cannot be emitted through the program itself; use month-changed if you need to do this.
Callback function:
void callback
(GtkCalendar calendar);
Type: Read Only
The month property is an integer representing the currently selected month. This will be in the range 0 - 11.
Type: Read Only
The year property is an integer representing the currently selected year. This is in the 4-digit format, i.e. 2002.
Type: Read Only
The selected_day property is an integer representing the currently selected day. This will be in the range 1 - 31.
Type: Read Only
The num_marked_dates property is an integer representing the number of marked dates set to true in the current marked_date array. If you are using GtkCalendar fully, you are likely to have several of these arrays - one for each month, at a minimum. This property is tied to the array.
Type: Read Only
The marked_date property is an array of 31 comma-separated values, all of which are either the default false or, if marked, true.
The array count begins at zero, whereas the days in the calendar begins at 1. You will need to add 1 to an integer representing the position of a marked date, to compensate for this mismatch.
Button that displays a discrete toggle indicator.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkButton
áááááááááááááááááááááááá`-- GtkToggleButton
áááááááááááááááááááááááááááááá`-- GtkCheckButton
Constructor
— Creates a button with a small toggle indicator.
GtkCheckButton
([string label ]);
The GtkCheckButton widget is basically a different style of GtkToggleButton. Instead of the entire button acting as the toggle indicator, a small button to the left of the text position appears 'pressed in' when the toggle is in the GTK_STATE_ACTIVE state.
See also: GtkRadioButton, GtkStateType, GtkToggleButton.
GtkCheckButton
([string
label
]);
instantiates a normal-sized GtkButton with a small draw_indicator toggle to the left of the button's label area. The indicator displays the GtkShadowType GTK_SHADOW_IN when the check button's GtkStateType is set as GTK_STATE_ACTIVE.
See also: GtkButton, GtkCheckMenuItem, GtkToggleButton.
Menu item with a toggle indicator.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkMenuItem
áááááááááááááááááááááááááááááá`-- GtkCheckMenuItem
Constructor
— Creates a GtkMenuItem with a toggle indicator.
GtkCheckMenuItem
([string label ]);Methods
set_active()
Toggles the active state. set_show_toggle()
Determines whether toggle indicator should be displayed. toggled()
Emits the toggled signal. Signals
toggled: Emitted when the toggled() method is called. Properties
active : 'Active' toggle.
A GtkCheckMenuItem is a normal GtkMenuItem that contains a toggle indicator positioned to the left of any GtkAccelLabel text. The indicator does not necessarily have to be displayed during the time that the menu item is set to its inactive state, but is always displayed when the state is set as active.
GtkCheckMenuItem
([string
label
]);
is the syntax that will create a new menu item with an indigenous toggle indicator placed to the left of any existing text. The GtkCheckMenuItem may be set to the active state - GtkStateType GTK_STATE_ACTIVE - or to the inactive state, GTK_STATE_NORMAL. When it is in the inactive state, the toggle indicator need not be displayed.
set_active() sets the state of the calling GtkCheckMenuItem to either the GTK_STATE_ACTIVE or the GTK_STATE_NORMAL GtkStateType. When the menu item is in its active state, the toggle indicator is always displayed.
will set the GtkCheckMenuItem's state to active.
The default setting is false.
set_show_toggle() determines whether the toggle indicator should be visible at all times, or only when the menu item is active.
The default setting is false.
toggled() causes the calling GtkCheckMenuItem to emit the toggled signal.
The toggled signal is emitted when the toggled() method is called. This is called internally when the GtkCheckMenuItem's activate signal is emitted - that is, when a user clicks on the menu item or presses the Enter or Space key while the item is selected. The signal is also emitted when calling the set_active() method.
Note that the state-switching triggered by activation is not directly related to the toggled signal.
Callback function:
void callback
(
GtkCheckMenuItem checkmenuitem
);
Type: Read Only
The active property provides a means of testing whether the GtkCheckMenuItem is currently in the active state - in which case the returned value will be true - or otherwise.
$active_state = $checkmenuitem->active; if($active_state == 1) echo "This GtkCheckMenuItem is active\n"; |
A multi-columned scrolling list widget.
Constructor
—
GtkCList
(XXX);Methods
set_hadjustment()
set_vadjustment()
get_hadjustment()
get_vadjustment()
set_shadow_type()
set_selection_mode()
set_reorderable()
set_use_drag_icons()
set_button_actions()
freeze()
thaw()
column_titles_show()
column_titles_hide()
column_title_active()
column_title_passive()
column_titles_active()
column_titles_passive()
set_column_title()
get_column_title()
set_column_widget()
get_column_widget()
set_column_justification()
set_column_visibility()
set_column_resizeable()
set_column_auto_resize()
columns_autosize()
optimal_column_width()
set_column_width()
set_column_min_width()
set_column_max_width()
set_row_height()
moveto()
row_is_visible()
get_cell_type()
set_text()
get_text()
set_pixmap()
set_pixtext()
set_foreground()
set_background()
set_cell_style()
get_cell_style()
set_row_style()
get_row_style()
set_shift()
set_selectable()
get_selectable()
prepend()
append()
insert()
remove()
select_row()
unselect_row()
undo_selection()
clear()
select_all()
unselect_all()
swap_rows()
row_move()
set_sort_column()
set_sort_type()
sort()
set_auto_sort()
GtkCList
(XXX);
void set_hadjustment
(GtkAdjustment adjustment);
void set_vadjustment
(GtkAdjustment adjustment);
GtkAdjustment get_hadjustment
(void);
GtkAdjustment get_vadjustment
(void);
void set_shadow_type
(GtkShadowType type);
void set_selection_mode
(GtkSelectionMode mode);
void set_column_widget
(int column, GtkWidget widget);
GtkWidget get_column_widget
(int column);
void set_column_justification
(int column, GtkJustification justification);
GtkVisibility row_is_visible
(int row);
GtkCellType get_cell_type
(int row, int column);
void set_foreground
(int row, GdkColor color);
void set_background
(int row, GdkColor color);
void set_cell_style
(int row, int column, GtkStyle style);
GtkStyle get_cell_style
(int row, int column);
void set_row_style
(int row, GtkStyle style);
GtkStyle get_row_style
(int row);
void set_sort_type
(GtkSortType sort_type);
Properties
state : foreground : background : style : fg_set : bg_set : selectable :
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Widget that allows for selection of a color.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkVBox
áááááááááááááááááááááááá`-- GtkColorSelection
Constructor
—
GtkColorSelection
(void);
GtkColorSelection
(void);
void set_update_policy
(GtkUpdateType policy);
Standard dialog box for selecting a color.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
áááááááááááááááááááááááá`-- GtkColorSelectionDialog
Constructor
—
GtkColorSelectionDialog
(string title);
GtkColorSelectionDialog
(string title);
Text entry field with a dropdown list.
Constructor
— Creates an entry box with a dropdown list.
GtkCombo
(void);Methods
set_value_in_list()
Toggles whether entry value must be matched in list. set_use_arrows()
Toggles whether list can be scrolled within entry box. set_use_arrows_always()
Toggles whether entry box list-scrolling should loop. set_case_sensitive()
Toggles whether matching should be case-sensitive. set_item_string()
Sets string associated with list item. set_popdown_strings()
Simple list construction. disable_activate()
Prevents return key from opening dropdown list. Properties
entry : Text entry field. list : Dropdown list.
A GtkCombo appears to be the equivalent of the select element in HTML. This can be misleading if you're coming directly from a web development background; a GUI widget is largely about appearance, and carrying hidden values is not something this one will do without a little programming. Luckily, there are a trio of invaluable GtkObject methods that will do just that, with any object and with any form of data. These are get_data() , set_data() and remove_data() . See the sample under GtkCombo's constructor to get an idea of their usage.
There are a few key bindings in the combo widget. Most of them have some bearing on searches.
Table 0. Key bindings in GtkCombo
Key combination Function Return (from the entry box) Opens up the list. If the entry contains text that fully matches a list item's content, that list item will be selected on opening. Tab + MOD_1 mask (from the entry box) The MOD_1 modifier is usually Alt. This key combination auto-completes a partial entry. Arrow up (from the entry box) If use_arrows has been set to true, scrolls up through the list without opening the list window. Can also be achieved with keypad arrow or Alt + p. Arrow down (from the entry box) If use_arrows has been set to true, scrolls down through the list without opening the list window. Can also be achieved with keypad arrow or Alt + n. Return (from the list box) Toggles the list item that has current focus. Spacebar (from the list box) Selects the list item that has current focus. Up arrow (from the list box) Scrolls up through the list items. Down arrow (from the list box) Scrolls down through the list items. Esc (from the list box) Removes grab from the list box, which closes it. See also: GtkEditable, GtkEntry, GtkItem, GtkList, GtkListItem, GtkOptionMenu.
GtkCombo
(void);
When the GtkListItem has been selected in a GtkCombo, the combo's entry text is picked up from the item, and the combo's list is searched for a data match. The unselect-child signal is fired by the list during this routine in order to clear previously existing data. If you connect to either that or the deselect signal, your callback function will run twice. The same applies to the select-child and select signals, as the deselection allows the item to be selected again - which it is, when select_child() is called immediately afterwards.
There are many ways of working around this. One is given in the sample below.
Example 12. Associating data with a GtkListItem
dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" : "so")); function on_click($item, $event, $i) { echo $item->get_data($i)."\n"; flush(); } function on_key($item, $i) { echo $item->get_data($i)."\n"; flush(); } $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object("destroy", array("gtk", "main_quit")); $combo = &new GtkCombo(); /* The GtkEntry and GtkList are accessible through the combo's properties */ $entry = $combo->entry; $entry->set_text('Choose some fruit'); $list = $combo->list; $list->set_selection_mode(GTK_SELECTION_SINGLE); $fruit = array('apples', 'bananas', 'cherries', 'damsons', 'eggplants', 'figs', 'grapes'); for($i = 0; $i < count($fruit); $i++) { $item = &new GtkListItem(); /* You can put pretty much anything into a GtkListItem */ $box = &new GtkHBox(); $arrow = &new GtkArrow(GTK_ARROW_RIGHT, GTK_SHADOW_OUT); $box->pack_start($arrow, false, false, 5); $label = &new GtkLabel('Item '.($i+1)); $box->pack_start($label, false, false, 10); $item->add($box); $combo->set_item_string($item, "You chose $fruit[$i]"); $data = $fruit[$i]; /* This data will be carried with the $item. The key here is $i. */ $item->set_data($i, $data); /* Two separate signals to get around the 'select' problem. */ $item->connect('button-press-event', 'on_click', $i); $item->connect('toggle', 'on_key', $i); $list->add($item); $item->show_all(); } $window->add($combo); $window->show_all(); gtk::main(); |
This method used to make the combo emit a beep if the entry value could not be matched in the list. It no longer does this, and nor does it print an error message when the search string is invalid. Effectively broken.
set_use_arrows() , when set to false prevents the Up and Down arrow keys from being used to scroll the list within the combo's entry box.
The default value is true, which allows such scrolling where there is a match between the entry text and one of the list item strings.
This method is the adult version of set_use_arrows() . The chief difference is that the entry box text does not need to match the text string in a list item in order for the arrows to be used. The secondary difference is that the scrolling loops back to the start of the list when the final item is reached, and vice versa.
set_case_sensitve(), if set to true, will not match items that are dissimilar with regard to case -in other words, Cat is not the same thing as cat.
The default behaviour is that a string in the combo's entry box that is accurate in all the ways other than case will be altered to match the list version of that string.
void set_item_string
(
GtkItem item
, string item_value);
As you may have noticed in the GtkCombo constructor example, it is not by any means essential that the items in a GtkList are GtkListItems. This method is intended to provide a way to give an alternative to the entry box, where only the string data type is allowed.
set_item_string() can be set regardless of whether there is already text in the list item, and in either case will provide the string that is compared against the entry's text content during search routines.
This method determines the string that will be displayed in the entry field after the list item has been selected.
Use this method to create the GtkListItems to populate the list, where only the labels themselves are necessary data.
Example 13. The easy way to fill a GtkCombo's list
dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" : "so")); function print_this($list, $item) { $label = $item->child; echo $label->get()."\n"; flush(); } $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object("destroy", array("gtk", "main_quit")); $combo = &new GtkCombo(); $fruit = array('apples', 'bananas', 'cherries', 'damsons', 'eggplants', 'figs', 'grapes'); $combo->set_popdown_strings($fruit); /* We don't have handles for these list items, so we connect them through the GtkList. The child is passed to the callback with the select-child signal. */ $list = $combo->list; $list->connect('select-child', 'print_this'); $window->add($combo); $window->show_all(); gtk::main(); |
Normally the activate signal is emitted when the return key is pressed and the GtkEntry has keyboard grab. This signal emission results in the dropdown list being exposed.
disable_activate() simply disconnects the activate signal when it is set.
Type: Read Only
The entry property provides a way of retrieving information directly from the GtkEntry part of the combo widget.
Type: Read Only
The list property provides a way of retrieving information directly from the GtkList part of the combo widget.
Base class for all container widgets.
Methods
set_border_width()
Sets border width. add()
Adds child widget to container. remove()
Removes child widget from container. set_resize_mode()
Sets priority of resize requests. check_resize()
Emits check_resize signal. children()
Returns array of container's child widgets. focus()
Queues child focus in a given direction. set_reallocate_redraws()
Toggles whether redraws are necessary. set_focus_child()
Sets initial child focus. set_focus_vadjustment()
Sets focus on a vertical GtkAdjustment. set_focus_hadjustment()
Sets focus on a horizontal GtkAdjustment. register_toplevel()
Registers container as toplevel. unregister_toplevel()
Unregisters a toplevel container. resize_children()
Resizes child widgets. child_type()
Describes expected child type. Signals
add: Emitted when the add() method is called. remove: Emitted when the remove() method is called. check-resize: Emitted when the check_resize() method is called. focus: Emitted when the focus() method is called. set-focus-child: Emitted when the set_focus_child() method is called.
GtkContainer is an abstract base class providing all widgets derived from it with the ability to contain child widgets.
It also endows those child widgets with a resizing mechanism.
set_border_width sets the width of the container's border, in pixels.
The default setting is 0.
void add
(
GtkWidget
widget
);
add() adds the child widget passed as the parameter to the container.
See also: GtkBin, GtkBox, pack_start() , pack_end() .
void remove
(
GtkWidget
widget
);
remove() removes the child widget passed as the parameter from the container, regardless of the method used to pack that child.
void set_resize_mode
(
GtkResizeMode
resize_mode
);
set_resize_mode() sets the priority of any resize requests for the container widget calling the method. The standard behaviour is to have any such requests added to a queue; setting the resize mode to GTK_RESIZE_IMMEDIATE bypasses that queue.
check_resize() emits the check-resize signal, which triggers a series of functions to check exactly what needs to be resized before either resetting the container's size allocation or calling the resize_children() method.
This method is mostly used internally.
children() provides an alternative means of accessing a container's child widgets, the other being through the container's properties.
The chief and potentially useful difference is that the array returned by this method consists of the child widget itself rather than a sub-array of information related to the child's packing dimensions. Note that the array returned by either method is reversed, so that the last item added to the container has the position [0].
int focus
(
GtkDirectionType
direction
);
focus() creates an internal array of the child widgets able to have focus, and sorts it according to the direction given. The first child in the array will receive focus on opening.
To be included in this array, child can be taken as any widget having the container in its ancestry; it need not be a direct child of the container.
set_reallocate_redraws() toggles whether redraws are necessary for the container, and if set to true will initiate the GtkWidget method queue_draw() as appropriate, allowing the content of the container to be re-set on the fly.
The default setting is false.
void set_focus_child
(
GtkWidget
child
);
set_focus_child() is used to denote which child widget should receive focus on opening.
void set_focus_vadjustment
(
GtkAdjustment
adjustment
);
set_focus_vadjustment() sets a vertical instance of a GtkAdjustment to have focus. In practice, this means that the adjustment will respond to changes made by the user, e.g. the position of a vertical scrollbar's handle in a GtkScrolledWindow will reflect the current focus within the scrolled window, when called from the scrolled window's container.
There is a method named get_vadjustment() which is implemented in all the classes where this method is likely to be utilised. Use it to provide the parameter.
void set_focus_hadjustment
(
GtkAdjustment
adjustment
);
set_focus_hadjustment() sets a horizontal instance of a GtkAdjustment to have focus, allowing it to act in synchronicity with the movement of the adjusted widget.
See also: set_focus_vadjustment() , GtkAdjustment.
register_toplevel() adds the calling container to an internal array of widgets having toplevel status within that application.
Registering a container as toplevel can speed up some of the processing involved in resizing.
unregister_toplevel() removes the calling container from an internal array of widgets having toplevel status. Note that the container must first have been prepended to this array using register_toplevel() ; simply declaring a container as toplevel does not add it to the registry.
resize_children() resizes child widgets following an alteration in their size requests.
child_type() returns an integer describing the type of child the container is expecting to be packed into it. This is mostly for internal use, but could perhaps be useful for diagnosis.
The return values are as follows from most containers:
GTK_TYPE_NONE = 1 (generated where no widget can be added, e.g. by a descendant of GtkBin already containing a child, or a GtkPaned already containing both children, or a GtkOptionMenu)
GTK_TYPE_WIDGET = 39701 (generated where non-specific widgets may be added, e.g. by GtkBox descendants, GtkNotebook, GtkFixed, GtkPacker or GtkTable)
The exceptions are GTK_TYPE_LIST_ITEM, GTK_MENU_ITEM and GTK_TREE_ITEM, all of which can be any of a variety of widget types depending on how the items are produced.
The add signal is emitted when the add() method is called.
It is generally used internally.
Callback function:
void callback
(GtkContainer container, GtkWidget child);
The remove signal is emitted when the remove() method is called.
It is generally used internally.
Callback function:
void callback
(GtkContainer container, GtkWidget child);
The check-resize signal is emitted when the check_resize() method is called.
It is generally used internally.
Callback function:
void callback
(GtkContainer container);
The focus signal is emitted when the focus() method is called.
It is generally used internally.
Callback function:
void callback
(GtkContainer container, GtkDirectionType direction);
The set-focus-child signal is emitted when the set_focus_child() method is called.
It is generally used internally.
Callback function:
void callback
(GtkContainer container, GtkWidget child);
Widget that displays a hierarchical tree.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkCList
áááááááááááááááááá`-- GtkCTree
Constructor
—
GtkCTree
(XXX);Methods
insert_node()
remove_node()
post_recursive()
post_recursive_to_depth()
pre_recursive()
pre_recursive_to_depth()
is_viewable()
last()
node_nth()
find()
is_ancestor()
is_hot_spot()
move()
expand()
expand_recursive()
expand_to_depth()
collapse()
collapse_recursive()
collapse_to_depth()
toggle_expansion()
toggle_expansion_recursive()
select()
select_recursive()
unselect()
unselect_recursive()
node_set_text()
node_set_pixmap()
node_set_pixtext()
set_node_info()
node_set_shift()
node_set_selectable()
node_get_selectable()
node_get_cell_type()
node_get_text()
node_get_pixtext()
get_node_info()
node_set_row_style()
node_get_row_style()
node_set_cell_style()
node_get_cell_style()
node_set_foreground()
node_set_background()
node_set_row_data()
node_get_row_data()
node_moveto()
node_is_visible()
set_indent()
set_spacing()
set_show_stub()
set_line_style()
set_expander_style()
sort_node()
sort_recursive()
GtkCTree
(XXX);
Notice how much of the code here is actually the arrays of data needed to populate the GtkCTree. It would probably be cleaner to keep your data generation in an include file.
Example 14. Setting up a GtkCTree
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); /* start of data generation arrays */ $widgets_ = array( /*level 0*/ array('Object'), /*level 1*/ array('Widget', 'Data', 'ItemFactory'), /*level 2*/ array('Misc', 'Container', 'Calendar', 'DrawingArea', 'Editable', 'Ruler', 'Range', 'Separator', 'Preview', 'Progress'), array('Adjustment', 'Tooltips'), /*level 3*/ array('Label', 'Arrow', 'Image', 'Pixmap'), array('Bin', 'Box', 'CList', 'Fixed', 'Notebook', 'Paned', 'Layout', 'List', 'MenuShell', 'Packer', 'Socket', 'Table', 'Toolbar', 'Tree'), array('Curve'), array('Entry', 'Text'), array('HRuler', 'VRuler'), array('Scale', 'Scrollbar'), array('HSeparator', 'VSeparator'), array('ProgressBar'), /*level 4*/ array('AccelLabel', 'TipsQuery'), array('Alignment', 'Frame', 'Button', 'Item', 'Window', 'EventBox', 'HandleBox', 'ScrolledWindow', 'Viewport', 'Invisible'), array('ButtonBox', 'HBox', 'VBox'), array('CTree'), array('FontSelection'), array('HPaned', 'VPaned'), array('MenuBar', 'Menu'), array('SpinButton'), array('HScale', 'VScale'), array('HScrollbar', 'VScrollbar'), /*level 5*/ array('AspectFrame'), array('ToggleButton', 'OptionMenu'), array('ListItem', 'MenuItem', 'TreeItem'), array('ColorSelectionDialog', 'Dialog', 'FileSelection', 'FontSelectionDialog', 'Plug'), array('HButtonBox', 'VButtonBox'), array('Combo', 'Statusbar'), array('ColorSelection', 'GammaCurve'), /*level 6*/ array('CheckButton'), array('CheckMenuItem', 'TearoffMenuItem'), array('InputDialog'), /*level 7*/ array('RadioButton'), array('RadioMenuItem') ); $row = array(0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, 5, 5, 5, 5, 5, 5, 7, 9, 9, 13, 13, 13, 13, 14, 14, 14, 23, 24, 25, 29, 30); $class = array(0, 0, 1, 0, 1, 3, 4, 5, 6, 7, 9, 0, 0, 1, 2, 4, 5, 8, 0, 0, 1, 1, 2, 3, 4, 0, 1, 2, 0, 1, 1, 0, 0); /* end of data generation arrays */ $window = &new GtkWindow(); $window->set_title('The GTK Class Hierarchy'); $window->set_position(GTK_WIN_POS_CENTER); $window->set_default_size(300, (gdk::screen_height()-30)); $window->connect_object('destroy', array('gtk', 'main_quit')); $scrolledwindow = &new GtkScrolledWindow(); $scrolledwindow->set_policy(GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); $window->add($scrolledwindow); $ctree = &new GtkCTree(1, 0); $ctree->set_line_style(GTK_CTREE_LINES_SOLID); for($x = 0; $x < count($widgets_); $x++) { $sibling[$x] = array(); switch($x) { case 0: $parent = null; break; default: $parent = $sibling[$row[$x-1]][$class[$x-1]]; break; } for ($i = 0; $i < count($widgets_[$x]); $i++) { $widgets[0] = "Gtk".$widgets_[$x][$i]; $sibling[$x][$i] = $ctree->insert_node($parent, $sibling[$x][], $widgets, 5, null, null, null, null, false, true); } } $scrolledwindow->add($ctree); $ctree->show(); $window->show_all(); gtk::main(); |
void remove_node
(
GtkCTreeNode
node
);
bool is_viewable
(
GtkCTreeNode
node
);
GtkCTreeNode
last
(
GtkCTreeNode
node
);
GtkCTreeNode
node_nth
(int row);
bool find
(
GtkCTreeNode
node
,
GtkCTreeNode
child
);
bool is_ancestor
(
GtkCTreeNode
node
,
GtkCTreeNode
child
);
void move
(
GtkCTreeNode
node
,
GtkCTreeNode
new_parent
,
GtkCTreeNode
new_sibling
);
void expand
(
GtkCTreeNode
node
);
void expand_recursive
([
GtkCTreeNode
node = NULL
]);
void expand_to_depth
(
GtkCTreeNode
node
, int depth);
void collapse
(
GtkCTreeNode
node
);
void collapse_recursive
([
GtkCTreeNode
node = NULL
]);
void collapse_to_depth
(
GtkCTreeNode
node
, int depth);
void toggle_expansion
(
GtkCTreeNode
node
);
void toggle_expansion_recursive
(
GtkCTreeNode
node
);
void select
(
GtkCTreeNode
node
);
void select_recursive
([
GtkCTreeNode
node = NULL
]);
void unselect
(
GtkCTreeNode
node
);
void unselect_recursive
([
GtkCTreeNode
node = NULL
]);
void node_set_text
(
GtkCTreeNode
node
, int column, string text);
void node_set_pixmap
(
GtkCTreeNode
node
, int column,
GdkPixmap
pixmap
,
GdkBitmap
mask
);
void node_set_pixtext
(
GtkCTreeNode
node
, int column, string text, int spacing,
GdkPixmap
pixmap
,
GdkBitmap
mask
);
void set_node_info
(
GtkCTreeNode
node
, string text, int spacing,
GdkPixmap
pixmap_closed
,
GdkBitmap
mask_closed
,
GdkPixmap
pixmap_opened
,
GdkBitmap
mask_opened
, bool is_leaf, bool expanded);
void node_set_shift
(
GtkCTreeNode
node
, int column, int vertical, int horizontal);
void node_set_selectable
(
GtkCTreeNode
node
, bool selectable);
bool node_get_selectable
(
GtkCTreeNode
node
);
GtkCellType
node_get_cell_type
(
GtkCTreeNode
node
, int column);
void node_set_row_style
(
GtkCTreeNode
node
,
GtkStyle
style
);
GtkStyle
node_get_row_style
(
GtkCTreeNode
node
);
void node_set_cell_style
(
GtkCTreeNode
node
, int column,
GtkStyle
style
);
GtkStyle
node_get_cell_style
(
GtkCTreeNode
node
, int column);
void node_set_foreground
(
GtkCTreeNode
node
,
GdkColor
color
);
void node_set_background
(
GtkCTreeNode
node
,
GdkColor
color
);
void node_moveto
(
GtkCTreeNode
node
, int column, double row_align, double col_align);
GtkVisibility
node_is_visible
(
GtkCTreeNode
node
);
void set_line_style
(
GtkCTreeLineStyle
line_style
);
void set_expander_style
(
GtkCTreeExpanderStyle
expander_style
);
void sort_node
(
GtkCTreeNode
node
);
void sort_recursive
([
GtkCTreeNode
node = NULL
]);
Properties
parent : sibling : children : pixmap_closed : pixmap_opened : mask_closed : mask_opened : level : is_leaf : expanded : row :
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Widget that allows editing of a curve.
Constructor
—
GtkCurve
(void);
GtkCurve
(void);
void set_curve_type
(GtkCurveType type);
Abstract base class for objects containing data.
Signals
disconnect: Never emitted.
GtkData is a legacy abstract base class providing inheriting objects with a single signal - which no longer operates.
Objects that are descendants of this class are not widgets, and do not take up screen space. They purely carry data.
In GTK 2, GtkData will cease to exist entirely, and the objects that currently are derived from it will be derived directly from GtkObject instead.
This is a legacy signal which has been implemented in GtkData but nowhere else. You won't get an error message by setting up a connection for it, but there is no longer any way to make an object emit it - so don't bother.
Callback function:
void callback
(GtkData object);
Widget that eases creation of popup dialogs.
Constructor
— Creates the basis for a popup dialog window.
GtkDialog
(void);Properties
vbox : Upper container. action_area : Lower container.
GtkDialog is used to create a popup window for presenting or requesting small amounts of information. It is composed of two containers separated by a GtkHSeparator. The top container is a GtkVBox, and would typically contain GtkLabel and GtkEntry widgets to present the user with information and allow input. The bottom container is a GtkHBox and would usually contain dialog buttons, e.g. OK, Cancel, Help and so on.
Note that widgets should not be added to the GtkDialog itself but to the containers, which can be accessed as vbox and action_area respectively.
Dialogs can be made modal (in effect freezing input to the rest of the application) by calling the GtkWindow method set_modal() on the GtkDialog object.
Note that making a GtkDialog modal does not stop execution of the code that calls it. In the example below, the call to 'echo' will still get executed even though the main application may not respond to user input. To stop execution of the code the GtkDialog must contain a call to a nested gtk::main() function. Execution will then continue when the corresponding gtk::main_quit() function is called.
Example 15. Using set_modal()
$dialog = &new GtkDialog(); $dialog->set_modal(TRUE); echo "This message will still be printed \n";
GtkDialog
(void);
Creates the basis for a dialog window.
Example 16. Creating a dialog window
$dialog = &new GtkDialog(); $dialog->set_policy(true, false, false); $dialog->set_position(GTK_WIN_POS_CENTER); $dialog->connect_object("destroy", array("gtk", "main_quit")); $dialog_vbox = $dialog->vbox; $dialog_action_area = $dialog->action_area; $user_info_label = &new GtkLabel("Some Important Information"); $dialog_vbox->pack_start($user_info_label); $ok_button = &new GtkButton("OK"); $dialog_action_area->pack_start($ok_button); gtk::main(); |
Type: Read Only
vbox is the GtkVBox at the top of the GtkDialog widget. The programmer would typically add widgets such as GtkLabel and GtkEntry here for the purpose of exchanging information with the end user.
Type: Read Only
action_area is the GtkHBox at the bottom of the GtkDialog widget, below the GtkHSeparator. This is where the programmer would usually add one or two GtkButtons, connecting these to functions that terminate the dialog and/or act upon the information gathered through it.
Widget for custom user interface elements.
Constructor
— Constructs a blank, drawable widget.
GtkDrawingArea
(void);Methods
size()
Sets the size of the drawing area.
A GtkDrawingArea is a widget whose GdkWindow can be drawn to. You could use it to create a new user interface element, or an updateable graph, or pretty much anything, using the GDK and GTK draw and paint functions.
Because it is in itself so featureless, everything has to be added to a GtkDrawingArea. It will not respond to key or button press events, unless you give it the ability to do so using set_events() or add_events() . It cannot have keyboard focus, unless you set the GTK_CAN_FOCUS flag. It does not regard what is drawn upon it as a clue to sizing, so you have to size it. If you want it to react to resizing, you will need to connect it to an appropriate callback via the configure-event signal in order to do so. It has no defining behaviour, beyond the ability to manufacture configure events when it is allocated a new size. It's basically a completely empty widget.
Note
Redraws should be created through an expose-event handler.
GtkDrawingArea
(void);
Example 17. Drawing to a GtkDrawingArea
dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); function draw_it($drawingarea, $event, $style, $gdkwindow) { /* access the GdkWindow's colormap to associate a color with a GdkGC */ $colormap = $gdkwindow->colormap; $yellow = $gdkwindow->new_gc(); $yellow->foreground = $colormap->alloc('yellow'); $red = $gdkwindow->new_gc(); $red->foreground = $colormap->alloc('red'); $red->line_width = 7; /* set up fonts. The first font here is set as part of the drawingarea's style property so that it will be used in gtk::draw_string(). */ $font = gdk::font_load('-unknown-Arial-bold-r-normal--*-120-*-*-p-0-iso8859-1'); $style->font = $font; $font2 = gdk::font_load('-unknown-Arial-bold-r-normal--*-720-*-*-p-0-iso8859-1'); /* call the appropriate drawing functions */ gdk::draw_rectangle($gdkwindow, $style->white_gc, true, 0, 0, 200, 220); gdk::draw_rectangle($gdkwindow, $yellow, true, 50, 50, 100, 100); gdk::draw_string($gdkwindow, $font2, $style->white_gc, 75, 130, '?'); gdk::draw_line($gdkwindow, $red, 20, 20, 180, 180); gdk::draw_line($gdkwindow, $red, 20, 180, 180, 20); gtk::draw_string($style, $gdkwindow, GTK_STATE_NORMAL, 12, 210, 'SAY TO SQUARE EGGS!'); gdk::draw_string($gdkwindow, $font, $red, 42, 210, 'NO'); } function press_it($drawingarea, $event, $style, $gdkwindow) { /* make the drawingarea look like it has been pressed down */ $rectangle = &new GdkRectangle(0, 0, 200, 220); gtk::paint_focus($style, $gdkwindow, $rectangle, $drawingarea, null, 0, 0, 200, 220); } function redraw_it($drawingarea, $event) { /* trigger a new expose event */ $drawingarea->queue_draw(); } /* set up the main window that will hold the drawing area */ $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); /* set up the drawing area. Sizing is taken from the parent, unless set. We need to add events so that the drawingarea is sensitive to the mouse, using set_events() to do this because the widget is not realized yet. */ $drawingarea = &new GtkDrawingArea(); $drawingarea->size(200, 220); $drawingarea->set_events(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); $window->add($drawingarea); /* once the drawing area has been added to the window we can realize() it, which means that we can now access its properties */ $drawingarea->realize(); $style = $drawingarea->style; $gdkwindow = $drawingarea->window; /* drawing should always follow an expose event */ $drawingarea->connect('expose-event', 'draw_it', $style, $gdkwindow); $drawingarea->connect('button-press-event', 'press_it', $style, $gdkwindow); $drawingarea->connect('button-release-event', 'redraw_it'); $window->show_all(); gtk::main(); |
A GtkDrawingArea has no default size set. If none is given, it will default to the size allocated to it by its parent window. Note that the size set using this method is treated as the drawingarea's size request, and may be overridden in some situations.
Base class for text-editing widgets.
Methods
select_region()
Selects designated area of text. insert_text()
Inserts a string of text. delete_text()
Deletes designated area of text. get_chars()
Returns designated string. cut_clipboard()
Copies and deletes selected string. copy_clipboard()
Copies selected string. paste_clipboard()
Pastes current clipboard contents. claim_selection()
Provides selection data. delete_selection()
Deletes selected text and accompanying selection data. changed()
Causes changed signal to be emitted. set_position()
Sets the cursor position. get_position()
Returns the current cursor position. set_editable()
Toggles whether the text is editable. Signals
changed: Emitted when there is a change to the text string. insert-text: Emitted when insert_text() is called. delete-text: Emitted when text is deleted. activate: Emitted when designated key is pressed. set-editable: Emitted when the set_editable() method is called. cut-clipboard: Emitted when cut_clipboard() is called. copy-clipboard: Emitted when copy_clipboard() is called. paste-clipboard: Emitted when paste_clipboard() is called. Properties
selection_start_pos : Selection start position. selection_end_pos : Selection end position. has_selection : Indicates whether there is currently a selection.
GtkEditable is an abstract base class providing GtkEntry and GtkText with several methods, signals and properties, and also a set of keybindings that can be used for editing.
Table 1. Key bindings for editing
Key combination Editing function Control + a Move to the beginning of the line Control + b Move back one character Control + c Copy currently selected text Control + d Delete forward character Control + e Move to the end of the line Control + f Move forward one character Control + h Delete backward character Control + k Delete to line end Control + n Move to the next line (GtkText only) Control + p Move to the previous line (GtkText only) Control + u Delete current line Control + v Paste clipboard text Control + w Delete backward word Control + x Cut currently selected text Alt + b Move back one word Alt + d Delete forward word Alt + f Move forward one word There are also a host of signals that are used internally to enable these editing functions to work. These signals have not been documented here.
select_region() selects an area of text programmatically. The start and end parameters can be 0, -1 if the full text string is required.
Note that the editable widget needs to be realized prior to this method being called on it. See claim_selection() .
insert_text() is the simplest way of putting text into an editable widget. GtkText has an alternative method, insert() , which gives greater control over the appearance of the text, amongst other things.
This method does not support internationalization under win32. Use insert() .
The insert_text() method also causes the signal of the same name to be emitted.
Deletes the designated area of text.
As with all editing functions, 0 denotes the beginning of the string, and -1 the end position.
delete_text() also causes the signal of the same name to be emitted.
This method is used to return the specified contents of a string. To return the complete string, pass 0, -1 as the parameters.
cut_clipboard() copies the current selection to the clipboard. It then deletes the original text using the position parameters of the selection.
It also causes the cut-clipboard signal to be emitted.
copy_clipboard() copies the current selection to the clipboard.
It also causes the copy-clipboard signal to be emitted.
paste_clipboard() pastes the current clipboard contents at the cursor position.
It also causes the paste-clipboard signal to be emitted.
This method is used internally as a way to provide select_region() with all the data it needs in order to work, including the underlying GdkWindow that the GtkSelectionData requires. It's not very useful elsewhere.
This method deletes the information held in the clipboard as well as the text to which it relates. It is used internally to differentiate between a full text delete and the deletion used in cut_clipboard() .
Generally, use delete_text() instead.
This method causes the GtkEditable widget to emit the changed signal.
It is called internally every time there is a change made to the text string.
Sets the cursor position within the string of existing text. Note that the calling editable widget must have keyboard focus in order for the cursor position to be valid.
This method returns the current cursor position.
set_editable() , when set to true, sets the widget to be editable by the user.
The default setting is false.
Effectively, the only difference between this and the key-press-event signal is that the key press event is not passed to the callback function.
Callback function:
void callback
(GtkEditable widget);
This signal is emitted when the insert_text() method is called, which happens internally every time the text is added to by the end user, at every key press.
The string_length that is passed is the length of the string that is being inserted, and not the length of the string that makes up the content of the text widget.
Note that there is a fourth parameter here that the signal cannot carry in PHP-GTK because it is a GTK_TYPE_POINTER, which is an unsupported type. Depending on the E-NOTICES settings in your php.ini file, you may get an error message when you connect this signal. This does not affect the signal's functionality.
Callback function:
void callback
(GtkEditable widget, string text_string, int string_length);
This signal is emitted when the delete_text() method is called, which happens internally when the user presses the delete button and text is currently selected.
The data that is passed with this signal consists of the calling class and the start and end positions of the selection.
Callback function:
void callback
(GtkEditable widget, int start_pos, int end_pos);
The activate signal is usually fired when the user presses Return. However, note that in GtkText both the Return key and the arrow keys need to be combined with the Control key in order to have their usual effect.
Callback function:
void callback
(GtkEditable widget);
This signal is emitted when the set_editable() is called. It carries a boolean value which determines in which direction the switch has been made.
Callback function:
void callback
(GtkEditable widget, bool is_editable);
This signal is emitted when the cut_clipboard() method is called. This happens internally when the user presses the Control and x keys silmultaneously.
Callback function:
void callback
(GtkEditable widget);
This signal is emitted when the copy_clipboard() method is called. This happens internally when the user presses the Control and c keys silmultaneously.
Callback function:
void callback
(GtkEditable widget);
This signal is emitted when the paste_clipboard() method is called. This happens internally when the user presses the Control and v keys silmultaneously.
Callback function:
void callback
(GtkEditable widget);
Type: Read Only
The position in the text index that the current selection starts from, if there is one.
Type: Read Only
The position in the text index that the current selection ends at, if there is one.
Type: Read Only
Indicates whether there is currently a selection.
A single line text entry field.
Constructor
— Creates a single-line text entry widget.
GtkEntry
(void);Methods
set_text()
Sets text content. append_text()
Adds text to the end of entered text. *Deprecated in GTK2* prepend_text()
Adds text to the start of entered text. *Deprecated in GTK2* set_position()
Sets cursor position. *Deprecated in GTK2* get_text()
Retrieves entered text. select_region()
Selects text region. *Deprecated in GTK2* set_visibility()
Toggles text visibility. set_editable()
Toggles text editability. *Deprecated in GTK2* set_max_length()
Sets the maximum text length.
GtkEntry is a single line text field generally used where input is required from the user. The minimum length of the entry field is set internally at 150 pixels; the maximum length is determined by the size of the container. If the text entered is longer than the entry field, the widget will scroll so that the cursor position is visible.
Both GtkEntry and GtkText have the potential to be edited by the user, and share a fairly large number of key bindings to that end. These are listed under GtkEditable for the sake of completeness; however, note that they are replaced by a more intuitive set in GTK+ 2.0.
Note
It will be immediately obvious that quite a few GtkEntry methods are marked here as being deprecated in later GTK+ releases. Please be aware that all editable classes are undergoing radical changes, and that deprecated methods may or may not be supportable in the future. It would therefore be wise to avoid methods marked as deprecated, as far as is possible.
See also: GtkEditable, GtkCombo, GtkList, GtkCheckButton, GtkToggleButton, GtkRadioButton.
GtkEntry
(void);
Creates a widget that will hold a single line of text, either set programmatically through set_text() or entered by the user.
Example 18. Retrieving text from a GtkEntry widget
dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); /* set up a function to collect the input from the entry and print it */ function get_input($entry) { $input=$entry->get_text(); echo "$input\n"; $entry->grab_focus(); $entry->set_text(""); } /* set up the window */ $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_MOUSE); $window->connect_object('destroy', array('gtk', 'main_quit')); /* add a box container to the window to allow more than one child widget */ $box = &new GtkVBox(); $window->add($box); /* add a GtkEntry to the box and connect it to the callback function */ $entry = &new GtkEntry(); $entry->connect('activate', 'get_input'); $box->add($entry); /* add a GtkButton to the box and use connect_object() so that it will pass the GtkEntry to the callback when it is clicked */ $button = &new GtkButton('Return or click me to echo input'); $button->connect_object('clicked', 'get_input', $entry); $box->add($button); /* display everything and set the main loop running */ $box->show_all(); $window->show_all(); gtk::main(); |
set_text() sets a string of given text in the entry field.
append_text() adds the given string to the end of any entered text.
prepend_text() adds the given string to the start of any entered text.
set_position() sets the cursor at the given character position within existing text in the entry field. Use 0 to set the cursor at the beginning of the text, and -1 to set it at the end.
get_text() retrieves the text entered into the GtkEntry widget, and also any appended or prepended text that may have been set but not displayed.
Contrary to rumour, this function is *not* marked as deprecated, either in the versions of GTK+ currently used by PHP-GTK or in recent development releases of GTK+.
select_region() is used to select a region of existing text, generally for using with the cut, copy and paste methods found in GtkEditable.
If you need to select the entire text entry, use the setting (0, -1).
set_visibility() , when set to false, provides a means of hiding sensitive input information on screen. It replaces each character with a star.
This function is mainly used for password entry.
set_editable() sets the entry field to be editable by the user, or otherwise.
The default setting is true.
Note that setting set_editable() to true on top of the default setting can lead to some unexpected effects.
set_max_length() sets the maximum number of characters that will be accepted in a text entry. Any further characters entered will not be displayed in the entry field, nor will they be capable of being retrieved with the get_text() function.
Widget used to capture events for widgets with no GdkWindow.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkEventBox
Constructor
— Creates a means of capturing events where there is none.
GtkEventBox
(void);
The GtkEventBox is used to capture events for widgets that do not have their own window.
Most widgets inherit the window property from GtkWidget, which makes it possible to use those widgets interactively. However, some widgets are flagged as GTK_NO_WINDOW at source, because there is rarely a need to capture events crossing those widgets.
The following widgets and their descendants fall into this category and need to be packed into an event box before they can be made to respond to user activity:
GtkAlignment GtkArrow GtkBox GtkCheckButton GtkFrame GtkImage GtkItem GtkLabel GtkPacker GtkPixmap GtkScale GtkScrolledWindow GtkSeparator GtkTable GtkToggleButton - alters according to its draw indicator status!
GtkEventBox
(void);
The most common need for a GtkEventBox arises when a tooltip is required for a non-windowed widget.
Example 19. Giving a GtkLabel a tooltip.
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); $eventbox = &new GtkEventBox(); $label = &new GtkLabel("This is a normal label. It cannot capture events."); $eventbox->add($label); $label->show(); $window->add($eventbox); $tooltip = &new GtkTooltips(); $tooltip->set_tip($eventbox, "So how did this get here?", null); $tooltip->enable(); $window->show_all(); gtk::main(); |
Widget for selecting a file or a directory.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
áááááááááááááááááááááááá`-- GtkFileSelection
Constructor
— Creates a new GtkFileSelection widget.
GtkFileSelection
([string title ]);Methods
set_filename()
Sets the default path. get_filename()
Returns the current selected path. complete()
Matches a given pattern to a valid file name. show_fileop_buttons()
Shows the file operation buttons. hide_fileop_buttons()
Hides the file operation buttons. Properties
dir_list : Directory list. file_list : File list. selection_entry : Entry field. selection_text : Directory selection status. main_vbox : Main container. ok_button : Standard button. cancel_button : Standard button. action_area : Container for custom additions.
GtkFileSelection is used to retrieve files or directories requested by the end user. The widget contains a directory list and a file list which will correspond to the default directory, that is, either the current working directory or one determined using set_filename() .
The filesystem can be navigated using either the directory tree or the dropdown history menu. Alternatively it is possible to type the directory or file path into the selection_entry field, and also to use the TAB key to autocomplete either the directory name or file name entered in this way.
GtkFileSelection
([string
title
]);
The syntax to create a GtkFileSelection widget is:
Note that if the title parameter is not supplied or is NULL the title will be set to the name of the file in which the PHP code resides.Sets the default path for the directory and/or file name.
Returns a string representing the current value in the file selector. If no directory or file has been selected then the current path is returned.
complete() will try to match the pattern given by the programmer to a valid file name in the current directory, or to a valid directory name on the current drive. This is useful when, for example, wishing to hard-code a search for a specific extension into an application. Where a full match is made, the matched file name will appear in both the file list and the text entry field of the file selection dialog. If only partial matches can be found, the file list will contain the resulting file names and the text entry field will contain the closest matched string (not the full file name).
Note that only a single wildcard field is effective here.
Shows the file operation buttons Create Dir, Delete File and Rename File. This is their default state, so that show_fileop_buttons() would only be used following a call to hide_fileop_buttons() . The rest of the widgets in the dialog will be automatically resized to accommodate the status of the file operation buttons. These buttons do not need any programming in order to carry out their respective functions, as these are already hard-coded into GTK+.
Hides the file operation buttons Create Dir, Delete File and Rename File which by default appear at the top of a GtkFileSelection. hide_fileop_buttons() is useful where the programmer would prefer the end user not to have easy access to these file operations.
Type: Read Only
dir_list is a GtkCList widget embedded in the GtkFileSelection object that displays the subdirectories available in the current directory.
Type: Read Only
file_list is a GtkCList widget embedded in the GtkFileSelection object that displays the list of files available in the current directory.
Type: Read Only
selection_entry is a GtkEntry widget placed at the bottom of the GtkFileSelection object for use in navigation and searching. It displays the current enquiry or the current selected item.
Type: Read Only
selection_text is a GtkLabel that by default contains the string "Selection: " followed by the full path of the current selected directory.
Type: Read Only
main_vbox is the container holding all the other elements of the GtkFileSelection widget.
Type: Read Only
ok_button is a GtkButton placed at the bottom of the GtkFileSelection object. Note that this button is not initially connected and has no default callback function.
Type: Read Only
cancal_button is a GtkButton placed at the bottom of the GtkFileSelection object. As with the ok_button , it is the programmer's responsibility to listen for signals from this button and take the appropriate action.
Type: Read Only
action_area is a GtkHBox which is positioned directly below the file_list and dir_list .
It would generally be used for displaying custom items such as additional buttons, labels or text entry boxes.
Container that retains the sizes and positions of its children.
Properties
children : Array of child positioning information.
GtkFixed is a container widget that retains the original sizes and positions of its children regardless of any top-level resizing.
Note that there is no padding or spacing implicit in this method of container packing. The arrangement of the children is based purely on the co-ordinate values given in the put() and move() method parameters. For this reason it is inadvisable to use add() when utilising GtkFixed, as widgets that have been added in this way can and will be overwritten by any fixed-position widgets.
GtkFixed
(void);
This function creates and returns a GtkFixed widget.
void put
(
GtkWidget widget
, int x, int y);
put() sets the initial position of the child widget(s) in a GtkFixed container. This information is held in the children property as an array of GtkFixedChild objects.
The parameters are the x and y co-ordinates of the top left-hand corner of the child widget, measured in pixels from the top left-hand corner of the container.
void move
(
GtkWidget widget
, int x, int y);
move() sets a new position for a child widget in a GtkFixed container.
The parameters are the x and y co-ordinates of the top left-hand corner of the child widget, measured in pixels from the top left-hand corner of the container.
Type: Read Only
The positioning information for the individual child widgets is stored in children as an array of GtkFixedChild objects.
Helper class for GtkFixed.
Properties
widget : Child widget. x : Child position x co-ordinate. y : Child position y co-ordinate.
GtkFixed is a widget that fixes its children at their given sizes and positions.
GtkFixedChild is a helper class that allows access to the positioning information for each individual child. The children property in GtkFixed is an array of GtkFixedChild objects corresponding to the child widgets that have been put() into a GtkFixed object.
Note that GtkFixedChild cannot be constructed directly.
Type: Read Only
The widget property provides access to the child widget object.
It is possible to access methods, properties and signals belonging to widget as with any GtkWidget of the same type.
$button = $fixed->children[5]->widget; $label = $button->child; $label->set_text("New Button Label"); |
Type: Read Only
x is the measurement in pixels of the distance between the top left-hand corner of the child widget and the left edge of the GtkFixed container.
Type: Read Only
y is the measurement in pixels of the distance between the top left-hand corner of the child widget and the top edge of the GtkFixed container.
Widget for selecting fonts.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkNotebook
áááááááááááááááááá`-- GtkFontSelection
Constructor
—
GtkFontSelection
(void);
GtkFontSelection
(void);
GdkFont get_font
(void);
Standard dialog box for selecting fonts.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
áááááááááááááááááááááááá`-- GtkFontSelectionDialog
Constructor
—
GtkFontSelectionDialog
(string title);
GtkFontSelectionDialog
(string title);
GdkFont get_font
(void);
Container with a decorative frame and an optional label.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkFrame
Constructor
— Creates a decorative container.
GtkFrame
([string label = NULL ]);Methods
set_label()
Sets label text. set_label_align()
Sets label position. set_shadow_type()
Sets angle and depth of shadow.
GtkFrame is a container for a single child widget that provides a configurable shadowed border around the child's allocated area.
GtkFrame
([string
label = NULL
]);
The label in the GtkFrame is only given physical space if a text string is passed to it. The NULL default setting does not refer to the value of the text string, but to its absence.
Note that the internal label exists in this widget regardless of whether it has text set during construction.
set_label() sets the label text programmatically.
set_label_align() sets the position of the label along the top edge of the frame. The position is given as a double, so that an xalign setting of 0.0 would hold the label against the top left edge of the frame and a setting of 1.0 against the top right edge. The default xalign setting is 0.0.
Note that although the yalign setting is currently ignored by GTK, it is not possible to omit the parameter completely. The default setting for yalign is 0.5 both currently and in development releases of GTK+, so it would seem advisable to use that value.
void set_shadow_type
(
GtkShadowType type
);
set_shadow_type sets the angle and depth of the line of shadow that decorates the GtkFrame border, according to the specified GtkShadowType option.
The default setting is GTK_SHADOW_ETCHED_IN.
A subclass of GtkCurve for editing gamma curves.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkVBox
áááááááááááááááááááááááá`-- GtkGammaCurve
Constructor
—
GtkGammaCurve
(void);
GtkGammaCurve
(void);
Widget for detachable window portions.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkHandleBox
Constructor
—
GtkHandleBox
(void);
GtkHandleBox
(void);
void set_shadow_type
(GtkShadowType type);
void set_handle_position
(GtkPositionType position);
void set_snap_edge
(GtkPositionType edge);
Horizontal box container.
Constructor
— Creates a container for a single row of child widgets.
GtkHBox
([bool homogeneous = false , [int spacing = 0 ]]);
GtkHBox is a box container that packs child widgets in a single row, using the packing methods inherited from GtkBox, such as pack_start() , as well as the less flexible add() method available to most container widgets. GtkHBox and GtkVBox in combination are the most commonly used packing widgets. See the GtkVBox constructor for a working example using both.
Note that all children in a GtkHBox are allocated the same height, regardless of settings and child requisition size. Widgets taking up less than the allocated height are by default centered within the available area in that dimension.
See also: GtkContainer, GtkBox, GtkVBox, GtkButtonBox, GtkTable.
GtkHBox
([bool
homogeneous = false
, [int
spacing = 0
]]);
Creates a new horizontal box container designed for packing a single row of child widgets.
The first parameter, homogeneous, is a boolean value which, if set to true, will set each child widget in the GtkHBox to the same width as that of the largest child widget. The second parameter, spacing, sets the minimum spacing between the child widgets along the width of the container, in pixels. Leaving both parameters empty, e.g.
will set the default behaviour of individual sizing and zero spacing.Container for arranging a group of buttons horizontally.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkButtonBox
áááááááááááááááááááááááá`-- GtkHButtonBox
Constructor
— Creates the basis for a horizontal button container.
GtkHButtonBox
(void);
GtkHButtonBox is a container widget designed for arranging a row of buttons in accordance with a specified GtkButtonBoxStyle setting.
See also: GtkButtonBox, GtkVButtonBox.
GtkHButtonBox
(void);
The syntax for creating a horizontal buttonbox is:
There are no parameters.As with all container widgets, no physical space is taken by a GtkHButtonBox until its child widgets are in place.
Container with two panes arranged horizontally.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkPaned
áááááááááááááááááá`-- GtkHPaned
Constructor
— Creates the basis for a horizontal dual-paned container.
GtkHPaned
(void);
GtkHPaned is a widget derived from GtkPaned, consisting of two panes arranged horizontally and separated by a dividing handle. The handle can be adjusted by the end user to alter the relative sizes of the pane contents.
GtkHPaned
(void);
The GtkHPaned widget should be thought of in terms of an arrangement of two child widgets, rather than as an object in its own right. The construct
needs to be within a containing GtkWindow and to contain two child widgets of its own in order to work.
Example 20. Constructing a GtkHPaned widget
$window = &new GtkWindow(); $window->set_title("GtkHPaned"); $window->connect_object("destroy", array("gtk", "main_quit")); $hpaned = &new GtkHPaned(); $window->add($hpaned); $hpaned->show(); $button = &new GtkButton("Widget child1"); $hpaned->pack1($button, false, false); $button->show(); $label = &new GtkLabel(); $label->set_text("Widget child2"); $hpaned->pack2($label, true, true); $label->show(); $window->show_all(); gtk::main(); |
Horizontal ruler.
Constructor
—
GtkHRuler
(void);
GtkHRuler
(void);
Horizontal slider widget for selecting a value from a range.
Constructor
— Creates a horizontal slider.
GtkHScale
( GtkAdjustment adjustment );
A GtkHScale is a horizontal scrollbar-like widget that is able to display its adjustment value as text.
There are some configuration issues with this widget when it is used in such a way; please refer to GtkScale for further information.
GtkHScale
(
GtkAdjustment
adjustment
);
A GtkHScale that can be given its own GtkAdjustment settings or simply not display the text value has no configuration issues whatever. However, please note that even a GtkHScale with no displayed value is not able to scroll a GtkText widget.
Horizontal scrollbar.
GtkObject
`-- GtkWidget
áááááá`-- GtkRange
áááááááááááá`-- GtkScrollbar
áááááááááááááááááá`-- GtkHScrollbar
Constructor
— Creates a horizontal scrollbar.
GtkHScrollbar
( GtkAdjustment adjustment );
A GtkHScrollbar is a horizontal scrollbar.
Table 2. Key bindings for GtkVScrollbar
Key combination Scroll function Left arrow Move left one step increment Right arrow Move right one step increment Home Move left one page increment End Move right one page increment Control + Home Move to left of scroll Control + End Move to right of scroll
GtkHScrollbar
(
GtkAdjustment
adjustment
);
A scrollbar needs a GtkAdjustment in order to operate. The values that you give to the adjustment object will depend on the situation where the scrollbar is intended to be used.
All scrollable widgets have their own adjustment object(s), and in most instances where you are most likely to need a horizontal scrollbar it is possible to create a handle for the widget's horizontal GtkAdjustment and assign that as the new scrollbar's adjustment object.
There is no working horizontal adjustment object in GtkText.
See also: GtkAdjustment, GtkVScrollbar.
Horizontal separator.
Constructor
— Draws a horizontal line.
GtkHSeparator
(void);
A GtkHSeparator is a widget that consists of a horizontal line. It is used to separate widgets that are laid out vertically.
Note
Separators cannot be added to menu widgets. See GtkMenuItem for details.
See also: GtkVSeparator, gtk::paint_hline() .
GtkHSeparator
(void);
Constructing a GtkHSeparator and adding it to a widget amounts to the same thing as drawing a horizontal line across that widget. Use the container's packing methods to organise spacing around the separator.
Widget for displaying a graphical image.
The GtkImage class is not implemented in PHP-GTK. Use GtkPixmap instead.
Standard dialog for configuring input devices.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
áááááááááááááááááááááááá`-- GtkDialog
áááááááááááááááááááááááááááááá`-- GtkInputDialog
Constructor
—
GtkInputDialog
(void);
GtkInputDialog
(void);
Internally used widget which is not displayed.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkInvisible
Constructor
—
GtkInvisible
(void);
GtkInvisible
(void);
Abstract base class for GtkMenuItem, GtkListItem, and GtkTreeItem.
Methods
select()
Emits select signal. deselect()
Emits deselect signal. toggle()
Emits toggle signal. Signals
select: Emitted when user selects item using mouse-click. deselect: Emitted when user deselects item using mouse-click. toggle: Emitted when user selects or deselects item using Enter key.
GtkItem provides the toggle() method and select, deselect and toggle signal prototypes for GtkMenuItem, GtkListItem, and GtkTreeItem.
Note that GtkItem is an abstract base class and cannot be constructed directly.
select() is part of a function/signal pair serving as a basis for methods of the same name lower in the hierarchy.
It enables the relevant implementation of the select signal to be emitted programmatically.
deselect() is part of a function/signal pair serving as a basis for methods of the same name lower in the hierarchy.
It enables the relevant implementation of the deselect signal to be emitted programmatically.
toggle() enables the relevant implementation of the toggle signal to be emitted programmatically.
The select signal is emitted when the select() is called within the program, or when the cursor enters the item's screen area. There is no behaviour defined at base level for this signal, please refer to the description in the deselect method in the non-abstract class you are using.
Callback function:
void callback
(GtkItem item);
The deselect signal is emitted when the deselect() is called within the program, or when the cursor leaves the screen area of the GtkItem. There is no behaviour defined at base level for this signal, please refer to the description in the deselect method in the non-abstract class you are using.
Callback function:
void callback
(GtkItem item);
The toggle signal is emitted when the toggle() is called within the program, or when the user presses the enter or spacebar key while the connected GtkItem has focus.
Beyond that, this signal also has no behaviour defined at base level. In GtkListItem and GtkTreeItem, the toggle signal switches states between GTK_STATE_SELECTED and GTK_STATE_NORMAL; these GtkStateType enumerations are by default colour-coded, providing visual cues for the end user as well as a value within the program.
GtkMenuItem inherits the toggle signal without adding to it, i.e. it is there in theory but has no functionality in practice.
It is worth noting that both GtkListItem and GtkTreeItem are deprecated in future versions of GTK+, so that it would seem reasonable to expect the toggle signal to disappear too over time.
Callback function:
void callback
(GtkItem item);
Constructor
—
GtkItemFactory
(int container_type, string path, GtkAccelGroup accel_group);
GtkItemFactory
(int container_type, string path, GtkAccelGroup accel_group);
void construct
(int container_type, string path, GtkAccelGroup accel_group);
GtkWidget get_item
(string path);
GtkWidget get_widget
(string path);
GtkWidget get_widget_by_action
(int action);
GtkWidget get_item_by_action
(int action);
Widget that displays a small amount of text.
Constructor
— Creates a new label with the given text inside it. If no text is specified, an empty label is created.
GtkLabel
([string label_text ]);Methods
set_text()
Sets the label text. set_justify()
Sets label justification. set_pattern()
Underlines text in the label. set_line_wrap()
Toggles line wrapping. get()
Gets label text. *deprecated in GTK2* parse_uline()
Parses underscores into underlines. *deprecated in GTK2*
A very common use of GtkLabel is to display text that describes or makes some comment about the use of an adjacent widget. If you need to display a great deal of text, use GtkText instead.
Note that labels do not generate events. If you want to catch events (e.g. from a button click) you will need to put the label in a GtkEventBox.
See also: GtkEditable, GtkEventBox, GtkText.
GtkLabel
([string
label_text
]);
The syntax to create a new GtkLabel widget is:
Sets the text for the label widget. Previous text in the label is not stored.
Note that any existing underlines are not overwritten in the same way that text is; use set_pattern() with no parameters to erase these.
void set_justify
(
GtkJustification
justification
);
set_justify() is the method for justifying text in GtkLabel. The options are GtkJustification enumerated flags, the default setting being GTK_JUSTIFY_CENTER.
set_pattern() is the method for underlining text in GtkLabel. It needs to be defined as a pattern, e.g. if your text consists of A B C, then "_ _" will underline A and C but not B, as that is where the space falls. Each underscore or space in the pattern maps directly to the character position in the label text.
Call this method with no parameters to erase existing underlines.
Toggles line wrapping in the label. If wrap is true, the lines exceeding the size of the widget will be automatically wrapped. Where wrap is false, those lines will be cut off at the widget's edge.
Returns the current text content of the label.
parse_uline() checks the string passed as the parameter for underscores, and then underlines the characters following the underscores. It will take the first underlined character in a label and return it as a lower-case accelerator key, e.g. _Save will return the accelerator key value for "s".
This method is used internally by Gtk+ for menu items.
Scrollable widget allowing multiple children in fixed positions.
Constructor
— Creates a scrollable backdrop whose children retain their positions.
GtkLayout
( GtkAdjustment hadjustment , GtkAdjustment vadjustment );Methods
put()
Fixes a child widget at the given position. move()
Moves a child widget to a new position. set_size()
Sets the size of the layout. get_hadjustment()
Returns the horizontal adjustment object. get_vadjustment()
Returns the vertical adjustment object. freeze()
Freezes the display during an update. thaw()
Allows the display to be updated.
A GtkLayout is a scrollable widget that provides a scrolling-aware backdrop for a child or children having fixed positions. It should be added directly to a GtkScrolledWindow.
Note that the scrolling does not work on win32 unless you program it to do so. There have been no such problems reported on other systems. The workaround under win32 is to connect the GtkScrolledWindow scrollbar adjustments' value-changed signals to a function that will force the GtkLayout to be redrawn. This can be queue_draw() in most situations, but the more complex child widgets will not respond to this alone and will need to have hide() and then show() called on the GtkLayout during the callback.
Note that GtkHtml is based on the GtkLayout class, and that similar redraw issues are seen with that widget.
GtkLayout
(
GtkAdjustment
hadjustment
,
GtkAdjustment
vadjustment
);
The following example is based on the GTK+ test file testgtk.c. Unix users will not need to use the callback function in order to achieve scrolling, but it shouldn't do any harm to run it as it stands. Win32 users will find that the labels are redrawn and the buttons are not, giving a somewhat psychedelic effect. To redraw both types of object under win32, replace the callback function with:
Example 21. Forcing a GtkLayout to redraw
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); /* callback that forces a redraw of simple child widgets */ function exposure($adj, $layout) { $layout->queue_draw(); } /* set up a window and size it to be smaller than the intended layout */ $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->set_title('Layout'); $window->set_usize(200, 200); $window->connect_object('destroy', array('gtk', 'main_quit')); /* create and add the scrolled window to the main window */ $scrolledwindow = &new GtkScrolledWindow(); $window->add($scrolledwindow); /* create and add the layout widget to the scrolled window */ $layout = &new GtkLayout(null, null); $scrolledwindow->add($layout); /* set the layout to be bigger than the windows that contain it */ $x = gdk::screen_width(); $y = gdk::screen_height(); $layout->set_size($x, $y); /* get the adjustment objects and connect them to the callback. This part should not be necessary under *nix systems */ $hadj = $scrolledwindow->get_hadjustment(); $vadj = $scrolledwindow->get_vadjustment(); $hadj->connect('value-changed', 'exposure', $layout); $vadj->connect('value-changed', 'exposure', $layout); /* populate the layout with a mixture of buttons and labels */ for ($i=0 ; $i < round($y/100); $i++) { for ($j=0 ; $j < round($x/100); $j++) { $buf =sprintf('Button %d, %d', $i, $j); if (($i + $j) % 2) $button = &new GtkButton($buf); else $button = &new GtkLabel($buf); $layout->put($button, $j*100, $i*100); } } /* display everything and run the main loop */ $layout->show_all(); $window->show_all(); gtk::main(); |
void put
(
GtkWidget
widget
, int x, int y);
This method adds a child widget to the layout. The top left corner of the child widget will be positioned at the co-ordinates passed in the x, y parameters.
void move
(
GtkWidget
widget
, int x, int y);
This method takes a child widget that has already been added to the GtkLayout and moves it to a new position reflecting the co-ordinates passed in the parameters.
Sets the size of the GtkLayout. If you do not call this method the layout will size itself according to the size allocation given it by the parent window, rather than the size requisition of the layout's child widgets.
GtkAdjustment
get_hadjustment
(void);
This method is used internally to set the horizontal scrollbar adjustment in the GtkScrolledWindow holding the GtkLayout. These sets of adjustment objects are interchangeable, i.e. they share the same values.
GtkAdjustment
get_vadjustment
(void);
This method is used internally to set the vertical scrollbar adjustment in the GtkScrolledWindow holding the GtkLayout. These sets of adjustment objects are interchangeable, i.e. they share the same values.
Use freeze() when you are updating a large amount of data, e.g. a large pixmap or series of pixmaps. Calling this method prior to the update will speed up the process and reduce flicker.
See also: thaw() .
thaw() is the corollary of freeze() . It allows the display to be redrawn after the new data is fully assimilated.
Widget displaying a list of selectable items.
Constructor
— Creates a container for a simple list.
GtkList
(void);Methods
append_items()
Appends an array of list items to a list. clear_items()
Clears designated list items from list. select_item()
Causes the select-child signal to be emitted. unselect_item()
Causes the unselect-child signal to be emitted. select_child()
Causes the select-child signal to be emitted. unselect_child()
Causes the unselect-child signal to be emitted. child_position()
Returns item specified by list position. set_selection_mode()
Sets the selection mode. extend_selection()
Extends selected area to position given. start_selection()
Selects range from anchor to currently selected item. end_selection()
Curtails selection set with start_selection() . select_all()
Selects all list items. unselect_all()
Deselects all list items. scroll_horizontal()
Sets associated horizontal scrollbar to a predetermined position. scroll_vertical()
Sets associated vertical scrollbar to a predetermined position. toggle_add_mode()
Toggles whether further selections may be added in extended mode. toggle_focus_row()
Toggles selection status of row with focus. toggle_row()
Toggles selection status of specified row. undo_selection()
In extended mode, returns selection to its previous state. end_drag_selection()
Ends drag selection. Signals
selection-changed: Emitted when the selection property is changed. select-child: Emitted when a list item is selected. unselect-child: Emitted when a list item is deselected. Properties
selection : Array containing current selection information.
A GtkList is a container widget that is designed to hold a simple list, the full range of which is displayed. The items held in the list are selectable, with the default selection mode set as GTK_SELECTION_SINGLE. Each item in the list must be a GtkListItem widget. Glade users will find that they need to code these manually in order to populate a list or combo box.
The signal part of the function/signal pair for most of the methods given here is private in GtkList, but is also implemented in GtkListItem. As this secondary implementation is also private, these signals are not covered in this manual. Although those signals that have GTK keybindings will cause the appropriate signal to be publicly fired when their key combinations are used, there is no other way to emit this range of signals. The keybindings are listed under GtkListItem; the signal prototypes share the relevant GtkList method's parameters, should you need to connect to them.
See also: GtkCList, GtkCombo, GtkListItem.
GtkList
(void);
Creating a GtkList widget is straightforward, populating it slightly less so. Each item added to the list container must itself be contained in a GtkListItem. In its simplest and most common form, all that means is that the GtkListItem is created with a label, the text content of which will be displayed in the list.
Example 22. Constructing a GtkList
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); function echo_it($list, $listitem) { /* collect the text from the selected list item's label */ $listlabel = $listitem->child; /* filter list items according to child object type */ if($listlabel->get_name() == 'GtkLabel') { $name = $listlabel->get(); $label = &new GtkLabel("You chose $name just now"); /* create a popup window and display a message relevant to selected item */ $popup = &new GtkWindow(GTK_WINDOW_POPUP); $popup->set_uposition((gdk::screen_width()/2)+50, (gdk::screen_height()/3)); $popup->add($label); $popup->show_all(); /* connect the list item's own deselect signal (not the list's) */ $listitem->connect_object('deselect', create_function('$popup', '$popup->destroy();'), $popup); } else gtk::main_quit(); } $window = &new GtkWindow(GTK_WINDOW_DIALOG); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); $list = &new GtkList(); /* the contents of this array will populate the list */ $fill = array('Angela', 'Belinda', 'Carolyn', 'Danike', 'Etha', 'Fiona', 'Gertraud', 'Heidi', 'Jessica', 'Kirstin', 'Lorinda', 'Marianne'); foreach(range(0, count($fill)-1) as $i) $listitem[] = &new GtkListItem($fill[$i]); $list->append_items($listitem); $enditem = &new GtkListItem(); /* a list item is also a container */ $button = &new GtkButton('Close'); $enditem->add($button); /* there is no way to append() a single item - but GtkList is a container widget, so it's okay to use add() */ $list->add($enditem); $list->connect('select-child', 'echo_it'); $list->show_all(); $window->add($list); $window->show_all(); gtk::main(); |
This is a widget-specific method for adding an array of GtkListItems to a GtkList.
Removes the list items between the positions given in the parameters, from a GtkList. The remaining items close up the gap, always moving closer to the top as there is no way to fix a child's list position. Note that the list container itself is not resized to reflect these changes.
The only difference between select_item() and select_child() is that the former takes the item's list position as a parameter rather than the GtkListItem object itself. In either case, the signal that is actually emitted is the list item's select signal - these are just different ways of describing the same thing, providing alternative means of selection and connection.
The only difference between unselect_item() and unselect_child() is that the former takes the item's list position as a parameter rather than the GtkListItem object itself. In either case, the signal that is actually emitted is the list item's deselect signal - these are just different ways of describing the same thing, providing alternative means of de-selection and connection.
void select_child
(
GtkWidget
child
);
The only difference between select_item() and select_child() is that the former takes the item's list position as a parameter rather than the GtkListItem object itself. In either case, the signal that is actually emitted is the list item's select signal - these are just different ways of describing the same thing, providing alternative means of selection and connection.
void unselect_child
(
GtkWidget
child
);
The only difference between unselect_item() and unselect_child() is that the former takes the item's list position as a parameter rather than the GtkListItem object itself. In either case, the signal that is actually emitted is the list item's deselect signal - these are just different ways of describing the same thing, providing alternative means of de-selection and connection.
int child_position
(
GtkWidget
child
);
child_position() returns the .list position currently holding the widget that was passed as the argument. The widget needs to be passed by reference, i.e. using the form $widget.
void set_selection_mode
(
GtkSelectionMode
mode
);
Sets one of the four possible GtkSelectionMode enumerated values.
The default setting is GTK_SELECTION_SINGLE.
void extend_selection
(
GtkScrollType
scroll_type
, double position, bool auto_start_selection);
This is quite a complex method that can only be used when the selection mode is set to GTK_SELECTION_EXTENDED. It duplicates and resets the focus row (i.e. the row that is marked as selected) and highlights all the items between that and the anchor item. It has different behaviours depending on whether or not the list has keyboard grab, so that putting it into a callback function does not have the same results as calling it from the main loop.
Selection of all the items in the highlighted range requires that scroll_vertical() is also set appropriately.
In general, calling the extend_selection() method will only select the last row with focus. It needs to have toggle_add_mode() set in order to do this when scroll_vertical() is set after the list widget has grab.
As with scroll_vertical() , this method's position parameter is used only when the GtkScrollType value is set to GTK_SCROLL_JUMP, and represents a percentage of the area covered by the scroll. The final parameter negates the method's functionality completely if set to false.
start_selection() selects the range between the anchor item - 0 on first opening or the most recent selection thereafter - and the next selection that is made. For instance, if you were to select item 4 on opening, the selection range would run as 4, 0, 1, 2, 3. If you then selected item 7 the new range would be 7, 4, 5, 6. Further items can be included in the selection by dragging while the mouse button is still pressed down from selecting the original item.
Note that this method can only be used if the list's selection mode is set to GTK_SELECTION_EXTENDED.
See also: end_selection() , end_drag_selection() .
end_selection() ends a selection as it would be if made using start_selection() . It curtails the selection so that only the anchor and the item selected return a select signal.
Note that this method can only be used if the list's selection mode is set to GTK_SELECTION_EXTENDED.
select_all() selects all the list items in a GtkList. Note that there needs to be the possibility of multiple selection for this method to work; see set_selection_mode() .
The corollary to select_all() , this method can also be used to clear the initial focus when the selection mode has been set to GTK_SELECTION_BROWSE.
void scroll_horizontal
(
GtkScrollType
scroll_type
, double position);
This method needs set_focus_hadjustment() to be called on the appropriate scrollbar from the GtkList in order for it to work. It scrolls the list horizontally to a predetermined position according to the GtkScrollType.
The position parameter is only used where the enumerated value is GTK_SCROLL_JUMP, when 0.0 sets the scroll to the (default) leftmost point and 1.0 to the rightmost. Values between 0.0 and 1.0 describe the percentage of the distance scrolled, i.e. 0.5 would set the beginning of the scroll slider halfway across the area.
Where any other GtkScrollType is set, the position is required but is then ignored.
void scroll_vertical
(
GtkScrollType
scroll_type
, double position);
This method needs set_focus_vadjustment() to be called on the appropriate scrollbar from the GtkList in order for it to work. It scrolls the list to a predetermined position according to the GtkScrollType setting and, if a selection has been made and the list's selection mode allows it, will automatically select the child nearest to the new scroll position.
The position parameter is only used where the enumerated value is GTK_SCROLL_JUMP, when 0.0 sets the scroll to the topmost item and 1.0 to the final item. Values between 0.0 and 1.0 describe the percentage of the distance scrolled, i.e. 0.5 would set the scroll so that the last visible item is the one holding the halfway position in the list.
Where any other GtkScrollType is set, the position is required but is then ignored.
When toggle_add_mode() has been called, the grab in a GTK_SELECTION_EXTENDED mode list will remain with the anchor item at the start of the selection, regardless of where the focus falls, until another item is actually selected. Effectively it switches the list to something very like GTK_SELECTION_BROWSE mode.
The item that currently has grab has a dashed line around it to signify its status, as well as the usual GTK_STATE_SELECTED style.
If the row having current focus is marked as selected, calling toggle_focus_row() will unselect it, and vice versa. In both cases the appropriate signal is fired.
This method would be pointless in a list set to GTK_SELECTION_BROWSE, and so is not implemented there.
void toggle_row
(
GtkWidget
item
);
If the item specified in the parameter is marked as selected, calling toggle_row() will unselect it, and vice versa. In both cases the appropriate signal is fired.
If the selection mode is GTK_SELECTION_BROWSE, the item will always be selected.
This method returns selection to its previous state if the list mode is set to GTK_SELECTION_EXTENDED. It is not implemented in any other mode.
This method is used extensively within GTK to complete a selection. It removes the grab from the list, and also the internal timer associated with the drag action. It is unlikely to be very useful at this level.
The selection-changed signal is emitted whenever there is a change in the list's selection property, regardless of whether that change empties the array.
Callback function:
void callback
(GtkList list);
The select-child signal is emitted when a child is selected. It carries the selected child as an argument.
This signal is basically a wrapper for the select signal emitted by the GtkListItem that is currently selected. If you mix the two, the same item will emit the same signal twice in response to selection.
Callback function:
void callback
(GtkList list, GtkWidget child);
The unselect-child signal is emitted when a child is deselected. It carries the deselected child as an argument.
This signal is basically a wrapper for the deselect signal emitted by the GtkListItem that has just been deselected. If you mix the two, the same item will emit the same signal twice in response to deselection.
Callback function:
void callback
(GtkList list, GtkWidget child);
Type: Read Only
The selection property is an array that contains any currently selected items. If there is no current selection, the array will be empty. If the selection mode does not allow multiple selection,
$list->selection[0]; |
See also: children() .
A single element in a GtkList.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkListItem
Constructor
— Creates a list element.
GtkListItem
([string label ]);Methods
select()
Causes the select signal to be emitted. deselect()
Causes the deselect signal to be emitted.
A GtkListItem is one of the elements that makes up a GtkList. It can consist of many things - see the constructor page - being basically a container with a specialised set of methods and signals.
GtkListItems are not equipped to carry data, unless you make it so. Using the GtkObject methods get_data() , remove_data() and set_data() is the usual way to achieve this. See GtkCombo for a working example.
The GtkListItem class supplies a multitude of signals to the list widget recursively, where they are treated as private signals and used internally. Several of these signals have keybindings, implemented here rather than in GtkList of necessity, which are described below.
Table 3. Key bindings used in GtkList
Key combination Effect Equivalent GtkList method Up arrow Scrolls up one step scroll_vertical(GTK_SCROLL_STEP_BACKWARD, 0.0) Down arrow Scrolls down one step scroll_vertical(GTK_SCROLL_STEP_FORWARD, 0.0) Page Up Scrolls up one page scroll_vertical(GTK_SCROLL_PAGE_BACKWARD, 0.0) Page Down Scrolls down one page scroll_vertical(GTK_SCROLL_PAGE_FORWARD, 0.0) Control + Home Scrolls to the top of the list scroll_vertical(GTK_SCROLL_JUMP, 0.0) Control + End Scrolls to the end of the list scroll_vertical(GTK_SCROLL_JUMP, 1.0) Shift + Up arrow Selects up one step extend_selection(GTK_SCROLL_STEP_BACKWARD, 0.0, true) Shift + Down arrow Selects down one step extend_selection(GTK_SCROLL_STEP_FORWARD, 0.0, true) Shift + Page Up Selects up one page extend_selection(GTK_SCROLL_PAGE_BACKWARD, 0.0, true) Shift + Page Down Selects down one page extend_selection(GTK_SCROLL_PAGE_FORWARD, 0.0, true) Shift | Control + Home Selects to the top of the list extend_selection(GTK_SCROLL_JUMP, 0.0, true) Shift | Control + End Selects to the end of the list extend_selection(GTK_SCROLL_JUMP, 1.0) Left arrow Scrolls one step to the left scroll_horizontal(GTK_SCROLL_STEP_BACKWARD, 0.0) Right arrow Scrolls one step to the right scroll_horizontal(GTK_SCROLL_STEP_FORWARD, 0.0) Home Scrolls to the left of the list scroll_horizontal(GTK_SCROLL_JUMP, 0.0) End Scrolls to the right of the list scroll_horizontal(GTK_SCROLL_JUMP, 1.0) Escape Returns to previous selection undo_selection() Space Toggles state of row with current focus toggle_focus_row() Control + Space Toggles whether further items can be selected toggle_add_mode() Control + / Selects all items select_all() Control + \\ Deselects all items unselect_all() Shift_L + Release | Shift Completes selection end_selection() Shift_R + Release | Shift Completes selection end_selection() Shift_R + Release | Shift | Control Completes selection end_selection()
GtkListItem
([string
label
]);
A GtkListItem is a container widget, derived indirectly from GtkBin and so only able to hold one direct child. Most of the time, the child you will want the list item to contain will be a GtkLabel - and so, in common with all objects that have an alternative '-with-label' constructor available in GTK, we have the option in PHP-GTK to pass the label's text as a parameter during construction, e.g.
If you wanted something other than a label in the list item, you simply omit the parameter and add the required widget:
$arrow = &new GtkArrow(GTK_ARROW_RIGHT, GTK_SHADOW_ETCHED_IN); $listitem = &new GtkListItem(); $listitem->add($arrow); |
$box = &new GtkHBox(); $label = &new GtkLabel("Here we have multiple objects in a GtkListItem"); $arrow = &new GtkArrow(GTK_ARROW_RIGHT, GTK_SHADOW_ETCHED_IN); $box->pack_start($label); $box->pack_end($arrow); $box->show_all(); $listitem = &new GtkListItem(); $listitem->add($box); |
Whatever your list item consists of, the GtkList will only respond to it as a GtkListItem. If you have different kinds of list item contents in the same list, you will need to exercise a great deal of caution if you are connecting callbacks to any form of select signal.
See also: GtkList, which has a working example under the constructor.
The GtkListItem method select() causes the list item to emit the GtkItem signal select. This is then bound recursively to the GtkListItem implementation of that signal.
The same sequence of events is produced by calling the GtkList method select_child() .
The easy part: it sets the GtkStateType of the calling list item to GTK_STATE_SELECTED.
Note that this state can also be achieved programmatically by calling toggle() from a list item that is currently unselected.
The GtkListItem method deselect() causes the list item to emit the GtkItem signal deselect. This is then bound recursively to the GtkListItem implementation of that signal.
The same sequence of events is produced by calling the GtkList method unselect_child() .
The easy part: it sets the GtkStateType of the calling list item to GTK_STATE_NORMAL.
Note that this state can also be achieved programmatically by calling toggle() from a list item that is currently selected.
Popup container for menu items.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkMenuShell
áááááááááááááááááá`-- GtkMenu
Constructor
— Creates the structure to hold a menu's content.
GtkMenu
(void);Methods
popup()
Pops up a menu. reposition()
Repositions menu. popdown()
Pops down menu. get_active()
Gets currently selected GtkMenuItem. set_active()
Sets active menu item. set_accel_group()
Sets the GtkAccelGroup holding global accelerators. get_accel_group()
Gets the GtkAccelGroup holding global accelerators. get_uline_accel_group()
Gets the internally-used GtkAccelGroup, if there is one. ensure_uline_accel_group()
Creates a GtkAccelGroup for internal menu use if one does not exist. attach_to_widget()
Sets attachment to specified widget. detach()
Detaches menu from associated widget. get_attach_widget()
Returns the widget currently attached. set_tearoff_state()
Toggles whether menu is torn off. set_title()
Sets the title for a torn off menu. reorder_child()
Moves specified item to given position.
GtkMenu is a menushell widget, designed to exclusively hold GtkMenuItems. It may be a standalone popup widget, or may be associated either with a higher-level GtkMenuItem within a GtkMenuBar, or with a GtkOptionMenu.
Note that a GtkMenu in any form is effectively a modal popup widget. There are keybindings in place here specifically to counteract this apparent isolation, by allowing the Up, Down, Left and Right arrow keys to navigate multiple menus with regard to the relationships between those menus (i.e. parent and child, next and previous). These are fairly rudimentary in the current version of GTK+ used in PHP-GTK, but have been improved recently.
See also: GtkCombo, GtkCTree, GtkItemFactory, GtkList, GtkRadioButton, GtkToolbar.
GtkMenu
(void);
creates an empty popup container widget that will exclusively hold GtkMenuItems. It may be instantiated alone as an event-driven popup menu (see the example below) or it can be associated with a higher-level GtkMenuItem as a submenu, or a GtkOptionMenu as a menu. When it is associated with an object in this way, the menu will pop up in response to the object's activation.
Example 23. Creating a right-click popup menu
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); function show_popup($event, $menu) { if($event->button == 3) { $menu->popup(null, null, null, $event->button, $event->time); } $window = &new GtkWindow(); $window->set_default_size(350, 450); $window->connect_object('destroy', array('gtk', 'main_quit')); $menu = &new GtkMenu(); $accel = $menu->ensure_uline_accel_group(); $open = &new GtkMenuItem("Open"); $open->lock_accelerators(); $menu->append($open); $save = &new GtkMenuItem("Save as ..."); $save->lock_accelerators(); $menu->append($save); $separator = &new GtkMenuItem(); $separator->set_sensitive(false); $menu->append($separator); $exit = &new GtkMenuItem(""); $accel_label = $exit->child; $accel_key = $accel_label->parse_uline("E_xit"); $exit->add_accelerator('activate', $accel, $accel_key, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); $exit->lock_accelerators(); $exit->connect_object('activate', array('gtk', 'main_quit')); $menu->append($exit); $menu->show_all(); $window->add_events(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); $window->connect_object('button-press-event', 'show_popup', $menu); $window->show_all(); gtk::main(); |
void popup
([
GtkWidget
parent_menu_shell
, [
GtkWidget
parent_menu_item
, [
GtkMenuPositionFunc
pos_function
, int button, int activate_time]]]);
The popup() method looks fairly intimidating at the outset, but is actually quite straightforward to use.
The first thing to be aware of is that the parent_menu_shell and parent_menu_item parameters would generally only be used internally, to associate the popped-up menu with a given GtkMenuShell descendant, or GtkMenuItem, or both. In a freestanding popup menu, both parameters should be passed as null.
The third parameter concerns the positioning of the popup menu, and has as its default the position of the mouse pointer. In order to set a different position, you will need to set up a function that will return an array of the co-ordinates, and call it from the pos_function parameter.
function position() { $position = array(300, 200); return $position; } $filemenu->popup(null, null, 'position', $event->button, $event->time); |
The fourth parameter refers to the mouse button emitting the button-release-event that will be compared with the button emitting the button-press-event in order to set the timer in the final parameter. This only works if you happen to be triggering the popup function with a button press, and the button pressed and button released are the same - in all other situations, the time element is ignored. However, setting the button parameter to 1 or 3 will speed up the deactivation when the left or right mouse button is released respectively, regardless of the callback event.
The final parameter, activate_time, sets the time conditions for the menu's deactivation. If you have used a button press event and ensured that the initial press and later release have the same valid integer value, then setting the timer to 0 will make the menu disappear as soon as the user releases the mouse-button that triggered it. The safest setting for this parameter is
$event->time |
reposition() is used internally to reposition a GtkMenuItem's submenu according to the results of the position function called in the popup() method.
popdown() is used internally to de-reference a popup menu. It is one of the methods that is called when a menu emits the deactivate signal.
GtkWidget get_active
(void);
get_active() can be used to retrieve the currently selected GtkMenuItem object through the menu. Note that this method returns the menu item object itself, and is really only useful for comparison against a set of criteria. In most instances it would be more efficient to connect the individual menu item's activate signal.
The get_active() method is used internally in GtkOptionMenu's set_history() to compare the menu item currently selected by the user against that previously displayed.
set_active() sets the 'active' GtkMenuItem in a GtkMenu. Note that this is not the same thing as calling the select() from the menu item, but is a way of adding to the given item's reference count from the menu.
The set_active() method is mainly used internally in GTK, as part of GtkOptionMenu's set_history() method.
void set_accel_group
(
GtkAccelGroup
accel_group
);
set_accel_group() sets the global accelerator group for a GtkMenu. A GtkAccelGroup set in this way should also be designated as toplevel. This is achieved by calling add_accel_group() from the corresponding toplevel GtkWindow.
Note that there is a bug in the win32 version of GTK+ currently used in PHP-GTK. The accelerator key appears as it should, but does not connect to its designated signal where the accel group has been newly created and set in this way. Also, much of the accelerator locking mechanism has been replaced in GTK2. Future-friendly code can be created by using GtkItemFactory to create your menus; however, the same limitations in functionality currently apply.
GtkAccelGroup
get_accel_group
(void);
get_accel_group() returns the global accelerator group that is used in the calling GtkMenu.
Note that this method does not work as it should in the win32 version of GTK+ currently used by PHP-GTK. Also, much of the accelerator lock mechanism has been replaced in GTK2. Future-friendly code can be created by using GtkItemFactory to create your menus; however, the same limitations in functionality currently apply.
GtkAccelGroup
get_uline_accel_group
(void);
get_uline_accel_group() returns the GtkAccelGroup used by GTK during the time that the GtkMenu is popped up. It is used internally to allow the user to modify the key accelerators where they have not been locked.
Note that this method does not work as it should in the win32 version of GTK+ currently used by PHP-GTK. Also, this method has been eliminated from later versions of GTK+, and much of the accelerator lock mechanism replaced. Future-friendly code can be created by using GtkItemFactory to create your menus; however, the same limitations in functionality currently apply.
GtkAccelGroup
ensure_uline_accel_group
(void);
ensure_uline_accel_group() returns the GtkAccelGroup used by GTK during the time that the calling GtkMenu is popped up, if one exists, and creates one for internal use if there is none.
This is currently the only way to get accelerators working properly under win32. It is also used internally for popup menus in GtkItemFactory. However, note that this method has been eliminated from later versions of GTK+. The replacements in GtkItemFactory are purely internal; the new methods in GtkMenu are not.
void attach_to_widget
(
GtkWidget
attach_widget
);
attach_to_widget() is mostly used internally to set up the relationship between the 'parent' - usually a GtkMenuItem - and the GtkMenu that is calling the method.
This is not the same thing as setting a submenu for a menu item (use set_submenu() for that), but creates an underlying relationship that subsumes the reference count on the menu to that of the attach_widget. The GtkWidget method set_parent() has very similar functionality, but is not appropriate here because the menu is itself a toplevel widget.
detach() detaches the calling GtkMenu from its current parent widget. This method is used internally when the menu is being destroyed.
Calling the detach() method after the menu has been set as a submenu, unsets that relationship in exactly the same way as remove_submenu() would. The difference is that the attached widget does not necessarily need to be a GtkMenuItem for detach() to work.
GtkWidget
get_attach_widget
(void);
get_attach_widget() returns the object to which the calling GtkMenu is currently attached. Use get_name() to further identify the returned object, or else compare it with likely candidates.
set_tearoff_state() when set to true creates a non-resizeable, decorated, top-level window, sized to fit the menu contents and iconized in the task bar. The torn-off menu does not need a further parent window, and can act as a standalone widget in its own right.
Where the same menu has also been set as a submenu on an existing GtkMenuItem or as a popup, the menu data is displayed in the currently-visible menu shell.
Note that the GtkMenu in this form is not and cannot be made modal. It could be described as a persistent popup.
It is not possible to connect directly to the tearoff window housing the menu, because it has not been exposed as a property in PHP-GTK - with good reason, as the reference counting has been juggled in GTK+ to make the widget possible in the first place. In order to connect the window's delete event to something meaningful, you will need to do something like this:
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); function exit_activated($menu) { $menu->destroy(); } $menu = &new GtkMenu(); $window = $filemenu->parent; $window->ref(); $window->set_flags(GTK_HAS_GRAB); $menu->connect_object('destroy', array('gtk', 'main_quit')); .... /* Append and connect your menu items here, but note that any exit item must call $menu->destroy() rather than the usual gtk::main_quit(), in order to avoid the main loop being quitted twice over */ .... $exit = &new GtkMenuItem("Exit"); $exit->connect_object('activate', 'exit_activated', $menu); $menu->set_title("Tested!"); $menu->set_tearoff_state(true); $menu->show_all(); gtk::main(); |
You will also spot that this means the menu needs to be rebuilt any time it is called.
set_title() sets the window title for a menu that has been detached from its parent through either a GtkTearoffMenuItem widget or the set_tearoff_state() method. As with all window titles, the text will be truncated to fit the area available.
Note that the title needs to be set prior to the menu's becoming torn off.
If the title is not set, the torn off menu will display in its title bar either the text in the parent GtkMenuItem's label or, where there is none, the full file path.
void reorder_child
(
GtkWidget child
, int position);
reorder_child() moves the specified GtkMenuItem from its current position in the GtkMenu to the position given. All items prior to the new position remain unchanged, and the later items all move on one.
The first position is 0, and the final position can always be found by setting -1.
Horizontal container for menu items.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkMenuShell
áááááááááááááááááá`-- GtkMenuBar
Constructor
— Constructs a horizontal menu bar.
GtkMenuBar
(void);Methods
set_shadow_type()
Alters appearance of menu bar.
A GtkMenuBar is a container that exclusively holds GtkMenuItem widgets, and displays them from left to right.
It has key bindings which allow the Up, Down, Left and Right arrow keys to be used for menubar navigation. Note that these do not work in the win32 version of GTK+ used by PHP-GTK.
GtkMenuBar
(void);
A GtkMenuBar should normally be packed into a GtkVBox, and the parent window size and position set as appropriate. As with all containers, the menu bar itself takes up no screen area until its child widgets are in place.
Example 24. Creating a Menu Bar
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); $window = &new GtkWindow(); $window->set_uposition(10, 10); $window->set_usize((gdk::screen_width()-20), (gdk::screen_height()-30)); $window->connect_object('destroy', array('gtk', 'main_quit')); $box = &new GtkVBox(); $window->add($box); .... $menubar = &new GtkMenuBar(); $box->pack_start($menubar, false, false, 0); $header1 = &new GtkMenuItem("File"); $menubar->append($header1); $header2 = &new GtkMenuItem("Edit"); $menubar->append($header2); .... $filemenu = &new GtkMenu(); $open = &new GtkMenuItem("Open"); $filemenu->append($open); $save = &new GtkMenuItem("Save"); $filemenu->append($save); $separator = &new GtkMenuItem(); $separator->set_sensitive(false); $filemenu->append($separator); $exit = &new GtkMenuItem("Exit"); $exit->connect_object("activate", array("gtk", "main_quit")); $filemenu->append($exit); $header1->set_submenu($filemenu); .... $window->show_all(); gtk::main(); |
void set_shadow_type
(
GtkShadowType type
);
set_shadow_type() alters the appearance of a GtkMenuBar according to the GtkShadowType option set.
The default setting is GTK_SHADOW_OUT.
Widget used for item in menus.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkMenuItem
Constructor
— Creates a menu item.
GtkMenuItem
([string label ]);Methods
set_submenu()
Sets a GtkMenu as submenu. remove_submenu()
Removes a pre-existing submenu. set_placement()
Toggles placement of submenu relative to parent. configure()
Toggles indicators. select()
Emits the select signal. deselect()
Emits the deselect signal. activate()
Emits the activate signal. right_justify()
Sets item to the right of a GtkMenuBar. Signals
activate: Emitted when menu item is chosen. activate-item: Fired when activate_item() is called.
A GtkMenuItem is a container widget that can be packed into a GtkMenu or GtkMenuBar, containing a GtkAccelLabel and capable of being associated with a submenu.
GtkMenuItem
([string
label
]);
The syntax
will create a single item in a menu with the label Edit. However this label is really a GtkAccelLabel, and has the ability to display any keyboard shortcuts - known as accelerators - associated with it.For more information on setting up accelerator display in this way, see add_accelerator() . There is also a working example in the GtkMenu constructor section of this manual.
Underlining an accelerator key within the label text is a separate issue, and can be achieved by calling the GtkLabel method parse_uline() from the accelerator label. A string passed using this method will overwrite any existing text in the label.
Much of the above is to some extent automated in the GtkItemFactory API, and different methods may apply when setting up a GtkItemFactory-generated menu.
Note that it is not possible to add a GtkHSeparator object to either a GtkMenuItem or a GtkMenu. The current workaround for this is to create an empty menu item and then toggle its sensitivity so that it cannot be inadvertently selected by the end user:
$separatoritem = &new GtkMenuItem(); $separator->set_sensitive(false); $menu->append($separatoritem); |
void set_submenu
(
GtkWidget submenu
);
set_submenu() sets the instance of GtkMenu passed as the parameter to be a submenu for the calling GtkMenuItem.
The submenu will be displayed whenever the calling menu item is selected.
remove_submenu() is the GtkMenuItem-specific version of the remove() found in GtkContainer. It is useful where a submenu needs to be removed or altered under given conditions within a script.
void set_placement
(
GtkSubmenuPlacement
placement
);
set_placement() toggles the placement of the submenu relative to its parent. This method is used internally to ensure that the submenu is always displayed within the visible screen area when it is activated.
configure() is intended to set the visibility of both the toggle and submenu indicator. However these are set internally in GTK+ to be true when appropriate and cannot be overridden, and although not marked as such this method has been eliminated from later revisions of GTK+.
select() makes the calling GtkMenuItem emit the select signal inherited from GtkItem.
In the GtkMenuItem widget, the emission of the select signal causes the widget to display its prelight GtkStateType and pops up its submenu, if it has one.
Note that the select signal is also emitted whenever a GtkMenuItem is entered by the cursor, and by the first item in a GtkMenu when it is popped up.
deselect() makes the calling GtkMenuItem emit the deselect signal inherited from GtkItem.
In the GtkMenuItem widget, the emission of the deselect signal causes the widget to display its normal GtkStateType and pops down its submenu, if it has one.
Note that the deselect signal is also emitted whenever the cursor leaves the screen area of a menu item.
activate() causes the calling GtkMenuItem to emit the activate signal as if the user had clicked on it.
right_justify() sets a GtkMenuItem to the right of the GtkMenuBar it is appended to. It has no effect in any other situation, and can only be used on the menu item taking the final position in the menu bar's array of items.
The activate signal is emitted when the user presses a mouse button while the cursor is over the widget, or hits the Enter key or spacebar while the widget is selected, or if the activate() method has been called from within the program by the widget, or if the activate_item() method has been called from within the program by the widget's parent.
It is also defined as the accelerator signal, so that any accelerator key associated with the widget will also emit the activate.when pressed, whether the widget is currently selected or not.
On activation, all GtkMenu widgets that are a part of the cascading selection sequence disappear from the screen, regardless of whether or not the GtkMenuItem has its activate signal connected to a function within the program.
Callback function:
void callback
(GtkMenuItem menuitem);
The activate-item signal is fired when activate_item() is called from a GtkMenuShell object. It is used internally in order to provide an indirect means of firing the activate signal.
If you have called the activate_item() method, you will need to connect() the appropriate GtkMenuItem to the activate signal.
Callback function:
void callback
(GtkMenuItem menuitem);
Abstract base class for menu objects.
Methods
append()
Adds item to end of menu. prepend()
Adds item to start of menu. insert()
Inserts item at specified position in menu. deactivate()
Emits deactivate signal. select_item()
Makes designated item emit the select signal. deselect()
Makes designated item emit the deselect signal. activate_item()
Makes designated item emit the activate signal. Signals
deactivate: Emitted when the menu is no longer active. selection-done: Emitted when selection is complete or cancelled. cancel: Cancels menu using key bindings.
GtkMenuShell is a special kind of abstract container that provides its descendants GtkMenu and GtkMenuBar with methods and signals that are appropriate to typical menu behaviour.
There are three keybindings set up here which are carried down to the inheriting classes. These are as follows:
The activate-current signal has not been documented here because any attempt to harness it beyond these bindings results in abort. The same applies to the move-current signal, implemented here and given keybindings in both GtkMenu and GtkMenuBar.
Escape cancels an existing popup menu Return activates the current selection Space also activates the current selected item Note that GtkMenuShell is an abstract base class, and can not be constructed directly.
void append
(
GtkWidget child
);
append() adds the item passed as the parameter to the current end position in the array of child objects within the containing menu.
See also: prepend() , insert() , GtkContainer.
void prepend
(
GtkWidget child
);
prepend() adds the item passed as the parameter to the current beginning position in the array of child objects within the containing menu, i.e. a second item packed using prepend() will precede the first item packed in this way.
void insert
(
GtkWidget child
, int position);
insert() allows the programmer to specify the position of the item within the menu's array of menuitems, regardless of the order of method calls.
If a position given is impossible (e.g. larger than the size of the array) the positioning of all items will be ignored, with the exception of 0. In this case the ordering of the method calls will take precedence.
deactivate() causes the calling menu to emit the deactivate signal, which has the effect of deselecting any currently selected menu item and toggling the active status of the menu to false before removing any grabs the menu may currently have. This in turn takes down the menu.
The deactivate() method is largely used internally.
void select_item
(
GtkWidget menu_item
);
select_item() is largely used internally. A 'selected' item is displayed in the prelight state and has its submenu popped up, if it has one. This is also achieved by using the mouse pointer or arrow keys in an active GtkMenu, and should not be confused with the activate signal, which is triggered by mouse clicks or the Enter key.
Using this method causes the designated item to emit the select signal, which in turn triggers the 'selected' state.
As with the select_item() method, deselect() is mostly used internally. A 'deselected' item is displayed in the normal state and has its submenu popped down, if it has one.
Using this method causes the designated item to emit the deselect signal, which in turn triggers the 'deselected' state.
void activate_item
(
GtkWidget menu_item
, bool force_deactivate);
activate_item() is used to emit the activate signal from the GtkMenuItem passed as the first argument. This has the same effect as a user clicking on an item or pressing the Enter key while that item is selected.
If the second parameter is set to true, the deactivate() method is called on the menu that the GtkMenuItem is a part of, taking the menu down. If set to false, the menu item is hidden on activation.
The deactivate signal is emitted when either a GtkMenuItem within the current menu has been selected or the menu has been cancelled.
This signal initiates the menu's deactivate routine, which removes the key and pointer grabs from the menu and deselects any selected item before popping the menu down. It is largely used internally, and probably carries more overhead when called than the selection-done signal emitted under similar conditions.
Callback function:
void callback
(GtkWidget menu);
The selection-done signal is emitted when the selection routine is complete, that is, when either a GtkMenuItem within the menu has been selected or when the user has cancelled the menu by using the Escape key.
This signal is not connected to any internal functions, merely reporting the selection status. Use it in preference to the deactivate signal.
Callback function:
void callback
(GtkWidget menu);
The cancel signal is fired when the Escape key is pressed.
The internal functions called when this signal is emitted cancel the current selection, deactivate the menu, and fire the selection-done signal.
It is, however, possible to add to the functions that this signal already invokes.
Callback function:
void callback
(GtkWidget menu);
Base class for widgets having their own alignment and padding.
Methods
set_alignment()
Sets alignment. set_padding()
Sets padding. Properties
xalign : Relative distance from container's left edge. yalign : Relative distance from container's top edge. xpad : Padding along horizontal axis. ypad : Padding along vertical axis.
GtkMisc is a base class bequeathing alignment and padding properties and related methods to its descendants.
Most widgets do not have such properties on their own account, and only get them through being packed into a multiple container such as the GtkBox family members or GtkTable, or else through using the GtkAlignment widget which is designed to lend a facsimile of these properties to its child widget.
It is therefore rare in GTK+ to find a widget capable of calling its own alignment and padding properties directly, and only GtkMisc descendants are able to do so.
This is an abstract base class, and cannot be directly constructed.
set_alignment() sets the relative positioning of the calling widget within its container. xalign refers to the relative distance from the left edge, and yalign to the relative distance from the top edge of the container, with 0.0 being no distance from those respective edges and 1.0 being no distance from their opposites.
set_padding() sets the padding around the calling widget to the given number of pixels, in both directions.
Type: Read Only
The xalign property provides the means to query the relative position of the widget to its container along the horizontal axis.
Type: Read Only
The yalign property provides the means to query the relative position of the widget to its container along the vertical axis.
Type: Read Only
The xpad property provides the means to query the padding around the widget to the left and right of the area it takes up. The returned integer represents pixels.
Type: Read Only
The ypad property provides the means to query the padding around the widget to the top and bottom of the area it takes up. The returned integer represents pixels.
Widget that displays a set of pages with tabs.
Constructor
—
GtkNotebook
(void);Methods
append_page()
append_page_menu()
prepend_page()
prepend_page_menu()
insert_page()
insert_page_menu()
remove_page()
get_current_page()
get_nth_page()
page_num()
set_page()
next_page()
prev_page()
set_show_border()
set_show_tabs()
set_tab_pos()
set_homogeneous_tabs()
set_tab_border()
set_tab_hborder()
set_tab_vborder()
set_scrollable()
popup_enable()
popup_disable()
get_tab_label()
set_tab_label()
set_tab_label_text()
get_menu_label()
set_menu_label()
set_menu_label_text()
set_tab_label_packing()
reorder_child()
GtkNotebook
(void);
GtkWidget get_nth_page
(int page_num);
int page_num
(GtkWidget child);
void set_tab_pos
(GtkPositionType pos);
void set_tab_label_text
(GtkWidget child, string tab_text);
void set_menu_label_text
(GtkWidget child, string menu_text);
void set_tab_label_packing
(GtkWidget child, bool expand, bool fill, GtkPackType pack_type);
void reorder_child
(GtkWidget child, int position);
The base class of the PHP-GTK class hierachy.
Methods
flags()
Fetch the current objects flags. set_flags()
Sets various flags on the object. unset_flags()
Unset certain flags on the object. default_construct()
The default object constructor. constructed()
Mark object as constructed. sink()
Decrease the initial reference count by 1. ref()
Increase the reference count on an object. unref()
Decrease a reference count on an object. destroy()
Call an objects shutdown handler. get_arg()
set_arg()
set_data()
remove_data()
Removes data from the objects data associations. get_data()
remove_no_notify()
Remove data without invoking the associations destroy handler. emit_stop()
emit_stop_by_name()
connect()
Connects a signal and a callback. connect_after()
Connects a signal and a callback to be called after any others. connect_object()
Pass a different object to the callback. connect_object_after()
Pass a different object to the callback, register the callback last. disconnect()
signal_handler_block()
signal_handler_unblock()
signal_handler_pending()
signal_handler_pending_by_id()
emit()
signal_handlers_destroy()
GtkObject is the base class of the PHP-GTK object hierachy. It implements the functionality that every object below it in the tree has. This object should not be directly constructed from PHP-GTK but is documented here for reference reasons.
This method returns the objects flags and defined in the enum GtkObjectFlags. The return value can be used to find information about the objects current state.
See also: set_flags , unset_flags .
This method allows you to set the flags defined in the GtkObjectFlags enum. The flags can be set to reflect an objects current state.
See also: flags , unset_flags .
This method allows the programmer to unset various flags, as defined in the GtkObjectFlags enum. These flags can be changed to reflect the objects current state.
This constructor is called when arguments have the GTK_ARG_CONSTRUCT flag set within GtkArgFlags.
This method allows precise control over the construction process. It marks an object as being constructed, this stops any further constructors being called on the object.
This method allows the programmer to decrease the objects reference count by 1, this only occurs the first time the sink method is called.
This might be used when an object that is floating is created. When the object is assigned a parent then it is sunk, but, the parent now also has a reference to the object so its reference count is now 1.
Increase the reference count on an object.
Decrease a reference count on an object.
This method causes the objects shutdown handler to be called. The objects memory wont be freed though until the object's reference count is 0.
See Also: unref
Connects a function to a signal so it is called when the signal is emitted by a widget.
The function takes two or three arguments. The first parameter, signal is the textual name of the signal, the second parameter, function is the name of the function that should be used as a callback. The third parameter, custom is optional and can be used to pass extra data to the callback. Please see the Userguide section of the manual for more information on this.
See Also: connect_after , connect_object , connect_object_after
Connects a function to a signal so it is called when the signal is emitted by a widget. The callback is guaranteed to be called after the normal and default handlers.
The function takes two or three arguments. The first parameter, signal is the textual name of the signal, the second parameter, function is the name of the function that should be used as a callback. The third parameter, custom is optional and can be used to pass extra data to the callback. Please see the Userguide section of the manual for more information on this.
See Also: connect , connect_object , connect_object_after
connect_object allows the passing of a different object to a callback than the one for emitting the signal in the first place.
The signal parameter is the textual name of the signal we want to connect to, the function parameter is the textual name of the function we want to connect to the signal and the param parameter is the object we want to pass as the first parameter to the callback.
The function returns the signal_id.
See Also: connect , connect_after , connect_object_after
connect_object_after allows the passing of a different object to a callback than the one for emitting the signal in the first place. By using the connect_object_after you can ensure that all normal handlers, and the default handler are called first.
The signal parameter is the textual name of the signal we want to connect to, the function parameter is the textual name of the function we want to connect to the signal and the param parameter is the object we want to pass as the first parameter to the callback.
The function returns the signal_id.
See Also: connect , connect_after , connect_object
Widget used to choose from a list of valid choices.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkButton
áááááááááááááááááááááááá`-- GtkOptionMenu
Constructor
— Creates a popup menu linked to a button.
GtkOptionMenu
(void);Methods
get_menu()
Retrieves current menu. set_menu()
Sets associated menu. remove_menu()
Removes existing menu. set_history()
Sets button text to that of designated GtkMenuItem.
A GtkOptionMenu consists of a button containing a label, with an indicator tab to the right.
The GtkMenu currently associated with the option menu pops up in a similar area to that which would be taken up by a dropdown menu. This is, however, a popup menu; if you need a dropdown list widget, take a look at GtkCombo.
GtkOptionMenu
(void);
Constructing a GtkOptionMenu is less complicated that creating most other forms of menu.
Example 25. Creating a simple GtkOptionMenu.
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); function echo_activated($item, $label, $rank, $x) { echo "\$items[$x] ('$label') is the $rank ".$item->get_name().".\n"; flush(); } $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); $menu = &new GtkMenu(); $labels = array('File', 'Edit', 'Save', 'Exit'); $pos = array('first', 'second', 'third', 'fourth'); for($i = 0; $i < 4; $i++) { $items[$i] = &new GtkMenuItem($labels[$i]); $items[$i]->connect('activate', 'echo_activated', $labels[$i], $pos[$i], $i); $menu->append($items[$i]); } $menu->show_all(); $optionmenu = &new GtkOptionMenu(); $optionmenu->set_menu($menu); $window->add($optionmenu); $window->show_all(); gtk::main(); |
GtkWidget get_menu
(void);
get_menu() returns the instance of the GtkMenu that is currently associated with the calling GtkOptionMenu.
void set_menu
(
GtkWidget menu
);
set_menu() sets the GtkMenu specified in the parameter to be associated with the calling GtkOptionMenu.
remove_menu() removes the GtkMenu currently associated with the GtkOptionMenu.
In order to avoid an error message the next time that the user clicks on the GtkOptionMenu after menu removal, it is necessary to either replace it with a new GtkMenu or to call set_sensitive(false) from the GtkOptionMenu. Either call will avert an error message regards the menu not existing.
set_history() is used internally in GTK to display the text of the GtkMenuItem most recently activated by the user.
This method can also be used by the PHP-GTK programmer to override this default behaviour or, alternatively, to designate an initial setting using the index position.
Constructor
—
GtkPacker
(void);
GtkPacker
(void);
void add_defaults
(GtkWidget child, GtkSideType side, GtkAnchorType anchor, GtkPackerOptions options);
void add
(GtkWidget child, GtkSideType side, GtkAnchorType anchor, GtkPackerOptions options, [int border_width = 0, [int pad_x = 0, [int pad_y = 0, [int i_pad_x = 0, [int i_pad_y = 0]]]]]);
void set_child_packing
(GtkWidget child, GtkSideType side, GtkAnchorType anchor, GtkPackerOptions options, [int border_width = 0, [int pad_x = 0, [int pad_y = 0, [int i_pad_x = 0, [int i_pad_y = 0]]]]]);
void reorder_child
(GtkWidget child, int position);
Base class for widgets with two adjustable panes.
Methods
add1()
Adds child to first pane. add2()
Adds child to second pane. pack1()
Adds child to first pane, with options. pack2()
Adds child to second pane, with options. set_position()
Sets position of dividing handle. set_handle_size()
Sets handle size. *deprecated in GTK2* set_gutter_size()
Sets gutter size. *deprecated in GTK2* Properties
child1 : Child widget in first pane. child2 : Child widget in second pane. handle_size : Size of separating handle. *deprecated in GTK2* gutter_size : Size of separating gutter. *deprecated in GTK2* child1_resize : Status of first child's resize setting. child1_shrink : Status of first child's shrink setting. child2_resize : Status of second child's resize setting. child2_shrink : Status of second child's shrink setting.
GtkPaned provides methods and properties for container widgets with two panes whose relative size can be adjusted by the end user. The panes are arranged horizontally in GtkHPaned or vertically in GtkVPaned, and are divided by a handle. By default, the initial position of the handle is set in accordance with the size requests of the child widgets.
Note that the panes are defined through their child widgets, i.e. they have an initial size of zero.
GtkPaned is an abstract base class and cannot be constructed directly.
void add1
(
GtkWidget
child
);
add1() adds the child widget specified to the top or left pane of a GtkPaned-based widget.
The only difference between add1() and pack1() is that the packing parameters are not visible to the programmer where add1() is used, and so cannot easily be altered. The settings are identical to the pack1() defaults.
void add2
(
GtkWidget
child
);
add2() adds the child widget specified to the bottom or right pane of a GtkPaned-based widget.
The only difference between add2() and pack2() is that the packing parameters are not visible to the programmer where add2() is used, and so cannot easily be altered. The settings are identical to the pack2() defaults.
void pack1
(
GtkWidget
child
, [bool
resize = false
, [bool
shrink = true
]]);
pack1() packs the child widget specified into the top or left pane of a GtkPaned-based widget.
The resize parameter when set to its default false ensures that the pane will not expand beyond its initial size when the top-level window is maximised, in the direction of the pane arrangement. Note that the resize parameter describes the spatial relationship between the two panes, so that setting both panes alike will always result in both panes resizing when the top-level window is maximised. The user resizing facility offered by the handle is not affected by the resize setting.
The shrink parameter when set to its default true allows the pane to shrink beyond the size requested by its child widget. Setting the shrink parameter to false prevents it from doing this. Note that setting the parameter to false across both panes renders the dividing handle ineffective where the size of the top-level window is reliant upon the size requests of the child widgets.
void pack2
(
GtkWidget
child
, [bool
resize = true
, [bool
shrink = true
]]);
pack2() packs the child widget specified into the bottom or right pane of a GtkPaned-based widget.
The resize parameter when set to its default true allows the pane and its child widget to expand to fill the area between the dividing handle and the edge of the container when the toplevel window is maximised, in the direction of the pane arrangement. The position of the dividing handle can be set using set_position() , or by default is set at the size requested by the child belonging to the opposite pane, where its resize parameter has been set to false.
Note that the resize parameter describes the spatial relationship between the two panes, so that setting both panes alike will always result in both panes resizing when the top-level window is maximised. The user resizing facility offered by the handle is not affected by the resize setting.
The shrink parameter when set to its default true allows the pane to shrink beyond the size requested by its child widget. Setting the shrink parameter to false prevents it from doing this. Note that setting the parameter to false across both panes renders the dividing handle ineffective where the size of the top-level window is reliant upon the size requests of the child widgets.
set_position() sets the position of the dividing handle at the specified number of pixels from the edge of the widget, in the direction of the pane arrangement, without regard to the size requests of the child widgets in the panes. It is overridden by the user's repositioning of the dividing handle.
To unset the position of the dividing handle, use
set_handle_size() can currently be used to set the width or height of the handle in pixels. The default setting is 5 pixels in the win32 binary, or 10 pixels in the 1.2.* series of GTK+. In GTK2 the size of the handle will be set at 5 pixels, across both platforms.
Please note that both this function and the handle_size property are deprecated in GTK2, and so should not be used.
set_gutter_size() can currently be used to set the width or height in pixels of the gutter where the dividing handle is based, only where the 1.2.* series of GTK+ is being used to compile PHP-GTK. It does nothing in the win32 version.
Please note that this function is more than deprecated in GTK2; the gutter_size property does not exist in later releases. Do not use this function.
Type: Read Only
child1 is the internal name for the child widget in the first pane of a GtkPaned-derived widget.
Type: Read Only
child2 is the internal name for the child widget in the second pane of a GtkPaned-derived widget.
Type: Read Only
handle_size is an integer describing the width or height (as appropriate) of the separating handle in a GtkPaned-derived widget.
Please note that in future releases of GTK+ there is no such property. It will be replaced internally by private fields.
Type: Read Only
gutter_size is an integer describing the width or height (as appropriate) of the gutter which provides the base for the separating handle of a GtkPaned-derived widget.
Please note that in later releases of GTK+ - including that currently used by the PHP-GTK win32 binary - there is no such property. The gutter itself has been deprecated.
Type: Read Only
child1_resize describes the current status of the resize parameter relating to the child that is packed in the first pane. This is useful where the end user needs to be given control over the resize setting.
Type: Read Only
child1_shrink describes the current status of the shrink parameter relating to the child that is packed in the first pane. This is useful where the end user needs to be given control over the shrink setting.
Type: Read Only
child2_resize describes the current status of the resize parameter relating to the child that is packed in the second pane. This is useful where the end user needs to be given control over the resize setting.
Type: Read Only
child2_shrink describes the current status of the shrink parameter relating to the child that is packed in the second pane. This is useful where the end user needs to be given control over the shrink setting.
Widget displaying a graphical image or icon.
Methods
set()
set_build_insensitive()
Toplevel widget for embedding into other processes.
Constructor
—
GtkPlug
(int socket_id);Methods
construct()
GtkPlug
(int socket_id);
Widget to display RGB or grayscale data.
Constructor
—
GtkPreview
(GtkPreviewType type);Methods
size()
put()
draw_row()
set_expand()
GtkPreview
(GtkPreviewType type);
void put
(GdkWindow window, GdkGC gc, int srcx, int srcy, int destx, int desty, int width, int height);
Base class for GtkProgressBar.
Methods
set_show_text()
Toggles progress text display. set_text_alignment()
Sets progress text alignment. set_format_string()
Sets and formats progress text. set_adjustment()
Sets the progress adjustment object. configure()
Sets the progress value parameters. set_percentage()
Sets the current progress percentage. set_value()
Sets the current progress value. get_value()
Gets the current progress value. set_activity_mode()
Toggles progress mode. get_current_text()
Gets the current progress text. get_text_from_value()
Gets progress text based on value. get_current_percentage()
Gets current progress percentage. get_percentage_from_value()
Gets progress percentage based on value.
GtkProgress is a base class providing methods for widgets implementing progress bar functionality. The only built-in widget using GtkProgress is GtkProgressBar.
Note that GtkProgress is an abstract class and cannot be constructed directly.
The show_text parameter controls whether the progress text is shown. The default setting is false.
See also: set_format_string() .
The alignment of the text within the progress area can be modified using this method. The x_align and y_align parameters control the horizontal and vertical alignment of the text, respectively. Their range can be from 0.0 to 1.0 (meaning from one side of the progress area to another).
The default setting is (0.5, 0.5).
The content of the progress text can be modified with the format string. It can contain the following format characters:
The default text string is "%p%%".
See also: GtkAdjustment, where the progress value and bounds are set.
void set_adjustment
(
GtkAdjustment
adjustment
);
A progress has an associated GtkAdjustment object which specifies the bounds of the value having its progress displayed. This method associates the specified adjustment object with the progress.
This method provides a way to directly control the current value and the bounds of a GtkProgress.
See also: GtkAdjustment.
This method sets the current percentage for a GtkProgress. Its value must be between 0.0 and 1.0.
Use this method to update a GtkProgressBar that is in percentage mode.
The progress value can be set directly with this method. The value must be within the range of the underlying GtkAdjustment in order for the GtkProgressBar to display it.
Use this method to update a GtkProgressBar that is in activity mode.
Returns the current progress value.
GtkProgress can be either in percentage mode (when the total amount of work is known and progress can be calculated) or activity mode (when there is no way to estimate the total amount of work and only activity must be indicated somehow).
If activity_mode is true, the activity mode is turned on, otherwise - the percentage mode.
See also: set_value(), set_percentage() .
The text indicating the amount of progress can be retrieved with this method. Before the text is returned, it is formatted using the current progress format.
See also: set_format_string() ).
If you wish to retrieve formatted progress text based on some value other than current, then this method should be used. The current progress value will not be changed.
Returns the current progress percentage as a number between 0.0 and 1.0.
If you wish to retrieve the progress percentage based on some value other than the current one, then this method should be used. It returns the desired percentage as a number between 0.0 and 1.0.
Widget that provides a visual indication of an operation's progress.
Constructor
— Creates a progress bar widget.
GtkProgressBar
( GtkAdjustment adjustment );Methods
set_bar_style()
Sets the progress bar style in percentage mode. set_discrete_blocks()
Sets the number of discrete blocks. set_activity_step()
Sets the step value in activity mode. set_activity_blocks()
Sets the number of blocks in activity mode. set_orientation()
Sets the orientation of the bar. update()
Sets progress update value. *deprecated*
The purpose of GtkProgressBar is to show the user the progress of a long-running operation. It can be used in two modes: a percentage mode or an activity mode.
The percentage mode should be used when the application can in advance determine the total amount of work that will be done. As the operation progresses the application should update the bar widget with the amount of work completed so far. The widget will reflect this by displaying a growing percentage bar.
The activity mode is useful when the application cannot determine the total amount of work and instead simply wishes to provide an indication that an operation is in progress. In this mode, the widget will display a block moving back and forth in the progress area.
See also: GtkProgress, set_activity_mode() .
GtkProgressBar
(
GtkAdjustment
adjustment
);
When constructing a progress bar, you need to specify an associated GtkAdjustment which will be used to configure the progress bar's initial value and range.
Example 26. Setting up a Progress Bar
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); function update_bar() { global $progressbar, $value; $progressbar->set_percentage($value); start_update(); } function start_update() { global $value; if($value <= 1.0) { $value += 0.01; gtk::timeout_add(200, 'update_bar'); } else gtk::timeout_add(50, array('gtk', 'main_quit')); } $window = &new GtkWindow(); $window->set_uposition(200, 250); $window->set_policy(false, false, true); $window->connect_object('destroy', array('gtk', 'main_quit')); /* These adjustment settings are on the wild side for demo purposes */ $adjustment = &new GtkAdjustment(0.5, 100.0, 200.0, 0.0, 0.0, 0.0); $value = $adjustment->value; $progressbar = &new GtkProgressBar($adjustment); $progressbar->set_show_text(true); $progressbar->set_text_alignment(0.02, 1.0); $progressbar->set_format_string("%v%% complete"); $progressbar->set_usize(gdk::screen_width()/2, 30); $window->add($progressbar); $window->show_all(); start_update(); gtk::main(); |
$progressbar->set_activity_mode(true); |
$progressbar->set_percentage($value); |
$progressbar->set_value($value); |
Note that a progress bar in activity mode will not be redrawn when the values of the lower and upper bounds in the attached GtkAdjustment have been exceeded.
void set_bar_style
(
GtkProgressBarStyle
style
);
The default style of a progress bar upon creation is GTK_PROGRESS_CONTINUOUS. This method may be used to change it to the style specified in the style parameter (GTK_PROGRESS_CONTINUOUS or GTK_PROGRESS_DISCRETE) when the progress bar is in percentage mode.
Note that the progress bar will not display text if it is drawn in the discrete style.
See also: set_discrete_blocks() .
When the progress bar has discrete style, it is divided into a number of blocks. This method can be used to change the number of these blocks.
The default value is 10.
When the progress bar is in the activity mode, this method can be used to set the step value by which the progress bar will be updated on each iteration. Higher values make the progress indicator appear to move faster.
The default value is 3.
When the progress bar is in activity mode, this method can be used to set the number of blocks that make up the progress bar. Larger numbers make the progress indicator smaller.
The default value is 5.
void set_orientation
(
GtkProgressBarOrientation
orientation
);
This method can be used to change the orientation of the progress bar. The orientation parameter controls the direction in which the progress indicator grows (in percentage mode) or moves (in activity mode), as the operation progresses.
The default setting is GTK_PROGRESS_LEFT_TO_RIGHT.
This is a deprecated method that has had its usage replaced by set_percentage() when a progress bar is set to the percentage mode, or by set_value() when using the activity mode.
Button that is part of a group, only one of which may be selected.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkButton
áááááááááááááááááááááááá`-- GtkToggleButton
áááááááááááááááááááááááááááááá`-- GtkCheckButton
áááááááááááááááááááááááááááááááááááá`-- GtkRadioButton
Constructor
— Creates one of a group of GtkRadioButton widgets.
GtkRadioButton
( GtkRadioButton group , string label);
A GtkRadioButton is one of a group of similar widgets, only one of which may be selected at any one time.
In the version of GTK+ currently used by PHP-GTK there is an issue with the activate signal where it is used alongside toggle switches in arrays. In this particular widget, the clicked signal is the activating signal, and as a result of this feature repeats itself when another group member is activated.
One way around this is to use the pressed signal. Another would be to set up a count for each individual function and test that the count is not divisible by 2. Or, depending on the kind of function you are calling, you could simply allow clicked to be fired twice.
GtkRadioButton
(
GtkRadioButton
group
, string label);
The first GtkRadioButton in a group should have the first parameter set to null. This 'group leader' is not attached to anything; there is not at present such a thing as a GtkGroup widget of any kind.
All subsequent GtkRadioButton widgets belonging to the same group should have the variable representing that group leader as the first parameter.
Example 27. Constructing a group of radio buttons
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); function here_goes($button) { $child = $button->child; echo $child->get()."\n"; } $window = &new GtkWindow(); $window->connect_object('destroy', array('gtk', 'main_quit')); $window->set_title('GtkRadioButton demo'); $box = &new GtkVBox(); $window->add($box); $button1 = &new GtkRadioButton(null, 'button 1'); $button1->connect('pressed', 'here_goes'); $box->pack_start($button1); for ($i = 2; $i <= 4; $i++) { $button = &new GtkRadioButton($button1, 'button ' . $i); $button->connect('pressed', 'here_goes'); $box->pack_start($button); } $button_end = &new GtkButton('Exit'); $button_end->connect_object('clicked', array('gtk', 'main_quit')); $box->pack_end($button_end); $window->show_all(); gtk::main(); |
Menu item that is part of a group, only one of which may be selected.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkMenuItem
áááááááááááááááááááááááááááááá`-- GtkCheckMenuItem
áááááááááááááááááááááááááááááááááááá`-- GtkRadioMenuItem
Constructor
— Creates one of a group of GtkRadioMenuItem widgets.
GtkRadioMenuItem
( GtkRadioMenuItem group , string label);
A GtkRadioMenuItem is one of a group of similar widgets, only one of which may be selected at any one time.
When the GtkMenuItem version of the activate signal has been emitted by a GtkRadioMenuItem, there is a second emission as the most recently active item is toggled to inactive. This is dealt with before the original signal is handled.
One way around this would be to use the button-press-event signal. Another would be to set up a count for each individual function and test that the count is not divisible by 2. Or, depending on the kind of function you are calling, you could simply allow activate to be emitted twice.
GtkRadioMenuItem
(
GtkRadioMenuItem
group
, string label);
The first GtkRadioMenuItem in a group should have the first parameter set to null. This 'group leader' is not attached to anything; there is not at present such a thing as a GtkGroup widget of any kind.
All subsequent GtkRadioMenuItem widgets belonging to the same group should have the variable representing that group leader as the first parameter.
It is possible to mix different types of menu item within a GtkMenu.
In the following code snippet, Open is the group leader and Save and Print the other options belonging to the group. Note that Exit is not a part of that group, although it is part of the same menu.
$menu = &new GtkMenu(); $open = &new GtkRadioMenuItem(null, "Open"); $open->connect('button-press-event', 'open_routine'); $menu->append($open); $save = &new GtkRadioMenuItem($open, "Save"); $save->connect('button-press-event', 'save_routine'); $menu->append($save); $print = &new GtkRadioMenuItem($open, "Print"); $print->connect('button-press-event', 'print_routine'); $menu->append($print); $separator = &new GtkMenuItem(); $menu->append($separator); $exit = &new GtkRadioMenuItem(null, "Exit"); $exit->connect_object('button-press-event','exit_routine', $menu); $menu->append($exit); |
GtkAdjustment
get_adjustment
(void);
void set_update_policy
(
GtkUpdateType
policy
);
void set_adjustment
(
GtkAdjustment
adjustment
);
Base class for horizontal and vertical rulers.
void set_metric
(GtkMetricType metric);
Base class for GtkHScale and GtkVScale.
Methods
set_digits()
Sets number of decimal places. set_draw_value()
Toggles whether value is displayed. set_value_pos()
Sets position of numeric text. get_value_width()
Returns string width of numeric text.
A GtkScale is a widget that looks very like a GtkScrollbar without the arrow buttons at either end and with the ability to display the current value as text.
There are some issues with the value display, in that scrolling-aware container widgets will not allow their child's GtkAdjustment to be overwritten, which means that the GtkScale cannot have focus unless it takes the values given by the container to the scrollable widget. This in turn misconfigures the display area, which is calculated with regard to the upper value of the associated adjustment object. When a container sets an adjustment, each value is 0 at the start, and the later values are calculated on the fly after the widgets have been drawn.
Although it is possible to use the GtkWidget method queue_resize() to force the text area to resize according to the width of the new adjustment values, the widget does not fully redraw unless it has a configure event - that is, you need to manually resize it and then restore it.
For all these reasons, it is unadvisable to use the draw-value feature where the GtkScale is associated with a scrollable widget.
This method sets the number of places to the right of the decimal point in the displayed value.
The default number of decimal places is 1.
set_draw_value() simply toggles whether the value is displayed as text or not.
The default setting is true.
void set_value_pos
(
GtkPositionType
pos
);
This method determines the position of the text, when it is displayed. The default value is GTK_POS_TOP.
get_value_width() returns the width of the numeric text string in a GtkScale. The value is given in pixels.
Base class for GtkHScrollbar and GtkVScrollbar.
GtkScrollbar is a base class providing the object type that GtkHScrollbar and GtkVScrollbar are derived from.
This is an abstract class, and as such cannot be constructed directly.
Adds scrollbars to its child widget.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkScrolledWindow
Constructor
— Creates a scrolling window.
GtkScrolledWindow
([ GtkAdjustment hadjustment = NULL , [ GtkAdjustment vadjustment = NULL ]]);Methods
get_hadjustment()
Returns the horizontal adjustment object. get_vadjustment()
Returns the vertical adjustment object. set_policy()
Sets scrollbar visibility policies. set_placement()
Sets scrollbar positions. add_with_viewport()
Convenience method for adding non-scrolling widgets.
A GtkScrolledWindow is a window that can supply a scrollable child widget with scrollbars.
The scrollbars take their adjustment settings from the child widget and do not need adjustment configuration. Children that are not scrollable therefore need to be packed into a widget that has scrolling awareness. GtkViewport is one such widget, and can be added and configured automatically using the convenience method add_with_viewport() . The other widget that can be used for this purpose is GtkLayout, which allows multiple children to be given fixed positions and provides scrollbars.
The scrolling-aware widgets are: GtkCList, GtkCTree, GtkLayout, GtkScrolledWindow, GtkText and the catch-all GtkViewport.
Note that any scroll key bindings are taken from the child widget in the GtkScrolledWindow, and not from the scrollbars themselves.
GtkScrolledWindow
([
GtkAdjustment
hadjustment = NULL
, [
GtkAdjustment
vadjustment = NULL
]]);
The GtkScrolledWindow widget is derived from GtkBin, and is designed to only have one direct child. One way around this is to add the children to a parent container, make that parent the only child of the window, and bind the container's focus to align with the scrollbars. Alternatively, you could use GtkLayout, which has no such restriction.
You do not need to explicitly add a child widget to a GtkViewport if you are using the add_with_viewport() method. You may, however, find that the scrollbars are unresponsive anyway unless you add the child to a box container first.
Example 28. Setting up a GtkScrolledWindow
dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); /* set up a window */ $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); /* set up the main scrolled window and add it to the main window, sizing it if necessary. */ $scrolledwindow = &new GtkScrolledWindow(); $scrolledwindow->set_usize(300, 300); $scrolledwindow->set_policy(GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); $window->add($scrolledwindow); /* create a box container and add child widgets to it */ $box = &new GtkVBox(); $calendar = &new GtkCalendar(); /* let's add a scrollable to an internal scrolled window */ $scrolledwindow2 = &new GtkScrolledWindow(); $scrolledwindow2->set_usize(280, 100); $scrolledwindow2->set_policy(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); $text = &new GtkText(); $text->set_editable(true); $scrolledwindow2->add($text); $box->pack_start($calendar, false, false, 5); $box->pack_start($scrolledwindow2); /* add the box container to the main scrolled window and link its focus so that the cursor position is reflected in the scrollbar's adjustment value. You do not need to do this when adding a scrollable widget directly */ $scrolledwindow->add_with_viewport($box); $box->set_focus_vadjustment($scrolledwindow->get_vadjustment()); $scrolledwindow2->show_all(); $box->show_all(); $window->show_all(); gtk::main(); |
GtkAdjustment
get_hadjustment
(void);
get_hadjustment() returns the GtkAdjustment object that is used in the horizontal scrollbar. The most likely use for this is in combination with set_focus_hadjustment() , where it is needed as a parameter.
GtkAdjustment
get_vadjustment
(void);
get_vadjustment() returns the GtkAdjustment object that is used in the vertical scrollbar. The most likely use for this is in combination with set_focus_vadjustment() , where it is needed as a parameter.
void set_policy
(
GtkPolicyType
hscrollbar_policy
,
GtkPolicyType
vscrollbar_policy
);
Sets the visibility policy for the scrollbars in a GtkScrolledWindow to one of three possible GtkPolicyType values.
The default setting is GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS, which displays both scrollbars regardless of the relative size of the child widget.
void set_placement
(
GtkCornerType
window_placement
);
This method sets the positions of the scrollbars in a GtkScrolledWindow to one of four possible GtkCornerType values.
These values are a little counter-intuitive because they describe the position of the child, rather than the position of the scrollbars themselves.
The default setting is GTK_CORNER_TOP_LEFT, which causes the child to be placed above and to the left of the scrollbars - i.e., the scrollbars are at the bottom and to the right of the child.
void add_with_viewport
(
GtkWidget
child
);
add_with_viewport() is a convenience function that invisibly adds the child widget to a GtkViewport before adding the viewport to the GtkScrolledWindow.
The GtkViewport is a scrolling-aware container that provides its child widget with that characteristic.
Methods
set()
Properties
selection : target : type : format : length : data :
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Base class for GtkHSeparator and GtkVSeparator.
GtkSeparator is a base class providing the underlying widget type for GtkHSeparator and GtkVSeparator.
Note that this is an abstract class, and cannot be constructed directly.
Container for widgets from other processes.
Constructor
—
GtkSocket
(void);Methods
steal()
GtkSocket
(void);
Widget offering masked numerical entry and/or selection.
GtkObject
`-- GtkWidget
áááááá`-- GtkEditable
áááááááááááá`-- GtkEntry
áááááááááááááááááá`-- GtkSpinButton
Constructor
— Creates an editable rotating display of selectable numbers.
GtkSpinButton
([ GtkAdjustment adjustment = NULL , [double climb_rate = 0.0 , [int digits = 0 ]]]);Methods
configure()
Configures all elements of a spinbutton. set_adjustment()
Sets adjustment object. get_adjustment()
Retrieves adjustment object. set_digits()
Sets number of decimal places displayed. get_value_as_float()
Retrieves value as float. get_value_as_int()
Retrieves value as integer. set_value()
Sets value displayed in spinbutton entry field. set_update_policy()
Controls update policy. set_numeric()
Toggles the way non-numeric input is treated in display. spin()
Forces a spin. set_wrap()
Toggles whether the display wraps. set_shadow_type()
Controls appearance of spinbutton. set_snap_to_ticks()
Toggles whether input is aligned with increment. update()
Updates value according to settings.
A GtkSpinButton is a widget offering a displayed numerical value which can be incremented or decremented within a pre-set range by the user's clicking on one of two arrow buttons, or by using the Up and Down arrow keys.
The display area is a GtkEntry; the spinbutton object currently provides the only built-in means of masking input in GTK+. If you want to restrict the user to the values displayed rather than allowing keyboard input, call set_editable() from the spinbutton.
See also: GtkAdjustment, GtkCombo.
GtkSpinButton
([
GtkAdjustment
adjustment = NULL
, [double
climb_rate = 0.0
, [int
digits = 0
]]]);
Although the first parameter adjustment is optional, you will find it impossible to create a working GtkSpinButton without harnessing it to an appropriately defined GtkAdjustment, as the first five parameters of the adjustment need to be set for the spinbutton widget to operate. You may either associate the adjustment at this point, or use the set_adjustment() or configure() method at a later point in your script.
climb_rate refers to the speed of the spin, rather than its incremental value. Its default setting is 0.0, which runs the internal timer at 20ms per increment (following a 200ms start from the button press). If you intend using this parameter, the value given needs to be fairly high in order for it to make an appreciable difference.
The digits parameter controls the number of decimal places displayed.
Example 29. Creating a GtkSpinButton calendar.
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); function collect($d, $m, $y) { echo $d->get_value_as_int(). "-" .$m->get_value_as_int(). "-" .$y->get_value_as_int()."\n"; flush(); } $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); $vbox = &new GtkVBox(false, 5); $window->add($vbox); $hbox = &new GtkHBox(false, 5); $hbox->set_border_width(5); $vbox->add($hbox); $daylabel = &new GtkLabel("Day:"); $hbox->pack_start($daylabel, false); $day = date("d"); $dayadj = &new GtkAdjustment($day, 1.0, 31.0, 1.0, 7.0, 0.0); $dayspin = &new GtkSpinButton($dayadj); $dayspin->set_wrap(true); $hbox->pack_start($dayspin, false); $monthlabel = &new GtkLabel("Month:"); $hbox->pack_start($monthlabel, false); $month = date("m"); $monthadj = &new GtkAdjustment($month, 1.0, 12.0, 1.0, 3.0, 0.0); $monthspin = &new GtkSpinButton($monthadj); $monthspin->set_wrap(true); $hbox->pack_start($monthspin, false); $yearlabel = &new GtkLabel("Year:"); $hbox->pack_start($yearlabel, false); $year = date("Y"); $yearadj = &new GtkAdjustment($year, $year-90, $year+10, 1.0, 5.0, 0.0); $yearspin = &new GtkSpinButton($yearadj); $yearspin->set_usize(55, 0); $hbox->pack_start($yearspin, false); $button = &new GtkButton("Collect data"); $button->connect_object('clicked', 'collect', $dayspin, $monthspin, $yearspin); $vbox->add($button); $vbox->show_all(); $hbox->show_all(); $window->show_all(); gtk::main(); |
void configure
(
GtkAdjustment
adjustment
, double climb_rate, int digits);
This method sets the GtkAdjustment and configures the rate of the spin and number of decimal points displayed in an existing spinbutton.
Configuration settings made in this way will overwrite any existing settings on the calling GtkSpinButton.
void set_adjustment
(
GtkAdjustment
adjustment
);
Call set_adjustment() when you only need to attach an adjustment object to a spinbutton. Otherwise, use configure() .
An adjustment associated with a spinbutton in this way will overwrite any exisiting adjustment object.
GtkAdjustment
get_adjustment
(void);
get_adjustment() returns the GtkAdjustment object currently associated with the calling spinbutton.
set_digits() sets the number of digits displayed after the decimal point in the spinbutton's entry field. User input is limited to the constraints of the displayed decimal places.
Retrieves the current value displayed in the spinbutton entry as a float value. Use this in combination with the PHP function round() where you need to collect the value to a specific number of decimal places.
$adj = &new GtkAdjustment(0.0, 0.0, 1.0, 0.01, 0.1, 0.0); $spin = &new GtkSpinButton($adj, 0.0, 2); round($spin->get_value_as_float(), 2); |
Retrieves the current value displayed in the spinbutton entry as an integer. If the value is a fraction, this method rounds it to the nearest whole number.
set_value() sets the value displayed in the spinbutton's entry field, which is equivalent to the value field in the spinbutton's associated GtkAdjustment.
If the lower or upper bounds set in the adjustment are exceeded, the value of the appropriate bound will replace the value passed as the parameter in this method.
void set_update_policy
(
GtkSpinButtonUpdatePolicy
policy
);
There are only two possible settings for the spinbutton update policy. Setting it as GTK_UPDATE_IF_VALID prevents the current value from being changed where the newly entered value is outside the range determined by the underlying GtkAdjustment.
The default setting is GTK_UPDATE_ALWAYS, which allows the update to continue by replacing an invalid value with the value of the nearest range boundary.
Note that set_value() . overrides the update policy setting.
set_numeric() , when set to true, prevents non-numeric characters other than the decimal point and positive/negative signs from being displayed in the spinbutton's GtkEntry at the point of being keyed in.
Note that inappropriate characters will not be accepted by the underlying GtkAdjustment in any case; this is purely a masking function at display level.
void spin
(
GtkSpinType
direction
, double increment);
This method resets the displayed value to a new value that is determined by the GtkSpinType chosen. It is used internally to set up the functions associated with mouse button presses over the spinbutton's arrows. These are, a left click spins one step increment, a middle button click spins one page increment, and a right click spins to the lower or upper bound depending on which arrow is pressed.
Where set_wrap() is set to true, the spinbutton having displayed the upper bound of its value range will return to the lower bound on the next step increment. In other words, if the range is 1 to 10, 1 will follow 10 in the display area when the up arrow is pressed.
The default setting is false, which greys out the appropriate arrow when the lower or upper bound of the range is reached.
void set_shadow_type
(
GtkShadowType
shadow_type
);
Sets the shadow style of the frame around the arrow buttons on a spinbutton using the GtkShadowType options.
The default setting is GTK_SHADOW_NONE.
set_snap_to_ticks() , if set to true, will restrict input values to the order of the step increment, taking the nearest value to the increment as the input value. For example, if you have set the step increment to 0.5 in a range of 0.0 to 2.5 and the user inputs 1.4, the input will be reset to 1.5 - the nearest incremental value.
The default setting is false, which allows the user to key in anything within range to the given number of decimal points.
See also: set_digits() .
The update() method is used internally to update the value field in the underlying GtkAdjustment according to the update policy, digits and snap settings.
Widget that provides a way to report messages of minor importance.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkHBox
áááááááááááááááááááááááá`-- GtkStatusbar
Constructor
— Creates a status bar.
GtkStatusbar
(void);Methods
get_context_id()
Returns the context id from the description. push()
Adds message to top of stack. pop()
Removes message from top of stack. remove()
Removes designated message from stack. Signals
text-pushed: Emitted when a message is prepended to the stack. text-popped: Emitted when a message is popped from the top of the stack.
A GtkStatusbar is a framed label, usually added to the bottom of a window, that provides a way to report messages of minor importance. It is usually updated fairly frequently.
There are two indices in the structure of a statusbar; one is an associative array of message information, and the other is a stack of uniquely-indexed message arrays. The message at the top of the stack is the one currently on display.
GtkStatusbar
(void);
Creating a status bar is very straightforward; creating and updating messages marginally less so.
Example 30. Setting up a status bar.
dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); /* function to clear the entry field and give it keyboard focus */ function focusback($entry) { $entry->set_text(''); $entry->grab_focus(); } /* on this occasion, the update function *is* the process */ function change_status($entry, $event, $status, $stuff, &$i) { /* pick up the value(s) you are intending to use */ $value = $event->keyval; $string = $event->string; /* prevent the message stack building up */ $popcontext = $status->get_context_id($stuff[$i]); $status->pop($popcontext); /* sort according to value */ switch($value) { case ($value >= GDK_KEY__a && $value <= GDK_KEY__z): $i = 1; break; case ($value >= GDK_KEY_A && $value <= GDK_KEY_Z): $i = 2; break; case ($value >= GDK_KEY_0 && $value <= GDK_KEY_9): $i = 3; break; case GDK_KEY_Return: $i = 4; break; case GDK_KEY_space: $i = 5; break; default: $i = 6; } /* create and push the new message according to the value */ $pushcontext = $status->get_context_id($stuff[$i]); if($string && $string!==' ') $status->push($pushcontext, $string.' is a '.$stuff[$i].' character'); else $status->push($pushcontext, $stuff[$i]); /* call any other function the value triggers */ if($i == 4) focusback($entry); } /* set up the main window */ $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); /* if you want anything else besides the statusbar, you'll need a box */ $vbox = &new GtkVBox(); $window->add($vbox); /* add the statusbar first, else connecting other widgets to it is messy */ $status = &new GtkStatusbar(); $stuff = array('Here we go...', 'lower case alpha', 'UPPER CASE ALPHA', 'numeric', 'return', 'spacebar', 'non-alphanumeric'); $status->push($status->get_context_id($stuff[0]), $stuff[0]); $vbox->pack_end($status, false); $status->show(); /* create, connect and pack your other widget(s) */ $entry = &new GtkEntry(); $entry->set_usize(400,20); /* this will usually be connect_object(). $entry is only passed here because it is used as a parameter in a function called from the callback. &$i is passed so that the correct message will get 'popped' from the stack */ $i = 1; $entry->connect('key-press-event','change_status', $status, $stuff, &$i); $vbox->pack_start($entry, false); $entry->show(); $window->show_all(); focusback($entry); gtk::main(); |
The GtkStatusbar sets up an internal array of the messages that have been used, as they are being called. The context_id is the array index position that a given message holds.
As the message array is created on the fly, it is never the same twice running. The messages that are displayed most frequently during the status bar's lifetime will have low numbers, and a message that is never called will not be added to the array. It is far more efficient to use get_context_id() to generate a context id for a message than it is to allocate your own integer value.
The context_description is actually the text string used in the statusbar label.
push() prepends the given message to an internal stack in the statusbar, along with its associated context_id. It is best to allow the statusbar to generate the context_id for itself, as the value can then change from one run to another to respond to the user's pattern of interaction with the application. Use get_context_id() to do this.
The returned value is a unique message_id, which is needed as a parameter in the remove() method. This is simply an incremented value, beginning at 1.
This method causes the text-pushed signal to be emitted.
pop() removes the message that is currently at the top of the statusbar's stack, using the context_id to identify the message.
When a message is removed from the stack, the memory that was allocated to it is freed. Given that all messages are generated uniquely, it is good practice to pop() the current message before appending the next. Allowing the stack to build up can add considerably to processing time.
This method causes the text-popped signal to be emitted.
This method removes a targeted message from anywhere in the stack.
Both the context_id and the message_id can be generated by the statusbar comfortably here as elsewhere in the GtkStatusbar methods.
If you use this simply to replace a working pop() function you should see no difference in behaviour; the remove() method even causes the text-popped signal to be emitted when it removes a message from the top of the stack. Note that no signal is emitted when messages are taken from elsewhere in the stack.
As there is no way to add a message anywhere other than the top of the statusbar's stack - thereby immediately displaying it - this method is basically a way of preventing a stack build-up where the pop/push procedure has proved inappropriate.
This signal is fired by a GtkStatusbar when the push() method is called. It carries with it the context_id and the text content of the message.
Callback function:
void callback
(GtkStatusbar statusbar, int context_id, string text);
This signal is fired by a GtkStatusbar when the pop() method is called, and also when when the topmost message in the stack is removed using the remove() method . The signal carries with it the context_id and the text content of the message.
Callback function:
void callback
(GtkStatusbar statusbar, int context_id, string text);
A class that determines the appearance of widgets.
Constructor
— Creates a new style for a widget.
GtkStyle
(void);Methods
copy()
Copies an existing style. Properties
black : The color being used as black. white : The color being used as white. font : The font. black_gc : white_gc : colormap : The colormap currently being used. fg : Foreground. bg : Background. light : dark : mid : Midway between light and dark. text : Text in a text widget. base : Text background. fg_gc : bg_gc : light_gc : dark_gc : mid_gc : text_gc : base_gc : bg_pixmap : Background pixmap.
GtkStyle is a structure that is used to define the colors displayed in any widget, or across an application. Being a GtkWidget property, it is accessible through all objects that take up screen space, using the syntax:
It is also possible to create a new GtkStyle object in the normal way, e.g. or to take the default application style: in order to change the style across an application.Setting a style across an application can also be achieved by using rc files. There are two in the PHP-GTK test directory which are used in gtk.php.
The style functions are generally not buggy, the only known exception being where the text and base properties are intended to describe text and its normally-white background. In some cases this has not worked, and you may find that you need to use fg to color the text.
Note
In all cases where the property type is given as array, what is being referred to is an array consisting of the five GtkStateType states.
GtkStyle
(void);
There are several ways to define the style across an application, but only two ways to directly set the style on a given widget.
Example 31. Writing to a widget's style property.
dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); /* set up a few buttons just to prove we're only changing one of them */ $bbox = &new GtkVButtonBox(); $window->add($bbox); for($i = 0; $i < 8; $i++) { $button[$i] = &new GtkButton("This is Button $i"); $bbox->pack_start($button[$i], false); $button[$i]->show(); } /* method 1 : set up a new style and define the parts you want to define. The remaining style elements retain the application's default settings. */ $newstyle = &new GtkStyle(); $cyan = &new GdkColor('#00FFFF'); $newstyle->fg[GTK_STATE_PRELIGHT] = $cyan; $label = $button[5]->child; $label->set_style($newstyle); /* gdk::color_parse() uses a color that is defined on your system to fill a GdkColor structure. It can be more convenient than manually creating a new GdkColor, particularly if you're only assigning the color once. */ $newstyle->bg[GTK_STATE_NORMAL] = gdk::color_parse('ivory'); $button[5]->set_style($newstyle); /* method 2 : copy the existing style from a widget and alter it. Defining a new style would overwrite the existing non-default style settings. */ $style2 = $label->style; $newstyle2 = $style2->copy(); $font = gdk::font_load('-unknown-Arial-bold-r-normal--*-160-*-*-p-0-iso8859-1'); $newstyle2->font = $font; $label->set_style($newstyle2); $window->show_all(); gtk::main(); |
copy() takes an existing style and copies it wholesale, including any prior modifications that have been made to it.
Type: Read Write
Type: Read Write
Type: Read Write
The current font.
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Container that provides a flexible grid for packing its children.
Constructor
— Creates a container whose children are arranged on a grid.
GtkTable
([int rows = 1 , [int columns = 1 , [bool homogeneous = FALSE ]]]);Methods
resize()
Resizes to accommodate changes. attach()
Means of arranging child widgets in a GtkTable. attach_defaults()
Packing defaults. set_row_spacing()
Determines the space below a given row. set_col_spacing()
Determines the space to the right of a given column. set_row_spacings()
Determines the spacing between all rows. set_col_spacings()
Determines the spacing between all columns. set_homogeneous()
Sets all child allocations to size of largest request. Properties
children : Array of GtkTableChild elements. nrows : Number of rows. ncols : Number of columns. column_spacing : Spacing between columns. row_spacing : Spacing between rows. homogeneous : Determines whether child sizing is homogeneous.
A GtkTable is a very adaptable container widget that is capable of having the layout of its children structured in both directions. There is a more simplistic version of a similar container in GtkFixed, but GtkTable offers the advantage that the child positions can be relative rather than absolute. The table's stucturing is similar to that of a GtkBox.
As with the box classes, there is an underlying single-child structure containing packing information, which consitutes one element of the array of child data in a GtkTable. This element is known as a GtkTableChild, and can be accessed through the children property inherited from GtkContainer. The child objects themselves can also be accessed more directly through the children() method inherited from the same ancestor.
GtkTable
([int
rows = 1
, [int
columns = 1
, [bool
homogeneous = FALSE
]]]);
It is not necessary to give the dimensions of a non-homogeneous GtkTable in the constructor, as the table will pick up the layout from the information given as its children are attached to it, and this will override the initial integer settings. If homogeneous is set to true the reverse will be the case, and the table's settings take precedence.
You will find that you need to use the attach() method throughout, as the way in which the add() method generally used in containers is implemented in GTK+ to always position an added child at 0, 1, 0, 1. Once a grid square has been filled, the widget taking up that space cannot be overwritten by another widget. The remove() method is fully operational.
The child widget sizing in a non-homogeneous GtkTable is relative, and will alter if one or more children is removed or resized. Again, this is not true for the child widgets in a homogeneous table.
There are a lot of parameters in the attach() method - nine in total - four of which are optional. Basically, if the homogeneous parameter in the constructor is set to true, there is very little point most of the time in using any of the four optional packing parameters. These come into their own when the children are not required to take up the same amount of space.
Example 32. Packing a GtkTable with differently-sized child widgets
dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" : "so")); $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object("destroy", array("gtk", "main_quit")); $table = &new GtkTable(); $table->set_row_spacings(5); $table->set_col_spacings(5); $window->add($table); $text = &new GtkText(); $table->attach($text, 1, 4, 1, 3); $label = &new GtkLabel('Expand this window to see the difference between the GtkAttachOptions settings.'); $table->attach($label, 1, 4, 4, 5, GTK_SHRINK, GTK_SHRINK); $button = &new GtkButton('Button '); $table->attach($button, 4, 6, 3, 4, GTK_SHRINK, GTK_SHRINK, 3, 3); $button = &new GtkButton('Button 2 '); $table->attach($button, 4, 6, 4, 5, GTK_FILL, GTK_FILL, 3, 3); $button = &new GtkButton('Button 3 '); $table->attach($button, 4, 6, 5, 6, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 3, 3); $window->show_all(); gtk::main(); |
This method is used internally to resize the table and rearrange the child widgets accordingly following a new child's attachment to a non-homogeneous table, or a change in the size of the largest child in a homogeneous table.
It can be used to redraw a homogeneous table with a new number of rows and columns, all of which will have the same size as existing rows and columns. It has no external use in a non-homogeneous table.
void attach
(
GtkWidget
child
, int left_attach, int right_attach, int top_attach, int bottom_attach, [
GtkAttachOptions
xoptions = GTK_EXPAND|GTK_FILL
, [
GtkAttachOptions
yoptions = GTK_EXPAND|GTK_FILL
, [int
xpadding = 0
, [int
ypadding = 0
]]]]);
attach() is the method used to pack child widgets in a GtkTable. Of the nine parameters delineated, five are absolutely needed.
The first parameter refers to the child widget that is to be attached.
The following pair of parameters denote the starting point that the child will be drawn from, at the left hand side, and the end point that the child will be drawn to, to the right. These parameters are given in terms of columns, with the start point being 0.
The pair after this denote the starting point that the child will be drawn from, at the top, and the end point that the child will be drawn to, at the bottom. These parameters are given in terms of rows, with the start point again being 0.
As with all container widgets, the container itself takes up no screen space until it contains a child widget or child widgets. If you attach only one child with parameters that should set it in the bottom right corner and set homogeneous to false, the resulting effect will not be that of a table with only one entry in the bottom right corner, but of a container with a single widget in it - regardless of the number of columns and rows specified in the table's constructor. Child settings always take precedence in a non-homogeneous table, and so all table attachments are relative to the other child widgets. This is in line with the behaviour of other multiple-child capable containers where the child widget can have its own packing parameters set.
The behaviour is very different when a regular grid is in position, which happens when the GtkTable has its homogeneous parameter set to true. The table can work out the dimensions of the grid from the the largest child widget's size request, and positions its children accordingly.
The final four optional parameters determine the way in which the child widget will respond to the area available to it (expand, shrink, fill) in each direction, and the padding between the child and its nearest border, in each direction.
void attach_defaults
(
GtkWidget
widget
, int left_attach, int right_attach, int top_attach, int bottom_attach);
The extra four parameters in attach() are all optional in PHP-GTK, rendering this method unnecessary.
Use this method to set the spacing below a given row, in pixels. Note that it only works when the row below the given row is populated and contains a child's upper edge.
The row count begins at 0.
Use this method to set the spacing to the right of a given column, in pixels. Note that it only works when the column to the right of the given column is populated and contains a child's leftmost edge.
The column count begins at 0.
Use this method to set the spacing between all rows, in pixels.
The default setting is 0.
Use this method to set the spacing between all columns, in pixels.
The default setting is 0.
set_homogeneous() when set to true makes all child widgets' allocated areas the same size as that of the child requesting the most space.
In most cases, this would be better set at the point of construction.
Type: Read Only
The children property consists of an array of GtkTableChild elements. If you need to access a widget, e.g. to change the text in a label, use the GtkContainer method children() , which separates the widget element out of this property.
Type: Read Only
The nrows property consists of the number of rows currently contained in a GtkTable.
Type: Read Only
The ncols property consists of the number of columns currently contained in a GtkTable.
Type: Read Only
column_spacing returns the column spacing that has been set for the entire table using set_col_spacings() , or 0 if none has been set.
Type: Read Only
row_spacing returns the row spacing that has been set for the entire table using set_row_spacings() , or 0 if none has been set.
Type: Read Only
homogeneous when queried returns 1 (true) if the table is homogeneous, or 0 (false) if it is not.
Helper class for GtkTable.
Properties
widget : The child widget. left_attach : Leftmost anchor. right_attach : Rightmost anchor. top_attach : Upper anchor. bottom_attach : Base anchor. xpadding : Padding to left and right. ypadding : Padding to top and bottom. xexpand : Child expansion left to right. yexpand : Child expansion top to bottom. xshrink : Child shrink left to right. yshrink : Child shrink top to bottom. xfill : Child fill left to right. yfill : Child fill top to bottom.
A GtkTableChild is an array of information about a GtkTable's child, which is itself stacked in the array that makes up the table's children property.
Accessing these properties is therefore a two-tiered process:
$children = $table->children; /*returns an array of GtkTableChild elements*/ for($i = 0; $i < count($children); $i++) { $child = $children[$i]; /*returns the individual GtkTableChild element from the $children array's current pointer position*/ $widget = $child->widget; /*returns the widget property of the GtkTableChild*/ echo $widget->get_name()."\n"; }
Type: Read Only
The widget property returns the child widget.
Type: Read Only
The left_attach property returns the number of the column that the child widget is attached to on the leftmost side. The column count begins at 0.
Type: Read Only
The right_attach property returns the number of the column that the child widget is attached to on the rightmost side. The column count begins at 0.
Type: Read Only
The top_attach property returns the number of the row that the child widget is attached to on the upper side. The row count begins at 0.
Type: Read Only
The bottom_attach property returns the number of the row that the child widget is attached to at the base. The row count begins at 0.
Type: Read Only
The xpadding property returns the integer value in pixels of the padding between the widget and the left and right edges of its allocated area.
Type: Read Only
The ypadding property returns the integer value in pixels of the padding between the widget and the top and bottom edges of its allocated area.
Type: Read Only
Returns true if the GTK_EXPAND flag is set on the x axis.
Type: Read Only
Returns true if the GTK_EXPAND flag is set on the y axis.
Type: Read Only
Returns true if the GTK_SHRINK flag is set on the x axis.
Type: Read Only
Returns true if the GTK_SHRINK flag is set on the y axis.
Type: Read Only
Returns true if the GTK_FILL flag is set on the x axis.
Type: Read Only
Returns true if the GTK_FILL flag is set on the y axis.
Menu item used to tear off and reattach its menu.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkMenuItem
áááááááááááááááááááááááááááááá`-- GtkTearoffMenuItem
Constructor
— Creates the means to tear off a menu.
GtkTearoffMenuItem
(void);
A GtkTearoffMenuItem is a dedicated type of GtkMenuItem that can be prepended to a menu in order to give the user the option of tearing off the popped-up menu from its parent object (usually a menu item in a GtkMenuBar), and keeping it within an independant, non-resizeable GtkWindow of its own.
The widget appears as a dotted line across the top of the menu when the menu is attached to a parent object, or as a dotted line with a left-pointing arrow where the menu is detached. Clicking on the dotted line detaches an attached menu, and clicking on the arrow of a detached menu re-attaches it to the parent.
GtkTearoffMenuItem
(void);
A GtkTearoffMenuItem will only work for a full menu, not for part of one. It therefore needs to be prepended so that it takes the 0 position in the GtkMenu where it is used:
Editable text-display widget.
Constructor
— Creates a scrollable text widget.
GtkText
([ GtkAdjustment hadj = NULL , [ GtkAdjustment vadj = NULL ]]);Methods
set_editable()
Toggles whether text widget is editable. set_word_wrap()
Toggles whether words at the end of a line can be broken. set_line_wrap()
Toggles whether text should be wrapped at the widget boundary. set_adjustments()
Specifies the GtkAdjustments to be used. set_point()
Sets insertion point. get_point()
Returns the current insertion point. get_length()
Returns length of string. freeze()
Freezes display. thaw()
Thaws display. insert()
Inserts a string of text. backward_delete()
Deletes characters prior to insertion point. forward_delete()
Deletes characters ahead of insertion point. Properties
hadj : Horizontal adjustment. *broken* vadj : Vertical adjustment.
GtkText provides a scrolling widget with a white background which can have text strings passed to it programmatically or directly from the keyboard (if it is set to be editable). There are a number of keybindings for the editing features; these are listed under GtkEditable, as they are generally shared by the GtkEntry widget.
GtkText is one of two widgets marked as BROKEN throughout the 1.3 series of GTK+ releases, and is being replaced entirely by a new set of text and editing widgets in GTK 2.0. If you can avoid using it, do so. If you can't, be aware that it has issues which are never going to be fixed.
One of these issues is that the horizontal GtkAdjustment does not work in the GtkText widget, and that trying to declare it as anything other than NULL causes the application to stall. There is no problem with the vertical adjustment, and a vertical scrollbar associated with the text widget will work just fine.
Another feature is that it cannot cope with very frequent text updates for long, that being when you're most likely to generate a string that is too big for its XWindow to handle. You may find it better to use a GtkCList if you are using it to display the output for any form of network monitoring, for example.
There is also a problem with the linewrap when the GtkText widget is utilised under Windows, causing it to display 'little black boxes' at every soft wrap. You can get around this by using PHP's wordwrap() function to create a line-end within the GTK line-end, but bear in mind that PHP uses a given number of characters to determine the length of the line, whereas GTK uses pixels to configure the relationship between the font size, the line-end, and the container's border.
See also: GtkEditable, GdkFont, GtkFontSelectionDialog.
A final note: the signal set_scroll_adjustments has not been covered here as it is purely used internally to allow the text widget to communicate with scrolling-aware container widgets.
GtkText
([
GtkAdjustment
hadj = NULL
, [
GtkAdjustment
vadj = NULL
]]);
Creates a text widget that is by default scrollable up and down using the bound keys given below, when there is enough text present. The horizontal adjustment, and therefore the horizontal scrolling, do not work; the horizontal adjustment parameter in the constructor should always be declared as null (the default setting) for that reason.
Table 4. Key bindings for scrolling GtkText
Key combination | Scroll function |
---|---|
Control + Home | Move to the top of the text |
Control + End | Move to the end of the text |
Page Up | Move up one page increment |
Page Down | Move down one page increment |
Up arrow | Move up one line |
Down arrow | Move down one line |
Example 33. Adding a scrollbar to a GtkText widget
dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); $box = &new GtkHBox(); $window->add($box); $text = &new GtkText(); $text->set_word_wrap(true); $string = "This is a string of text which will be displayed in the GtkText widget.\n\nIt isn't long enough to allow scrolling, so you will probably need to extend it.\n\nOn the other hand, the box isn't sized, so it may just creep over that limit and be a useful demonstration after all."; if(strstr(PHP_OS, 'WIN')) $string = wordwrap($string, 26); $text->insert_text($string, 0); $box->pack_start($text); $adj = $text->vadj; $scrollbar = &new GtkVScrollbar($adj); $box->pack_end($scrollbar, false); $window->show_all(); gtk::main(); |
set_editable() , when set to true, allows the user to write to or manipulate existing text displayed in the widget.
The default setting is false.
This method, when set to true, ensures that words that would otherwise be broken when reaching a line end are kept in one piece and moved to the beginning of the next line.
If you are using the PHP wordwrap() function, you will need to use it in tandem with the GTK set_word_wrap() method.
The default setting is false.
set_line_wrap() , when set to true ensures that the text is sensitive to the boundaries of the GtkText widget and will wrap within them.
The default setting is true.
See also: set_word_wrap() .
void set_adjustments
(
GtkAdjustment
hadj
,
GtkAdjustment
vadj
);
In most cases, set_adjustments() is a redundant method, as it is already used internally by scrolling-aware containers to create appropriate adjustment settings for the size of the text widget. This pre-setting by a container cannot be overridden.
Where you need to use this method, the first parameter must always be null due to the malfunctioning hadj property in a GtkText widget.
set_point() sets the point in the string index where any extraneous text should be inserted. This means that the initial string has to exist in the first place.
If the text widget has focus at the time when this method is called, the insertion point will be reflected in the position of the cursor.
Note that an insertion point beyond the length of the existing string (that is, the entire existing GtkText content) cannot be set in this way.
This method returns the current insertion point, which is the position taken by the cursor. By default, that will be the position following the final character in the string that makes up the entire existing GtkText content.
This method returns the length of the string making up the current text widget contents, measured in characters.
If you need to measure separate elements of the text contents, use the PHP function strlen() instead.
Call the freeze() method prior to any text update. This prevents the display from flickering during the time it takes for the update to be made, as the full update is only drawn once rather than for every new character.
See also: thaw() .
The thaw() method is the corollary to the freeze() method, and should be used in conjunction with it. Call this method following an update to redraw the display.
This is a complex method offering more control over the appearance of the text in a GtkText widget than the alternative insert_text() inherited from GtkEditable. It also has the bonus that it allows some support for internationalization on all platforms, although multibyte conversion under win32 is not currently included in this.
Any of the first three parameters can be passed as null, making it possible to define only one aspect of the text's appearance, or many.
The first parameter font is a GdkFont. If you are intending to change fonts, you will need to call the static function gdk::font_load() beforehand in order to define your chosen font.
The next two parameters use GdkColor objects to describe the foreground and background colors of the text; again, you will need to define these in order to use them. The first of these is the color of the text itself, the second is the color of the 'page' behind it. Note that setting the back will only change the color for the area that is taken up by the string itself, and not for the entire widget or to the widget's border when the end of the text is reached.
The final two parameters are chars, the string of text to insert; and the optional length, which can be used to limit the extent of the string where it is being input by a user. The default length -1 will allow the entire string.
You can use the current default style with:
Deletes the number of characters stipulated, back from the current insertion point.
Note that these are literal numbers, and that shortcuts such as 0 and -1 cannot be used here.
Deletes the number of characters stipulated, forward from the current insertion point.
Note that these are literal numbers, and that shortcuts such as 0 and -1 cannot be used here.
Type: Read Only
The hadj property is a GtkAdjustment that simply does not work in the GtkText widget. It should always be declared as null at the creation stage, and will always have adjustment settings of 0 throughout for that reason.
Type: Read Only
The vadj property is a GtkAdjustment widget. Use this property to interrogate the adjustment settings that have been pre-set by the GtkText widget's parent container.
It can also be used to set the adjustment value for an associated GtkScrollbar.
Displays help about widgets in the user interface.
GtkObject
`-- GtkWidget
áááááá`-- GtkMisc
áááááááááááá`-- GtkLabel
áááááááááááááááááá`-- GtkTipsQuery
Constructor
—
GtkTipsQuery
(void);
GtkTipsQuery
(void);
void set_caller
(GtkWidget caller);
Button that retains its state.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkButton
áááááááááááááááááááááááá`-- GtkToggleButton
Constructor
— Creates a button that can be toggled between two states.
GtkToggleButton
([string label ]);Methods
set_mode()
Toggles indicator mode. set_active()
Sets state. get_active()
Returns true if active. toggled()
Causes the toggled signal to be emitted. Signals
toggled: Emitted when the toggled() method is called. Properties
draw_indicator : Toggle indicator display.
A GtkToggleButton is a button that will retain its state following activation. This can be either the active state, GtkStateType GTK_STATE_ACTIVE, or the normal state, GTK_STATE_NORMAL. The active state has the appearance of a button that has been pressed down and not released.
The toggled signal is emitted as part of the process when the button is activated. Activation also triggers a change from the current state to its opposite value.
GtkToggleButton also provides some base elements for GtkCheckButton and GtkRadioButton widgets.
GtkToggleButton
([string
label
]);
creates a GtkToggleButton that can be toggled between active and normal states.
set_mode() is used internally to set the indicator mode for the different varieties of toggle button. There is no reason to use it unless you are creating your own widget.
This method toggles whether the toggle indicator is drawn or not. In GtkToggleButton itself, the indicator happens to take up the entire surface of the button, so that if the draw_indicator parameter is set to true the button itself vanishes. In the classes that inherit the GtkToggleButton methods the indicator takes up a very small area of the button, and setting the mode as false in those classes removes the indicator from the button, leaving only a GtkToggleButton with an offset label.
set_active() determines whether the GtkToggleButton's initial state is GTK_STATE_ACTIVE or otherwise.
The default setting is false.
get_active() returns true if the calling GtkToggleButton's current state is GTK_STATE_ACTIVE.
toggled() makes the calling GtkToggleButton emit the toggled signal. This method is called internally when the clicked signal is fired, that is, when the user either clicks the mouse over the button or presses the Enter or Space key while the button is selected.
The toggled signal is emitted when the toggled() method is called. This happens whenever the button is activated. As part of the response to the button classes' activating signal clicked, the state of the toggle indicator is switched from GTK_STATE_ACTIVE to GTK_STATE_NORMAL or vice versa. Note that this state-switching has no relationship with the toggled signal itself.
Callback function:
void callback
(GtkToggleButton togglebutton);
Type: Read Only
The draw_indicator property is the setting that denotes whether the toggle indicator is drawn or not. It is exposed here so that the value of the indicator's mode setting can be tested programmatically.
The property can be accessed using the syntax
The draw_indicator property should not be accessed directly. Use set_mode() where the value needs to be changed.
Container that creates bars of buttons and other widgets.
Constructor
—
GtkToolbar
(GtkOrientation orientation, GtkToolbarStyle style);
GtkToolbar
(GtkOrientation orientation, GtkToolbarStyle style);
void append_widget
(GtkWidget widget, string tooltip_text, string tooltip_private_text);
void prepend_widget
(GtkWidget widget, string tooltip_text, string tooltip_private_text);
void insert_widget
(GtkWidget widget, string tooltip_text, string tooltip_private_text, int position);
void set_orientation
(GtkOrientation orientation);
void set_style
(GtkToolbarStyle style);
void set_space_style
(GtkToolbarSpaceStyle space_style);
void set_button_relief
(GtkReliefStyle relief);
GtkReliefStyle get_button_relief
(void);
Adds tooltips to other widgets.
Constructor
—
GtkTooltips
(void);
GtkTooltips
(void);
void set_tip
(
GtkWidget
widget
, string tip_text, string tip_private);
Widget for displaying hierarchical information.
Constructor
—
GtkTree
(void);
GtkTree
(void);
void append
(GtkWidget tree_item);
void prepend
(GtkWidget tree_item);
void insert
(GtkWidget tree_item, int position);
void select_child
(GtkWidget tree_item);
void unselect_child
(GtkWidget tree_item);
int child_position
(GtkWidget child);
void set_selection_mode
(GtkSelectionMode mode);
void set_view_mode
(GtkTreeViewMode mode);
void remove_item
(GtkWidget child);
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkTreeItem
Constructor
—
GtkTreeItem
(XXX);
GtkTreeItem
(XXX);
void set_subtree
(GtkWidget subtree);
Vertical box container.
Constructor
— Creates a container for a single column of child widgets.
GtkVBox
([bool homogeneous = false , [int spacing = 0 ]]);
GtkVBox is a box container that packs child widgets in a single column, using the packing methods inherited from GtkBox, such as pack_start() , as well as the less flexible add() method available to most container widgets.
Note that all children in a GtkVBox are allocated the same width, regardless of settings and child requisition size. Widgets taking up less than the allocated width are by default centered within the available area in that dimension.
See also: GtkContainer, GtkBox, GtkHBox, GtkButtonBox, GtkTable.
GtkVBox
([bool
homogeneous = false
, [int
spacing = 0
]]);
Creates a new vertical box container designed for packing a single column of child widgets.
The first parameter, homogeneous, is a boolean value which, if set to true, will set each child widget in the GtkVBox to the same height as that of the largest child widget. The second parameter, spacing, sets the minimum spacing between the child widgets, in pixels. Leaving both parameters empty, e.g.
will set the default behaviour of individual sizing and zero spacing.
Example 34. Packing child widgets using GtkVBox and GtkHBox
$window = &new GtkWindow(); $window->set_title("GtkHBox and GtkVBox packing demonstration"); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object("destroy", array("gtk", "main_quit")); $window->show(); $vbox = &new GtkVBox(false, 5); $window->add($vbox); $label = &new GtkLabel(); $label->set_text("This GtkLabel is packed at the start of a GtkVBox. The GtkCalendar below is\npacked at the start of a GtkHBox, which is in turn packed at the end of the\nGtkVBox. The empty GtkText widget is packed at the end of the GtkHBox."); $label->set_justify(GTK_JUSTIFY_LEFT); $vbox->pack_start($label, true, true, 5); $label->show(); $hbox = &new GtkHBox(true, 0); $vbox->pack_end($hbox); $calendar = &new GtkCalendar(); $hbox->pack_start($calendar, true, true, 2); $calendar->show(); $text = &new GtkText(); $text->set_editable(true); $hbox->pack_end($text, true, true, 2); $text->show(); $window->show_all(); Gtk::main(); |
Container for arranging a group of buttons vertically.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkButtonBox
áááááááááááááááááááááááá`-- GtkVButtonBox
Constructor
— Creates the basis for a vertical button container.
GtkVButtonBox
(void);
GtkVButtonBox is a container widget designed for arranging a column of buttons in accordance with a specified GtkButtonBoxStyle setting.
See also: GtkButtonBox, GtkHButtonBox.
GtkVButtonBox
(void);
The syntax for creating a vertical buttonbox is:
There are no parameters.As with all container widgets, no physical space is taken by a GtkVButtonBox until its child widgets are in place.
Provides scrolling capability for non-scrolling aware widgets.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkViewport
Constructor
— Creates a scrollable container.
GtkViewport
([ GtkAdjustment hadjustment = NULL , [ GtkAdjustment vadjustment = NULL ]]);Methods
get_hadjustment()
Returns the horizontal adjustment object. get_vadjustment()
Returns the vertical adjustment object. set_shadow_type()
Sets the shadow style on the viewport's border.
The GtkViewport object is only used alongside a GtkScrolledWindow, and provides scrolling capability where the child widget being added to a scrolled window is not otherwise scrollable.
It is not possible in most cases to use it outside this context, as its adjustment values are set internally by the child's sizing policies and can neither be overridden manually nor used directly. Note that directional keybindings in a non-scrolling aware widget are not usually bound to any adjustment value by default; the GtkViewport simply allows the use of scrollbars with such a widget. The exception that proves this rule is GtkList, which is set up so that it can be made to be scrollable via the keyboard if it is added to a GtkViewport.
In most circumstances, it is easier to construct the viewport object by using the convenience method add_with_viewport() rather than by using its own constructor.
GtkViewport
([
GtkAdjustment
hadjustment = NULL
, [
GtkAdjustment
vadjustment = NULL
]]);
You should rarely need to construct a GtkViewport directly, as its main use is where a GtkScrolledWindow needs a scrollable widget as its child - which situation is catered for with the method add_with_viewport() , saving three or four coding lines.
Example 35. Creating a GtkViewport the hard way
dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); /* set up a window */ $window = &new GtkWindow(); $window->set_position(GTK_WIN_POS_CENTER); $window->connect_object('destroy', array('gtk', 'main_quit')); /* set up the scrolled window and add it to the main window, sizing it if necessary. */ $scrolledwindow = &new GtkScrolledWindow(); $scrolledwindow->set_usize(150, 150); $window->add($scrolledwindow); /* create the viewport */ $viewport = &new GtkViewport(); $viewport->set_shadow_type(GTK_SHADOW_ETCHED_OUT); /* create a box container and add child widget or widgets to it - because as with most widgets, a GtkCalendar has no adjustment-friendly focus internals, whereas a box container does */ $box = &new GtkVBox(); $calendar = &new GtkCalendar(); $box->pack_start($calendar, false); /* add the box to the viewport, and the viewport to the scrolled window */ $viewport->add($box); $scrolledwindow->add($viewport); $box->show_all(); $window->show_all(); gtk::main(); |
GtkAdjustment
get_hadjustment
(void);
get_hadjustment() returns the GtkAdjustment object that is used in horizontal scrolling.
GtkAdjustment
get_vadjustment
(void);
get_vadjustment() returns the GtkAdjustment object that is used in vertical scrolling.
void set_shadow_type
(
GtkShadowType
type
);
Sets the shadow style of the border area around a GtkViewport to one of five possible GtkShadowType values.
The default setting is GTK_SHADOW_IN.
Container with two panes arranged vertically.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkPaned
áááááááááááááááááá`-- GtkVPaned
Constructor
— Creates the basis for a vertical dual-paned container.
GtkVPaned
(void);
GtkVPaned is a widget derived from GtkPaned, consisting of two panes arranged vertically and separated by a dividing handle. The handle can be adjusted by the end user to alter the relative sizes of the panes.
GtkVPaned
(void);
The GtkVPaned widget should be thought of in terms of an arrangement of two child widgets, rather than as an object in its own right. The construct
needs to be within a containing GtkWindow and to contain two child widgets of its own in order to work.There is a code sample demonstrating the construction of a paned widget under the entry for the GtkHPaned constructor.
Vertical ruler.
Constructor
—
GtkVRuler
(void);
GtkVRuler
(void);
Vertical slider widget for selecting a value from a range.
Constructor
— Creates a vertical slider.
GtkVScale
([ GtkAdjustment adjustment = NULL ]);
A GtkVScale is a vertical scrollbar-like widget that is able to display its adjustment value as text.
There are some configuration issues with this widget when it is used in such a way; please refer to GtkScale for further information.
GtkVScale
([
GtkAdjustment
adjustment = NULL
]);
A GtkVScale that can be given its own GtkAdjustment settings has no configuration issues whatever.
Reasonable settings on an adjustment object for a GtkVScale on a single full page might look something like this:
This would give a scale of 0 to 100 along the height of the page, and no overlap.Vertical scrollbar.
GtkObject
`-- GtkWidget
áááááá`-- GtkRange
áááááááááááá`-- GtkScrollbar
áááááááááááááááááá`-- GtkVScrollbar
Constructor
— Creates a vertical scrollbar.
GtkVScrollbar
([ GtkAdjustment adjustment = NULL ]);
A GtkVScrollbar is a vertical scrollbar.
Table 5. Key bindings for GtkVScrollbar
Key combination Scroll function Up arrow Move up one step increment Down arrow Move down one step increment Page Up Move up one page increment Page Down Move down one page increment Control + Page Up Move to top of scroll Control + Page Down Move to bottom of scroll
GtkVScrollbar
([
GtkAdjustment
adjustment = NULL
]);
A scrollbar needs a GtkAdjustment in order to operate. The values that you give to the adjustment object will depend on the situation where the scrollbar is intended to be used.
All scrollable widgets have their own adjustment object(s), and in all instances where you are most likely to need a vertical scrollbar it is possible to create a handle for the widget's vertical GtkAdjustment and assign that as the new scrollbar's adjustment object.
For example:
Vertical separator.
Constructor
— Draws a vertical line.
GtkVSeparator
(void);
A GtkVSeparator is a widget that consists of a vertical line. It is used to separate widgets that are laid out horizontally.
Separators cannot be used in menu widgets, and there is currently no way to put a vertical separator into a GtkMenuBar.
See also: GtkHSeparator, gtk::paint_vline() .
GtkVSeparator
(void);
Constructing a GtkVSeparator and adding it to a widget amounts to the same thing as drawing a vertical line across that widget. Use the container's packing methods to determine the spacing around the separator.
Base class for user interface elements.
Methods
drag_highlight()
drag_unhighlight()
drag_dest_unset()
drag_source_unset()
drag_source_set_icon()
selection_owner_set()
selection_add_target()
selection_convert()
selection_remove_all()
unparent()
Dissociates widget from current parent. show()
Displays the calling widget. show_now()
hide()
Hides the calling widget. show_all()
Displays calling widget and its children. hide_all()
Hides calling widget and its children. map()
Maps calling widget to the screen. unmap()
Unmaps calling widget from the screen. realize()
Instantiates calling widget's GdkWindow. unrealize()
Removes calling widget's GdkWindow. queue_draw()
Queues widget's redraw requests, for the whole widget. queue_draw_area()
Queues widget's redraw requests, for any area within the widget. queue_clear()
queue_clear_area()
queue_resize()
Queues widget's resize requests. draw()
draw_focus()
draw_default()
add_accelerator()
Adds accelerator key to a widget. remove_accelerator()
Removes a single accelerator. remove_accelerators()
Removes all accelerators meeting certain criteria. lock_accelerators()
Locks accelerator key definitions. unlock_accelerators()
Unlocks accelerators to allow alterations. accelerators_locked()
Tests accelerator lock status. event()
activate()
reparent()
popup()
intersect()
grab_focus()
Gives grab and focus to the calling widget. grab_default()
Gives grab and default to the calling widget. set_name()
Sets widget name. get_name()
Returns name of widget. set_state()
Sets widget's state. set_sensitive()
Toggles sensitivity. set_app_paintable()
set_parent()
set_parent_window()
get_parent_window()
set_uposition()
Sets widget's position relative to its container. set_usize()
Sets widget's size in pixels. set_events()
Extends capturable events prior to realization. add_events()
Extends capturable events after realization. get_toplevel()
get_ancestor()
get_colormap()
Returns the GdkColormap object used by the widget. get_visual()
Returns the GdkVisual object used by the widget. set_colormap()
set_visual()
get_events()
is_ancestor()
Tests relationship with other widgets. hide_on_delete()
set_style()
Sets a widget's style property. set_rc_style()
ensure_style()
get_style()
Returns the GtkStyle object used by the widget. restore_default_style()
set_composite_name()
get_composite_name()
reset_rc_styles()
shape_combine_mask()
Signals
show: hide: map: unmap: realize: unrealize: draw: draw-focus: draw-default: size-request: size-allocate: state-changed: parent-set: style-set: add-accelerator: remove-accelerator: grab-focus: event: Emitted when any event is captured. button-press-event: Emitted when a GDK_BUTTON_PRESS event is captured. button-release-event: Emitted when a GDK_BUTTON_RELEASE event is captured. motion-notify-event: Emitted when a GDK_MOTION_NOTIFY event is captured. delete-event: Emitted when a GDK_DELETE event is captured. destroy-event: Emitted when a GDK_DESTROY event is captured. expose-event: Emitted when a GDK_EXPOSE event is captured. key-press-event: Emitted when a GDK_KEY_PRESS event is captured. key-release-event: Emitted when a GDK_KEY_RELEASE event is captured. enter-notify-event: Emitted when a GDK_ENTER_NOTIFY event is captured. leave-notify-event: Emitted when a GDK_LEAVE_NOTIFY event is captured. configure-event: Emitted when a GDK_CONFIGURE event is captured. focus-in-event: Emitted when a GDK_FOCUS_CHANGE event is captured. focus-out-event: Emitted when a GDK_FOCUS_CHANGE event is captured. map-event: Emitted when a GDK_MAP event is captured. unmap-event: Emitted when a GDK_UNMAP event is captured. property-notify-event: Emitted when a GDK_PROPERTY_NOTIFY event is captured. selection-clear-event: Emitted when a GDK_SELECTION_CLEAR event is captured. selection-request-event: Emitted when a GDK_SELECTION_REQUEST event is captured. selection-notify-event: Emitted when a GDK_SELECTION_NOTIFY event is captured. selection-received: selection-get: proximity-in-event: Emitted when a GDK_PROXIMITY_IN event is captured. proximity-out-event: Emitted when a GDK_PROXIMITY_OUT event is captured. drag-leave: drag-begin: drag-end: drag-data-delete: drag-motion: drag-drop: drag-data-get: drag-data-received: visibility-notify-event: Emitted when a GDK_VISIBILITY_NOTIFY event is captured. client-event: Emitted when a GDK_CLIENT_EVENT event is captured. no-expose-event: debug-msg: Properties
style : Style associated with a widget. window : Underlying GdkWindow that captures events on a widget. allocation : Size and position allocated to a widget. state : Degree of response to events. parent : A widget's parent.
GtkWidget is an abstract base class providing its descendants with properties, methods and signals pertinent to displayable user interface elements. The only objects that do not inherit GtkWidget characteristics are GtkTooltips, GtkAdjustment and GtkItemFactory - all of which are relatively abstract concepts. Everything else that is a member of the object hierarchy is a descendant of the GtkWidget class, takes up screen space, and may be referred to as a widget.
Note that GtkWidget cannot be constructed directly.
void drag_source_set_icon
(
GdkColormap
colormap
,
GdkPixmap
pixmap
,
GdkBitmap
mask
);
This method takes away the association between the calling widget and its current GdkWindow parent, allowing a new parent to be set for the widget.
show() is a commonly-used method that combines a series of other methods in order to display a widget on the screen.
hide() is the corollary to the show() method. It combines other methods in order to hide the calling widget from display.
This method is used to display the calling widget and its children. The extent to which it 'sees' children is system-dependant; some systems will not display children belonging to a child widget when show_all() is called from a top-level container. You may find that you still need to show() the children individually in order to display them, and it is good practice to do so consistently.
hide_all() is the corollary to show_all() , and the same reservations regards the levels of children that will respond to this call, apply. If in doubt, hide() the child widgets individually.
This method maps a widget to the screen area it will take. It is mostly used internally, being one of the methods that is called as part of the show() routine. It causes the map signal to be emitted by the widget, which in turn switches a flag causing the widget to be mapped.
At the point of a widget's becoming mapped, the GdkEvent GDK_MAP is triggered, causing the map-event signal to also be emitted by that widget. Use this signal to trigger functions that rely on the map event having occurred.
This method destroys information regards the dimensions of the screen area where the widget is displayed . It is mostly used internally, being one of the methods that is called as part of the hide() routine. It causes the unmap signal to be emitted by the widget, which in turn switches a flag causing the widget to be unmapped.
At the point of a widget's becoming unmapped, the GdkEvent GDK_UNMAP is triggered, causing the unmap-event signal to also be emitted by that widget. Use this signal to trigger functions that rely on the unmap event having occurred.
This method is the one to use if you need to force a widget to redraw itself. Put it into a callback function and determine an appropriate signal to trigger the redraws. queue_draw() creates an expose event, in most situations.
In the event that this method does not have the desired effect, try calling queue_resize() instead. If that also fails, you will need to resort to calling hide() followed immediately by show() in the callback.
This has exactly the same functionality as queue_draw() , with the exception that the area to be redrawn can be defined in the parameters.
Use this method to force a widget to resize. See GtkScale for a working example.
queue_resize() is useful in conjunction with a GtkDrawingArea, where the widget creates synthetic configure events in response to the resizing. It can also trigger expose events in some situations where the queue_draw() has proved ineffective in doing same.
This method is used extensively within GTK+ internals.
void add_accelerator
(string accel_signal,
GtkAccelGroup
accel_group
, int accel_key, GdkModifierType accel_mods,
GtkAccelFlags
accel_flags
);
add_accelerator() defines and adds a keyboard accelerator to the calling widget, usually a GtkMenuItem.
The first parameter is the name of the signal that you want the widget to emit when the key is pressed. Generally this will probably be activate.
The second parameter is the GtkAccelGroup that this GtkAccelEntry will belong to when it has been created. This will generally be an accelerator group that has been newly created and added to the toplevel window.
Thirdly there is the accel_key parameter. This can be pulled from the GtkAccelLabel using the parse_uline() method if you have an underscore under the appropriate letter, or alternatively you could use the key symbols which have been hard-coded into PHP-GTK. Usually these would be in the format GDK_KEY__a - always in lower case, because the accelerator functions return lower case key values.
The full list of PHP-GTK key symbol hard codings is available in the source code in the file ext/gtk+/php_gdk.c.
The fourth and fifth parameters are GdkModifierType and GtkAccelFlags respectively. In both cases, passing 0 is accepted as a null field.
There is no limit on the number of accelerator keys that can be associated with a widget.
void remove_accelerator
(
GtkAccelGroup
accel_group
, int accel_key, GdkModifierType accel_mods);
remove_accelerator() is a way to remove a single accelerator, defined by its key value and GtkModifierType.
Note that the accelerator needs to be unlocked before this method will work.
remove_accelerators() is a way to remove any number of accelerators belonging to the calling widget and causing the given signal to be fired. The second parameter toggles whether this should include all such accelerators, or only those displayed on the GtkAccelLabel.
Note that the accelerators on the widget need to be unlocked before this method will work.
lock_accelerators() locks any accelerators defined on the calling widget - usually a GtkMenuItem - so that no further keys can be entered or existing keys removed or altered.
Note that if you do not lock your accelerators the end user will be able to define their own, whether any exist on that widget or not.
unlock_accelerators() unlocks the accelerator entries defined in the calling widget, allowing changes or additions to be made to them.
See also: accelerators_locked() .
accelerators_locked() returns true if the accelerators on the calling widget are locked, and false if they are not.
void reparent
(
GtkWidget
new_parent
);
This method sets the initial grab and focus on the calling widget so that, for example, if a GtkText were to call it, any keyboard events would be picked up immediately by the text widget.
grab_focus() can only be called when the widget in question has the GTK_CAN_FOCUS flag set. Some will have this set at source, others will not, and will generate an error message to that effect when the method is called. Use set_flags() to override the source settings.
This method sets the keyboard grab and default status on the calling widget.
The single most likely scenario where you might use this would be to set up a GtkButton so that the user could activate it by immediately pressing the return key.
In order to make this possible, you will need to set the GTK_CAN_DEFAULT widget flag on the button. See also: set_flags() .
You may give a widget a unique name. This is mainly intended for use when creating a derived object, but it can also be useful for identifying individual widgets, for example, when an array of buttons is going to be queried at a later point in the script.
See also: get_name() .
This method returns the name of the calling widget. If no name has been set for the widget, this will be in the format GtkWidget.
get_name() is very useful where the widget could be one of many, e.g. in a callback that is used by several different widgets.
See also: get_type(), set_name() .
void set_state
(
GtkStateType
state
);
Sets the initial GtkStateType for the calling widget. Note that this will be overridden when the user interacts with the widget, and is primarily useful for offering visual cues.
A widget's current state can be queried using the state property.
See also: GtkStyle.
Use this function to toggle whether or not the user can interact with a widget. Setting it to false sets the widget's state to GTK_STATE_INSENSITIVE, which 'greys out' the widget.
You might use this if, for instance, you wanted to prevent a button from being pressed in certain situations.
void set_parent
(
GtkWidget
parent
);
void set_parent_window
(
GdkWindow
parent_window
);
GdkWindow
get_parent_window
(void);
set_uposition() sets the position of a child widget in pixels relative to the top left corner of its container or, if the widget is a toplevel window, relative to the top left corner of the screen.
set_usize() sets a widget's size in pixels. Sizing methods should only be called at one level of the packing hierarchy; you may need to size either the container or its children, but doing both will create conflicts in the size requests made by child widgets internally, which in turn can lead to unexpected results.
See also: GtkAlignment, and the packing methods supplied by GtkBox and GtkTable.
void set_events
(
GdkEventMask
events
);
This method is used to set the GdkEventMask flags on a widget, extending the type of event that the widget can capture from its default capabilities. You may need to do this, for instance, to capture a key press event on a widget that does not normally capture such events.
set_events() can be used at any point in the widget's life-cycle.
Staying with the key-press example, the syntax would be:
This would enable a previously keyboard-insensitive widget to emit key-press-event and key-release-event signals.
void add_events
(
GdkEventMask
events
);
This method is used to set the GdkEventMask flags on a widget, extending the type of event that the widget can capture from its default capabilities. You may need to do this, for instance, to capture a button press event on a widget that does not normally capture such events.
add_events() can only be used after a widget has had realize() called on it. Note that realization is a part of the show() routine as well as being a method/signal pair in its own right.
Staying with the button-press example, the syntax would be:
This would enable a previously mouse-insensitive widget to emit button-press-event and button-release-event signals.
GtkWidget
get_toplevel
(void);
GtkWidget
get_ancestor
(int widget_type);
GdkColormap
get_colormap
(void);
GdkVisual
get_visual
(void);
void set_colormap
(
GdkColormap
colormap
);
void set_visual
(
GdkVisual
visual
);
bool is_ancestor
(
GtkWidget
ancestor
);
is_ancestor() tests whether the widget named in the ancestor parameter is an ancestor of the calling widget, in the packing hierarchy rather than in the GTK object hierarchy.
This method is used extensively in GTK+ internals, but can also be useful in PHP-GTK, particularly for debugging purposes.
void set_style
(
GtkStyle
style
);
set_style() is used when some or all of the elements that make up an individual widget's default style property are being overwritten by a different instance of a GtkStyle object.
GtkStyle
get_style
(void);
void shape_combine_mask
(
GdkBitmap
shape_mask
, int offset_x, int offset_y);
Callback function:
void callback
(GtkWidget widget);
Callback function:
void callback
(GtkWidget widget);
Callback function:
void callback
(GtkWidget widget);
Callback function:
void callback
(GtkWidget widget);
Callback function:
void callback
(GtkWidget widget);
Callback function:
void callback
(GtkWidget widget);
Callback function:
void callback
(GtkWidget widget, );
Callback function:
void callback
(GtkWidget widget);
Callback function:
void callback
(GtkWidget widget);
Callback function:
void callback
(GtkWidget widget, );
Callback function:
void callback
(GtkWidget widget, );
Callback function:
void callback
(GtkWidget widget, );
Callback function:
void callback
(GtkWidget widget, GtkWidget parent);
Callback function:
void callback
(GtkWidget widget, );
Callback function:
void callback
(GtkWidget widget);
Callback function:
void callback
(GtkWidget widget);
Callback function:
void callback
(GtkWidget widget);
The event signal is emitted when any GdkEvent is captured by the connected widget's underlying GdkWindow.
All event signals return false until the event has been propagated to the widget that will handle it, at which point they return true, the event is no longer propagated and the signal is no longer fired.
Each event causes two signal emissions; the generic event signal described here, and the specific event signal that is being called, such as the key-press-event signal. The event signal itself is unlikely to be used directly on its own account very often.
All event signals carry the event that caused the signal to be fired as the first parameter after the connecting widget. You may add as many parameters as you like that contain data specific to your application.
You can limit or extend the events that are captured by a windowed widget by setting one or more GdkEventMask flags for the widget. See add_events() , and set_events() .
Callback function:
bool callback
(GtkWidget widget, GdkEvent event);
This is an event signal, fired when the connected widget picks up a GDK_BUTTON_PRESS event. Button press events are generated by any of the mouse buttons being pressed. You can distinguish between the mouse buttons in the callback by using an if or switch statement:
function on_click($widget, $event, $data) { switch($event->button) { case 1: /* do something appropriate to a left click */ break; case 2: /* do something appropriate to a middle click */ break; case 3: /* do something appropriate to a right click */ break; }} $widget->connect('button-press-event', 'on_click', $data); |
See also: button-release-event, event, key-press-event.
Callback function:
bool callback
(GtkWidget widget, GdkEvent button_press);
This is an event signal, fired when the connected widget picks up a GDK_BUTTON_RELEASE event. Button release events are generated by any of the mouse buttons being released. You can distinguish between the mouse buttons in the callback by using $event->button.
See also: button-press-event, event, key-press-event.
Callback function:
bool callback
(GtkWidget widget, GdkEvent button_release);
This is an event signal, fired when the connected widget picks up a GDK_MOTION_NOTIFY event. Motion notify events are triggered when the mouse pointer moves across the screen. There are a great many of them, which has given rise to several different kinds of GdkEventMask aiming to minimise the amount that are captured.
See also: event.
Callback function:
bool callback
(GtkWidget widget, GdkEvent motion_notify);
This is an event signal, fired when the window manager requests that a widget be deleted. This is generally when a user clicks the X close button on a toplevel window.
The delete event is not propagated. If you want to prevent the end user from using the window decorations to close your application, returning true from the delete-event signal will do just that. Allowing it to return false - which it does by default - will cause its default handler to be called. This happens to be the destroy() method, which in turns fires the destroy signal. In most cases, it's simpler to connect directly to the latter.
See also: event.
Callback function:
bool callback
(GtkWidget widget, GdkEvent delete);
You really shouldn't ever find a widget that emits this signal. The destroy event is triggered by the destruction of a widget's underlying GdkWindow, so if that widget is still capable of emitting the destroy-event signal something has gone badly awry.
See also: delete-event, event.
Callback function:
bool callback
(GtkWidget widget, GdkEvent destroy);
This is an event signal, initially emitted when the connected widget becomes fully visible on screen. Every widget can capture expose events; they are even synthesized for widgets that don't have a GdkWindow.
Expose events are also generated when a widget has been partially or fully covered by another widget, and is re-exposed. These events trigger a redraw internally; a GdkWindow that is not currently exposed is not currently drawn, and the same applies to any unexposed area of a window.
Following suit, the most likely reason to connect to an expose-event signal is that you have a drawing function in the callback.
See also: event, GtkDrawingArea, GdkWindow, and the numerous GTK and GDK drawing functions filed under 'Misc'.
Callback function:
bool callback
(GtkWidget widget, GdkEvent expose);
This is an event signal, fired when the connected widget picks up a GDK_KEY_PRESS event. Key press events are generated by any of the keys on a keyboard being pressed. You can distinguish between the key values in the callback using an if or switch statement:
function on_click($widget, $event, $data) { if($event->keyval==GDK_KEY_Return) { /*do something appropriate for the return key being pressed*/ } elseif($event->keyval > GDK_KEY__a) { /*we can reach the character strings, too*/ echo $event->string."\n"; }} |
Yes, we have hard-coded keysyms. The full list of PHP-GTK keysymbol constants is in the source code in the file php-gtk/ext/gtk+/php_gdk.c.
Callback function:
bool callback
(GtkWidget widget, GdkEvent key_press);
Callback function:
bool callback
(GtkWidget widget, GdkEvent key_release);
Callback function:
bool callback
(GtkWidget widget, GdkEvent enter_notify);
Callback function:
bool callback
(GtkWidget widget, GdkEvent leave_notify);
Callback function:
bool callback
(GtkWidget widget, GdkEvent configure);
Callback function:
bool callback
(GtkWidget widget, GdkEvent focus_change);
Callback function:
bool callback
(GtkWidget widget, GdkEvent focus_change);
Callback function:
bool callback
(GtkWidget widget, GdkEvent map);
Callback function:
bool callback
(GtkWidget widget, GdkEvent unmap);
Callback function:
bool callback
(GtkWidget widget, GdkEvent property_notify);
Callback function:
bool callback
(GtkWidget widget, GdkEvent selection_clear);
Callback function:
bool callback
(GtkWidget widget, GdkEvent selection_request);
Callback function:
bool callback
(GtkWidget widget, GdkEvent selection_notify);
Callback function:
void callback
(GtkWidget widget, , );
Callback function:
void callback
(GtkWidget widget, , , );
Callback function:
bool callback
(GtkWidget widget, GdkEvent proximity_in);
Callback function:
bool callback
(GtkWidget widget, GdkEvent proximity_out);
Callback function:
void callback
(GtkWidget widget, , );
Callback function:
void callback
(GtkWidget widget, );
Callback function:
void callback
(GtkWidget widget, );
Callback function:
void callback
(GtkWidget widget, );
Callback function:
bool callback
(GtkWidget widget, , , , );
Callback function:
bool callback
(GtkWidget widget, , , , );
Callback function:
void callback
(GtkWidget widget, , , , );
Callback function:
void callback
(GtkWidget widget, , , , , , );
Callback function:
bool callback
(GtkWidget widget, GdkEvent visibility_notify);
Callback function:
bool callback
(GtkWidget widget, GdkEvent client_event);
Emitted when a GDK_NO_EXPOSE event is captured.
Callback function:
bool callback
(GtkWidget widget, GdkEvent no_expose);
Callback function:
void callback
(GtkWidget widget, );
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Widget that provides windows for an application.
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
Constructor
— Creates a new GtkWindow.
GtkWindow
([ GtkWindowType type = GTK_WINDOW_TOPLEVEL ]);Methods
set_title()
Sets window title. set_wmclass()
Sets window manager class and name. set_policy()
Sets window resizing policy. *deprecated in GTK2* add_accel_group()
Associates accelerator group with window. remove_accel_group()
Removes associated accelerator group from window. set_position()
Sets screen position of window. activate_focus()
Activates child that currently has focus. activate_default()
Activates child currently set as default. set_transient_for()
Sets window as transient for the given parent. set_default_size()
Sets default window size. set_modal()
Toggles window modality. set_focus()
Gives child widget focus. set_default()
Sets child widget as default. Signals
set-focus: Emitted when set_focus() is called.
GtkWindow is the widget providing the windows for an application. There are three different types, defined by the programmer during construction - toplevel, dialog or popup.
Toplevel windows contain the standard window decorations minimize, maximize and close. Of these, the first two exhibit the expected default behaviour; this is pre-set within the GDK source, and cannot currently be altered from within PHP-GTK. The close button is not pre-set in same way, in that its emission of the destroy signal can be overridden by connecting a function to the window's delete-event signal and having that function return true. Note that the main window's destroy signal should be connected, directly or otherwise, to a function that will quit the GTK main loop.
A dialog window is not the same thing as a GtkDialog, but is simply a normal toplevel window with the maximize function disabled. Both dialog and popup windows are designed to be used when a message to the user requires a response, and should be used in conjunction with the set_transient_for() and set_modal() methods.
A popup window lacks any window decoration, so needs an alternative means of closure. This could triggered by a timer, an event, or a widget capable of user interaction.
Note that both the window decorations and the associated functions described above are provided by the underlying system's window manager, and could possibly vary or be absent.
GtkWindow
([
GtkWindowType
type = GTK_WINDOW_TOPLEVEL
]);
Creates a new GtkWindow which is toplevel by default. Most of the other widgets in PHP-GTK need to have a window constructed and to be added to that window (or a container within that window) before they can be instantiated. There are exceptions, such as GtkDialog and GtkColorSelectionDialog; these are compound widgets which are already based upon their own internal instance of a GtkWindow.
As the GtkWindow is such a fundamental object in the design of windowed applications, there follows a brief code sample to reiterate the essential basic steps in creating any PHP-GTK script:
/*load the php_gtk module*/ dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) || die("Can't load php_gtk module!\n"); /*create the main window*/ $window = &new GtkWindow(); /*ensure that the destruction of the main window also kills the main loop*/ $window->connect_object('destroy', array('gtk', 'main_quit')); /*realize the underlying GdkWindow, flag the GtkWindow's visibility and map it onto the screen, all in one simple line*/ $window->show(); /*without the main loop, there is no PHP-GTK script*/ gtk::main(); |
Sets the title shown in the window's title bar, and also in the task bar icon for the window when it is minimized. The text is truncated to the width of the window.
Either single or double quotation marks may be used to contain the string. Note that any apostrophes will need to be escaped with a backslash if single quotation marks are used.
Sets the window manager name and class across an application. However, given that the window manager class is already set in precisely this way by GTK, and that there are no functions in PHP-GTK where we might need this information, this method is best left untouched.
The default policy on a GtkWindow is false, true, false, which retains the default size of the window on opening and allows the user to resize it thereafter.
allow_shrink when set to true allows the window to be smaller than its child's size requisition, which has the effect of truncating the child. For this reason, it should always be set to false.
allow_grow when set to true allows the window to be expanded beyond its initial size. The default behaviour of the child is to expand with the window, in most cases. Setting the allow_grow parameter to false prevents such resizing, taking the requisition size of the window's child as the window's base size.
auto_shrink when set to true overrides the window's default size setting, and shrinks or expands the window to fit the child's requisition size if the second parameter hasn't already done so.
Basically the only reason to use this method is likely to be when you don't want the window to be user-resizable. In this case, the setting you should use is false, false, true, or alternatively false, false, false which will have the same effect due to the redundancy of the third parameter here.
This method has been deprecated in GTK 2.0 in favour of a new and more efficient method. It would be wise to bear this in mind and use set_policy() sparingly.
void add_accel_group
(
GtkAccelGroup
accel_group
);
Adds an existing GtkAccelGroup to the window, allowing keyboard shortcuts to be created - usually for menus.
void remove_accel_group
(
GtkAccelGroup
accel_group
);
Removes the named accelerator group from the window.
void set_position
(
GtkWindowPosition
position
);
set_position() sets the position of the window on opening to one of four possible GtkWindowPosition values.
activate_focus() is a method that will emit the activate signal from the child widget having focus at the point that the method is called. In GTK+, each widget has one signal which has activate signal status; the signal with this status has the ability to respond to events generated from the keyboard. If you do not have that widget-specific activate signal connected to the widget with focus, nothing will be fired.
The widget that is most likely to be used in this situation is probably GtkButton, which has clicked as its activate signal.
If this method is part of a callback called from another widget, that widget will have focus at the time that the callback is run and PHP will - understandably - crash. It needs to be called from an event signal in order to work.
See also: Signals and Events in the PHP-GTK userguide, activate_default() , set_focus() , activate.
As with activate_focus() , the activate_default() method causes the widget-specific activate signal to be emitted by the targeted child.
See also: activate_focus() , set_default() , activate.
void set_transient_for
(
GtkWindow
parent
);
set_transient_for() is used to set a dialog or popup window as a temporary child of the toplevel window it is associated with. This prevents there being an additional icon for the transient message in the taskbar, and also allows the transient window to take on the behaviour of the parent window, e.g. if the parent is minimized the child will minimize along with it.
This method does not work in the win32 version of GTK+ currently used by PHP-GTK, but as the bug causing the problem has now been fixed in Gnome CVS it would be sensible to use it.
Attempting to delete the parent window before destroying the transient window produces a gdk warning on win32. To avoid this, always use set_modal() where you have used set_transient_for() .
set_default_size() sets the default opening size of a window, in pixels. This can be overridden by size requests from the window's child widget exceeding the default size of the window, or by actively setting the resizing policy of the window so that the window always shrink-wraps its child.
Note that a smaller child widget whose size has not been set or otherwise restricted by the programmer will generally expand to fit the default size of the parent window.
set_modal() is used to prevent the other windows in an application from reacting to user activity until the modal window has had an appropriate user response. It is usually used where dialog or popup windows are acting as message boxes.
A similar effect can be achieved with most widgets by using the static function gtk::grab_add() ; however note that set_modal() is a slightly more complex method and is equipped to deal more fully with the scenarios likely to arise when using modal windows.
void set_focus
(
GtkWidget
focus
);
set_focus() sets the focus to the child widget passed as the parameter. The child must have the flag GTK_CAN_FOCUS set in order to be allowed focus. Some widgets are created with this flag already set (including the GtkButton widget), others are not.
See also: GtkWidgetFlags, GtkWidget, set_flags() .
void set_default
(
GtkWidget
defaultw
);
set_default() sets the child widget passed to it as the default child. (This will usually be a GtkButton.) The child must have the flag GTK_CAN_DEFAULT set in order to be allowed focus. Some widgets are created with this flag already set; GtkButton is not one of those widgets, and needs to be flagged.
Child widgets that are set as default are marked as such in a way that will be familiar to users. For instance, a button set as default has a decorative frame and shadow around it.
See also: GtkWidgetFlags, GtkWidget, set_flags() .
The set-focus signal is emitted by the GtkWindow in response to a set_focus() method call, which is triggered each time the child having focus within that window changes, that is, every time the user chooses a different child widget.
The signal is primarily for internal GTK use.
Callback function:
void callback
(
GtkWindow
window
,
GtkWidget
child_widget
);
gtk::accel_group_get_default()
Gets the toplevel window's default GtkAccelGroup. gtk::button_box_set_child_ipadding_default()
Sets GtkButtonBox default child internal padding. gtk::button_box_set_child_size_default()
Sets GtkButtonBox default minimum child size. gtk::check_version()
Checks which version of GTK+ is being used. gtk::drag_finish()
gtk::drag_get_source_widget()
gtk::drag_set_default_icon()
gtk::drag_set_icon_default()
gtk::drag_set_icon_pixmap()
gtk::drag_set_icon_widget()
gtk::drag_dest_handle_event()
gtk::drag_source_handle_event()
gtk::draw_arrow()
Draws an arrow. gtk::draw_box()
Draws a box. gtk::draw_diamond()
gtk::draw_hline()
gtk::draw_oval()
Not implemented. gtk::draw_shadow()
gtk::draw_string()
gtk::draw_vline()
gtk::entry_new_with_max_length()
Creates a limited-character GtkEntry. gtk::events_pending()
Tests whether there are GdkEvents queueing. gtk::false()
Returns false. gtk::hbutton_box_get_layout_default()
Returns GtkHButtonBox layout default. gtk::hbutton_box_get_spacing_default()
Returns GtkHButtonBox spacing default. gtk::grab_add()
Endows a widget with keyboard grab. gtk::grab_get_current()
Returns widget that currently has keyboard grab. gtk::grab_remove()
Removes keyboard grab from a widget. gtk::hbutton_box_set_layout_default()
Sets layout default for GtkHButtonBoxes. gtk::hbutton_box_set_spacing_default()
Sets spacing default for GtkHButtonBoxes. gtk::idle_add()
gtk::idle_remove()
gtk::input_add()
gtk::input_remove()
gtk::item_factories_path_delete()
gtk::item_factory_from_path()
gtk::item_factory_from_widget()
gtk::item_factory_parse_rc()
gtk::item_factory_parse_rc_string()
gtk::item_factory_path_from_widget()
gtk::main()
Runs the main loop. gtk::main_do_event()
Processes a single GdkEvent. gtk::main_iteration()
Runs the main loop once and then blocks GTK until an event is pending. gtk::main_iteration_do()
Runs the main loop once, with optional blocking. gtk::main_level()
Returns the main loop nesting level. gtk::main_quit()
Quits the main loop. gtk::paint_arrow()
gtk::paint_box()
gtk::paint_box_gap()
gtk::paint_check()
gtk::paint_cross()
gtk::paint_diamond()
gtk::paint_extension()
gtk::paint_flat_box()
Paints a flat box. gtk::paint_focus()
A quick way to draw focus-like shadow around a given rectangle. gtk::paint_handle()
gtk::paint_hline()
gtk::paint_option()
gtk::paint_oval()
Not implemented. gtk::paint_ramp()
gtk::paint_shadow()
gtk::paint_shadow_gap()
gtk::paint_slider()
gtk::paint_string()
gtk::paint_tab()
gtk::paint_vline()
gtk::preview_get_cmap()
gtk::preview_get_visual()
gtk::preview_reset()
gtk::preview_set_color_cube()
gtk::preview_set_gamma()
gtk::preview_set_install_cmap()
gtk::preview_set_reserved()
gtk::quit_add()
gtk::quit_remove()
gtk::rc_add_default_file()
gtk::rc_find_module_in_path()
gtk::rc_get_module_dir()
gtk::rc_get_style()
gtk::rc_get_theme_dir()
gtk::rc_load_image()
gtk::rc_parse()
Parses an application's rc file(s). gtk::rc_parse_string()
gtk::rc_reparse_all()
gtk::timeout_add()
Sets up a function to be called at regular intervals. gtk::timeout_remove()
Removes timeout. gtk::true()
Returns true. gtk::type_from_name()
Returns object type from object name. gtk::type_name()
Returns name of object. gtk::vbutton_box_get_layout_default()
Returns GtkVButtonBox layout default. gtk::vbutton_box_get_spacing_default()
Returns GtkVButtonBox spacing default. gtk::vbutton_box_set_layout_default()
Sets layout default for GtkVButtonBoxes. gtk::vbutton_box_set_spacing_default()
Sets spacing default for GtkVButtonBoxes. gtk::widget_get_default_colormap()
Returns the application's default GdkColormap. gtk::widget_get_default_style()
Returns the application's default GtkStyle. gtk::widget_get_default_visual()
Returns the application's default GdkVisual. gtk::widget_pop_colormap()
gtk::widget_pop_composite_child()
gtk::widget_pop_style()
gtk::widget_pop_visual()
gtk::widget_push_colormap()
gtk::widget_push_composite_child()
gtk::widget_push_style()
gtk::widget_push_visual()
gtk::widget_set_default_colormap()
Sets a GdkColormap as default for the application. gtk::widget_set_default_style()
Sets a GtkStyle as default for the application. gtk::widget_set_default_visual()
Sets a GdkVisual as default for the application.
GtkAccelGroup
gtk::accel_group_get_default
(void);
void gtk::drag_finish
(
GdkDragContext
context
, bool success, bool del, int time);
GtkWidget
gtk::drag_get_source_widget
(
GdkDragContext
context
);
void gtk::drag_set_default_icon
(
GdkColormap
colormap
,
GdkPixmap
pixmap
,
GdkBitmap
mask
, int hot_x, int hot_y);
void gtk::drag_set_icon_default
(
GdkDragContext
context
);
void gtk::drag_set_icon_pixmap
(
GdkDragContext
context
,
GdkColormap
colormap
,
GdkPixmap
pixmap
,
GdkBitmap
mask
, int hot_x, int hot_y);
void gtk::drag_set_icon_widget
(
GdkDragContext
context
,
GtkWidget
widget
, int hot_x, int hot_y);
void gtk::drag_dest_handle_event
(
GtkWidget
toplevel
,
GdkEvent
event
);
void
gtk::drag_source_handle_event
(
GtkWidget
widget
,
GdkEvent
event
);
void gtk::draw_arrow
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
,
GtkArrowType
arrow_type
, bool fill, int x, int y, int width, int height);
The chief advantage of drawing your own GTK arrow rather than using the GtkArrow widget is that you can shape it, using the width and height parameters. The fill parameter refers to the color of the arrow, with false giving it the same color as the area it is drawn onto. All positions and sizes are absolute in terms of the underlying drawable.
gtk::draw_arrow($style, $gdkwindow, GTK_STATE_NORMAL, GTK_SHADOW_OUT, GTK_ARROW_RIGHT, false, $x, $y, $width, $height); |
void gtk::draw_box
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, int x, int y, int width, int height);
This is the simplest way to draw a box, with or without a shadow. Any coloring is completely dependant on the GtkStyle that is passed as the first parameter.
void gtk::draw_diamond
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, int x, int y, int width, int height);
void gtk::draw_hline
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
, int x1, int x2, int y);
void gtk::draw_oval
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, int x, int y, int width, int height);
void gtk::draw_shadow
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, int x, int y, int width, int height);
void gtk::draw_string
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
, int x, int y, string string);
void gtk::draw_vline
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
, int y1, int y2, int x);
GtkWidget
gtk::entry_new_with_max_length
(int max);
gtk::events_pending() is useful when there is a function that needs to be carried out during a long-running process, for example, updating a status bar during an SQL query.
The way it would be used in such a situation is to have
after every update that is made to the GUI. This causes the main loop to run once each time events are anticipated.See also: gtk::main_iteration() , gtk::main_iteration_do() , gtk::timeout_add() .
A static function that simply returns false. By default this is null; you can force a 0 return by declaring it as a PHP (int) type.
GtkButtonBoxStyle
gtk::hbutton_box_get_layout_default
(void);
void gtk::grab_add
(
GtkWidget
widget
);
GtkWidget
gtk::grab_get_current
(void);
void gtk::grab_remove
(
GtkWidget
widget
);
void
gtk::hbutton_box_set_layout_default
(
GtkButtonBoxStyle
layout
);
GtkItemFactory
gtk::item_factory_from_path
(string path);
GtkItemFactory
gtk::item_factory_from_widget
(
GtkWidget
widget
);
string
gtk::item_factory_path_from_widget
(
GtkWidget
widget
);
void gtk::paint_arrow
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail,
GtkArrowType
arrow_type
, bool fill, int x, int y, int width, int height);
void gtk::paint_box
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height);
void gtk::paint_box_gap
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height,
GtkPositionType
gap_side
, int gap_x, int gap_width);
void gtk::paint_check
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height);
void gtk::paint_cross
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height);
void gtk::paint_diamond
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height);
void gtk::paint_extension
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height,
GtkPositionType
gap_side
);
void gtk::paint_flat_box
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height);
Regardless of the GtkShadowType detailed here, the effect is similar to the box drawn using gtk::draw_box() and GTK_SHADOW_NONE.
The GdkRectangle used should be in the same position and have the same dimensions as those passed in the function, as otherwise only the overlap between the two rectangles will be displayed, or nothing at all if there is no overlapping area. The detail parameter actually does nothing here, but is needed for back compatibility. Passing it as null, or as any string you feel, is okay.
$rectangle = &new GdkRectangle($x, $y, $width, $height); gtk::paint_flat_box($style, $gdkwindow, GTK_STATE_ACTIVE, GTK_SHADOW_NONE, $rectangle, $drawingarea, null, $x, $y, $width, $height);
void gtk::paint_focus
(
GtkStyle
style
,
GdkWindow
window
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height);
gtk::paint_focus() is a convenience function that draws a dark shadow along the left and top sides of the given rectangle, making it appear as GTK widgets generally do when they have focus.
This is the only function that uses the detail parameter at all now; if you pass 'set-mode' as that parameter, the shadow will appear as long dashes rather than as a continuous line. Any other string is regarded the same as if it were null.
The other parameters are on the whole self-explanatory. The widget parameter refers to the widget that is being drawn upon (usually a GtkDrawingArea).
void gtk::paint_handle
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height,
GtkOrientation
orientation
);
void gtk::paint_hline
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x1, int x2, int y);
void gtk::paint_option
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height);
void gtk::paint_oval
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height);
void gtk::paint_ramp
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail,
GtkArrowType
arrow_type
, int x, int y, int width, int height);
void gtk::paint_shadow
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height);
void gtk::paint_shadow_gap
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height,
GtkPositionType
gap_side
, int gap_x, int gap_width);
void gtk::paint_slider
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height,
GtkOrientation
orientation
);
void gtk::paint_string
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, string string);
void gtk::paint_tab
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
,
GtkShadowType
shadow_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int x, int y, int width, int height);
void gtk::paint_vline
(
GtkStyle
style
,
GdkWindow
window
,
GtkStateType
state_type
, GdkRectangle area,
GtkWidget
widget
, string detail, int y1, int y2, int x);
GdkColormap
gtk::preview_get_cmap
(void);
GdkVisual
gtk::preview_get_visual
(void);
void gtk::preview_set_color_cube
(int nred_shades, int ngreen_shades, int nblue_shades, int ngray_shades);
GdkPixmap
gtk::rc_load_image
(
GdkColormap
colormap
,
GdkColor
transparent_color
, string filename);
This is a static function that simply returns 1. It has no other functionality.
GtkButtonBoxStyle
gtk::vbutton_box_get_layout_default
(void);
void
gtk::vbutton_box_set_layout_default
(
GtkButtonBoxStyle
layout
);
GdkColormap
gtk::widget_get_default_colormap
(void);
GtkStyle
gtk::widget_get_default_style
(void);
Returns the default GtkStyle that is currently being used throughout an application.
Use gtk::widget_set_default_style() to change aspects of the default style.
GdkVisual
gtk::widget_get_default_visual
(void);
void gtk::widget_push_colormap
(
GdkColormap
cmap
);
void gtk::widget_push_style
(
GtkStyle
style
);
void gtk::widget_push_visual
(
GdkVisual
visual
);
void
gtk::widget_set_default_colormap
(
GdkColormap
colormap
);
void
gtk::widget_set_default_style
(
GtkStyle
style
);
void
gtk::widget_set_default_visual
(
GdkVisual
visual
);
Table of Contents
A structure that holds a defined color.
Constructor
— Creates a new color object using one of three possible constructs.
GdkColor
(int red, int green, int blue);
A GdkColor provides an object structure for retaining information about a defined color.
This is an XcmsColor structure, and will take values in any XcmsColor format accordingly. Probably the most generally useful of these formats is the gamma-corrected XcmsRGB structure, which takes the range 0 to 65535 per RGB value, with 0, 0, 0 being the color black. RGB values that are given in this way are scaled to match the color range of the hardware device currently being used.
Colors can be assigned through an application's RC files, where the GdkColor objects are constructed via the application colormap defined through the file. Colors that are assigned in this way can be constructed using any of the formats accepted by the XcmsColor structure, including intensity doubles.
Note that this is not the case when assigning a color to a GdkColor directly.
GdkColor
(int red, int green, int blue);
When constructing a GdkColor directly, you will need to use the system's color names, hex RGB triples or XcmsRGB values. Attempting to use other formats here will not result in an error message, because the structure itself recognises them, but equally they will not display, because the function doesn't recognise them at all.
The options when directly constructing colors in PHP-GTK are:
or or Color names that are used on a given system are defined in a file named rgb.txt. The equivalent file is not available in human-readable form under win32, although utilised. Here is one of the better reference pages currently online detailing the standard color names used by window management systems.See also: GtkStyle.
Type: Read Only
Type: Read Only
Properties
protocol : is_source : source_window : dest_window : targets : actions : suggested_action : action : start_time :
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Structure holding font information.
Methods
extents()
Returns an array of sizing information. measure()
The drawn width of a text-string, measured in pixels. height()
Returns the line height, measured in pixels. width()
The logical width of a text string, measured in pixels. Properties
type : Font or fontset type. ascent : Baseline to top of logical area. descent : Baseline to bottom of logical area.
A GdkFont is a data structure containing basic information about a font, in terms of its type , ascent and descent . There is no constructor, as the fonts available are provided by the system. The GdkFont structure simply allows a new font to be loaded and queried.
To load a font, use gdk::font_load() . To load a fontset - a range of different fonts - use gdk::fontset_load() . Either function will return a single GdkFont.
extents() returns an array of five integers representing the left bearing, right bearing, width, ascent and descent of the string using the font, or the font itself, as appropriate.
The left and right bearing are the distance from the drawing origin to the leftmost and rightmost extent of the drawn string respectively, measured in pixels.
The width is the length of the current string, measured in pixels. This measurement supplies information regarding where to begin drawing the next string, if there is more than one. The returned integer may be greater or smaller than the value of the right bearing.
The ascent and descent are the pixel measurements of the extents of the current string above and below the baseline.
If you're working with unix, all the above should be correct. If you're using win32, the left bearing will always be 0, the right bearing will match the width, the ascent is actually the line-height + 1 pixel, and the descent is the descent + 1 pixel. Use GdkFont properties if you need the ascent and descent values under win32.
The return from this method is the equivalent of the right bearing returned by extents() . It is the size in pixels of the width of the string, to the point where the final part of the final character in the string is drawn.
If you need the logical width of the string - that is, to the point where the next character should be inserted - use width() instead.
The return value of height() is arrived at by summing the values of ascent and descent returned by extents() and relating to the current string.
Under win32, this is a bogus value. Add the values returned by the GdkFont properties ascent and descent to get the value of the font's height.
The value of the height is the line-height, given in pixels, and represents the logical space required by a line. If you are using this measurement to calculate the size of a text box, you will need to add 6 pixels to the total to allow for the borders of the text widget.
width() returns the logical width of the text string, measured in pixels. The logical width includes the area up to where the next character should be drawn.
This method is completely broken in Windows, and will always return the right bearing measurement instead.
Type: Read Only
The returned integer may have a value of 0, indicating that the font was loaded as a unique font, or of 1, indicating that the font was loaded as part of a fontset. See GdkFontType.
Note that under win32 this property will always have a value of 1, as all fonts are loaded as fontsets in order to provide support for the wide characters used by the operating system.
Type: Read Only
The ascent is the distance between a font's baseline and the top of the logical space taken up by that font.
Add this to the descent to obtain the full font height value in pixels.
Type: Read Only
The descent is the distance between a font's baseline and the bottom of the logical space taken up by that font.
A structure that contains graphics information.
Methods
set_dashes()
Configures the appearance of dashed lines. Properties
foreground : The foreground color. background : The background color. font : The loaded font. function : Bitwise description of the drawing function. fill : The style of the fill. tile : The pixmap used for tiling. stipple : The pixmap used for stippling. clip_mask : The clip mask bitmap. subwindow_mode : The way subwindows are treated. ts_x_origin : Tile or stipple's x origin. ts_y_origin : Tile or stipple's y origin. clip_x_origin : Clip mask's x origin. clip_y_origin : Clip mask's y origin. graphics_exposures : Whether expose events are generated during pixmap copies. line_width : The pixel width of a drawn line. line_style : The way a dashed line is drawn. cap_style : The way the end of a line is drawn. join_style : The way line joins are drawn.
A GdkGC is made up of a series of properties, each of which may or may not be set, that describe everything from color to font to line-width. It forms several of the underlying elements of the style property in widgets, and is used in GDK where GtkStyle would be used at GTK level. The GC part of GdkGC stands for graphics context, and every GDK drawing function requires one in much the same way that every GTK drawing function requires a style.
The functions that allow the getting and setting of GdkGC properties are internalised in PHP-GTK. For the most part, we have writeable properties instead of these methods. Please note that there is no guarantee that all these properties will be supported by your operating system; win32's 'little black boxes' text issue is there because win32 does not support stippling, for example.
There is no direct constructor for a GdkGC. To create one, you will need to use the GdkWindow method new_gc() and set the properties that you are interested in directly.
Type: Read Write
This looks so straightforward, and isn't. GdkGC objects are so far down in the evolutionary scale that they don't have an associated colormap. If you try to apply color directly, any color will be returned as a muddy brown.
The way around this is to borrow an existing GdkColormap and allocate a color from there. You can use gdk::colormap_get_system() to do this, or you can access the colormap in a GdkWindow.
The syntax is:
As with the GdkColor constructor, you could use '#FF0000' or 65535, 0, 0 in place of 'red', but not 1.0, 0.0. 0.0.
Type: Read Write
It is not possible to apply a new or existing GdkColor to a GdkGC, because there is no colormap there for the color to reference.
You will need to take an existing GdkColormap, either by using gdk::colormap_get_system() or by accessing the colormap property in the existing GdkWindow that most widgets have, and give it a handle. Then you do something like:
and the color is allocated intelligently.The background color fills the areas not taken up by the foreground color, e.g. the gaps in a dashed line will take the background color. If you don't want this, just don't set this property.
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
Type: Read Write
GdkPixmap
();
Properties
type : depth : byte_order : colormap_size : bits_per_rgb : red_mask : red_shift : red_prec : green_mask : green_shift : green_prec : blue_mask : blue_shift : blue_prec :
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Methods
raise()
lower()
get_pointer()
set_cursor()
new_gc()
property_get()
property_change()
property_delete()
set_icon()
Properties
width : height : x : y : colormap : pointer : pointer_state : parent : toplevel : children : type : depth : xid : Not on Windows.
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
Type: Read Only
gdk::atom_intern()
gdk::beep()
Emits a sound. gdk::colormap_new()
Creates a new GdkColormap. gdk::colormap_get_system()
Returns the system colormap. gdk::colormap_get_system_size()
Returns the size of the system colormap. gdk::color_parse()
Creates a GdkColor from a color specification. gdk::cursor_new()
Creates a new GdkCursor. gdk::cursor_new_from_pixmap()
Creates a new GdkCursor using a pixmap. gdk::drag_status()
gdk::draw_arc()
Draws an arc. gdk::draw_gray_image()
gdk::draw_line()
Draws a line. gdk::draw_pixmap()
gdk::draw_point()
gdk::draw_rectangle()
Draws a rectangle. gdk::draw_rgb_32_image()
gdk::draw_rgb_image()
gdk::draw_rgb_image_dithalign()
gdk::draw_string()
Draws a string of text. gdk::draw_text()
gdk::flush()
gdk::font_load()
Loads the given font. gdk::fontset_load()
Loads a selection of fonts described as a fontset. gdk::get_display()
Returns the name of the system. gdk::input_remove()
gdk::pixmap_colormap_create_from_xpm()
gdk::pixmap_colormap_create_from_xpm_d()
gdk::pixmap_create_from_xpm()
Creates a GdkPixmap from an xpm file. gdk::pixmap_create_from_xpm_d()
Creates a GdkPixmap from inline data. gdk::pointer_is_grabbed()
gdk::rgb_gc_set_background()
gdk::rgb_gc_set_foreground()
gdk::rgb_get_cmap()
gdk::rgb_get_visual()
gdk::rgb_xpixel_from_rgb()
gdk::screen_height()
Returns screen height in pixels. gdk::screen_height_mm()
Returns screen height in mm. gdk::screen_width()
Returns screen width in pixels. gdk::screen_width_mm()
Returns screen width in mm. gdk::threads_enter()
gdk::threads_leave()
gdk::visual_get_best()
gdk::visual_get_best_with_both()
gdk::visual_get_best_with_depth()
gdk::visual_get_best_with_type()
gdk::visual_get_system()
Returns the system visual.
This function causes a warning sound to be emitted. The precise nature of the sound is system and setup dependant.
GdkColormap
gdk::colormap_new
(
GdkVisual
visual
, bool allocate);
GdkColormap
gdk::colormap_get_system
(void);
This function creates a new GdkColor structure and fills it according to the color named in the color_spec parameter. The string that is passed as the parameter can be the hex triplet version of the color, e.g. '#FF0000', or the equivalent color name linked in rgb.txt, e.g. 'red'.
Win32 users will not be able to find that file, as it is compiled. There is a good rgb.txt reference page here.
GdkCursor
gdk::cursor_new
(
GdkCursorType
cursor_type
);
GdkCursor
gdk::cursor_new_from_pixmap
(
GdkPixmap
source
,
GdkPixmap
mask
,
GdkColor
fg
,
GdkColor
bg
, int x, int y);
void gdk::drag_status
(
GdkDragContext
context
,
GdkDragAction
action
, int time);
void gdk::draw_arc
(GdkWindow drawable,
GdkGC
gc
, int filled, int x, int y, int width, int height, int angle1, int angle2);
void gdk::draw_gray_image
(GdkWindow drawable,
GdkGC
gc
, int x, int y, int width, int height,
GdkRgbDither
dith
, string buf, int rowstride);
void gdk::draw_line
(GdkWindow drawable,
GdkGC
gc
, int x1, int y1, int x2, int y2);
void gdk::draw_pixmap
(GdkWindow drawable,
GdkGC
gc
, GdkWindow src, int xsrc, int ysrc, int xdest, int ydest, int width, int height);
void gdk::draw_point
(GdkWindow drawable,
GdkGC
gc
, int x, int y);
void gdk::draw_rectangle
(GdkWindow drawable,
GdkGC
gc
, int filled, int x, int y, int width, int height);
void gdk::draw_rgb_32_image
(GdkWindow drawable,
GdkGC
gc
, int x, int y, int width, int height,
GdkRgbDither
dith
, string buf, int rowstride);
void gdk::draw_rgb_image
(GdkWindow drawable,
GdkGC
gc
, int x, int y, int width, int height,
GdkRgbDither
dith
, string rgb_buf, int rowstride);
void
gdk::draw_rgb_image_dithalign
(GdkWindow drawable,
GdkGC
gc
, int x, int y, int width, int height,
GdkRgbDither
dith
, string rgb_buf, int rowstride, int xdith, int ydith);
void gdk::draw_text
(GdkWindow drawable,
GdkFont
font
,
GdkGC
gc
, int x, int y, string text, int text_length);
GdkFont
gdk::font_load
(string font_name);
This method loads a font_name, which must be given in the form of an X Logical Font Description (XLFD).
The XLFD is a way of describing a font that is completely system-independant. It contains 14 fields, most of which can be represented by a wildcard * in order to allow flexibility when a match is being sought - the exceptions are addedstyle, which doesn't need one, and registry, which is the only mandatory field. The description opens with a hyphen, -, and each field is also separated by a hyphen.
If you need more information on fonts than is given here, the full XWindows definition is available online through the relevant XWindows documentation.
foundry xxx (where the font was created. 'unknown' is okay) |
family xxx (e.g. Arial) |
weight xxx (e.g. bold, medium) |
slant x (r - roman, i = italic, o = oblique) |
setwidth xxx (e.g. normal, condensed) |
addedstyle xxx (e.g. serif, sans. Leave blank for none) |
pixelsize N (set either this or pointsize, not both) |
pointsize N (point size, e.g. 120) |
resx N (x res the font was created for, in dots per inch) |
resy N (y res the font was created for, in dots per inch) |
space x (m = monospaced, p = proportional, c = cell) |
averagewidth N (average character width in pixels. 0 if unknown) |
registry xxx (e.g. utf, iso8859 or adobe) |
encoding xxx (e.g. 1 or 2 (for iso8859) or fontspecific) |
A typical font-load would look something like this:
Font information in the XLFD format can be retrieved from any system by utilising the GtkFontSelection or GtkFontSelectionDialog widgets.
Note that there are sizing issues in GdkFont in the version of GTK+ currently used in PHP-GTK under win32. As a result, the point size should always be set in win32 - using the pixel size may give unexpected results.
GdkFont
gdk::fontset_load
(string fontset_name);
This method is used when any of a range of fonts would be acceptable. Usually, that would be when internationalization is an issue. It could also be useful anywhere that some flexibility over the choice of font is needed.
Load in exactly the same way as with gdk::font_load() , separating each of the potential fonts to be used with a comma. The system running the application will use the first font in the set that achieves a match.
In win32, the fontset_load() method is used internally regardless of whether this or gdk::font_load() is called.
GdkPixmap
gdk::pixmap_create_from_xpm
(GdkWindow
window
, [GdkColor
transparent_color
, resource filename]);
gdk::pixmap_create_from_xpm() returns a GdkPixmap that has been created from an existing .xpm file.
The GdkPixmap is the underlying structure that holds the image ready to be displayed in a GtkPixmap. In order to make that image appear on the screen, you will need to use one of the following constructs:
$gdkpixmap = gdk::pixmap_create_from_xpm($main_window->window, null, 'test.xpm'); $image = &new GtkPixmap($gdkpixmap[0], $gdkpixmap[1]); |
list ($gdkpixmap, $mask) = gdk::pixmap_create_from_xpm($gdkwindow, $transparent_color, 'test.xpm'); $image = &new GtkPixmap($gdkpixmap, $mask); |
GdkPixmap
gdk::pixmap_create_from_xpm_d
(GdkWindow
window
, [GdkColor
transparent_color
, array data]);
void gdk::rgb_gc_set_background
(
GdkGC
gc
, int rgb);
void gdk::rgb_gc_set_foreground
(
GdkGC
gc
, int rgb);
GdkColormap
gdk::rgb_get_cmap
(void);
GdkVisual
gdk::rgb_get_visual
(void);
This function returns the screen height in pixels. This can be used in size-setting methods to ensure that containers are sized relative to the screen resolution.
This function returns the screen height in millimeters. This can be used in size-setting methods to ensure that containers are sized relative to the screen size being used.
This function returns the screen width in pixels. This can be used in size-setting methods to ensure that containers are sized relative to the screen resolution.
This function returns the screen width in millimeters. This can be used in size-setting methods to ensure that containers are sized relative to the screen size being used.
GdkVisual
gdk::visual_get_best
(void);
GdkVisual
gdk::visual_get_best_with_both
(int depth,
GdkVisualType
visual_type
);
GdkVisual
gdk::visual_get_best_with_depth
(int depth);
GdkVisual
gdk::visual_get_best_with_type
(
GdkVisualType
visual_type
);
GdkVisual
gdk::visual_get_system
(void);
This function returns the GdkVisual that is currently used by the system.
Table of Contents
GtkAccelFlags | |
Symbolic Name |
Description |
GTK_ACCEL_VISIBLE | Denotes that the accelerator key along with any associated modifiers should be displayed to the right of any text in a GtkAccelLabel. Note that this will always be displayed as upper case, whereas a lower case key value is actually being returned. Use a shift modifier if this is likely to cause a problem for your users. (See also: GdkModifierTypes.) |
GTK_ACCEL_SIGNAL_VISIBLE | This flag does not work, and has been eliminated completely in later versions of GTK+. Use GTK_ACCEL_MASK to achieve the desired effect. |
GTK_ACCEL_LOCKED | Denotes that the accelerator entry is locked. However, this does not seem to work everywhere in the current version of GTK+. Call the GtkWidget method lock_accelerators() on the target widget - usually a GtkMenuItem - in order to ensure accelerator entry locking. |
GTK_ACCEL_MASK | Returns full information for a GtkAccelGroupEntry (the individual element in a GtkAccelGroup array), displaying any modifiers, the accelerator key and the name of the associated signal to the right of any existing GtkAccelLabel text. |
GtkButtonAction | |
Symbolic Name |
Description |
GTK_BUTTON_IGNORED | Denotes that an instance of GtkCList will ignore mouse button events. |
GTK_BUTTON_SELECTS | Denotes that an instance of GtkCList will react to select mouse events. |
GTK_BUTTON_DRAGS | Denotes that an instance of GtkCList will react to drag mouse button events. |
GTK_BUTTON_EXPANDS | Denotes that an instance of GtkCList will react to expand mouse button events. |
GtkCellType | |
Symbolic Name |
Description |
GTK_CELL_EMPTY | Denotes that a cell of an instance of GtkCList should not contain anything. |
GTK_CELL_TEXT | Denotes a cell of an instance of GtkCList should contain text. |
GTK_CELL_PIXMAP | Denotes a cell of an instance of GtkCList should contain a pixel map. |
GTK_CELL_PIXTEXT | Denotes a cell of an instance of GtkCList should contain text and a pixelmap. |
GTK_CELL_WIDGET | Support for a GtkClist containing a widget has not been completed in GTK+, therefore it is not currently available in PHP-GTK itself. |
GtkCTreeExpanderStyle | |
Symbolic Name |
Description |
GTK_CTREE_EXPANDER_NONE | Denotes that this instance of the GtkCTree should have no visible expanders. |
GTK_CTREE_EXPANDER_SQUARE | Denotes that this instance of the GtkCTree should have square expanders. |
GTK_CTREE_EXPANDER_TRIANGLE | Denotes that this instance of the GtkCTree should have triangular expanders. |
GTK_CTREE_EXPANDER_CIRCULAR | Denotes that this instance of the GtkCTree should have circular expanders. |
GtkCTreeExpansionType | |
Symbolic Name |
Description |
GTK_CTREE_EXPANSION_EXPAND | Tells PHP-GTK to expand the current node of this instance of GtkCTree. |
GTK_CTREE_EXPANSION_EXPAND_RECURSIVE | Tells PHP-GTK to expand the current node, and all nodes below it in this instance of the GtkCTree class. |
GTK_CTREE_EXPANSION_COLLAPSE | Tells PHP-GTK to collapse the current node of this instance of GtkCTree. |
GTK_CTREE_EXPANSION_COLLAPSE_RECURSIVE | Tells PHP-GTK to collapse the current node, and all nodes below it in this instance of the GtkCTree class. |
GTK_CTREE_EXPANSION_TOGGLE | Tells PHP-GTK to toggle the current node of this instance of GtkCTree, this will cause an expanded node to collapse and a collapsed node to expand. |
GTK_CTREE_EXPANSION_TOGGLE_RECURSIVE | Tells PHP-GTK to toggle the current node, and all nodes below it in this instance of the GtkCTree class, this will cause an expanded node to collapse and a collapsed node to expand. |
GtkCTreeLineStyle | |
Symbolic Name |
Description |
GTK_CTREE_LINES_NONE | Denotes there should be no lines between the nodes on this instance of GtkCTree. |
GTK_CTREE_LINES_SOLID | Denotes that the lines between the nodes in this instance of GtkCTree should be solid. |
GTK_CTREE_LINES_DOTTED | Denotes that the lines between the nodes in this instance of GtkCTree should be dotted lines. |
GTK_CTREE_LINES_TABBED | Denotes that the lines between the nodes in this instance of GtkCTree should be tabs rather than lines. |
GtkCurveType | |
Symbolic Name |
Description |
GTK_CURVE_TYPE_LINEAR | |
GTK_CURVE_TYPE_SPLINE | |
GTK_CURVE_TYPE_FREE |
GtkDestDefaults | |
Symbolic Name |
Description |
GTK_DEST_DEFAULT_MOTION | |
GTK_DEST_DEFAULT_HIGHLIGHT | |
GTK_DEST_DEFAULT_DROP | |
GTK_DEST_DEFAULT_ALL |
GtkFontFilterType | |
Symbolic Name |
Description |
GTK_FONT_FILTER_BASE | Tells PHP-GTK not to allow the user to change the filter via the Filters page of the GtkFontSelection class. |
GTK_FONT_FILTER_USER | Tells PHP-GTK to allow the user to change the filter via the Filters page of the GtkFontSelection class. |
GtkFontType | |
Symbolic Name |
Description |
GTK_FONT_BITMAP | Instructs PHP-GTK to show bitmap fonts when calling GtkFontSelection:: set_filter() or GtkFontSelectionDialog:: set_filter(). |
GTK_FONT_SCALABLE | Instructs PHP-GTK to show scaleable fonts when calling GtkFontSelection:: set_filter() or GtkFontSelectionDialog:: set_filter(). |
GTK_FONT_SCALABLE_BITMAP | Instructs PHP-GTK to show scaleable bitmap fonts when calling GtkFontSelection:: set_filter() or GtkFontSelectionDialog:: set_filter(). |
GTK_FONT_ALL | Instructs PHP-GTK to show any font that matches any of the above flags when calling GtkFontSelection:: set_filter() or GtkFontSelectionDialog:: set_filter(). |
GtkOrientation | |
Symbolic Name |
Description |
GTK_ORIENTATION_HORIZONTAL | |
GTK_ORIENTATION_VERTICAL |
GtkPackerOptions | |
Symbolic Name |
Description |
GTK_PACK_EXPAND | |
GTK_FILL_X | |
GTK_FILL_Y |
GtkPolicyType | |
Symbolic Name |
Description |
GTK_POLICY_ALWAYS | The scrollbar is always on display. |
GTK_POLICY_AUTOMATIC | The scrollbar is shown only when it is needed. For instance, a GtkText may alter in size according to the amount of text displayed in it. The scrollbar will not be present when the text widget is empty, but will become apparent when the size of the text exceeds the size of the displayable page. |
GTK_POLICY_NEVER | The scrollbar is never shown. |
GtkPositionType | |
Symbolic Name |
Description |
GTK_POS_LEFT | |
GTK_POS_RIGHT | |
GTK_POS_TOP | |
GTK_POS_BOTTOM |
GtkPreviewType | |
Symbolic Name |
Description |
GTK_PREVIEW_COLOR | |
GTK_PREVIEW_GRAYSCALE |
GtkProgressBarStyle | |
Symbolic Name |
Description |
GTK_PROGRESS_CONTINUOUS | The progress bar grows in a smooth, continuous manner. |
GTK_PROGRESS_DISCRETE | The progress bar grows in discrete, visible blocks. |
GtkScrollType | |
Symbolic Name |
Description |
GTK_SCROLL_NONE | The default setting. Indicates that the scrollbar's slider is not moved. |
GTK_SCROLL_STEP_BACKWARD | Sets the scrollbar's slider back one step increment from its current position. The value of the step increment is taken from the underlying GtkAdjustment in the scrollbar. |
GTK_SCROLL_STEP_FORWARD | Sets the scrollbar's slider forward one step increment from its current position. The value of the step increment is taken from the underlying GtkAdjustment in the scrollbar. |
GTK_SCROLL_PAGE_BACKWARD | Sets the scrollbar's slider back one page increment from its current position. The value of the page increment is taken from the underlying GtkAdjustment in the scrollbar. |
GTK_SCROLL_PAGE_FORWARD | Sets the scrollbar's slider forward one page increment from its current position. The value of the page increment is taken from the underlying GtkAdjustment in the scrollbar. |
GTK_SCROLL_JUMP | Sets the scrollbar's slider to the position described in the accompanying float parameter. The range of values are 0 to 1, with the halfway point being 0.5. |
GtkSideType | |
Symbolic Name |
Description |
GTK_SIDE_TOP | |
GTK_SIDE_BOTTOM | |
GTK_SIDE_LEFT | |
GTK_SIDE_RIGHT |
GtkSortType | |
Symbolic Name |
Description |
GTK_SORT_ASCENDING | |
GTK_SORT_DESCENDING |
GtkSpinType | |
Symbolic Name |
Description |
GTK_SPIN_STEP_FORWARD | Spins forward by the value set in the underlying step_increment. This value can be overridden by setting the increment parameter to a value above 0.0. |
GTK_SPIN_STEP_BACKWARD | Spins backward by the value set in the underlying step_increment. This value can be overridden by setting the increment parameter to a value above 0.0. |
GTK_SPIN_PAGE_FORWARD | Spins forward by the value set as page_increment in the underlying GtkAdjustment. The value set in the increment parameter is ignored. |
GTK_SPIN_PAGE_BACKWARD | Spins backward by the value set as page_increment in the underlying GtkAdjustment. The value set in the increment parameter is ignored. |
GTK_SPIN_HOME | Spins to value set as lower bound. The value set in the increment parameter is ignored. |
GTK_SPIN_END | Spins to value set as upper bound. The value set in the increment parameter is ignored. |
GTK_SPIN_USER_DEFINED | Used where the amount of spin is not defined anywhere in the underlying GtkAdjustment. Negative or positive values set in the increment parameter are used to indicate the direction of the spin. |
GtkSubmenuPlacement | |
Symbolic Name |
Description |
GTK_TOP_BOTTOM | |
GTK_LEFT_RIGHT |
GtkToolbarChildType | |
Symbolic Name |
Description |
GTK_TOOLBAR_CHILD_SPACE | |
GTK_TOOLBAR_CHILD_BUTTON | |
GTK_TOOLBAR_CHILD_TOGGLEBUTTON | |
GTK_TOOLBAR_CHILD_RADIOBUTTON | |
GTK_TOOLBAR_CHILD_WIDGET |
GtkToolbarSpaceStyle | |
Symbolic Name |
Description |
GTK_TOOLBAR_SPACE_EMPTY | |
GTK_TOOLBAR_SPACE_LINE |
GtkToolbarStyle | |
Symbolic Name |
Description |
GTK_TOOLBAR_ICONS | |
GTK_TOOLBAR_TEXT | |
GTK_TOOLBAR_BOTH |
GtkTreeViewMode | |
Symbolic Name |
Description |
GTK_TREE_VIEW_LINE | |
GTK_TREE_VIEW_ITEM |
GtkUpdateType | |
Symbolic Name |
Description |
GTK_UPDATE_CONTINUOUS | |
GTK_UPDATE_DISCONTINUOUS | |
GTK_UPDATE_DELAYED |
GtkVisibility | |
Symbolic Name |
Description |
GTK_VISIBILITY_NONE | |
GTK_VISIBILITY_PARTIAL | |
GTK_VISIBILITY_FULL |
GtkWidgetFlags | |
Symbolic Name |
Description |
GTK_TOPLEVEL | Marks a widget as toplevel. This would generally be used internally by GTK. |
GTK_NO_WINDOW | Marks a widget as having no GDK window. This would generally be used internally by GTK, and indicates that the widget is unable to capture GDK events. See also: GtkEventBox. |
GTK_REALIZED | Marks a widget as having been realized, that is, having its GdkWindow instantiated. |
GTK_MAPPED | Marks a widget as having been mapped to the screen. In order to be mapped, a widget must have the GTK_VISIBLE flag set. See also: realize() , map() , show() . |
GTK_VISIBLE | Marks a widget as visible. This is necessary before the widget can be mapped onto the screen. |
GTK_SENSITIVE | Marks a widget as able to react to user input. |
GTK_PARENT_SENSITIVE | Marks the parent of a widget as able to react to user input. |
GTK_CAN_FOCUS | Marks a widget as able to have focus. |
GTK_HAS_FOCUS | Gives a widget focus. |
GTK_CAN_DEFAULT | Marks a widget as able to have default status. This also has the effect of drawing the widget with enough space around it to display its default style. |
GTK_HAS_DEFAULT | Gives a widget default status. The widget will respond directly to keyboard events, and will be drawn in such a way as to make this apparent to the user. |
GTK_HAS_GRAB | Mostly used internally, to ensure that the widget currently having focus is able to grab events relevant to it. Note that flagging a widget in this way requires that the widget is also flagged as sensitive and has its reference count increased. Flagging the widget does not in itself have any bearing on the widget's relationship with other widgets; if you want modality, use GtkWindow's set_modal() method or the static function gtk::grab_add() as appropriate. |
GTK_RC_STYLE | |
GTK_COMPOSITE_CHILD | |
GTK_NO_REPARENT | |
GTK_APP_PAINTABLE | |
GTK_RECEIVES_DEFAULT | A widget flagged in this way will receive the default action and have GTK_HAS_DEFAULT set when it is focused, even if there is a different widget set as default. |
GtkWindowType | |
Symbolic Name |
Description |
GTK_WINDOW_TOPLEVEL | The default window type, describing a toplevel window with a title bar, minimize, maximize and close buttons. Note that these window decorations are provided by the window manager and may vary in appearance or even not exist on some operating systems. |
GTK_WINDOW_DIALOG | A window type that is intended for messages requiring a user response. If a maximize button is displayed, it is greyed out and the maximize function disabled on a dialog window. |
GTK_WINDOW_POPUP | A window type with no window decorations or associated functions. Do not use this to create popup menus; refer instead to the popup() method in GtkMenu, which provides its own internal popup window. |
Table of Contents
GdkCapStyle | |
Symbolic Name |
Description |
GDK_CAP_NOT_LAST | |
GDK_CAP_BUTT | |
GDK_CAP_ROUND | |
GDK_CAP_PROJECTING |
GdkCursorType | |
Symbolic Name |
Description |
GDK_CURSOR_IS_PIXMAP |
GdkDragAction | |
Symbolic Name |
Description |
GDK_ACTION_DEFAULT | |
GDK_ACTION_COPY | |
GDK_ACTION_MOVE | |
GDK_ACTION_LINK | |
GDK_ACTION_PRIVATE | |
GDK_ACTION_ASK |
GdkEventMask | |
Symbolic Name |
Description |
GDK_EXPOSURE_MASK | Setting this flag allows the GDK_EXPOSE event to be captured by a widget's GdkWindow. This causes the widget to emit the expose-event signal. |
GDK_POINTER_MOTION_MASK | Setting this flag allows the GDK_MOTION_NOTIFY event to be captured by a widget's GdkWindow. This makes the widget emit the motion-notify-event signal. |
GDK_POINTER_MOTION_HINT_MASK | This is a special flag allowing a less intensive version of the GDK_POINTER_MOTION_MASK functionality. This can be necessary to avoid a time-lag in processing caused by the sheer volume of GDK_MOTION_NOTIFY events produced by mouse movement, each once of which causes a motion-notify-event signal to be fired by the widget. |
GDK_BUTTON_MOTION_MASK | Allows the GDK_MOTION_NOTIFY events to be picked up by the widget's GdkWindow only while a mouse-button (any) is pressed down. This is a way of limiting the widget's motion-notify-event signal emissions. |
GDK_BUTTON1_MOTION_MASK | Allows the GDK_MOTION_NOTIFY events to be picked up by the widget's GdkWindow only while mouse-button 1 is pressed down - usually that's the left button. This is a way of limiting the widget's motion-notify-event signal emissions. |
GDK_BUTTON2_MOTION_MASK | Allows the GDK_MOTION_NOTIFY events to be picked up by the widget's GdkWindow only while mouse-button 2 is pressed down - usually that's the center button, where it exists. This is a way of limiting the widget's motion-notify-event signal emissions. |
GDK_BUTTON3_MOTION_MASK | Allows the GDK_MOTION_NOTIFY events to be picked up by the widget's GdkWindow only while mouse-button 3 is pressed down - usually that's the right button. This is a way of limiting the widget's motion-notify-event signal emissions. |
GDK_BUTTON_PRESS_MASK | Setting this flag allows the GDK_BUTTON_PRESS events to be captured by a widget's GdkWindow. This makes the widget emit the button-press-event signal. |
GDK_BUTTON_RELEASE_MASK | Setting this flag allows the GDK_BUTTON_RELEASE event to be captured by a widget's GdkWindow. This makes the widget emit the button-release-event signal. |
GDK_KEY_PRESS_MASK | Setting this flag allows the GDK_KEY_PRESS event to be captured by a widget's GdkWindow. This makes the widget emit the key-press-event signal. |
GDK_KEY_RELEASE_MASK | Setting this flag allows the GDK_KEY_RELEASE event to be captured by a widget's GdkWindow. This makes the widget emit the key-release-event signal. |
GDK_ENTER_NOTIFY_MASK | Setting this flag allows the GDK_ENTER_NOTIFY event to be captured by a widget's GdkWindow. This causes the widget to emit the enter-notify-event signal. |
GDK_LEAVE_NOTIFY_MASK | Setting this flag allows the GDK_LEAVE_NOTIFY event to be captured by a widget's GdkWindow. This makes the widget emit the leave-notify-event signal. |
GDK_FOCUS_CHANGE_MASK | Setting this flag allows the GDK_FOCUS_CHANGE event to be captured by a widget's GdkWindow. This makes the widget emit the focus-in-event or focus-out-event signal as appropriate. |
GDK_STRUCTURE_MASK | This flag is set on all new instances of GdkWindow. It allows map, unmap, destroy and configure events to be captured, causing map-event, unmap-event, destroy-event and configure-event signals to be emitted from all windowed widgets. |
GDK_PROPERTY_CHANGE_MASK | Setting this flag allows the GDK_PROPERTY_NOTIFY event to be captured by a widget's GdkWindow. This makes the widget emit the property-notify-event signal. |
GDK_VISIBILITY_NOTIFY_MASK | Setting this flag allows the GDK_VISIBILITY_NOTIFY event to be captured by a widget's GdkWindow. This causes the widget to emit the visibility-notify-event signal. |
GDK_PROXIMITY_IN_MASK | Setting this flag allows the GDK_PROXIMITY_IN event to be captured by a widget's GdkWindow. This causes the widget to emit the proximity-in-event signal. |
GDK_PROXIMITY_OUT_MASK | Setting this flag allows the GDK_PROXIMITY_OUT event to be captured by a widget's GdkWindow. This makes the widget emit the proximity-out-event signal. |
GDK_SUBSTRUCTURE_MASK | Enables the widget's GdkWindow to capture GDK_STRUCTURE_MASK events on any child windows. |
GDK_ALL_EVENTS_MASK | Setting this flag allows any GdkEvent to be captured by a widget's GdkWindow. |
GdkEventType | |
Symbolic Name |
Description |
GDK_NOTHING | A null event. |
GDK_DELETE | This event is triggered when the user clicks on the X button on a decorated window. |
GDK_DESTROY | This event is triggered when a widget is being destroyed. |
GDK_EXPOSE | This event is triggered whenever a widget is exposed to display. That includes all redraws, full or partial. |
GDK_MOTION_NOTIFY | This event is triggered when the mouse is moved. |
GDK_BUTTON_PRESS | This event is triggered when any mouse button is pressed. |
GDK_2BUTTON_PRESS | This event is triggered when there are two mouse button presses in quick succession - a double-click. It is preceded by a second GDK_BUTTON_PRESS and that event's corollary, a GDK_BUTTON_RELEASE. |
GDK_3BUTTON_PRESS | This event is triggered when there are three mouse button presses in quick succession - a treble-click. It is preceded by two GDK_BUTTON_PRESS and one GDK_2BUTTON_PRESS event, as well as the associated GDK_BUTTON_RELEASE events. |
GDK_BUTTON_RELEASE | This event is triggered when any mouse button is released. |
GDK_KEY_PRESS | This event is triggered when any key is pressed. |
GDK_KEY_RELEASE | This event is triggered when any key is released. |
GDK_ENTER_NOTIFY | This event is triggered when the cursor enters the screen area of a widget. |
GDK_LEAVE_NOTIFY | This event is triggered when the cursor leaves the screen area of a widget. |
GDK_FOCUS_CHANGE | This event is triggered whenever there is a keyboard focus change, in or out. |
GDK_CONFIGURE | This event is triggered whenever a widget is drawn, that is, at its first display and on any subsequent redraws caused by moving or resizing. |
GDK_MAP | This event is triggered during the show() process, while the widget is being mapped to the screen. |
GDK_UNMAP | This event is triggered during the hide() process, while the widget is being removed from display. |
GDK_PROPERTY_NOTIFY | |
GDK_SELECTION_CLEAR | |
GDK_SELECTION_REQUEST | |
GDK_SELECTION_NOTIFY | |
GDK_PROXIMITY_IN | |
GDK_PROXIMITY_OUT | |
GDK_DRAG_ENTER | |
GDK_DRAG_LEAVE | |
GDK_DRAG_MOTION | |
GDK_DRAG_STATUS | |
GDK_DROP_START | |
GDK_DROP_FINISHED | |
GDK_CLIENT_EVENT | |
GDK_VISIBILITY_NOTIFY | |
GDK_NO_EXPOSE |
GdkFill | |
Symbolic Name |
Description |
GDK_SOLID | |
GDK_TILED | |
GDK_STIPPLED | |
GDK_OPAQUE_STIPPLED |
GdkFontType | |
Symbolic Name |
Description |
GDK_FONT_FONT | An internal constuct denoting that a single font has been loaded into a GdkFont structure. |
GDK_FONT_FONTSET | An internal construct denoting that several alternate fonts have been loaded into a GdkFont structure. In win32, all GdkFont type queries will return this type. |
GdkInputCondition | |
Symbolic Name |
Description |
GDK_INPUT_READ | |
GDK_INPUT_WRITE | |
GDK_INPUT_EXCEPTION |
GdkJoinStyle | |
Symbolic Name |
Description |
GDK_JOIN_MITER | |
GDK_JOIN_ROUND | |
GDK_JOIN_BEVEL |
GdkLineStyle | |
Symbolic Name |
Description |
GDK_LINE_SOLID | |
GDK_LINE_ON_OFF_DASH | |
GDK_LINE_DOUBLE_DASH |
GdkRgbDither | |
Symbolic Name |
Description |
GDK_RGB_DITHER_NONE | |
GDK_RGB_DITHER_NORMAL | |
GDK_RGB_DITHER_MAX |
GdkSubwindowMode | |
Symbolic Name |
Description |
GDK_CLIP_BY_CHILDREN | |
GDK_INCLUDE_INFERIORS |
GdkVisualType | |
Symbolic Name |
Description |
GDK_VISUAL_STATIC_GRAY | |
GDK_VISUAL_GRAYSCALE | |
GDK_VISUAL_STATIC_COLOR | |
GDK_VISUAL_PSEUDO_COLOR | |
GDK_VISUAL_TRUE_COLOR | |
GDK_VISUAL_DIRECT_COLOR |
Table of Contents
GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkFrame
áááááááááááááááááááááááá`-- GtkScintilla
Constructor
—
GtkScintilla
(void);Methods
find_text()
add_text()
insert_text()
clear_all()
clear_document_style()
get_length()
get_char_at()
get_current_pos()
get_anchor()
get_style_at()
redo()
set_undo_collection()
select_all()
set_save_point()
can_redo()
marker_line_from_handle()
marker_delete_handle()
get_undo_collection()
get_view_ws()
set_view_ws()
position_from_point()
goto_line()
goto_pos()
set_anchor()
get_cur_line()
get_end_styled()
convert_eols()
get_eol_mode()
set_eol_mode()
start_styling()
set_styling()
get_buffered_draw()
set_buffered_draw()
set_tab_width()
get_tab_width()
set_code_page()
set_use_palette()
marker_define()
marker_set_fore()
marker_set_back()
marker_add()
marker_delete()
marker_delete_all()
marker_get()
marker_next()
marker_previous()
set_margin_type_n()
get_margin_type_n()
set_margin_width_n()
get_margin_width_n()
set_margin_mask_n()
get_margin_mask_n()
set_margin_sensitive_n()
get_margin_sensitive_n()
style_clear_all()
style_set_fore()
style_set_back()
style_set_bold()
style_set_italic()
style_set_size()
style_set_font()
style_set_eol_filled()
style_reset_default()
style_set_underline()
style_set_case()
style_set_character_set()
set_sel_fore()
set_sel_back()
set_caret_fore()
clear_all_cmd_keys()
set_styling_ex()
style_set_visible()
get_caret_period()
set_caret_period()
set_word_chars()
begin_undo_action()
end_undo_action()
indic_set_style()
indic_get_style()
indic_set_fore()
indic_get_fore()
set_style_bits()
get_style_bits()
set_line_state()
get_line_state()
get_max_line_state()
get_caret_line_visible()
set_caret_line_visible()
get_caret_line_back()
set_caret_line_back()
autoc_show()
autoc_cancel()
autoc_active()
autoc_pos_start()
autoc_complete()
autoc_stops()
autoc_set_separator()
autoc_get_separator()
autoc_select()
autoc_set_cancel_at_start()
autoc_get_cancel_at_start()
autoc_set_fill_ups()
autoc_set_choose_single()
autoc_get_choose_single()
autoc_set_ignore_case()
autoc_get_ignore_case()
user_list_show()
autoc_set_auto_hide()
autoc_get_auto_hide()
set_indent()
get_indent()
set_use_tabs()
get_use_tabs()
set_line_indentation()
get_line_indentation()
get_line_indent_position()
get_column()
set_h_scroll_bar()
get_h_scroll_bar()
set_indentation_guides()
get_indentation_guides()
set_highlight_guide()
get_highlight_guide()
get_line_end_position()
get_code_page()
get_caret_fore()
get_use_palette()
get_read_only()
set_current_pos()
set_selection_start()
get_selection_start()
set_selection_end()
get_selection_end()
set_print_magnification()
get_print_magnification()
set_print_colour_mode()
get_print_colour_mode()
get_first_visible_line()
get_line()
get_line_count()
set_margin_left()
get_margin_left()
set_margin_right()
get_margin_right()
get_modify()
set_sel()
get_sel_text()
hide_selection()
point_x_from_position()
point_y_from_position()
line_from_position()
position_from_line()
line_scroll()
scroll_caret()
replace_sel()
set_read_only()
null()
can_paste()
can_undo()
empty_undo_buffer()
undo()
cut()
copy()
paste()
clear()
set_text()
get_text()
get_text_length()
get_direct_function()
get_direct_pointer()
set_overtype()
get_overtype()
set_caret_width()
get_caret_width()
set_target_start()
get_target_start()
set_target_end()
get_target_end()
replace_target()
replace_target_re()
search_in_target()
set_search_flags()
get_search_flags()
call_tip_show()
call_tip_cancel()
call_tip_active()
call_tip_pos_start()
call_tip_set_hlt()
call_tip_set_back()
visible_from_doc_line()
doc_line_from_visible()
set_fold_level()
get_fold_level()
get_last_child()
get_fold_parent()
show_lines()
hide_lines()
get_line_visible()
set_fold_expanded()
get_fold_expanded()
toggle_fold()
ensure_visible()
set_fold_flags()
set_tab_indents()
get_tab_indents()
set_backspace_unindents()
get_backspace_unindents()
line_down()
line_down_extend()
line_up()
line_up_extend()
char_left()
char_left_extend()
char_right()
char_right_extend()
word_left()
word_left_extend()
word_right()
word_right_extend()
home()
home_extend()
line_end()
line_end_extend()
document_start()
document_start_extend()
document_end()
document_end_extend()
page_up()
page_up_extend()
page_down()
page_down_extend()
edit_toggle_overtype()
cancel()
delete_back()
tab()
back_tab()
new_line()
form_feed()
v_c_home()
v_c_home_extend()
zoom_in()
zoom_out()
del_word_left()
del_word_right()
line_cut()
line_delete()
line_transpose()
lower_case()
upper_case()
line_scroll_down()
line_scroll_up()
move_caret_inside_view()
line_length()
brace_highlight()
brace_bad_light()
brace_match()
get_view_eol()
set_view_eol()
get_doc_pointer()
set_doc_pointer()
set_mod_event_mask()
get_edge_column()
set_edge_column()
get_edge_mode()
set_edge_mode()
get_edge_colour()
set_edge_colour()
search_anchor()
search_next()
search_prev()
set_caret_policy()
lines_on_screen()
use_pop_up()
selection_is_rectangle()
set_zoom()
get_zoom()
create_document()
add_ref_document()
release_document()
get_mod_event_mask()
set_focus()
get_focus()
set_status()
get_status()
set_mouse_down_captures()
get_mouse_down_captures()
set_cursor()
get_cursor()
word_part_left()
word_part_left_extend()
word_part_right()
word_part_right_extend()
set_visible_policy()
del_line_left()
del_line_right()
grab_focus()
start_record()
stop_record()
set_lexer()
get_lexer()
colourise()
set_property()
set_keywords()
set_lexer_language()
GtkScintilla
(void);
Table of Contents
Constructor
—
GladeXML
(string fname, [string root = NULL, [string domain = NULL]]);
GladeXML
(string fname, [string root = NULL, [string domain = NULL]]);
GladeXML xml_new_from_memory
(string buffer, int size, string root, string domain);
Version 1.1, March 2000
Copyright
Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
PREAMBLE
The purpose of this License is to make a manual, textbook, or other written document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.
This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.
APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you".
A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.
A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (For example, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.
The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License.
The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License.
A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. A copy that is not "Transparent" is called "Opaque".
Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML designed for human modification. Opaque formats include PostScript, PDF, proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML produced by some word processors for output purposes only.
The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text.
VERBATIM COPYING
You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly display copies.
COPYING IN QUANTITY
If you publish printed copies of the Document numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document, free of added material, which the general network-using public has access to download anonymously at no charge using public-standard network protocols. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.
MODIFICATIONS
You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has less than five).
C. State on the Title page the name of the publisher of the Modified Version, as the publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice.
H. Include an unaltered copy of this License.
I. Preserve the section entitled "History", and its title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
K. In any section entitled "Acknowledgements" or "Dedications", preserve the section's title, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
M. Delete any section entitled "Endorsements". Such a section may not be included in the Modified Version.
N. Do not retitle any existing section as "Endorsements" or to conflict in title with any Invariant Section.
If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles.
You may add a section entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.
COMBINING DOCUMENTS
You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice.
The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections entitled "History" in the various original documents, forming one section entitled "History"; likewise combine any sections entitled "Acknowledgements", and any sections entitled "Dedications". You must delete all sections entitled "Endorsements."
COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.
AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, does not as a whole count as a Modified Version of the Document, provided no compilation copyright is claimed for the compilation. Such a compilation is called an "aggregate", and this License does not apply to the other self-contained works thus compiled with the Document, on account of their being thus compiled, if they are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one quarter of the entire aggregate, the Document's Cover Texts may be placed on covers that surround only the Document within the aggregate. Otherwise they must appear on covers around the whole aggregate.
TRANSLATION
Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License provided that you also include the original English version of this License. In case of a disagreement between the translation and the original English version of this License, the original English version will prevail.
TERMINATION
You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.