Fawkes API  Fawkes Development Version
multi_interface_chooser_dialog.h
00001 /***************************************************************************
00002  *  multi_interface_chooser_dialog.h - Dialog for choosing a blackboard interface
00003  *
00004  *  Created: Mon Oct 17 21:01:30 2011
00005  *  Copyright  2011  Christoph Schwering
00006  *
00007  ****************************************************************************/
00008 
00009 /*  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version. A runtime exception applies to
00013  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00021  */
00022 
00023 #ifndef __LIBS_GUI_UTILS_MULTI_INTERFACE_CHOOSER_DIALOG_H_
00024 #define __LIBS_GUI_UTILS_MULTI_INTERFACE_CHOOSER_DIALOG_H_
00025 
00026 #include <list>
00027 #include <set>
00028 #include <string>
00029 
00030 #include <gui_utils/interface_chooser_dialog.h>
00031 
00032 namespace fawkes {
00033 
00034 class MultiInterfaceChooserDialog : public InterfaceChooserDialog
00035 {
00036  public:
00037   /** Pair of type and IDs of interfaces. */
00038   typedef std::pair<Glib::ustring, Glib::ustring> TypeIdPair;
00039   /** List of type and ID of an interface. */
00040   typedef std::list<TypeIdPair> TypeIdPairList;
00041 
00042   static MultiInterfaceChooserDialog* create(
00043       Gtk::Window &parent,
00044       BlackBoard *blackboard,
00045       const char *type_pattern,
00046       const char *id_pattern,
00047       const TypeIdPairList& loaded_interfaces,
00048       const Glib::ustring& title = DEFAULT_TITLE);
00049 
00050   virtual ~MultiInterfaceChooserDialog();
00051 
00052   TypeIdPairList get_selected_interfaces() const;
00053   TypeIdPairList get_newly_selected_interfaces() const;
00054 
00055  protected:
00056   class Record : public InterfaceChooserDialog::Record
00057   {
00058    public:
00059     Record();
00060     Gtk::TreeModelColumn<bool> load; /**< Load this interface? */
00061   };
00062 
00063   MultiInterfaceChooserDialog(Gtk::Window &parent,
00064                               const TypeIdPairList& loaded_interfaces,
00065                               const Glib::ustring& title);
00066 
00067   virtual const Record& record() const;
00068   virtual int init_columns();
00069   virtual void init_row(Gtk::TreeModel::Row& row, const InterfaceInfo& ii);
00070 
00071  private:
00072   /** Set of type and ID of an interface. */
00073   typedef std::set<TypeIdPair> TypeIdPairSet;
00074 
00075   void on_load_toggled(const Glib::ustring& path);
00076 
00077   const Record* __record; /**< Should only be accessed by record(). */
00078   TypeIdPairSet __loaded_interfaces;
00079 };
00080 
00081 } // end of namespace fawkes
00082 
00083 #endif