Gtk2_IndexedComboBox
[ class tree: Gtk2_IndexedComboBox ] [ index: Gtk2_IndexedComboBox ] [ all elements ]

Source for file normal.php

Documentation is available at normal.php

  1. <?php
  2. /**
  3. *   Simple Gtk2_IndexedComboBox example
  4. *
  5. *   @author Christian Weiske <cweiske@php.net>
  6. */
  7. require_once 'Gtk2/IndexedComboBox.php';
  8.  
  9. $arData = array('key' => 'constructor'2 => 'c02'3 => 'c03');
  10. $arPrepend = array('prepend' => 'prepend'10 => 'p10'11 => 'p11'12 => 'p12');
  11. $arInsert  = array('insert'  => 'insert' 20 => 'i20'21 => 'i21'22 => 'i22');
  12. $arAppend  = array('append'  => 'append' 30 => 'a30'31 => 'a31'32 => 'a32');
  13.  
  14. $cmb = array();
  15.  
  16. $cmb['empty'= new Gtk2_IndexedComboBox();
  17.  
  18. $cmb['constructor'= new Gtk2_IndexedComboBox($arData);
  19.  
  20. $cmb['append'= new Gtk2_IndexedComboBox();
  21. $cmb['append']->append_array($arAppend);
  22.  
  23. $cmb['append+c'= new Gtk2_IndexedComboBox($arData);
  24. $cmb['append+c']->append_array($arAppend);
  25.  
  26. $cmb['prepend'= new Gtk2_IndexedComboBox();
  27. $cmb['prepend']->prepend_array($arPrepend);
  28.  
  29. $cmb['prepend+c'= new Gtk2_IndexedComboBox($arData);
  30. $cmb['prepend+c']->prepend_array($arPrepend);
  31.  
  32. $cmb['insert'= new Gtk2_IndexedComboBox();
  33. $cmb['insert']->insert_array(2$arInsert);
  34.  
  35. $cmb['insert+c'= new Gtk2_IndexedComboBox($arData);
  36. $cmb['insert+c']->insert_array(2$arInsert);
  37.  
  38. $cmb['normal'= new Gtk2_IndexedComboBox();
  39. $cmb['normal']->append('append''append');
  40. $cmb['normal']->prepend('prepend''prepend');
  41. $cmb['normal']->insert(1'insert''insert on #1');
  42. $cmb['normal']->append('append2''append#2');
  43.  
  44. $cmb['normal']->set_active_key('append');
  45.  
  46.  
  47. $lbl = new GtkLabel("Status\r\n\r\n");
  48.  
  49. $tbl = new GtkTable(2count($cmb));
  50. $nPos = 0;
  51. foreach ($cmb as $id => $combo{
  52.     $tbl->attach(new GtkLabel($id)01$nPos$nPos + 1);
  53.     $tbl->attach($combo12$nPos$nPos + 1);
  54.     $combo->connect('changed''comboChanged'$id$lbl);
  55.     ++$nPos;
  56. }
  57.  
  58.  
  59. function comboChanged($combo$comboId$lbl)
  60. {
  61.     $lbl->set_text(
  62.         'Combo "'    $comboId "\" changed:\r\n"
  63.         . 'Key: '   $combo->get_active_key("\r\n"
  64.         . 'Value: ' $combo->get_active_text()
  65.     );
  66. }
  67.  
  68.  
  69. $vbox = new GtkVBox();
  70. $vbox->pack_start($tbl);
  71. $vbox->pack_start($lbl);
  72.  
  73. $wnd = new GtkWindow();
  74. $wnd->connect_simple('destroy'array('Gtk''main_quit'));
  75. $wnd->add($vbox);
  76. $wnd->show_all();
  77. Gtk::main();
  78. ?>

Documentation generated on Mon, 11 Mar 2019 14:38:30 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.