From: Dominic L. <ma...@us...> - 2004-08-16 17:43:05
|
Update of /cvsroot/robotflow/RobotFlow/Probes/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25373 Modified Files: CheckBoxPanel.cc Log Message: added default values for checkboxes Index: CheckBoxPanel.cc =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Probes/src/CheckBoxPanel.cc,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CheckBoxPanel.cc 16 Aug 2004 16:57:25 -0000 1.1 --- CheckBoxPanel.cc 16 Aug 2004 17:42:56 -0000 1.2 *************** *** 41,46 **** * @parameter_name CHECKBOXES * @parameter_type string ! * @parameter_value label1:label2 ! * @parameter_description Checkboxes labels separated by ":" * * @output_name OUTPUT --- 41,46 ---- * @parameter_name CHECKBOXES * @parameter_type string ! * @parameter_value label1;false:label2;true ! * @parameter_description Checkboxes labels separated by ":". Default value can be specified by adding ;true ;false at the end. * * @output_name OUTPUT *************** *** 111,141 **** for (int pos = 0; pos != string::npos;) { int next_pos = m_checkboxNames.find(":",pos + 1); if (next_pos != string::npos) { ! string val = m_checkboxNames.substr(pos,next_pos - pos); ! ! GtkWidget *check = gtk_check_button_new_with_label(val.c_str()); ! gtk_widget_ref(check); ! gtk_widget_show(check); ! ! gtk_box_pack_start (GTK_BOX (m_vbox), check, TRUE, TRUE, 0); ! m_checkboxes.push_back(check); ! pos = next_pos + 1; } else { ! string val = m_checkboxNames.substr(pos,m_checkboxNames.size() - pos); ! ! GtkWidget *check = gtk_check_button_new_with_label(val.c_str()); ! gtk_widget_ref(check); ! gtk_widget_show(check); ! gtk_box_pack_start (GTK_BOX (m_vbox), check, TRUE, TRUE, 0); ! m_checkboxes.push_back(check); ! pos = string::npos; } } --- 111,151 ---- for (int pos = 0; pos != string::npos;) { + bool state = false; + string val; int next_pos = m_checkboxNames.find(":",pos + 1); + //is that the last label ? if (next_pos != string::npos) { ! val = m_checkboxNames.substr(pos,next_pos - pos); pos = next_pos + 1; } else { + val = m_checkboxNames.substr(pos,m_checkboxNames.size() - pos); + pos = string::npos; + } ! //default value specified ? ! int default_value_pos = val.find(";"); ! ! if (default_value_pos != string::npos) { ! string true_false = val.substr(default_value_pos + 1, val.size() - default_value_pos); ! if (true_false == "true") { ! state = TRUE; ! } ! //set null character to avoid display of default value in the label ! val[default_value_pos] = '\0'; } + + //create the widget + GtkWidget *check = gtk_check_button_new_with_label(val.c_str()); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),state); + + gtk_widget_ref(check); + gtk_widget_show(check); + gtk_box_pack_start (GTK_BOX (m_vbox), check, TRUE, TRUE, 0); + + m_checkboxes.push_back(check); } *************** *** 162,171 **** int state = (int) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_checkboxes[i])); - vect->push_back(state); } - - gdk_threads_leave(); --- 172,178 ---- |