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

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

  

GtkItemFactory Constructor

GtkItemFactory (GtkType container_type, String path, GtkAccelGroup accel_group);

Creates a new instance of the GtkItemFactory class. One factory can be used for one menu, and not more. This means that if you want to have a standard GtkMenuBar at the top of a window and an additional right-click popup menu, you have to use 2 item factories.

The container_type determines, which type the root menu will have: GtkMenu, GtkMenuBar or GtkOptionMenu. To get the GtkType you want, just use the the get_type() function of this class:
$type = GtkMenuBar::get_type();     

The path is a unique name for this menu, enclosed in < and >, e.g. <mainmenu>. This path has to be unique in the whole application.

The accel_group is the accelerator group belonging to this window and is responsible for the menu shortcuts. It can be NULL, but then the menu shortcuts won't work.

例 18. Using a GtkItemFactory

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

$window = &new GtkWindow();
$window->set_default_size( 300, 20);
$window->connect_object('destroy', array('gtk', 'main_quit'));

$accelgroup	= &new GtkAccelGroup();
$window->add_accel_group( $accelgroup);

$fac	= &new GtkItemFactory( GtkMenuBar::get_type(), "<mainmenu>", $accelgroup);

function quit( $number, $item) {
	gtk::main_quit();
}
$arItems	= array(
array( "/_File/_Open", null, null, 0, null ),
array( "/_File/_Save", null, null, 0, null ),
array( "/_File/_Quit", "<CTRL>Q", 'quit', 0, null )
);

$fac->create_items( $arItems);

$window->add( $fac->get_widget( "<mainmenu>"));
$window->show_all();
gtk::main();
?>

A more sophisticated example can be found at the create_items() function.

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

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