Lumiera  0.pre.03
»edit your freedom«
dock-area.hpp
Go to the documentation of this file.
1 /*
2  DOCK-AREA.hpp - maintain a docking area within the WorkspaceWindow
3 
4  Copyright (C) Lumiera.org
5  2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6  2018, Hermann Vosseler <Ichthyostega@web.de>
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of
11  the License, or (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 
22 */
23 
24 
39 #ifndef STAGE_WORKSPACE_DOCK_AREA_H
40 #define STAGE_WORKSPACE_DOCK_AREA_H
41 
42 #include "stage/panel/panel.hpp"
43 
44 #include <gdlmm.h>
45 #include <typeinfo>
46 
47 
48 using namespace stage::panel;
49 
50 namespace stage {
51 namespace workspace {
52 
53 
58  class DockArea
59  {
62 
66  Gdl::Dock dock_;
67 
71  Gdl::DockBar dockBar_;
72 
76  Glib::RefPtr<Gdl::DockLayout> dockLayout_;
77 
81  GdlDockPlaceholder *dockPlaceholders_[4];
82 
84  std::list<panel::Panel*> panels_;
85 
89  static unsigned short panelID;
90 
91 
92  public:
94  ~DockArea();
95 
102  void setupDock();
103 
108  Gdl::Dock& getDock();
109 
114  Gdl::DockBar& getDockBar();
115 
119  WorkspaceWindow& getWorkspaceWindow();
120 
126  panel::Panel& showPanel (const int description_index);
127 
129  bool hasPanel (const int description_index);
130 
138  void switchPanel (panel::Panel& old_panel, const int description_index);
139 
145  void splitPanel (panel::Panel& panel, Gtk::Orientation split_direction);
146 
147 
148  public:
154  template<class P>
155  static int findPanelID();
156 
158  static int getPanelDescriptionCount();
159 
165  static const gchar* getPanelStockID (const int index);
166 
172  static const char* getPanelTitle (int index);
173 
174 
175  private:
177  void createPanels();
178 
185  static int findPanelDescription (const char* class_name);
186 
192  panel::Panel* createPanel_by_index (const int index);
193 
200  panel::Panel* createPanel_by_index (const int index, Gdl::DockItem& dock_item);
201 
207  panel::Panel* createPanel_by_name (const char* class_name);
208 
215  int getPanelType (panel::Panel* const panel) const;
216 
221  void removePanel (panel::Panel* const panel);
222 
224  void clearPanels();
225 
226 
227  private:
232  void on_panel_shown (panel::Panel *panel);
233 
234 
235 
236  private:
237 
242  {
243  protected:
244  typedef panel::Panel* (*const CreatePanelProc)(DockArea&, Gdl::DockItem&);
246  private:
248  const std::type_info& classInfo_;
249 
251  const char* const titleName_;
252 
254  const gchar* const stockID_;
255 
257  CreatePanelProc createPanelProc_;
258 
259 
260  protected:
267  PanelDescription (std::type_info const& classInfo
268  ,const char* title
269  ,const gchar* stockID
270  ,CreatePanelProc createPanelProc)
271  : classInfo_(classInfo)
272  , titleName_(title)
273  , stockID_(stockID)
274  , createPanelProc_(createPanelProc)
275  {
276  REQUIRE(titleName_);
277  }
278 
279 
280  public:
281  const std::type_info& getClassInfo() const
282  {
283  return classInfo_;
284  }
285 
286  const char* getClassName() const
287  {
288  return classInfo_.name();
289  }
290 
292  const char* getTitle() const
293  {
294  ENSURE(titleName_);
295  return titleName_;
296  }
297 
298  const gchar* getStockID() const
299  {
300  ENSURE(stockID_);
301  return stockID_;
302  }
303 
304 
311  panel::Panel*
312  create (DockArea& panelManager, Gdl::DockItem& dockItem) const
313  {
314  REQUIRE(createPanelProc_);
315  return createPanelProc_ (panelManager, dockItem);
316  }
317  };
318 
319 
320 
326  template<class P>
327  class Panel
328  : public PanelDescription
329  {
330  public:
331  Panel()
332  : PanelDescription (typeid(P)
333  ,P::getTitle()
334  ,P::getStockID()
335  ,Panel::createPanel)
336  { }
337 
338  private:
344  static panel::Panel*
345  createPanel (DockArea& panelManager, Gdl::DockItem& dockItem)
346  {
347  return new P(panelManager, dockItem);
348  }
349  };
350 
351 
353  static const PanelDescription panelDescriptionList[];
354  };
355 
356 
357 
358 
359  template<class P>
360  inline int
361  DockArea::findPanelID()
362  {
363  return DockArea::findPanelDescription (typeid(P).name());
364  }
365 
366 
367 
368 }}// namespace stage::workspace
369 #endif /*STAGE_WORKSPACE_DOCK_AREA_H*/
A helper class that will create PanelDescription objects.
Definition: dock-area.hpp:327
std::list< panel::Panel * > panels_
list of all panels created
Definition: dock-area.hpp:84
panel::Panel * create(DockArea &panelManager, Gdl::DockItem &dockItem) const
Creates an instance of this panel.
Definition: dock-area.hpp:312
WorkspaceWindow & workspaceWindow_
reference to the owner workspace window object
Definition: dock-area.hpp:61
const char *const titleName_
localised title that will be shown on the panel.
Definition: dock-area.hpp:251
const std::type_info & classInfo_
reference to the typeID of this class
Definition: dock-area.hpp:248
Gdl::DockBar dockBar_
The pointer to GDL dock bar widget.
Definition: dock-area.hpp:71
Docking panel classes.
const gchar *const stockID_
Stock ID for this type of panel.
Definition: dock-area.hpp:254
The base class for all dockable panels.
Definition: panel.hpp:49
Base class and interface for all dockable panels.
A class to manage DockItem objects for WorkspaceWindow.
Definition: dock-area.hpp:58
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
A class to describe and instantiate Panel types.
Definition: dock-area.hpp:241
Gdl::Dock dock_
The pointer to GDL dock widget.
Definition: dock-area.hpp:66
The main Lumiera workspace window.
static panel::Panel * createPanel(DockArea &panelManager, Gdl::DockItem &dockItem)
helper function to create a panel of type P
Definition: dock-area.hpp:345
CreatePanelProc createPanelProc_
pointer to a function that will instantiate the panel object
Definition: dock-area.hpp:257
PanelDescription(std::type_info const &classInfo, const char *title, const gchar *stockID, CreatePanelProc createPanelProc)
Definition: dock-area.hpp:267
static unsigned short panelID
An accumulator for the panel id.
Definition: dock-area.hpp:89
Glib::RefPtr< Gdl::DockLayout > dockLayout_
The pointer to GDL dock layout object.
Definition: dock-area.hpp:76
ElementBoxWidget::Config::Qualifier name(string id)
define the name-ID displayed in the caption
const char * getTitle() const
the localised title that will be shown on the panel
Definition: dock-area.hpp:292