From: Dominic L. <ma...@us...> - 2004-08-16 16:57:35
|
Update of /cvsroot/robotflow/RobotFlow/Probes/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16431 Modified Files: Makefile.am Added Files: CheckBoxPanel.cc Log Message: added new CheckBoxPanel with user defined labels and size --- NEW FILE: CheckBoxPanel.cc --- /* Copyright (C) 2004 Dominic Letourneau (dom...@us...) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _CHECKBOXPANEL_CC_ #define _CHECKBOXPANEL_CC_ #include "Object.h" #include "Exception.h" #include "BufferedNode.h" #include <gnome.h> #include <pthread.h> #include "gdk-pixbuf/gdk-pixbuf.h" #include "libgnomecanvas/gnome-canvas-pixbuf.h" #include <Vector.h> //forward declaration class CheckBoxPanel; using namespace std; DECLARE_NODE(CheckBoxPanel) /*Node * * @name CheckBoxPanel * @category RobotFlow:Probes * @description Display vertical checkboxes and output the state * * @parameter_name CHECKBOXES * @parameter_type string * @parameter_value label1:label2 * @parameter_description Checkboxes labels separated by ":" * * @output_name OUTPUT * @output_type Vector<int> * @output_description The state of the checkboxes * END*/ static gboolean ignore_delete(GtkWidget *widget, GdkEvent *event, CheckBoxPanel *panel) { return TRUE; } class CheckBoxPanel : public BufferedNode { private: int m_outputID; GtkWidget *m_window; GtkWidget *m_vbox; String m_checkboxNames; vector<GtkWidget*> m_checkboxes; public: CheckBoxPanel(string nodeName, ParameterSet params) : BufferedNode(nodeName, params) { //parameters m_checkboxNames = object_cast<String>(parameters.get("CHECKBOXES")); //output(s) m_outputID = addOutput("OUTPUT"); } virtual ~CheckBoxPanel() { gdk_threads_enter(); gtk_object_destroy(GTK_OBJECT(m_window)); gdk_threads_leave(); } void initialize() { BufferedNode::initialize(); gdk_threads_enter(); m_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_object_set_data (GTK_OBJECT (m_window), "window1", m_window); gtk_window_set_title (GTK_WINDOW (m_window), _("CheckBoxPanel")); gtk_window_set_default_size(GTK_WINDOW(m_window), 150,50); m_vbox = gtk_vbox_new (FALSE, 0); gtk_widget_ref (m_vbox); gtk_object_set_data_full (GTK_OBJECT (m_window), "vbox1", m_vbox, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (m_vbox); gtk_container_add (GTK_CONTAINER (m_window), m_vbox); 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; } } gtk_signal_connect (GTK_OBJECT (m_window), "delete-event", GTK_SIGNAL_FUNC (ignore_delete), this); gtk_widget_show (m_window); gdk_threads_leave(); } void calculate(int output_id, int count, Buffer &out) { try { Vector<int> *vect = new Vector<int>(); gdk_threads_enter(); for (int i = 0; i < m_checkboxes.size(); i++) { int state = (int) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(m_checkboxes[i])); vect->push_back(state); } gdk_threads_leave(); //output vector out[count] = ObjectRef(vect); }//try catch (BaseException *e) { throw e->add(new NodeException (NULL,"Caught Exception in PixbufProbe (calculate)",__FILE__,__LINE__)); } } };//end class CheckBoxPanel #endif Index: Makefile.am =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/Probes/src/Makefile.am,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile.am 26 Jul 2004 15:13:49 -0000 1.11 --- Makefile.am 16 Aug 2004 16:57:25 -0000 1.12 *************** *** 19,23 **** PTZControl.cc \ $(IMAGEPROBE_SDL_SOURCE) \ ! SymbolKeypad.cc --- 19,24 ---- PTZControl.cc \ $(IMAGEPROBE_SDL_SOURCE) \ ! SymbolKeypad.cc \ ! CheckBoxPanel.cc |