1#ifndef PHWIDGETS_WIDGET_H
2#define PHWIDGETS_WIDGET_H
5#include <photon/PtWidget.h>
6#include <photon/PtContainer.h>
7#include <photon/PtGridLayout.h>
8#include <photon/PtRowLayout.h>
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"
23#include "./Drawing/Color.h"
40 using namespace cppproperties;
41 using namespace phevents;
42 using namespace cppbitmasks;
108 protected detail::IPtWidget,
109 public IPhWidgetsProperty
130 template<class ParentT, typename ParentT::template Callbacks<PtCallback_t>::Callback CallbackID>
142 _obj->resource.callback[CallbackID].add(value);
148 _obj->resource.callback[CallbackID].remove(value);
156 _obj->resource.callback[CallbackID].raise(info);
232 struct ResourceTypeTag;
237 template<
class T = void,
class Disabled = ResourceTypeTag<-1>,
bool Dummy =
false>
243 template<
class T,
int TypeID>
244 struct Arguments<T, ResourceTypeTag<TypeID> >
255 struct Arguments<
Widget, T, false>
293 AnchorFlags = Pt_ARG_ANCHOR_FLAGS
313 CursorType = Pt_ARG_CURSOR_TYPE,
398 LayoutData = Pt_ARG_LAYOUT_DATA,
401 UserData = Pt_ARG_USER_DATA
438 EnchorOffsets = Pt_ARG_ANCHOR_OFFSETS,
441 Extent = Pt_ARG_EXTENT
479 BitmapCursor = Pt_ARG_BITMAP_CURSOR
497 GridLayoutData = Pt_ARG_GRID_LAYOUT_DATA
534 RowLayoutData = Pt_ARG_ROW_LAYOUT_DATA
552 Dimension = Pt_ARG_DIM,
553 DimensionMax = Pt_ARG_MAXIMUM_DIM,
554 DimensionMin = Pt_ARG_MINIMUM_DIM
559 template<
class T =
void,
class Disabled =
void,
bool Dummy = false>
570 template<
class T,
bool Dummy>
571 struct Callbacks<T, void, Dummy>
572 : Callbacks<T, ResourceTag::Callback, Dummy>
589 Filter = Pt_CB_FILTER,
621 DragAndDrop = Pt_CB_DND,
661 Hotkey = Pt_CB_HOTKEY
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__>>
684 struct Callbacks<void, void, Dummy>
685 : Callbacks<PtRawCallback_t>
686 , Callbacks<PtCallback_t>
687 , Callbacks<PtHotkeyCallback_t>
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
859 using IPhWidgetsProperty::setArgument;
860 using IPhWidgetsProperty::getArgument;
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>::
871 Define::Struct<Arguments<PhPoint_t>::Struct,
PhPoint_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>::
881 Define::Link<Callbacks<PtCallback_t>::type,
PtCallback_t*>::
885 resource_type WidgetResourcesSingleton;
888 virtual void check();
892 void setAllowDrop(
bool);
893 bool getAllowDrop()
const;
895 void setEnabled(
bool);
896 bool getEnabled()
const;
898 void setHelpTopic(std::string);
899 std::string getHelpTopic()
const;
907 short getBottom()
const;
912 bool getCanFocus()
const;
914 bool getCanSelect()
const;
916 bool getContainsFocus()
const;
918 bool getFocused()
const;
920 bool hasChildren()
const;
921 bool hasParent()
const;
924 short getLeft()
const;
926 void setTag(
const void*, std::size_t);
927 const void * getTag()
const;
930 short getTop()
const;
932 short getRight()
const;
934 void setVisible(
bool);
935 bool getVisible()
const;
937 bool getIsRealized()
const;
942 std::set<Widget> getWidgets()
const;
1239 void SetBounds(
short x,
short y,
unsigned short width,
unsigned short height);
1438 phbitmask<unsigned, Flags::Anchor::type, Flags::Anchor::All>::
1477 property<short, property<>::ro>::bind<Widget, &Widget::getBottom>
Bottom;
1513 property<PhArea_t>::bind<
Widget, &Widget::getBounds, &Widget::setBounds>
Bounds;
1535 property<bool, property<>::ro>::bind<Widget, &Widget::getCanFocus>
CanFocus;
1556 property<bool, property<>::ro>::bind<Widget, &Widget::getCanSelect>
CanSelect;
1577 property<bool, property<>::ro>::bind<Widget, &Widget::getContainsFocus>
ContainsFocus;
1630 property<PhWidgets::Cursor>::bind<
Widget, &Widget::getCursor, &Widget::setCursor>
Cursor;
1705 property<bool, property<>::ro>::bind<Widget, &Widget::getFocused>
Focused;
1718 property<bool, property<>::ro>::bind<Widget, &Widget::hasChildren>
HasChildren;
1731 property<bool, property<>::ro>::bind<Widget, &Widget::hasParent>
HasParent;
1758 property<std::string>::bind<
Widget, &Widget::getHelpTopic, &Widget::setHelpTopic>
HelpTopic;
1775 property<bool, property<>::ro>::bind<Widget, &Widget::getIsRealized>
IsRealized;
1794 property<short>::bind<
Widget, &Widget::getLeft, &Widget::setLeft>
Left;
1816 property<PhPoint_t>::bind<
Widget, &Widget::getLocation, &Widget::setLocation>
Location;
1867 property<PtWidget_t*>::bind<
Widget, &Widget::getParent, &Widget::setParent>
Parent;
1911 property<short, property<>::ro>::bind<Widget, &Widget::getRight>
Right;
2051 tag_property<Widget, &Widget::getTag, &Widget::setTag>
Tag;
2070 property<short>::bind<
Widget, &Widget::getTop, &Widget::setTop>
Top;
2125 property<std::set<PhWidgets::Widget>, property<>::ro>::bind<Widget, &Widget::getWidgets>
Widgets;
2144 phbitmask<unsigned long, Flags::Extended::type>::
2171 phbitmask<long, Flags::type>::
2174 phbitmask<long, Flags::Resize::type>::
2235 template<
class W
idgetT>
2238 template<
class W
idgetT>
2243 cppproperties::detail::is_convertable<
2244 typename stdex::remove_cv<WidgetT>::type,
2248 >::type widget)
throw()
2251 WidgetT result = widget;
2254 catch(
const std::exception&)
2263 cppbitmasks::bitmask<
2266 PhWidgets::Widget::Flags::Anchor::All
2268 anchor_flags_bitmask;