Photon microGUI widgets library 0.6.0
Widget.h
1#ifndef PHWIDGETS_WIDGET_H
2#define PHWIDGETS_WIDGET_H
3
4#include <photon/PhT.h>
5#include <photon/PtWidget.h>
6#include <photon/PtContainer.h>
7#include <photon/PtGridLayout.h>
8#include <photon/PtRowLayout.h>
9
10#include <map>
11#include <string>
12#include <list>
13#include <set>
14
15#include "./service/stdex/stdex.h"
16#include "./service/phproperty.hpp"
17#include "./service/phevent.hpp"
18#include "./service/phbitmask.hpp"
19#include "./service/tag_property.hpp"
20#include "./service/WidgetResource.hpp"
21
22#include "./Cursor.h"
23#include "./Drawing/Color.h"
24
25
26//typedef Ph_rect `PhRect_t`;
27
28#ifndef __QNXNTO__
29 typedef struct Ph_rect PhRect_t;
30#endif
31
32// @defgroup Widgets PhWidgets library widgets
33// @defgroup Values PhWidgets library flags and predefined values
34// @defgroup Classes PhWidgets library helper classes
35// @defgroup Resources PhWidgets library resource ID's and raw widgets flags
36
38namespace PhWidgets
39{
40 using namespace cppproperties;
41 using namespace phevents;
42 using namespace cppbitmasks;
43
45
56 {
58
66 enum type
67 {
68 LeftAnchoredRight = Pt_LEFT_ANCHORED_RIGHT,
69 RightAnchoredRight = Pt_RIGHT_ANCHORED_RIGHT,
70 TopAnchoredBottom = Pt_TOP_ANCHORED_BOTTOM,
71 BottomAnchoredBottom = Pt_BOTTOM_ANCHORED_BOTTOM,
72 LeftAnchoredLeft = Pt_LEFT_ANCHORED_LEFT,
73 RightAnchoredLeft = Pt_RIGHT_ANCHORED_LEFT,
74 TopAnchoredTop = Pt_TOP_ANCHORED_TOP,
75 BottomAnchoredTop = Pt_BOTTOM_ANCHORED_TOP,
76 BalloonsOn = Pt_BALLOONS_ON,
77
78 // Visual Studio like styles:
79
82 None = 0,
85
91 };
92 };
93
100
107 class Widget:
108 protected detail::IPtWidget,
109 public IPhWidgetsProperty
110 {
111 protected:
112 struct ResourceTag
113 {
114 struct Struct;
115 struct Callback;
116 struct Alloc;
117 struct Color;
118 struct Flag;
119 struct String;
120 struct Scalar;
121 };
122 public:
123
124
125 typedef phevent::ph_callback_t callback_t;
126
128
130 template<class ParentT, typename ParentT::template Callbacks<PtCallback_t>::Callback CallbackID>
132 {
133
134 public:
135 phwidgets_event(ParentT *parent) :
136 _obj(parent)
137 {}
138
140 inline void add(callback_t value)
141 {
142 _obj->resource.callback[CallbackID].add(value);
143 }
144
146 inline void remove(callback_t value)
147 {
148 _obj->resource.callback[CallbackID].remove(value);
149 }
150
152
154 inline void raise(PtCallbackInfo_t * info) const
155 {
156 _obj->resource.callback[CallbackID].raise(info);
157 }
158
160 inline void operator+=(callback_t value)
161 {
162 add(value);
163 }
164
166 inline void operator-=(callback_t value)
167 {
168 remove(value);
169 }
170
172
174 inline void operator()(PtCallbackInfo_t * info) const
175 {
176 raise(info);
177 }
178
179
180 private:
181 ParentT *_obj;
182
184
185 inline phwidgets_event &operator=(callback_t);
186 inline phwidgets_event &operator=(phwidgets_event const &);
187 };
188
189
190 /*template<class ParentT, ParentT::Callbacks::eRawCallback callback>
191 class phwidgets_event
192 {
193 typedef phevent::ph_callback_t value_t;
194
195 public:
196 phwidgets_event(ParentT *parent) :
197 _obj(parent)
198 {}
199
200 inline void add(value_t value)
201 {
202 _obj->resource.callback[callback].add(value);
203 }
204
205 inline void remove(value_t value)
206 {
207 _obj->resource.callback[callback].remove(value);
208 }
209
210 inline void operator+=(value_t value)
211 {
212 add(value);
213 }
214
215 inline void operator-=(value_t value)
216 {
217 remove(value);
218 }
219
220
221 private:
222 ParentT *_obj;
223
224 phwidgets_event(const phwidgets_event &rhs);
225
226 inline phwidgets_event &operator=(value_t);
227 inline phwidgets_event &operator=(phwidgets_event const &);
228 };*/
229
230 protected:
231 template<int>
232 struct ResourceTypeTag;
233
234 public:
235
237 template<class T = void, class Disabled = ResourceTypeTag<-1>, bool Dummy = false>
239 {
240 typedef void type;
241 };
242
243 template<class T, int TypeID>
244 struct Arguments<T, ResourceTypeTag<TypeID> >
245 : Arguments<T, ResourceTag::Alloc>
246 , Arguments<T, ResourceTag::Callback>
247 , Arguments<T, ResourceTag::Color>
248 , Arguments<T, ResourceTag::Flag>
249 , Arguments<T, ResourceTag::Scalar>
250 , Arguments<T, ResourceTag::String>
251 , Arguments<T, ResourceTag::Struct>
252 { };
253
254 template<class T>
255 struct Arguments<Widget, T, false>
256 : Arguments<T>
257 { };
258
260 template<bool Dummy>
261 struct Arguments<PhArea_t, ResourceTag::Struct, Dummy>
262 {
264
272 typedef enum Struct
273 {
274 Area = Pt_ARG_AREA
275 } type;
276 };
277
279 template<bool Dummy>
280 struct Arguments<unsigned, ResourceTag::Flag, Dummy>
281 {
283
291 typedef enum Flag
292 {
293 AnchorFlags = Pt_ARG_ANCHOR_FLAGS
294 } type;
295 };
296
298 template<bool Dummy>
299 struct Arguments<unsigned short, ResourceTag::Scalar, Dummy>
300 {
302
310 typedef enum Scalar
311 {
312 BevelWidth = Pt_ARG_BEVEL_WIDTH,
313 CursorType = Pt_ARG_CURSOR_TYPE,
314 Height = Pt_ARG_HEIGHT,
315 Width = Pt_ARG_WIDTH
316 } type;
317 };
318
320 template<bool Dummy>
321 struct Arguments<unsigned long, ResourceTag::Flag, Dummy>
322 {
324
332 typedef enum Flag
333 {
334 ExtendedFlags = Pt_ARG_EFLAGS
335 } type;
336 };
337
339 template<bool Dummy>
340 struct Arguments<long, ResourceTag::Flag, Dummy>
341 {
343
351 typedef enum Flag
352 {
353 Flags = Pt_ARG_FLAGS,
354 Resiztype = Pt_ARG_RESIZE_FLAGS
355 } type;
356 };
357
359 template<bool Dummy>
360 struct Arguments<char*, ResourceTag::String, Dummy>
361 {
363
371 typedef enum String
372 {
373 HelpTopic = Pt_ARG_HELP_TOPIC
376
377 } type;
378 };
379
381 template<bool Dummy>
382 struct Arguments<void*, ResourceTag::Alloc, Dummy>
383 {
385
396 typedef enum Alloc
397 {
398 LayoutData = Pt_ARG_LAYOUT_DATA,
400 Data = Pt_ARG_DATA,
401 UserData = Pt_ARG_USER_DATA
402 } type;
403
405
417 typedef enum Pointer
418 {
419 Pointer = Pt_ARG_POINTER
420 } PointerResource;
421 };
422
424 template<bool Dummy>
425 struct Arguments<PhRect_t, ResourceTag::Struct, Dummy>
426 {
428
436 typedef enum Struct
437 {
438 EnchorOffsets = Pt_ARG_ANCHOR_OFFSETS,
440
441 Extent = Pt_ARG_EXTENT
442 } type;
443 };
444
446 template<bool Dummy>
447 struct Arguments<PgColor_t, ResourceTag::Color, Dummy>
448 {
450
458 typedef enum Color
459 {
460 CursorColor = Pt_ARG_CURSOR_COLOR
461 } type;
462 };
463
465 template<bool Dummy>
466 struct Arguments<PhCursorDef_t, ResourceTag::Struct, Dummy>
467 {
469
477 typedef enum Struct
478 {
479 BitmapCursor = Pt_ARG_BITMAP_CURSOR
480 } type;
481 };
482
484 template<bool Dummy>
485 struct Arguments<PtGridLayoutData_t, ResourceTag::Struct, Dummy>
486 {
488
495 typedef enum Struct
496 {
497 GridLayoutData = Pt_ARG_GRID_LAYOUT_DATA
499 } type;
500 };
501
503 template<bool Dummy>
504 struct Arguments<PhPoint_t, ResourceTag::Struct, Dummy>
505 {
507
514 typedef enum Struct
515 {
516 Position = Pt_ARG_POS
517 } type;
518 };
519
521 template<bool Dummy>
522 struct Arguments<PtRowLayoutData_t, ResourceTag::Struct, Dummy>
523 {
525
532 typedef enum Struct
533 {
534 RowLayoutData = Pt_ARG_ROW_LAYOUT_DATA
535 } type;
536 };
537
539 template<bool Dummy>
540 struct Arguments<PhDim_t, ResourceTag::Struct, Dummy>
541 {
543
550 typedef enum Struct
551 {
552 Dimension = Pt_ARG_DIM,
553 DimensionMax = Pt_ARG_MAXIMUM_DIM,
554 DimensionMin = Pt_ARG_MINIMUM_DIM
555 } type;
556 };
557
559 template<class T = void, class Disabled = void, bool Dummy = false>
561 {
562 typedef Callbacks<> type;
563 };
564
565 template<class T>
566 struct Callbacks<Widget, T>
567 : Callbacks<T>
568 { };
569
570 template<class T, bool Dummy>
571 struct Callbacks<T, void, Dummy>
572 : Callbacks<T, ResourceTag::Callback, Dummy>
573 { };
574
576 template<bool Dummy>
577 struct Callbacks<PtRawCallback_t, ResourceTag::Callback, Dummy>
578 {
580
587 typedef enum RawCallback
588 {
589 Filter = Pt_CB_FILTER,
592
593 Raw = Pt_CB_RAW
595
596 } type;
597 };
598
600 template<bool Dummy>
601 struct Callbacks<PtCallback_t, ResourceTag::Callback, Dummy>
602 {
604
611 typedef enum Callback
612 {
613 Blocked = Pt_CB_BLOCKED,
615
616 Destroyed = Pt_CB_DESTROYED,
620
621 DragAndDrop = Pt_CB_DND,
623
624 IsDestroyed = Pt_CB_IS_DESTROYED,
627 Released = IsDestroyed,
628
629 Outbound = Pt_CB_OUTBOUND,
632
633 Realized = Pt_CB_REALIZED,
635
636 Unrealized = Pt_CB_UNREALIZED
638 } type;
639 };
640
642 template<bool Dummy>
643 struct Callbacks<PtHotkeyCallback_t, ResourceTag::Callback, Dummy>
644 {
646
653 typedef enum HotkeyCallback
654 {
656
661 Hotkey = Pt_CB_HOTKEY
662 } type;
663 };
664
665 template<int TypeID>
666 struct Arguments<void, ResourceTypeTag<TypeID>>
667 : Arguments<PhArea_t, ResourceTypeTag<__LINE__>>
668 , Arguments<unsigned, ResourceTypeTag<__LINE__>>
669 , Arguments<unsigned short, ResourceTypeTag<__LINE__>>
670 , Arguments<unsigned long, ResourceTypeTag<__LINE__>>
671 , Arguments<long, ResourceTypeTag<__LINE__>>
672 , Arguments<char*, ResourceTypeTag<__LINE__>>
673 , Arguments<void*, ResourceTypeTag<__LINE__>>
674 , Arguments<PhRect_t, ResourceTypeTag<__LINE__>>
675 , Arguments<PgColor_t, ResourceTypeTag<__LINE__>>
676 , Arguments<PhCursorDef_t, ResourceTypeTag<__LINE__>>
677 , Arguments<PtGridLayoutData_t, ResourceTypeTag<__LINE__>>
678 , Arguments<PhPoint_t, ResourceTypeTag<__LINE__>>
679 , Arguments<PtRowLayoutData_t, ResourceTypeTag<__LINE__>>
680 , Arguments<PhDim_t, ResourceTypeTag<__LINE__>>
681 { };
682
683 template<bool Dummy>
684 struct Callbacks<void, void, Dummy>
685 : Callbacks<PtRawCallback_t>
686 , Callbacks<PtCallback_t>
687 , Callbacks<PtHotkeyCallback_t>
688 { };
689
691 struct Flags
692 {
694 struct Cursor
695 {
697
702 enum type
703 {
704 Inherit = Ph_CURSOR_INHERIT,
707
708 BitmapNoInherit = Ph_CURSOR_BITMAP,
711
712 BitmapInherit = Ph_CURSOR_BITMAP & ~Ph_CURSOR_NO_INHERIT,
715
717
718 };
719 };
720
722 struct Extended
723 {
725
730 enum type
731 {
734 ConsumeEvents = Pt_CONSUME_EVENTS,
735
736 InternalHelp = Pt_INTERNAL_HELP,
737 //damage_parent = Pt_DAMAGE_PARENT, //!< If the widget is damaged for any reason, damage its parent instead (internal use only).
738 SkipLayout = Pt_SKIP_LAYOUT
739 };
740 };
741
743 struct Anchor:
744 public AnchorStyles
745 {};
746
748 struct Resize
749 {
751
776 enum type
777 {
778 None = 0,
779 ResizeX_asRequired = Pt_RESIZE_X_AS_REQUIRED,
780 ResizeX_always = Pt_RESIZE_X_ALWAYS,
781 ResizeX_initial = Pt_RESIZE_X_INITIAL,
782 ResizeX_bits = Pt_RESIZE_X_BITS,
783 ResizeY_asRequired = Pt_RESIZE_Y_AS_REQUIRED,
784 ResizeY_always = Pt_RESIZE_Y_ALWAYS,
785 ResizeY_initial = Pt_RESIZE_Y_INITIAL,
786 ResizeY_bits = Pt_RESIZE_Y_BITS,
787 ResizeXY_asRequired = Pt_RESIZE_XY_ALWAYS,
788 ResizeXY_always = Pt_RESIZE_XY_AS_REQUIRED,
789 ResizeXY_initial = Pt_RESIZE_XY_INITIAL,
790 ResizeXY_bits = Pt_RESIZE_XY_BITS
791
792 };
793 };
794
796
803 enum type
804 {
805 AllButtons = Pt_ALL_BUTTONS,
806 Autohighlight = Pt_AUTOHIGHLIGHT,
807 Blocked = Pt_BLOCKED,
808
817 CallbacksActive = Pt_CALLBACKS_ACTIVE,
818
819 Clear = Pt_CLEAR,
820 ClipHighlight = Pt_CLIP_HIGHLIGHT,
821 Damaged = Pt_DAMAGED,
822 DamageFamily = Pt_DAMAGE_FAMILY,
823 DelayRealize = Pt_DELAY_REALIZE,
824 Destroyed = Pt_DESTROYED,
825 FocusRender = Pt_FOCUS_RENDER,
826 GetsFocus = Pt_GETS_FOCUS,
827 Ghost = Pt_GHOST,
828 Highlighted = Pt_HIGHLIGHTED,
829 InFlux = Pt_IN_FLUX,
830 Menuable = Pt_MENUABLE,
831 MenuButton = Pt_MENU_BUTTON,
832 Obscured = Pt_OBSCURED,
833 Opaque = Pt_OPAQUE,
834 Procreated = Pt_PROCREATED,
835 Realized = Pt_REALIZED,
836 Realizing = Pt_REALIZING,
837 Region = Pt_REGION,
838 Selectable = Pt_SELECTABLE,
839 SelectNoredraw = Pt_SELECT_NOREDRAW,
840 Set = Pt_SET,
841
844 Toggle = Pt_TOGGLE,
845
846 WidgetRebuild = Pt_WIDGET_REBUILD,
847 WidgetResize = Pt_WIDGET_RESIZE
848 };
849
850 };
851
852
853
854 private:
855
856 int _abn;
857 mutable PtWidget_t *_widget;
858
859 using IPhWidgetsProperty::setArgument;
860 using IPhWidgetsProperty::getArgument;
861
862 protected:
863
864 typedef ResourceFrom<>::
865 Define::String<Arguments<char*>::String>::
866 Define::Alloc<Arguments<void*>::Alloc>::
867 Define::Pointer<Arguments<void*>::PointerResource>::
868 Define::Color<Arguments<PgColor_t>::Color>::
869 Define::Struct<Arguments<PhCursorDef_t>::Struct, PhCursorDef_t>::
870 Define::Struct<Arguments<PtGridLayoutData_t>::Struct, PtGridLayoutData_t>::
871 Define::Struct<Arguments<PhPoint_t>::Struct, PhPoint_t>::
872 Define::Struct<Arguments<PtRowLayoutData_t>::Struct, PtRowLayoutData_t>::
873 Define::Struct<Arguments<PhArea_t>::Struct, PhArea_t>::
874 Define::Struct<Arguments<PhRect_t>::Struct, PhRect_t>::
875 Define::Scalar<Arguments<unsigned short>::Scalar, unsigned short>::
876 Define::Struct<Arguments<PhDim_t>::Struct, PhDim_t>::
877 Define::Flag<Arguments<long>::Flag, long>::
878 Define::Flag<Arguments<unsigned long>::Flag, unsigned long>::
879 Define::Flag<Arguments<unsigned>::Flag, unsigned>::
880
881 Define::Link<Callbacks<PtCallback_t>::type, PtCallback_t*>::
882 //Define::Link<RawCallback::eRawCallback, `PtRawCallback_t`*>::
883 //Define::Link<HotkeyCallback::eHotkeyCallback, `PtHotkeyCallback_t`*>::
884
885 resource_type WidgetResourcesSingleton;
886
887 virtual PtWidget_t *widget() const;
888 virtual void check();
889
890 //for properties:
891
892 void setAllowDrop(bool);
893 bool getAllowDrop() const;
894
895 void setEnabled(bool);
896 bool getEnabled() const;
897
898 void setHelpTopic(std::string);
899 std::string getHelpTopic() const;
900
901 void setLocation(PhPoint_t);
902 PhPoint_t getLocation() const;
903
904 void setBounds(PhArea_t);
905 PhArea_t getBounds() const;
906
907 short getBottom() const;
908
909 void setCursor(PhWidgets::Cursor);
910 PhWidgets::Cursor getCursor() const;
911
912 bool getCanFocus() const;
913
914 bool getCanSelect() const;
915
916 bool getContainsFocus() const;
917
918 bool getFocused() const;
919
920 bool hasChildren() const;
921 bool hasParent() const;
922
923 void setLeft(short);
924 short getLeft() const;
925
926 void setTag(const void*, std::size_t);
927 const void * getTag() const;
928
929 void setTop(short);
930 short getTop() const;
931
932 short getRight() const;
933
934 void setVisible(bool);
935 bool getVisible() const;
936
937 bool getIsRealized() const;
938
939 void setParent(PtWidget_t*);
940 PtWidget_t* getParent() const;
941
942 std::set<Widget> getWidgets() const;
943
944 public:
946
950 explicit Widget(int abn);
951
953
957 explicit Widget(PtWidget_t *wdg);
958
960
964 Widget(const Widget &other);
965
967
970 void swap(Widget &other);
971
973
977 Widget &operator=(const Widget &other);
978
980
985
987
991 bool operator==(const Widget &other) const;
992
994
998 bool operator!=(const Widget &other) const;
999
1001
1005 bool operator<(const Widget &other) const;
1006
1008
1012 bool operator<=(const Widget &other) const;
1013
1015
1019 bool operator>(const Widget &other) const;
1020
1022
1026 bool operator>=(const Widget &other) const;
1027
1029 PtWidget_t* get() const;
1030
1032 operator PtWidget_t*();
1033
1035 operator const PtWidget_t*() const;
1036
1038
1047
1049
1076 bool Contains(const Widget &widget);
1077
1079
1112 bool Focus();
1113
1115
1131 Widget GetNextWidget(const Widget &widget, bool forward = true) const;
1132
1134
1143 void Hide();
1144
1146
1164 void Invalidate(PhRect_t rc, bool invalidateChildren = false);
1165
1167
1182 void Invalidate(bool invalidateChildren = false);
1183
1185
1201 bool Realize();
1202
1204
1215 void Refresh();
1216
1218
1230
1232
1239 void SetBounds(short x, short y, unsigned short width, unsigned short height);
1240
1242
1246 void SetBounds(short x, short y);
1248
1250
1264 void Select();
1265
1267
1276 void Show();
1277
1279
1293
1295
1322 static void Update();
1323
1325
1382 WidgetResourcesSingleton resource;
1383
1386
1387
1403 property<bool>::bind<Widget, &Widget::getAllowDrop, &Widget::setAllowDrop> AllowDrop;
1404
1406
1438 phbitmask<unsigned, Flags::Anchor::type, Flags::Anchor::All>::
1439 bind<Widget, Arguments<unsigned>::Flag, Arguments<unsigned>::AnchorFlags> Anchor;
1440
1442
1457
1459
1477 property<short, property<>::ro>::bind<Widget, &Widget::getBottom> Bottom;
1478
1480
1513 property<PhArea_t>::bind<Widget, &Widget::getBounds, &Widget::setBounds> Bounds;
1514
1516
1535 property<bool, property<>::ro>::bind<Widget, &Widget::getCanFocus> CanFocus;
1536
1538
1556 property<bool, property<>::ro>::bind<Widget, &Widget::getCanSelect> CanSelect;
1557
1559
1577 property<bool, property<>::ro>::bind<Widget, &Widget::getContainsFocus> ContainsFocus;
1578
1580
1630 property<PhWidgets::Cursor>::bind<Widget, &Widget::getCursor, &Widget::setCursor> Cursor;
1631
1633
1662
1664
1689 property<bool>::bind<Widget, &Widget::getEnabled, &Widget::setEnabled> Enabled;
1690
1692
1705 property<bool, property<>::ro>::bind<Widget, &Widget::getFocused> Focused;
1706
1708
1718 property<bool, property<>::ro>::bind<Widget, &Widget::hasChildren> HasChildren;
1719
1721
1731 property<bool, property<>::ro>::bind<Widget, &Widget::hasParent> HasParent;
1732
1734
1749
1751
1758 property<std::string>::bind<Widget, &Widget::getHelpTopic, &Widget::setHelpTopic> HelpTopic;
1759
1761
1775 property<bool, property<>::ro>::bind<Widget, &Widget::getIsRealized> IsRealized;
1776
1778
1794 property<short>::bind<Widget, &Widget::getLeft, &Widget::setLeft> Left;
1795
1797
1816 property<PhPoint_t>::bind<Widget, &Widget::getLocation, &Widget::setLocation> Location;
1817
1819
1867 property<PtWidget_t*>::bind<Widget, &Widget::getParent, &Widget::setParent> Parent;
1868
1870
1890
1891
1893
1911 property<short, property<>::ro>::bind<Widget, &Widget::getRight> Right;
1912
1914
1932
1934
2051 tag_property<Widget, &Widget::getTag, &Widget::setTag> Tag;
2052
2054
2070 property<short>::bind<Widget, &Widget::getTop, &Widget::setTop> Top;
2071
2073
2089 property<bool>::bind<Widget, &Widget::getVisible, &Widget::setVisible> Visible;
2090
2092
2125 property<std::set<PhWidgets::Widget>, property<>::ro>::bind<Widget, &Widget::getWidgets> Widgets;
2126
2128
2143
2144 phbitmask<unsigned long, Flags::Extended::type>::
2145 bind<Widget, Arguments<unsigned long>::Flag, Arguments<unsigned long>::ExtendedFlags> ExtendedFlags;
2146
2148
2171 phbitmask<long, Flags::type>::
2172 bind<Widget, Arguments<long>::Flag, Arguments<long>::Flags> WidgetFlags;
2173
2174 phbitmask<long, Flags::Resize::type>::
2175 bind<Widget, Arguments<long>::Flag, Arguments<long>::Resiztype> Resiztype;
2177
2179
2188
2190
2198
2199
2200
2201 };
2202
2204
2234#ifdef __DOXYGEN__ // ugly hack for Doxygen docs
2235 template<class WidgetT>
2236 PtWidget_t* dynamic_widget_cast(const Widget &widget);
2237#else
2238 template<class WidgetT>
2239 inline
2241 typename
2242 stdex::enable_if<
2243 cppproperties::detail::is_convertable<
2244 typename stdex::remove_cv<WidgetT>::type,
2245 Widget&
2246 >::value,
2247 const Widget&
2248 >::type widget) throw()
2249 try
2250 {
2251 WidgetT result = widget;
2252 return result;
2253 }
2254 catch(const std::exception&)
2255 {
2256 return nullptr;
2257 }
2258#endif
2259
2260 namespace typedefs
2261 {
2262 typedef
2263 cppbitmasks::bitmask<
2264 unsigned,
2266 PhWidgets::Widget::Flags::Anchor::All
2267 >
2268 anchor_flags_bitmask;
2269 }
2270} // namespace PhWidgets
2271
2272
2273
2274cppbitmasks::bitmask<unsigned long, PhWidgets::Widget::Flags::Extended::type> operator|(const PhWidgets::Widget::Flags::Extended::type &flag1, const PhWidgets::Widget::Flags::Extended::type &flag2);
2275cppbitmasks::bitmask<unsigned long, PhWidgets::Widget::Flags::Extended::type> operator&(const PhWidgets::Widget::Flags::Extended::type &flag1, const PhWidgets::Widget::Flags::Extended::type &flag2);
2276cppbitmasks::bitmask<unsigned long, PhWidgets::Widget::Flags::Extended::type> operator^(const PhWidgets::Widget::Flags::Extended::type &flag1, const PhWidgets::Widget::Flags::Extended::type &flag2);
2277
2278cppbitmasks::bitmask<long, PhWidgets::Widget::Flags::type> operator|(const PhWidgets::Widget::Flags::type &flag1, const PhWidgets::Widget::Flags::type &flag2);
2279cppbitmasks::bitmask<long, PhWidgets::Widget::Flags::type> operator&(const PhWidgets::Widget::Flags::type &flag1, const PhWidgets::Widget::Flags::type &flag2);
2280cppbitmasks::bitmask<long, PhWidgets::Widget::Flags::type> operator^(const PhWidgets::Widget::Flags::type &flag1, const PhWidgets::Widget::Flags::type &flag2);
2281
2282cppbitmasks::bitmask<long, PhWidgets::Widget::Flags::Resize::type> operator|(const PhWidgets::Widget::Flags::Resize::type &flag1, const PhWidgets::Widget::Flags::Resize::type &flag2);
2283cppbitmasks::bitmask<long, PhWidgets::Widget::Flags::Resize::type> operator&(const PhWidgets::Widget::Flags::Resize::type &flag1, const PhWidgets::Widget::Flags::Resize::type &flag2);
2284cppbitmasks::bitmask<long, PhWidgets::Widget::Flags::Resize::type> operator^(const PhWidgets::Widget::Flags::Resize::type &flag1, const PhWidgets::Widget::Flags::Resize::type &flag2);
2285
2286PhWidgets::typedefs::anchor_flags_bitmask operator|(const PhWidgets::Widget::Flags::Anchor::type &flag1, const PhWidgets::Widget::Flags::Anchor::type &flag2);
2287PhWidgets::typedefs::anchor_flags_bitmask operator&(const PhWidgets::Widget::Flags::Anchor::type &flag1, const PhWidgets::Widget::Flags::Anchor::type &flag2);
2288PhWidgets::typedefs::anchor_flags_bitmask operator^(const PhWidgets::Widget::Flags::Anchor::type &flag1, const PhWidgets::Widget::Flags::Anchor::type &flag2);
2289
2290bool operator==(const PhArea_t &lhs, const PhArea_t &rhs);
2291bool operator!=(const PhArea_t &lhs, const PhArea_t &rhs);
2292
2293#endif // PHWIDGETS_WIDGET_H
Represents the image used to paint the mouse pointer.
Definition: Cursor.h:65
An event, which raise a notification to registered subscribers (event handlers) that something of int...
Definition: Widget.h:132
void operator+=(callback_t value)
add an event handler
Definition: Widget.h:160
void raise(PtCallbackInfo_t *info) const
raise an event
Definition: Widget.h:154
void remove(callback_t value)
remove an event handler
Definition: Widget.h:146
void operator-=(callback_t value)
remove an event handler
Definition: Widget.h:166
void add(callback_t value)
add an event handler
Definition: Widget.h:140
void operator()(PtCallbackInfo_t *info) const
raise an event
Definition: Widget.h:174
Superclass for all widgets.
Definition: Widget.h:110
property< PtWidget_t * >::bind< Widget, &Widget::getParent, &Widget::setParent > Parent
Gets or sets the parent container of the widget.
Definition: Widget.h:1867
void swap(Widget &other)
Exchanges the contents of *this and other.
Widget GetNextWidget(const Widget &widget, bool forward=true) const
Retrieves the next widget forward or back in the tab order of child widgets.
void SendToBack()
Sends the widget to the back of the z-order.
void BringToFront()
Brings the widget to the front of the z-order.
property< PhPoint_t >::bind< Widget, &Widget::getLocation, &Widget::setLocation > Location
Gets or sets the coordinates of the upper-left corner of the widget relative to the upper-left corner...
Definition: Widget.h:1816
bool operator<(const Widget &other) const
Compares Widgets.
void SetBounds(short x, short y)
Sets the bounds of the widget to the specified location.
bool operator==(const Widget &other) const
Compares Widgets.
bool operator<=(const Widget &other) const
Compares Widgets.
property< bool >::bind< Widget, &Widget::getVisible, &Widget::setVisible > Visible
Gets or sets a value indicating whether the widget and all its child widgets are displayed.
Definition: Widget.h:2089
property< bool, property<>::ro >::bind< Widget, &Widget::getCanSelect > CanSelect
Gets a value indicating whether the widget can be selected.
Definition: Widget.h:1556
phbitmask< unsigned long, Flags::Extended::type >::bind< Widget, Arguments< unsigned long >::Flag, Arguments< unsigned long >::ExtendedFlags > ExtendedFlags
Gets or sets extended flags inherited by all widgets. See Flags::Extended::type.
Definition: Widget.h:2145
phwidgets_event< Widget, Widget::Callbacks<>::Destroyed > Destroyed
Occurs when the widget is destroyed.
Definition: Widget.h:2180
property< std::string >::bind< Widget, &Widget::getHelpTopic, &Widget::setHelpTopic > HelpTopic
Gets or sets the help topic of the widget.
Definition: Widget.h:1758
bool operator!=(const Widget &other) const
Compares Widgets.
phwidgets_event< Widget, Widget::Callbacks<>::Blocked > Blocked
Occurs when the widget is blocked.
Definition: Widget.h:2181
phwidgets_event< Widget, Widget::Callbacks<>::Unrealized > Unrealized
Occurs when the widget is unrealized.
Definition: Widget.h:2186
property< std::set< PhWidgets::Widget >, property<>::ro >::bind< Widget, &Widget::getWidgets > Widgets
Gets the list of widgets contained within the widget.
Definition: Widget.h:2125
property< bool, property<>::ro >::bind< Widget, &Widget::hasChildren > HasChildren
Gets a value indicating whether the widget contains one or more child widgets.
Definition: Widget.h:1718
phwidgets_event< Widget, Widget::Callbacks<>::IsDestroyed > IsDestroyed
Occurs when the widget's resources are being released.
Definition: Widget.h:2183
property< bool, property<>::ro >::bind< Widget, &Widget::hasParent > HasParent
Gets a value indicating whether the widget has parent.
Definition: Widget.h:1731
phwidgets_event< Widget, Widget::Callbacks<>::Realized > Realized
Occurs when the widget is realized.
Definition: Widget.h:2185
void Invalidate(bool invalidateChildren=false)
Invalidates a specific region of the widget and causes a paint message to be sent to the widget.
phbitmask< long, Flags::Resize::type >::bind< Widget, Arguments< long >::Flag, Arguments< long >::Resiztype > Resiztype
Gets or sets flags to control a widget's resize policy. See Flags::Resize::type.
Definition: Widget.h:2175
void SetBounds(short x, short y, unsigned short width, unsigned short height)
Sets the bounds of the widget to the specified location and size.
property< PhArea_t >::bind< Widget, &Widget::getBounds, &Widget::setBounds > Bounds
Gets or sets the size and location of the widget including its nonclient elements,...
Definition: Widget.h:1513
phbitmask< long, Flags::type >::bind< Widget, Arguments< long >::Flag, Arguments< long >::Flags > WidgetFlags
Gets or sets flags inherited by all widgets.
Definition: Widget.h:2172
property< short, property<>::ro >::bind< Widget, &Widget::getBottom > Bottom
Gets the distance, in pixels, between the bottom edge of the widget and the top edge of its container...
Definition: Widget.h:1477
WidgetResourcesSingleton resource
Resources of the Widget.
Definition: Widget.h:1382
phwidgets_event< Widget, Widget::Callbacks<>::DragAndDrop > DragDrop
Occurs when a drag-and-drop operation is completed.
Definition: Widget.h:2182
phproperty< Drawing::Color >::bind< Widget, Arguments< PgColor_t >::Color, Arguments< PgColor_t >::CursorColor > CursorColor
Gets or sets the color of the cursor pointer when it's inside the widget.
Definition: Widget.h:1661
tag_property< Widget, &Widget::getTag, &Widget::setTag > Tag
Gets or sets the resource that contains data about the widget.
Definition: Widget.h:2051
bool Unrealize()
Unrealizes the widget and all its children.
property< bool >::bind< Widget, &Widget::getAllowDrop, &Widget::setAllowDrop > AllowDrop
Gets or sets a value indicating whether the widget can accept data that the user drags onto it.
Definition: Widget.h:1403
bool operator>=(const Widget &other) const
Compares Widgets.
void Select()
Activates the widget.
bool operator>(const Widget &other) const
Compares Widgets.
void OnUnrealized(PtCallbackInfo_t *info)
Raises the Widget::Unrealized event.
phwidgets_event< Widget, Widget::Callbacks<>::Outbound > Outbound
Occurs when you press the pointer button on the widget and then move out of the "hot spot" with the b...
Definition: Widget.h:2184
property< bool, property<>::ro >::bind< Widget, &Widget::getCanFocus > CanFocus
Gets a value indicating whether the widget can receive focus.
Definition: Widget.h:1535
bool Focus()
Sets input focus to the widget.
void Show()
Displays the widget to the user.
property< short, property<>::ro >::bind< Widget, &Widget::getRight > Right
Gets the distance, in pixels, between the right edge of the widget and the left edge of its container...
Definition: Widget.h:1911
phproperty< unsigned short >::bind< Widget, Arguments< unsigned short >::Scalar, Arguments< unsigned short >::Width > Width
Gets or sets the width of the widget.
Definition: Widget.h:2142
bool Contains(const Widget &widget)
Retrieves a value indicating whether the specified widget is a child of the widget.
void OnRealized(PtCallbackInfo_t *info)
Raises the Widget::Realized event.
void Invalidate(PhRect_t rc, bool invalidateChildren=false)
Invalidates a specific region of the widget and causes a paint message to be sent to the widget.
property< short >::bind< Widget, &Widget::getTop, &Widget::setTop > Top
Gets or sets the distance, in pixels, between the top edge of the widget and the top edge of its cont...
Definition: Widget.h:2070
Widget & operator=(const Widget &other)
Assigns value in Widget.
void OnOutbound(PtCallbackInfo_t *info)
Raises the Widget::Outbound event.
property< bool, property<>::ro >::bind< Widget, &Widget::getFocused > Focused
Gets a value indicating whether the widget has input focus.
Definition: Widget.h:1705
PtWidget_t * get() const
Returns the stored pointer.
void Hide()
Conceals the widget from the user.
Widget(int abn)
(constructor)
Widget(PtWidget_t *wdg)
(constructor)
void Refresh()
Forces the widget to invalidate its client area and immediately redraw itself and any child widgets.
Widget(const Widget &other)
(copy constructor)
phproperty< PhPoint_t >::bind< Widget, Arguments< PhPoint_t >::Struct, Arguments< PhPoint_t >::Position > Position
Gets or sets the absolute coordinates of the upper-left corner of the widget.
Definition: Widget.h:1889
property< bool >::bind< Widget, &Widget::getEnabled, &Widget::setEnabled > Enabled
Gets or sets a value indicating whether the widget can respond to user interaction.
Definition: Widget.h:1689
void OnBlocked(PtCallbackInfo_t *info)
Raises the Widget::Blocked event.
phproperty< unsigned short >::bind< Widget, Arguments< unsigned short >::Scalar, Arguments< unsigned short >::BevelWidth > BevelWidth
Gets or sets the bevel width of the widget.
Definition: Widget.h:1456
Widget & operator=(PtWidget_t *wdg)
Assigns value in Widget.
void OnDestroyed(PtCallbackInfo_t *info)
Raises the Widget::Destroyed event.
property< bool, property<>::ro >::bind< Widget, &Widget::getIsRealized > IsRealized
Gets or sets a value indicating whether the widget is realized.
Definition: Widget.h:1775
bool Realize()
Make the widget and its children visible and possibly interactive.
phevent::ph_callback_t callback_t
An event handler that is raised when an event occur.
Definition: Widget.h:125
property< short >::bind< Widget, &Widget::getLeft, &Widget::setLeft > Left
Gets or sets the distance, in pixels, between the left edge of the widget and the left edge of its co...
Definition: Widget.h:1794
void OnDragDrop(PtCallbackInfo_t *info)
Raises the Widget::DragDrop event.
phbitmask< unsigned, Flags::Anchor::type, Flags::Anchor::All >::bind< Widget, Arguments< unsigned >::Flag, Arguments< unsigned >::AnchorFlags > Anchor
Gets or sets flags specifying how the widget is anchored to its parent.
Definition: Widget.h:1439
static void Update()
Causes the Photon microGUI to redraw the all invalidated regions.
phproperty< unsigned short >::bind< Widget, Arguments< unsigned short >::Scalar, Arguments< unsigned short >::Height > Height
Gets or sets the height of the widget.
Definition: Widget.h:1748
property< PhWidgets::Cursor >::bind< Widget, &Widget::getCursor, &Widget::setCursor > Cursor
Gets or sets the cursor that is displayed when the mouse pointer is over the widget.
Definition: Widget.h:1630
property< bool, property<>::ro >::bind< Widget, &Widget::getContainsFocus > ContainsFocus
Gets a value indicating whether the widget, or one of its child widgets, currently has the input focu...
Definition: Widget.h:1577
phproperty< PhDim_t >::bind< Widget, Arguments< PhDim_t >::Struct, Arguments< PhDim_t >::Dimension > Size
Gets or sets the size of the widget.
Definition: Widget.h:1931
The main namespace for all widgets.
Definition: Basic.h:11
PtWidget_t * dynamic_widget_cast(typename stdex::enable_if< cppproperties::detail::is_convertable< typename stdex::remove_cv< WidgetT >::type, Widget & >::value, const Widget & >::type widget)
Dynamic cast of PhWidgets::Widget.
Definition: Widget.h:2240
Specifies how a widget anchors to the edges of its container.
Definition: Widget.h:56
type
Anchor flags for Widget resource Widget::Arguments::anchor_flags.
Definition: Widget.h:67
@ BottomAnchoredBottom
Anchors the widget's bottom extent to the bottom edge of its parent's canvas.
Definition: Widget.h:71
@ RightAnchoredRight
Anchors the widget's right extent to the right edge of its parent's canvas.
Definition: Widget.h:69
@ Right
The widget is anchored to the right edge of its container.
Definition: Widget.h:83
@ BottomAnchoredTop
Anchors the widget's bottom extent to the top edge of its parent's canvas.
Definition: Widget.h:75
@ None
The widget is not anchored to any edges of its container.
Definition: Widget.h:82
@ LeftAnchoredRight
Anchors the widget's left extent to the right edge of its parent's canvas.
Definition: Widget.h:68
@ Bottom
The widget is anchored to the bottom edge of its container.
Definition: Widget.h:80
@ TopAnchoredBottom
Anchors the widget's top extent to the bottom edge of its parent's canvas.
Definition: Widget.h:70
@ BalloonsOn
If a child widget has been assigned a balloon, pop up the balloon as soon as the pointer passes over ...
Definition: Widget.h:76
@ Top
The widget is anchored to the top edge of its container.
Definition: Widget.h:84
@ TopAnchoredTop
Anchors the widget's top extent to the top edge of its parent's canvas.
Definition: Widget.h:74
@ Left
The widget is anchored to the left edge of its container.
Definition: Widget.h:81
@ LeftAnchoredLeft
Anchors the widget's left extent to the left edge of its parent's canvas.
Definition: Widget.h:72
@ RightAnchoredLeft
Anchors the widget's right extent to the left edge of its parent's canvas.
Definition: Widget.h:73
Color
Resource IDs for Widget arguments of type PgColor_t.
Definition: Widget.h:459
Struct
Resource IDs for Widget arguments of type PhArea_t.
Definition: Widget.h:273
Struct
Resource IDs for Widget arguments of type PhCursorDef_t.
Definition: Widget.h:478
Struct
Resource IDs for Widget arguments of type PhDim_t.
Definition: Widget.h:551
Struct
Resource IDs for Widget arguments of type PhPoint_t.
Definition: Widget.h:515
Struct
Resource IDs for Widget arguments of type PhRect_t.
Definition: Widget.h:437
Struct
Resource IDs for Widget arguments of type PtGridLayoutData_t.
Definition: Widget.h:496
Struct
Resource IDs for Widget arguments of type PtRowLayoutData_t.
Definition: Widget.h:533
String
Resource IDs for Widget arguments of type char*.
Definition: Widget.h:372
Flag
Resource IDs for Widget arguments of type long.
Definition: Widget.h:352
Flag
Resource IDs for Widget arguments of type unsigned.
Definition: Widget.h:292
Flag
Resource IDs for Widget arguments of type unsigned long.
Definition: Widget.h:333
Scalar
Resource IDs for Widget arguments of type unsigned short.
Definition: Widget.h:311
Pointer
Resource IDs for Widget arguments of type void* that are stored externally.
Definition: Widget.h:418
Alloc
Resource IDs for Widget arguments of type void* that are stored in widget.
Definition: Widget.h:397
Contains resource IDs for all Widget arguments.
Definition: Widget.h:239
Callback
Resource IDs for Widget arguments of type PtCallback_t.
Definition: Widget.h:612
HotkeyCallback
Resource IDs for Widget arguments of type PtHotkeyCallback_t.
Definition: Widget.h:654
RawCallback
Resource IDs for Widget arguments of type PtRawCallback_t.
Definition: Widget.h:588
Contains resource IDs for Widget callbacks.
Definition: Widget.h:561
Contains flags for Widget resource Widget::Arguments::AnchorFlags.
Definition: Widget.h:745
Contains flags for Widget resource Widget::Arguments::CursorType.
Definition: Widget.h:695
type
Cursor flags for Widget resource Widget::Arguments::CursorType.
Definition: Widget.h:703
@ BitmapNoInherit
Definition: Widget.h:708
@ Inherit
Definition: Widget.h:704
@ BitmapInherit
Definition: Widget.h:712
@ Bitmap
Same as Cursor::BitmapNoInherit.
Definition: Widget.h:716
Contains flags for Widget resource Widget::Arguments<>::ExtendedFlags.
Definition: Widget.h:723
type
Extended flags for Widget resource Widget::Arguments<>::ExtendedFlags.
Definition: Widget.h:731
@ InternalHelp
Display help information for the widget in a balloon, not in the Helpviewer.
Definition: Widget.h:736
@ ConsumeEvents
Definition: Widget.h:734
@ SkipLayout
Skip this widget when performing a layout.
Definition: Widget.h:738
Contains flags for Widget resource Widget::Arguments::Resiztype.
Definition: Widget.h:749
type
Resize flags for Widget resource Widget::Arguments::Resiztype.
Definition: Widget.h:777
Contains flags for Widget resources.
Definition: Widget.h:692
type
Common flags for Widget resource Widget::Arguments::Flags.
Definition: Widget.h:804
@ ClipHighlight
Clip the corners of the highlighting rectangle.
Definition: Widget.h:820
@ WidgetRebuild
(read-only) The widget will be rebuilt(rerealized) when the widget engine is finished applying resour...
Definition: Widget.h:846
@ Obscured
(read-only) The widget is completely covered by one other widget, or it's completely outside its pare...
Definition: Widget.h:832
@ Realized
(read-only) The widget is realized.
Definition: Widget.h:835
@ CallbacksActive
Definition: Widget.h:817
@ AllButtons
Any pointer button can activate the widget. Default is the left button only.
Definition: Widget.h:805
@ Clear
(read-only) The widget's brothers-in-front don't intersect with its extent.
Definition: Widget.h:819
@ Destroyed
(read-only) The widget has been marked for destruction.
Definition: Widget.h:824
@ DamageFamily
(read-only) The widget and all its children need to be repaired.
Definition: Widget.h:822
@ Highlighted
Allow the widget to be highlighted as defined by the Widget::BevelWidth, and the Basic::BasicFlags.
Definition: Widget.h:828
@ Autohighlight
Highlight and give focus to the widget when the cursor enters its extent, and unhighlight and remove ...
Definition: Widget.h:806
@ Damaged
(read-only) The Widget requires repair.
Definition: Widget.h:821
@ Ghost
Dim the widget. Setting this flag doesn't affect the widget's behavior, just its appearance....
Definition: Widget.h:827
@ Toggle
Definition: Widget.h:844
@ InFlux
(read-only) A call to PtContainerHold() has been made on the widget.
Definition: Widget.h:829
@ Selectable
You can select (repeat, arm, disarm and activate) the widget. Widgets usually provide visual feedback...
Definition: Widget.h:838
@ Blocked
Prevent the widget and all its non-window-class children from interacting with Photon events.
Definition: Widget.h:807
@ Set
The widget is in a set state. Generally, this indicates that the widget has been selected.
Definition: Widget.h:840
@ Region
Force the widget to have a region.
Definition: Widget.h:837
@ FocusRender
Render a focus indicator when the widget when it gets focus.
Definition: Widget.h:825
@ SelectNoredraw
The widget doesn't change its appearance when set or unset. This is meaningful only when the widget i...
Definition: Widget.h:839
@ DelayRealize
Prevent the widget from becoming realized unless it's explicitly realized with Widget::Realized event...
Definition: Widget.h:823
@ GetsFocus
Allow the widget to be granted focus. The widget needs to have this bit set if it's to receive key ev...
Definition: Widget.h:826
@ WidgetResize
(read-only) The widget will be resized when the widget engine is finished applying resource changes.
Definition: Widget.h:847
@ Opaque
(read-only) This widget obscures everything directly behind it (i.e. it isn't transparent).
Definition: Widget.h:833
@ Realizing
(read-only) The widget is in the process of being realized.
Definition: Widget.h:836
@ Procreated
(read-only) The widget was created by another widget (as opposed to an application),...
Definition: Widget.h:834
@ MenuButton
The widget is a menu item.
Definition: Widget.h:831
@ Menuable
Respond to clicks on the pointer's right button (i.e. enable the Basic::MenuActivate event).
Definition: Widget.h:830