PHP Classes
Icontem

File: sample.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of jonathan gotti  >  Menu Icon  >  sample.php  
File: sample.php
Role: Example script
Content type: text/plain
Description: sample of use
Class: Menu Icon
Create menu with optional icons using PHP-GTK
 

Contents

Class file image Download
<?
if(strtoupper(substr(PHP_OS0,3)) == 'WIN')
  
dl('php_gtk.dll');
else
  
dl('php_gtk.so');
include_once(
'class-menu.php');

$w = &new gtkwindow();
$w->connect('destroy-event','shutdown');
$w->connect('delete-event','shutdown');
$w->set_position('center');

// We realize the window to get the gdkwindow needed to 
// create Xpm if we want to display icons in our menu
$w->realize();
$gdkwindow  $w->window;

// We also create a gtkaccelgroup to manage accelkeys
// the class menu will attempt to create its own if none is given at creation time
$accelgroup = &new gtkaccelgroup();
$w->add_accel_group($accelgroup);

// So we declare the menu and add it to the window
$menu = &new menu($gdkwindow,$accelgroup);

// We now can add entrys to the menu
// first the file menu 
$menu->add_menu_item('file',null,'file');
// Second we want a open file option in the file menu
$menu->add_menu_item($keyid='open',$parent='file',$label='_open',
                     
$callback='openfilefunctionname',$imgfile='img/fileopen.xpm');
//we also want a separator in the menu file
$menu->add_sep('file');
$menu->add_menu_item('quit','file','_quit','shutdown','img/exit.xpm'); # you can now pass $xpmdatas or array(gdkpixmap,gdkkbitmask) instead of a file as image
$menu->add_menu_item('help',null,'help');
$menu->add_menu_item('about','help','about','about_function_name');
//You can add check menu item too by setting is_checkmenuitem patameter to TRUE.
$menu->add_menu_item('check','help','checkitem','callbackfuntion',null,
                     
$is_sensitive=TRUE,$is_checkmenuitem=TRUE,$is_checked=FALSE);

# now add an entry with a beautifull right click menu
$box = &new gtkvbox();
$entry = &new gtkentry();
$box->pack_start($menu->bar);
$box->pack_start($entry);
$w->add($box);
$w->show_all();
gtk::main();

function 
shutdown(){
  
gtk::main_quit();
}
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products