tgbutton.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef _TOGGLEBUTTON_H
  2. #define _TOGGLEBUTTON_H
  3. #include <api/script/script.h>
  4. #include <api/script/scriptobj.h>
  5. #include <api/skin/widgets/button.h>
  6. #define TOGGLEBUTTON_PARENT Wasabi::Button
  7. class TgButtonScriptController : public ButtonScriptController {
  8. public:
  9. virtual const wchar_t *getClassName();
  10. virtual const wchar_t *getAncestorClassName();
  11. virtual ScriptObjectController *getAncestorController() { return buttonController; }
  12. virtual int getNumFunctions();
  13. virtual const function_descriptor_struct *getExportedFunctions();
  14. virtual GUID getClassGuid();
  15. virtual ScriptObject *instantiate();
  16. virtual void destroy(ScriptObject *o);
  17. virtual void *encapsulate(ScriptObject *o);
  18. virtual void deencapsulate(void *o);
  19. private:
  20. static function_descriptor_struct exportedFunction[];
  21. };
  22. extern TgButtonScriptController *tgbuttonController;
  23. class ToggleButton : public TOGGLEBUTTON_PARENT {
  24. public:
  25. ToggleButton();
  26. virtual ~ToggleButton();
  27. virtual void onLeftPush(int x, int y);
  28. virtual void onToggle(int i);
  29. virtual int setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *name, const wchar_t *value);
  30. #ifdef WASABI_COMPILE_CONFIG
  31. virtual int onReloadConfig();
  32. #endif
  33. virtual void autoToggle();
  34. virtual const wchar_t *vcpu_getClassName();
  35. virtual ScriptObjectController *vcpu_getController() { return tgbuttonController; }
  36. virtual int getCurCfgVal();
  37. protected:
  38. /*static */void CreateXMLParameters(int master_handle);
  39. enum {
  40. TOGGLEBUTTON_AUTOTOGGLE=0,
  41. #ifdef WASABI_COMPILE_CONFIG
  42. TOGGLEBUTTON_CFGVAL,
  43. #endif
  44. };
  45. private:
  46. static XMLParamPair params[];
  47. wchar_t *param;
  48. int autotoggle;
  49. #ifdef WASABI_COMPILE_CONFIG
  50. int cfgVal;
  51. #endif
  52. int xuihandle;
  53. public:
  54. static scriptVar script_onToggle(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar is);
  55. static scriptVar script_getCurCfgVal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  56. };
  57. extern const wchar_t toggleButtonXuiObjectStr[];
  58. extern char toggleButtonXuiSvcName[];
  59. class ToggleButtonXuiSvc : public XuiObjectSvc<ToggleButton, toggleButtonXuiObjectStr, toggleButtonXuiSvcName> {};
  60. // {80F97426-9A10-472c-82E7-8309AA4789E7}
  61. static const GUID NStatesTgButtonGuid =
  62. { 0x80f97426, 0x9a10, 0x472c, { 0x82, 0xe7, 0x83, 0x9, 0xaa, 0x47, 0x89, 0xe7 } };
  63. #define NSTATESTGBUTTON_PARENT ToggleButton
  64. class NStatesTgButton : public NSTATESTGBUTTON_PARENT {
  65. public:
  66. NStatesTgButton();
  67. virtual ~NStatesTgButton();
  68. virtual int setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *paramname, const wchar_t *strvalue);
  69. void setNStates(int n) { nstates = n; }
  70. virtual int onInit();
  71. void setState(int n);
  72. virtual int getActivatedButton();
  73. virtual void autoToggle();
  74. int getState() { return state; }
  75. virtual void setActivatedButton(int a);
  76. virtual int getCurCfgVal();
  77. void setOneVisualState(int v);
  78. protected:
  79. /*static */void CreateXMLParameters(int master_handle);
  80. virtual void setupBitmaps();
  81. enum {
  82. NSTATESTGBUTTON_NSTATES=0,
  83. #ifdef WASABI_COMPILE_CONFIG
  84. NSTATESTGBUTTON_CFGVALS,
  85. #endif
  86. NSTATESTGBUTTON_ONEVSTATE,
  87. };
  88. StringW image, hover, down, active;
  89. int nstates;
  90. int state;
  91. int onevstate;
  92. #ifdef WASABI_COMPILE_CONFIG
  93. StringW cfgvals;
  94. #endif
  95. private:
  96. static XMLParamPair params[];
  97. int xuihandle;
  98. };
  99. extern const wchar_t nStatesTgButtonXuiObjectStr[];
  100. extern char nStatesTgButtonXuiSvcName[];
  101. class nStatesTgButtonXuiSvc : public XuiObjectSvc<NStatesTgButton, nStatesTgButtonXuiObjectStr, nStatesTgButtonXuiSvcName> {};
  102. #endif