CFx SDK Documentation  2020SP3
FxUIObject.h
Go to the documentation of this file.
1 //
2 // (C) Copyright 2005-2020 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/QFile>
24 #include <QtCore/QList>
25 #include <QtCore/QMap>
26 #include <QtCore/QString>
27 #include <QtCore/QUuid>
28 #include <QtCore/QVariant>
29 #include <QtCore/QVector>
30 #include <QtGui/QPalette>
31 #include <QtGui/QValidator>
32 #if !defined( XENON )
33 #include <QtGui/QIcon>
34 #include <QtGui/QPixmap>
35 #endif
36 
37 using CFxUIBuffer = QBuffer;
38 using CFxUIByteArray = QByteArray;
39 using CFxUIByteArrayList = QByteArrayList;
40 using CFxUIFile = QFile;
41 template<typename T>
42 using CFxUIList = QList<T>;
43 using CFxUIPainter = QPainter;
44 using CFxUIPalette = QPalette;
45 using CFxUISize = QSize;
46 using CFxUIString = QString;
47 using CFxUIStringList = QStringList;
48 using CFxUIUuid = QUuid;
49 using CFxUIValidator = QValidator;
50 using CFxUIVariant = QVariant;
51 template< typename K, typename V >
53 template< typename T >
54 using CFxUIVector = QVector<T>;
55 #if defined(XENON)
56 #include <Wt/WLink>
57 using CFxUIIcon = Wt::WLink;
58 using CFxUIPixmap = Wt::WLink;
59 #else
60 using CFxUIIcon = QIcon;
61 using CFxUIPixmap = QPixmap;
62 #endif
63 
64 #if defined( Q_OS_IOS )
65  typedef void* FxNativeHandle;
66 #elif defined( ANDROID )
67  #include <jni.h>
68  #include "../../../DDKERNEL/touch/FxJavaUtils.h"
69  typedef CFxJavaHandle* FxNativeHandle;
70 #else
71  #if defined(XENON)
72 #ifdef emit
73 #undef emit
74 #define FX_REDEFINE_EMIT
75 #endif
76 #ifdef slots
77 #undef slots
78 #define FX_REDEFINE_SLOTS
79 #endif
80  #include <Wt/WObject>
81  typedef Wt::WObject* FxNativeHandle;
82 #ifdef FX_REDEFINE_EMIT
83 #define emit
84 #endif
85 #ifdef FX_REDEFINE_SLOTS
86 #define slots
87 #endif
88  #else
89  typedef QObject* FxNativeHandle;
90  #endif
91 #endif
92 
93 class CFxUIObjectImpl;
94 class CFxUIObjectData;
95 class CFxUIEmitScope;
96 
101 {
102  friend CFxUIObjectData;
103  friend CFxUIEmitScope;
104 public:
105 
108 
110  virtual ~CFxUIObject();
111 
120 
126  void setHandle( FxNativeHandle handle );
127 
133  void setParent( CFxUIObject* parent );
134 
141 
147  const CFxUIObject* parent() const;
148 
154  void setObjectName( const CFxUIString& objectName );
155 
162 
170  bool setProperty( const char* name, const CFxUIVariant& value );
171 
179  CFxUIVariant property( const char* name );
180 
187 
195  template<typename T>
197  {
198  CFxUIList<T> result;
199 
200  CFxUIList<CFxUIObject*> allChildren = children();
201  for ( CFxUIObject* child : allChildren )
202  {
203  if ( T obj = dynamic_cast<T>( child ) )
204  {
205  if ( !name.isEmpty() )
206  {
207  if ( name == obj->objectName() )
208  result.push_back( obj );
209  }
210  else
211  result.push_back( obj );
212  }
213  }
214 
215  return result;
216  }
217 
223  void blockSignals( bool block );
224 
230  bool signalsBlocked() const;
231 
232 protected:
239 
240 private:
246  void setSender( CFxUIObject* pSender );
247 
248 protected:
249  CFxUIObjectImpl* m_pImpl;
250  CFxUIObjectData* m_pData;
251 
252  //...
253 };
CFxUIByteArrayList
QByteArrayList CFxUIByteArrayList
Definition: FxUIObject.h:39
name
GLuint const GLchar * name
Definition: gles2_ext.h:265
CFxUIByteArray
QByteArray CFxUIByteArray
Definition: FxUIObject.h:38
CFxUIUuid
QUuid CFxUIUuid
Definition: FxUIObject.h:48
CFxUIObject::getHandle
FxNativeHandle getHandle() const
CFxUIVariant
QVariant CFxUIVariant
Definition: FxUIObject.h:50
CFxUIIcon
QIcon CFxUIIcon
Definition: FxUIObject.h:60
CFxUIObject::sender
CFxUIObject * sender()
CFxUIList
QList< T > CFxUIList
Definition: FxUIObject.h:42
CFxUIVector
QVector< T > CFxUIVector
Definition: FxUIObject.h:54
CFxUIPainter
QPainter CFxUIPainter
Definition: FxUIObject.h:43
CFxUIValidator
QValidator CFxUIValidator
Definition: FxUIObject.h:49
CFxUIObject::parent
CFxUIObject * parent()
CFxUIObject::signalsBlocked
bool signalsBlocked() const
CFxUIObject::parent
const CFxUIObject * parent() const
CFxUIObject::property
CFxUIVariant property(const char *name)
CFxUIObject::m_pData
CFxUIObjectData * m_pData
Definition: FxUIObject.h:250
CFxUIObject::~CFxUIObject
virtual ~CFxUIObject()
CFxUIObject::setObjectName
void setObjectName(const CFxUIString &objectName)
CFxUISize
QSize CFxUISize
Definition: FxUIObject.h:45
CFxUIObject::objectName
CFxUIString objectName() const
CFxUIStringList
QStringList CFxUIStringList
Definition: FxUIObject.h:47
CFxUIObject::m_pImpl
CFxUIObjectImpl * m_pImpl
Definition: FxUIObject.h:249
CFxUIObject::children
CFxUIList< CFxUIObject * > children() const
CFxUIString
QString CFxUIString
Definition: FxUIObject.h:46
FxNativeHandle
QObject * FxNativeHandle
Definition: FxUIObject.h:89
COMMONUI_API
#define COMMONUI_API
Definition: FxCommonFramework.h:4
CFxUIObject::findChildren
CFxUIList< T > findChildren(const CFxUIString &name=CFxUIString())
Definition: FxUIObject.h:196
CFxUIEmitScope
Definition: FxUISignal.h:28
CFxUIPalette
QPalette CFxUIPalette
Definition: FxUIObject.h:44
CFxUIObject::setProperty
bool setProperty(const char *name, const CFxUIVariant &value)
CFxUIBuffer
QBuffer CFxUIBuffer
Definition: FxUIObject.h:37
value
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
CFxUIObject::setParent
void setParent(CFxUIObject *parent)
CFxUIPixmap
QPixmap CFxUIPixmap
Definition: FxUIObject.h:61
CFxUIObject::blockSignals
void blockSignals(bool block)
QMap
Definition: FxFileData.h:28
CFxUIObject::CFxUIObject
CFxUIObject()
CFxUIObject::setHandle
void setHandle(FxNativeHandle handle)
CFxUIObject
Definition: FxUIObject.h:101
CFxUIFile
QFile CFxUIFile
Definition: FxUIObject.h:40