Lumiera  0.pre.03
»edit your freedom«
panel-manager.hpp
Go to the documentation of this file.
1 /*
2  PANEL-MANAGER.hpp - management of dockable GDL panels
3 
4  Copyright (C)
5  2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
25 #ifndef STAGE_WORKSPACE_PANEL_MANAGER_H
26 #define STAGE_WORKSPACE_PANEL_MANAGER_H
27 
28 #include "stage/panel/panel.hpp"
29 
30 #include <gdlmm.h>
31 #include <typeinfo>
32 
33 
34 using namespace stage::panel;
35 
36 namespace stage {
37 namespace workspace {
38 
39 
45  {
48 
52  Gdl::Dock dock_;
53 
57  Gdl::DockBar dockBar_;
58 
62  Glib::RefPtr<Gdl::DockLayout> dockLayout_;
63 
67  GdlDockPlaceholder *dockPlaceholders_[4];
68 
70  std::list<panel::Panel*> panels_;
71 
75  static unsigned short panelID;
76 
77 
78  public:
80  ~PanelManager();
81 
86  void setupDock();
87 
92  Gdl::Dock& getDock();
93 
98  Gdl::DockBar& getDockBar();
99 
103  WorkspaceWindow& getWorkspaceWindow();
104 
110  panel::Panel& showPanel (const int description_index);
111 
113  bool hasPanel (const int description_index);
114 
122  void switchPanel (panel::Panel& old_panel, const int description_index);
123 
129  void splitPanel (panel::Panel& panel, Gtk::Orientation split_direction);
130 
131 
132  public:
138  template<class P>
139  static int findPanelID();
140 
142  static int getPanelDescriptionCount();
143 
149  static const gchar* getPanelStockID (const int index);
150 
156  static const char* getPanelTitle (int index);
157 
158 
159  private:
161  void createPanels();
162 
169  static int findPanelDescription (const char* class_name);
170 
176  panel::Panel* createPanel_by_index (const int index);
177 
184  panel::Panel* createPanel_by_index (const int index, Gdl::DockItem& dock_item);
185 
191  panel::Panel* createPanel_by_name (const char* class_name);
192 
199  int getPanelType (panel::Panel* const panel) const;
200 
205  void removePanel (panel::Panel* const panel);
206 
208  void clearPanels();
209 
210 
211  private:
216  void on_panel_shown (panel::Panel *panel);
217 
218 
219 
220  private:
221 
226  {
227  protected:
228  typedef panel::Panel* (*const CreatePanelProc)(PanelManager&, Gdl::DockItem&);
230  private:
232  const std::type_info& classInfo_;
233 
235  const char* const titleName_;
236 
238  const gchar* const stockID_;
239 
241  CreatePanelProc createPanelProc_;
242 
243 
244  protected:
251  PanelDescription (std::type_info const& classInfo
252  ,const char* title
253  ,const gchar* stockID
254  ,CreatePanelProc createPanelProc)
255  : classInfo_(classInfo)
256  , titleName_(title)
257  , stockID_(stockID)
258  , createPanelProc_(createPanelProc)
259  {
260  REQUIRE(titleName_);
261  }
262 
263 
264  public:
265  const std::type_info& getClassInfo() const
266  {
267  return classInfo_;
268  }
269 
270  const char* getClassName() const
271  {
272  return classInfo_.name();
273  }
274 
276  const char* getTitle() const
277  {
278  ENSURE(titleName_);
279  return titleName_;
280  }
281 
282  const gchar* getStockID() const
283  {
284  ENSURE(stockID_);
285  return stockID_;
286  }
287 
288 
295  panel::Panel*
296  create (PanelManager& panelManager, Gdl::DockItem& dockItem) const
297  {
298  REQUIRE(createPanelProc_);
299  return createPanelProc_ (panelManager, dockItem);
300  }
301  };
302 
303 
304 
309  template<class P>
310  class Panel
311  : public PanelDescription
312  {
313  public:
314  Panel()
315  : PanelDescription (typeid(P)
316  ,P::getTitle()
317  ,P::getStockID()
318  ,Panel::createPanel)
319  { }
320 
321  private:
327  static panel::Panel*
328  createPanel (PanelManager& panelManager, Gdl::DockItem& dockItem)
329  {
330  return new P(panelManager, dockItem);
331  }
332  };
333 
334 
336  static const PanelDescription panelDescriptionList[];
337  };
338 
339 
340 
341 
342  template<class P>
343  inline int
344  PanelManager::findPanelID()
345  {
346  return PanelManager::findPanelDescription (typeid(P).name());
347  }
348 
349 
350 
351 }}// namespace stage::workspace
352 #endif /*STAGE_WORKSPACE_PANEL_MANAGER_H*/
const char *const titleName_
localised title that will be shown on the panel.
WorkspaceWindow & workspaceWindow_
reference to the owner workspace window object
std::list< panel::Panel * > panels_
list of all panels created
const std::type_info & classInfo_
reference to the typeID of this class
Docking panel classes.
CreatePanelProc createPanelProc_
pointer to a function that will instantiate the panel object
static unsigned short panelID
An accumulator for the panel id.
PanelDescription(std::type_info const &classInfo, const char *title, const gchar *stockID, CreatePanelProc createPanelProc)
A class to manage DockItem objects for WorkspaceWindow.
Gdl::DockBar dockBar_
The pointer to GDL dock bar widget.
The base class for all dockable panels.
Definition: panel.hpp:40
Base class and interface for all dockable panels.
A helper class that will create PanelDescription objects.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
Gdl::Dock dock_
The pointer to GDL dock widget.
Glib::RefPtr< Gdl::DockLayout > dockLayout_
The pointer to GDL dock layout object.
panel::Panel * create(PanelManager &panelManager, Gdl::DockItem &dockItem) const
Creates an instance of this panel.
The main Lumiera workspace window.
static panel::Panel * createPanel(PanelManager &panelManager, Gdl::DockItem &dockItem)
helper function to create a panel of type P
const gchar *const stockID_
Stock ID for this type of panel.
const char * getTitle() const
the localised title that will be shown on the panel
ElementBoxWidget::Config::Qualifier name(string id)
define the name-ID displayed in the caption
A class to describe and instantiate Panel types.