27 lines
7.9 KiB
Text
27 lines
7.9 KiB
Text
version=pmwiki-1.0.5
|
|
newline=²
|
|
text=!!!! PhpGtkClockWidget²²!!! extending from GtkVbox²²* this example show how to extends a composite Widget.²* a composite Widget is a container widget that can handle other widgets inside it.²* for a composite widget, you need to extends from a container widget,²* GtkContainer doest not allow direct extention ; you will have an error if you call parent::__construct(). It's also for GtkBox, GtkBin ... ,²* it works very well for GtkVbox as you can see in example below,²* [[http://gtk.php.net/manual/en/tutorials.objectorientation.basics.php GtkWindow]] is also a possible container.²[[include:Main/CodeTable]]<?php²²# Marc Quinton - September 2006.²# ²# a Php Gtk widget extension example²#²²class PhpGtkClockWidget extends GtkVbox{²² protected $label;² protected $count;² protected $timeout;² protected $time_format;²² function __construct(){² parent::__construct();² $this->timeout = 1000; # 1000ms is 1 second² $this->time_format = '%T'; # %T - current time, equal to %H:%M:%S²² $this->set_border_width(10);²² $this->label = new GtkLabel();² $this->add($this->label);²² # update clock label as soon as possible.² $this->timeout();² }²² function timeout(){² $this->display_time();²² # update clock label next delay² Gtk::timeout_add($this->timeout, array($this, 'timeout'));² }²² function display_time(){² $this->label->set_text(strftime($this->time_format));² }²}²²²$win = new GtkWindow();²$win->set_title('clock widget test');²$win->connect_simple('destroy', array('gtk', 'main_quit'));²$win->set_position(Gtk::WIN_POS_CENTER);²²$clock = new PhpGtkClockWidget();²²$win->add($clock);²²$win->show_all();²Gtk::main();²²?>[[include:Main/CodeTableEnd]]²²!!! extending from GtkLabel²²* here, you can is an simple example extending from GtkLabel,²* very simple too.²[[include:Main/CodeTable]]<?php²²# Marc Quinton - September 2006.²# ²# a Gtk widget extension example²#²²class PhpGtkClockWidget extends GtkLabel{²² protected $label;² protected $count;² protected $timeout;² protected $time_format;²² function __construct(){² parent::__construct();² $this->timeout = 1000; # 1000ms is 1 second² $this->time_format = '%T'; # %T - current time, equal to %H:%M:%S²² # update clock label as soon as possible.² $this->timeout();² }²² function timeout(){² $this->display_time();²² # update clock label next delay² Gtk::timeout_add($this->timeout, array($this, 'timeout'));² }²² function display_time(){² $this->set_text(strftime($this->time_format));² }²}²²²$win = new GtkWindow();²$win->set_title('clock widget test');²$win->connect_simple('destroy', array('gtk', 'main_quit'));²$win->set_position(Gtk::WIN_POS_CENTER);²$win->set_border_width(10);²²$clock = new PhpGtkClockWidget();²²$win->add($clock);²²$win->show_all();²Gtk::main();²²?>[[include:Main/CodeTableEnd]]²²²²²
|
|
time=1157451711
|
|
diff:1157447752:1157447752:=1,55c1²< !!!! PhpGtkClockWidget²< ²< [[include:Main/CodeTable]]<?php²< ²< # Marc Quinton - September 2006.²< # ²< # a Php Gtk widget extention example²< #²< ²< class PhpGtkClockWidget extends GtkVbox{²< ²< protected $label;²< protected $count;²< protected $timeout;²< protected $time_format;²< ²< function __construct(){²< parent::__construct();²< $this->timeout = 1000; # 1000ms is 1 second²< $this->time_format = '%T'; # %T - current time, equal to %H:%M:%S²< ²< $this->label = new GtkLabel();²< $this->add($this->label);²< ²< # update clock label as soon as possible.²< $this->timeout();²< }²< ²< function timeout(){²< $this->display_time();²< ²< # update clock label next delay²< Gtk::timeout_add($this->timeout, array($this, 'timeout'));²< }²< ²< function display_time(){²< $this->label->set_text(strftime($this->time_format));²< }²< }²< ²< ²< $win = new GtkWindow();²< $win->set_title('clock widget test');²< $win->connect_simple('destroy', array('gtk', 'main_quit'));²< $win->set_size_request(100, 50);²< ²< $clock = new PhpGtkClockWidget();²< ²< $win->add($clock);²< ²< $win->show_all();²< Gtk::main();²< ²< ?>[[include:Main/CodeTableEnd]]²< ²---²> Describe PhpGtkClock here.²\ No newline at end of file²
|
|
author=Marc Quinton
|
|
author:1157447752=Marc Quinton
|
|
host:1157447752=143.196.162.107
|
|
name=CodeSnippets.PhpGtkClock
|
|
host=143.196.162.107
|
|
agent=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041217
|
|
rev=6
|
|
diff:1157450397:1157447752:=3,7d2²< - this example show how to extends a composite Widget.²< - a composite Widget is a container widget that can handle other widgets inside it.²< - for a composite widget, you need to extends from a container widget,²< - GtkContainer doest not allow direct extention ; you will have an error if you call parent::__construct(). It's also for GtkBox, GtkBin ... ; It workds very well for GtkVbox²< - [http://gtk.php.net/manual/en/tutorials.objectorientation.basics.php GtkWindow] is also a possible container.²
|
|
author:1157450397=Marc Quinton
|
|
host:1157450397=143.196.162.107
|
|
diff:1157450518:1157450397:=3,8c3,7²< * this example show how to extends a composite Widget.²< * a composite Widget is a container widget that can handle other widgets inside it.²< * for a composite widget, you need to extends from a container widget,²< * GtkContainer doest not allow direct extention ; you will have an error if you call parent::__construct(). It's also for GtkBox, GtkBin ... ,²< * it works very well for GtkVbox as you can see in example below,²< * [[http://gtk.php.net/manual/en/tutorials.objectorientation.basics.php GtkWindow]] is also a possible container.²---²> - this example show how to extends a composite Widget.²> - a composite Widget is a container widget that can handle other widgets inside it.²> - for a composite widget, you need to extends from a container widget,²> - GtkContainer doest not allow direct extention ; you will have an error if you call parent::__construct(). It's also for GtkBox, GtkBin ... ; It workds very well for GtkVbox²> - [http://gtk.php.net/manual/en/tutorials.objectorientation.basics.php GtkWindow] is also a possible container.²
|
|
author:1157450518=Marc Quinton
|
|
host:1157450518=143.196.162.107
|
|
diff:1157450562:1157450518:minor=13c13²< # a Php Gtk widget extension example²---²> # a Php Gtk widget extention example²
|
|
author:1157450562=Marc Quinton
|
|
host:1157450562=143.196.162.107
|
|
diff:1157451528:1157450562:=3,4d2²< !!! entending from GtkVbox²< ²30,31d27²< $this->set_border_width(10);²< ²55c51²< $win->set_position(Gtk::WIN_POS_CENTER);²---²> $win->set_size_request(100, 50);²65,123d60²< ²< !!! entending from GtkLabel²< ²< * here, you can is an simple example extending from GtkLabel,²< * ²< ²< [[include:Main/CodeTable]]<?php²< ²< # Marc Quinton - September 2006.²< # ²< # a Gtk widget extension example²< #²< ²< class PhpGtkClockWidget extends GtkLabel{²< ²< protected $label;²< protected $count;²< protected $timeout;²< protected $time_format;²< ²< function __construct(){²< parent::__construct();²< $this->timeout = 1000; # 1000ms is 1 second²< $this->time_format = '%T'; # %T - current time, equal to %H:%M:%S²< ²< # update clock label as soon as possible.²< $this->timeout();²< }²< ²< function timeout(){²< $this->display_time();²< ²< # update clock label next delay²< Gtk::timeout_add($this->timeout, array($this, 'timeout'));²< }²< ²< function display_time(){²< $this->set_text(strftime($this->time_format));²< }²< }²< ²< ²< $win = new GtkWindow();²< $win->set_title('clock widget test');²< $win->connect_simple('destroy', array('gtk', 'main_quit'));²< $win->set_position(Gtk::WIN_POS_CENTER);²< $win->set_border_width(10);²< ²< $clock = new PhpGtkClockWidget();²< ²< $win->add($clock);²< ²< $win->show_all();²< Gtk::main();²< ²< ?>[[include:Main/CodeTableEnd]]²< ²< ²< ²
|
|
author:1157451528=Marc Quinton
|
|
host:1157451528=143.196.162.107
|
|
diff:1157451711:1157451528:=3c3²< !!! extending from GtkVbox²---²> !!! entending from GtkVbox²66c66²< !!! extending from GtkLabel²---²> !!! entending from GtkLabel²69c69,70²< * very simple too.²---²> * ²> ²
|
|
author:1157451711=Marc Quinton
|
|
host:1157451711=143.196.162.107
|