Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 30th, 2012  |  syntax: None  |  size: 1.33 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. List the contents of a vector in Gtk
  2. _Square 1-side:7_  
  3. _Square 2-side:25_
  4.        
  5. Gtk::Dialog dialog("Listing Squares",false,true);
  6. dialog.set_default_size(500,30);
  7. Gtk::Button close("Close");
  8. close.signal_clicked().connect( sigc::mem_fun(*this,&Window::onFileListButtonClose) );
  9. Gtk::VBox* vbox = dialog.get_vbox();
  10.  
  11. Gtk::ScrolledWindow sw;
  12. sw.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC);
  13.  
  14. /** FETCH FROM ARRAY*/
  15.   for(unsigned int i(0); i<vc.size();++i){
  16.     Gtk::Label label( "Square number " + i );
  17.     sw.add( label );
  18.   }
  19. sw.show_all_children();
  20. vbox->pack_start( sw );
  21. vbox = 0;
  22. dialog.add_action_widget(close,1);
  23. dialog.show_all_children();
  24. dialog.run();
  25.        
  26. void Window::onMenuFileNew(void) {
  27.   Gtk::Dialog dialog("New Square",true,true);
  28.   dialog.set_default_size(70,20);
  29.   dialog.set_has_separator(true);
  30.   Gtk::Button close("Close");
  31.  
  32.   entry.set_max_length(2);
  33.   entry.set_text("");
  34.   close.signal_clicked().connect( sigc::mem_fun(*this,&Window::onFileNewButtonClose) );
  35.   Gtk::Label lab("Square side length:");
  36.   Gtk::VBox* vbox = dialog.get_vbox();
  37.   vbox->pack_start( lab );
  38.   vbox->pack_start( entry );
  39.   vbox = 0;
  40.   dialog.add_action_widget(close,1);
  41.   dialog.show_all_children();
  42.   dialog.run();
  43. }
  44.  
  45. void Window::onFileNewButtonClose(void) {
  46.   int side = atoi( (entry.get_text()).c_str() );
  47.   vc.push_back(Cuadrado( side ));
  48. }