xuibrowser.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef __XUIBROWSER_H
  2. #define __XUIBROWSER_H
  3. #include <api/skin/widgets/mb/minibrowserwnd.h>
  4. #include <api/script/objcontroller.h>
  5. #define MAIN_BROWSER_ATOM_NAME L"browser.main.object"
  6. #define SCRIPTBROWSERWND_PARENT MiniBrowserWnd
  7. // -----------------------------------------------------------------------------------------------------
  8. class ScriptBrowserWnd : public SCRIPTBROWSERWND_PARENT {
  9. public:
  10. ScriptBrowserWnd();
  11. virtual ~ScriptBrowserWnd();
  12. virtual void onSetVisible(int v);
  13. // XuiObject
  14. virtual int setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value);
  15. // MiniBrowserWnd
  16. int onBeforeNavigate(const wchar_t *url, int flags, const wchar_t *frame);
  17. void onDocumentComplete(const wchar_t *url);
  18. void onDocumentReady(const wchar_t *url);
  19. void onNavigateError(const wchar_t *url, int status);
  20. void onMediaLink(const wchar_t *url);
  21. void getDocumentTitle(wchar_t *str, size_t len);
  22. virtual int navigateUrl(const wchar_t *url);
  23. const wchar_t* messageToMaki(wchar_t* str1, wchar_t* str2, int i1, int i2, int i3);
  24. const wchar_t* messageToJS(const wchar_t* str1, const wchar_t* str2, int i1, int i2, int i3);
  25. // --
  26. void setUrl(const wchar_t *url);
  27. void setMainMB(int tf);
  28. void Scrape(); // benski> added Aug 17 2007
  29. void setCancelIEErrorPage(bool cancel);
  30. protected:
  31. /*static */void CreateXMLParameters(int master_handle);
  32. private:
  33. enum {
  34. BROWSER_SETURL = 0,
  35. BROWSER_SETMAINMB,
  36. BROWSER_SETTARGETNAME,
  37. BROWSER_SETSCROLLBARS,
  38. BROWSER_CANCELIEERRORPAGE,
  39. };
  40. static XMLParamPair params[];
  41. int translateScrollbarFlag(const wchar_t *scrollbarflag);
  42. StringW defurl;
  43. int myxuihandle;
  44. };
  45. // -----------------------------------------------------------------------------------------------------
  46. class BrowserScriptController : public ScriptObjectControllerI {
  47. public:
  48. virtual const wchar_t *getClassName() { return L"Browser"; }
  49. virtual const wchar_t *getAncestorClassName() { return L"GuiObject"; }
  50. virtual ScriptObjectController *getAncestorController() { return WASABI_API_MAKI->maki_getController(guiObjectGuid); }
  51. virtual int getNumFunctions();
  52. virtual const function_descriptor_struct *getExportedFunctions();
  53. virtual GUID getClassGuid() { return browserGuid; }
  54. virtual ScriptObject *instantiate();
  55. virtual void destroy(ScriptObject *o);
  56. virtual void *encapsulate(ScriptObject *o);
  57. virtual void deencapsulate(void *o);
  58. public:
  59. static scriptVar browser_navigateUrl(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url);
  60. static scriptVar browser_back(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  61. static scriptVar browser_forward(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  62. static scriptVar browser_home(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  63. static scriptVar browser_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  64. static scriptVar browser_refresh(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  65. static scriptVar browser_scrape(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  66. static scriptVar browser_setTargetName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name);
  67. static scriptVar browser_onDocumentComplete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url);
  68. static scriptVar browser_onDocumentReady(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url);
  69. static scriptVar browser_onNavigateError(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url, scriptVar status);
  70. static scriptVar browser_onBeforeNavigate(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url, scriptVar flags, scriptVar framename);
  71. static scriptVar browser_messageToMaki(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str1, scriptVar str2, scriptVar i1, scriptVar i2, scriptVar i3);
  72. static scriptVar browser_messageToJS(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str1, scriptVar str2, scriptVar i1, scriptVar i2, scriptVar i3);
  73. static scriptVar browser_onMediaLink(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url);
  74. static /*string*/ scriptVar browser_getDocumentTitle(SCRIPT_FUNCTION_PARAMS, ScriptObject *o);
  75. static scriptVar browser_setCancelIEErrorPage(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar cancel);
  76. private:
  77. static function_descriptor_struct exportedFunction[];
  78. };
  79. extern BrowserScriptController *browserController;
  80. extern const wchar_t browserXuiObjectStr[];
  81. extern char browserXuiSvcName[];
  82. class BrowserXuiSvc : public XuiObjectSvc<ScriptBrowserWnd, browserXuiObjectStr, browserXuiSvcName> {};
  83. #endif