Lumiera  0.pre.03
»edit your freedom«
panel-locator.hpp
Go to the documentation of this file.
1 /*
2  PANEL-LOCATOR.hpp - manage all top level windows
3 
4  Copyright (C) Lumiera.org
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
49 #ifndef STAGE_CTRL_PANEL_LOCATOR_H
50 #define STAGE_CTRL_PANEL_LOCATOR_H
51 
52 #include "stage/gtk-base.hpp"
54 #include "lib/format-string.hpp"
55 #include "lib/meta/util.hpp"
56 #include "lib/nocopy.hpp"
57 
58 #include <type_traits>
59 #include <memory>
60 #include <list>
61 
62 
63 namespace stage {
64 namespace workspace {
65  class WorkspaceWindow;
66 }
67 namespace panel {
68  class Panel;
69 }
70 namespace ctrl {
71 
72  namespace error = lumiera::error;
73 
74  using panel::Panel;
75  using util::_Fmt;
76  using std::list;
77 
78 
79 
87  {
89  using WindowList = list<PWindow>;
90 
91  WindowList& windowList_;
92 
93 
94  public:
95  PanelLocator (WindowList&);
96 
108  template<class PAN>
109  PAN& find_or_create();
110 
111 
112  private:
113  panel::Panel& preliminary_impl_PanelLookup (int typeID);
114  };
115 
116 
117 
119  template<class PAN>
120  inline PAN&
121  PanelLocator::find_or_create()
122  {
123  static_assert (std::is_base_of<panel::Panel, PAN>(), "Lumiera Panel subclass expected");
124 
125  int typeID = workspace::PanelManager::findPanelID<PAN>();
126  if (-1 == typeID)
127  throw error::Invalid (_Fmt{"Requested type «%s» not usable as docking panel."}
128  % util::typeStr<PAN>()
129  ,LERR_(WRONG_TYPE));
130 
131  return dynamic_cast<PAN&> (preliminary_impl_PanelLookup (typeID));
132  }
133 
134 
135 
136 }}// namespace stage::ctrl
137 #endif /*STAGE_CTRL_PANEL_LOCATOR_H*/
Simple and lightweight helpers for metaprogramming and type detection.
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
Management of dockable panels.
Front-end for printf-style string template interpolation.
A front-end for using printf-style formatting.
Derived specific exceptions within Lumiera&#39;s exception hierarchy.
Definition: error.hpp:199
Mix-Ins to allow or prohibit various degrees of copying and cloning.
The base class for all dockable panels.
Definition: panel.hpp:49
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
The main Lumiera workspace window.
A set of basic GTK includes for the UI.
Service to access, locate or place panels within top-level windows Access- and query front-end to the...