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 namespace mira {
58 
60 
61 class EditorPartWindow;
62 class EditorPartAreaTabBar; // declared below in this file
63 
65 
71 class EditorPartArea : public QWidget
72 {
73  Q_OBJECT
74 public:
75 
76  EditorPartArea(QWidget* parent=0, Qt::WindowFlags flags=Qt::WindowFlags()) ;
77 
78 public:
79 
80  virtual void addSubWindow(EditorPartWindow* window);
81  void removeSubWindow(EditorPartWindow* window);
82 
83  void activateSubWindow(EditorPartWindow* window);
85 
86  void scrollToSubWindow(EditorPartWindow* window);
87 
88 signals:
89 
91 
92 public slots:
93 
94  void tileSubWindows();
95 
96 public:
97 
98  void setBackground(const QBrush& brush);
99 
100  void setAutoHideDecorations(bool on);
101 
102 public:
103 
104  virtual bool eventFilter(QObject* object, QEvent* event);
105  virtual void resizeEvent(QResizeEvent* event);
106 
107 public:
108 
109  std::vector<EditorPartWindow*> getTabbedWindows();
110 
111 protected:
112 
113  friend class EditorPartWindow;
114 
115  // to be called by EditorPartWindows
116  void dockSubwindow(EditorPartWindow* window); // called by subwindow to dock back
117  void undockSubwindow(EditorPartWindow* window); // called by subwindow to undock
118  void maximizedSubwindow(EditorPartWindow* window); // called by subwindow when it was maximized
119  void restoredSubwindow(EditorPartWindow* window); // called by subwindow when it was restored
120 
121  // must be called if area was resized, scrolled, or window was newly maximized
123 
124  void resizeMaximizedSubwindows(const QSize& size);
127 
128  void scrolledAreaBy(int dx, int dy);
129 
130  std::set<EditorPartWindow*> getSubWindows();
131 
132 protected slots:
133 
134  void onFocusChanged(QWidget *old, QWidget *now);
135 
136  void onTabChanged(int);
137  void onTabDoubleClicked(int);
138 
139 private:
140 
141  void addWindowTab(EditorPartWindow* window);
142  void removeWindowTab(EditorPartWindow* window);
143  int findWindowTab(EditorPartWindow* window) const;
144 
145  void internalRaise(EditorPartWindow* window) const;
146 
147 private:
148 
149  class ScrollArea;
150  friend class ScrollArea;
151  ScrollArea* mArea;
152 
153  EditorPartAreaTabBar* mTabBar;
154 
155  std::set<EditorPartWindow*> mSubWindows;
156  std::set<EditorPartWindow*> mDockedSubWindows;
157 
158  EditorPartWindow* mActiveSubWindow;
159 
160  bool mAutoHideDecorations;
161 };
162 
164 
165 class EditorPartAreaTabBar : public QTabBar
166 {
167  Q_OBJECT
168 public:
169 
170  EditorPartAreaTabBar (QWidget* parent) : QTabBar(parent) {
171  setAcceptDrops(true);
172  }
173 
174 signals:
175 
176  void tabDoubleClicked(int index);
177  void tabContextMenu(int index, QPoint globalPos);
178 
179 protected:
180 
181  void dragEnterEvent(QDragEnterEvent* event)
182  {
183  event->acceptProposedAction();
184  }
185 
186  void dragMoveEvent(QDragMoveEvent* event)
187  {
188  int tab = tabAt(event->pos());
189  if(tab>=0 && tab!=currentIndex())
190  setCurrentIndex(tab);
191  event->ignore();
192  }
193 
194  virtual void mouseDoubleClickEvent(QMouseEvent* e)
195  {
196  QTabBar::mouseDoubleClickEvent(e);
197 
198  if(e->button()==Qt::LeftButton)
199  emit tabDoubleClicked(currentIndex());
200  }
201 
202  virtual void contextMenuEvent(QContextMenuEvent* e)
203  {
204  emit tabContextMenu(tabAt(e->pos()), e->globalPos());
205  }
206 };
207 
209 }
210 
211 #endif
This is a replacement for QMdiArea.
Definition: EditorPartArea.h:71
virtual bool eventFilter(QObject *object, QEvent *event)
void scrollToSubWindow(EditorPartWindow *window)
void setAutoHideDecorations(bool on)
void tabDoubleClicked(int index)
virtual void mouseDoubleClickEvent(QMouseEvent *e)
Definition: EditorPartArea.h:194
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void restoredSubwindow(EditorPartWindow *window)
void scrolledAreaBy(int dx, int dy)
void onTabDoubleClicked(int)
void resizeMaximizedSubwindows(const QSize &size)
std::set< EditorPartWindow * > getSubWindows()
EditorPartAreaTabBar(QWidget *parent)
Definition: EditorPartArea.h:170
void rearrangeMaximizedSubwindows()
std::vector< EditorPartWindow * > getTabbedWindows()
void updateMaximizedSubwindowsVisibility()
void dockSubwindow(EditorPartWindow *window)
Definition: EditorPartWindow.h:61
void rearrangeMaximizedSubwindow(EditorPartWindow *window)
void undockSubwindow(EditorPartWindow *window)
void editorWindowActivated(EditorPartWindow *window)
void onFocusChanged(QWidget *old, QWidget *now)
void removeSubWindow(EditorPartWindow *window)
EditorPartArea(QWidget *parent=0, Qt::WindowFlags flags=Qt::WindowFlags())
virtual void addSubWindow(EditorPartWindow *window)
void dragMoveEvent(QDragMoveEvent *event)
Definition: EditorPartArea.h:186
void setBackground(const QBrush &brush)
void tabContextMenu(int index, QPoint globalPos)
virtual void contextMenuEvent(QContextMenuEvent *e)
Definition: EditorPartArea.h:202
EditorPartWindow * activeSubWindow() const
void activateSubWindow(EditorPartWindow *window)
friend class ScrollArea
Definition: EditorPartArea.h:149
Definition: EditorPartArea.h:165
virtual void resizeEvent(QResizeEvent *event)
void dragEnterEvent(QDragEnterEvent *event)
Definition: EditorPartArea.h:181
void maximizedSubwindow(EditorPartWindow *window)