GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
octave-dock-widget.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2012-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_octave_dock_widget_h)
27 #define octave_octave_dock_widget_h 1
28 
29 #include <QDockWidget>
30 #include <QIcon>
31 #include <QMainWindow>
32 #include <QMouseEvent>
33 #include <QToolButton>
34 
35 #include "gui-settings.h"
36 #include "qt-interpreter-events.h"
37 
38 namespace octave
39 {
40  class base_qobject;
41 
42  // The few decoration items common to both main window and variable editor.
43 
45  {
46  Q_OBJECT
47 
48  public:
49 
50  label_dock_widget (QWidget *p, base_qobject& oct_qobj);
51 
52  // set_title() uses the custom title bar while setWindowTitle() uses
53  // the default title bar (with style sheets)
54  void set_title (const QString&);
55 
56  protected slots:
57 
58  //! Slots to handle copy & paste.
59  //!@{
60  virtual void copyClipboard (void) { }
61  virtual void pasteClipboard (void) { }
62  virtual void selectAll (void) { }
63  //!@}
64 
65  //! Slot to handle undo.
66 
67  virtual void do_undo (void) { }
68 
69  protected:
70 
72 
77  QAction *m_dock_action;
78  QAction *m_close_action;
79 
80  QAbstractButton *m_default_float_button;
81  QAbstractButton *m_default_close_button;
82  };
83 
85  {
86  Q_OBJECT
87 
88  public:
89 
90  octave_dock_widget (const QString& obj_name, QWidget *p,
91  base_qobject& oct_qobj);
92 
93  virtual ~octave_dock_widget (void) = default;
94 
95  virtual void connect_visibility_changed (void);
96 
97  void set_predecessor_widget (octave_dock_widget *prev_widget);
98 
99  signals:
100 
101  //! Custom signal that tells whether a user has clicked away that dock
102  //! widget, i.e. the active dock widget has changed.
103 
104  void active_changed (bool active);
105 
106  void queue_make_window (bool widget_was_dragged);
107 
108  void queue_make_widget (void);
109 
110  void interpreter_event (const fcn_callback& fcn);
111  void interpreter_event (const meth_callback& meth);
112 
113  protected:
114 
115  virtual void closeEvent (QCloseEvent *e);
116 
117  QWidget * focusWidget (void);
118 
119  bool event (QEvent *event);
120 
121  public slots:
122 
123  virtual void activate (void);
124 
125  virtual void handle_visibility (bool visible);
126 
127  virtual void notice_settings (const gui_settings *) { }
128 
129  void handle_settings (const gui_settings *);
130 
132 
133  QMainWindow * main_win (void) { return m_parent; }
134 
135  void save_settings (void);
136 
137  void moveEvent (QMoveEvent *event);
138 
139  void resizeEvent (QResizeEvent *event);
140 
141  void make_window (bool widget_was_dragged = false);
142 
143  void make_widget (bool not_used = false);
144 
145  void default_dock (bool not_used = false);
146 
147  protected slots:
148 
149  virtual void toplevel_change (bool);
150 
151  //! Slot to steer changing visibility from outside.
152 
153  virtual void handle_visibility_changed (bool visible)
154  {
155  if (visible)
156  emit active_changed (true);
157  }
158 
159  //! Event filter for double clicks into the window decoration elements.
160 
161  bool eventFilter (QObject *obj, QEvent *e);
162 
163  private slots:
164 
165  void change_visibility (bool);
166 
167  private:
168 
169  void set_style (bool active);
170  void set_focus_predecessor (void);
171  void store_geometry (void);
172 
173  //! Stores the parent, since we are reparenting to 0.
174 
176 
179  QColor m_bg_color;
181  QColor m_fg_color;
183  QString m_icon_color;
189 
190  };
191 }
192 
193 #endif
Base class for Octave interfaces that use Qt.
QAbstractButton * m_default_close_button
QAbstractButton * m_default_float_button
virtual void selectAll(void)
Slots to handle copy & paste.
label_dock_widget(QWidget *p, base_qobject &oct_qobj)
virtual void copyClipboard(void)
Slots to handle copy & paste.
virtual void do_undo(void)
Slot to handle undo.
virtual void pasteClipboard(void)
Slots to handle copy & paste.
void set_title(const QString &)
void queue_make_window(bool widget_was_dragged)
void handle_settings(const gui_settings *)
void handle_active_dock_changed(octave_dock_widget *, octave_dock_widget *)
void interpreter_event(const meth_callback &meth)
QMainWindow * m_parent
Stores the parent, since we are reparenting to 0.
void make_window(bool widget_was_dragged=false)
octave_dock_widget * m_predecessor_widget
bool eventFilter(QObject *obj, QEvent *e)
Event filter for double clicks into the window decoration elements.
virtual void toplevel_change(bool)
void make_widget(bool not_used=false)
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.
virtual void handle_visibility_changed(bool visible)
Slot to steer changing visibility from outside.
void resizeEvent(QResizeEvent *event)
void moveEvent(QMoveEvent *event)
virtual void closeEvent(QCloseEvent *e)
QMainWindow * main_win(void)
virtual ~octave_dock_widget(void)=default
void interpreter_event(const fcn_callback &fcn)
octave_dock_widget(const QString &obj_name, QWidget *p, base_qobject &oct_qobj)
virtual void handle_visibility(bool visible)
void default_dock(bool not_used=false)
virtual void connect_visibility_changed(void)
virtual void notice_settings(const gui_settings *)
std::function< void(octave::interpreter &)> meth_callback
Definition: event-manager.h:47
std::function< void(void)> fcn_callback
Definition: event-manager.h:46