Re: WHOA! - new tack + alchohol works!

From: Date: Mon, 02 Jul 2001 00:45:24 +0000
Subject: Re: WHOA! - new tack + alchohol works!
Groups: php.gtk 
Request: Send a blank email to php-gtk+get-2023@lists.php.net to get a copy of this message
You're a monster, Steph ! set_data does the job ! Now i can put the classes in a separate file and just 'include'. All 3 first problems solved - all with your glues and your 'Hitchhiker's Guide' ! (you really can't send me a copy of your guide for a local browser ? please..) Now i just need a new brain ! easy ! <? // standard header if(strtoupper(substr(PHP_OS,0,3))=='WIN') dl('php_gtk.dll'); else dl('php_gtk.so'); function closeWindow($widget){$window=$widget->get_toplevel();$window->destroy();} function shutdown(){Gtk::main_quit();} // the comboBox & radioButton event handler hidding classes - still incomplete... class comboBox { var $cmbBox; var $cmbBoxEntry; var $cmbBoxList; var $colLength; function start($instance,$text,$default,$width){ $this->cmbInstance = $instance; $this->cmbBox = &new GtkCombo(); $this->cmbBox->set_popdown_strings($text); $this->cmbBoxEntry = $this->cmbBox->entry; $this->cmbBoxEntry->set_max_length($width); if(($this->colLength = 8*$width)<18) $this->colLength = 18; $this->cmbBoxEntry->set_usize($this->colLength,18); $this->cmbBoxList=$this->cmbBox->list; $this->cmbBoxList->set_selection_mode(GTK_SELECTION_BROWSE); $this->cmbBoxList->connect('select-child','cmbBoxChanged',$pos,$this->cmbBox); $this->cmbBox->index = $default; $this->cmbBoxList->select_item($default); return($this->cmbBox); } } function cmbBoxChanged($list,$listItem,$pos,$combo){ $pos=$list->child_position($listItem); $combo->set_data("index",$pos); } class radioButton { var $button; var $buttonx; var $tmp; var $index; function start($instance,$text,$default,&$horBox){ $this->button = &new GtkRadioButton(NULL,$text[0]); $this->button->connect('clicked','buttonChanged',0,$this->button); if(!$default) $button->set_active(TRUE); $horBox->pack_start($this->button,TRUE,TRUE,0); $this->button->show(); for($this->tmp=1;$this->tmp<count($text);$this->tmp++){ $this->buttonx = &new GtkRadioButton($this->button,$text[$this->tmp]); $this->buttonx->connect('clicked','buttonChanged',$this->tmp,$this->button); if($this->tmp==$default) $this->buttonx->set_active(TRUE); $horBox->pack_start($this->buttonx,TRUE,TRUE,0); $this->buttonx->show(); } } } function buttonChanged($buttonx,$pos,$button){ $button->set_data("index",$pos); } $window=&new GtkWindow; $window->connect('destroy','shutdown'); $window->set_title('form'); $window->set_border_width(0); $verBox = &new GtkVBox(FALSE,0); $verBox->set_border_width(0); $window->add($verBox); $verBox->show(); $table = &new GtkTable(3,5,FALSE); $table->set_row_spacings(2); $table->set_col_spacings(2); $table->set_border_width(5); $verBox->pack_start($table,FALSE,FALSE,0); $table->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); // result from a global search for 'align' $table->attach($align,0,1,0,1,GTK_FILL); // in all gtk manual... $align->show(); // and then a look in 'Hitchhiker's Guide' $label = &new GtkLabel('Code '); $label->set_justify(GTK_JUSTIFY_LEFT); // thanks twice, Steph ! Problem 1 solved ! $align->add($label); $label->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,1,2,0,1,GTK_FILL); $align->show(); $colLength = 5; $entry0 = &new GtkEntry(); $entry0->set_max_length($colLength); if(($entryLength = 8*$colLength)<18) $entryLength = 18; $entry0->set_usize($entryLength,18); $align->add($entry0); $entry0->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,0,1,1,2,GTK_FILL); $align->show(); $label = &new GtkLabel('Short Description '); $label->set_justify(GTK_JUSTIFY_LEFT); $align->add($label); $label->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,1,2,1,2,GTK_FILL); $align->show(); $colLength = 30; $entry1 = &new GtkEntry(); $entry1->set_max_length($colLength); if(($entryLength = 8*$colLength)<18) $entryLength = 18; $entry1->set_usize($entryLength,18); $align->add($entry1); $entry1->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,0,1,2,3,GTK_FILL); $align->show(); $label = &new GtkLabel('Length '); $label->set_justify(GTK_JUSTIFY_LEFT); $align->add($label); $label->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,1,2,2,3,GTK_FILL); $align->show(); $text = array("Tiny","Short","Normal","Long","Big"); $comBox3 = new comboBox; $comBox3 = $comBox3->start('$comBox3',$text,2,20); // hehehe...'see, mom ! no head !' $align->add($comBox3); $comBox3->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,0,1,3,4,GTK_FILL); $align->show(); $label = &new GtkLabel('Type '); $label->set_justify(GTK_JUSTIFY_LEFT); $align->add($label); $label->show(); $align = &new GtkAlignment(0.0,0.5,0.0,0.0); $table->attach($align,1,2,3,4,GTK_FILL); $align->show(); $horBox = &new GtkHBox(FALSE,0); $horBox->set_border_width(0); $align->add($horBox); $horBox->show(); $text = array('Autonumber','Signed','Unsigned'); $button4 = new radioButton; $button4->start('$button4',$text,1,$horBox); $horBox = &new GtkHBox(FALSE,0); $horBox->set_border_width(0); $verBox->pack_start($horBox,FALSE,FALSE,0); $horBox->show(); $button=&new GtkButton('Show me'); $button->connect('clicked','showMe'); $horBox->pack_start($button); $button->show(); $button=&new GtkButton('Close'); $button->connect('clicked','shutdown'); $horBox->pack_start($button); $button->show(); $window->show(); Gtk::main(); function showMe($button) { global $entry0,$entry1,$comBox3,$button4; $crlf = chr(13).chr(10); echo $crlf; echo 'Code:'.$entry0->get_text().$crlf; echo 'Short Description:'.$entry1->get_text().$crlf; echo 'Length:'.$comBox3->get_data('index').$crlf; $button = $button4->button; echo 'Type:'.$button->get_data('index').$crlf; } ?>

« previous php.gtk (#2023) next »