GNU Octave  8.1.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-2023 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 <QMouseEvent>
32 #include <QToolButton>
33 
34 #include "gui-settings.h"
35 #include "qt-interpreter-events.h"
36 
38 
39 class base_qobject;
40 class main_window;
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  ~label_dock_widget (void) = default;
53 
54  // set_title() uses the custom title bar while setWindowTitle() uses
55  // the default title bar (with style sheets)
56  void set_title (const QString&);
57 
58 protected slots:
59 
60  //! Slots to handle copy & paste.
61  //!@{
62  virtual void copyClipboard (void) { }
63  virtual void pasteClipboard (void) { }
64  virtual void selectAll (void) { }
65  //!@}
66 
67  //! Slot to handle undo.
68 
69  virtual void do_undo (void) { }
70 
71 protected:
72 
74 
79  QAction *m_dock_action;
80  QAction *m_close_action;
81 
82  QAbstractButton *m_default_float_button;
83  QAbstractButton *m_default_close_button;
84 };
85 
87 {
88  Q_OBJECT
89 
90 public:
91 
92  octave_dock_widget (const QString& obj_name, QWidget *p,
93  base_qobject& oct_qobj);
94 
95  ~octave_dock_widget (void) = default;
96 
97  void set_predecessor_widget (octave_dock_widget *prev_widget);
98 
99  void set_main_window (main_window *mw);
100 
101  void set_adopted (bool adopted = true) { m_adopted = adopted; }
102  bool adopted (void) const { return m_adopted; }
103 
104 signals:
105 
106  //! Custom signal that tells whether a user has clicked away that dock
107  //! widget, i.e. the active dock widget has changed.
108 
109  void active_changed (bool active);
110 
111  void queue_make_window (bool widget_was_dragged);
112 
113  void queue_make_widget (void);
114 
115 protected:
116 
117  virtual void closeEvent (QCloseEvent *e);
118 
119  QWidget * focusWidget (void);
120 
121  bool event (QEvent *event);
122 
123 public slots:
124 
125  virtual void activate (void);
126 
127  virtual void handle_visibility (bool visible);
128 
129  virtual void notice_settings (const gui_settings *) { }
130 
131  virtual void save_settings (void);
132 
133  void init_window_menu_entry (void);
134 
135  void handle_settings (const gui_settings *);
136 
138 
139  void moveEvent (QMoveEvent *event);
140 
141  void resizeEvent (QResizeEvent *event);
142 
143  void make_window (bool widget_was_dragged = false);
144 
145  void make_widget (bool not_used = false);
146 
147  void default_dock (bool not_used = false);
148 
149 protected slots:
150 
151  virtual void toplevel_change (bool);
152 
153  //! Event filter for double clicks into the window decoration elements.
154 
155  bool eventFilter (QObject *obj, QEvent *e);
156 
157 private slots:
158 
159  void change_visibility (bool);
160 
161 private:
162 
163  void set_style (bool active);
164  void set_focus_predecessor (void);
165  void store_geometry (void);
166 
167  //! Stores the parent, since we are reparenting to 0.
168 
170 
171  bool m_adopted;
175  QColor m_bg_color;
177  QColor m_fg_color;
179  QString m_icon_color;
185 };
186 
188 
189 #endif
OCTAVE_END_NAMESPACE(octave)
Base class for Octave interfaces that use Qt.
base_qobject & m_octave_qobj
virtual void pasteClipboard(void)
Slots to handle copy & paste.
void set_title(const QString &)
virtual void copyClipboard(void)
Slots to handle copy & paste.
~label_dock_widget(void)=default
label_dock_widget(QWidget *p, base_qobject &oct_qobj)
QAbstractButton * m_default_float_button
QToolButton * m_dock_button
virtual void do_undo(void)
Slot to handle undo.
virtual void selectAll(void)
Slots to handle copy & paste.
QAbstractButton * m_default_close_button
QToolButton * m_close_button
Represents the main window.
Definition: main-window.h:73
void queue_make_window(bool widget_was_dragged)
virtual void notice_settings(const gui_settings *)
bool eventFilter(QObject *obj, QEvent *e)
Event filter for double clicks into the window decoration elements.
void handle_settings(const gui_settings *)
bool event(QEvent *event)
void init_window_menu_entry(void)
~octave_dock_widget(void)=default
virtual void handle_visibility(bool visible)
octave_dock_widget * m_predecessor_widget
virtual void save_settings(void)
void queue_make_widget(void)
void default_dock(bool not_used=false)
void handle_active_dock_changed(octave_dock_widget *, octave_dock_widget *)
void set_predecessor_widget(octave_dock_widget *prev_widget)
virtual void toplevel_change(bool)
bool adopted(void) const
main_window * m_main_window
Stores the parent, since we are reparenting to 0.
QWidget * focusWidget(void)
void set_focus_predecessor(void)
void moveEvent(QMoveEvent *event)
octave_dock_widget(const QString &obj_name, QWidget *p, base_qobject &oct_qobj)
void set_style(bool active)
void set_adopted(bool adopted=true)
void resizeEvent(QResizeEvent *event)
void set_main_window(main_window *mw)
virtual void closeEvent(QCloseEvent *e)
void make_window(bool widget_was_dragged=false)
void make_widget(bool not_used=false)
void active_changed(bool active)
Custom signal that tells whether a user has clicked away that dock widget, i.e.
virtual void activate(void)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn