Changeset 1446:320f73c5cfc1 in lemon-0.x
- Timestamp:
- 06/06/05 19:01:12 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1926
- Location:
- gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/map_win.cc
r1442 r1446 2 2 #include <set> 3 3 4 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)4 bool MapWin::close_if_escape_is_pressed(GdkEventKey* e) 5 5 { 6 if(e->keyval==GDK_Escape) 7 { 8 hide(); 9 } 10 return true; 11 } 6 12 7 //most nem kommentezem fel, mert ugyis valtozik 13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst),table(PROPERTY_NUM, 2, false) 14 { 15 set_title(title); 16 set_default_size(200, 50); 8 17 9 set_title(title); 10 set_default_size(400, 200); 18 signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed)); 11 19 12 rb_array=new Gtk::RadioButton * [PROPERTY_NUM]; 13 vbox_r1=new Gtk::VBox[PROPERTY_NUM]; 14 vbox_r2=new Gtk::VBox[PROPERTY_NUM]; 15 radios=new Gtk::HBox[PROPERTY_NUM]; 20 combo_array=new Gtk::Combo [PROPERTY_NUM]; 21 16 22 for(int i=0;i<PROPERTY_NUM;i++) 17 23 { 18 rb_array[i]=new Gtk::RadioButton[ms.numOfEdgeMaps()+1];19 20 Gtk::RadioButton::Group group;21 24 22 25 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps(); … … 24 27 25 28 int actprop; 29 30 //here we find out, which map is the default in MapStorage for this property, which are not 26 31 for(int j=0;j<ms.numOfEdgeMaps();j++) 27 32 { 28 33 //this is the default value for this property 29 34 if(emsi->second==&(ms.default_edgemaps[i])) 30 35 { 31 36 actprop=j; 32 37 } 38 //this is the other maps to show for this property 33 39 for(int k=0;k<PROPERTY_NUM;k++) 34 40 { … … 41 47 } 42 48 43 rb_array[i][0].set_group(group); 44 rb_array[i][0].set_label("Default"); 45 rb_array[i][0].signal_clicked().connect( sigc::bind( sigc::bind( sigc::mem_fun(*this, &MapWin::radio_click), 0), i) ); 46 vbox_r1[i].pack_start(rb_array[i][0]); 49 //combo_array[i].set_group(group); 47 50 51 //filling in combo box with choices 52 std::list<Glib::ustring> listStrings; 53 54 listStrings.push_back("Default"); 48 55 49 56 emsi=ms.beginOfEdgeMaps(); 50 int actpos=1; 57 51 58 for(int j=0;j<ms.numOfEdgeMaps();j++) 52 59 { 53 60 if( ( props.find(j) )==( props.end() ) ) 54 61 { 55 rb_array[i][actpos].set_group(group); 56 rb_array[i][actpos].set_label(emsi->first); 57 rb_array[i][actpos].signal_clicked().connect 58 ( 59 sigc::bind( 60 sigc::bind( 61 sigc::mem_fun(*this, &MapWin::radio_click), 62 actpos 63 ), 64 i 65 ) 66 ); 67 68 if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2) 69 { 70 vbox_r1[i].pack_start(rb_array[i][actpos]); 71 } 72 else 73 { 74 vbox_r2[i].pack_start(rb_array[i][actpos]); 75 } 76 actpos++; 62 listStrings.push_back(emsi->first); 77 63 } 78 64 emsi++; 79 65 } 80 radios[i].pack_start(vbox_r1[i]); 81 radios[i].pack_start(vbox_r2[i]); 82 notebook.append_page(radios[i], property_strings[i]); 66 67 combo_array[i].set_popdown_strings(listStrings); 68 69 //Restrict it to these choices only: 70 combo_array[i].set_value_in_list(); 71 72 //binding signal to thew actual entry 73 combo_array[i].get_entry()->signal_changed().connect 74 ( 75 sigc::bind 76 ( 77 sigc::mem_fun(*this, &MapWin::combo_changed), 78 i 79 ) 80 ); 81 82 //placing actual entry in the right place 83 84 label=new Gtk::Label; 85 label->set_text(property_strings[i]); 86 87 // labelpluscombo=new Gtk::HBox; 88 // labelpluscombo->pack_start(*label); 89 // labelpluscombo->pack_start(combo_array[i]); 90 91 table.attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); 92 table.attach(combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); 93 94 /* 95 if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2) 96 { 97 vbox_r1.pack_start(*labelpluscombo); 98 } 99 else 100 { 101 vbox_r2.pack_start(*labelpluscombo); 102 } 103 actpos++; 104 //*/ 105 83 106 } 84 107 85 add(vbox_b); 86 vbox_b.pack_start(notebook); 108 combos.pack_start(vbox_r1); 109 combos.pack_start(vbox_r2); 110 111 //add(combos); 112 add(table); 87 113 88 114 show_all_children(); … … 90 116 } 91 117 92 void MapWin:: radio_click(int prop, int actpos)118 void MapWin::combo_changed(int prop) 93 119 { 94 120 95 121 //most nem kommentezem fel, mert ugyis valtozik 122 Gtk::Entry* entry = combo_array[prop].get_entry(); 96 123 97 if( rb_array[prop][actpos].get_active())124 if(entry) 98 125 { 126 Glib::ustring mapname = entry->get_text(); 127 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. 128 { 129 if(mapname=="Default") 130 { 131 mapname=property_strings[prop]; 132 } 99 133 100 std::string mapname=rb_array[prop][actpos].get_label(); 101 102 if(mapname=="Default") 103 { 104 mapname=property_strings[prop]; 105 } 106 107 switch(prop) 108 { 109 case WIDTH: 110 gdc.changeLineWidth(mapname); 111 break; 112 case COLOR: 113 gdc.changeColor(mapname); 114 break; 115 case TEXT: 116 gdc.changeText(mapname); 117 break; 118 default: 119 std::cout<<"Error\n"; 134 if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) 135 { 136 switch(prop) 137 { 138 case WIDTH: 139 gdc.changeLineWidth(mapname); 140 break; 141 case COLOR: 142 gdc.changeColor(mapname); 143 break; 144 case TEXT: 145 gdc.changeText(mapname); 146 break; 147 default: 148 std::cout<<"Error\n"; 149 } 150 } 120 151 } 121 152 } -
gui/map_win.h
r1442 r1446 25 25 MapStorage & ms; 26 26 27 Gtk::Table table; 27 28 28 Gtk::HBox * radios;29 Gtk:: RadioButton ** rb_array;29 Gtk::HBox combos, * labelpluscombo; 30 Gtk::Combo * combo_array; 30 31 31 Gtk::VBox vbox_b, * vbox_r1, *vbox_r2;32 Gtk::VBox vbox_b, vbox_r1, vbox_r2; 32 33 33 ///The notebook has different pages for each attribute. 34 Gtk::Notebook notebook; 35 36 Gtk::Label * labels; 34 Gtk::Label * label; 37 35 38 36 public: … … 44 42 ///appropriate function of the \ref GraphDisplayerCanvas 45 43 ///to change the visible values of that attribute. 46 virtual void radio_click(int, int); 44 virtual void combo_changed(int); 45 virtual bool close_if_escape_is_pressed(GdkEventKey*); 47 46 }; 48 47
Note: See TracChangeset
for help on using the changeset viewer.