OpenStructure
Loading...
Searching...
No Matches
panel_bar.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-2020 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_BAR
20#define OST_GUI_PANEL_BAR_PANEL_BAR
21
22
25#include <ost/gui/widget.hh>
27
28#include "button_box.hh"
29
30
31#include <QStackedLayout>
32#include <QWidget>
33#include <QString>
34#include <QAction>
35#include <QActionGroup>
36namespace ost { namespace gui {
37
38class PanelWidgetContainer;
39
41{
42 WidgetState(Widget * w,bool v=true, QString n=""):
43 widget(w), visible(v), name(n)
44 { }
46 bool visible;
47 QString name;
48};
49
54 Q_OBJECT
55public:
56 PanelBar(QWidget* parent);
57 virtual ~PanelBar();
58
59 virtual bool Save(const QString& prefix);
60 virtual bool Restore(const QString& prefix);
61
66 virtual void AddWidget(Widget* widget, bool hidden);
67
68 // \brief Add a view mode to this widget
69 // Adds a view mode to this class. The view mode will automaticaly added to the view mode menu see /ref PanelBar::AddGetViewModeMenu() for more information.
70 // \param pwc View Mode to be added
76
81 int GetIndex(Widget* widget);
82
85 void DragEnter();
88 void EndDrag();
89
93 QAction* GetShowAction();
94
95public slots:
101 void InsertWidget(Widget * widget, int index, bool is_hidden=false);
105
108
112 void RemoveWidget(Widget* widget);
113
114private slots:
115 void ChangeViewMode(QAction* action);
116 void ToggleVisibility(Widget*);
117 void ShowActionTrigger();
118 void SetViewMode(int index);
119private:
120 void UpdateShow();
121
122 QStackedLayout* layout_;
123 QActionGroup* view_modes_;
124 QMenu* view_mode_menu_;
125 PanelWidgetContainer* current_view_mode_;
126 QList<WidgetState> widget_states_;
127 Widget* drop_box_;
128 QAction* show_action_;
129};
130
131}}
132
133#endif
Panel Bar which may contain other Widgets A PanelBar might have different ViewModes which are PanelWi...
Definition panel_bar.hh:53
void ToggleHide()
Toggle the visibility of all Panels.
virtual bool Save(const QString &prefix)
PanelBar(QWidget *parent)
void RemoveWidget(Widget *widget)
Remove a Widget The widget will be removed if it is in this PanelBar.
int GetIndex(Widget *widget)
Get the index of a given widget The index of a widget is the position number. This method can be used...
virtual void AddWidget(Widget *widget, bool hidden)
Add a widget to this widget Puts a widget at the end of the current PanelWidgetContainer.
void EndDrag()
Stop dragging widgets This method is called by the PanelManager class. Read more about this method at...
void DragEnter()
Begin with dragging widgets This method is called by the PanelManager class. Read more about this met...
QMenu * GetViewModeMenu()
Get QMenu with view modes The returned menu can be used for exmaple in the menubar to allow the user ...
void ToggleViewMode()
Change to the next view mode This method changes the view mode to the next view mode....
virtual bool Restore(const QString &prefix)
QAction * GetShowAction()
Get action which changes the visibility of this widget The returned action can be used for example in...
void AddViewMode(PanelWidgetContainer *pwc)
void InsertWidget(Widget *widget, int index, bool is_hidden=false)
This slot adds a given widget at the given position The Widget will be added at the given index....
A PanelWidgetContainer can display various widgets A PanelWidgetContainer is a abstract class which i...
Base class for widgets.
Definition widget.hh:40
#define DLLEXPORT_OST_GUI
Definition base.dox:1
WidgetState(Widget *w, bool v=true, QString n="")
Definition panel_bar.hh:42