CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
ExtBar.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23// Extensions Bar
24
25#ifndef OD_TR_EXTBAR_H_
26#define OD_TR_EXTBAR_H_
27
28#include "TD_PackPush.h"
29
30#include "OdString.h"
31#include <limits.h>
32#include <float.h>
33
34class ElementImplIface;
35
36class ExtBar
37{
38 public:
39 // System definitions
40#ifdef WIN32
41 struct WinSysHandle
42 {
43 HWND hOwner;
44 HINSTANCE hInstance;
45 };
46 typedef WinSysHandle *SysHandle;
47 typedef RECT Rect;
48 typedef SIZE Size;
49 typedef POINT Point;
50#else
51 typedef void *SysHandle;
52 struct Rect
53 {
54 long left;
55 long top;
56 long right;
57 long bottom;
58 };
59 struct Size
60 {
61 long cx;
62 long cy;
63 };
64 struct Point
65 {
66 long x;
67 long y;
68 };
69#endif
70 // Element types
72 {
73 kGroup = 0,
74 kText, // interfaces: [kText | kEditBox] | kColorButton
75 kButton, // interfaces: [kText | kEditBox]
76 kCheckButton, // interfaces: [kText | kEditBox] | [kCheckButton | kCheckBox | kRadioButton]
77 kColorButton, // interfaces: [kText | kEditBox] | kColorButton
78 kCheckBox, // interfaces: [kText | kEditBox] | [kCheckButton | kCheckBox | kRadioButton]
79 kRadioGroup, // interfaces: kRadioGroup
80 kRadioButton, // interfaces: [kText | kEditBox] | [kCheckButton | kCheckBox | kRadioButton] | kRadioGroup
81 kPlaceholder, // interfaces: NULL
82 kComboBox, // interfaces: [kComboBox | kListBox]
83 kListBox, // interfaces: [kComboBox | kListBox]
84 kEditBox, // interfaces: [kText | kEditBox]
85 kRangeBox // interfaces: [kText | kEditBox] | kRangeBox
86 };
87 // Element sizes
89 {
90 k8d8 = 8,
91 k6d8 = 6,
92 k4d8 = 4,
93 k2d8 = 2,
94 k1d8 = 1
95 };
96 // Element interfaces
97 struct Element
98 {
99 virtual ~Element() {}
100 virtual OdUInt32 elementId() const = 0;
101 virtual ElementType elementType() const = 0;
103 virtual void setDisabled(bool bDisable) = 0;
104 virtual bool isDisabled() const = 0;
105 virtual ElementImplIface *getImpl() const = 0;
106 virtual void attachSomeData(void *pData) = 0;
107 virtual void* getAttachedData() const = 0;
108 };
109 struct TextElement : public Element
110 {
111 virtual OdString getText() const = 0;
112 virtual void setText(const OdString &text) = 0;
113 static TextElement *cast(Element *pIface) { return static_cast<TextElement*>(pIface->elementInterface(kText)); }
114 };
115 struct GroupElement : public Element
116 {
117 virtual bool isLayoutGroup() const = 0;
118 virtual bool isExpandeable() const = 0;
119 virtual void setExpanded(bool bExpand) = 0;
120 virtual bool isExpanded() const = 0;
121 virtual OdUInt32 getNumElements() const = 0;
122 virtual Element *getElement(OdUInt32 nElement) const = 0;
123 static GroupElement *cast(Element *pIface) { return static_cast<GroupElement*>(pIface->elementInterface(kGroup)); }
124 };
125 struct CheckElement : public Element
126 {
127 virtual bool isChecked() const = 0;
128 virtual void setChecked(bool bCheck) = 0;
129 static CheckElement *cast(Element *pIface) { return static_cast<CheckElement*>(pIface->elementInterface(kCheckBox)); }
130 };
131 struct RadioElement : public Element
132 {
133 virtual OdUInt32 checkedElement() const = 0;
134 virtual void setCheckedElement(OdUInt32 nElement) = 0;
135 static RadioElement *cast(Element *pIface) { return static_cast<RadioElement*>(pIface->elementInterface(kRadioGroup)); }
136 };
137 struct ListElement : public Element
138 {
139 virtual void addString(const OdString &string) = 0;
140 virtual void clear() = 0;
141 virtual OdUInt32 getNumStrings() const = 0;
142 virtual OdString getString(OdUInt32 nString) const = 0;
143 virtual int getSelString() const = 0;
144 virtual void setSelString(int nString) = 0;
145 virtual void delString(OdUInt32 nString) = 0;
146 virtual void insString(int nWhere, const OdString &string) = 0;
147 static ListElement *cast(Element *pIface) { return static_cast<ListElement*>(pIface->elementInterface(kListBox)); }
148 };
149 struct ColorElement : public Element
150 {
151 virtual ODCOLORREF getColor() const = 0;
152 virtual void setColor(ODCOLORREF color) = 0;
153 static ColorElement *cast(Element *pIface) { return static_cast<ColorElement*>(pIface->elementInterface(kColorButton)); }
154 };
155 struct RangeElement : public Element
156 {
157 virtual OdInt32 getRangeMinInt() const = 0;
158 virtual OdInt32 getRangeMaxInt() const = 0;
159 virtual void setRangeInt(OdInt32 nMin, OdInt32 nMax) = 0;
160 virtual OdInt32 getDeltaInt() const = 0;
161 virtual void setDeltaInt(OdInt32 nDelta) = 0;
162 virtual OdInt32 getPosInt() const = 0;
163 virtual void setPosInt(OdInt32 nPos) = 0;
164 virtual void setInt(OdInt32 nPos = 0, OdInt32 nMin = INT_MIN, OdInt32 nMax = INT_MAX, OdInt32 nDelta = 1) = 0;
165
166 virtual OdUInt32 getRangeMinUInt() const = 0;
167 virtual OdUInt32 getRangeMaxUInt() const = 0;
168 virtual void setRangeUInt(OdUInt32 nMin, OdUInt32 nMax) = 0;
169 virtual OdUInt32 getPosUInt() const = 0;
170 virtual void setPosUInt(OdUInt32 nPos) = 0;
171 virtual void setUInt(OdUInt32 nPos = 0, OdUInt32 nMin = 0, OdUInt32 nMax = UINT_MAX, OdInt32 nDelta = 1) = 0;
172
173 virtual double getRangeMinFP() const = 0;
174 virtual double getRangeMaxFP() const = 0;
175 virtual void setRangeFP(double fMin, double fMax) = 0;
176 virtual double getDeltaFP() const = 0;
177 virtual void setDeltaFP(double fDelta) = 0;
178 virtual double getPosFP() const = 0;
179 virtual void setPosFP(double fPos) = 0;
180 virtual void setFP(double fPos = 0.0, double fMin = DBL_MIN, double fMax = DBL_MAX, double fDelta = 0.01) = 0;
181
182 virtual bool isFP() const = 0;
183 virtual void setFP(bool bFP) = 0;
184 virtual bool isSigned() const = 0;
185 virtual void setSigned(bool bSigned) = 0;
186 static RangeElement *cast(Element *pIface) { return static_cast<RangeElement*>(pIface->elementInterface(kRangeBox)); }
187 };
188 // Main callback function
189 struct Callback
190 {
191 virtual void fillExtBar(ExtBar * /*pExtBar*/) {}
192 virtual void closeExtBar(ExtBar * /*pExtBar*/, int /*nReason*/) {}
193 virtual void elementChanged(Element *pElem) = 0;
194 };
195 // Inplace callback function
196 struct InplaceCallback : public Callback
197 {
198 virtual bool canCloseInplace(ExtBar * /*pInplace*/) { return true; }
199 virtual void inplaceClosed(ExtBar * /*pInplace*/) { }
200 };
201 public:
204
205 virtual GroupElement *createGroup(OdUInt32 nElementId, bool bExpandeable = true, bool bExpanded = true) = 0;
206 virtual TextElement *createText(OdUInt32 nElementId, GroupElement *pGroup = NULL, ElementSize size = k8d8, OdUInt32 nStrings = 1, bool bBorder = false, ODCOLORREF color = ODRGB(0, 0, 0)) = 0;
207 virtual TextElement *createButton(OdUInt32 nElementId, GroupElement *pGroup = NULL, ElementSize size = k8d8) = 0;
208 virtual TextElement *createCheckButton(OdUInt32 nElementId, GroupElement *pGroup = NULL, ElementSize size = k8d8) = 0;
209 virtual ColorElement *createColorButton(OdUInt32 nElementId, GroupElement *pGroup = NULL, ElementSize size = k8d8) = 0;
210 virtual TextElement *createCheckBox(OdUInt32 nElementId, GroupElement *pGroup = NULL, ElementSize size = k8d8, bool bChecked = false, bool bLText = false) = 0;
211 virtual RadioElement *createRadioGroup(OdUInt32 nElementId, GroupElement *pGroup = NULL) = 0;
212 virtual TextElement *createRadioButton(OdUInt32 nElementId, RadioElement *pGroup, ElementSize size = k8d8, bool bChecked = false) = 0;
213 virtual void createPlaceholder(GroupElement *pGroup = NULL, ElementSize size = k8d8) = 0;
214 virtual ListElement *createComboBox(OdUInt32 nElementId, GroupElement *pGroup = NULL, OdUInt32 nOpenLines = 4) = 0;
215 virtual ListElement *createListBox(OdUInt32 nElementId, GroupElement *pGroup = NULL, OdUInt32 nStrings = 4) = 0;
216 virtual TextElement *createEditBox(OdUInt32 nElementId, GroupElement *pGroup = NULL, ElementSize size = k8d8, OdUInt32 nStrings = 1, bool bReadOnly = false, bool bMonitorTyping = false) = 0;
217 virtual RangeElement *createRangeBox(OdUInt32 nElementId, GroupElement *pGroup = NULL, ElementSize size = k8d8, bool bSigned = false, bool bFP = false) = 0;
218
219 virtual Element *getElement(OdUInt32 nElementId) const = 0;
220 virtual GroupElement *getLayoutGroup() const = 0;
221
222 virtual bool getColor(ODCOLORREF &color) const = 0;
223 virtual OdString getOpenFileName(const OdChar *pFilter, const OdChar *pDefExt) = 0;
224 virtual OdString getSaveFileName(const OdChar *pFilter, const OdChar *pDefExt) = 0;
225};
226
227// This is host interfaces. Non-abstract. Shouldn't be called from client code.
228
230{
231 public:
232 static ExtBar *createExtBar(ExtBar::Callback *pCallback = NULL);
234 static void destroyExtBar(ExtBar *pExtBar);
235};
236
238{
239 protected:
241 public:
242 ExtBarInterface(ExtBar *pExtBar = NULL) : m_pExtBar(pExtBar) {}
244
245 void create(ExtBar::SysHandle sysHandle);
246 void destroy(int nReason = 0);
247 void resize(const ExtBar::Rect &rect);
248
249 void update();
250 void clear();
251
253 ExtBar *extBar() { return m_pExtBar; }
254};
255
257{
258 public:
259 StaticExtBar(ExtBar::Callback *pCallback = NULL) : ExtBarInterface(createExtBar(pCallback)) { }
261};
262
264{
265 protected:
267 protected:
268 virtual void inplaceClosed(ExtBar * /*pInplace*/) { close(); }
270 void closeImpl();
271 public:
274
276 static ExtBar::Size makesize(int w, int h);
278
279 void display(ExtBar::SysHandle sysHandle, const ExtBar::Rect &rect)
280 {
281 if (m_pExtBar)
282 close();
284 create(sysHandle);
286 resize(rect);
287 fakewndproc();
288 }
289 void close(int nReason = 0)
290 {
291 if (m_pExtBar)
292 {
293 closeImpl();
294 destroy(nReason);
296 m_pExtBar = NULL;
297 }
298 }
299 bool isClosed() const { return !m_pExtBar; }
300
301 virtual void fillInplace(ExtBar * /*pExtBar*/)
302 {
303 // Do your own initialization here
304 }
305};
306
307#include "TD_PackPop.h"
308
309#endif // OD_TR_EXTBAR_H_
true
Definition: DimVarDefs.h:2046
#define ODRGB(r, g, b)
Definition: OdPlatform.h:934
#define ODCOLORREF
Definition: OdPlatform.h:933
unsigned int OdUInt32
int OdInt32
wchar_t OdChar
Definition: ExtBar.h:37
virtual OdString getOpenFileName(const OdChar *pFilter, const OdChar *pDefExt)=0
virtual TextElement * createEditBox(OdUInt32 nElementId, GroupElement *pGroup=NULL, ElementSize size=k8d8, OdUInt32 nStrings=1, bool bReadOnly=false, bool bMonitorTyping=false)=0
virtual TextElement * createButton(OdUInt32 nElementId, GroupElement *pGroup=NULL, ElementSize size=k8d8)=0
ExtBar()
Definition: ExtBar.h:202
virtual OdString getSaveFileName(const OdChar *pFilter, const OdChar *pDefExt)=0
virtual RangeElement * createRangeBox(OdUInt32 nElementId, GroupElement *pGroup=NULL, ElementSize size=k8d8, bool bSigned=false, bool bFP=false)=0
virtual ListElement * createListBox(OdUInt32 nElementId, GroupElement *pGroup=NULL, OdUInt32 nStrings=4)=0
virtual Element * getElement(OdUInt32 nElementId) const =0
virtual TextElement * createRadioButton(OdUInt32 nElementId, RadioElement *pGroup, ElementSize size=k8d8, bool bChecked=false)=0
virtual RadioElement * createRadioGroup(OdUInt32 nElementId, GroupElement *pGroup=NULL)=0
virtual ListElement * createComboBox(OdUInt32 nElementId, GroupElement *pGroup=NULL, OdUInt32 nOpenLines=4)=0
void * SysHandle
Definition: ExtBar.h:51
virtual TextElement * createText(OdUInt32 nElementId, GroupElement *pGroup=NULL, ElementSize size=k8d8, OdUInt32 nStrings=1, bool bBorder=false, ODCOLORREF color=ODRGB(0, 0, 0))=0
ElementSize
Definition: ExtBar.h:89
@ k6d8
Definition: ExtBar.h:91
@ k1d8
Definition: ExtBar.h:94
@ k2d8
Definition: ExtBar.h:93
@ k8d8
Definition: ExtBar.h:90
@ k4d8
Definition: ExtBar.h:92
virtual GroupElement * createGroup(OdUInt32 nElementId, bool bExpandeable=true, bool bExpanded=true)=0
virtual TextElement * createCheckBox(OdUInt32 nElementId, GroupElement *pGroup=NULL, ElementSize size=k8d8, bool bChecked=false, bool bLText=false)=0
virtual ColorElement * createColorButton(OdUInt32 nElementId, GroupElement *pGroup=NULL, ElementSize size=k8d8)=0
virtual TextElement * createCheckButton(OdUInt32 nElementId, GroupElement *pGroup=NULL, ElementSize size=k8d8)=0
ElementType
Definition: ExtBar.h:72
@ kComboBox
Definition: ExtBar.h:82
@ kButton
Definition: ExtBar.h:75
@ kEditBox
Definition: ExtBar.h:84
@ kText
Definition: ExtBar.h:74
@ kRadioButton
Definition: ExtBar.h:80
@ kPlaceholder
Definition: ExtBar.h:81
@ kColorButton
Definition: ExtBar.h:77
@ kRadioGroup
Definition: ExtBar.h:79
@ kListBox
Definition: ExtBar.h:83
@ kRangeBox
Definition: ExtBar.h:85
@ kCheckBox
Definition: ExtBar.h:78
@ kGroup
Definition: ExtBar.h:73
@ kCheckButton
Definition: ExtBar.h:76
virtual bool getColor(ODCOLORREF &color) const =0
virtual GroupElement * getLayoutGroup() const =0
virtual void createPlaceholder(GroupElement *pGroup=NULL, ElementSize size=k8d8)=0
~ExtBar()
Definition: ExtBar.h:203
virtual void inplaceClosed(ExtBar *)
Definition: ExtBar.h:268
static ExtBar::Point curpos()
void closeImpl()
virtual void fillInplace(ExtBar *)
Definition: ExtBar.h:301
void display(ExtBar::SysHandle sysHandle, const ExtBar::Rect &rect)
Definition: ExtBar.h:279
ExtBarInplace()
Definition: ExtBar.h:272
void close(int nReason=0)
Definition: ExtBar.h:289
static ExtBar::Size makesize(int w, int h)
void fakewndproc()
static ExtBar::Rect screenplace(const ExtBar::Point &pt, const ExtBar::Size &sz)
bool isClosed() const
Definition: ExtBar.h:299
~ExtBarInplace()
Definition: ExtBar.h:273
bool m_bDone
Definition: ExtBar.h:266
void destroy(int nReason=0)
void resize(const ExtBar::Rect &rect)
ExtBar * extBar()
Definition: ExtBar.h:253
void create(ExtBar::SysHandle sysHandle)
ExtBar * m_pExtBar
Definition: ExtBar.h:240
void resetCallback(ExtBar::Callback *pCallback)
~ExtBarInterface()
Definition: ExtBar.h:243
ExtBarInterface(ExtBar *pExtBar=NULL)
Definition: ExtBar.h:242
static void destroyExtBar(ExtBar *pExtBar)
static ExtBar * createExtBar(ExtBar::InplaceCallback *pCallback)
static ExtBar * createExtBar(ExtBar::Callback *pCallback=NULL)
StaticExtBar(ExtBar::Callback *pCallback=NULL)
Definition: ExtBar.h:259
~StaticExtBar()
Definition: ExtBar.h:260
GLfloat GLfloat GLfloat GLfloat w
Definition: gles2_ext.h:320
GLsizeiptr size
Definition: gles2_ext.h:182
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
virtual void fillExtBar(ExtBar *)
Definition: ExtBar.h:191
virtual void closeExtBar(ExtBar *, int)
Definition: ExtBar.h:192
virtual void elementChanged(Element *pElem)=0
static CheckElement * cast(Element *pIface)
Definition: ExtBar.h:129
virtual void setChecked(bool bCheck)=0
virtual bool isChecked() const =0
static ColorElement * cast(Element *pIface)
Definition: ExtBar.h:153
virtual void setColor(ODCOLORREF color)=0
virtual ODCOLORREF getColor() const =0
virtual void attachSomeData(void *pData)=0
virtual OdUInt32 elementId() const =0
virtual bool isDisabled() const =0
virtual void setDisabled(bool bDisable)=0
virtual Element * elementInterface(ElementType type)=0
virtual void * getAttachedData() const =0
virtual ElementType elementType() const =0
virtual ElementImplIface * getImpl() const =0
virtual ~Element()
Definition: ExtBar.h:99
virtual OdUInt32 getNumElements() const =0
virtual bool isExpanded() const =0
virtual void setExpanded(bool bExpand)=0
virtual bool isLayoutGroup() const =0
static GroupElement * cast(Element *pIface)
Definition: ExtBar.h:123
virtual Element * getElement(OdUInt32 nElement) const =0
virtual bool isExpandeable() const =0
virtual bool canCloseInplace(ExtBar *)
Definition: ExtBar.h:198
virtual void inplaceClosed(ExtBar *)
Definition: ExtBar.h:199
virtual void setSelString(int nString)=0
virtual int getSelString() const =0
virtual void insString(int nWhere, const OdString &string)=0
virtual OdString getString(OdUInt32 nString) const =0
virtual void clear()=0
virtual void delString(OdUInt32 nString)=0
virtual OdUInt32 getNumStrings() const =0
virtual void addString(const OdString &string)=0
static ListElement * cast(Element *pIface)
Definition: ExtBar.h:147
long x
Definition: ExtBar.h:66
long y
Definition: ExtBar.h:67
virtual OdUInt32 checkedElement() const =0
virtual void setCheckedElement(OdUInt32 nElement)=0
static RadioElement * cast(Element *pIface)
Definition: ExtBar.h:135
virtual void setFP(double fPos=0.0, double fMin=DBL_MIN, double fMax=DBL_MAX, double fDelta=0.01)=0
virtual OdUInt32 getRangeMaxUInt() const =0
virtual void setPosFP(double fPos)=0
virtual bool isSigned() const =0
virtual OdUInt32 getRangeMinUInt() const =0
virtual void setUInt(OdUInt32 nPos=0, OdUInt32 nMin=0, OdUInt32 nMax=UINT_MAX, OdInt32 nDelta=1)=0
virtual double getPosFP() const =0
virtual double getRangeMinFP() const =0
virtual void setInt(OdInt32 nPos=0, OdInt32 nMin=INT_MIN, OdInt32 nMax=INT_MAX, OdInt32 nDelta=1)=0
static RangeElement * cast(Element *pIface)
Definition: ExtBar.h:186
virtual void setSigned(bool bSigned)=0
virtual double getDeltaFP() const =0
virtual void setDeltaFP(double fDelta)=0
virtual OdInt32 getRangeMaxInt() const =0
virtual bool isFP() const =0
virtual OdInt32 getPosInt() const =0
virtual void setRangeInt(OdInt32 nMin, OdInt32 nMax)=0
virtual void setDeltaInt(OdInt32 nDelta)=0
virtual OdUInt32 getPosUInt() const =0
virtual void setPosInt(OdInt32 nPos)=0
virtual OdInt32 getRangeMinInt() const =0
virtual void setRangeUInt(OdUInt32 nMin, OdUInt32 nMax)=0
virtual OdInt32 getDeltaInt() const =0
virtual double getRangeMaxFP() const =0
virtual void setPosUInt(OdUInt32 nPos)=0
virtual void setRangeFP(double fMin, double fMax)=0
virtual void setFP(bool bFP)=0
long bottom
Definition: ExtBar.h:57
long left
Definition: ExtBar.h:54
long right
Definition: ExtBar.h:56
long top
Definition: ExtBar.h:55
long cx
Definition: ExtBar.h:61
long cy
Definition: ExtBar.h:62
virtual OdString getText() const =0
static TextElement * cast(Element *pIface)
Definition: ExtBar.h:113
virtual void setText(const OdString &text)=0