Proposal for "Styled"

» Metadata » Status
  • Category: Gtk Components
  • Proposer: Scott Mattocks 
  • License: PHP v3.0
» Description


Most classes in PHP-GTK that have visual components can have their appearance changed using a GtkStyle object. This allows the programmer to make applications that have a unique look and feel. Unfortuantely some classes, those that don't inherit from GtkWidget, can not have their appearance altered. This leads to applications that have an unfinished look. The most common types of widgets that cannot be styled are scroll bars. Scroll bars are a visual representation of a GtkAdjustment object.


By mimicing the properties and capabilities of commonly used and unstyleable GtkObjects and GtkWidgets with collections of widgets whose style can be controlled, you can have the functionality and usefulness of objects like scroll bars and progress bars and also have a completely unified appearance to your applications.

The most common problem that programmers run into when trying to create a unified appearance are widgets that incorporate GtkAjustment objects. GtkAdjustments themselves are decendants of GtkData and do not have any visual components, but are used in many widgets such as GtkScrollBars and GtkProgress. By creating a GtkAdjustment psuedo-widget, the programmer can control the look and feel of a basic component for scrolling widgets.


A simple example:


// Create a vertical adjustment.
require_once 'Gtk/Styled/VAdjustment.php';
$vStyleAdj =& new Gtk_Styled_VAdjustment(0, 0, 50, 1, 20, 10);

// Make the bar of the adjustment appear blue and green.
$gtkStyle = new GtkStyle;
$gtkStyle->bg[GTK_STATE_NORMAL]   = new GdkColor('#0000CC');
$gtkStyle->bg[GTK_STATE_PRELIGHT] = new GdkColor('#00CC00');
$vStyleAdj->setStyle('bar', $gtkStyle);

More advanced example found at:

Screen shot of the advanced example:


Gtk_Styled_ScrolledWindow (Not yet implemented)
Gtk_Styled_ProgressBar (Not yet implemented)

» Dependencies » Links
  • PHP-Gtk 1.0.1
  • PHP 4.3.x
» Timeline » Changelog
  • First Draft: 2004-11-23
  • Proposal: 2004-12-14
  • Call for Votes: 2005-01-03
  • Scott Mattocks
    [2004-12-16 13:45 UTC]

    Fixed whitespace, file paths, and class name. (Per comments by Alan Knowles)