GNU Octave  4.0.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-2015 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 <QToolButton>
31 #include <QMouseEvent>
32 
34 {
35  Q_OBJECT
36 
37 public:
38 
39  octave_dock_widget (QWidget *p = 0);
40  virtual ~octave_dock_widget ();
41 
42  virtual void connect_visibility_changed (void);
43  void make_window (void);
44  void make_widget (bool dock=true);
45  void set_title (const QString&);
46  void set_predecessor_widget (octave_dock_widget *prev_widget);
47 signals:
48 
49  /** Custom signal that tells whether a user has clicked away
50  * that dock widget, i.e the active dock widget has
51  * changed. */
52  void active_changed (bool active);
53 
54 protected:
55 
56  virtual void closeEvent (QCloseEvent *e);
57 
58  QWidget * focusWidget ();
59 
60 public slots:
61 
62  virtual void focus (void)
63  {
64  if (! isVisible ())
65  setVisible (true);
66 
67  setFocus ();
68  activateWindow ();
69  raise ();
70  }
71 
72  virtual void handle_visibility (bool visible)
73  {
74  if (visible && ! isFloating ())
75  focus ();
76  }
77 
78  virtual void notice_settings (const QSettings*)
79  {
80  }
81  void handle_settings (const QSettings*);
82 
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  virtual void pasteClipboard () { }
98  virtual void selectAll () { }
99  /** slots to handle undo */
100  virtual void do_undo () { }
101 
102  // event filter for double clicks into the window decoration elements
103  bool eventFilter(QObject *obj, QEvent *e);
104 
105  virtual void add_actions (QList<QAction *> action_list);
106 
107 private slots:
108 
109  void change_floating (bool);
110  void change_visibility (bool);
111 
112 private:
113 
114  void set_style (bool active);
115  void set_focus_predecessor ();
116 
117  QMainWindow *_parent; // store the parent since we are reparenting to 0
118  bool _floating;
122  QColor _bg_color;
124  QColor _fg_color;
126  QString _icon_color;
129 
130 #if defined (Q_OS_WIN32)
131  QWidget *_title_widget;
132  QToolButton *_dock_button;
133  QToolButton *_close_button;
134  QAction *_dock_action;
135  QAction *_close_action;
136 #endif
137 
138 };
139 
140 #endif
virtual void handle_visibility_changed(bool visible)
Slot to steer changing visibility from outside.
octave_dock_widget * _predecessor_widget
void handle_settings(const QSettings *)
bool eventFilter(QObject *obj, QEvent *e)
void set_title(const QString &)
void make_widget(bool dock=true)
octave_dock_widget(QWidget *p=0)
virtual void pasteClipboard()
QMainWindow * main_win()
virtual void add_actions(QList< QAction * > action_list)
void handle_active_dock_changed(octave_dock_widget *, octave_dock_widget *)
void set_predecessor_widget(octave_dock_widget *prev_widget)
void active_changed(bool active)
Custom signal that tells whether a user has clicked away that dock widget, i.e the active dock widget...
virtual void selectAll()
virtual void notice_settings(const QSettings *)
virtual void copyClipboard()
slots to handle copy & paste
virtual void closeEvent(QCloseEvent *e)
void set_style(bool active)
virtual void handle_visibility(bool visible)
virtual void do_undo()
slots to handle undo
virtual void focus(void)
virtual void connect_visibility_changed(void)