PHP-GTK Documentation

PHP-GTK Authors
Andrei Zmievski
PHP-GTK Manual
James Moore
et al.

Edited By

James Moore

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

PHP-GTK Userguide
I Introduction
1 Introduction to PHP-GTK
Introduction
What is PHP-GTK?
What is GTK+?
A History of GTK+
What does GTK+ do?
What is PHP?
A History of PHP
What does PHP do?
PHP-GTK Acknowledgements
2 Widgets and Containers
Introduction
What are Widgets?
What are Containers?
3 Signals and Callbacks
What are Signals?
What are Callbacks?
Signal Inheritance
Connecting Signals
Simple Connections
Multiple Connections
Using Custom Parameters
Passing Custom Data as a Parameter
Using the connect_object* methods
Signals and Events
II Getting Started
1 Installation
Getting The Latest Version
Installing PHP-GTK Under Windows
Downloading PHP-GTK
Layout of the Binary Distribution
How to install
How to use PHP-GTK
Installing PHP-GTK Under Unix
PHP-GTK Tutorials
1 Hello World Tutorial
PHP-GTK Reference
I. GTK Classes
GtkAccelGroup
A structure containing accelerator key data.
GtkAccelLabel
A label that can display an accelerator key next to the text.
GtkAdjustment
Represents an adjustable bounded value.
GtkAlignment
A container that controls the alignment and scale of its child.
GtkArrow
An arrow pointing in one of the four cardinal directions.
GtkAspectFrame
A frame that constrains its child to a particular aspect ratio.
GtkBin
Base class for containers with just one child.
GtkBox
Base class for box containers.
GtkBoxChild
Helper class for GtkBox.
GtkButton
A container widget that emits a signal when clicked on.
GtkButtonBox
Base class for GtkHButtonBox and GtkVButtonBox.
GtkCalendar
A calendar offering dates that can be selected and marked.
GtkCheckButton
Button that displays a discrete toggle indicator.
GtkCheckMenuItem
Menu item with a toggle indicator.
GtkCList
A multi-columned scrolling list widget.
GtkCListRow
GtkColorSelection
Widget that allows for selection of a color.
GtkColorSelectionDialog
Standard dialog box for selecting a color.
GtkCombo
Text entry field with a dropdown list.
GtkContainer
Base class for all container widgets.
GtkCTree
Widget that displays a hierarchical tree.
GtkCTreeNode
GtkCurve
Widget that allows editing of a curve.
GtkData
Abstract base class for objects containing data.
GtkDialog
Widget that eases creation of popup dialogs.
GtkDrawingArea
Widget for custom user interface elements.
GtkEditable
Base class for text-editing widgets.
GtkEntry
A single line text entry field.
GtkEventBox
Widget used to capture events for widgets with no GdkWindow.
GtkFileSelection
Widget for selecting a file or a directory.
GtkFixed
Container that retains the sizes and positions of its children.
GtkFixedChild
Helper class for GtkFixed.
GtkFontSelection
Widget for selecting fonts.
GtkFontSelectionDialog
Standard dialog box for selecting fonts.
GtkFrame
Container with a decorative frame and an optional label.
GtkGammaCurve
A subclass of GtkCurve for editing gamma curves.
GtkHandleBox
Widget for detachable window portions.
GtkHBox
Horizontal box container.
GtkHButtonBox
Container for arranging a group of buttons horizontally.
GtkHPaned
Container with two panes arranged horizontally.
GtkHRuler
Horizontal ruler.
GtkHScale
Horizontal slider widget for selecting a value from a range.
GtkHScrollbar
Horizontal scrollbar.
GtkHSeparator
Horizontal separator.
GtkImage
Widget for displaying a graphical image.
GtkInputDialog
Standard dialog for configuring input devices.
GtkInvisible
Internally used widget which is not displayed.
GtkItem
Abstract base class for GtkMenuItem, GtkListItem, and GtkTreeItem.
GtkItemFactory
GtkLabel
Widget that displays a small amount of text.
GtkLayout
Scrollable widget allowing multiple children in fixed positions.
GtkList
Widget displaying a list of selectable items.
GtkListItem
A single element in a GtkList.
GtkMenu
Popup container for menu items.
GtkMenuBar
Horizontal container for menu items.
GtkMenuItem
Widget used for item in menus.
GtkMenuShell
Abstract base class for menu objects.
GtkMisc
Base class for widgets having their own alignment and padding.
GtkNotebook
Widget that displays a set of pages with tabs.
GtkObject
The base class of the PHP-GTK class hierachy.
GtkOptionMenu
Widget used to choose from a list of valid choices.
GtkPacker
GtkPaned
Base class for widgets with two adjustable panes.
GtkPixmap
Widget displaying a graphical image or icon.
GtkPlug
Toplevel widget for embedding into other processes.
GtkPreview
Widget to display RGB or grayscale data.
GtkProgress
Base class for GtkProgressBar.
GtkProgressBar
Widget that provides a visual indication of an operation's progress.
GtkRadioButton
Button that is part of a group, only one of which may be selected.
GtkRadioMenuItem
Menu item that is part of a group, only one of which may be selected.
GtkRange
GtkRuler
Base class for horizontal and vertical rulers.
GtkScale
Base class for GtkHScale and GtkVScale.
GtkScrollbar
Base class for GtkHScrollbar and GtkVScrollbar.
GtkScrolledWindow
Adds scrollbars to its child widget.
GtkSelectionData
GtkSeparator
Base class for GtkHSeparator and GtkVSeparator.
GtkSocket
Container for widgets from other processes.
GtkSpinButton
Widget offering masked numerical entry and/or selection.
GtkStatusbar
Widget that provides a way to report messages of minor importance.
GtkStyle
A class that determines the appearance of widgets.
GtkTable
Container that provides a flexible grid for packing its children.
GtkTableChild
Helper class for GtkTable.
GtkTearoffMenuItem
Menu item used to tear off and reattach its menu.
GtkText
Editable text-display widget.
GtkTipsQuery
Displays help about widgets in the user interface.
GtkToggleButton
Button that retains its state.
GtkToolbar
Container that creates bars of buttons and other widgets.
GtkTooltips
Adds tooltips to other widgets.
GtkTree
Widget for displaying hierarchical information.
GtkTreeItem
GtkVBox
Vertical box container.
GtkVButtonBox
Container for arranging a group of buttons vertically.
GtkViewport
Provides scrolling capability for non-scrolling aware widgets.
GtkVPaned
Container with two panes arranged vertically.
GtkVRuler
Vertical ruler.
GtkVScale
Vertical slider widget for selecting a value from a range.
GtkVScrollbar
Vertical scrollbar.
GtkVSeparator
Vertical separator.
GtkWidget
Base class for user interface elements.
GtkWindow
Widget that provides windows for an application.
Misc GTK Functions
II. GDK Classes
GdkAtom
GdkBitmap
GdkColor
A structure that holds a defined color.
GdkColormap
GdkCursor
GdkDragContext
GdkFont
Structure holding font information.
GdkGC
A structure that contains graphics information.
GdkPixmap
GdkVisual
GdkWindow
Misc GDK Functions
III. GTK Enums
GtkAccelFlags
GtkAnchorType
GtkArrowType
GtkAttachOptions
GtkButtonAction
GtkButtonBoxStyle
GtkCalendarDisplayOptions
GtkCellType
GtkCornerType
GtkCTreeExpanderStyle
GtkCTreeExpansionType
GtkCTreeLineStyle
GtkCurveType
GtkDestDefaults
GtkDirectionType
GtkFontFilterType
GtkFontType
GtkJustification
GtkObjectFlags
GtkOrientation
GtkPackerOptions
GtkPackType
GtkPolicyType
GtkPositionType
GtkPreviewType
GtkProgressBarOrientation
GtkProgressBarStyle
GtkReliefStyle
GtkResizeMode
GtkScrollType
GtkSelectionMode
GtkShadowType
GtkSideType
GtkSortType
GtkSpinButtonUpdatePolicy
GtkSpinType
GtkStateType
GtkSubmenuPlacement
GtkToolbarChildType
GtkToolbarSpaceStyle
GtkToolbarStyle
GtkTreeViewMode
GtkUpdateType
GtkVisibility
GtkWidgetFlags
GtkWindowPosition
GtkWindowType
IV. GDK Enums
GdkCapStyle
GdkCursorType
GdkDragAction
GdkEventMask
GdkEventType
GdkFill
GdkFontType
GdkFunction
GdkInputCondition
GdkJoinStyle
GdkLineStyle
GdkModifierType
GdkRgbDither
GdkSubwindowMode
GdkVisualType
V. Scintilla Classes
GtkScintilla
VI. LibGlade Classes
GladeXML
Misc Glade Functions
VII. Sqpane Classes
GtkSQPane
GNU Free Documentation License
A PHP-GTK Credits

Preface

Introduction to Manual

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.

About the Manual

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.

PHP-GTK Userguide


Introduction

Chapter 1. Introduction to PHP-GTK

Introduction

This section of the manual will introduce you to the ideas and the technologies behind PHP-GTK as well as its uses.

What is PHP-GTK?

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.

What is GTK+?

A History of GTK+

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.

What does GTK+ do?

GTK+ is a set of libraries written in C to create graphical user interfaces. It has an object oriented architecture developed in three libraries:

  • GLib

    provides various tools for use when programming with GTK+.

  • GDK

    abstracts the low-level window drawing functions.

  • GTK

    provides a set of widgets for use when creating your GUI.

What is PHP?

A History of PHP

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.)

What does PHP do?

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.

PHP-GTK Acknowledgements

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.

Andrei Zmievski - Feb 2001

Chapter 2. Widgets and Containers

Introduction

This chapter will explain some of the concepts behind GTK+ and how you can use them.

What are Widgets?

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:

  1. Creation

    In PHP-GTK this is done by creating an object, e.g. $window = &new GtkWindow();

  2. 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);

  3. 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.

  4. Display

    This describes whether the widget is on display to the user. It is started by calling $widget->show(); and finished by $widget->hide();.

  5. Destruction

    This occurs when the gtk::main_quit() function is called. All actions that are necessary here are handled internally.

What are Containers?

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.

Chapter 3. Signals and Callbacks

What are Signals?

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.

What are Callbacks?

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.

Signal Inheritance

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.

Connecting Signals

Simple Connections

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

     $button->connect();
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.

Multiple Connections

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();
     
In the above example we connect two functions to a button's clicked signal. The first call to the connect() method connects the clicked signal to the first() function, the second call connects the clicked signal to the second() function.

The output from this program would be:
     
First function has been called.
Second function has been called.
    

Using Custom Parameters

Passing Custom Data as a Parameter

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();
     
In the above code you can see that we pass not only the $button variable, an instance of GtkButton, to the clicked callback but also the $window variable, an instance of the GtkWindow class. This allows us to call the destroy() method on the window.

Note

You can have as many custom parameters as you want.

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();
     

Using the connect_object* methods

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();
     
This could be called on any static function or method by using the gtkobject::method syntax expressed as an array.

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() .

Signals and Events

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.

Note

It is not possible to connect a callback function to a GdkEvent directly.

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();
    

Getting Started

Chapter 1. Installation

Getting The Latest Version

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.

Installing PHP-GTK Under Windows

Downloading PHP-GTK

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.

Layout of the Binary Distribution

The binary distribution of PHP-GTK contains this structure:

  • \php4 -> PHP 4.1.1 and PHP-GTK 0.5.0 binary files

  • \winnt -> the default php.ini file

  • \winnt\system32 -> GTK+ binaries used by the extension

  • \test -> a few samples to demonstrate PHP-GTK usage

  • README.TXT

How to install

  1. 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.

  2. 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.

  3. 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.

  4. Copy \test to the location where you want to run your scripts (e.g. c:\php4\test).

How to use PHP-GTK

PHP-GTK applications can be started from the command line (or a batch file) with this syntax: c:\php4\php -q c:\path\to\php-gtk\script.php

Installing PHP-GTK Under Unix

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:

  • PHP version 4.1.1 or later

  • 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.

PHP-GTK Tutorials


Table of Contents

1 Hello World Tutorial

Chapter 1. Hello World Tutorial

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();
   

Example 1.1. Loading PHP-GTK

     
if (!class_exists('gtk')) {
    if (strtoupper(substr(PHP_OS, 0,3) == 'WIN'))
    dl('php_gtk.dll');
 else
    dl('php_gtk.so');
}
   
These first few lines check to see if the PHP-GTK extension is already available, and loads it if it isn't. This is done by the dl('php_gtk.dll'); or dl('php_gtk.so'); statements on Windows and Linux respectively.

Example 1.2. The delete_event() function

     
function delete_event()
{
    return false;
}
   
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();
}
   
The shutdown() function is registered as a handler for the destroy signal. The function prints the text "Shutting down...\n" to the console and then calls the static function gtk::main_quit().

Example 1.4. The hello() function

     
function hello()
{
    global $window;
    print "Hello World!\n";
    $window->destroy();
}
   
The hello() function is registered as a handler for the clicked signal on the button. It globalises the $window variable so it can access the instance of GtkWindow created further down the script. It then prints the text "Hello World" to the console before calling the destroy() method on the window, which in turn fires the destroy signal, which in turn calls the shutdown() function.

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);
   
The next four lines set up the window itself. Firstly we create an instance of GtkWindow. Once this has been done successfully, we call the connect() method from the window in order to register the shutdown() function as the handler for the destroy signal and the delete_event() function as the handler for the delete-event signal. Finally, we call the set_border_width() function to set a 10-pixel wide border on the instance of GtkWindow that we just created.

Example 1.6. Setting up the Button

           
$button = &new GtkButton('Hello World!');
$button->connect('clicked', 'hello');
$window->add($button);

$window->show_all();
   
These three lines of the script create and set up the button. In the first line of the above code snippet we create a new instance of the GtkButton widget. The argument to the constructor is the text we want the button to display - in this case "Hello World!". We then call the connect() method to register the hello() function we defined earlier, as the handler for the clicked signal. Finally we add the button to the window we previously created by calling the GtkContainer method add() from our containing $window, and then display everything contained by $window (and its child widget, $button) by calling the show_all() method, also from our instance of GtkWindow.

Example 1.7. The call to gtk::main

     
gtk::main();
   
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.

PHP-GTK Reference


Table of Contents

I. GTK Classes
GtkAccelGroup
A structure containing accelerator key data.
GtkAccelLabel
A label that can display an accelerator key next to the text.
GtkAdjustment
Represents an adjustable bounded value.
GtkAlignment
A container that controls the alignment and scale of its child.
GtkArrow
An arrow pointing in one of the four cardinal directions.
GtkAspectFrame
A frame that constrains its child to a particular aspect ratio.
GtkBin
Base class for containers with just one child.
GtkBox
Base class for box containers.
GtkBoxChild
Helper class for GtkBox.
GtkButton
A container widget that emits a signal when clicked on.
GtkButtonBox
Base class for GtkHButtonBox and GtkVButtonBox.
GtkCalendar
A calendar offering dates that can be selected and marked.
GtkCheckButton
Button that displays a discrete toggle indicator.
GtkCheckMenuItem
Menu item with a toggle indicator.
GtkCList
A multi-columned scrolling list widget.
GtkCListRow
GtkColorSelection
Widget that allows for selection of a color.
GtkColorSelectionDialog
Standard dialog box for selecting a color.
GtkCombo
Text entry field with a dropdown list.
GtkContainer
Base class for all container widgets.
GtkCTree
Widget that displays a hierarchical tree.
GtkCTreeNode
GtkCurve
Widget that allows editing of a curve.
GtkData
Abstract base class for objects containing data.
GtkDialog
Widget that eases creation of popup dialogs.
GtkDrawingArea
Widget for custom user interface elements.
GtkEditable
Base class for text-editing widgets.
GtkEntry
A single line text entry field.
GtkEventBox
Widget used to capture events for widgets with no GdkWindow.
GtkFileSelection
Widget for selecting a file or a directory.
GtkFixed
Container that retains the sizes and positions of its children.
GtkFixedChild
Helper class for GtkFixed.
GtkFontSelection
Widget for selecting fonts.
GtkFontSelectionDialog
Standard dialog box for selecting fonts.
GtkFrame
Container with a decorative frame and an optional label.
GtkGammaCurve
A subclass of GtkCurve for editing gamma curves.
GtkHandleBox
Widget for detachable window portions.
GtkHBox
Horizontal box container.
GtkHButtonBox
Container for arranging a group of buttons horizontally.
GtkHPaned
Container with two panes arranged horizontally.
GtkHRuler
Horizontal ruler.
GtkHScale
Horizontal slider widget for selecting a value from a range.
GtkHScrollbar
Horizontal scrollbar.
GtkHSeparator
Horizontal separator.
GtkImage
Widget for displaying a graphical image.
GtkInputDialog
Standard dialog for configuring input devices.
GtkInvisible
Internally used widget which is not displayed.
GtkItem
Abstract base class for GtkMenuItem, GtkListItem, and GtkTreeItem.
GtkItemFactory
GtkLabel
Widget that displays a small amount of text.
GtkLayout
Scrollable widget allowing multiple children in fixed positions.
GtkList
Widget displaying a list of selectable items.
GtkListItem
A single element in a GtkList.
GtkMenu
Popup container for menu items.
GtkMenuBar
Horizontal container for menu items.
GtkMenuItem
Widget used for item in menus.
GtkMenuShell
Abstract base class for menu objects.
GtkMisc
Base class for widgets having their own alignment and padding.
GtkNotebook
Widget that displays a set of pages with tabs.
GtkObject
The base class of the PHP-GTK class hierachy.
GtkOptionMenu
Widget used to choose from a list of valid choices.
GtkPacker
GtkPaned
Base class for widgets with two adjustable panes.
GtkPixmap
Widget displaying a graphical image or icon.
GtkPlug
Toplevel widget for embedding into other processes.
GtkPreview
Widget to display RGB or grayscale data.
GtkProgress
Base class for GtkProgressBar.
GtkProgressBar
Widget that provides a visual indication of an operation's progress.
GtkRadioButton
Button that is part of a group, only one of which may be selected.
GtkRadioMenuItem
Menu item that is part of a group, only one of which may be selected.
GtkRange
GtkRuler
Base class for horizontal and vertical rulers.
GtkScale
Base class for GtkHScale and GtkVScale.
GtkScrollbar
Base class for GtkHScrollbar and GtkVScrollbar.
GtkScrolledWindow
Adds scrollbars to its child widget.
GtkSelectionData
GtkSeparator
Base class for GtkHSeparator and GtkVSeparator.
GtkSocket
Container for widgets from other processes.
GtkSpinButton
Widget offering masked numerical entry and/or selection.
GtkStatusbar
Widget that provides a way to report messages of minor importance.
GtkStyle
A class that determines the appearance of widgets.
GtkTable
Container that provides a flexible grid for packing its children.
GtkTableChild
Helper class for GtkTable.
GtkTearoffMenuItem
Menu item used to tear off and reattach its menu.
GtkText
Editable text-display widget.
GtkTipsQuery
Displays help about widgets in the user interface.
GtkToggleButton
Button that retains its state.
GtkToolbar
Container that creates bars of buttons and other widgets.
GtkTooltips
Adds tooltips to other widgets.
GtkTree
Widget for displaying hierarchical information.
GtkTreeItem
GtkVBox
Vertical box container.
GtkVButtonBox
Container for arranging a group of buttons vertically.
GtkViewport
Provides scrolling capability for non-scrolling aware widgets.
GtkVPaned
Container with two panes arranged vertically.
GtkVRuler
Vertical ruler.
GtkVScale
Vertical slider widget for selecting a value from a range.
GtkVScrollbar
Vertical scrollbar.
GtkVSeparator
Vertical separator.
GtkWidget
Base class for user interface elements.
GtkWindow
Widget that provides windows for an application.
Misc GTK Functions
II. GDK Classes
GdkAtom
GdkBitmap
GdkColor
A structure that holds a defined color.
GdkColormap
GdkCursor
GdkDragContext
GdkFont
Structure holding font information.
GdkGC
A structure that contains graphics information.
GdkPixmap
GdkVisual
GdkWindow
Misc GDK Functions
III. GTK Enums
GtkAccelFlags
GtkAnchorType
GtkArrowType
GtkAttachOptions
GtkButtonAction
GtkButtonBoxStyle
GtkCalendarDisplayOptions
GtkCellType
GtkCornerType
GtkCTreeExpanderStyle
GtkCTreeExpansionType
GtkCTreeLineStyle
GtkCurveType
GtkDestDefaults
GtkDirectionType
GtkFontFilterType
GtkFontType
GtkJustification
GtkObjectFlags
GtkOrientation
GtkPackerOptions
GtkPackType
GtkPolicyType
GtkPositionType
GtkPreviewType
GtkProgressBarOrientation
GtkProgressBarStyle
GtkReliefStyle
GtkResizeMode
GtkScrollType
GtkSelectionMode
GtkShadowType
GtkSideType
GtkSortType
GtkSpinButtonUpdatePolicy
GtkSpinType
GtkStateType
GtkSubmenuPlacement
GtkToolbarChildType
GtkToolbarSpaceStyle
GtkToolbarStyle
GtkTreeViewMode
GtkUpdateType
GtkVisibility
GtkWidgetFlags
GtkWindowPosition
GtkWindowType
IV. GDK Enums
GdkCapStyle
GdkCursorType
GdkDragAction
GdkEventMask
GdkEventType
GdkFill
GdkFontType
GdkFunction
GdkInputCondition
GdkJoinStyle
GdkLineStyle
GdkModifierType
GdkRgbDither
GdkSubwindowMode
GdkVisualType
V. Scintilla Classes
GtkScintilla
VI. LibGlade Classes
GladeXML
Misc Glade Functions
VII. Sqpane Classes
GtkSQPane

Table of Contents

GtkAccelGroup
A structure containing accelerator key data.
GtkAccelLabel
A label that can display an accelerator key next to the text.
GtkAdjustment
Represents an adjustable bounded value.
GtkAlignment
A container that controls the alignment and scale of its child.
GtkArrow
An arrow pointing in one of the four cardinal directions.
GtkAspectFrame
A frame that constrains its child to a particular aspect ratio.
GtkBin
Base class for containers with just one child.
GtkBox
Base class for box containers.
GtkBoxChild
Helper class for GtkBox.
GtkButton
A container widget that emits a signal when clicked on.
GtkButtonBox
Base class for GtkHButtonBox and GtkVButtonBox.
GtkCalendar
A calendar offering dates that can be selected and marked.
GtkCheckButton
Button that displays a discrete toggle indicator.
GtkCheckMenuItem
Menu item with a toggle indicator.
GtkCList
A multi-columned scrolling list widget.
GtkCListRow
GtkColorSelection
Widget that allows for selection of a color.
GtkColorSelectionDialog
Standard dialog box for selecting a color.
GtkCombo
Text entry field with a dropdown list.
GtkContainer
Base class for all container widgets.
GtkCTree
Widget that displays a hierarchical tree.
GtkCTreeNode
GtkCurve
Widget that allows editing of a curve.
GtkData
Abstract base class for objects containing data.
GtkDialog
Widget that eases creation of popup dialogs.
GtkDrawingArea
Widget for custom user interface elements.
GtkEditable
Base class for text-editing widgets.
GtkEntry
A single line text entry field.
GtkEventBox
Widget used to capture events for widgets with no GdkWindow.
GtkFileSelection
Widget for selecting a file or a directory.
GtkFixed
Container that retains the sizes and positions of its children.
GtkFixedChild
Helper class for GtkFixed.
GtkFontSelection
Widget for selecting fonts.
GtkFontSelectionDialog
Standard dialog box for selecting fonts.
GtkFrame
Container with a decorative frame and an optional label.
GtkGammaCurve
A subclass of GtkCurve for editing gamma curves.
GtkHandleBox
Widget for detachable window portions.
GtkHBox
Horizontal box container.
GtkHButtonBox
Container for arranging a group of buttons horizontally.
GtkHPaned
Container with two panes arranged horizontally.
GtkHRuler
Horizontal ruler.
GtkHScale
Horizontal slider widget for selecting a value from a range.
GtkHScrollbar
Horizontal scrollbar.
GtkHSeparator
Horizontal separator.
GtkImage
Widget for displaying a graphical image.
GtkInputDialog
Standard dialog for configuring input devices.
GtkInvisible
Internally used widget which is not displayed.
GtkItem
Abstract base class for GtkMenuItem, GtkListItem, and GtkTreeItem.
GtkItemFactory
GtkLabel
Widget that displays a small amount of text.
GtkLayout
Scrollable widget allowing multiple children in fixed positions.
GtkList
Widget displaying a list of selectable items.
GtkListItem
A single element in a GtkList.
GtkMenu
Popup container for menu items.
GtkMenuBar
Horizontal container for menu items.
GtkMenuItem
Widget used for item in menus.
GtkMenuShell
Abstract base class for menu objects.
GtkMisc
Base class for widgets having their own alignment and padding.
GtkNotebook
Widget that displays a set of pages with tabs.
GtkObject
The base class of the PHP-GTK class hierachy.
GtkOptionMenu
Widget used to choose from a list of valid choices.
GtkPacker
GtkPaned
Base class for widgets with two adjustable panes.
GtkPixmap
Widget displaying a graphical image or icon.
GtkPlug
Toplevel widget for embedding into other processes.
GtkPreview
Widget to display RGB or grayscale data.
GtkProgress
Base class for GtkProgressBar.
GtkProgressBar
Widget that provides a visual indication of an operation's progress.
GtkRadioButton
Button that is part of a group, only one of which may be selected.
GtkRadioMenuItem
Menu item that is part of a group, only one of which may be selected.
GtkRange
GtkRuler
Base class for horizontal and vertical rulers.
GtkScale
Base class for GtkHScale and GtkVScale.
GtkScrollbar
Base class for GtkHScrollbar and GtkVScrollbar.
GtkScrolledWindow
Adds scrollbars to its child widget.
GtkSelectionData
GtkSeparator
Base class for GtkHSeparator and GtkVSeparator.
GtkSocket
Container for widgets from other processes.
GtkSpinButton
Widget offering masked numerical entry and/or selection.
GtkStatusbar
Widget that provides a way to report messages of minor importance.
GtkStyle
A class that determines the appearance of widgets.
GtkTable
Container that provides a flexible grid for packing its children.
GtkTableChild
Helper class for GtkTable.
GtkTearoffMenuItem
Menu item used to tear off and reattach its menu.
GtkText
Editable text-display widget.
GtkTipsQuery
Displays help about widgets in the user interface.
GtkToggleButton
Button that retains its state.
GtkToolbar
Container that creates bars of buttons and other widgets.
GtkTooltips
Adds tooltips to other widgets.
GtkTree
Widget for displaying hierarchical information.
GtkTreeItem
GtkVBox
Vertical box container.
GtkVButtonBox
Container for arranging a group of buttons vertically.
GtkViewport
Provides scrolling capability for non-scrolling aware widgets.
GtkVPaned
Container with two panes arranged vertically.
GtkVRuler
Vertical ruler.
GtkVScale
Vertical slider widget for selecting a value from a range.
GtkVScrollbar
Vertical scrollbar.
GtkVSeparator
Vertical separator.
GtkWidget
Base class for user interface elements.
GtkWindow
Widget that provides windows for an application.
Misc GTK Functions

GtkAccelGroup

A structure containing accelerator key data.

Object Hierarchy

Object Properties and Methods

Constructor

— Provides the structure for a hash table of accelerator key information.

Methods

lock()
Locks accelerator group information.
unlock()
Unlocks accelerator group information.

Description

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 Constructor

Although not a part of the GTK object hierarchy, GtkAccelGroup can be constructed in the same way as most GTK classes, i.e.

     
$accelgroup = &new GtkAccelGroup();
     

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.

GtkAccelGroup::lock

void lock(void);

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() .

GtkAccelGroup::unlock

void unlock(void);

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() .

GtkAccelLabel

A label that can display an accelerator key next to the text.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkMisc
áááááááááááá`-- GtkLabel
áááááááááááááááááá`-- GtkAccelLabel

Object Properties and Methods

Constructor

GtkAccelLabel (string string);

— Constructs a label for displaying accelerator information.

Methods

get_accel_width()
Sets width to accommodate accelerator information.
set_accel_widget()
Associates accelerator label with specified widget.
refetch()
Recreates accelerator information.

Description

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:

     
$accel_label = $menu_item->child;
     
You will then be able to call most of the methods available to a new instance of a GtkAccelLabel.

GtkAccelLabel Constructor

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() .

GtkAccelLabel::get_accel_width

int get_accel_width(void);

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.

GtkAccelLabel::set_accel_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.

GtkAccelLabel::refetch

bool refetch(void);

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.

GtkAdjustment

Represents an adjustable bounded value.

Object Hierarchy

GtkObject
`-- GtkData
áááááá`-- GtkAdjustment

Object Properties and Methods

Constructor

GtkAdjustment (double value, double lower, double upper, double step_increment, double page_increment, double page_size);

— Creates the basis for an adjustable widget.

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.

Description

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 Constructor

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() .

GtkAdjustment::changed

void changed(void);

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.

GtkAdjustment::value_changed

void value_changed(void);

The value_changed() method is called internally whereever a signal emission is needed. It causes the value-changed signal to be emitted.

GtkAdjustment::clamp_page

void clamp_page(double lower, double upper);

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.

GtkAdjustment::set_value

void set_value(double value);

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.

Note

Adjustable widgets generally have their own wrapper method for setting the adjustment value, which should be used in preference where it exists.

changed

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);

value_changed

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);

GtkAdjustment::value

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.

GtkAdjustment::lower

Type: Read Only

lower is the lowest value that will be accepted by the GtkAdjustment.

GtkAdjustment::upper

Type: Read Only

upper is the highest value that will be accepted by the GtkAdjustment.

GtkAdjustment::step_increment

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.

GtkAdjustment::page_increment

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.

GtkAdjustment::page_size

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.

GtkAlignment

A container that controls the alignment and scale of its child.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkAlignment

Object Properties and Methods

Constructor

GtkAlignment (double xalign, double yalign, double xscale, double yscale);

— Creates a container that determines its child's alignment and scale.

Methods

set()
Sets new parameter values for an existing GtkAlignment.

Description

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 Constructor

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.

GtkAlignment::set

void set(double xalign, double yalign, double xscale, double yscale);

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();
      

GtkArrow

An arrow pointing in one of the four cardinal directions.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkMisc
áááááááááááá`-- GtkArrow

Object Properties and Methods

Constructor

GtkArrow ( GtkArrowType arrow_type , GtkShadowType shadow_type );

— Displays an arrow pointing in one of the four cardinal directions.

Methods

set()
Sets new parameter values for an existing GtkArrow.

Properties

arrow_type :
Direction of arrow's nose.
shadow_type :
Appearance of arrow.

Description

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 Constructor

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:

     
$arrow = &new GtkArrow(GTK_ARROW_RIGHT, GTK_SHADOW_ETCHED_IN);
     

GtkArrow::set

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.

GtkArrow::arrow_type

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.

GtkArrow::shadow_type

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.

GtkAspectFrame

A frame that constrains its child to a particular aspect ratio.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkFrame
áááááááááááááááááááááááá`-- GtkAspectFrame

Object Properties and Methods

Constructor

GtkAspectFrame ([string label = NULL, [double xalign = 0.5, [double yalign = 0.5, [double ratio = 1.0, [bool obey_child = TRUE]]]]]);

Methods

set()

Description

GtkAspectFrame Constructor

GtkAspectFrame ([string label = NULL, [double xalign = 0.5, [double yalign = 0.5, [double ratio = 1.0, [bool obey_child = TRUE]]]]]);

GtkAspectFrame::set

void set(double xalign, double yalign, double ratio, bool obey_child);

GtkBin

Base class for containers with just one child.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin

Object Properties and Methods

Properties

child :
The child widget.

Description

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.

GtkBin::child

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.

     
$button->remove($button->child);
      

GtkBox

Base class for box containers.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox

Object Properties and Methods

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.

Description

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.

GtkBox::pack_start

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.

GtkBox::pack_end

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.

GtkBox::pack_start_defaults

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

     
$box->pack_start($child);
      
without specifying any further parameters.

GtkBox::pack_end_defaults

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

     
$box->pack_end($child);
      
without specifying any further parameters.

GtkBox::set_homogeneous

void set_homogeneous(bool homogeneous);

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.

GtkBox::set_spacing

void set_spacing(int spacing);

set_spacing() is used to set the universal minimum spacing between the child widgets, in pixels.

The default setting is 0.

GtkBox::reorder_child

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.

GtkBox::set_child_packing

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.

GtkBox::query_child_packing

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.

GtkBox::children

Type: Read Only

The packing information for the individual child widgets is stored in children as an array of GtkBoxChild objects.

GtkBox::spacing

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.

GtkBox::homogeneous

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.

GtkBoxChild

Helper class for GtkBox.

Object Hierarchy

Object Properties and Methods

Properties

widget :
Child widget.
padding :
Child padding.
expand :
Child expand toggle.
fill :
Child fill toggle.
pack :
Child packing type.

Description

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.

GtkBoxChild::widget

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");
       

GtkBoxChild::padding

Type: Read Only

The padding property is an integer showing the padding around the widget , in pixels.

The default setting for padding is 0.

GtkBoxChild::expand

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.

GtkBoxChild::fill

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.

GtkBoxChild::pack

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.

GtkButton

A container widget that emits a signal when clicked on.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkButton

Object Properties and Methods

Constructor

GtkButton ([string label ]);

— Creates a button.

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.

Description

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 Constructor

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();
      

GtkButton::pressed

void pressed(void);

Makes the button emit the pressed signal.

GtkButton::released

void released(void);

Makes the button emit the released signal.

GtkButton::clicked

void clicked(void);

Makes the button emit the clicked signal.

GtkButton::enter

void enter(void);

Makes the button emit the enter signal.

GtkButton::leave

void leave(void);

Makes the button emit the leave signal.

GtkButton::set_relief

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.

GtkButton::get_relief

GtkReliefStyle get_relief (void);

Returns the current GtkReliefStyle setting for the button.

enter

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);

pressed

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);

clicked

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();
      
For further information about connecting signals, refer to the Signals and Callbacks chapter in the PHP-GTK Userguide.

Callback function:

void callback(GtkButton button);

released

The released signal is emitted when the user releases the mouse-button, regardless of the cursor position.

Callback function:

void callback(GtkButton button);

leave

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);

GtkButtonBox

Base class for GtkHButtonBox and GtkVButtonBox.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkButtonBox

Object Properties and Methods

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*

Description

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.

GtkButtonBox::get_spacing

int get_spacing(void);

get_spacing() returns the integer value representing the spacing in pixels between the buttons contained in a GtkButtonBox.

Note

Note that this method is deprecated in GTK+ 2.0 and should not be used where forward compatibility is an issue.

GtkButtonBox::get_layout

GtkButtonBoxStyle get_layout (void);

get_layout() retrieves the current GtkButtonBoxStyle setting.

GtkButtonBox::set_spacing

void set_spacing(int spacing);

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

Note that this method is deprecated in GTK+ 2.0. Where forward compatibility is an issue, use set_layout() instead.

GtkButtonBox::set_layout

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() .

GtkButtonBox::set_child_size

void set_child_size(int min_width, int min_height);

set_child_size() sets the minimum size for any child in the GtkButtonBox widget, in pixels.

The default setting is (85, 27).

Note

Note that this method is deprecated, and that minimum sizing will be set internally in future versions of GTK+.

GtkButtonBox::set_child_ipadding

void set_child_ipadding(int ipad_x, int ipad_y);

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

Note that this method is deprecated, and that internal padding will be set by the widget itself in future versions of GTK+.

GtkCalendar

A calendar offering dates that can be selected and marked.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkCalendar

Object Properties and Methods

Constructor

GtkCalendar (void);

— Creates a calendar widget.

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.

Description

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 Constructor

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();
     

GtkCalendar::select_month

int select_month(int month, int year);

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').

GtkCalendar::select_day

void select_day(int day);

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.

GtkCalendar::mark_day

int mark_day(int day);

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.

GtkCalendar::unmark_day

int unmark_day(int day);

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.

GtkCalendar::clear_marks

void clear_marks(void);

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');
      

GtkCalendar::display_options

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.

GtkCalendar::get_date

array get_date(void);

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.

Note

The range for the month is 1 - 12 here, but 0 - 11 in the select_month() method. Marked dates also run from 0. Beware!

GtkCalendar::freeze

void freeze(void);

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() .

GtkCalendar::thaw

void thaw(void);

thaw() is the corollary to freeze() , and is placed after an update routine.

month-changed

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);

day-selected

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);

day-selected-double-click

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);

prev-month

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);

next-month

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);

prev-year

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);

next-year

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);

GtkCalendar::month

Type: Read Only

The month property is an integer representing the currently selected month. This will be in the range 0 - 11.

GtkCalendar::year

Type: Read Only

The year property is an integer representing the currently selected year. This is in the 4-digit format, i.e. 2002.

GtkCalendar::selected_day

Type: Read Only

The selected_day property is an integer representing the currently selected day. This will be in the range 1 - 31.

GtkCalendar::num_marked_dates

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.

GtkCalendar::marked_date

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.

GtkCheckButton

Button that displays a discrete toggle indicator.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkButton
áááááááááááááááááááááááá`-- GtkToggleButton
áááááááááááááááááááááááááááááá`-- GtkCheckButton

Object Properties and Methods

Constructor

GtkCheckButton ([string label ]);

— Creates a button with a small toggle indicator.

Description

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 Constructor

GtkCheckButton ([string label ]);

     
$checkbutton = &new GtkCheckButton("GtkCheckButton 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.

GtkCheckMenuItem

Menu item with a toggle indicator.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkMenuItem
áááááááááááááááááááááááááááááá`-- GtkCheckMenuItem

Object Properties and Methods

Constructor

GtkCheckMenuItem ([string label ]);

— Creates a GtkMenuItem with a toggle indicator.

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.

Description

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 Constructor

GtkCheckMenuItem ([string label ]);

     
$checkmenuitem = &new GtkCheckMenuItem("CheckMenuItem's 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.

GtkCheckMenuItem::set_active

void set_active(bool is_active);

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.

     
$checkmenuitem->set_active(true);
      
will set the GtkCheckMenuItem's state to active.

The default setting is false.

GtkCheckMenuItem::set_show_toggle

void set_show_toggle(bool always);

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.

GtkCheckMenuItem::toggled

void toggled(void);

toggled() causes the calling GtkCheckMenuItem to emit the toggled signal.

toggled

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 );

GtkCheckMenuItem::active

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";
      

GtkCList Constructor

GtkCList (XXX);

GtkCList::set_hadjustment

void set_hadjustment(GtkAdjustment adjustment);

GtkCList::set_vadjustment

void set_vadjustment(GtkAdjustment adjustment);

GtkCList::get_hadjustment

GtkAdjustment get_hadjustment(void);

GtkCList::get_vadjustment

GtkAdjustment get_vadjustment(void);

GtkCList::set_shadow_type

void set_shadow_type(GtkShadowType type);

GtkCList::set_selection_mode

void set_selection_mode(GtkSelectionMode mode);

GtkCList::set_reorderable

void set_reorderable(bool reorderable);

GtkCList::set_use_drag_icons

void set_use_drag_icons(bool use_icons);

GtkCList::set_button_actions

void set_button_actions(int button, int button_actions);

GtkCList::freeze

void freeze(void);

GtkCList::thaw

void thaw(void);

GtkCList::column_titles_show

void column_titles_show(void);

GtkCList::column_titles_hide

void column_titles_hide(void);

GtkCList::column_title_active

void column_title_active(int column);

GtkCList::column_title_passive

void column_title_passive(int column);

GtkCList::column_titles_active

void column_titles_active(void);

GtkCList::column_titles_passive

void column_titles_passive(void);

GtkCList::set_column_title

void set_column_title(int column, string title);

GtkCList::get_column_title

string get_column_title(int column);

GtkCList::set_column_widget

void set_column_widget(int column, GtkWidget widget);

GtkCList::get_column_widget

GtkWidget get_column_widget(int column);

GtkCList::set_column_justification

void set_column_justification(int column, GtkJustification justification);

GtkCList::set_column_visibility

void set_column_visibility(int column, bool visible);

GtkCList::set_column_resizeable

void set_column_resizeable(int column, bool resizeable);

GtkCList::set_column_auto_resize

void set_column_auto_resize(int column, bool auto_resize);

GtkCList::columns_autosize

int columns_autosize(void);

GtkCList::optimal_column_width

int optimal_column_width(int column);

GtkCList::set_column_width

void set_column_width(int column, int width);

GtkCList::set_column_min_width

void set_column_min_width(int column, int min_width);

GtkCList::set_column_max_width

void set_column_max_width(int column, int max_width);

GtkCList::set_row_height

void set_row_height(int height);

GtkCList::moveto

void moveto(int row, int column, double row_align, double col_align);

GtkCList::row_is_visible

GtkVisibility row_is_visible(int row);

GtkCList::get_cell_type

GtkCellType get_cell_type(int row, int column);

GtkCList::set_text

void set_text(int row, int column, string text);

GtkCList::get_text

XXX get_text(XXX);

GtkCList::set_pixmap

void set_pixmap(int row, int column, GdkPixmap pixmap, GdkBitmap mask);

GtkCList::set_pixtext

void set_pixtext(int row, int column, string text, int spacing, GdkPixmap pixmap, GdkBitmap mask);

GtkCList::set_foreground

void set_foreground(int row, GdkColor color);

GtkCList::set_background

void set_background(int row, GdkColor color);

GtkCList::set_cell_style

void set_cell_style(int row, int column, GtkStyle style);

GtkCList::get_cell_style

GtkStyle get_cell_style(int row, int column);

GtkCList::set_row_style

void set_row_style(int row, GtkStyle style);

GtkCList::get_row_style

GtkStyle get_row_style(int row);

GtkCList::set_shift

void set_shift(int row, int column, int vertical, int horizontal);

GtkCList::set_selectable

void set_selectable(int row, bool selectable);

GtkCList::get_selectable

bool get_selectable(int row);

GtkCList::prepend

XXX prepend(XXX);

GtkCList::append

XXX append(XXX);

GtkCList::insert

XXX insert(XXX);

GtkCList::remove

void remove(int row);

GtkCList::select_row

void select_row(int row, int column);

GtkCList::unselect_row

void unselect_row(int row, int column);

GtkCList::undo_selection

void undo_selection(void);

GtkCList::clear

void clear(void);

GtkCList::select_all

void select_all(void);

GtkCList::unselect_all

void unselect_all(void);

GtkCList::swap_rows

void swap_rows(int row1, int row2);

GtkCList::row_move

void row_move(int source_row, int dest_row);

GtkCList::set_sort_column

void set_sort_column(int column);

GtkCList::set_sort_type

void set_sort_type(GtkSortType sort_type);

GtkCList::sort

void sort(void);

GtkCList::set_auto_sort

void set_auto_sort(bool auto_sort);

GtkCListRow

Object Hierarchy

Object Properties and Methods

Properties

state :
foreground :
background :
style :
fg_set :
bg_set :
selectable :

Description

GtkCListRow::state

Type: Read Only

GtkCListRow::foreground

Type: Read Only

GtkCListRow::background

Type: Read Only

GtkCListRow::style

Type: Read Only

GtkCListRow::fg_set

Type: Read Only

GtkCListRow::bg_set

Type: Read Only

GtkCListRow::selectable

Type: Read Only

GtkColorSelection

Widget that allows for selection of a color.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkVBox
áááááááááááááááááááááááá`-- GtkColorSelection

Object Properties and Methods

Constructor

Description

GtkColorSelection Constructor

GtkColorSelection::set_update_policy

void set_update_policy(GtkUpdateType policy);

GtkColorSelection::set_opacity

void set_opacity(int use_opacity);

GtkColorSelection::set_color

XXX set_color(XXX);

GtkColorSelection::get_color

XXX get_color(XXX);

GtkColorSelectionDialog

Standard dialog box for selecting a color.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
áááááááááááááááááááááááá`-- GtkColorSelectionDialog

Object Properties and Methods

Constructor

GtkColorSelectionDialog (string title);

Description

GtkColorSelectionDialog Constructor

GtkColorSelectionDialog (string title);

GtkCombo

Text entry field with a dropdown list.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkHBox
áááááááááááááááááááááááá`-- GtkCombo

Object Properties and Methods

Constructor

GtkCombo (void);

— Creates an entry box with a dropdown list.

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.

Description

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 Constructor

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();
     

GtkCombo::set_value_in_list

void set_value_in_list(bool val, bool ok_if_empty);

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.

GtkCombo::set_use_arrows

void set_use_arrows(bool val);

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.

GtkCombo::set_use_arrows_always

void set_use_arrows_always(bool val);

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.

GtkCombo::set_case_sensitive

void set_case_sensitive(bool val);

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.

GtkCombo::set_item_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.

Note

This method determines the string that will be displayed in the entry field after the list item has been selected.

GtkCombo::set_popdown_strings

array set_popdown_strings(array item_labels);

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();
      

GtkCombo::disable_activate

void disable_activate(void);

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.

GtkCombo::entry

Type: Read Only

The entry property provides a way of retrieving information directly from the GtkEntry part of the combo widget.

GtkCombo::list

Type: Read Only

The list property provides a way of retrieving information directly from the GtkList part of the combo widget.

GtkContainer

Base class for all container widgets.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer

Object Properties and Methods

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.

Description

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.

GtkContainer::set_border_width

void set_border_width(int border_width);

set_border_width sets the width of the container's border, in pixels.

The default setting is 0.

GtkContainer::add

void add( GtkWidget widget );

add() adds the child widget passed as the parameter to the container.

See also: GtkBin, GtkBox, pack_start() , pack_end() .

GtkContainer::remove

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.

GtkContainer::set_resize_mode

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.

GtkContainer::check_resize

void check_resize(void);

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.

GtkContainer::children

array children(void);

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].

GtkContainer::focus

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.

GtkContainer::set_reallocate_redraws

void set_reallocate_redraws(bool needs_redraws);

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.

GtkContainer::set_focus_child

void set_focus_child( GtkWidget child );

set_focus_child() is used to denote which child widget should receive focus on opening.

GtkContainer::set_focus_vadjustment

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.

GtkContainer::set_focus_hadjustment

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.

GtkContainer::register_toplevel

void register_toplevel(void);

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.

GtkContainer::unregister_toplevel

void unregister_toplevel(void);

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.

GtkContainer::resize_children

void resize_children(void);

resize_children() resizes child widgets following an alteration in their size requests.

GtkContainer::child_type

int child_type(void);

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.

add

The add signal is emitted when the add() method is called.

It is generally used internally.

Callback function:

void callback(GtkContainer container, GtkWidget child);

remove

The remove signal is emitted when the remove() method is called.

It is generally used internally.

Callback function:

void callback(GtkContainer container, GtkWidget child);

check-resize

The check-resize signal is emitted when the check_resize() method is called.

It is generally used internally.

Callback function:

void callback(GtkContainer container);

focus

The focus signal is emitted when the focus() method is called.

It is generally used internally.

Callback function:

void callback(GtkContainer container, GtkDirectionType direction);

set-focus-child

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);

GtkCTree Constructor

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();
     

GtkCTree::insert_node

XXX insert_node(XXX);

GtkCTree::remove_node

void remove_node( GtkCTreeNode node );

GtkCTree::post_recursive

XXX post_recursive(XXX);

GtkCTree::post_recursive_to_depth

XXX post_recursive_to_depth(XXX);

GtkCTree::pre_recursive

XXX pre_recursive(XXX);

GtkCTree::pre_recursive_to_depth

XXX pre_recursive_to_depth(XXX);

GtkCTree::is_viewable

bool is_viewable( GtkCTreeNode node );

GtkCTree::last

GtkCTreeNode last ( GtkCTreeNode node );

GtkCTree::node_nth

GtkCTreeNode node_nth (int row);

GtkCTree::find

bool find( GtkCTreeNode node , GtkCTreeNode child );

GtkCTree::is_ancestor

bool is_ancestor( GtkCTreeNode node , GtkCTreeNode child );

GtkCTree::is_hot_spot

bool is_hot_spot(int x, int y);

GtkCTree::move

void move( GtkCTreeNode node , GtkCTreeNode new_parent , GtkCTreeNode new_sibling );

GtkCTree::expand

void expand( GtkCTreeNode node );

GtkCTree::expand_recursive

void expand_recursive([ GtkCTreeNode node = NULL ]);

GtkCTree::expand_to_depth

void expand_to_depth( GtkCTreeNode node , int depth);

GtkCTree::collapse

void collapse( GtkCTreeNode node );

GtkCTree::collapse_recursive

void collapse_recursive([ GtkCTreeNode node = NULL ]);

GtkCTree::collapse_to_depth

void collapse_to_depth( GtkCTreeNode node , int depth);

GtkCTree::toggle_expansion

void toggle_expansion( GtkCTreeNode node );

GtkCTree::toggle_expansion_recursive

void toggle_expansion_recursive( GtkCTreeNode node );

GtkCTree::select

void select( GtkCTreeNode node );

GtkCTree::select_recursive

void select_recursive([ GtkCTreeNode node = NULL ]);

GtkCTree::unselect

void unselect( GtkCTreeNode node );

GtkCTree::unselect_recursive

void unselect_recursive([ GtkCTreeNode node = NULL ]);

GtkCTree::node_set_text

void node_set_text( GtkCTreeNode node , int column, string text);

GtkCTree::node_set_pixmap

void node_set_pixmap( GtkCTreeNode node , int column, GdkPixmap pixmap , GdkBitmap mask );

GtkCTree::node_set_pixtext

void node_set_pixtext( GtkCTreeNode node , int column, string text, int spacing, GdkPixmap pixmap , GdkBitmap mask );

GtkCTree::set_node_info

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);

GtkCTree::node_set_shift

void node_set_shift( GtkCTreeNode node , int column, int vertical, int horizontal);

GtkCTree::node_set_selectable

void node_set_selectable( GtkCTreeNode node , bool selectable);

GtkCTree::node_get_selectable

bool node_get_selectable( GtkCTreeNode node );

GtkCTree::node_get_cell_type

GtkCellType node_get_cell_type ( GtkCTreeNode node , int column);

GtkCTree::node_get_text

XXX node_get_text(XXX);

GtkCTree::node_get_pixtext

XXX node_get_pixtext(XXX);

GtkCTree::get_node_info

XXX get_node_info(XXX);

GtkCTree::node_set_row_style

void node_set_row_style( GtkCTreeNode node , GtkStyle style );

GtkCTree::node_get_row_style

GtkStyle node_get_row_style ( GtkCTreeNode node );

GtkCTree::node_set_cell_style

void node_set_cell_style( GtkCTreeNode node , int column, GtkStyle style );

GtkCTree::node_get_cell_style

GtkStyle node_get_cell_style ( GtkCTreeNode node , int column);

GtkCTree::node_set_foreground

void node_set_foreground( GtkCTreeNode node , GdkColor color );

GtkCTree::node_set_background

void node_set_background( GtkCTreeNode node , GdkColor color );

GtkCTree::node_set_row_data

XXX node_set_row_data(XXX);

GtkCTree::node_get_row_data

XXX node_get_row_data(XXX);

GtkCTree::node_moveto

void node_moveto( GtkCTreeNode node , int column, double row_align, double col_align);

GtkCTree::node_is_visible

GtkVisibility node_is_visible ( GtkCTreeNode node );

GtkCTree::set_indent

void set_indent(int indent);

GtkCTree::set_spacing

void set_spacing(int spacing);

GtkCTree::set_show_stub

void set_show_stub(bool show_stub);

GtkCTree::set_line_style

void set_line_style( GtkCTreeLineStyle line_style );

GtkCTree::set_expander_style

void set_expander_style( GtkCTreeExpanderStyle expander_style );

GtkCTree::sort_node

void sort_node( GtkCTreeNode node );

GtkCTree::sort_recursive

void sort_recursive([ GtkCTreeNode node = NULL ]);

GtkCTreeNode

Object Hierarchy

Object Properties and Methods

Properties

parent :
sibling :
children :
pixmap_closed :
pixmap_opened :
mask_closed :
mask_opened :
level :
is_leaf :
expanded :
row :

Description

GtkCTreeNode::parent

Type: Read Only

GtkCTreeNode::sibling

Type: Read Only

GtkCTreeNode::children

Type: Read Only

GtkCTreeNode::pixmap_closed

Type: Read Only

GtkCTreeNode::pixmap_opened

Type: Read Only

GtkCTreeNode::mask_closed

Type: Read Only

GtkCTreeNode::mask_opened

Type: Read Only

GtkCTreeNode::level

Type: Read Only

GtkCTreeNode::is_leaf

Type: Read Only

GtkCTreeNode::expanded

Type: Read Only

GtkCTreeNode::row

Type: Read Only

GtkCurve

Widget that allows editing of a curve.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkDrawingArea
áááááááááááá`-- GtkCurve

Object Properties and Methods

Constructor

GtkCurve (void);

Description

GtkCurve Constructor

GtkCurve (void);

GtkCurve::reset

void reset(void);

GtkCurve::set_gamma

void set_gamma(double gamma);

GtkCurve::set_range

void set_range(double min_x, double max_x, double min_y, double max_y);

GtkCurve::get_vector

XXX get_vector(XXX);

GtkCurve::set_vector

XXX set_vector(XXX);

GtkCurve::set_curve_type

void set_curve_type(GtkCurveType type);

GtkData

Abstract base class for objects containing data.

Object Hierarchy

Object Properties and Methods

Signals

disconnect:
Never emitted.

Description

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.

disconnect

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);

GtkDialog

Widget that eases creation of popup dialogs.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
áááááááááááááááááááááááá`-- GtkDialog

Object Properties and Methods

Constructor

GtkDialog (void);

— Creates the basis for a popup dialog window.

Properties

vbox :
Upper container.
action_area :
Lower container.

Description

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 Constructor

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();
     

GtkDialog::vbox

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.

GtkDialog::action_area

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.

GtkDrawingArea

Widget for custom user interface elements.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkDrawingArea

Object Properties and Methods

Constructor

GtkDrawingArea (void);

— Constructs a blank, drawable widget.

Methods

size()
Sets the size of the drawing area.

Description

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 Constructor

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();
     

GtkDrawingArea::size

void size(int width, int height);

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.

GtkEditable

Base class for text-editing widgets.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkEditable

Object Properties and Methods

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.

Description

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.

GtkEditable::select_region

void select_region(int start, int end);

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() .

GtkEditable::insert_text

void insert_text(string text_string, int position);

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.

Note

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.

GtkEditable::delete_text

void delete_text(int start_pos, int end_pos);

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.

GtkEditable::get_chars

string get_chars(int start_pos, int end_pos);

This method is used to return the specified contents of a string. To return the complete string, pass 0, -1 as the parameters.

GtkEditable::cut_clipboard

void cut_clipboard(void);

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.

GtkEditable::copy_clipboard

void copy_clipboard(void);

copy_clipboard() copies the current selection to the clipboard.

It also causes the copy-clipboard signal to be emitted.

GtkEditable::paste_clipboard

void paste_clipboard(void);

paste_clipboard() pastes the current clipboard contents at the cursor position.

It also causes the paste-clipboard signal to be emitted.

GtkEditable::claim_selection

void claim_selection(bool claim, int time);

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.

GtkEditable::delete_selection

void delete_selection(void);

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.

GtkEditable::changed

void changed(void);

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.

GtkEditable::set_position

void set_position(int position);

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.

GtkEditable::get_position

int get_position(void);

This method returns the current cursor position.

GtkEditable::set_editable

void set_editable(bool is_editable);

set_editable() , when set to true, sets the widget to be editable by the user.

The default setting is false.

changed

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);

insert-text

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);

delete-text

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);

activate

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);

set-editable

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);

cut-clipboard

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);

copy-clipboard

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);

paste-clipboard

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);

GtkEditable::selection_start_pos

Type: Read Only

The position in the text index that the current selection starts from, if there is one.

GtkEditable::selection_end_pos

Type: Read Only

The position in the text index that the current selection ends at, if there is one.

GtkEditable::has_selection

Type: Read Only

Indicates whether there is currently a selection.

GtkEntry

A single line text entry field.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkEditable
áááááááááááá`-- GtkEntry

Object Properties and Methods

Constructor

GtkEntry (void);

— Creates a single-line text entry widget.

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.

Description

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 Constructor

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();
     

GtkEntry::set_text

void set_text(string text);

set_text() sets a string of given text in the entry field.

     
$entry-gt;set_text("Programmed text entry");
      

GtkEntry::append_text

void append_text(string text);

append_text() adds the given string to the end of any entered text.

     
$entry->append_text("</END>");
      

GtkEntry::prepend_text

void prepend_text(string text);

prepend_text() adds the given string to the start of any entered text.

     
$entry->prepend_text("<START>");
      

GtkEntry::set_position

void set_position(int position);

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.

GtkEntry::get_text

string get_text(void);

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.

Note

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+.

GtkEntry::select_region

void select_region(int start, int end);

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).

GtkEntry::set_visibility

void set_visibility(bool visible);

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.

GtkEntry::set_editable

void set_editable(bool editable);

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.

GtkEntry::set_max_length

void set_max_length(int max);

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.

GtkEventBox

Widget used to capture events for widgets with no GdkWindow.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkEventBox

Object Properties and Methods

Constructor

GtkEventBox (void);

— Creates a means of capturing events where there is none.

Description

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 Constructor

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();
     

GtkFileSelection

Widget for selecting a file or a directory.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
áááááááááááááááááááááááá`-- GtkFileSelection

Object Properties and Methods

Constructor

GtkFileSelection ([string title ]);

— Creates a new GtkFileSelection widget.

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.

Description

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 Constructor

GtkFileSelection ([string title ]);

The syntax to create a GtkFileSelection widget is:

     
$fs = &new GtkFileSelection("My File Selection");
     
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.

GtkFileSelection::set_filename

void set_filename(string filename);

Sets the default path for the directory and/or file name.

     
$fs->set_filename("/home/user/php/");
      

GtkFileSelection::get_filename

string get_filename(void);

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.

     
$filename = $fs->get_filename();
      

GtkFileSelection::complete

void complete(string pattern);

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.

     
$fs->complete("*.php");
      

GtkFileSelection::show_fileop_buttons

void show_fileop_buttons(void);

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+.

     
$fs->show_fileop_buttons();
      

GtkFileSelection::hide_fileop_buttons

void hide_fileop_buttons(void);

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.

     
$fs->hide_fileop_buttons();
      

GtkFileSelection::dir_list

Type: Read Only

dir_list is a GtkCList widget embedded in the GtkFileSelection object that displays the subdirectories available in the current directory.

GtkFileSelection::file_list

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.

GtkFileSelection::selection_entry

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.

GtkFileSelection::selection_text

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.

GtkFileSelection::main_vbox

Type: Read Only

main_vbox is the container holding all the other elements of the GtkFileSelection widget.

GtkFileSelection::ok_button

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.

GtkFileSelection::cancel_button

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.

GtkFileSelection::action_area

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.

GtkFixed

Container that retains the sizes and positions of its children.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkFixed

Object Properties and Methods

Constructor

GtkFixed (void);

— Creates a GtkFixed container.

Methods

put()
Sets initial position of child.
move()
Moves child to new position.

Properties

children :
Array of child positioning information.

Description

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 Constructor

GtkFixed (void);

This function creates and returns a GtkFixed widget.

GtkFixed::put

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.

GtkFixed::move

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.

GtkFixed::children

Type: Read Only

The positioning information for the individual child widgets is stored in children as an array of GtkFixedChild objects.

GtkFixedChild

Helper class for GtkFixed.

Object Hierarchy

Object Properties and Methods

Properties

widget :
Child widget.
x :
Child position x co-ordinate.
y :
Child position y co-ordinate.

Description

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.

GtkFixedChild::widget

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");
       

GtkFixedChild::x

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.

GtkFixedChild::y

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.

GtkFontSelection

Widget for selecting fonts.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkNotebook
áááááááááááááááááá`-- GtkFontSelection

Object Properties and Methods

Constructor

Description

GtkFontSelection Constructor

GtkFontSelection::get_font_name

string get_font_name(void);

GtkFontSelection::get_font

GdkFont get_font(void);

GtkFontSelection::set_font_name

bool set_font_name(string fontname);

GtkFontSelection::get_preview_text

string get_preview_text(void);

GtkFontSelection::set_preview_text

void set_preview_text(string text);

GtkFontSelectionDialog

Standard dialog box for selecting fonts.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
áááááááááááááááááááááááá`-- GtkFontSelectionDialog

Object Properties and Methods

Constructor

GtkFontSelectionDialog (string title);

Description

GtkFontSelectionDialog Constructor

GtkFontSelectionDialog (string title);

GtkFontSelectionDialog::get_font_name

string get_font_name(void);

GtkFontSelectionDialog::get_font

GdkFont get_font(void);

GtkFontSelectionDialog::set_font_name

bool set_font_name(string fontname);

GtkFontSelectionDialog::get_preview_text

string get_preview_text(void);

GtkFontSelectionDialog::set_preview_text

void set_preview_text(string text);

GtkFrame

Container with a decorative frame and an optional label.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkFrame

Object Properties and Methods

Constructor

GtkFrame ([string label = NULL ]);

— Creates a decorative container.

Methods

set_label()
Sets label text.
set_label_align()
Sets label position.
set_shadow_type()
Sets angle and depth of shadow.

Description

GtkFrame is a container for a single child widget that provides a configurable shadowed border around the child's allocated area.

GtkFrame Constructor

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.

GtkFrame::set_label

void set_label(string label);

set_label() sets the label text programmatically.

     
$frame->set_label("Alternative text string");
      

GtkFrame::set_label_align

void set_label_align(double xalign, double yalign);

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.

     
$frame->set_label_align(0.7, 0.5);
      

GtkFrame::set_shadow_type

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.

GtkGammaCurve

A subclass of GtkCurve for editing gamma curves.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkVBox
áááááááááááááááááááááááá`-- GtkGammaCurve

Object Properties and Methods

Constructor

GtkGammaCurve (void);

Description

GtkGammaCurve Constructor

GtkGammaCurve (void);

GtkHandleBox

Widget for detachable window portions.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkHandleBox

Object Properties and Methods

Constructor

GtkHandleBox (void);

Description

GtkHandleBox Constructor

GtkHandleBox (void);

GtkHandleBox::set_shadow_type

void set_shadow_type(GtkShadowType type);

GtkHandleBox::set_handle_position

void set_handle_position(GtkPositionType position);

GtkHandleBox::set_snap_edge

void set_snap_edge(GtkPositionType edge);

GtkHBox

Horizontal box container.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkHBox

Object Properties and Methods

Constructor

GtkHBox ([bool homogeneous = false , [int spacing = 0 ]]);

— Creates a container for a single row of child widgets.

Description

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 Constructor

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.

     $hbox = &new GtkHBox();
will set the default behaviour of individual sizing and zero spacing.

GtkHButtonBox

Container for arranging a group of buttons horizontally.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkButtonBox
áááááááááááááááááááááááá`-- GtkHButtonBox

Object Properties and Methods

Constructor

GtkHButtonBox (void);

— Creates the basis for a horizontal button container.

Description

GtkHButtonBox is a container widget designed for arranging a row of buttons in accordance with a specified GtkButtonBoxStyle setting.

See also: GtkButtonBox, GtkVButtonBox.

GtkHButtonBox Constructor

GtkHButtonBox (void);

The syntax for creating a horizontal buttonbox is:

     
$hbuttonbox = &new GtkHButtonBox();
     
There are no parameters.

As with all container widgets, no physical space is taken by a GtkHButtonBox until its child widgets are in place.

GtkHPaned

Container with two panes arranged horizontally.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkPaned
áááááááááááááááááá`-- GtkHPaned

Object Properties and Methods

Constructor

GtkHPaned (void);

— Creates the basis for a horizontal dual-paned container.

Description

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.

See also: GtkPaned, GtkVPaned.

GtkHPaned Constructor

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

     $hbox = &new GtkHBox();
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();
     
Note that setting the resize parameter when packing GtkHPaned child widgets will not prevent them from resizing vertically when the top-level window is maximised.

GtkHRuler

Horizontal ruler.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkRuler
áááááááááááá`-- GtkHRuler

Object Properties and Methods

Constructor

GtkHRuler (void);

Description

GtkHRuler Constructor

GtkHRuler (void);

GtkHScale

Horizontal slider widget for selecting a value from a range.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkRange
áááááááááááá`-- GtkScale
áááááááááááááááááá`-- GtkHScale

Object Properties and Methods

Constructor

GtkHScale ( GtkAdjustment adjustment );

— Creates a horizontal slider.

Description

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 Constructor

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.

GtkHScrollbar

Horizontal scrollbar.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkRange
áááááááááááá`-- GtkScrollbar
áááááááááááááááááá`-- GtkHScrollbar

Object Properties and Methods

Constructor

GtkHScrollbar ( GtkAdjustment adjustment );

— Creates a horizontal scrollbar.

Description

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 Constructor

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.

Note

There is no working horizontal adjustment object in GtkText.

See also: GtkAdjustment, GtkVScrollbar.

GtkHSeparator

Horizontal separator.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkSeparator
áááááááááááá`-- GtkHSeparator

Object Properties and Methods

Constructor

GtkHSeparator (void);

— Draws a horizontal line.

Description

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 Constructor

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.

GtkImage

Widget for displaying a graphical image.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkMisc
áááááááááááá`-- GtkImage

Object Properties and Methods

Description

The GtkImage class is not implemented in PHP-GTK. Use GtkPixmap instead.

GtkInputDialog

Standard dialog for configuring input devices.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
áááááááááááááááááááááááá`-- GtkDialog
áááááááááááááááááááááááááááááá`-- GtkInputDialog

Object Properties and Methods

Constructor

GtkInputDialog (void);

Description

GtkInputDialog Constructor

GtkInputDialog (void);

GtkInvisible

Internally used widget which is not displayed.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkInvisible

Object Properties and Methods

Constructor

GtkInvisible (void);

Description

GtkInvisible Constructor

GtkInvisible (void);

GtkItem

Abstract base class for GtkMenuItem, GtkListItem, and GtkTreeItem.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem

Object Properties and Methods

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.

Description

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.

GtkItem::select

void select(void);

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.

GtkItem::deselect

void deselect(void);

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.

GtkItem::toggle

void toggle(void);

toggle() enables the relevant implementation of the toggle signal to be emitted programmatically.

select

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);

deselect

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);

toggle

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.

Note

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);

GtkItemFactory

Object Hierarchy

Object Properties and Methods

Constructor

GtkItemFactory (int container_type, string path, GtkAccelGroup accel_group);

Description

GtkItemFactory Constructor

GtkItemFactory (int container_type, string path, GtkAccelGroup accel_group);

GtkItemFactory::construct

void construct(int container_type, string path, GtkAccelGroup accel_group);

GtkItemFactory::get_item

GtkWidget get_item(string path);

GtkItemFactory::get_widget

GtkWidget get_widget(string path);

GtkItemFactory::get_widget_by_action

GtkWidget get_widget_by_action(int action);

GtkItemFactory::get_item_by_action

GtkWidget get_item_by_action(int action);

GtkItemFactory::create_items

XXX create_items(XXX);

GtkItemFactory::delete_item

void delete_item(string path);

GtkItemFactory::popup

void popup(int x, int y, int mouse_button, int time);

GtkLabel

Widget that displays a small amount of text.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkMisc
áááááááááááá`-- GtkLabel

Object Properties and Methods

Constructor

GtkLabel ([string label_text ]);

— Creates a new label with the given text inside it. If no text is specified, an empty label is created.

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*

Description

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 Constructor

GtkLabel ([string label_text ]);

The syntax to create a new GtkLabel widget is:

     
$label = &new GtkLabel("Initial or static label text");
     

GtkLabel::set_text

void set_text(string label_text );

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.

     
$label->set_text("Whatever text you wish to pass");
      

GtkLabel::set_justify

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.

     
$label->set_justify(GTK_JUSTIFY_FILL);
      

GtkLabel::set_pattern

void set_pattern([string pattern = NULL ]);

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.

     
$label->set_pattern("_   _");
      

Call this method with no parameters to erase existing underlines.

GtkLabel::set_line_wrap

void set_line_wrap(bool wrap);

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.

     
$label->set_line_wrap(true);
      

GtkLabel::get

string get(void );

Returns the current text content of the label.

Note

Note that this method is deprecated in GTK 2.0, and will be replaced by get_text().

     
$label->get();
      

GtkLabel::parse_uline

int parse_uline(string string);

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.

Note

Note that this method is deprecated in GTK+ 2.0.

     
$label->parse_uline("_File");
      

GtkLayout

Scrollable widget allowing multiple children in fixed positions.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkLayout

Object Properties and Methods

Constructor

GtkLayout ( GtkAdjustment hadjustment , GtkAdjustment vadjustment );

— Creates a scrollable backdrop whose children retain their positions.

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.

Description

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 Constructor

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:

     
function exposure($adj, $layout) {
  $layout->hide();
  $layout->show();
}
     

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();
     

GtkLayout::put

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.

GtkLayout::move

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.

GtkLayout::set_size

void set_size(int width, int height);

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.

GtkLayout::get_hadjustment

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.

GtkLayout::get_vadjustment

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.

GtkLayout::freeze

void freeze(void);

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() .

GtkLayout::thaw

void thaw(void);

thaw() is the corollary of freeze() . It allows the display to be redrawn after the new data is fully assimilated.

GtkList

Widget displaying a list of selectable items.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkList

Object Properties and Methods

Constructor

GtkList (void);

— Creates a container for a simple list.

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.

Description

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 Constructor

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();
     

GtkList::append_items

void append_items(array);

This is a widget-specific method for adding an array of GtkListItems to a GtkList.

GtkList::clear_items

void clear_items(int start, int end);

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.

GtkList::select_item

void select_item(int item);

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.

GtkList::unselect_item

void unselect_item(int item);

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.

GtkList::select_child

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.

GtkList::unselect_child

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.

GtkList::child_position

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.

GtkList::set_selection_mode

void set_selection_mode( GtkSelectionMode mode );

Sets one of the four possible GtkSelectionMode enumerated values.

The default setting is GTK_SELECTION_SINGLE.

GtkList::extend_selection

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.

GtkList::start_selection

void start_selection(void);

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() .

GtkList::end_selection

void end_selection(void);

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.

GtkList::select_all

void select_all(void);

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() .

GtkList::unselect_all

void unselect_all(void);

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.

GtkList::scroll_horizontal

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.

GtkList::scroll_vertical

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.

GtkList::toggle_add_mode

void toggle_add_mode(void);

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.

GtkList::toggle_focus_row

void toggle_focus_row(void);

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.

GtkList::toggle_row

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.

GtkList::undo_selection

void undo_selection(void);

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.

GtkList::end_drag_selection

void end_drag_selection(void);

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.

selection-changed

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);

select-child

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);

unselect-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);

GtkList::selection

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];
will return the selected item. If the selection mode allows multiple selection, there will be as many elements in the array as there are currently-selected objects.

See also: children() .

GtkListItem

A single element in a GtkList.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkListItem

Object Properties and Methods

Constructor

GtkListItem ([string label ]);

— Creates a list element.

Methods

select()
Causes the select signal to be emitted.
deselect()
Causes the deselect signal to be emitted.

Description

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 Constructor

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.

     
$listitem = &new GtkListItem("This list item now has a label");
     

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);
     
or, if you wanted perhaps a label plus some other item:
     
$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.

GtkListItem::select

void select(void);

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.

GtkListItem::deselect

void deselect(void);

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.

GtkMenu

Popup container for menu items.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkMenuShell
áááááááááááááááááá`-- GtkMenu

Object Properties and Methods

Constructor

GtkMenu (void);

— Creates the structure to hold a menu's content.

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.

Description

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 Constructor

GtkMenu (void);

     
$menu = &new GtkMenu();
     
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();
     

GtkMenu::popup

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
- this being a setting that all GdkEvent structures share; it causes the popup menu to react as you'd expect it to, and won't spring any surprises if you duplicate or otherwise adapt the original callback event.

GtkMenu::reposition

void reposition(void);

reposition() is used internally to reposition a GtkMenuItem's submenu according to the results of the position function called in the popup() method.

GtkMenu::popdown

void popdown(void);

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.

GtkMenu::get_active

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.

GtkMenu::set_active

void set_active(int index);

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.

GtkMenu::set_accel_group

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.

GtkMenu::get_accel_group

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.

GtkMenu::get_uline_accel_group

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.

GtkMenu::ensure_uline_accel_group

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.

GtkMenu::attach_to_widget

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.

GtkMenu::detach

void detach(void);

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.

GtkMenu::get_attach_widget

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.

GtkMenu::set_tearoff_state

void set_tearoff_state(bool torn_off);

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();
      
Notice that the destroy signal must be connected in this instance, and not the window's delete-event signal. This is because the parent window accessed is not the same window as has the window decorations, but is capable of accessing the internal destroy signal triggered by that window if it is given grab beforehand, and can propagate the event to all its children.

You will also spot that this means the menu needs to be rebuilt any time it is called.

GtkMenu::set_title

void set_title(string title);

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.

GtkMenu::reorder_child

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.

GtkMenuBar

Horizontal container for menu items.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkMenuShell
áááááááááááááááááá`-- GtkMenuBar

Object Properties and Methods

Constructor

GtkMenuBar (void);

— Constructs a horizontal menu bar.

Methods

set_shadow_type()
Alters appearance of menu bar.

Description

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 Constructor

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();
     

GtkMenuBar::set_shadow_type

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.

GtkMenuItem

Widget used for item in menus.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkMenuItem

Object Properties and Methods

Constructor

GtkMenuItem ([string label ]);

— Creates a menu item.

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.

Description

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 Constructor

GtkMenuItem ([string label ]);

The syntax

     
$menuitem = &new GtkMenuItem("Edit");
     
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);
     

GtkMenuItem::set_submenu

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.

GtkMenuItem::remove_submenu

void remove_submenu(void);

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.

GtkMenuItem::set_placement

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.

GtkMenuItem::configure

void configure(int show_toggle_indicator, int show_submenu_indicator);

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+.

GtkMenuItem::select

void select(void);

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.

GtkMenuItem::deselect

void deselect(void);

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.

GtkMenuItem::activate

void activate(void);

activate() causes the calling GtkMenuItem to emit the activate signal as if the user had clicked on it.

GtkMenuItem::right_justify

void right_justify(void);

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.

activate

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);

activate-item

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);

GtkMenuShell

Abstract base class for menu objects.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkMenuShell

Object Properties and Methods

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.

Description

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:
Escape cancels an existing popup menu
Return activates the current selection
Space also activates the current selected item
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.

Note that GtkMenuShell is an abstract base class, and can not be constructed directly.

GtkMenuShell::append

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.

GtkMenuShell::prepend

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.

GtkMenuShell::insert

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.

GtkMenuShell::deactivate

void deactivate(void);

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.

GtkMenuShell::select_item

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.

GtkMenuShell::deselect

void deselect(void);

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.

GtkMenuShell::activate_item

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.

deactivate

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);

selection-done

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);

cancel

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);

GtkMisc

Base class for widgets having their own alignment and padding.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkMisc

Object Properties and Methods

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.

Description

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.

GtkMisc::set_alignment

void set_alignment(double xalign, double yalign);

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.

GtkMisc::set_padding

void set_padding(int xpad, int ypad);

set_padding() sets the padding around the calling widget to the given number of pixels, in both directions.

GtkMisc::xalign

Type: Read Only

The xalign property provides the means to query the relative position of the widget to its container along the horizontal axis.

GtkMisc::yalign

Type: Read Only

The yalign property provides the means to query the relative position of the widget to its container along the vertical axis.

GtkMisc::xpad

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.

GtkMisc::ypad

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.

GtkNotebook Constructor

GtkNotebook (void);

GtkNotebook::append_page

void append_page(GtkWidget child, GtkWidget tab_label);

GtkNotebook::append_page_menu

void append_page_menu(GtkWidget child, GtkWidget tab_label, GtkWidget menu_label);

GtkNotebook::prepend_page

void prepend_page(GtkWidget child, GtkWidget tab_label);

GtkNotebook::prepend_page_menu

void prepend_page_menu(GtkWidget child, GtkWidget tab_label, GtkWidget menu_label);

GtkNotebook::insert_page

void insert_page(GtkWidget child, GtkWidget tab_label, int position);

GtkNotebook::insert_page_menu

void insert_page_menu(GtkWidget child, GtkWidget tab_label, GtkWidget menu_label, int position);

GtkNotebook::remove_page

void remove_page(int page_num);

GtkNotebook::get_current_page

int get_current_page(void);

GtkNotebook::get_nth_page

GtkWidget get_nth_page(int page_num);

GtkNotebook::page_num

int page_num(GtkWidget child);

GtkNotebook::set_page

void set_page(int page_num);

GtkNotebook::next_page

void next_page(void);

GtkNotebook::prev_page

void prev_page(void);

GtkNotebook::set_show_border

void set_show_border(bool show_border);

GtkNotebook::set_show_tabs

void set_show_tabs(bool show_tabs);

GtkNotebook::set_tab_pos

void set_tab_pos(GtkPositionType pos);

GtkNotebook::set_homogeneous_tabs

void set_homogeneous_tabs(bool homogeneous);

GtkNotebook::set_tab_border

void set_tab_border(int border_width);

GtkNotebook::set_tab_hborder

void set_tab_hborder(int tab_hborder);

GtkNotebook::set_tab_vborder

void set_tab_vborder(int tab_vborder);

GtkNotebook::set_scrollable

void set_scrollable(bool scrollable);

GtkNotebook::popup_enable

void popup_enable(void);

GtkNotebook::popup_disable

void popup_disable(void);

GtkNotebook::get_tab_label

GtkWidget get_tab_label(GtkWidget child);

GtkNotebook::set_tab_label

void set_tab_label(GtkWidget child, GtkWidget tab_label);

GtkNotebook::set_tab_label_text

void set_tab_label_text(GtkWidget child, string tab_text);

GtkNotebook::get_menu_label

GtkWidget get_menu_label(GtkWidget child);

GtkNotebook::set_menu_label

void set_menu_label(GtkWidget child, GtkWidget menu_label);

GtkNotebook::set_menu_label_text

void set_menu_label_text(GtkWidget child, string menu_text);

GtkNotebook::set_tab_label_packing

void set_tab_label_packing(GtkWidget child, bool expand, bool fill, GtkPackType pack_type);

GtkNotebook::reorder_child

void reorder_child(GtkWidget child, int position);

GtkObject

The base class of the PHP-GTK class hierachy.

Object Hierarchy

Object Properties and Methods

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()

Description

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.

GtkObject::flags

int flags(void);

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 .

GtkObject::set_flags

void set_flags(int 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 .

GtkObject::unset_flags

void unset_flags(int 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.

See also: flags , set_flags

GtkObject::default_construct

void default_construct(void);

This constructor is called when arguments have the GTK_ARG_CONSTRUCT flag set within GtkArgFlags.

GtkObject::constructed

void constructed(void);

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.

GtkObject::sink

void sink(void);

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.

GtkObject::ref

void ref(void);

Increase the reference count on an object.

GtkObject::unref

void unref(void);

Decrease a reference count on an object.

Note

If you decrease the refcount to 0 then the object will be destroyed.

GtkObject::destroy

void destroy(void);

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

GtkObject::get_arg

XXX get_arg(XXX);

GtkObject::set_arg

XXX set_arg(XXX);

GtkObject::set_data

XXX set_data(XXX);

GtkObject::remove_data

void remove_data(string key);

GtkObject::get_data

XXX get_data(XXX);

GtkObject::remove_no_notify

void remove_no_notify(string key);

GtkObject::emit_stop

void emit_stop(int signal_id);

GtkObject::emit_stop_by_name

void emit_stop_by_name(string name);

GtkObject::connect

int connect(string signal, string function, void custom ]);

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

GtkObject::connect_after

int connect_after(string signal, string function, void custom ]);

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

GtkObject::connect_object

int connect_object(string signal, string function, Object param);

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

GtkObject::connect_object_after

int connect_object_after(string signal, string function, Object param);

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

GtkObject::disconnect

void disconnect(int handler_id);

GtkObject::signal_handler_block

void signal_handler_block(int handler_id);

GtkObject::signal_handler_unblock

void signal_handler_unblock(int handler_id);

GtkObject::signal_handler_pending

int signal_handler_pending(int signal_id, bool may_be_blocked);

GtkObject::signal_handler_pending_by_id

int signal_handler_pending_by_id(int handler_id, bool may_be_blocked);

GtkObject::emit

XXX emit(XXX);

GtkObject::signal_handlers_destroy

void signal_handlers_destroy(void);

GtkOptionMenu

Widget used to choose from a list of valid choices.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkButton
áááááááááááááááááááááááá`-- GtkOptionMenu

Object Properties and Methods

Constructor

GtkOptionMenu (void);

— Creates a popup menu linked to a button.

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.

Description

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 Constructor

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();
      

GtkOptionMenu::get_menu

GtkWidget get_menu (void);

get_menu() returns the instance of the GtkMenu that is currently associated with the calling GtkOptionMenu.

GtkOptionMenu::set_menu

void set_menu( GtkWidget menu );

set_menu() sets the GtkMenu specified in the parameter to be associated with the calling GtkOptionMenu.

GtkOptionMenu::remove_menu

void remove_menu(void);

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.

GtkOptionMenu::set_history

void set_history(int index);

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.

GtkPacker

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkPacker

Object Properties and Methods

Constructor

GtkPacker (void);

Description

GtkPacker Constructor

GtkPacker (void);

GtkPacker::add_defaults

void add_defaults(GtkWidget child, GtkSideType side, GtkAnchorType anchor, GtkPackerOptions options);

GtkPacker::add

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]]]]]);

GtkPacker::set_child_packing

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]]]]]);

GtkPacker::reorder_child

void reorder_child(GtkWidget child, int position);

GtkPacker::set_spacing

void set_spacing(int spacing);

GtkPacker::set_default_border_width

void set_default_border_width(int border);

GtkPacker::set_default_pad

void set_default_pad(int pad_x, int pad_y);

GtkPacker::set_default_ipad

void set_default_ipad(int i_pad_x, int i_pad_y);

GtkPaned

Base class for widgets with two adjustable panes.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkPaned

Object Properties and Methods

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.

Description

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.

GtkPaned::add1

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.

GtkPaned::add2

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.

GtkPaned::pack1

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.

GtkPaned::pack2

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.

GtkPaned::set_position

void set_position(int position);

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

     $paned->set_position(-1);

GtkPaned::set_handle_size

void set_handle_size(int size);

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.

Note

Please note that both this function and the handle_size property are deprecated in GTK2, and so should not be used.

GtkPaned::set_gutter_size

void set_gutter_size(int size);

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.

Note

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.

GtkPaned::child1

Type: Read Only

child1 is the internal name for the child widget in the first pane of a GtkPaned-derived widget.

GtkPaned::child2

Type: Read Only

child2 is the internal name for the child widget in the second pane of a GtkPaned-derived widget.

GtkPaned::handle_size

Type: Read Only

handle_size is an integer describing the width or height (as appropriate) of the separating handle in a GtkPaned-derived widget.

Note

Please note that in future releases of GTK+ there is no such property. It will be replaced internally by private fields.

GtkPaned::gutter_size

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.

Note

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.

GtkPaned::child1_resize

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.

GtkPaned::child1_shrink

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.

GtkPaned::child2_resize

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.

GtkPaned::child2_shrink

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.

GtkPixmap

Widget displaying a graphical image or icon.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkMisc
áááááááááááá`-- GtkPixmap

Object Properties and Methods

Constructor

GtkPixmap (GdkPixmap pixmap, GdkBitmap mask);

Description

GtkPixmap Constructor

GtkPixmap (GdkPixmap pixmap, GdkBitmap mask);

GtkPixmap::set

void set(GdkPixmap val, GdkBitmap mask);

GtkPixmap::set_build_insensitive

void set_build_insensitive(int build);

GtkPlug

Toplevel widget for embedding into other processes.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow
áááááááááááááááááááááááá`-- GtkPlug

Object Properties and Methods

Constructor

GtkPlug (int socket_id);

Methods

construct()

Description

GtkPlug Constructor

GtkPlug (int socket_id);

GtkPlug::construct

void construct(int socket_id);

GtkPreview

Widget to display RGB or grayscale data.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkPreview

Object Properties and Methods

Constructor

Description

GtkPreview Constructor

GtkPreview::size

void size(int width, int height);

GtkPreview::put

void put(GdkWindow window, GdkGC gc, int srcx, int srcy, int destx, int desty, int width, int height);

GtkPreview::draw_row

void draw_row(string data, int x, int y, int w);

GtkPreview::set_expand

void set_expand(bool expand);

GtkProgress

Base class for GtkProgressBar.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkProgress

Object Properties and Methods

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.

Description

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.

GtkProgress::set_show_text

void set_show_text(bool show_text);

The show_text parameter controls whether the progress text is shown. The default setting is false.

See also: set_format_string() .

GtkProgress::set_text_alignment

void set_text_alignment(double x_align, double y_align);

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).

GtkProgress::set_format_string

void set_format_string(string format);

The content of the progress text can be modified with the format string. It can contain the following format characters:

  • %v - the current progress value.

  • %l - the lower bound of the progress value.

  • %u - the upper bound of the progress value.

  • %p - the current progress percentage.

The % character itself can be specified as %%.

The default text string is "%p%%".

See also: GtkAdjustment, where the progress value and bounds are set.

GtkProgress::set_adjustment

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.

GtkProgress::configure

void configure(double value, double min, double max);

This method provides a way to directly control the current value and the bounds of a GtkProgress.

See also: GtkAdjustment.

GtkProgress::set_percentage

void set_percentage(double percentage);

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.

GtkProgress::set_value

void set_value(double value);

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.

GtkProgress::get_value

double get_value(void);

Returns the current progress value.

GtkProgress::set_activity_mode

void set_activity_mode(bool activity_mode);

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() .

GtkProgress::get_current_text

string get_current_text(void);

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() ).

GtkProgress::get_text_from_value

string get_text_from_value(double value);

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.

GtkProgress::get_current_percentage

double get_current_percentage(void);

Returns the current progress percentage as a number between 0.0 and 1.0.

GtkProgress::get_percentage_from_value

double get_percentage_from_value(double value);

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.

GtkProgressBar

Widget that provides a visual indication of an operation's progress.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkProgress
áááááááááááá`-- GtkProgressBar

Object Properties and Methods

Constructor

GtkProgressBar ( GtkAdjustment adjustment );

— Creates a progress bar widget.

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*

Description

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 Constructor

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();
     
To create a progress bar in activity mode, delete the references to the text string and replace them with
     
$progressbar->set_activity_mode(true);
    
and any further methods appropriate to an activity indicator. You will also need to replace
     
$progressbar->set_percentage($value);
    
in the update_bar() function with
     
$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.

GtkProgressBar::set_bar_style

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() .

GtkProgressBar::set_discrete_blocks

void set_discrete_blocks(int 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.

GtkProgressBar::set_activity_step

void set_activity_step(int step);

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.

GtkProgressBar::set_activity_blocks

void set_activity_blocks(int blocks);

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.

GtkProgressBar::set_orientation

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.

GtkProgressBar::update

void update(double percentage);

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.

GtkRadioButton

Button that is part of a group, only one of which may be selected.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkButton
áááááááááááááááááááááááá`-- GtkToggleButton
áááááááááááááááááááááááááááááá`-- GtkCheckButton
áááááááááááááááááááááááááááááááááááá`-- GtkRadioButton

Object Properties and Methods

Constructor

GtkRadioButton ( GtkRadioButton group , string label);

— Creates one of a group of GtkRadioButton widgets.

Description

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 Constructor

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();
     

GtkRadioMenuItem

Menu item that is part of a group, only one of which may be selected.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkMenuItem
áááááááááááááááááááááááááááááá`-- GtkCheckMenuItem
áááááááááááááááááááááááááááááááááááá`-- GtkRadioMenuItem

Object Properties and Methods

Constructor

GtkRadioMenuItem ( GtkRadioMenuItem group , string label);

— Creates one of a group of GtkRadioMenuItem widgets.

Description

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 Constructor

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.

Note

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);
     

GtkRange::get_adjustment

GtkAdjustment get_adjustment (void);

GtkRange::set_update_policy

void set_update_policy( GtkUpdateType policy );

GtkRange::set_adjustment

void set_adjustment( GtkAdjustment adjustment );

GtkRange::draw_background

void draw_background(void);

GtkRange::clear_background

void clear_background(void);

GtkRange::draw_trough

void draw_trough(void);

GtkRange::draw_slider

void draw_slider(void);

GtkRange::draw_step_forw

void draw_step_forw(void);

GtkRange::draw_step_back

void draw_step_back(void);

GtkRange::slider_update

void slider_update(void);

GtkRange::default_hslider_update

void default_hslider_update(void);

GtkRange::default_vslider_update

void default_vslider_update(void);

GtkRange::default_hmotion

void default_hmotion(int xdelta, int ydelta);

GtkRange::default_vmotion

void default_vmotion(int xdelta, int ydelta);

GtkRuler

Base class for horizontal and vertical rulers.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkRuler

Object Properties and Methods

Description

GtkRuler::set_metric

void set_metric(GtkMetricType metric);

GtkRuler::set_range

void set_range(double lower, double upper, double position, double max_size);

GtkRuler::draw_ticks

void draw_ticks(void);

GtkRuler::draw_pos

void draw_pos(void);

GtkScale

Base class for GtkHScale and GtkVScale.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkRange
áááááááááááá`-- GtkScale

Object Properties and Methods

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.

Description

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.

GtkScale::set_digits

void set_digits(int digits);

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.

GtkScale::set_draw_value

void set_draw_value(bool draw_value);

set_draw_value() simply toggles whether the value is displayed as text or not.

The default setting is true.

GtkScale::set_value_pos

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.

GtkScale::get_value_width

int get_value_width(void);

get_value_width() returns the width of the numeric text string in a GtkScale. The value is given in pixels.

GtkScrollbar

Base class for GtkHScrollbar and GtkVScrollbar.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkRange
áááááááááááá`-- GtkScrollbar

Object Properties and Methods

Description

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.

GtkScrolledWindow

Adds scrollbars to its child widget.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkScrolledWindow

Object Properties and Methods

Constructor

GtkScrolledWindow ([ GtkAdjustment hadjustment = NULL , [ GtkAdjustment vadjustment = NULL ]]);

— Creates a scrolling window.

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.

Description

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 Constructor

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.

Note

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();
     

GtkScrolledWindow::get_hadjustment

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.

GtkScrolledWindow::get_vadjustment

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.

GtkScrolledWindow::set_policy

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.

GtkScrolledWindow::set_placement

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.

GtkScrolledWindow::add_with_viewport

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.

GtkSelectionData

Object Hierarchy

Object Properties and Methods

Methods

set()

Properties

selection :
target :
type :
format :
length :
data :

Description

GtkSelectionData::set

void set(void);

GtkSelectionData::selection

Type: Read Only

GtkSelectionData::target

Type: Read Only

GtkSelectionData::type

Type: Read Only

GtkSelectionData::format

Type: Read Only

GtkSelectionData::length

Type: Read Only

GtkSelectionData::data

Type: Read Only

GtkSeparator

Base class for GtkHSeparator and GtkVSeparator.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkSeparator

Object Properties and Methods

Description

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.

GtkSocket

Container for widgets from other processes.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkSocket

Object Properties and Methods

Constructor

GtkSocket (void);

Methods

steal()

Description

GtkSocket Constructor

GtkSocket (void);

GtkSocket::steal

void steal(int wid);

GtkSpinButton

Widget offering masked numerical entry and/or selection.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkEditable
áááááááááááá`-- GtkEntry
áááááááááááááááááá`-- GtkSpinButton

Object Properties and Methods

Constructor

GtkSpinButton ([ GtkAdjustment adjustment = NULL , [double climb_rate = 0.0 , [int digits = 0 ]]]);

— Creates an editable rotating display of selectable numbers.

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.

Description

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 Constructor

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();
     
See also: GtkAdjustment's value-changed signal.

GtkSpinButton::configure

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.

GtkSpinButton::set_adjustment

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.

GtkSpinButton::get_adjustment

GtkAdjustment get_adjustment (void);

get_adjustment() returns the GtkAdjustment object currently associated with the calling spinbutton.

GtkSpinButton::set_digits

void set_digits(int digits);

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.

GtkSpinButton::get_value_as_float

double get_value_as_float(void);

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);
      

GtkSpinButton::get_value_as_int

int get_value_as_int(void);

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.

GtkSpinButton::set_value

void set_value(double value);

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.

GtkSpinButton::set_update_policy

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.

GtkSpinButton::set_numeric

void set_numeric(bool numeric);

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.

GtkSpinButton::spin

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.

GtkSpinButton::set_wrap

void set_wrap(bool wrap);

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.

GtkSpinButton::set_shadow_type

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.

GtkSpinButton::set_snap_to_ticks

void set_snap_to_ticks(bool snap_to_ticks);

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() .

GtkSpinButton::update

void update(void);

The update() method is used internally to update the value field in the underlying GtkAdjustment according to the update policy, digits and snap settings.

GtkStatusbar

Widget that provides a way to report messages of minor importance.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkHBox
áááááááááááááááááááááááá`-- GtkStatusbar

Object Properties and Methods

Constructor

GtkStatusbar (void);

— Creates a status bar.

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.

Description

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.

Note

Where a routine requires a lot of processing, the statusbar may be unable to update during the time taken to do so. You will need to call

     
while (gtk::events_pending())
  gtk::main_iteration();
      
each time the bar has been updated, to allow updating throughout.

GtkStatusbar Constructor

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();
     

GtkStatusbar::get_context_id

int get_context_id(string context_description);

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.

GtkStatusbar::push

int push(int context_id, string text);

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.

GtkStatusbar::pop

void pop(int context_id);

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.

GtkStatusbar::remove

void remove(int context_id, int message_id);

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.

text-pushed

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);

text-popped

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);

GtkStyle

A class that determines the appearance of widgets.

Object Hierarchy

Object Properties and Methods

Constructor

GtkStyle (void);

— Creates a new style for a widget.

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.

Description

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:

     
$style = $widget->style;
     
It is also possible to create a new GtkStyle object in the normal way, e.g.
     
$style = &new GtkStyle();
     
or to take the default application style:
     
$style = gtk::widget_get_default_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 Constructor

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();
     

GtkStyle::copy

GtkStyle copy(void);

copy() takes an existing style and copies it wholesale, including any prior modifications that have been made to it.

GtkStyle::black

Type: Read Write

GtkStyle::white

Type: Read Write

GtkStyle::font

Type: Read Write

The current font.

GtkStyle::black_gc

Type: Read Write

GtkStyle::white_gc

Type: Read Write

GtkStyle::colormap

Type: Read Write

GtkStyle::fg

Type: Read Write

GtkStyle::bg

Type: Read Write

GtkStyle::light

Type: Read Write

GtkStyle::dark

Type: Read Write

GtkStyle::mid

Type: Read Write

GtkStyle::text

Type: Read Write

GtkStyle::base

Type: Read Write

GtkStyle::fg_gc

Type: Read Write

GtkStyle::bg_gc

Type: Read Write

GtkStyle::light_gc

Type: Read Write

GtkStyle::dark_gc

Type: Read Write

GtkStyle::mid_gc

Type: Read Write

GtkStyle::text_gc

Type: Read Write

GtkStyle::base_gc

Type: Read Write

GtkStyle::bg_pixmap

Type: Read Write

GtkTable

Container that provides a flexible grid for packing its children.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkTable

Object Properties and Methods

Constructor

GtkTable ([int rows = 1 , [int columns = 1 , [bool homogeneous = FALSE ]]]);

— Creates a container whose children are arranged on a grid.

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.

Description

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 Constructor

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.

Note

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();
     

GtkTable::resize

void resize(int rows, int columns);

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.

GtkTable::attach

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.

Note

It is possible for a single child widget to span several rows or columns.

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.

GtkTable::attach_defaults

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.

GtkTable::set_row_spacing

void set_row_spacing(int row, int spacing);

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.

GtkTable::set_col_spacing

void set_col_spacing(int column, int spacing);

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.

GtkTable::set_row_spacings

void set_row_spacings(int spacing);

Use this method to set the spacing between all rows, in pixels.

The default setting is 0.

GtkTable::set_col_spacings

void set_col_spacings(int spacing);

Use this method to set the spacing between all columns, in pixels.

The default setting is 0.

GtkTable::set_homogeneous

void set_homogeneous(bool homogeneous);

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.

GtkTable::children

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.

GtkTable::nrows

Type: Read Only

The nrows property consists of the number of rows currently contained in a GtkTable.

GtkTable::ncols

Type: Read Only

The ncols property consists of the number of columns currently contained in a GtkTable.

GtkTable::column_spacing

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.

GtkTable::row_spacing

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.

GtkTable::homogeneous

Type: Read Only

homogeneous when queried returns 1 (true) if the table is homogeneous, or 0 (false) if it is not.

GtkTableChild

Helper class for GtkTable.

Object Hierarchy

Object Properties and Methods

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.

Description

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";
}
     

GtkTableChild::widget

Type: Read Only

The widget property returns the child widget.

GtkTableChild::left_attach

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.

GtkTableChild::right_attach

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.

GtkTableChild::top_attach

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.

GtkTableChild::bottom_attach

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.

GtkTableChild::xpadding

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.

GtkTableChild::ypadding

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.

GtkTableChild::xexpand

Type: Read Only

Returns true if the GTK_EXPAND flag is set on the x axis.

GtkTableChild::yexpand

Type: Read Only

Returns true if the GTK_EXPAND flag is set on the y axis.

GtkTableChild::xshrink

Type: Read Only

Returns true if the GTK_SHRINK flag is set on the x axis.

GtkTableChild::yshrink

Type: Read Only

Returns true if the GTK_SHRINK flag is set on the y axis.

GtkTableChild::xfill

Type: Read Only

Returns true if the GTK_FILL flag is set on the x axis.

GtkTableChild::yfill

Type: Read Only

Returns true if the GTK_FILL flag is set on the y axis.

GtkTearoffMenuItem

Menu item used to tear off and reattach its menu.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkMenuItem
áááááááááááááááááááááááááááááá`-- GtkTearoffMenuItem

Object Properties and Methods

Constructor

— Creates the means to tear off a menu.

Description

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 Constructor

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:

     
$menu = &new GtkMenu();
$tearoff = &new GtkTearoffMenuItem();
$menu->prepend($tearoff);
     

GtkText

Editable text-display widget.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkEditable
áááááááááááá`-- GtkText

Object Properties and Methods

Constructor

GtkText ([ GtkAdjustment hadj = NULL , [ GtkAdjustment vadj = NULL ]]);

— Creates a scrollable text widget.

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.

Description

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 Constructor

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();
     

GtkText::set_editable

void set_editable(bool editable);

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.

GtkText::set_word_wrap

void set_word_wrap(bool word_wrap);

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.

Note

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.

GtkText::set_line_wrap

void set_line_wrap(bool line_wrap);

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() .

GtkText::set_adjustments

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.

GtkText::set_point

void set_point(int index);

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.

GtkText::get_point

int get_point(void);

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.

GtkText::get_length

int get_length(void);

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.

GtkText::freeze

void freeze(void);

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() .

GtkText::thaw

void thaw(void);

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.

GtkText::insert

void insert( GdkFont font , GdkColor fore , GdkColor back , string chars, [int length = -1 ]);

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:

     
$text->insert(null, null, null, "A string of text.");
      

GtkText::backward_delete

int backward_delete(int nchars);

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.

GtkText::forward_delete

int forward_delete(int nchars);

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.

GtkText::hadj

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.

GtkText::vadj

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.

GtkTipsQuery

Displays help about widgets in the user interface.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkMisc
áááááááááááá`-- GtkLabel
áááááááááááááááááá`-- GtkTipsQuery

Object Properties and Methods

Constructor

GtkTipsQuery (void);

Description

GtkTipsQuery Constructor

GtkTipsQuery (void);

GtkTipsQuery::start_query

void start_query(void);

GtkTipsQuery::stop_query

void stop_query(void);

GtkTipsQuery::set_caller

void set_caller(GtkWidget caller);

GtkTipsQuery::set_labels

void set_labels(string label_inactive, string label_no_tip);

GtkToggleButton

Button that retains its state.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkButton
áááááááááááááááááááááááá`-- GtkToggleButton

Object Properties and Methods

Constructor

GtkToggleButton ([string label ]);

— Creates a button that can be toggled between two states.

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.

Description

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 Constructor

GtkToggleButton ([string label ]);

     
$togglebutton = &new GtkToggleButton("GtkToggleButton's label");
     
creates a GtkToggleButton that can be toggled between active and normal states.

GtkToggleButton::set_mode

void set_mode(bool draw_indicator);

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.

GtkToggleButton::set_active

void set_active(bool is_active);

set_active() determines whether the GtkToggleButton's initial state is GTK_STATE_ACTIVE or otherwise.

The default setting is false.

GtkToggleButton::get_active

bool get_active(void);

get_active() returns true if the calling GtkToggleButton's current state is GTK_STATE_ACTIVE.

GtkToggleButton::toggled

void toggled(void);

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.

toggled

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);

GtkToggleButton::draw_indicator

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

     
$togglebutton->draw_indicator;
      

The draw_indicator property should not be accessed directly. Use set_mode() where the value needs to be changed.

GtkToolbar

Container that creates bars of buttons and other widgets.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkToolbar

Object Properties and Methods

Constructor

GtkToolbar (GtkOrientation orientation, GtkToolbarStyle style);

Description

GtkToolbar Constructor

GtkToolbar (GtkOrientation orientation, GtkToolbarStyle style);

GtkToolbar::append_space

void append_space(void);

GtkToolbar::prepend_space

void prepend_space(void);

GtkToolbar::insert_space

void insert_space(int position);

GtkToolbar::append_widget

void append_widget(GtkWidget widget, string tooltip_text, string tooltip_private_text);

GtkToolbar::prepend_widget

void prepend_widget(GtkWidget widget, string tooltip_text, string tooltip_private_text);

GtkToolbar::insert_widget

void insert_widget(GtkWidget widget, string tooltip_text, string tooltip_private_text, int position);

GtkToolbar::set_orientation

void set_orientation(GtkOrientation orientation);

GtkToolbar::set_style

void set_style(GtkToolbarStyle style);

GtkToolbar::set_space_size

void set_space_size(int space_size);

GtkToolbar::set_space_style

void set_space_style(GtkToolbarSpaceStyle space_style);

GtkToolbar::set_tooltips

void set_tooltips(int enable);

GtkToolbar::set_button_relief

void set_button_relief(GtkReliefStyle relief);

GtkToolbar::get_button_relief

GtkReliefStyle get_button_relief(void);

GtkTooltips

Adds tooltips to other widgets.

Object Hierarchy

GtkObject
`-- GtkData
áááááá`-- GtkTooltips

Object Properties and Methods

Constructor

GtkTooltips (void);

Description

GtkTooltips Constructor

GtkTooltips (void);

GtkTooltips::enable

void enable(void);

GtkTooltips::disable

void disable(void);

GtkTooltips::set_delay

void set_delay(int delay);

GtkTooltips::set_tip

void set_tip( GtkWidget widget , string tip_text, string tip_private);

GtkTooltips::set_colors

void set_colors( GdkColor background , GdkColor foreground );

GtkTooltips::force_window

void force_window(void);

GtkTree

Widget for displaying hierarchical information.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkTree

Object Properties and Methods

Constructor

GtkTree (void);

Description

GtkTree Constructor

GtkTree (void);

GtkTree::append

void append(GtkWidget tree_item);

GtkTree::prepend

void prepend(GtkWidget tree_item);

GtkTree::insert

void insert(GtkWidget tree_item, int position);

GtkTree::clear_items

void clear_items(int start, int end);

GtkTree::select_item

void select_item(int item);

GtkTree::unselect_item

void unselect_item(int item);

GtkTree::select_child

void select_child(GtkWidget tree_item);

GtkTree::unselect_child

void unselect_child(GtkWidget tree_item);

GtkTree::child_position

int child_position(GtkWidget child);

GtkTree::set_selection_mode

void set_selection_mode(GtkSelectionMode mode);

GtkTree::set_view_mode

void set_view_mode(GtkTreeViewMode mode);

GtkTree::set_view_lines

void set_view_lines(int flag);

GtkTree::remove_item

void remove_item(GtkWidget child);

GtkTreeItem

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkItem
áááááááááááááááááááááááá`-- GtkTreeItem

Object Properties and Methods

Constructor

GtkTreeItem (XXX);

Description

GtkTreeItem Constructor

GtkTreeItem (XXX);

GtkTreeItem::set_subtree

void set_subtree(GtkWidget subtree);

GtkTreeItem::remove_subtree

void remove_subtree(void);

GtkTreeItem::select

void select(void);

GtkTreeItem::deselect

void deselect(void);

GtkTreeItem::expand

void expand(void);

GtkTreeItem::collapse

void collapse(void);

GtkVBox

Vertical box container.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkVBox

Object Properties and Methods

Constructor

GtkVBox ([bool homogeneous = false , [int spacing = 0 ]]);

— Creates a container for a single column of child widgets.

Description

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 Constructor

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.

     $vbox = &new GtkVBox();
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();
     

GtkVButtonBox

Container for arranging a group of buttons vertically.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBox
áááááááááááááááááá`-- GtkButtonBox
áááááááááááááááááááááááá`-- GtkVButtonBox

Object Properties and Methods

Constructor

GtkVButtonBox (void);

— Creates the basis for a vertical button container.

Description

GtkVButtonBox is a container widget designed for arranging a column of buttons in accordance with a specified GtkButtonBoxStyle setting.

See also: GtkButtonBox, GtkHButtonBox.

GtkVButtonBox Constructor

GtkVButtonBox (void);

The syntax for creating a vertical buttonbox is:

     
$vbuttonbox = &new GtkVButtonBox();
     
There are no parameters.

As with all container widgets, no physical space is taken by a GtkVButtonBox until its child widgets are in place.

GtkViewport

Provides scrolling capability for non-scrolling aware widgets.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkViewport

Object Properties and Methods

Constructor

GtkViewport ([ GtkAdjustment hadjustment = NULL , [ GtkAdjustment vadjustment = NULL ]]);

— Creates a scrollable container.

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.

Description

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 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();
     

GtkViewport::get_hadjustment

GtkAdjustment get_hadjustment (void);

get_hadjustment() returns the GtkAdjustment object that is used in horizontal scrolling.

GtkViewport::get_vadjustment

GtkAdjustment get_vadjustment (void);

get_vadjustment() returns the GtkAdjustment object that is used in vertical scrolling.

GtkViewport::set_shadow_type

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.

GtkVPaned

Container with two panes arranged vertically.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkPaned
áááááááááááááááááá`-- GtkVPaned

Object Properties and Methods

Constructor

GtkVPaned (void);

— Creates the basis for a vertical dual-paned container.

Description

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.

See also: GtkPaned, GtkHPaned.

GtkVPaned Constructor

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

     $vbox = &new GtkVBox();
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.

GtkVRuler

Vertical ruler.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkRuler
áááááááááááá`-- GtkVRuler

Object Properties and Methods

Constructor

GtkVRuler (void);

Description

GtkVRuler Constructor

GtkVRuler (void);

GtkVScale

Vertical slider widget for selecting a value from a range.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkRange
áááááááááááá`-- GtkScale
áááááááááááááááááá`-- GtkVScale

Object Properties and Methods

Constructor

GtkVScale ([ GtkAdjustment adjustment = NULL ]);

— Creates a vertical slider.

Description

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 Constructor

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:

     
$adjustment = &new GtkAdjustment(0, 0, 100, 1, 25, 0);
$vscale = &new GtkVScale($adjustment);
     
This would give a scale of 0 to 100 along the height of the page, and no overlap.

GtkVScrollbar

Vertical scrollbar.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkRange
áááááááááááá`-- GtkScrollbar
áááááááááááááááááá`-- GtkVScrollbar

Object Properties and Methods

Constructor

GtkVScrollbar ([ GtkAdjustment adjustment = NULL ]);

— Creates a vertical scrollbar.

Description

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 Constructor

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:

     
$text = &new GtkText();
$adjustment = $text->vadj;
$scrollbar = &new GtkVScrollbar($adjustment);
     

GtkVSeparator

Vertical separator.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkSeparator
áááááááááááá`-- GtkVSeparator

Object Properties and Methods

Constructor

GtkVSeparator (void);

— Draws a vertical line.

Description

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 Constructor

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.

GtkWidget

Base class for user interface elements.

Object Hierarchy

Object Properties and Methods

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.

Description

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.

GtkWidget::drag_highlight

void drag_highlight(void);

GtkWidget::drag_unhighlight

void drag_unhighlight(void);

GtkWidget::drag_dest_unset

void drag_dest_unset(void);

GtkWidget::drag_source_unset

void drag_source_unset(void);

GtkWidget::drag_source_set_icon

void drag_source_set_icon( GdkColormap colormap , GdkPixmap pixmap , GdkBitmap mask );

GtkWidget::selection_owner_set

int selection_owner_set(GdkAtom selection, int time);

GtkWidget::selection_add_target

void selection_add_target(GdkAtom selection, GdkAtom target, int info);

GtkWidget::selection_convert

int selection_convert(GdkAtom selection, GdkAtom target, int time);

GtkWidget::selection_remove_all

void selection_remove_all(void);

GtkWidget::unparent

void unparent(void);

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.

GtkWidget::show

void show(void);

show() is a commonly-used method that combines a series of other methods in order to display a widget on the screen.

See also: map() , realize() .

GtkWidget::show_now

void show_now(void);

GtkWidget::hide

void hide(void);

hide() is the corollary to the show() method. It combines other methods in order to hide the calling widget from display.

GtkWidget::show_all

void show_all(void);

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.

GtkWidget::hide_all

void hide_all(void);

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.

GtkWidget::map

void map(void);

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.

GtkWidget::unmap

void unmap(void);

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.

GtkWidget::realize

void realize(void);

GtkWidget::unrealize

void unrealize(void);

GtkWidget::queue_draw

void queue_draw(void);

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.

GtkWidget::queue_draw_area

void queue_draw_area(int x, int y, int width, int height);

This has exactly the same functionality as queue_draw() , with the exception that the area to be redrawn can be defined in the parameters.

GtkWidget::queue_clear

void queue_clear(void);

GtkWidget::queue_clear_area

void queue_clear_area(int x, int y, int width, int height);

GtkWidget::queue_resize

void queue_resize(void);

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.

GtkWidget::draw

void draw(GdkRectangle area);

GtkWidget::draw_focus

void draw_focus(void);

GtkWidget::draw_default

void draw_default(void);

GtkWidget::add_accelerator

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.

Note

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.

GtkWidget::remove_accelerator

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.

GtkWidget::remove_accelerators

void remove_accelerators(string accel_signal, bool visible_only);

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.

GtkWidget::lock_accelerators

void lock_accelerators(void);

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.

GtkWidget::unlock_accelerators

void unlock_accelerators(void);

unlock_accelerators() unlocks the accelerator entries defined in the calling widget, allowing changes or additions to be made to them.

See also: accelerators_locked() .

GtkWidget::accelerators_locked

bool accelerators_locked(void);

accelerators_locked() returns true if the accelerators on the calling widget are locked, and false if they are not.

GtkWidget::event

int event( GdkEvent event );

GtkWidget::activate

bool activate(void);

GtkWidget::reparent

void reparent( GtkWidget new_parent );

GtkWidget::popup

void popup(int x, int y);

GtkWidget::intersect

XXX intersect(XXX);

GtkWidget::grab_focus

void grab_focus(void);

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.

GtkWidget::grab_default

void grab_default(void);

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() .

GtkWidget::set_name

void set_name(string name);

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() .

GtkWidget::get_name

string get_name(void);

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() .

GtkWidget::set_state

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.

GtkWidget::set_sensitive

void set_sensitive(bool sensitive);

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.

Note

Setting a container as 'insensitive' will make all that container's children insensitive too.

GtkWidget::set_app_paintable

void set_app_paintable(bool app_paintable);

GtkWidget::set_parent

void set_parent( GtkWidget parent );

GtkWidget::set_parent_window

void set_parent_window( GdkWindow parent_window );

GtkWidget::get_parent_window

GdkWindow get_parent_window (void);

GtkWidget::set_uposition

void set_uposition(int x, int y);

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.

GtkWidget::set_usize

void set_usize(int width, int height);

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.

GtkWidget::set_events

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:

     
$widget->set_events(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
      
This would enable a previously keyboard-insensitive widget to emit key-press-event and key-release-event signals.

GtkWidget::add_events

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:

     
$widget->add_events(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
      
This would enable a previously mouse-insensitive widget to emit button-press-event and button-release-event signals.

GtkWidget::get_toplevel

GtkWidget get_toplevel (void);

GtkWidget::get_ancestor

GtkWidget get_ancestor (int widget_type);

GtkWidget::get_colormap

GdkColormap get_colormap (void);

GtkWidget::get_visual

GdkVisual get_visual (void);

GtkWidget::set_colormap

void set_colormap( GdkColormap colormap );

GtkWidget::set_visual

void set_visual( GdkVisual visual );

GtkWidget::get_events

int get_events(void);

GtkWidget::is_ancestor

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.

GtkWidget::hide_on_delete

int hide_on_delete(void);

GtkWidget::set_style

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.

See also: GtkStyle, copy() .

GtkWidget::set_rc_style

void set_rc_style(void);

GtkWidget::ensure_style

void ensure_style(void);

GtkWidget::get_style

GtkStyle get_style (void);

GtkWidget::restore_default_style

void restore_default_style(void);

GtkWidget::set_composite_name

void set_composite_name(string name);

GtkWidget::get_composite_name

string get_composite_name(void);

GtkWidget::reset_rc_styles

void reset_rc_styles(void);

GtkWidget::shape_combine_mask

void shape_combine_mask( GdkBitmap shape_mask , int offset_x, int offset_y);

show

Callback function:

void callback(GtkWidget widget);

hide

Callback function:

void callback(GtkWidget widget);

map

Callback function:

void callback(GtkWidget widget);

unmap

Callback function:

void callback(GtkWidget widget);

realize

Callback function:

void callback(GtkWidget widget);

unrealize

Callback function:

void callback(GtkWidget widget);

draw

Callback function:

void callback(GtkWidget widget, );

draw-focus

Callback function:

void callback(GtkWidget widget);

draw-default

Callback function:

void callback(GtkWidget widget);

size-request

Callback function:

void callback(GtkWidget widget, );

size-allocate

Callback function:

void callback(GtkWidget widget, );

state-changed

Callback function:

void callback(GtkWidget widget, );

parent-set

Callback function:

void callback(GtkWidget widget, GtkWidget parent);

style-set

Callback function:

void callback(GtkWidget widget, );

add-accelerator

Callback function:

void callback(GtkWidget widget);

remove-accelerator

Callback function:

void callback(GtkWidget widget);

grab-focus

Callback function:

void callback(GtkWidget widget);

event

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.

Note

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);

button-press-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);

button-release-event

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);

motion-notify-event

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);

delete-event

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);

destroy-event

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);

expose-event

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);

key-press-event

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";
}}
      

Note

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);

key-release-event

Callback function:

bool callback(GtkWidget widget, GdkEvent key_release);

enter-notify-event

Callback function:

bool callback(GtkWidget widget, GdkEvent enter_notify);

leave-notify-event

Callback function:

bool callback(GtkWidget widget, GdkEvent leave_notify);

configure-event

Callback function:

bool callback(GtkWidget widget, GdkEvent configure);

focus-in-event

Callback function:

bool callback(GtkWidget widget, GdkEvent focus_change);

focus-out-event

Callback function:

bool callback(GtkWidget widget, GdkEvent focus_change);

map-event

Callback function:

bool callback(GtkWidget widget, GdkEvent map);

unmap-event

Callback function:

bool callback(GtkWidget widget, GdkEvent unmap);

property-notify-event

Callback function:

bool callback(GtkWidget widget, GdkEvent property_notify);

selection-clear-event

Callback function:

bool callback(GtkWidget widget, GdkEvent selection_clear);

selection-request-event

Callback function:

bool callback(GtkWidget widget, GdkEvent selection_request);

selection-notify-event

Callback function:

bool callback(GtkWidget widget, GdkEvent selection_notify);

selection-received

Callback function:

void callback(GtkWidget widget, , );

selection-get

Callback function:

void callback(GtkWidget widget, , , );

proximity-in-event

Callback function:

bool callback(GtkWidget widget, GdkEvent proximity_in);

proximity-out-event

Callback function:

bool callback(GtkWidget widget, GdkEvent proximity_out);

drag-leave

Callback function:

void callback(GtkWidget widget, , );

drag-begin

Callback function:

void callback(GtkWidget widget, );

drag-end

Callback function:

void callback(GtkWidget widget, );

drag-data-delete

Callback function:

void callback(GtkWidget widget, );

drag-motion

Callback function:

bool callback(GtkWidget widget, , , , );

drag-drop

Callback function:

bool callback(GtkWidget widget, , , , );

drag-data-get

Callback function:

void callback(GtkWidget widget, , , , );

drag-data-received

Callback function:

void callback(GtkWidget widget, , , , , , );

visibility-notify-event

Callback function:

bool callback(GtkWidget widget, GdkEvent visibility_notify);

client-event

Callback function:

bool callback(GtkWidget widget, GdkEvent client_event);

no-expose-event

Emitted when a GDK_NO_EXPOSE event is captured.

Callback function:

bool callback(GtkWidget widget, GdkEvent no_expose);

debug-msg

Callback function:

void callback(GtkWidget widget, );

GtkWidget::style

Type: Read Only

GtkWidget::window

Type: Read Only

GtkWidget::allocation

Type: Read Only

GtkWidget::state

Type: Read Only

GtkWidget::parent

Type: Read Only

GtkWindow

Widget that provides windows for an application.

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkWindow

Object Properties and Methods

Constructor

GtkWindow ([ GtkWindowType type = GTK_WINDOW_TOPLEVEL ]);

— Creates a new GtkWindow.

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.

Description

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.

Note

A GtkWindow object is derived from GtkBin, and can therefore only have one child widget added to it directly. To add more children it is necessary to make that child a container that can hold mulitple children. See GtkBox.

GtkWindow Constructor

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();
     

GtkWindow::set_title

void set_title(string title);

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.

GtkWindow::set_wmclass

void set_wmclass(string wmclass_name, string wmclass_class);

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.

GtkWindow::set_policy

void set_policy(int allow_shrink, int allow_grow, int auto_shrink);

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.

GtkWindow::add_accel_group

void add_accel_group( GtkAccelGroup accel_group );

Adds an existing GtkAccelGroup to the window, allowing keyboard shortcuts to be created - usually for menus.

GtkWindow::remove_accel_group

void remove_accel_group( GtkAccelGroup accel_group );

Removes the named accelerator group from the window.

GtkWindow::set_position

void set_position( GtkWindowPosition position );

set_position() sets the position of the window on opening to one of four possible GtkWindowPosition values.

GtkWindow::activate_focus

int activate_focus(void);

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.

Note

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.

GtkWindow::activate_default

int activate_default(void);

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.

GtkWindow::set_transient_for

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() .

GtkWindow::set_default_size

void set_default_size(int width, int height);

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.

GtkWindow::set_modal

void set_modal(bool modal);

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.

GtkWindow::set_focus

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() .

GtkWindow::set_default

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() .

set-focus

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 );

Misc GTK Functions

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.

gtk::accel_group_get_default

GtkAccelGroup gtk::accel_group_get_default (void);

gtk::button_box_set_child_ipadding_default

void gtk::button_box_set_child_ipadding_default (int ipad_x, int ipad_y);

gtk::button_box_set_child_size_default

void gtk::button_box_set_child_size_default (int min_width, int min_height);

gtk::check_version

string gtk::check_version(int required_major, int required_minor, int required_micro);

gtk::drag_finish

void gtk::drag_finish( GdkDragContext context , bool success, bool del, int time);

gtk::drag_get_source_widget

GtkWidget gtk::drag_get_source_widget ( GdkDragContext context );

gtk::drag_set_default_icon

void gtk::drag_set_default_icon( GdkColormap colormap , GdkPixmap pixmap , GdkBitmap mask , int hot_x, int hot_y);

gtk::drag_set_icon_default

void gtk::drag_set_icon_default( GdkDragContext context );

gtk::drag_set_icon_pixmap

void gtk::drag_set_icon_pixmap( GdkDragContext context , GdkColormap colormap , GdkPixmap pixmap , GdkBitmap mask , int hot_x, int hot_y);

gtk::drag_set_icon_widget

void gtk::drag_set_icon_widget( GdkDragContext context , GtkWidget widget , int hot_x, int hot_y);

gtk::drag_dest_handle_event

void gtk::drag_dest_handle_event( GtkWidget toplevel , GdkEvent event );

gtk::drag_source_handle_event

void gtk::drag_source_handle_event ( GtkWidget widget , GdkEvent event );

gtk::draw_arrow

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);
      

gtk::draw_box

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.

     
gtk::draw_box($style, $gdkwindow, GTK_STATE_ACTIVE, GTK_SHADOW_IN, $x, $y, 
$width, $height);
      

gtk::draw_diamond

void gtk::draw_diamond( GtkStyle style , GdkWindow window , GtkStateType state_type , GtkShadowType shadow_type , int x, int y, int width, int height);

gtk::draw_hline

void gtk::draw_hline( GtkStyle style , GdkWindow window , GtkStateType state_type , int x1, int x2, int y);

gtk::draw_oval

void gtk::draw_oval( GtkStyle style , GdkWindow window , GtkStateType state_type , GtkShadowType shadow_type , int x, int y, int width, int height);

gtk::draw_shadow

void gtk::draw_shadow( GtkStyle style , GdkWindow window , GtkStateType state_type , GtkShadowType shadow_type , int x, int y, int width, int height);

gtk::draw_string

void gtk::draw_string( GtkStyle style , GdkWindow window , GtkStateType state_type , int x, int y, string string);

gtk::draw_vline

void gtk::draw_vline( GtkStyle style , GdkWindow window , GtkStateType state_type , int y1, int y2, int x);

gtk::entry_new_with_max_length

GtkWidget gtk::entry_new_with_max_length (int max);

gtk::events_pending

int gtk::events_pending(void);

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

     
while(gtk::events_pending()) gtk::main_iteration();
      
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() .

gtk::false

int gtk::false(void);

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.

gtk::hbutton_box_get_layout_default

GtkButtonBoxStyle gtk::hbutton_box_get_layout_default (void);

gtk::hbutton_box_get_spacing_default

int gtk::hbutton_box_get_spacing_default (void);

gtk::grab_add

void gtk::grab_add( GtkWidget widget );

gtk::grab_get_current

GtkWidget gtk::grab_get_current (void);

gtk::grab_remove

void gtk::grab_remove( GtkWidget widget );

gtk::hbutton_box_set_layout_default

void gtk::hbutton_box_set_layout_default ( GtkButtonBoxStyle layout );

gtk::hbutton_box_set_spacing_default

void gtk::hbutton_box_set_spacing_default (int spacing);

gtk::idle_add

int gtk::idle_add( GtkFunction function , [mixed data ]);

gtk::idle_remove

void gtk::idle_remove(int idle_handler_id);

gtk::input_add

XXX gtk::input_add(XXX);

gtk::input_remove

void gtk::input_remove(int input_handler_id);

gtk::item_factories_path_delete

void gtk::item_factories_path_delete (string ifactory_path, string path);

gtk::item_factory_from_path

GtkItemFactory gtk::item_factory_from_path (string path);

gtk::item_factory_from_widget

GtkItemFactory gtk::item_factory_from_widget ( GtkWidget widget );

gtk::item_factory_parse_rc

void gtk::item_factory_parse_rc(string file_name);

gtk::item_factory_parse_rc_string

void gtk::item_factory_parse_rc_string (string rc_string);

gtk::item_factory_path_from_widget

string gtk::item_factory_path_from_widget ( GtkWidget widget );

gtk::main

void gtk::main(void);

gtk::main_do_event

void gtk::main_do_event( GdkEvent event );

gtk::main_iteration

int gtk::main_iteration(void);

gtk::main_iteration_do

int gtk::main_iteration_do([bool blocking = TRUE ]);

gtk::main_level

int gtk::main_level(void);

gtk::main_quit

void gtk::main_quit(void);

gtk::paint_arrow

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);

gtk::paint_box

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);

gtk::paint_box_gap

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);

gtk::paint_check

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);

gtk::paint_cross

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);

gtk::paint_diamond

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);

gtk::paint_extension

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 );

gtk::paint_flat_box

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);

gtk::paint_focus

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).

gtk::paint_handle

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 );

gtk::paint_hline

void gtk::paint_hline( GtkStyle style , GdkWindow window , GtkStateType state_type , GdkRectangle area, GtkWidget widget , string detail, int x1, int x2, int y);

gtk::paint_option

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);

gtk::paint_oval

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);

gtk::paint_ramp

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);

gtk::paint_shadow

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);

gtk::paint_shadow_gap

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);

gtk::paint_slider

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 );

gtk::paint_string

void gtk::paint_string( GtkStyle style , GdkWindow window , GtkStateType state_type , GdkRectangle area, GtkWidget widget , string detail, int x, int y, string string);

gtk::paint_tab

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);

gtk::paint_vline

void gtk::paint_vline( GtkStyle style , GdkWindow window , GtkStateType state_type , GdkRectangle area, GtkWidget widget , string detail, int y1, int y2, int x);

gtk::preview_get_cmap

GdkColormap gtk::preview_get_cmap (void);

gtk::preview_get_visual

GdkVisual gtk::preview_get_visual (void);

gtk::preview_reset

void gtk::preview_reset(void);

gtk::preview_set_color_cube

void gtk::preview_set_color_cube(int nred_shades, int ngreen_shades, int nblue_shades, int ngray_shades);

gtk::preview_set_gamma

void gtk::preview_set_gamma(double gamma);

gtk::preview_set_install_cmap

void gtk::preview_set_install_cmap(int install_cmap);

gtk::preview_set_reserved

void gtk::preview_set_reserved(int nreserved);

gtk::quit_add

XXX gtk::quit_add(XXX);

gtk::quit_remove

void gtk::quit_remove(int quit_handler_id);

gtk::rc_add_default_file

void gtk::rc_add_default_file(string filename);

gtk::rc_find_module_in_path

string gtk::rc_find_module_in_path (string module_file);

gtk::rc_get_module_dir

string gtk::rc_get_module_dir(void);

gtk::rc_get_style

GtkStyle gtk::rc_get_style ( GtkWidget widget );

gtk::rc_get_theme_dir

string gtk::rc_get_theme_dir(void);

gtk::rc_load_image

GdkPixmap gtk::rc_load_image ( GdkColormap colormap , GdkColor transparent_color , string filename);

gtk::rc_parse

void gtk::rc_parse(string filename);

gtk::rc_parse_string

void gtk::rc_parse_string(string rc_string);

gtk::rc_reparse_all

bool gtk::rc_reparse_all(void);

gtk::timeout_add

int gtk::timeout_add(int interval, GtkFunction function , [mixed data ]);

gtk::timeout_remove

void gtk::timeout_remove(int timeout_handler_id);

gtk::true

int gtk::true(void);

This is a static function that simply returns 1. It has no other functionality.

gtk::type_from_name

int gtk::type_from_name(string name);

gtk::type_name

string gtk::type_name(int type);

gtk::vbutton_box_get_layout_default

GtkButtonBoxStyle gtk::vbutton_box_get_layout_default (void);

gtk::vbutton_box_get_spacing_default

int gtk::vbutton_box_get_spacing_default (void);

gtk::vbutton_box_set_layout_default

void gtk::vbutton_box_set_layout_default ( GtkButtonBoxStyle layout );

gtk::vbutton_box_set_spacing_default

void gtk::vbutton_box_set_spacing_default (int spacing);

gtk::widget_get_default_colormap

GdkColormap gtk::widget_get_default_colormap (void);

gtk::widget_get_default_style

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.

gtk::widget_get_default_visual

GdkVisual gtk::widget_get_default_visual (void);

gtk::widget_pop_colormap

void gtk::widget_pop_colormap(void);

gtk::widget_pop_composite_child

void gtk::widget_pop_composite_child(void);

gtk::widget_pop_style

void gtk::widget_pop_style(void);

gtk::widget_pop_visual

void gtk::widget_pop_visual(void);

gtk::widget_push_colormap

void gtk::widget_push_colormap( GdkColormap cmap );

gtk::widget_push_composite_child

void gtk::widget_push_composite_child(void);

gtk::widget_push_style

void gtk::widget_push_style( GtkStyle style );

gtk::widget_push_visual

void gtk::widget_push_visual( GdkVisual visual );

gtk::widget_set_default_colormap

void gtk::widget_set_default_colormap ( GdkColormap colormap );

gtk::widget_set_default_style

void gtk::widget_set_default_style ( GtkStyle style );

gtk::widget_set_default_visual

void gtk::widget_set_default_visual ( GdkVisual visual );

Table of Contents

GdkAtom
GdkBitmap
GdkColor
A structure that holds a defined color.
GdkColormap
GdkCursor
GdkDragContext
GdkFont
Structure holding font information.
GdkGC
A structure that contains graphics information.
GdkPixmap
GdkVisual
GdkWindow
Misc GDK Functions

GdkAtom

Object Hierarchy

Object Properties and Methods

Description

GdkBitmap

Object Hierarchy

Object Properties and Methods

Description

GdkBitmap::extents

array extents(void);

GdkBitmap::lock

int lock(void);

GdkBitmap::height

int height(void);

GdkBitmap::width

int width(void);

GdkColor

A structure that holds a defined color.

Object Hierarchy

Object Properties and Methods

Constructor

GdkColor (int red, int green, int blue);

— Creates a new color object using one of three possible constructs.

Description

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 Constructor

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:

     
/* XcmsRGB values, expressed as three integers */
$cyan = &new GdkColor(0, 65535, 65535);
     
or
     
/* hex triples expressed as a single string */
$cyan = &new GdkColor('#00FFFF');
     
or
     
/* a color name expressed as a single string */
$cyan = &new GdkColor('cyan');
     
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.

GdkColormap

Object Hierarchy

Object Properties and Methods

Methods

size()
alloc()

Description

GdkColormap::size

void size(void);

GdkColormap::alloc

void alloc(void);

GdkCursor

Object Hierarchy

Object Properties and Methods

Properties

type :
name :

Description

GdkCursor::type

Type: Read Only

GdkCursor::name

Type: Read Only

GdkDragContext

Object Hierarchy

Object Properties and Methods

Properties

protocol :
is_source :
source_window :
dest_window :
targets :
actions :
suggested_action :
action :
start_time :

Description

GdkDragContext::protocol

Type: Read Only

GdkDragContext::is_source

Type: Read Only

GdkDragContext::source_window

Type: Read Only

GdkDragContext::dest_window

Type: Read Only

GdkDragContext::targets

Type: Read Only

GdkDragContext::actions

Type: Read Only

GdkDragContext::suggested_action

Type: Read Only

GdkDragContext::action

Type: Read Only

GdkDragContext::start_time

Type: Read Only

GdkFont

Structure holding font information.

Object Hierarchy

Object Properties and Methods

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.

Description

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.

Note

Under win32 currently, all fonts are of the type GDK_FONT_FONTSET, regardless of the loading method.

GdkFont::extents

array extents(string text_string);

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.

GdkFont::measure

int measure(string text_string);

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.

GdkFont::height

int height(string text_string);

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.

GdkFont::width

int width(string text_string);

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.

GdkFont::type

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.

GdkFont::ascent

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.

GdkFont::descent

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.

GdkGC

A structure that contains graphics information.

Object Hierarchy

Object Properties and Methods

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.

Description

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.

GdkGC::set_dashes

void set_dashes(int offset, array dash_list);

GdkGC::foreground

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:

     
$gc->foreground = $colormap->alloc('red');
      

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.

GdkGC::background

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:

     
$gc->background = $colormap->alloc('lime green');
      
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.

GdkGC::font

Type: Read Write

GdkGC::function

Type: Read Write

GdkGC::fill

Type: Read Write

GdkGC::tile

Type: Read Write

GdkGC::stipple

Type: Read Write

GdkGC::clip_mask

Type: Read Write

GdkGC::subwindow_mode

Type: Read Write

GdkGC::ts_x_origin

Type: Read Write

GdkGC::ts_y_origin

Type: Read Write

GdkGC::clip_x_origin

Type: Read Write

GdkGC::clip_y_origin

Type: Read Write

GdkGC::graphics_exposures

Type: Read Write

GdkGC::line_width

Type: Read Write

GdkGC::line_style

Type: Read Write

GdkGC::cap_style

Type: Read Write

GdkGC::join_style

Type: Read Write

GdkPixmap

Object Hierarchy

Object Properties and Methods

Constructor

GdkPixmap ();

Description

GdkPixmap Constructor

GdkPixmap ();

GdkPixmap::new_gc

void new_gc(void);

GdkPixmap::property_get

void property_get(void);

GdkPixmap::property_change

void property_change(void);

GdkPixmap::property_delete

void property_delete(void);

GdkVisual

Object Hierarchy

Object Properties and Methods

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 :

Description

GdkVisual::type

Type: Read Only

GdkVisual::depth

Type: Read Only

GdkVisual::byte_order

Type: Read Only

GdkVisual::colormap_size

Type: Read Only

GdkVisual::bits_per_rgb

Type: Read Only

GdkVisual::red_mask

Type: Read Only

GdkVisual::red_shift

Type: Read Only

GdkVisual::red_prec

Type: Read Only

GdkVisual::green_mask

Type: Read Only

GdkVisual::green_shift

Type: Read Only

GdkVisual::green_prec

Type: Read Only

GdkVisual::blue_mask

Type: Read Only

GdkVisual::blue_shift

Type: Read Only

GdkVisual::blue_prec

Type: Read Only

GdkWindow

Object Hierarchy

Object Properties and Methods

Properties

width :
height :
x :
y :
colormap :
pointer :
pointer_state :
parent :
toplevel :
children :
type :
depth :
xid :
Not on Windows.

Description

GdkWindow::raise

void raise(void);

GdkWindow::lower

void lower(void);

GdkWindow::get_pointer

void get_pointer(void);

GdkWindow::set_cursor

void set_cursor(void);

GdkWindow::new_gc

void new_gc(void);

GdkWindow::property_get

void property_get(void);

GdkWindow::property_change

void property_change(void);

GdkWindow::property_delete

void property_delete(void);

GdkWindow::set_icon

void set_icon(void);

GdkWindow::width

Type: Read Only

GdkWindow::height

Type: Read Only

GdkWindow::x

Type: Read Only

GdkWindow::y

Type: Read Only

GdkWindow::colormap

Type: Read Only

GdkWindow::pointer

Type: Read Only

GdkWindow::pointer_state

Type: Read Only

GdkWindow::parent

Type: Read Only

GdkWindow::toplevel

Type: Read Only

GdkWindow::children

Type: Read Only

GdkWindow::type

Type: Read Only

GdkWindow::depth

Type: Read Only

GdkWindow::xid

Type: Read Only

Misc GDK Functions

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.

gdk::atom_intern

GdkAtom gdk::atom_intern(string atom_name, [int only_if_exists = FALSE ]);

gdk::beep

void gdk::beep(void);

This function causes a warning sound to be emitted. The precise nature of the sound is system and setup dependant.

gdk::colormap_new

GdkColormap gdk::colormap_new ( GdkVisual visual , bool allocate);

gdk::colormap_get_system

GdkColormap gdk::colormap_get_system (void);

gdk::colormap_get_system_size

int gdk::colormap_get_system_size(void);

gdk::color_parse

GdkColor gdk::color_parse(string color_spec);

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.

gdk::cursor_new

GdkCursor gdk::cursor_new ( GdkCursorType cursor_type );

gdk::cursor_new_from_pixmap

GdkCursor gdk::cursor_new_from_pixmap ( GdkPixmap source , GdkPixmap mask , GdkColor fg , GdkColor bg , int x, int y);

gdk::drag_status

void gdk::drag_status( GdkDragContext context , GdkDragAction action , int time);

gdk::draw_arc

void gdk::draw_arc(GdkWindow drawable, GdkGC gc , int filled, int x, int y, int width, int height, int angle1, int angle2);

gdk::draw_gray_image

void gdk::draw_gray_image(GdkWindow drawable, GdkGC gc , int x, int y, int width, int height, GdkRgbDither dith , string buf, int rowstride);

gdk::draw_line

void gdk::draw_line(GdkWindow drawable, GdkGC gc , int x1, int y1, int x2, int y2);

gdk::draw_pixmap

void gdk::draw_pixmap(GdkWindow drawable, GdkGC gc , GdkWindow src, int xsrc, int ysrc, int xdest, int ydest, int width, int height);

gdk::draw_point

void gdk::draw_point(GdkWindow drawable, GdkGC gc , int x, int y);

gdk::draw_rectangle

void gdk::draw_rectangle(GdkWindow drawable, GdkGC gc , int filled, int x, int y, int width, int height);

gdk::draw_rgb_32_image

void gdk::draw_rgb_32_image(GdkWindow drawable, GdkGC gc , int x, int y, int width, int height, GdkRgbDither dith , string buf, int rowstride);

gdk::draw_rgb_image

void gdk::draw_rgb_image(GdkWindow drawable, GdkGC gc , int x, int y, int width, int height, GdkRgbDither dith , string rgb_buf, int rowstride);

gdk::draw_rgb_image_dithalign

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);

gdk::draw_string

void gdk::draw_string(GdkWindow drawable, GdkFont font , GdkGC gc , int x, int y, string string);

gdk::draw_text

void gdk::draw_text(GdkWindow drawable, GdkFont font , GdkGC gc , int x, int y, string text, int text_length);

gdk::flush

void gdk::flush(void);

gdk::font_load

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 = 
gdk::font_load('-unknown-Arial-normal-r-normal--*-120-96-96-p-0-iso8859-1');
      

Note

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.

gdk::fontset_load

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.

gdk::get_display

string gdk::get_display(void);

gdk::input_remove

void gdk::input_remove(int tag);

gdk::pixmap_colormap_create_from_xpm

XXX gdk::pixmap_colormap_create_from_xpm (XXX);

gdk::pixmap_colormap_create_from_xpm_d

XXX gdk::pixmap_colormap_create_from_xpm_d (XXX);

gdk::pixmap_create_from_xpm

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]);
      
or
     
list ($gdkpixmap, $mask) = 
gdk::pixmap_create_from_xpm($gdkwindow, $transparent_color, 'test.xpm');
$image = &new GtkPixmap($gdkpixmap, $mask);
      

gdk::pixmap_create_from_xpm_d

GdkPixmap gdk::pixmap_create_from_xpm_d (GdkWindow window , [GdkColor transparent_color , array data]);

     
$gdkpixmap = gdk::pixmap_create_from_xpm_d($main_window->window, 
$transparent_color, $data);
      

gdk::pointer_is_grabbed

bool gdk::pointer_is_grabbed(void);

gdk::rgb_gc_set_background

void gdk::rgb_gc_set_background( GdkGC gc , int rgb);

gdk::rgb_gc_set_foreground

void gdk::rgb_gc_set_foreground( GdkGC gc , int rgb);

gdk::rgb_get_cmap

GdkColormap gdk::rgb_get_cmap (void);

gdk::rgb_get_visual

GdkVisual gdk::rgb_get_visual (void);

gdk::rgb_xpixel_from_rgb

int gdk::rgb_xpixel_from_rgb(int rgb);

gdk::screen_height

int gdk::screen_height(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.

gdk::screen_height_mm

int gdk::screen_height_mm(void);

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.

gdk::screen_width

int gdk::screen_width(void);

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.

gdk::screen_width_mm

int gdk::screen_width_mm(void);

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.

gdk::threads_enter

void gdk::threads_enter(void);

gdk::threads_leave

void gdk::threads_leave(void);

gdk::visual_get_best

GdkVisual gdk::visual_get_best (void);

gdk::visual_get_best_with_both

GdkVisual gdk::visual_get_best_with_both (int depth, GdkVisualType visual_type );

gdk::visual_get_best_with_depth

GdkVisual gdk::visual_get_best_with_depth (int depth);

gdk::visual_get_best_with_type

GdkVisual gdk::visual_get_best_with_type ( GdkVisualType visual_type );

gdk::visual_get_system

GdkVisual gdk::visual_get_system (void);

This function returns the GdkVisual that is currently used by the system.

GTK Enums

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.

GtkAnchorType

Symbolic Name

Description

GTK_ANCHOR_CENTER
GTK_ANCHOR_NORTH
GTK_ANCHOR_NORTH_WEST
GTK_ANCHOR_NORTH_EAST
GTK_ANCHOR_SOUTH
GTK_ANCHOR_SOUTH_WEST
GTK_ANCHOR_SOUTH_EAST
GTK_ANCHOR_WEST
GTK_ANCHOR_EAST
GTK_ANCHOR_N
GTK_ANCHOR_NW
GTK_ANCHOR_NE
GTK_ANCHOR_S
GTK_ANCHOR_SW
GTK_ANCHOR_SE
GTK_ANCHOR_W
GTK_ANCHOR_E

GtkArrowType

Symbolic Name

Description

GTK_ARROW_UP The arrow points up.
GTK_ARROW_DOWN The arrow points down.
GTK_ARROW_LEFT The arrow points to the left.
GTK_ARROW_RIGHT The arrow points to the right.

GtkAttachOptions

Symbolic Name

Description

GTK_EXPAND The child's allocated area will expand proportionately when the parent container is resized.
GTK_SHRINK The child will shrink to the dimensions of its size request regardless of the size of the parent or its allocated area.
GTK_FILL The child will expand to fill its allocated area.

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.

GtkButtonBoxStyle

Symbolic Name

Description

GTK_BUTTONBOX_DEFAULT_STYLE The current default style for button arrangement, which can be reset. The default setting is GTK_BUTTONBOX_EDGE.
GTK_BUTTONBOX_SPREAD Specifies that the buttons should be spaced evenly across the area of the buttonbox, with a full-sized space at either edge of the column or row.
GTK_BUTTONBOX_EDGE Specifies that the buttons should be spaced evenly across the area of the buttonbox, with no space at either edge of the column or row.
GTK_BUTTONBOX_START Specifies that the buttons should be packed from the top or left edge of the buttonbox, and spaced according to their spacing and internal padding settings.
GTK_BUTTONBOX_END Specifies that the buttons should be packed from the bottom or right edge of the buttonbox, and spaced according to their spacing and internal padding settings.

GtkCalendarDisplayOptions

Symbolic Name

Description

GTK_CALENDAR_SHOW_HEADING Specifies that the month and year should be displayed.
GTK_CALENDAR_SHOW_DAY_NAMES Specifies that three letter day descriptions should be present.
GTK_CALENDAR_NO_MONTH_CHANGE Prevents the user from switching months with the calendar.
GTK_CALENDAR_SHOW_WEEK_NUMBERS Displays each week numbers of the current year, down the left side of the calendar
GTK_CALENDAR_WEEK_START_MONDAY Starts the calendar week on Monday, instead of the default Sunday

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.

GtkCornerType

Symbolic Name

Description

GTK_CORNER_TOP_LEFT The child is above and to the left of the scrollbars, so that the scrollbars are placed to the right and bottom of it. This is the default behaviour.
GTK_CORNER_BOTTOM_LEFT The child is below and to the left of the scrollbars, so that the scrollbars are placed at the right and top of the window.
GTK_CORNER_TOP_RIGHT The child is above and to the right of the scrollbars, i.e. the scrollbars are positioned at the left and bottom of the window.
GTK_CORNER_BOTTOM_RIGHT The child is below and to the right of the scrollbars, so that the scrollbars are displayed at the left and top of the window.

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

GtkDirectionType

Symbolic Name

Description

GTK_DIR_TAB_FORWARD Intended to tab forward through the children capable of having focus, starting at the left or top. This option appears not to work in the versions of GTK+ used in PHP-GTK, and has been completely rewritten for GTK 2.
GTK_DIR_TAB_BACKWARD Intended to tab backward through the children with focus capability, starting at the right or bottom. This option appears not to work in the versions of GTK+ used in PHP-GTK, and has been completely rewritten for GTK 2.
GTK_DIR_UP Sets initial focus on the child nearest the bottom of the container.
GTK_DIR_DOWN Sets initial focus on the child nearest the top of the container.
GTK_DIR_LEFT Sets initial focus on the child nearest the right edge of the container.
GTK_DIR_RIGHT Sets initial focus on the child nearest the left edge of the container.

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().

GtkJustification

Symbolic Name

Description

GTK_JUSTIFY_LEFT Left-justifies text within the containing area.
GTK_JUSTIFY_RIGHT Right-justifies text within the containing area.
GTK_JUSTIFY_CENTER Centers text within the containing area.
GTK_JUSTIFY_FILL Justifies text from edge to edge of the containing area.

GtkObjectFlags

Symbolic Name

Description

GTK_DESTROYED The object has been destroyed and is processing any shutdown callbacks required.
GTK_FLOATING The object is not contained within another object.
GTK_CONNECTED There are signals which are connected to this object.
GTK_CONSTRUCTED The object has undergone its construction process and is ready to be used.

GtkOrientation

Symbolic Name

Description

GTK_ORIENTATION_HORIZONTAL
GTK_ORIENTATION_VERTICAL

GtkPackerOptions

Symbolic Name

Description

GTK_PACK_EXPAND
GTK_FILL_X
GTK_FILL_Y

GtkPackType

Symbolic Name

Description

GTK_PACK_START Specifies that the packing should be done from top or left of the container widget.
GTK_PACK_END Specifies that the packing should be done from the bottom or right of the container widget.

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

GtkProgressBarOrientation

Symbolic Name

Description

GTK_PROGRESS_LEFT_TO_RIGHT A horizontal progress bar growing from left to right.
GTK_PROGRESS_RIGHT_TO_LEFT A horizontal progress bar growing from right to left.
GTK_PROGRESS_BOTTOM_TO_TOP A vertical progress bar growing from bottom to top.
GTK_PROGRESS_TOP_TO_BOTTOM A vertical progress bar growing from top to bottom.

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.

GtkReliefStyle

Symbolic Name

Description

GTK_RELIEF_NORMAL The default relief style for a button.
GTK_RELIEF_HALF Sets the shadow around the button to GTK_SHADOW_OUT until the button is pressed, and GTK_SHADOW_IN when it is. This is currently the normal relief style for a button.
GTK_RELIEF_NONE Sets the shadow around the button to GTK_SHADOW_NONE except when the cursor enters the area of the button, meaning that only the contents (e.g. the label) of the button show until that point.

GtkResizeMode

Symbolic Name

Description

GTK_RESIZE_PARENT Default setting. Effectively shares the behaviour described in GTK_RESIZE_QUEUE. Only used when writing an original container widget.
GTK_RESIZE_QUEUE Adds any resize requests from a container widget to a queue of resize requests marked GTK_RESIZE_PENDING.
GTK_RESIZE_IMMEDIATE Immediately resets the private flags on a container to GTK_RESIZE_NEEDED, giving the request priority over any (standard) queued resize requests.

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.

GtkSelectionMode

Symbolic Name

Description

GTK_SELECTION_SINGLE Only one item can be selected at any given moment. Other items can have focus, but will not be marked as selected.
GTK_SELECTION_BROWSE Only one item can be selected at any given moment. Any item currently having focus will be marked as selected.
GTK_SELECTION_MULTIPLE Several items may be selected or unselected with a click or using the spacebar. They cannot be selected or unselected in any other way. Note that multiple selection should only be used where all items share the exact same callback routine.
GTK_SELECTION_EXTENDED Several items may be selected or unselected using drag, or the shift (selects all items from the leader to the current focus) or control (selects the item having current focus) keys. Note that extended selection should only be used where all items share the exact same callback routine.

GtkShadowType

Symbolic Name

Description

GTK_SHADOW_NONE No shadow is displayed, resulting in a two-dimensional appearance.
GTK_SHADOW_IN Displays dark shadow on left and upper sides of the widget, resulting in the appearance of the widget being lower than its surrounding area.
GTK_SHADOW_OUT Displays dark shadow on right and lower sides of the widget, resulting in the illusion that the widget is raised above its surrounding area.
GTK_SHADOW_ETCHED_IN Displays the appearance of sunken detail.
GTK_SHADOW_ETCHED_OUT Displays the appearance of raised detail.

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

GtkSpinButtonUpdatePolicy

Symbolic Name

Description

GTK_UPDATE_ALWAYS Always updates the spinbutton value. If an entry is invalid, the value is updated to the lower or upper bound as appropriate.
GTK_UPDATE_IF_VALID Prevents the spinbutton's current value from being altered where an entry is invalid.

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.

GtkStateType

Symbolic Name

Description

GTK_STATE_NORMAL Default state.
GTK_STATE_ACTIVE Denotes that the widget is currently active, e.g. that a button is in the process of being clicked.
GTK_STATE_PRELIGHT Denotes that the area of the widget has been entered by the cursor.
GTK_STATE_SELECTED Denotes that the widget is currently selected.
GTK_STATE_INSENSITIVE Denotes that the widget cannot react to user input.

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.

GtkWindowPosition

Symbolic Name

Description

GTK_WIN_POS_NONE Default state. This setting uses the default window gravity on the underlying windowing system to determine the position of the window. This generally results in the window being mapped from the top left corner of the screen.
GTK_WIN_POS_CENTER Places the window over the center of the screen.
GTK_WIN_POS_MOUSE Draws the window at the point of the mouse cursor. This is useful for popup menus or similar widgets initiated by a mouse-click.
GTK_WIN_POS_CENTER_ALWAYS Places the window over the center of the screen and keeps those co-ordinates stored in memory, so that a redraw following a move elsewhere will reposition the window at the center.

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.

GDK Enums

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.

GdkFunction

Symbolic Name

Description

GDK_COPY
GDK_INVERT
GDK_XOR
GDK_CLEAR
GDK_AND
GDK_AND_REVERSE
GDK_AND_INVERT
GDK_NOOP
GDK_OR
GDK_INVERT
GDK_XOR
GDK_EQUIV
GDK_OR_REVERSE
GDK_COPY_INVERT
GDK_OR_INVERT
GDK_NAND
GDK_SET

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

GdkModifierType

Symbolic Name

Description

GDK_SHIFT_MASK Denotes that a shift modifier is in place. A dedicated key or mouse-button will not become active until the Shift key is pressed down.
GDK_LOCK_MASK Denotes that a Caps Lock modifier is in place. Note that this modifier is illegal for use with accelerator keys, and will not work there.
GDK_CONTROL_MASK Denotes that a control modifier is in place. A dedicated key or mouse-button will not become active until the Control key is pressed down.
GDK_MOD1_MASK Denotes that an alt modifier is in place. A dedicated key or mouse-button will not become active until the Alt key is pressed down.
GDK_MOD2_MASK
GDK_MOD3_MASK
GDK_MOD4_MASK
GDK_MOD5_MASK
GDK_BUTTON1_MASK
GDK_BUTTON2_MASK
GDK_BUTTON3_MASK
GDK_BUTTON4_MASK
GDK_BUTTON5_MASK
GDK_RELEASE_MASK Denotes that the act of releasing the button is a modifier.
GDK_MODIFIER_MASK Returns all the modifiers that are possible in the current context.

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

GtkScintilla

GtkScintilla

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkBin
áááááááááááááááááá`-- GtkFrame
áááááááááááááááááááááááá`-- GtkScintilla

Object Properties and Methods

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()

Description

GtkScintilla Constructor

GtkScintilla (void);

GtkScintilla::find_text

XXX find_text(XXX);

GtkScintilla::add_text

XXX add_text(XXX);

GtkScintilla::insert_text

void insert_text(int pos, string text);

GtkScintilla::clear_all

void clear_all(void);

GtkScintilla::clear_document_style

void clear_document_style(void);

GtkScintilla::get_length

int get_length(void);

GtkScintilla::get_char_at

int get_char_at(int pos);

GtkScintilla::get_current_pos

int get_current_pos(void);

GtkScintilla::get_anchor

int get_anchor(void);

GtkScintilla::get_style_at

int get_style_at(int pos);

GtkScintilla::redo

void redo(void);

GtkScintilla::set_undo_collection

void set_undo_collection(int collect_undo);

GtkScintilla::select_all

void select_all(void);

GtkScintilla::set_save_point

void set_save_point(void);

GtkScintilla::can_redo

int can_redo(void);

GtkScintilla::marker_line_from_handle

int marker_line_from_handle(int handle);

GtkScintilla::marker_delete_handle

void marker_delete_handle(int handle);

GtkScintilla::get_undo_collection

int get_undo_collection(void);

GtkScintilla::get_view_ws

int get_view_ws(void);

GtkScintilla::set_view_ws

void set_view_ws(int view_ws);

GtkScintilla::position_from_point

int position_from_point(int x, int y);

GtkScintilla::goto_line

void goto_line(int line);

GtkScintilla::goto_pos

void goto_pos(int pos);

GtkScintilla::set_anchor

void set_anchor(int pos_anchor);

GtkScintilla::get_cur_line

XXX get_cur_line(XXX);

GtkScintilla::get_end_styled

int get_end_styled(void);

GtkScintilla::convert_eols

void convert_eols(int eol_mode);

GtkScintilla::get_eol_mode

int get_eol_mode(void);

GtkScintilla::set_eol_mode

void set_eol_mode(int eol_mode);

GtkScintilla::start_styling

void start_styling(int pos, int mask);

GtkScintilla::set_styling

void set_styling(int length, int style);

GtkScintilla::get_buffered_draw

int get_buffered_draw(void);

GtkScintilla::set_buffered_draw

void set_buffered_draw(int buffered);

GtkScintilla::set_tab_width

void set_tab_width(int tab_width);

GtkScintilla::get_tab_width

int get_tab_width(void);

GtkScintilla::set_code_page

void set_code_page(int code_page);

GtkScintilla::set_use_palette

void set_use_palette(int use_palette);

GtkScintilla::marker_define

void marker_define(int marker_number, int marker_symbol);

GtkScintilla::marker_set_fore

void marker_set_fore(int marker_number, int fore);

GtkScintilla::marker_set_back

void marker_set_back(int marker_number, int back);

GtkScintilla::marker_add

void marker_add(int line, int marker_number);

GtkScintilla::marker_delete

void marker_delete(int line, int marker_number);

GtkScintilla::marker_delete_all

void marker_delete_all(int marker_number);

GtkScintilla::marker_get

int marker_get(int line);

GtkScintilla::marker_next

int marker_next(int line_start, int marker_mask);

GtkScintilla::marker_previous

int marker_previous(int line_start, int marker_mask);

GtkScintilla::set_margin_type_n

void set_margin_type_n(int margin, int margin_type);

GtkScintilla::get_margin_type_n

int get_margin_type_n(int margin);

GtkScintilla::set_margin_width_n

void set_margin_width_n(int margin, int pixel_width);

GtkScintilla::get_margin_width_n

int get_margin_width_n(int margin);

GtkScintilla::set_margin_mask_n

void set_margin_mask_n(int margin, int mask);

GtkScintilla::get_margin_mask_n

int get_margin_mask_n(int margin);

GtkScintilla::set_margin_sensitive_n

void set_margin_sensitive_n(int margin, int sensitive);

GtkScintilla::get_margin_sensitive_n

int get_margin_sensitive_n(int margin);

GtkScintilla::style_clear_all

void style_clear_all(void);

GtkScintilla::style_set_fore

void style_set_fore(int style, int fore);

GtkScintilla::style_set_back

void style_set_back(int style, int back);

GtkScintilla::style_set_bold

void style_set_bold(int style, int bold);

GtkScintilla::style_set_italic

void style_set_italic(int style, int italic);

GtkScintilla::style_set_size

void style_set_size(int style, int size_points);

GtkScintilla::style_set_font

void style_set_font(int style, string font_name);

GtkScintilla::style_set_eol_filled

void style_set_eol_filled(int style, int filled);

GtkScintilla::style_reset_default

void style_reset_default(void);

GtkScintilla::style_set_underline

void style_set_underline(int style, int underline);

GtkScintilla::style_set_case

void style_set_case(int style, int case_force);

GtkScintilla::style_set_character_set

void style_set_character_set(int style, int character_set);

GtkScintilla::set_sel_fore

void set_sel_fore(int use_setting, int fore);

GtkScintilla::set_sel_back

void set_sel_back(int use_setting, int back);

GtkScintilla::set_caret_fore

void set_caret_fore(int fore);

GtkScintilla::clear_all_cmd_keys

void clear_all_cmd_keys(void);

GtkScintilla::set_styling_ex

void set_styling_ex(int length, string styles);

GtkScintilla::style_set_visible

void style_set_visible(int style, int visible);

GtkScintilla::get_caret_period

int get_caret_period(void);

GtkScintilla::set_caret_period

void set_caret_period(int period_milliseconds);

GtkScintilla::set_word_chars

void set_word_chars(string characters);

GtkScintilla::begin_undo_action

void begin_undo_action(void);

GtkScintilla::end_undo_action

void end_undo_action(void);

GtkScintilla::indic_set_style

void indic_set_style(int indic, int style);

GtkScintilla::indic_get_style

int indic_get_style(int indic);

GtkScintilla::indic_set_fore

void indic_set_fore(int indic, int fore);

GtkScintilla::indic_get_fore

int indic_get_fore(int indic);

GtkScintilla::set_style_bits

void set_style_bits(int bits);

GtkScintilla::get_style_bits

int get_style_bits(void);

GtkScintilla::set_line_state

void set_line_state(int line, int state);

GtkScintilla::get_line_state

int get_line_state(int line);

GtkScintilla::get_max_line_state

int get_max_line_state(void);

GtkScintilla::get_caret_line_visible

int get_caret_line_visible(void);

GtkScintilla::set_caret_line_visible

void set_caret_line_visible(int show);

GtkScintilla::get_caret_line_back

int get_caret_line_back(void);

GtkScintilla::set_caret_line_back

void set_caret_line_back(int back);

GtkScintilla::autoc_show

void autoc_show(int len_entered, string item_list);

GtkScintilla::autoc_cancel

void autoc_cancel(void);

GtkScintilla::autoc_active

int autoc_active(void);

GtkScintilla::autoc_pos_start

int autoc_pos_start(void);

GtkScintilla::autoc_complete

void autoc_complete(void);

GtkScintilla::autoc_stops

void autoc_stops(string character_set);

GtkScintilla::autoc_set_separator

void autoc_set_separator(int separator_character);

GtkScintilla::autoc_get_separator

int autoc_get_separator(void);

GtkScintilla::autoc_select

void autoc_select(string text);

GtkScintilla::autoc_set_cancel_at_start

void autoc_set_cancel_at_start(int cancel);

GtkScintilla::autoc_get_cancel_at_start

int autoc_get_cancel_at_start(void);

GtkScintilla::autoc_set_fill_ups

void autoc_set_fill_ups(string character_set);

GtkScintilla::autoc_set_choose_single

void autoc_set_choose_single(int choose_single);

GtkScintilla::autoc_get_choose_single

int autoc_get_choose_single(void);

GtkScintilla::autoc_set_ignore_case

void autoc_set_ignore_case(int ignore_case);

GtkScintilla::autoc_get_ignore_case

int autoc_get_ignore_case(void);

GtkScintilla::user_list_show

void user_list_show(int list_type, string item_list);

GtkScintilla::autoc_set_auto_hide

void autoc_set_auto_hide(int auto_hide);

GtkScintilla::autoc_get_auto_hide

int autoc_get_auto_hide(void);

GtkScintilla::set_indent

void set_indent(int indent_size);

GtkScintilla::get_indent

int get_indent(void);

GtkScintilla::set_use_tabs

void set_use_tabs(int use_tabs);

GtkScintilla::get_use_tabs

int get_use_tabs(void);

GtkScintilla::set_line_indentation

void set_line_indentation(int line, int indent_size);

GtkScintilla::get_line_indentation

int get_line_indentation(int line);

GtkScintilla::get_line_indent_position

int get_line_indent_position(int line);

GtkScintilla::get_column

int get_column(int pos);

GtkScintilla::set_h_scroll_bar

void set_h_scroll_bar(int show);

GtkScintilla::get_h_scroll_bar

int get_h_scroll_bar(void);

GtkScintilla::set_indentation_guides

void set_indentation_guides(int show);

GtkScintilla::get_indentation_guides

int get_indentation_guides(void);

GtkScintilla::set_highlight_guide

void set_highlight_guide(int column);

GtkScintilla::get_highlight_guide

int get_highlight_guide(void);

GtkScintilla::get_line_end_position

int get_line_end_position(int line);

GtkScintilla::get_code_page

int get_code_page(void);

GtkScintilla::get_caret_fore

int get_caret_fore(void);

GtkScintilla::get_use_palette

int get_use_palette(void);

GtkScintilla::get_read_only

int get_read_only(void);

GtkScintilla::set_current_pos

void set_current_pos(int pos);

GtkScintilla::set_selection_start

void set_selection_start(int pos);

GtkScintilla::get_selection_start

int get_selection_start(void);

GtkScintilla::set_selection_end

void set_selection_end(int pos);

GtkScintilla::get_selection_end

int get_selection_end(void);

GtkScintilla::set_print_magnification

void set_print_magnification(int magnification);

GtkScintilla::get_print_magnification

int get_print_magnification(void);

GtkScintilla::set_print_colour_mode

void set_print_colour_mode(int mode);

GtkScintilla::get_print_colour_mode

int get_print_colour_mode(void);

GtkScintilla::get_first_visible_line

int get_first_visible_line(void);

GtkScintilla::get_line

XXX get_line(XXX);

GtkScintilla::get_line_count

int get_line_count(void);

GtkScintilla::set_margin_left

void set_margin_left(int pixel_width);

GtkScintilla::get_margin_left

int get_margin_left(void);

GtkScintilla::set_margin_right

void set_margin_right(int pixel_width);

GtkScintilla::get_margin_right

int get_margin_right(void);

GtkScintilla::get_modify

int get_modify(void);

GtkScintilla::set_sel

void set_sel(int start, int end);

GtkScintilla::get_sel_text

XXX get_sel_text(XXX);

GtkScintilla::hide_selection

void hide_selection(int normal);

GtkScintilla::point_x_from_position

int point_x_from_position(int pos);

GtkScintilla::point_y_from_position

int point_y_from_position(int pos);

GtkScintilla::line_from_position

int line_from_position(int pos);

GtkScintilla::position_from_line

int position_from_line(int line);

GtkScintilla::line_scroll

void line_scroll(int columns, int lines);

GtkScintilla::scroll_caret

void scroll_caret(void);

GtkScintilla::replace_sel

void replace_sel(string text);

GtkScintilla::set_read_only

void set_read_only(int read_only);

GtkScintilla::null

void null(void);

GtkScintilla::can_paste

int can_paste(void);

GtkScintilla::can_undo

int can_undo(void);

GtkScintilla::empty_undo_buffer

void empty_undo_buffer(void);

GtkScintilla::undo

void undo(void);

GtkScintilla::cut

void cut(void);

GtkScintilla::copy

void copy(void);

GtkScintilla::paste

void paste(void);

GtkScintilla::clear

void clear(void);

GtkScintilla::set_text

void set_text(string text);

GtkScintilla::get_text

XXX get_text(XXX);

GtkScintilla::get_text_length

int get_text_length(void);

GtkScintilla::get_direct_function

int get_direct_function(void);

GtkScintilla::get_direct_pointer

int get_direct_pointer(void);

GtkScintilla::set_overtype

void set_overtype(int overtype);

GtkScintilla::get_overtype

int get_overtype(void);

GtkScintilla::set_caret_width

void set_caret_width(int pixel_width);

GtkScintilla::get_caret_width

int get_caret_width(void);

GtkScintilla::set_target_start

void set_target_start(int pos);

GtkScintilla::get_target_start

int get_target_start(void);

GtkScintilla::set_target_end

void set_target_end(int pos);

GtkScintilla::get_target_end

int get_target_end(void);

GtkScintilla::replace_target

XXX replace_target(XXX);

GtkScintilla::replace_target_re

XXX replace_target_re(XXX);

GtkScintilla::search_in_target

XXX search_in_target(XXX);

GtkScintilla::set_search_flags

void set_search_flags(int flags);

GtkScintilla::get_search_flags

int get_search_flags(void);

GtkScintilla::call_tip_show

void call_tip_show(int pos, string definition);

GtkScintilla::call_tip_cancel

void call_tip_cancel(void);

GtkScintilla::call_tip_active

int call_tip_active(void);

GtkScintilla::call_tip_pos_start

int call_tip_pos_start(void);

GtkScintilla::call_tip_set_hlt

void call_tip_set_hlt(int start, int end);

GtkScintilla::call_tip_set_back

void call_tip_set_back(int back);

GtkScintilla::visible_from_doc_line

int visible_from_doc_line(int line);

GtkScintilla::doc_line_from_visible

int doc_line_from_visible(int line_display);

GtkScintilla::set_fold_level

void set_fold_level(int line, int level);

GtkScintilla::get_fold_level

int get_fold_level(int line);

GtkScintilla::get_last_child

int get_last_child(int line, int level);

GtkScintilla::get_fold_parent

int get_fold_parent(int line);

GtkScintilla::show_lines

void show_lines(int line_start, int line_end);

GtkScintilla::hide_lines

void hide_lines(int line_start, int line_end);

GtkScintilla::get_line_visible

int get_line_visible(int line);

GtkScintilla::set_fold_expanded

void set_fold_expanded(int line, int expanded);

GtkScintilla::get_fold_expanded

int get_fold_expanded(int line);

GtkScintilla::toggle_fold

void toggle_fold(int line);

GtkScintilla::ensure_visible

void ensure_visible(int line);

GtkScintilla::set_fold_flags

void set_fold_flags(int flags);

GtkScintilla::set_tab_indents

void set_tab_indents(int tab_indents);

GtkScintilla::get_tab_indents

int get_tab_indents(void);

GtkScintilla::set_backspace_unindents

void set_backspace_unindents(int bs_unindents);

GtkScintilla::get_backspace_unindents

int get_backspace_unindents(void);

GtkScintilla::line_down

void line_down(void);

GtkScintilla::line_down_extend

void line_down_extend(void);

GtkScintilla::line_up

void line_up(void);

GtkScintilla::line_up_extend

void line_up_extend(void);

GtkScintilla::char_left

void char_left(void);

GtkScintilla::char_left_extend

void char_left_extend(void);

GtkScintilla::char_right

void char_right(void);

GtkScintilla::char_right_extend

void char_right_extend(void);

GtkScintilla::word_left

void word_left(void);

GtkScintilla::word_left_extend

void word_left_extend(void);

GtkScintilla::word_right

void word_right(void);

GtkScintilla::word_right_extend

void word_right_extend(void);

GtkScintilla::home

void home(void);

GtkScintilla::home_extend

void home_extend(void);

GtkScintilla::line_end

void line_end(void);

GtkScintilla::line_end_extend

void line_end_extend(void);

GtkScintilla::document_start

void document_start(void);

GtkScintilla::document_start_extend

void document_start_extend(void);

GtkScintilla::document_end

void document_end(void);

GtkScintilla::document_end_extend

void document_end_extend(void);

GtkScintilla::page_up

void page_up(void);

GtkScintilla::page_up_extend

void page_up_extend(void);

GtkScintilla::page_down

void page_down(void);

GtkScintilla::page_down_extend

void page_down_extend(void);

GtkScintilla::edit_toggle_overtype

void edit_toggle_overtype(void);

GtkScintilla::cancel

void cancel(void);

GtkScintilla::delete_back

void delete_back(void);

GtkScintilla::tab

void tab(void);

GtkScintilla::back_tab

void back_tab(void);

GtkScintilla::new_line

void new_line(void);

GtkScintilla::form_feed

void form_feed(void);

GtkScintilla::v_c_home

void v_c_home(void);

GtkScintilla::v_c_home_extend

void v_c_home_extend(void);

GtkScintilla::zoom_in

void zoom_in(void);

GtkScintilla::zoom_out

void zoom_out(void);

GtkScintilla::del_word_left

void del_word_left(void);

GtkScintilla::del_word_right

void del_word_right(void);

GtkScintilla::line_cut

void line_cut(void);

GtkScintilla::line_delete

void line_delete(void);

GtkScintilla::line_transpose

void line_transpose(void);

GtkScintilla::lower_case

void lower_case(void);

GtkScintilla::upper_case

void upper_case(void);

GtkScintilla::line_scroll_down

void line_scroll_down(void);

GtkScintilla::line_scroll_up

void line_scroll_up(void);

GtkScintilla::move_caret_inside_view

void move_caret_inside_view(void);

GtkScintilla::line_length

int line_length(int line);

GtkScintilla::brace_highlight

void brace_highlight(int pos1, int pos2);

GtkScintilla::brace_bad_light

void brace_bad_light(int pos);

GtkScintilla::brace_match

int brace_match(int pos);

GtkScintilla::get_view_eol

int get_view_eol(void);

GtkScintilla::set_view_eol

void set_view_eol(int visible);

GtkScintilla::get_doc_pointer

int get_doc_pointer(void);

GtkScintilla::set_doc_pointer

void set_doc_pointer(int pointer);

GtkScintilla::set_mod_event_mask

void set_mod_event_mask(int mask);

GtkScintilla::get_edge_column

int get_edge_column(void);

GtkScintilla::set_edge_column

void set_edge_column(int column);

GtkScintilla::get_edge_mode

int get_edge_mode(void);

GtkScintilla::set_edge_mode

void set_edge_mode(int mode);

GtkScintilla::get_edge_colour

int get_edge_colour(void);

GtkScintilla::set_edge_colour

void set_edge_colour(int edge_colour);

GtkScintilla::search_anchor

void search_anchor(void);

GtkScintilla::search_next

int search_next(int flags, string text);

GtkScintilla::search_prev

int search_prev(int flags, string text);

GtkScintilla::set_caret_policy

void set_caret_policy(int caret_policy, int caret_slop);

GtkScintilla::lines_on_screen

int lines_on_screen(void);

GtkScintilla::use_pop_up

void use_pop_up(int allow_pop_up);

GtkScintilla::selection_is_rectangle

int selection_is_rectangle(void);

GtkScintilla::set_zoom

void set_zoom(int zoom);

GtkScintilla::get_zoom

int get_zoom(void);

GtkScintilla::create_document

int create_document(void);

GtkScintilla::add_ref_document

void add_ref_document(int doc);

GtkScintilla::release_document

void release_document(int doc);

GtkScintilla::get_mod_event_mask

int get_mod_event_mask(void);

GtkScintilla::set_focus

void set_focus(int focus);

GtkScintilla::get_focus

int get_focus(void);

GtkScintilla::set_status

void set_status(int status_code);

GtkScintilla::get_status

int get_status(void);

GtkScintilla::set_mouse_down_captures

void set_mouse_down_captures(int captures);

GtkScintilla::get_mouse_down_captures

int get_mouse_down_captures(void);

GtkScintilla::set_cursor

void set_cursor(int cursor_type);

GtkScintilla::get_cursor

int get_cursor(void);

GtkScintilla::word_part_left

void word_part_left(void);

GtkScintilla::word_part_left_extend

void word_part_left_extend(void);

GtkScintilla::word_part_right

void word_part_right(void);

GtkScintilla::word_part_right_extend

void word_part_right_extend(void);

GtkScintilla::set_visible_policy

void set_visible_policy(int visible_policy, int visible_slop);

GtkScintilla::del_line_left

void del_line_left(void);

GtkScintilla::del_line_right

void del_line_right(void);

GtkScintilla::grab_focus

void grab_focus(void);

GtkScintilla::start_record

void start_record(void);

GtkScintilla::stop_record

void stop_record(void);

GtkScintilla::set_lexer

void set_lexer(int lexer);

GtkScintilla::get_lexer

int get_lexer(void);

GtkScintilla::colourise

void colourise(int start, int end);

GtkScintilla::set_property

void set_property(string key, string value);

GtkScintilla::set_keywords

void set_keywords(int keyword_set, string key_words);

GtkScintilla::set_lexer_language

void set_lexer_language(string language);

Table of Contents

GladeXML
Misc Glade Functions

GladeXML

Object Hierarchy

GtkObject
`-- GtkData
áááááá`-- GladeXML

Object Properties and Methods

Constructor

GladeXML (string fname, [string root = NULL, [string domain = NULL]]);

Description

GladeXML Constructor

GladeXML (string fname, [string root = NULL, [string domain = NULL]]);

GladeXML::construct

bool construct(string fname, string root, string domain);

GladeXML::signal_connect

XXX signal_connect(XXX);

GladeXML::signal_autoconnect

XXX signal_autoconnect(XXX);

GladeXML::relative_file

string relative_file(string filename);

Misc Glade Functions

xml_new_from_memory

GladeXML xml_new_from_memory(string buffer, int size, string root, string domain);

Table of Contents

GtkSQPane

GtkSQPane

Object Hierarchy

GtkObject
`-- GtkWidget
áááááá`-- GtkContainer
áááááááááááá`-- GtkSQPane

Object Properties and Methods

Constructor

GtkSQPane (void);

Description

GtkSQPane Constructor

GtkSQPane (void);

GtkSQPane::set_position

void set_position(int x, int y);

GtkSQPane::set_handle_size

void set_handle_size(int size);

GtkSQPane::compute_position

void compute_position(int width, int height);

Appendix . GNU Free Documentation License

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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."

  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. 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.

Appendix A. PHP-GTK Credits

PHP-GTK Authors
Andrei Zmievski : Main body of work
PHP-GTK Contributors
Frank Kromann : Win32 Compilation, some code generator work
PHP-GTK Manual Contributors
James Moore : Manual Content and XML framework
Steph Fox : Class Documentation

Edited By

James Moore