MIRA
EditorPartArea.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #ifndef MIRA_EDITORPARTAREA_H_
48 #define MIRA_EDITORPARTAREA_H_
49 
50 #include <set>
51 #include <iostream>
52 
53 #include <QWidget>
54 #include <QTabBar>
55 #include <QMouseEvent>
56 
57 #include <rcp/GuiRCPExports.h>
58 
59 namespace mira {
60 
62 
63 class EditorPartWindow;
64 class EditorPartAreaTabBar; // declared below in this file
65 
67 
73 class MIRA_GUI_RCP_EXPORT EditorPartArea : public QWidget
74 {
75  Q_OBJECT
76 public:
77 
78  EditorPartArea(QWidget* parent=0, Qt::WindowFlags flags=Qt::WindowFlags()) ;
79 
80 public:
81 
82  virtual void addSubWindow(EditorPartWindow* window);
83  void removeSubWindow(EditorPartWindow* window);
84 
85  void activateSubWindow(EditorPartWindow* window);
86  EditorPartWindow* activeSubWindow () const;
87 
88  void scrollToSubWindow(EditorPartWindow* window);
89 
90 signals:
91 
92  void editorWindowActivated(EditorPartWindow* window);
93 
94 public slots:
95 
96  void tileSubWindows();
97 
98 public:
99 
100  void setBackground(const QBrush& brush);
101 
102  void setAutoHideDecorations(bool on);
103 
104 public:
105 
106  virtual bool eventFilter(QObject* object, QEvent* event);
107  virtual void resizeEvent(QResizeEvent* event);
108 
109 public:
110 
111  std::vector<EditorPartWindow*> getTabbedWindows();
112 
113 protected:
114 
115  friend class EditorPartWindow;
116 
117  // to be called by EditorPartWindows
118  void dockSubwindow(EditorPartWindow* window); // called by subwindow to dock back
119  void undockSubwindow(EditorPartWindow* window); // called by subwindow to undock
120  void maximizedSubwindow(EditorPartWindow* window); // called by subwindow when it was maximized
121  void restoredSubwindow(EditorPartWindow* window); // called by subwindow when it was restored
122 
123  // must be called if area was resized, scrolled, or window was newly maximized
124  void rearrangeMaximizedSubwindow(EditorPartWindow* window);
125 
126  void resizeMaximizedSubwindows(const QSize& size);
127  void rearrangeMaximizedSubwindows();
128  void updateMaximizedSubwindowsVisibility();
129 
130  void scrolledAreaBy(int dx, int dy);
131 
132  std::set<EditorPartWindow*> getSubWindows();
133 
134 protected slots:
135 
136  void onFocusChanged(QWidget *old, QWidget *now);
137 
138  void onTabChanged(int);
139  void onTabDoubleClicked(int);
140 
141 private:
142 
143  void addWindowTab(EditorPartWindow* window);
144  void removeWindowTab(EditorPartWindow* window);
145  int findWindowTab(EditorPartWindow* window) const;
146 
147  void internalRaise(EditorPartWindow* window) const;
148 
149 private:
150 
151  class ScrollArea;
152  friend class ScrollArea;
153  ScrollArea* mArea;
154 
155  EditorPartAreaTabBar* mTabBar;
156 
157  std::set<EditorPartWindow*> mSubWindows;
158  std::set<EditorPartWindow*> mDockedSubWindows;
159 
160  EditorPartWindow* mActiveSubWindow;
161 
162  bool mAutoHideDecorations;
163 };
164 
166 
167 class EditorPartAreaTabBar : public QTabBar
168 {
169  Q_OBJECT
170 public:
171 
172  EditorPartAreaTabBar (QWidget* parent) : QTabBar(parent) {
173  setAcceptDrops(true);
174  }
175 
176 signals:
177 
178  void tabDoubleClicked(int index);
179  void tabContextMenu(int index, QPoint globalPos);
180 
181 protected:
182 
183  void dragEnterEvent(QDragEnterEvent* event)
184  {
185  event->acceptProposedAction();
186  }
187 
188  void dragMoveEvent(QDragMoveEvent* event)
189  {
190  int tab = tabAt(event->pos());
191  if(tab>=0 && tab!=currentIndex())
192  setCurrentIndex(tab);
193  event->ignore();
194  }
195 
196  virtual void mouseDoubleClickEvent(QMouseEvent* e)
197  {
198  QTabBar::mouseDoubleClickEvent(e);
199 
200  if(e->button()==Qt::LeftButton)
201  emit tabDoubleClicked(currentIndex());
202  }
203 
204  virtual void contextMenuEvent(QContextMenuEvent* e)
205  {
206  emit tabContextMenu(tabAt(e->pos()), e->globalPos());
207  }
208 };
209 
211 }
212 
213 #endif
This is a replacement for QMdiArea.
Definition: EditorPartArea.h:73
void tabDoubleClicked(int index)
virtual void mouseDoubleClickEvent(QMouseEvent *e)
Definition: EditorPartArea.h:196
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
EditorPartAreaTabBar(QWidget *parent)
Definition: EditorPartArea.h:172
Definition: EditorPartWindow.h:63
void dragMoveEvent(QDragMoveEvent *event)
Definition: EditorPartArea.h:188
void tabContextMenu(int index, QPoint globalPos)
Gui export macro declaration.
virtual void contextMenuEvent(QContextMenuEvent *e)
Definition: EditorPartArea.h:204
#define MIRA_GUI_RCP_EXPORT
Definition: GuiRCPExports.h:61
Definition: EditorPartArea.h:167
void dragEnterEvent(QDragEnterEvent *event)
Definition: EditorPartArea.h:183