diff --git a/src/Basic.cpp b/src/Basic.cpp index cb04d30b..50b316ad 100644 --- a/src/Basic.cpp +++ b/src/Basic.cpp @@ -72,57 +72,37 @@ Basic &Basic::operator=(const Basic &rhs) return *this; } -void Basic::setColor(PgColor_t val) -{ - resource.argument[Arguments::color].set(val); -} - -PgColor_t Basic::getColor() const -{ - return resource.argument[Arguments::color].get(); -} - -void Basic::setFillColor(PgColor_t val) -{ - resource.argument[Arguments::fill_color].set(val); -} - -PgColor_t Basic::getFillColor() const -{ - return resource.argument[Arguments::fill_color].get(); -} - void PhWidgets::Basic::OnActivated(PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::activate].get(), info); + resource.callback[Callback::activate].raise(info); } void PhWidgets::Basic::OnArmed(PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::arm].get(), info); + resource.callback[Callback::arm].raise(info); } void PhWidgets::Basic::OnDisarmed(PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::disarm].get(), info); + resource.callback[Callback::disarm].raise(info); } void PhWidgets::Basic::OnGotFocused(PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::got_focus].get(), info); + resource.callback[Callback::got_focus].raise(info); } void PhWidgets::Basic::OnLostFocus(PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::lost_focus].get(), info); + resource.callback[Callback::lost_focus].raise(info); } void PhWidgets::Basic::OnMenu(PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::menu].get(), info); + resource.callback[Callback::menu].raise(info); } void PhWidgets::Basic::OnRepeat(PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::repeat].get(), info); + resource.callback[Callback::repeat].raise(info); } diff --git a/src/Basic.h b/src/Basic.h index 44d3e0ed..4cbe3371 100644 --- a/src/Basic.h +++ b/src/Basic.h @@ -106,21 +106,21 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgUnsignedShort { - using ThisArgs::ArgUnsignedShort::eArgUnsignedShort; + typedef ThisArgs::ArgUnsignedShort::eArgUnsignedShort eArgUnsignedShort; }; struct ArgUnsignedLong: public ArgumentsEx, public ThisArgs::ArgUnsignedLong { - using ThisArgs::ArgUnsignedLong::eArgUnsignedLong; + typedef ThisArgs::ArgUnsignedLong::eArgUnsignedLong eArgUnsignedLong; }; struct ArgColor: public ArgumentsEx, public ThisArgs::ArgColor { - using ThisArgs::ArgColor::eArgColor; + typedef ThisArgs::ArgColor::eArgColor eArgColor; }; struct ArgChar: @@ -142,14 +142,14 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgPChar { - using ThisArgs::ArgPChar::eArgPChar; + typedef ThisArgs::ArgPChar::eArgPChar eArgPChar; }; struct Callback: public ArgumentsEx, public Widget::Callback { - using ThisCallbacks::Callback::eCallback; + typedef ThisCallbacks::Callback::eCallback eCallback; }; struct Arguments: @@ -186,12 +186,6 @@ namespace PhWidgets resource_type WidgetResourcesSingleton; virtual void check(); - - void setColor(PgColor_t); - PgColor_t getColor() const; - - void setFillColor(PgColor_t); - PgColor_t getFillColor() const; public: Basic(int abn); @@ -203,8 +197,8 @@ namespace PhWidgets WidgetResourcesSingleton resource; - property::bind Color; - property::bind FillColor; + phproperty::bind Color; + phproperty::bind FillColor; phwidgets_event Activate; phwidgets_event Arm; diff --git a/src/Button.cpp b/src/Button.cpp index aaa42b76..0bd73f00 100644 --- a/src/Button.cpp +++ b/src/Button.cpp @@ -40,14 +40,4 @@ Button &Button::operator=(const Button &rhs) static_cast(*this) = static_cast(rhs); return *this; -} - -void Button::setArmColor(PgColor_t val) -{ - resource.argument[Arguments::arm_color].set(val); -} - -PgColor_t Button::getArmColor() const -{ - return resource.argument[Arguments::arm_color].get(); } \ No newline at end of file diff --git a/src/Button.h b/src/Button.h index 96b6111b..20a56e3e 100644 --- a/src/Button.h +++ b/src/Button.h @@ -46,21 +46,21 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgColor { - using ThisArgs::ArgColor::eArgColor; + typedef ThisArgs::ArgColor::eArgColor eArgColor; }; struct ArgUnsignedChar: public ArgumentsEx, public ThisArgs::ArgUnsignedChar { - using ThisArgs::ArgUnsignedChar::eArgUnsignedChar; + typedef ThisArgs::ArgUnsignedChar::eArgUnsignedChar eArgUnsignedChar; }; struct ArgPImage: public ArgumentsEx, public ThisArgs::ArgPImage { - using ThisArgs::ArgPImage::eArgPImage; + typedef ThisArgs::ArgPImage::eArgPImage eArgPImage; }; @@ -83,9 +83,6 @@ namespace PhWidgets virtual void check(); - void setArmColor(PgColor_t); - PgColor_t getArmColor() const; - public: WidgetResourcesSingleton resource; @@ -97,7 +94,7 @@ namespace PhWidgets Button &operator=(const Button &rhs); - property::bind ArmColor; + phproperty::bind ArmColor; }; } diff --git a/src/Container.h b/src/Container.h index 46367ed7..b49fdfc0 100644 --- a/src/Container.h +++ b/src/Container.h @@ -114,7 +114,7 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgLong { - using ThisArgs::ArgLong::eArgLong; + typedef ThisArgs::ArgLong::eArgLong eArgLong; }; struct ArgInt: @@ -142,7 +142,7 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgPVoid { - using ThisArgs::ArgPVoid::eArgPVoid; + typedef ThisArgs::ArgPVoid::eArgPVoid eArgPVoid; }; struct ArgPRowLayoutInfo: @@ -155,14 +155,14 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgPChar { - using ThisArgs::ArgPChar::eArgPChar; + typedef ThisArgs::ArgPChar::eArgPChar eArgPChar; }; struct Callback: public ArgumentsEx, public Basic::Callback { - using ThisCallbacks::Callback::eCallback; + typedef ThisCallbacks::Callback::eCallback eCallback; }; struct Arguments: diff --git a/src/Label.cpp b/src/Label.cpp index f1c6b9db..19d9dac5 100644 --- a/src/Label.cpp +++ b/src/Label.cpp @@ -54,13 +54,3 @@ void Label::setCaption(std::string caption) resource.argument[Arguments::text_string].set(caption.c_str()); } -void Label::setBalloonColor(PgColor_t val) -{ - resource.argument[Arguments::balloon_color].set(val); -} - -PgColor_t Label::getBalloonColor() const -{ - return resource.argument[Arguments::balloon_color].get(); -} - diff --git a/src/Label.h b/src/Label.h index ff74537d..a1ba0e7d 100644 --- a/src/Label.h +++ b/src/Label.h @@ -118,14 +118,14 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgPChar { - using ThisArgs::ArgPChar::eArgPChar; + typedef ThisArgs::ArgPChar::eArgPChar eArgPChar; }; struct ArgColor: public ArgumentsEx, public ThisArgs::ArgColor { - using ThisArgs::ArgColor::eArgColor; + typedef ThisArgs::ArgColor::eArgColor eArgColor; }; struct ArgShort: @@ -137,7 +137,7 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgUnsignedShort { - using ThisArgs::ArgUnsignedShort::eArgUnsignedShort; + typedef ThisArgs::ArgUnsignedShort::eArgUnsignedShort eArgUnsignedShort; }; struct ArgSignedShort: @@ -149,7 +149,7 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgUnsignedChar { - using ThisArgs::ArgUnsignedChar::eArgUnsignedChar; + typedef ThisArgs::ArgUnsignedChar::eArgUnsignedChar eArgUnsignedChar; }; struct ArgPWidget: @@ -161,7 +161,7 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgChar { - using ThisArgs::ArgChar::eArgChar; + typedef ThisArgs::ArgChar::eArgChar eArgChar; }; struct ArgPImage: @@ -207,9 +207,6 @@ namespace PhWidgets std::string getCaption() const; void setCaption(std::string caption); - void setBalloonColor(PgColor_t); - PgColor_t getBalloonColor() const; - virtual void check(); public: @@ -223,7 +220,8 @@ namespace PhWidgets Label &operator=(const Label &rhs); property::bind Caption; - property::bind BalloonColor; + + phproperty::bind BalloonColor; }; } diff --git a/src/Numeric.h b/src/Numeric.h index 9550d660..b0ba13ca 100644 --- a/src/Numeric.h +++ b/src/Numeric.h @@ -52,7 +52,7 @@ namespace PhWidgets public ThisArgs::ArgUnsignedShort, public ThisArgs::ArgUnsignedShortFlag { - using ThisArgs::ArgUnsignedShort::eArgUnsignedShort; + typedef ThisArgs::ArgUnsignedShort::eArgUnsignedShort eArgUnsignedShort; }; @@ -61,7 +61,7 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgPChar { - using ThisArgs::ArgPChar::eArgPChar; + typedef ThisArgs::ArgPChar::eArgPChar eArgPChar; }; struct Arguments: diff --git a/src/NumericFloat.h b/src/NumericFloat.h index 01a59bb0..a029642b 100644 --- a/src/NumericFloat.h +++ b/src/NumericFloat.h @@ -63,7 +63,7 @@ namespace PhWidgets public ArgumentsEx, public Numeric::Callback { - using ThisCallbacks::Callback::eCallback; + typedef ThisCallbacks::Callback::eCallback eCallback; }; diff --git a/src/NumericInteger.cpp b/src/NumericInteger.cpp index eb498cee..c6b34f9c 100644 --- a/src/NumericInteger.cpp +++ b/src/NumericInteger.cpp @@ -59,36 +59,5 @@ NumericInteger &NumericInteger::operator=(const NumericInteger &rhs) return *this; } -int NumericInteger::getValue() const -{ - return resource.argument[Arguments::numeric_value].get(); -} - -void NumericInteger::setValue(int val) -{ - resource.argument[Arguments::numeric_value].set(val); -} - -int NumericInteger::getMaxValue() const -{ - return resource.argument[Arguments::numeric_max].get(); -} - -void NumericInteger::setMaxValue(int val) -{ - resource.argument[Arguments::numeric_max].set(val); -} - - -int NumericInteger::getMinValue() const -{ - return resource.argument[Arguments::numeric_min].get(); -} - -void NumericInteger::setMinValue(int val) -{ - resource.argument[Arguments::numeric_min].set(val); -} - diff --git a/src/NumericInteger.h b/src/NumericInteger.h index def9c8cd..8e4a8da8 100644 --- a/src/NumericInteger.h +++ b/src/NumericInteger.h @@ -49,7 +49,7 @@ namespace PhWidgets public ArgumentsEx, public Numeric::Callback { - using ThisCallbacks::Callback::eCallback; + typedef ThisCallbacks::Callback::eCallback eCallback; }; @@ -75,15 +75,7 @@ namespace PhWidgets resource_type WidgetResourcesSingleton; virtual void check(); - - int getValue() const; - void setValue(int); - - int getMaxValue() const; - void setMaxValue(int); - - int getMinValue() const; - void setMinValue(int); + public: WidgetResourcesSingleton resource; @@ -95,9 +87,9 @@ namespace PhWidgets NumericInteger &operator=(const NumericInteger &rhs); - property::bind Value; - property::bind MaxValue; - property::bind MinValue; + phproperty::bind Value; + phproperty::bind MaxValue; + phproperty::bind MinValue; phwidgets_event NumericChanged; }; diff --git a/src/OnOffButton.cpp b/src/OnOffButton.cpp index ebc6c544..432eeb21 100644 --- a/src/OnOffButton.cpp +++ b/src/OnOffButton.cpp @@ -61,13 +61,4 @@ void OnOffButton::Uncheck(bool val) resource.argument[Arguments::onoff_state].set(false); } -void OnOffButton::setChecked(bool val) -{ - resource.argument[Arguments::onoff_state].set(val); -} - -bool OnOffButton::getChecked() const -{ - return resource.argument[Arguments::onoff_state].get(); -} diff --git a/src/OnOffButton.h b/src/OnOffButton.h index 14e6c80b..a0302c01 100644 --- a/src/OnOffButton.h +++ b/src/OnOffButton.h @@ -45,7 +45,7 @@ namespace PhWidgets public ArgumentsEx, public Button::Callback { - using ThisCallbacks::Callback::eCallback; + typedef ThisCallbacks::Callback::eCallback eCallback; }; @@ -70,9 +70,6 @@ namespace PhWidgets resource_type WidgetResourcesSingleton; virtual void check(); - - void setChecked(bool val); - bool getChecked() const; public: WidgetResourcesSingleton resource; @@ -84,10 +81,10 @@ namespace PhWidgets OnOffButton &operator=(const OnOffButton &rhs); - void Check(bool val); - void Uncheck(bool val); + void Check(bool val = true); + void Uncheck(bool val = true); - property::bind Checked; + phproperty::bind Checked; phwidgets_event NewValue; }; diff --git a/src/Text.h b/src/Text.h index 206530d7..46e74727 100644 --- a/src/Text.h +++ b/src/Text.h @@ -52,7 +52,7 @@ namespace PhWidgets public ArgumentsEx, public Label::Callback { - using ThisCallbacks::Callback::eCallback; + typedef ThisCallbacks::Callback::eCallback eCallback; }; @@ -94,7 +94,7 @@ namespace PhWidgets phwidgets_event MotionVerify; phwidgets_event TextChanged; }; - + } diff --git a/src/Timer.cpp b/src/Timer.cpp index 7fa1a530..c737d72d 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -57,27 +57,7 @@ Timer &Timer::operator=(const Timer &rhs) return *this; } -void Timer::setInitial(unsigned long val) -{ - resource.argument[Arguments::timer_initial].set(val); -} - -unsigned long Timer::getInitial() const -{ - return resource.argument[Arguments::timer_initial].get(); -} - -void Timer::setRepeat(unsigned long val) -{ - resource.argument[Arguments::timer_repeat].set(val); -} - -unsigned long Timer::getRepeat() const -{ - return resource.argument[Arguments::timer_repeat].get(); -} - void Timer::OnActivate(PtCallbackInfo_t *info) { - onEvent(resource.callback[Callback::timer_activate].get(), info); + resource.callback[Callback::timer_activate].raise(info); } \ No newline at end of file diff --git a/src/Timer.h b/src/Timer.h index 308fc165..66786edd 100644 --- a/src/Timer.h +++ b/src/Timer.h @@ -14,6 +14,7 @@ namespace PhWidgets protected Widget { public: + using Widget::IPhWidgetsProperty; struct ThisArgs { @@ -57,7 +58,7 @@ namespace PhWidgets public ArgumentsEx, public Widget::Callback { - using ThisCallbacks::Callback::eCallback; + typedef ThisCallbacks::Callback::eCallback eCallback; }; struct Arguments: @@ -73,7 +74,8 @@ namespace PhWidgets { }; - + private: + protected: typedef ResourceFrom:: Define::Scalar:: @@ -83,12 +85,6 @@ namespace PhWidgets resource_type WidgetResourcesSingleton; virtual void check(); - - void setInitial(unsigned long); - unsigned long getInitial() const; - - void setRepeat(unsigned long); - unsigned long getRepeat() const; public: WidgetResourcesSingleton resource; @@ -106,8 +102,8 @@ namespace PhWidgets using Widget::operator PtWidget_t*; using Widget::operator const PtWidget_t*; - property::bind Initial; - property::bind Interval; + phproperty::bind Initial; + phproperty::bind Interval; Widget::Enabled; phwidgets_event Activate; diff --git a/src/ToggleButton.h b/src/ToggleButton.h index 4000de9e..4a2f36f5 100644 --- a/src/ToggleButton.h +++ b/src/ToggleButton.h @@ -40,7 +40,7 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgUnsignedChar { - using ThisArgs::ArgUnsignedChar::eArgUnsignedChar; + typedef ThisArgs::ArgUnsignedChar::eArgUnsignedChar eArgUnsignedChar; }; @@ -49,7 +49,7 @@ namespace PhWidgets public ArgumentsEx, public ThisArgs::ArgColor { - using ThisArgs::ArgColor::eArgColor; + typedef ThisArgs::ArgColor::eArgColor eArgColor; }; struct Arguments: @@ -82,8 +82,8 @@ namespace PhWidgets ToggleButton &operator=(const ToggleButton &rhs); - void Check(bool val); - void Uncheck(bool val); + void Check(bool val = true); + void Uncheck(bool val = true); property::bind Checked; }; diff --git a/src/Widget.cpp b/src/Widget.cpp index af138c61..50a1a957 100644 --- a/src/Widget.cpp +++ b/src/Widget.cpp @@ -121,11 +121,11 @@ Widget::Widget(int abn): resource(this), //properties: Enabled(this), + HelpTopic(this), Width(this), Height(this), - Size(this), BevelWidth(this), - HelpTopic(this), + Size(this), Location(this), //callbacks: Destroyed(this), @@ -148,11 +148,11 @@ Widget::Widget(PtWidget_t* wdg): resource(this), //properties: Enabled(this), + HelpTopic(this), Width(this), Height(this), - Size(this), BevelWidth(this), - HelpTopic(this), + Size(this), Location(this), //callbacks: Destroyed(this), @@ -212,11 +212,11 @@ Widget::Widget(const Widget &rhs): resource(this), //properties: Enabled(this), + HelpTopic(this), Width(this), Height(this), - Size(this), BevelWidth(this), - HelpTopic(this), + Size(this), Location(this), //callbacks: Destroyed(this), @@ -266,45 +266,39 @@ Widget::operator const PtWidget_t*() const return widget(); } -void Widget::onEvent(PtCallbackList_t *cl, PtCallbackInfo_t * info) -{ - - if (nullptr == cl) - return; - - PtWidget_t *w = widget(); - - PtInvokeCallbackList(cl, w, info); -} - void Widget::OnDestroyed( PtCallbackInfo_t * info) { - onEvent( resource.callback[Callback::destroyed].get(), info); + resource.callback[Callback::destroyed].raise(info); } void PhWidgets::Widget::OnBlocked( PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::blocked].get(), info); + resource.callback[Callback::blocked].raise(info); } void PhWidgets::Widget::OnDragDrop( PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::dnd].get(), info); + resource.callback[Callback::dnd].raise(info); } void PhWidgets::Widget::OnOutbound( PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::outbound].get(), info); + resource.callback[Callback::outbound].raise(info); } void PhWidgets::Widget::OnRealized( PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::realized].get(), info); + resource.callback[Callback::realized].raise(info); } void PhWidgets::Widget::OnUnrealized( PtCallbackInfo_t * info) { - onEvent(resource.callback[Callback::unrealized].get(), info); + resource.callback[Callback::unrealized].raise(info); +} + +Widget::operator PtWidget_t*() +{ + return widget(); } //for properties: @@ -318,70 +312,12 @@ bool Widget::getEnabled() const return resource.argument[Arguments::flags].get(Pt_BLOCKED); } -void Widget::setWidth(unsigned short val) -{ - resource.argument[Arguments::width].set(val); -} - -unsigned short Widget::getWidth() const -{ - return resource.argument[Arguments::width].get(); -} - -void Widget::setHeight(unsigned short val) -{ - resource.argument[Arguments::height].set(val); -} - -unsigned short Widget::getHeight() const -{ - return resource.argument[Arguments::height].get(); -} - -void Widget::setDim(PhDim_t val) -{ - resource.argument[Arguments::dim].set(val); -} - -PhDim_t Widget::getDim() const -{ - return resource.argument[Arguments::dim].get(); -} - -void Widget::setBevelWidth(unsigned short val) -{ - resource.argument[Arguments::bevel_width].set(val); -} - -unsigned short Widget::getBevelWidth() const -{ - return resource.argument[Arguments::bevel_width].get(); -} - -void Widget::setHelpTopic(std::string val) +void PhWidgets::Widget::setHelpTopic(std::string val) { resource.argument[Arguments::help_topic].set(val.c_str()); } -std::string Widget::getHelpTopic() const +std::string PhWidgets::Widget::getHelpTopic() const { return resource.argument[Arguments::help_topic].get(); } - -void Widget::setLocation(PhPoint_t val) -{ - resource.argument[Arguments::pos].set(val); -} - - -PhPoint_t Widget::getLocation() const -{ - return resource.argument[Arguments::pos].get(); -} - - - -Widget::operator PtWidget_t*() -{ - return widget(); -} \ No newline at end of file diff --git a/src/Widget.h b/src/Widget.h index e3ef2bde..dba94519 100644 --- a/src/Widget.h +++ b/src/Widget.h @@ -13,7 +13,7 @@ #include "./service/mystd/my_exception.h" #include "./service/stdex/stdex.h" -#include "./service/property.hpp" +#include "./service/phproperty.hpp" #include "./service/phevent.hpp" #include "./WidgetResource.hpp" @@ -30,51 +30,73 @@ namespace PhWidgets using namespace phevents; class Widget: - protected detail::IPtWidget + protected detail::IPtWidget, + public IPhWidgetsProperty { public: + + typedef phevent::ph_callback_t callback_t;//!< An event handler that is raised when an \link Widget::phwidgets_event event \endlink occur. //! An event, which raise a notification to registered subscribers (event handlers) that something of interest has occurred. //! Event handlers must be Widget::callback_t type or convertable to it. - template + template class phwidgets_event { - typedef phevent::ph_callback_t value_t; - + public: phwidgets_event(ParentT *parent) : _obj(parent) {} - inline void add(value_t value) + //! add an event handler + inline void add(callback_t value) { - _obj->resource.callback[callback].add(value); + _obj->resource.callback[CallbackID].add(value); } - inline void remove(value_t value) + //! remove an event handler + inline void remove(callback_t value) { - _obj->resource.callback[callback].remove(value); + _obj->resource.callback[CallbackID].remove(value); } - inline void operator+=(value_t value) + //! raise an event + + //! invokes all event handlers that are subscribed to this event + inline void raise(PtCallbackInfo_t * info) const + { + _obj->resource.callback[CallbackID].raise(info); + } + + //! add an event handler + inline void operator+=(callback_t value) { add(value); } - inline void operator-=(value_t value) + //! remove an event handler + inline void operator-=(callback_t value) { remove(value); } + //! raise an event + + //! invokes all event handlers that are subscribed to this event + inline void operator()(PtCallbackInfo_t * info) const + { + raise(info); + } + private: ParentT *_obj; phwidgets_event(const phwidgets_event &rhs); - inline phwidgets_event &operator=(value_t); + inline phwidgets_event &operator=(callback_t); inline phwidgets_event &operator=(phwidgets_event const &); }; @@ -172,8 +194,8 @@ namespace PhWidgets enum eArgPChar { help_topic = Pt_ARG_HELP_TOPIC //!< The meaning of this resource depends on the bits set in Pt_ARG_EFLAGS: - //!< If Pt_INTERNAL_HELP isn't set, Pt_ARG_HELP_TOPIC is used to set the topic position within the HTML help file. - //!< If Pt_INTERNAL_HELP is set, Pt_ARG_HELP_TOPIC is the help information to be displayed. + //!< If Pt_INTERNAL_HELP isn't set, Widget::ArgPChar::help_topic is used to set the topic position within the HTML help file. + //!< If Pt_INTERNAL_HELP is set, Widget::ArgPChar::help_topic is the help information to be displayed. }; }; @@ -431,6 +453,8 @@ namespace PhWidgets int _abn; mutable PtWidget_t *_widget; + using IPhWidgetsProperty::setArgument; + using IPhWidgetsProperty::getArgument; protected: @@ -469,26 +493,9 @@ namespace PhWidgets void setEnabled(bool); bool getEnabled() const; - - void setWidth(unsigned short); - unsigned short getWidth() const; - - void setHeight(unsigned short); - unsigned short getHeight() const; - void setDim(PhDim_t); - PhDim_t getDim() const; - - void setBevelWidth(unsigned short); - unsigned short getBevelWidth() const; - void setHelpTopic(std::string); std::string getHelpTopic() const; - - void setLocation(PhPoint_t); - PhPoint_t getLocation() const; - - void onEvent(PtCallbackList_t *cl, PtCallbackInfo_t * info); public: //! (constructor) @@ -531,31 +538,35 @@ namespace PhWidgets //! Resources of the Widget WidgetResourcesSingleton resource; - property::bind Enabled;//!< Gets or sets a value indicating whether the widget can respond to user interaction. - property::bind Width;//!< Gets or sets the width of the widget. - property::bind Height;//!< Gets or sets the hight of the widget. - property::bind Size;//!< Gets or sets the size of the widget. - property::bind BevelWidth;//!< Gets or sets the bevel width of the widget. - property::bind HelpTopic;//!< Gets or sets the help topic of the widget. - property::bind Location;//!< Gets or sets the location of the widget. - - phwidgets_event Destroyed;//!< Occurs when the widget is destroyed. - phwidgets_event Blocked;//!< Occurs when the widget is blocked. - phwidgets_event DragDrop;//!< Occurs when a drag-and-drop operation is completed. - phwidgets_event IsDestroyed;//!< Occurs when the widget's resources are being released. - phwidgets_event Outbound;//!< Occurs when you press the pointer button on the widget and then move out of the "hot spot" with the button still depressed. - phwidgets_event Realized;//!< Occurs when the widget is realized. - phwidgets_event Unrealized;//!< Occurs when the widget is unrealized. - - void OnDestroyed(PtCallbackInfo_t *info);//!< Raises the Widget::Destroyed event. - void OnBlocked(PtCallbackInfo_t *info);//!< Raises the Widget::Blocked event. - void OnDragDrop(PtCallbackInfo_t *info);//!< Raises the Widget::DragDrop event. - void OnOutbound(PtCallbackInfo_t *info);//!< Raises the Widget::Outbound event. - void OnRealized(PtCallbackInfo_t *info);//!< Raises the Widget::Realized event. - void OnUnrealized(PtCallbackInfo_t *info);//!< Raises the Widget::Unrealized event. + property::bind Enabled; //!< Gets or sets a value indicating whether the widget can respond to user interaction. + property::bind HelpTopic; //!< Gets or sets the help topic of the widget. + + phproperty::bind Width; //!< Gets or sets the width of the widget. + phproperty::bind Height; //!< Gets or sets the hight of the widget. + phproperty::bind BevelWidth; //!< Gets or sets the bevel width of the widget. + phproperty::bind Size; //!< Gets or sets the size of the widget. + phproperty::bind Location; //!< Gets or sets the position of the widget. + + phwidgets_event Destroyed; //!< Occurs when the widget is destroyed. + phwidgets_event Blocked; //!< Occurs when the widget is blocked. + phwidgets_event DragDrop; //!< Occurs when a drag-and-drop operation is completed. + phwidgets_event IsDestroyed; //!< Occurs when the widget's resources are being released. + phwidgets_event Outbound; //!< Occurs when you press the pointer button on the widget and then move out of the "hot spot" with the button still depressed. + phwidgets_event Realized; //!< Occurs when the widget is realized. + phwidgets_event Unrealized; //!< Occurs when the widget is unrealized. + + void OnDestroyed(PtCallbackInfo_t *info); //!< Raises the Widget::Destroyed event. + void OnBlocked(PtCallbackInfo_t *info); //!< Raises the Widget::Blocked event. + void OnDragDrop(PtCallbackInfo_t *info); //!< Raises the Widget::DragDrop event. + void OnOutbound(PtCallbackInfo_t *info); //!< Raises the Widget::Outbound event. + void OnRealized(PtCallbackInfo_t *info); //!< Raises the Widget::Realized event. + void OnUnrealized(PtCallbackInfo_t *info); //!< Raises the Widget::Unrealized event. - }; + + }; + + }//namespace PhWidgets diff --git a/src/WidgetResource.hpp b/src/WidgetResource.hpp index e4ca3073..6aecf72c 100644 --- a/src/WidgetResource.hpp +++ b/src/WidgetResource.hpp @@ -293,6 +293,18 @@ namespace PhWidgets return cl; } + inline void emitLink(PtCallbackInfo_t *info) const + { + PtCallbackList_t *cl = this->getLink(); + + if (nullptr == cl) + return; + + PtWidget_t *w = _rwidget->widget(); + + PtInvokeCallbackList(cl, w, info); + } + public: @@ -775,6 +787,11 @@ namespace PhWidgets { return this->getLink(); } + + inline void raise(PtCallbackInfo_t * info) const + { + this->emitLink(info); + } }; template @@ -816,6 +833,11 @@ namespace PhWidgets { return this->getLink(); } + + inline void raise(PtCallbackInfo_t * info) const + { + this->emitLink(info); + } }; template @@ -858,6 +880,11 @@ namespace PhWidgets { return this->getLink(); } + + inline void raise(PtCallbackInfo_t * info) const + { + this->emitLink(info); + } }; template @@ -900,6 +927,11 @@ namespace PhWidgets { return this->getLink(); } + + inline void raise(PtCallbackInfo_t * info) const + { + this->emitLink(info); + } }; template @@ -931,6 +963,11 @@ namespace PhWidgets { return this->getLink(); } + + inline void raise(PtCallbackInfo_t * info) const + { + this->emitLink(info); + } }; template @@ -962,6 +999,11 @@ namespace PhWidgets { return this->getLink(); } + + inline void raise(PtCallbackInfo_t * info) const + { + this->emitLink(info); + } }; struct WidgetCallbacksBase diff --git a/src/service/phproperty.hpp b/src/service/phproperty.hpp new file mode 100644 index 00000000..e9fcdd31 --- /dev/null +++ b/src/service/phproperty.hpp @@ -0,0 +1,178 @@ +#ifndef PH_PROPERTY_HPP +#define PH_PROPERTY_HPP + +#include "property.hpp" + +namespace PhWidgets +{ + struct IPhWidgetsProperty + { + template + inline ReturnT getArgument() const + { + return static_cast(this)->resource.argument[ArgumentID].get(); + } + + template + inline void setArgument(ValueT val) + { + static_cast(this)->resource.argument[ArgumentID].set(val); + } + }; + + template::flag)> + class phproperty{}; + + //phproperty: + template<> + class phproperty : + public cppproperties::detail::property_flag + { + public: + typedef cppproperties::detail::property_flag flags; + }; + + template<> + class phproperty : + public cppproperties::detail::property_flag + { + public: + typedef cppproperties::detail::property_flag flags; + }; + + template<> + class phproperty : + public cppproperties::detail::property_flag + { + public: + typedef cppproperties::detail::property_flag flags; + }; + + //phproperty: + template + class phproperty//ValueT == const... + { + typedef cppproperties::property cpp_property_t; + + template::getter_t Getter> + struct bind_internal : + public cpp_property_t::template bind + { + bind_internal(WidgetClassT *parent) : + cpp_property_t::template bind(parent) + {} + + private: + inline bind_internal &operator=(ValueT const &); + inline bind_internal &operator=(bind_internal const &); + }; + + public: + template + class bind : + public bind_internal< + IPhWidgetsProperty, + &IPhWidgetsProperty::getArgument + > + { + typedef bind_internal< + IPhWidgetsProperty, + &IPhWidgetsProperty::getArgument + > cpp_bind_t; + + public: + bind(WidgetClassT *parent) : + cpp_bind_t(parent) + {} + + private: + inline bind &operator=(ValueT const &); + inline bind &operator=(bind const &); + }; + }; + + + template + class phproperty//ValueT != const... + { + typedef cppproperties::property cpp_property_t; + + template::getter_t Getter, typename cppproperties::detail::get_parent_func::setter_t Setter> + struct bind_internal : + public cpp_property_t::template bind + { + bind_internal(WidgetClassT *parent) : + cpp_property_t::template bind(parent) + {} + + using cpp_property_t::template bind::operator=; + }; + + public: + + template + class bind : + public bind_internal< + IPhWidgetsProperty, + &IPhWidgetsProperty::getArgument, + &IPhWidgetsProperty::setArgument + > + { + typedef bind_internal< + IPhWidgetsProperty, + &IPhWidgetsProperty::getArgument, + &IPhWidgetsProperty::setArgument + > cpp_bind_t; + + public: + bind(WidgetClassT *parent) : + cpp_bind_t(parent) + {} + + using cpp_bind_t::operator=; + }; + + }; + + template + class phproperty//ValueT != const... + { + typedef cppproperties::property cpp_property_t; + + template::setter_t Setter> + struct bind_internal : + public cpp_property_t::template bind + { + bind_internal(WidgetClassT *parent) : + cpp_property_t::template bind(parent) + {} + + using cpp_property_t::template bind::operator=; + }; + + public: + template + class bind : + public bind_internal< + IPhWidgetsProperty, + &IPhWidgetsProperty::setArgument + > + { + typedef bind_internal< + IPhWidgetsProperty, + &IPhWidgetsProperty::setArgument + > cpp_bind_t; + + public: + bind(WidgetClassT *parent) : + cpp_bind_t(parent) + {} + + using cpp_bind_t::operator=; + }; + + }; +} + +#endif \ No newline at end of file diff --git a/src/service/property.hpp b/src/service/property.hpp index 4c1b0073..2cc93962 100644 --- a/src/service/property.hpp +++ b/src/service/property.hpp @@ -69,7 +69,7 @@ namespace cppproperties { }; - template + template struct flag_chooser : public flag_chooser_helper {