button.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #ifndef _BUTTON_H
  2. #define _BUTTON_H
  3. #include <bfc/string/bfcstring.h>
  4. #include <api/script/script.h>
  5. #include <api/wnd/wndclass/buttwnd.h>
  6. #include <api/script/objects/guiobj.h>
  7. #include <api/syscb/callbacks/corecbi.h>
  8. #include <api/wndmgr/layout.h>
  9. #include <api/wnd/wndclass/guiobjwnd.h>
  10. #include <api/service/svcs/svc_xuiobject.h>
  11. #define BUTTON_PARENT ButtonWnd
  12. class ComponentBucket2;
  13. class ScriptObject;
  14. class ButtonScriptController: public GuiObjectScriptController {
  15. public:
  16. virtual const wchar_t *getClassName();
  17. virtual const wchar_t *getAncestorClassName();
  18. virtual ScriptObjectController *getAncestorController() { return guiController; }
  19. virtual int getNumFunctions();
  20. virtual const function_descriptor_struct *getExportedFunctions();
  21. virtual GUID getClassGuid();
  22. virtual ScriptObject *instantiate();
  23. virtual void destroy(ScriptObject *o);
  24. virtual void *encapsulate(ScriptObject *o);
  25. virtual void deencapsulate(void *o);
  26. private:
  27. static function_descriptor_struct exportedFunction[];
  28. };
  29. extern ButtonScriptController *buttonController;
  30. namespace Wasabi // Apple defines "Button" so we're pretty much forced to namespace this... annoying
  31. {
  32. #ifdef WASABI_COMPILE_MEDIACORE
  33. class Button : public BUTTON_PARENT, public CoreCallbackI {
  34. #else
  35. class Button : public BUTTON_PARENT {
  36. #endif
  37. public:
  38. Button();
  39. virtual ~Button();
  40. virtual int onInit();
  41. virtual int setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *paramname, const wchar_t *strvalue);
  42. virtual void setParam(const wchar_t *p);
  43. virtual int getPreferences(int what);
  44. virtual const wchar_t *getParam();
  45. virtual int onLeftButtonUp(int x, int y);
  46. virtual int onLeftButtonDown(int x, int y);
  47. virtual void onLeftPush(int x, int y);
  48. virtual void onRightPush(int x, int y);
  49. virtual int onActivateButton(int is);
  50. virtual int childNotify(ifc_window *child, int msg, intptr_t param1, intptr_t param2);
  51. virtual int wantAutoContextMenu();
  52. #ifdef WASABI_WIDGETS_COMPBUCK
  53. virtual void setCBTarget(const wchar_t *t);
  54. #endif
  55. virtual void setAction(const wchar_t *action);
  56. virtual int onShowWindow(Container *c, GUID guid, const wchar_t *groupid);
  57. virtual int onHideWindow(Container *c, GUID guid, const wchar_t *groupid);
  58. protected:
  59. /*static */void CreateXMLParameters(int master_handle);
  60. #ifdef WASABI_COMPILE_MEDIACORE
  61. virtual int corecb_onEQStatusChange(int newval);
  62. virtual int corecb_onEQAutoChange(int newval);
  63. #endif
  64. StringW s_normal, s_down, s_hover, s_active;
  65. int btn_getXuiHandle() { return xuihandle; }
  66. int retcode;
  67. virtual void setupBitmaps();
  68. enum {
  69. BUTTON_TEXT = 0,
  70. BUTTON_ACTION,
  71. BUTTON_IMAGE,
  72. BUTTON_DOWNIMAGE,
  73. BUTTON_HOVERIMAGE,
  74. BUTTON_ACTIVEIMAGE,
  75. BUTTON_PARAM,
  76. BUTTON_RECTRGN,
  77. BUTTON_CBTARGET,
  78. BUTTON_BORDERS,
  79. BUTTON_BORDERSTYLE,
  80. BUTTON_RETCODE,
  81. BUTTON_ACTIONTARGET,
  82. BUTTON_CENTER_IMAGE,
  83. BUTTON_TEXTCOLOR,
  84. BUTTON_TEXTHOVERCOLOR,
  85. BUTTON_TEXTDIMMEDCOLOR,
  86. BUTTON_NUMPARAMS,
  87. };
  88. private:
  89. StringW param;
  90. StringW action, actionstr, actionname;
  91. StringW action_target;
  92. ComponentBucket2 *cbtarget;
  93. int borders;
  94. int disablenextcontextmenu;
  95. int xuihandle;
  96. static XMLParamPair params[];
  97. public:
  98. static scriptVar script_vcpu_setActivatedNoCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v);
  99. static scriptVar script_vcpu_onLeftClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  100. static scriptVar script_vcpu_onRightClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  101. static scriptVar script_vcpu_leftClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  102. static scriptVar script_vcpu_rightClick(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  103. static scriptVar script_vcpu_setActivated(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v);
  104. static scriptVar script_vcpu_getActivated(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  105. static scriptVar script_vcpu_onActivate(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v);
  106. };
  107. }
  108. extern const wchar_t buttonXuiObjectStr[];
  109. extern char buttonXuiSvcName[];
  110. class ButtonXuiSvc : public XuiObjectSvc<Wasabi::Button, buttonXuiObjectStr, buttonXuiSvcName> {};
  111. #endif