PHPマニュアル/PEARマニュアル | ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot

GtkStyle Constructor | JavaScript入門&応用&リファレンスなら「JavaScriptist」

  

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.

例 42. 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();
?>

忘却曲線を使ってこの知識を確実に記憶に残す

フォーラムで「GtkStyle Constructor」について話す
各種マニュアル: PHPマニュアル | PEARマニュアル | Smarty(英語)マニュアル | PHP-GTKマニュアル | GtkStyle Constructor」をGoogle検索
copyright © 1997-2024 PHP ドキュメント作成グループ(ライセンス). provided by php spot. マニュアル: