CFx SDK Documentation  2023 SP0
FxUIObject.h
Go to the documentation of this file.
1 //
2 // (C) Copyright 2005-2022 by Graebert GmbH.
3 //
4 // Permission to use, copy, modify, and distribute this software in
5 // object code form for any purpose and without fee is hereby granted,
6 // provided that the above copyright notice appears in all copies and
7 // that both that copyright notice and the limited warranty and
8 // restricted rights notice below appear in all supporting
9 // documentation.
10 //
11 // GRAEBERT PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
12 // GRAEBERT SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
13 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. GRAEBERT GMBH
14 // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
15 // UNINTERRUPTED OR ERROR FREE.
16 
17 #pragma once
18 
19 #include "../FxCommonFramework.h"
20 
21 #include <QtCore/QBuffer>
22 #include <QtCore/QByteArray>
23 #include <QtCore/QDate>
24 #include <QtCore/QFile>
25 #include <QtCore/QList>
26 #include <QtCore/QMap>
27 #include <QtCore/QString>
28 #include <QtCore/QUuid>
29 #include <QtCore/QVariant>
30 #include <QtCore/QVector>
31 #include <QtGui/QPalette>
32 #include <QtGui/QValidator>
33 #if !defined( XENON )
34 #include <QtGui/QIcon>
35 #include <QtGui/QPixmap>
36 #endif
37 
38 using CFxUIBuffer = QBuffer;
39 using CFxUIByteArray = QByteArray;
40 using CFxUIByteArrayList = QByteArrayList;
41 using CFxUIDate = QDate;
42 using CFxUIFile = QFile;
43 template<typename T>
44 using CFxUIList = QList<T>;
45 using CFxUIPainter = QPainter;
46 using CFxUIPalette = QPalette;
47 using CFxUISize = QSize;
48 using CFxUIString = QString;
49 using CFxUIStringList = QStringList;
50 using CFxUIUuid = QUuid;
51 using CFxUIValidator = QValidator;
52 using CFxUIVariant = QVariant;
53 template< typename K, typename V >
55 template< typename T >
56 using CFxUIVector = QVector<T>;
57 #if defined(XENON)
58 #include <Wt/WLink>
59 using CFxUIIcon = Wt::WLink;
60 using CFxUIPixmap = Wt::WLink;
61 #else
62 using CFxUIIcon = QIcon;
63 using CFxUIPixmap = QPixmap;
64 #endif
65 
66 #if defined( Q_OS_IOS )
67  typedef void* FxNativeHandle;
68 #elif defined( ANDROID )
69  #include <jni.h>
70  #include "../../../Kernel/DDKERNEL/touch/FxJavaUtils.h"
71  typedef CFxJavaHandle* FxNativeHandle;
72 #else
73  #if defined(XENON)
74 #ifdef emit
75 #undef emit
76 #define FX_REDEFINE_EMIT
77 #endif
78 #ifdef slots
79 #undef slots
80 #define FX_REDEFINE_SLOTS
81 #endif
82  #include <Wt/WObject>
83  typedef Wt::WObject* FxNativeHandle;
84 #ifdef FX_REDEFINE_EMIT
85 #define emit
86 #endif
87 #ifdef FX_REDEFINE_SLOTS
88 #define slots
89 #endif
90  #else
91  typedef QObject* FxNativeHandle;
92  #endif
93 #endif
94 
95 class CFxUIObjectImpl;
96 class CFxUIObjectData;
97 class CFxUIEmitScope;
98 
103 {
104  friend CFxUIObjectData;
105  friend CFxUIEmitScope;
106 public:
107 
110 
112  virtual ~CFxUIObject();
113 
122 
128  void setHandle( FxNativeHandle handle );
129 
135  void setParent( CFxUIObject* parent );
136 
143 
149  const CFxUIObject* parent() const;
150 
156  void setObjectName( const CFxUIString& objectName );
157 
164 
172  bool setProperty( const char* name, const CFxUIVariant& value );
173 
181  CFxUIVariant property( const char* name );
182 
189 
197  template<typename T>
199  {
200  CFxUIList<T> result;
201 
202  CFxUIList<CFxUIObject*> allChildren = children();
203  for ( CFxUIObject* child : allChildren )
204  {
205  if ( T obj = dynamic_cast<T>( child ) )
206  {
207  if ( !name.isEmpty() )
208  {
209  if ( name == obj->objectName() )
210  result.push_back( obj );
211  }
212  else
213  result.push_back( obj );
214  }
215  }
216 
217  return result;
218  }
219 
225  void blockSignals( bool block );
226 
232  bool signalsBlocked() const;
233 
234 protected:
241 
242 private:
248  void setSender( CFxUIObject* pSender );
249 
250 protected:
251  CFxUIObjectImpl* m_pImpl;
252  CFxUIObjectData* m_pData;
253 
254  //...
255 };
#define COMMONUI_API
QUuid CFxUIUuid
Definition: FxUIObject.h:50
QByteArrayList CFxUIByteArrayList
Definition: FxUIObject.h:40
QList< T > CFxUIList
Definition: FxUIObject.h:44
QStringList CFxUIStringList
Definition: FxUIObject.h:49
QString CFxUIString
Definition: FxUIObject.h:48
QDate CFxUIDate
Definition: FxUIObject.h:41
QValidator CFxUIValidator
Definition: FxUIObject.h:51
QIcon CFxUIIcon
Definition: FxUIObject.h:62
QPalette CFxUIPalette
Definition: FxUIObject.h:46
QByteArray CFxUIByteArray
Definition: FxUIObject.h:39
QVector< T > CFxUIVector
Definition: FxUIObject.h:56
QFile CFxUIFile
Definition: FxUIObject.h:42
QPixmap CFxUIPixmap
Definition: FxUIObject.h:63
QVariant CFxUIVariant
Definition: FxUIObject.h:52
QBuffer CFxUIBuffer
Definition: FxUIObject.h:38
QObject * FxNativeHandle
Definition: FxUIObject.h:91
QPainter CFxUIPainter
Definition: FxUIObject.h:45
QSize CFxUISize
Definition: FxUIObject.h:47
CFxUIString objectName() const
CFxUIObjectData * m_pData
Definition: FxUIObject.h:252
CFxUIObjectImpl * m_pImpl
Definition: FxUIObject.h:251
const CFxUIObject * parent() const
CFxUIVariant property(const char *name)
void setParent(CFxUIObject *parent)
virtual ~CFxUIObject()
bool setProperty(const char *name, const CFxUIVariant &value)
FxNativeHandle getHandle() const
CFxUIList< CFxUIObject * > children() const
void setHandle(FxNativeHandle handle)
void blockSignals(bool block)
bool signalsBlocked() const
CFxUIObject * parent()
CFxUIList< T > findChildren(const CFxUIString &name=CFxUIString())
Definition: FxUIObject.h:198
void setObjectName(const CFxUIString &objectName)
CFxUIObject * sender()
GLuint const GLchar * name
Definition: gles2_ext.h:265
GLsizei const GLfloat * value
Definition: gles2_ext.h:302