1
0

xuicheckbox.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef __SCRIPTCHECKBOX_H
  2. #define __SCRIPTCHECKBOX_H
  3. #include <api/skin/widgets/checkbox.h>
  4. #include <api/script/objects/c_script/h_guiobject.h>
  5. #include <api/script/objcontroller.h>
  6. #include <api/wnd/accessible.h>
  7. #define SCRIPTCHECKBOX_PARENT CheckBox
  8. // -----------------------------------------------------------------------
  9. // Your wnd object class
  10. class ScriptCheckBox : public SCRIPTCHECKBOX_PARENT {
  11. public:
  12. ScriptCheckBox();
  13. virtual ~ScriptCheckBox();
  14. // XuiObject automatically calls this back for all parameters registered using addParam
  15. // encountered in the xml source
  16. virtual int setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value);
  17. virtual void onToggle();
  18. virtual int accessibility_getState() { return CHECKBOX_PARENT::accessibility_getState() | (isActivated() ? STATE_SYSTEM_CHECKED : 0); }
  19. protected:
  20. /*static */void CreateXMLParameters(int master_handle);
  21. private:
  22. // a list of IDs for our xml attributes, we use them in addParam() in the constructor
  23. enum {
  24. SCRIPTCHECKBOX_TEXT = 0,
  25. SCRIPTCHECKBOX_RADIOID,
  26. SCRIPTCHECKBOX_RADIOVAL,
  27. SCRIPTCHECKBOX_ACTION,
  28. SCRIPTCHECKBOX_ACTIONPARAM,
  29. SCRIPTCHECKBOX_ACTIONTARGET,
  30. };
  31. int myxuihandle;
  32. static XMLParamPair params[];
  33. };
  34. // -----------------------------------------------------------------------------------------------------
  35. class CheckBoxController : public ScriptObjectControllerI {
  36. public:
  37. virtual const wchar_t *getClassName() { return L"Checkbox"; }
  38. virtual const wchar_t *getAncestorClassName() { return L"GuiObject"; }
  39. virtual ScriptObjectController *getAncestorController() { return WASABI_API_MAKI->maki_getController(guiObjectGuid); }
  40. virtual int getNumFunctions();
  41. virtual const function_descriptor_struct *getExportedFunctions();
  42. virtual GUID getClassGuid() { return checkBoxGuid; }
  43. virtual ScriptObject *instantiate();
  44. virtual void destroy(ScriptObject *o);
  45. virtual void *encapsulate(ScriptObject *o);
  46. virtual void deencapsulate(void *o);
  47. public:
  48. static scriptVar onToggle(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newstate);
  49. static scriptVar setChecked(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar state);
  50. static scriptVar isChecked(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  51. static scriptVar setText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar text);
  52. static scriptVar getText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  53. private:
  54. static function_descriptor_struct exportedFunction[];
  55. };
  56. extern CheckBoxController *checkBoxController;
  57. // -----------------------------------------------------------------------
  58. // This defines the svc_xuiObject that exposes your wnd object
  59. extern const wchar_t ScriptCheckBoxXuiObjectStr[];
  60. extern char ScriptCheckBoxXuiSvcName[];
  61. class ScriptCheckBoxXuiSvc : public XuiObjectSvc<ScriptCheckBox, ScriptCheckBoxXuiObjectStr, ScriptCheckBoxXuiSvcName> {};
  62. #endif