Webhosting and cheap domain registration service
  

 Home

GtkStyle
Prev GtkStyle Constructor Next

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 40. Writing to a widget's style property.

<?php
if( !extension_loaded('gtk')) {	
	dl( 'php_gtk.' . PHP_SHLIB_SUFFIX); 
}

$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('-*-Arial-bold-r-normal--*-160-*-*-p-0-iso8859-1');
$newstyle2->font = $font;
$label->set_style($newstyle2);

$window->show_all();

gtk::main();
?>


Prev Home Next
GtkStyle Up GtkStyle::copy

 

  

Network sites:

Cheap domain registrar's cheap domain registration service

$8.95 domain registration : Buy domain name or register domain name 

 
 
Quotes:
Be not afraid of greatness: some are born great, some achieve greatness, and some have greatness thrust upon them.In everyone's life, at some time, our inner fire goes out. It is then burst into flame by an encounter with another human being. We should all be thankful for those people who rekindle the inner spirit.  
 
 

Disclaimer: This documentation is provided only for the benefits of our webhosting customers.
For authoritative source of the documentation, please refer to http://gtk.php.net/docs.php