OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
panel_manager.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GUI_PANEL_BAR_PANEL_MANAGER
20 #define OST_GUI_PANEL_BAR_PANEL_MANAGER
21 
22 
23 #include <ost/gui/widget.hh>
24 #include <ost/gui/widget_pool.hh>
25 #include <ost/gui/thin_splitter.hh>
26 
28 #include "button_box.hh"
29 
30 #include <QWidget>
31 #include <QString>
32 #include <QList>
33 #include <QMenu>
34 #include <QDragEnterEvent>
35 namespace ost { namespace gui {
36 
38 {
43 };
44 
49  Q_OBJECT
50 public:
51  PanelManager(QWidget* widget);
53  virtual bool Save(const QString& prefix);
54  virtual bool Restore(const QString& prefix);
55 
62  virtual void AddWidgetToPool(const QString& class_name, int limit=-1);
68  virtual void AddWidgetToPool(const QString& name, Widget* widget);
69 
76  void AddWidget(PanelPosition pos, Widget* widget, bool is_hidden=false);
82  void AddWidgetByName(PanelPosition pos, const QString& class_name, bool is_hidden=false);
83 
89  void ReplaceWidget(Widget* w1, Widget* w2);
93  void ReplaceWidget(Widget* w1, QString& class_name);
94 
98  QMenu* GetMenu();
102  QList<QString> GetAvailableWidgets();
103 
107  void StartDrag();
110  void EndDrag();
111 
112 public slots:
116  QMenu* GetAvailableWidgetsMenu();
117 
120  void ToggleViewMode(PanelPosition pos);
121 
125  void MoveWidget(Widget * widget, PanelPosition pos, int index);
126 
131  void MoveNextTo(Widget* target, Widget* widget);
132 
136  void RemoveWidget(Widget * widget);
137 
139  void ToggleHide();
142  void ToggleHide(PanelPosition pos);
143 
144 private slots:
145  void UpdateAddMenu();
146  void UpdateCurrentMenu();
147  void AddWidgetFromMenu(QAction * action);
148 
149 private:
150  PanelPosition GetParentPanel(Widget* widget);
151 
152  ThinSplitter* right_panel_splitter_;
153  ThinSplitter* left_panel_splitter_;
154  ThinSplitter* bottom_panel_splitter_;
155  QMap<PanelPosition, PanelBar*> panels_;
156  WidgetPool* pool_;
157  QMenu* add_menu_;
158  PanelPosition current_menu_;
159 };
160 
161 }}
162 
163 #endif
164