GNU Octave  4.2.1
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-2017 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 
40  virtual ~octave_dock_widget (void) { }
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  void handle_settings (const QSettings*);
81 
83 
84  QMainWindow *main_win () { return _parent; }
85 
86  void save_settings (void);
87 
88 protected slots:
89 
90  /** Slot to steer changing visibility from outside. */
91  virtual void handle_visibility_changed (bool visible)
92  {
93  if (visible)
94  emit active_changed (true);
95  }
96  /** slots to handle copy & paste */
97  virtual void copyClipboard () { }
98  virtual void pasteClipboard () { }
99  virtual void selectAll () { }
100  /** slots to handle undo */
101  virtual void do_undo () { }
102 
103  // event filter for double clicks into the window decoration elements
104  bool eventFilter(QObject *obj, QEvent *e);
105 
106 private slots:
107 
108  void change_floating (bool);
109  void change_visibility (bool);
110 
111 private:
112 
113  void set_style (bool active);
114  void set_focus_predecessor ();
115 
116  QMainWindow *_parent; // store the parent since we are reparenting to 0
117  bool _floating;
121  QColor _bg_color;
123  QColor _fg_color;
125  QString _icon_color;
128 
129 #if defined (Q_OS_WIN32)
130  QWidget *_title_widget;
131  QToolButton *_dock_button;
132  QToolButton *_close_button;
133  QAction *_dock_action;
134  QAction *_close_action;
135 #endif
136 
137 };
138 
139 #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)
i e
Definition: data.cc:2724
octave_dock_widget(QWidget *p=0)
virtual void pasteClipboard()
QMainWindow * main_win()
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 ~octave_dock_widget(void)
virtual void notice_settings(const QSettings *)
p
Definition: lu.cc:138
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)