function on_interactive_dialog_clicked($button) { $dialog = new GtkDialog('Interactive Dialog', $this, 0, array(Gtk::STOCK_OK, Gtk::RESPONSE_OK, '_Non-stock button', Gtk::RESPONSE_CANCEL)); $hbox = new GtkHBox(false, 8); $hbox->set_border_width(8); $dialog->vbox->pack_start($hbox, false, false, 0); $stock = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_QUESTION, Gtk::ICON_SIZE_DIALOG); $hbox->pack_start($stock, false, false, 0); $table = new GtkTable(2, 2); $table->set_row_spacings(4); $table->set_col_spacings(4); $hbox->pack_start($table, true, true, 0); $label = new GtkLabel('Entry _1'); $label->set_use_underline(true); $table->attach($label, 0, 1, 0, 1); $local_entry1 = new GtkEntry(); $local_entry1->set_text($this->entry1->get_text()); $table->attach($local_entry1, 1, 2, 0, 1); $label->set_mnemonic_widget($local_entry1); $label = new GtkLabel('Entry _2'); $label->set_use_underline(true); $table->attach($label, 0, 1, 1, 2); $local_entry2 = new GtkEntry(); $local_entry2->set_text($this->entry2->get_text()); $table->attach($local_entry2, 1, 2, 1, 2); $label->set_mnemonic_widget($local_entry2); $dialog->show_all(); $response = $dialog->run(); if ($response == Gtk::RESPONSE_OK) { $this->entry1->set_text($local_entry1->get_text()); $this->entry2->set_text($local_entry2->get_text()); } $dialog->destroy(); }
/** * 画窗体方法 */ public function draw() { $this->set_default_size(200, 200); $this->set_title("24计算器"); $mesg = new GtkLabel('Please input 4 integer(0-99):'); $this->chalkboard = new GtkLabel(); $this->inputs = $inputs = array(new GtkEntry(), new GtkEntry(), new GtkEntry(), new GtkEntry()); /** * container */ $table = new GtkTable(4, 1, 0); $layout = array('left' => 0, 'right' => 1, 'top' => 0, 'bottom' => 1); $vBox = new GtkVBox(false, true); $vBox->pack_start($mesg); foreach ($inputs as $input) { $input->set_max_length(2); $table->attach($input, $layout['left'], $layout['right'], $layout['top']++, $layout['bottom']++); } $vBox->pack_start($table); $button = new GtkButton("Calculate"); $button->connect("clicked", array($this, "calculate")); $vBox->pack_start($this->chalkboard); $vBox->pack_start($button, true, false); $this->add($vBox); }
function __create_box() { $vbox = new GtkVBox(false, 5); $vbox->set_border_width(5); $this->size_group = new GtkSizeGroup(gtk::SIZE_GROUP_HORIZONTAL); $frame = new GtkFrame('Color options'); $vbox->pack_start($frame, true, true, 0); $table = new GtkTable(2, 2, false); $table->set_border_width(5); $table->set_row_spacings(5); $table->set_col_spacings(10); $frame->add($table); $color_options = array('Red', 'Green', 'Blue'); $this->add_row($table, 0, '_Foreground', $color_options); $this->add_row($table, 1, '_Background', $color_options); $frame = new GtkFrame('Line options'); $vbox->pack_start($frame, true, true, 0); $table = new GtkTable(2, 2, false); $table->set_border_width(5); $table->set_row_spacings(5); $table->set_col_spacings(10); $frame->add($table); $dash_options = array('Solid', 'Dashed', 'Dotted'); $end_options = array('Square', 'Round', 'Arrow'); $this->add_row($table, 0, '_Dashing', $dash_options); $this->add_row($table, 1, '_Line ends', $end_options); $check_button = new GtkCheckButton('_Enable grouping'); $check_button->set_use_underline(true); $vbox->pack_start($check_button, false, false, 0); $check_button->set_active(true); $check_button->connect('toggled', array($this, 'on_toggle_grouping')); return $vbox; }
function get_data($title, $field_labels) { $dialog = new GtkDialog($title, null, Gtk::DIALOG_MODAL); // create a new dialog $dialog->set_position(Gtk::WIN_POS_CENTER_ALWAYS); $top_area = $dialog->vbox; // get the top area $top_area->pack_start($hbox = new GtkHBox()); $stock = GtkImage::new_from_stock(Gtk::STOCK_DIALOG_QUESTION, Gtk::ICON_SIZE_DIALOG); $hbox->pack_start($stock, 0, 0); // stuff in the icon // display the data entry form as table $table = new GtkTable(); // create a new table $row = 0; $input = array(); // holds the ID of each GtkEntry foreach ($field_labels as $field_label) { $label = new GtkLabel($field_label); $label->set_alignment(0, 0); // left-justify the label $table->attach($label, 0, 1, $row, $row + 1); // insert the label into table $input[$row] = new GtkEntry(); // create a new input field $table->attach($input[$row], 1, 2, $row, $row + 1); // add this besides the label if (eregi("password", $field_label)) { $input[$row]->set_visibility(false); } // show password entry as '*' ++$row; } $hbox->pack_start($table); $dialog->add_button(Gtk::STOCK_OK, Gtk::RESPONSE_OK); // add an OK button $dialog->set_has_separator(false); // don't display the set_has_separator $dialog->show_all(); // show the dialog $dialog->run(); // the dialog in action // grab the user input before destroying the dialog - note 1 $data = array(); // put user input in an array for ($i = 0; $i < count($input); ++$i) { $data[] = $input[$i]->get_text(); } $dialog->destroy(); // done. close the dialog box. return $data; // returns the user input as array }
/** * Show the table and all aggregated rows */ public function show() { if ($this->showed === FALSE) { $i = 0; if ($this->rows) { foreach ($this->rows as $row) { $c = 0; if ($row->getCells()) { foreach ($row->getCells() as $column) { $properties = $column->getProperties(); $properties['colspan'] = isset($properties['colspan']) ? $properties['colspan'] - 1 : 0; $hbox = new GtkHBox(); if (isset($properties['width'])) { $hbox->set_size_request($properties['width'], -1); } $hbox->set_border_width(1); $hbox->pack_start($column->getContent(), false, false); $column->getContent()->show(); //$hbox->pack_start(new GtkHBox, true, true); parent::attach($hbox, $c, $c + 1 + $properties['colspan'], $i, $i + 1, GTK::FILL, 0, 0, 0); $c++; } } $i++; } } $this->showed = TRUE; } parent::show(); }
function __construct() { parent::__construct(); $this->set_border_width(10); $this->set_title('X-Money - Login'); $this->set_icon_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . 'logo.png'); $this->vbox->pack_start($hbox = new GtkHBox()); $hbox->pack_start(GtkImage::new_from_file(XMONEY_IMAGES . DIRECTORY_SEPARATOR . 'logo.png')); $hbox->pack_start($vbox = new GtkVBox()); $vbox->pack_start($frame = new GtkFrame(latin1(' Digite suas informações para acessar o sistema: '))); $frame->set_border_width(10); $frame->add($table = new GtkTable()); $table->attach(new GtkLabel('Usuario:'), 0, 1, 0, 1); $table->attach($this->username = new GtkEntry(), 1, 2, 0, 1); $table->attach(new GtkLabel('Senha:'), 0, 1, 1, 2); $table->attach($this->password = new GtkEntry(), 1, 2, 1, 2); $this->password->set_visibility(false); $this->ok = $this->add_button('_Ok', Gtk::RESPONSE_OK); $this->add_button('_Cancelar', Gtk::RESPONSE_CANCEL); EntrySetNextFocus($this->username, $this->password); EntrySetNextFocus($this->password, $this->ok); $this->vbox->show_all(); }
private function window() { //create window $this->set_title("calculator GUI"); $this->set_default_size(350, 350); $this->connect_simple('destroy', array('gtk', 'main_quit')); //create vbox $vbox = new GtkVBox(); //create entry box $this->entry = new GtkEntry(); $this->entry->set_size_request(100, 100); //create button $btn1 = new GtkButton(); $btn2 = new GtkButton(); $btn3 = new GtkButton(); $btnsin = new GtkButton(); $btncos = new GtkButton(); $btn4 = new GtkButton(); $btn5 = new GtkButton(); $btn6 = new GtkButton(); $btnt2 = new GtkButton(); $btnrad = new GtkButton(); $btn7 = new GtkButton(); $btn8 = new GtkButton(); $btn9 = new GtkButton(); $btn0 = new GtkButton(); $btndot = new GtkButton(); $btnpercent = new GtkButton(); $btnplus = new GtkButton(); $btntan = new GtkButton(); $btncot = new GtkButton(); $btnminus = new GtkButton(); $btndiv = new GtkButton(); $btnmulti = new GtkButton(); $btnequal = new GtkButton(); $btnref = GtkButton::new_from_stock(Gtk::STOCK_REFRESH); $btnback = GtkButton::new_from_stock(Gtk::STOCK_CLEAR); //set button value $btn1->set_label('1'); $btn1->connect('clicked', array($this, 'click1')); $btn2->set_label('2'); $btn2->connect('clicked', array($this, 'click2')); $btn3->set_label('3'); $btn3->connect('clicked', array($this, 'click3')); $btn4->set_label('4'); $btn4->connect('clicked', array($this, 'click4')); $btn5->set_label('5'); $btn5->connect('clicked', array($this, 'click5')); $btn6->set_label('6'); $btn6->connect('clicked', array($this, 'click6')); $btn7->set_label('7'); $btn7->connect('clicked', array($this, 'click7')); $btn8->set_label('8'); $btn8->connect('clicked', array($this, 'click8')); $btn9->set_label('9'); $btn9->connect('clicked', array($this, 'click9')); $btn0->set_label('0'); $btn0->connect('clicked', array($this, 'click0')); $btndot->set_label('.'); $btndot->connect('clicked', array($this, 'clickdot')); $btnpercent->set_label('%'); $btnpercent->connect('clicked', array($this, 'clickpercent')); $btnplus->set_label('+'); $btnplus->connect('clicked', array($this, 'clickplus')); $btnminus->set_label('-'); $btnminus->connect('clicked', array($this, 'clickminus')); $btndiv->set_label('/'); $btndiv->connect('clicked', array($this, 'clickdiv')); $btnmulti->set_label('*'); $btnmulti->connect('clicked', array($this, 'clickmulti')); $btnequal->set_label('='); $btnequal->connect('clicked', array($this, 'clickequal')); $btnt2->set_label('^2'); //$btnt2->connect('clicked',array($this,'clickt2')); //$btnrad->set_label('v--'); $btnrad->connect('clicked', array($this, 'clickrad')); $btnsin->set_label('sin'); $btnsin->connect('clicked', array($this, 'clicksin')); $btncos->set_label('cos'); $btncos->connect('clicked', array($this, 'clickcos')); $btntan->set_label('tan'); $btntan->connect('clicked', array($this, 'clicktan')); $btncot->set_label('cot'); $btncot->connect('clicked', array($this, 'clickcot')); //create table $tbl = new GtkTable(4, 6, true); //set button on table $tbl->attach($btn7, 0, 1, 0, 1); $tbl->attach($btn8, 1, 2, 0, 1); $tbl->attach($btn9, 2, 3, 0, 1); $tbl->attach($btnmulti, 3, 4, 0, 1); $tbl->attach($btnref, 4, 5, 0, 1); $tbl->attach($btnback, 5, 6, 0, 1); $tbl->attach($btn4, 0, 1, 1, 2); $tbl->attach($btn5, 1, 2, 1, 2); $tbl->attach($btn6, 2, 3, 1, 2); $tbl->attach($btndiv, 3, 4, 1, 2); $tbl->attach($btnpercent, 4, 5, 1, 2); $tbl->attach($btnt2, 5, 6, 1, 2); $tbl->attach($btn1, 0, 1, 2, 3); $tbl->attach($btn2, 1, 2, 2, 3); $tbl->attach($btn3, 2, 3, 2, 3); $tbl->attach($btnminus, 3, 4, 2, 3); $tbl->attach($btnsin, 4, 5, 2, 3); $tbl->attach($btncos, 5, 6, 2, 3); $tbl->attach($btn0, 0, 1, 3, 4); $tbl->attach($btndot, 1, 2, 3, 4); $tbl->attach($btnequal, 2, 3, 3, 4); $tbl->attach($btnplus, 3, 4, 3, 4); $tbl->attach($btntan, 4, 5, 3, 4); $tbl->attach($btncot, 5, 6, 3, 4); //add to vbox $vbox->pack_start($this->entry, true, true, 0); $vbox->pack_end($tbl, true, true, 0); //add to window $this->add($vbox); $this->show_all(); }
$chkOptionSaveConfig = new GtkCheckButton('Save Config File', true); //buttons $btnRun = new GtkButton('_Run'); $btnConfigFile = new GtkButton('_Config File'); $btnQuit = new GtkButton('_Quit'); //Which widget should be activated when the // mnemonic (Alt+U or Alt+P) is pressed? $lblRepositoryPath->set_mnemonic_widget($txtRepositoryPath); //Destroy the window when the user clicks Cancel $btnQuit->connect_simple('clicked', array($wnd, 'destroy')); // what to do when RUN is pressed $options = array('chkOptionHideFiles' => $chkOptionHideFiles, 'chkOptionHideFilenames' => $chkOptionHideFilenames, 'chkOptionHideDirnames' => $chkOptionHideDirnames, 'chkOptionHideDates' => $chkOptionHideDates, 'chkOptionHideProgress' => $chkOptionHideProgress, 'chkOptionHideBloom' => $chkOptionHideBloom, 'chkOptionHideMouse' => $chkOptionHideMouse, 'chkOptionHideTree' => $chkOptionHideTree, 'chkOptionHideUsers' => $chkOptionHideUsers, 'chkOptionHideUsernames' => $chkOptionHideUsernames, 'chkOptionFullscreen' => $chkOptionFullscreen, 'chkOptionMultiSampling' => $chkOptionMultiSampling, 'chkOptionTransparent' => $chkOptionTransparent, 'chkOptionSaveConfig' => $chkOptionSaveConfig); $btnRun->connect_simple('clicked', 'run_gource', $wnd, $txtRepositoryPath, $options); $btnConfigFile->connect_simple('clicked', 'show_file_select', $wnd); //Lay out all the widgets in the table $tbl = new GtkTable(3, 6); $tbl->attach($lblRepositoryPath, 0, 1, 0, 1); $tbl->attach($txtRepositoryPath, 1, 3, 0, 1); //options attach to table $tbl->attach($chkOptionHideFiles, 0, 1, 1, 2); $tbl->attach($chkOptionHideFilenames, 0, 1, 2, 3); $tbl->attach($chkOptionHideDirnames, 0, 1, 3, 4); $tbl->attach($chkOptionHideDates, 0, 1, 4, 5); $tbl->attach($chkOptionHideProgress, 0, 1, 5, 6); $tbl->attach($chkOptionHideBloom, 1, 2, 1, 2); $tbl->attach($chkOptionHideTree, 1, 2, 2, 3); $tbl->attach($chkOptionHideUsers, 1, 2, 3, 4); $tbl->attach($chkOptionHideUsernames, 1, 2, 4, 5); $tbl->attach($chkOptionFullscreen, 2, 3, 1, 2); $tbl->attach($chkOptionMultiSampling, 2, 3, 2, 3); $tbl->attach($chkOptionTransparent, 2, 3, 3, 4);