GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
octave-dock-widget.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2012-2013 Richard Crozier
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_octave_dock_widget_h)
24 #define octave_octave_dock_widget_h 1
25 
26 #include <QDockWidget>
27 #include <QSettings>
28 #include <QIcon>
29 #include <QMainWindow>
30 #include <QMouseEvent>
31 
33 {
34  Q_OBJECT
35 
36 public:
37 
38  octave_dock_widget (QWidget *p = 0);
39  virtual ~octave_dock_widget ();
40 
41  virtual void connect_visibility_changed (void);
42  void make_window (void);
43  void make_widget (bool dock=true);
44  void set_title (const QString&);
45 
46 signals:
47 
48  /** Custom signal that tells whether a user has clicked away
49  * that dock widget, i.e the active dock widget has
50  * changed. */
51  void active_changed (bool active);
52 
53 protected:
54 
55  virtual void closeEvent (QCloseEvent *e)
56  {
57  emit active_changed (false);
59  }
60 
61  QWidget * focusWidget ();
62 
63 public slots:
64 
65  virtual void focus (void)
66  {
67  if (! isVisible ())
68  setVisible (true);
69 
70  setFocus ();
71  activateWindow ();
72  raise ();
73  }
74 
75  virtual void handle_visibility (bool visible)
76  {
77  if (visible && ! isFloating ())
78  focus ();
79  }
80 
81  virtual void notice_settings (const QSettings*)
82  {
83  }
84 
85  QMainWindow *main_win () { return _parent; }
86 
87 protected slots:
88 
89  /** Slot to steer changing visibility from outside. */
90  virtual void handle_visibility_changed (bool visible)
91  {
92  if (visible)
93  emit active_changed (true);
94  }
95  /** slots to handle copy & paste */
96  virtual void copyClipboard ()
97  {
98  }
99  virtual void pasteClipboard ()
100  {
101  }
102 
103 private slots:
104 
105  void change_floating (bool);
106  void change_visibility (bool);
107 
108 private:
109 
110  QMainWindow *_parent; // store the parent since we are reparenting to 0
111  QAction *_dock_action;
112  bool _floating;
113 
114 };
115 
116 #endif