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
Object.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2015 Michael Goffioul
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 #ifndef __QtHandles_Object__
24 #define __QtHandles_Object__ 1
25 
26 #include <QObject>
27 
28 #include "graphics.h"
29 
30 class QObject;
31 class QString;
32 class QWidget;
33 
34 namespace QtHandles
35 {
36 
37 class Container;
38 class ObjectProxy;
39 
40 class Object : public QObject
41 {
42  Q_OBJECT
43 
44 public:
45  Object (const graphics_object& go, QObject* obj = 0);
46 
47  virtual ~Object (void);
48 
50  { return object ().get_properties (); }
51 
52  const base_properties& properties (void) const
53  { return object ().get_properties (); }
54 
55  template <class T>
56  typename T::properties& properties (void)
57  {
58  return dynamic_cast<typename T::properties&>
59  (object ().get_properties ());
60  }
61 
62  template <class T>
63  const typename T::properties& properties (void) const
64  {
65  return dynamic_cast<const typename T::properties&>
66  (object ().get_properties ());
67  }
68 
69  graphics_object object (void) const;
70 
71  virtual QObject* qObject (void) { return m_qobject; }
72 
73  template <class T>
74  T* qWidget (void) { return qobject_cast<T*>(qObject ()); }
75 
76  virtual Container* innerContainer (void) = 0;
77 
78  static Object* fromQObject (QObject* obj);
79 
80 public slots:
81  void slotUpdate (int pId);
82  void slotFinalize (void);
83  void slotRedraw (void);
84  void slotPrint (const QString& file_cmd, const QString& term);
85 
86  void objectDestroyed (QObject *obj = 0);
87 
88 protected:
89  static Object* parentObject (const graphics_object& go);
90  void init (QObject* obj, bool callBase = false);
91 
92  virtual void update (int pId);
93  virtual void finalize (void);
94  virtual void redraw (void);
95  virtual void print (const QString& file_cmd, const QString& term);
96 
97  virtual void beingDeleted (void);
98 
99 protected:
102 };
103 
104 }; // namespace QtHandles
105 
106 #endif
const base_properties & properties(void) const
Definition: Object.h:52
virtual void redraw(void)
Definition: Object.cc:149
T::properties & properties(void)
Definition: Object.h:56
void slotUpdate(int pId)
Definition: Object.cc:86
static Object * parentObject(const graphics_object &go)
Definition: Object.cc:170
virtual Container * innerContainer(void)=0
const T::properties & properties(void) const
Definition: Object.h:63
void slotFinalize(void)
Definition: Object.cc:107
virtual ~Object(void)
Definition: Object.cc:68
void slotRedraw(void)
Definition: Object.cc:115
void init(QObject *obj, bool callBase=false)
Definition: Object.cc:51
graphics_handle m_handle
Definition: Object.h:100
T * qWidget(void)
Definition: Object.h:74
static Object * fromQObject(QObject *obj)
Definition: Object.cc:181
virtual void beingDeleted(void)
Definition: Object.cc:159
base_properties & get_properties(void)
Definition: graphics.h:3377
QObject * m_qobject
Definition: Object.h:101
virtual QObject * qObject(void)
Definition: Object.h:71
Object(const graphics_object &go, QObject *obj=0)
Definition: Object.cc:37
graphics_object object(void) const
Definition: Object.cc:73
virtual void finalize(void)
Definition: Object.cc:138
virtual void update(int pId)
Definition: Object.cc:133
virtual void print(const QString &file_cmd, const QString &term)
Definition: Object.cc:154
void objectDestroyed(QObject *obj=0)
Definition: Object.cc:163
void slotPrint(const QString &file_cmd, const QString &term)
Definition: Object.cc:124
base_properties & properties(void)
Definition: Object.h:49
T::properties & properties(graphics_object obj)