Fawkes API  Fawkes Development Version
interface_chooser_dialog.h
1 /***************************************************************************
2  * interface_chooser_dialog.h - Dialog for choosing a blackboard interface
3  *
4  * Created: Sat Mar 19 12:18:43 2011
5  * Copyright 2008-2011 Tim Niemueller [www.niemueller.de]
6  * Copyright 2011 Christoph Schwering
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __LIBS_GUI_UTILS_INTERFACE_CHOOSER_DIALOG_H_
25 #define __LIBS_GUI_UTILS_INTERFACE_CHOOSER_DIALOG_H_
26 
27 #include <gtkmm/dialog.h>
28 #include <gtkmm/treeview.h>
29 #include <gtkmm/entry.h>
30 #include <gtkmm/expander.h>
31 #include <gtkmm/scrolledwindow.h>
32 #include <gtkmm/liststore.h>
33 
34 namespace fawkes {
35 #if 0 /* just to make Emacs auto-indent happy */
36 }
37 #endif
38 
39 class Interface;
40 class BlackBoard;
41 class InterfaceInfo;
42 
44  : public Gtk::Dialog
45 {
46  public:
47  static const char* const DEFAULT_TITLE;
48 
50  Gtk::Window &parent,
51  BlackBoard *blackboard,
52  const char *type_pattern,
53  const char *id_pattern,
54  const Glib::ustring& title = DEFAULT_TITLE);
55 
56  virtual ~InterfaceChooserDialog();
57 
58  void get_selected_interface(Glib::ustring &type, Glib::ustring &id);
59 
61 
62  protected:
63  class Record : public Gtk::TreeModelColumnRecord
64  {
65  public:
66  Record();
67 
68  Gtk::TreeModelColumn<Glib::ustring> type; /**< The type of the interface */
69  Gtk::TreeModelColumn<Glib::ustring> id; /**< The ID of the interface */
70  Gtk::TreeModelColumn<bool> has_writer; /**< Writer exists? */
71  Gtk::TreeModelColumn<unsigned int> num_readers; /**< Number of readers */
72  };
73 
74  InterfaceChooserDialog(Gtk::Window& parent, const Glib::ustring& title);
75 
76  void init(BlackBoard* blackboard,
77  const char* type_pattern,
78  const char* id_pattern);
79 
80  virtual const Record& record() const;
81  virtual int init_columns();
82  virtual void init_row(Gtk::TreeModel::Row& row, const InterfaceInfo& ii);
83 
84  Gtk::TreeView __treeview; /**< Tree widget for interfaces. */
85  Glib::RefPtr<Gtk::ListStore> __model; /**< Data model of the tree. */
86 
87  private:
89  InterfaceChooserDialog& operator=(const InterfaceChooserDialog& obj);
90 
91  BlackBoard *__bb;
92 
93  Gtk::Window &__parent;
94  Gtk::ScrolledWindow __scrollwin;
95 
96  const Record* __record; /**< Should only be accessed by record(). */
97 };
98 
99 } // end of namespace fawkes
100 
101 #endif
Blackboard interface chooser dialog.
Fawkes library namespace.
void init(BlackBoard *blackboard, const char *type_pattern, const char *id_pattern)
Initialization method.
Glib::RefPtr< Gtk::ListStore > __model
Data model of the tree.
virtual const Record & record() const
Returns the Record of this chooser dialog.
static const char *const DEFAULT_TITLE
Default title of interface chooser dialogs.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
virtual int init_columns()
Initializes the columns GUI-wise.
Gtk::TreeModelColumn< Glib::ustring > type
The type of the interface.
Gtk::TreeModelColumn< bool > has_writer
Writer exists?
Gtk::TreeView __treeview
Tree widget for interfaces.
InterfaceChooserDialog(Gtk::Window &parent, const Glib::ustring &title)
Constructor for subclasses.
Gtk::TreeModelColumn< unsigned int > num_readers
Number of readers.
void get_selected_interface(Glib::ustring &type, Glib::ustring &id)
Get selected interface type and ID.
virtual void init_row(Gtk::TreeModel::Row &row, const InterfaceInfo &ii)
Initializes a row with the given interface.
fawkes::Interface * run_and_open_for_reading()
Run dialog and try to connect.
The BlackBoard abstract class.
Definition: blackboard.h:48
Gtk::TreeModelColumn< Glib::ustring > id
The ID of the interface.
static InterfaceChooserDialog * create(Gtk::Window &parent, BlackBoard *blackboard, const char *type_pattern, const char *id_pattern, const Glib::ustring &title=DEFAULT_TITLE)
Factory method.
Interface info.