diff options
Diffstat (limited to 'Src/Wasabi/api/script/objects')
148 files changed, 23374 insertions, 0 deletions
diff --git a/Src/Wasabi/api/script/objects/PlaylistScriptObject.cpp b/Src/Wasabi/api/script/objects/PlaylistScriptObject.cpp new file mode 100644 index 00000000..aa177956 --- /dev/null +++ b/Src/Wasabi/api/script/objects/PlaylistScriptObject.cpp @@ -0,0 +1,438 @@ +// ----------------------------------------------------------------------------------------------------- +// Playlist Script Object +// +// functions for <pledit.mi> +// ----------------------------------------------------------------------------------------------------- + +#include <precomp.h> +#include "main.h" + +#include "PlaylistScriptObject.h" + +#include <bfc/wasabi_std.h> +#include <api/script/script.h> +#include <api/script/scriptmgr.h> +#include <api/script/scriptobj.h> +#include <api/script/scriptguid.h> + +#ifdef WASABI_COMPILE_MEDIACORE +#include <api/service/svcs/svc_player.h> +#include <api/core/buttons.h> +#include <api/core/api_core.h> +#include <api/core/corehandle.h> // safe to include even if core isn't there +#endif + +static PlaylistScriptController _playlistController; +ScriptObjectController *playlistController = &_playlistController; + + +#ifndef _WASABIRUNTIME + +BEGIN_SERVICES(PlaylistObject_Svc); +DECLARE_SERVICE(ScriptObjectCreator<PlaylistScriptObjectSvc>); +END_SERVICES(PlaylistObject_Svc, _PlaylistObject_Svc); + +#ifdef _X86_ +extern "C" { int _link_PlaylistObjectSvc; } +#else +extern "C" { int __link_PlaylistObjectSvc; } +#endif + +#endif + + +// ----------------------------------------------------------------------------------------------------- +// Functions Table +function_descriptor_struct PlaylistScriptController::exportedFunction[] = +{ + {L"showCurrentlyPlayingTrack", 0, (void*)SPlaylist::script_vcpu_showCurrentlyPlayingEntry}, + {L"showTrack", 1, (void*)SPlaylist::script_vcpu_showEntry}, + {L"getNumTracks", 0, (void*)SPlaylist::script_vcpu_getNumItems}, + {L"getCurrentIndex", 0, (void*)SPlaylist::script_vcpu_getCurrentIndex}, + {L"getRating", 1, (void*)SPlaylist::script_vcpu_getTrackRating}, + {L"setRating", 2, (void*)SPlaylist::script_vcpu_setTrackRating}, + {L"enqueueFile", 1, (void*)SPlaylist::script_vcpu_enqueueFile }, + {L"clear", 0, (void*)SPlaylist::script_vcpu_clear }, + {L"removeTrack", 1, (void*)SPlaylist::script_vcpu_removeTrack }, + {L"swapTracks", 2, (void*)SPlaylist::script_vcpu_swapTrack }, + {L"moveUp", 1, (void*)SPlaylist::script_vcpu_moveUp }, + {L"moveDown", 1, (void*)SPlaylist::script_vcpu_moveDown }, + {L"moveTo", 2, (void*)SPlaylist::script_vcpu_moveTo }, + {L"getTitle", 1, (void*)SPlaylist::script_vcpu_getTitle }, + {L"getLength", 1, (void*)SPlaylist::script_vcpu_getLength }, + {L"getMetaData", 2, (void*)SPlaylist::script_vcpu_getExtendedInfo }, + {L"getNumSelectedTracks", 0, (void*)SPlaylist::script_vcpu_getNumSelectedItems }, + {L"getNextSelectedTrack", 1, (void*)SPlaylist::script_vcpu_getNextSelectedItem }, + {L"getFileName", 1, (void*)SPlaylist::script_vcpu_getFileName }, + {L"playTrack", 1, (void*)SPlaylist::script_vcpu_playTrack }, + {L"onPleditModified", 0, (void*)SPlaylist::script_vcpu_onPleditModified }, +}; + +ScriptObjectController *PlaylistScriptObjectSvc::getController(int n) +{ + switch (n) { + case 0: + return playlistController; + } + return NULL; +} + +ScriptObject *PlaylistScriptController::instantiate() +{ + SPlaylist *c = new SPlaylist; + if (!c) return NULL; + return c->getScriptObject(); +} + +void PlaylistScriptController::destroy(ScriptObject *o) +{ + SPlaylist *obj = static_cast<SPlaylist *>(o->vcpu_getInterface(playlistScriptObjectGUID)); + ASSERT(obj != NULL); + delete obj; +} + +void *PlaylistScriptController::encapsulate(ScriptObject *o) +{ + return NULL; +} + +void PlaylistScriptController::deencapsulate(void *o) +{ +} + +int PlaylistScriptController::getNumFunctions() +{ + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +SPlaylist::SPlaylist() +{ + getScriptObject()->vcpu_setInterface(playlistScriptObjectGUID, (void *)static_cast<SPlaylist *>(this)); + getScriptObject()->vcpu_setClassName(L"PlEdit"); + getScriptObject()->vcpu_setController(playlistController); + + SOList.addItem(this); +} + +SPlaylist::~SPlaylist() +{ + SOList.removeItem(this); +} + +// Script helper functions + +void SPlaylist::onPleditModified () +{ + //This one is not working + for (int i=0; i < SOList.getNumItems(); i++) + { + //script_vcpu_onPleditModified(SCRIPT_CALL, getScriptObject()); + script_vcpu_onPleditModified(SCRIPT_CALL, SOList.enumItem(i)->getScriptObject()); + //Std::messageBox(SOList.enumItem(i)->getClassName(), t, 0); + } +} + +void SPlaylist::showEntry( int i) +{ + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + SendMessageW(hPeWindow, WM_USER, 666, i); +} + +void SPlaylist::swap(int track1, int track2) +{ + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + + int i = wa2.PE_getCurrentIndex(); + + int param = ((track1) << 16) | (track2); + SendMessageW(hPeWindow, WM_USER, IPC_PE_SWAPINDEX, param); + + //Swap our currently playing item as well + if (i == track1) + { + wa2.PE_setCurrentIndex(track2); + } + else if (i == track2) + { + wa2.PE_setCurrentIndex(track1); + } +} + +fileinfoW *SPlaylist::getFileInfoStructW1 (int item) +{ + static fileinfoW fi; + fi.index = item; + *(fi.file) = 0; + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + SendMessageW(hPeWindow, WM_USER, IPC_PE_GETINDEXINFOW_INPROC, (LPARAM)&fi); + return &fi; +} + +// Script Calls + +scriptVar SPlaylist::script_vcpu_showCurrentlyPlayingEntry(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT + + showEntry (wa2.PE_getCurrentIndex()); + + RETURN_SCRIPT_VOID; +} + + +scriptVar SPlaylist::script_vcpu_showEntry(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) +{ + SCRIPT_FUNCTION_INIT + + showEntry (GET_SCRIPT_INT(i)); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_getNumItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT + + int i = wa2.PE_getNumItems(); + + return MAKE_SCRIPT_INT(i); +} + +scriptVar SPlaylist::script_vcpu_getCurrentIndex(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT + + int i = wa2.PE_getCurrentIndex(); + + return MAKE_SCRIPT_INT(i); +} + +scriptVar SPlaylist::script_vcpu_setTrackRating(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i, scriptVar rating) +{ + SCRIPT_FUNCTION_INIT + + HWND hwnd_winamp = wa2.getMainWindow(); + + int cur_pos = wa2.PE_getCurrentIndex(); + wa2.PE_setCurrentIndex(GET_SCRIPT_INT(i)); + SendMessageW(hwnd_winamp, WM_WA_IPC, GET_SCRIPT_INT(rating), IPC_SETRATING); + wa2.PE_setCurrentIndex(cur_pos); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_getTrackRating(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) +{ + SCRIPT_FUNCTION_INIT + + HWND hwnd_winamp = wa2.getMainWindow(); + + int cur_pos = wa2.PE_getCurrentIndex(); + wa2.PE_setCurrentIndex(GET_SCRIPT_INT(i)); + int r = 0; + r = SendMessageW(hwnd_winamp, WM_WA_IPC, GET_SCRIPT_INT(i), IPC_GETRATING); + wa2.PE_setCurrentIndex(cur_pos); + + return MAKE_SCRIPT_INT(r); +} + +scriptVar SPlaylist::script_vcpu_enqueueFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar file) +{ + SCRIPT_FUNCTION_INIT; + + wa2.enqueueFile (GET_SCRIPT_STRING(file)); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_clear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + + wa2.clearPlaylist(); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_removeTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) +{ + SCRIPT_FUNCTION_INIT; + + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + SendMessageW(hPeWindow, WM_USER, IPC_PE_DELETEINDEX, GET_SCRIPT_INT(i)); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_swapTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track1, scriptVar _track2) +{ + SCRIPT_FUNCTION_INIT; + + int track1 = GET_SCRIPT_INT(_track1); + int track2 = GET_SCRIPT_INT(_track2); + + if (track1 >= wa2.PE_getNumItems() || track1 < 0 || track2 >= wa2.PE_getNumItems() || track2 < 0) RETURN_SCRIPT_VOID; + swap ((track1), (track2)); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_moveUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + if (track < wa2.PE_getNumItems()-1) swap (track, track+1); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_moveDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + if (track > 0) swap (track, track-1); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_moveTo(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track, scriptVar _pos) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + int pos = GET_SCRIPT_INT(_pos); + + if (track == pos || pos >= wa2.PE_getNumItems() || pos < 0 || track >= wa2.PE_getNumItems() || track < 0) + { + RETURN_SCRIPT_VOID; + } + + // Martin> This can be done much faster :P + /*if (track > pos) + { + for (int i = track; i > pos; i--) + { + swap (i, i-1); + } + } + else + { + for (int i = track; i < pos; i++) + { + swap (i, i+1); + } + }*/ + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + fileinfoW *fi = getFileInfoStructW1(track); + SendMessageW(hPeWindow, WM_USER, IPC_PE_DELETEINDEX, fi->index); + fi->index = pos; + static COPYDATASTRUCT cds; + cds.dwData = IPC_PE_INSERTFILENAMEW; + cds.lpData = fi; + SendMessageW(hPeWindow, WM_COPYDATA, NULL, (LPARAM)&cds); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPlaylist::script_vcpu_getTitle(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + + // Martin> There might be a better way to convert this;) + // benski> yes, there is :) see below. There's a unicode equivalent API for this, just wasn't enabled in wa2frontend object + // so I added it + fileinfo2W *fi = wa2.PE_getFileTitleW(track); + if (fi) + return MAKE_SCRIPT_STRING(fi->filetitle); + else + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar SPlaylist::script_vcpu_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + + fileinfo2W *fi = wa2.PE_getFileTitleW(track); + if (fi) + return MAKE_SCRIPT_STRING((fi->filelength)); + else + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar SPlaylist::script_vcpu_getFileName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + + fileinfoW *fi = getFileInfoStructW1(track); + + return MAKE_SCRIPT_STRING(fi->file); +} + + +scriptVar SPlaylist::script_vcpu_getExtendedInfo(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track, scriptVar _name) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + const wchar_t *name = GET_SCRIPT_STRING(_name); + + fileinfoW *fi = getFileInfoStructW1(track); + + wa2.getMetaData((fi->file), name, staticStr, 4096); + + return MAKE_SCRIPT_STRING(staticStr); +} + +scriptVar SPlaylist::script_vcpu_getNumSelectedItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + + HWND hPeWindow = wa2.getWnd(IPC_GETWND_PE); + int ret = SendMessageW(hPeWindow, WM_USER, IPC_PE_GETSELECTEDCOUNT, 0); + + return MAKE_SCRIPT_INT(ret); +} + +scriptVar SPlaylist::script_vcpu_getNextSelectedItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; + + int track = GET_SCRIPT_INT(_track); + + track = SendMessageW(wa2.getMainWindow(), WM_USER, track, IPC_PLAYLIST_GET_NEXT_SELECTED); + + return MAKE_SCRIPT_INT(track); +} + +scriptVar SPlaylist::script_vcpu_playTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + int track = GET_SCRIPT_INT(_track); + WASABI_API_MEDIACORE->core_userButton(0, UserButton::STOP); + wa2.PE_setCurrentIndex(track); + WASABI_API_MEDIACORE->core_userButton(0, UserButton::PLAY); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SPlaylist::script_vcpu_onPleditModified(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, playlistController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +wchar_t SPlaylist::staticStr[4096] = {0}; +PtrList < SPlaylist > SPlaylist::SOList;
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/PlaylistScriptObject.h b/Src/Wasabi/api/script/objects/PlaylistScriptObject.h new file mode 100644 index 00000000..db21e54b --- /dev/null +++ b/Src/Wasabi/api/script/objects/PlaylistScriptObject.h @@ -0,0 +1,102 @@ +#ifndef NULLSOFT_GEN_FF_PLAYLISTSCRIPTOBJECT_H +#define NULLSOFT_GEN_FF_PLAYLISTSCRIPTOBJECT_H + +#include "wa2frontend.h" + +class SPlaylist; + +#include <api/script/script.h> +#include <api/script/objects/rootobj.h> +#include <api/script/objects/rootobject.h> +#include <api/script/objcontroller.h> + +#include <api/service/svcs/svc_scriptobji.h> + +// ----------------------------------------------------------------------------------------------------- +// ScriptObject Provider Service + +class PlaylistScriptObjectSvc : public svc_scriptObjectI { + +public: + PlaylistScriptObjectSvc() {}; + virtual ~PlaylistScriptObjectSvc() {}; + + static const char *getServiceName() { return "PlEdit maki object"; } + virtual ScriptObjectController *getController(int n); +}; + +// ----------------------------------------------------------------------------------------------------- +// PlaylistScriptObject GUID +// {345BEEBC-0229-4921-90BE-6CB6A49A79D9} +static const GUID playlistScriptObjectGUID = +{ 0x345beebc, 0x229, 0x4921, { 0x90, 0xbe, 0x6c, 0xb6, 0xa4, 0x9a, 0x79, 0xd9 } }; + +#define SPLAYLIST_SCRIPTPARENT RootObjectInstance + +// ----------------------------------------------------------------------------------------------------- +// ScriptObject Service + +class PlaylistScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName() { return L"PlEdit"; } + virtual const wchar_t *getAncestorClassName() { return L"Object"; } + virtual ScriptObjectController *getAncestorController() { return rootScriptObjectController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions() { return exportedFunction; } + virtual GUID getClassGuid() { return playlistScriptObjectGUID; } + //virtual int getInstantiable() { return 0; } + //virtual int getReferenceable() { return 0; } + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern ScriptObjectController *playlistController; + +class SPlaylist : public SPLAYLIST_SCRIPTPARENT { +public: + SPlaylist(); + virtual ~SPlaylist(); + + static PtrList < SPlaylist > SOList; + + static void onPleditModified(); + static void showEntry (int i); + static void swap (int a, int b); + static fileinfoW * getFileInfoStructW1 (int index); + + // Maki functions table + static scriptVar script_vcpu_showCurrentlyPlayingEntry(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_showEntry(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i); + static scriptVar script_vcpu_getCurrentIndex(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getNumItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getTrackRating(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i); + static scriptVar script_vcpu_setTrackRating(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i, scriptVar rating); + static scriptVar script_vcpu_enqueueFile (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar file); + static scriptVar script_vcpu_clear(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_removeTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i); + static scriptVar script_vcpu_swapTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar track, scriptVar to); + static scriptVar script_vcpu_moveUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar track); + static scriptVar script_vcpu_moveDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar track); + static scriptVar script_vcpu_moveTo(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar track, scriptVar to); + static scriptVar script_vcpu_getTitle(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track); + static scriptVar script_vcpu_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track); + static scriptVar script_vcpu_getExtendedInfo(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _track, scriptVar _name); + static scriptVar script_vcpu_getNumSelectedItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getNextSelectedItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _num); + static scriptVar script_vcpu_getFileName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _num); + static scriptVar script_vcpu_playTrack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar _num); + static scriptVar script_vcpu_onPleditModified(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + +private: + static wchar_t staticStr[4096]; +}; + +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/c_script/c_browser.cpp b/Src/Wasabi/api/script/objects/c_script/c_browser.cpp new file mode 100644 index 00000000..fdb167b9 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_browser.cpp @@ -0,0 +1,127 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_browser.h" +#include <api/script/objcontroller.h> + +C_Browser::C_Browser(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + C_hook(object); +} + +C_Browser::C_Browser() { + inited = 0; + obj = NULL; +} + +void C_Browser::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, browserGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + navigateurl_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"navigateUrl", this); + back_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"back", this); + forward_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"forward", this); + stop_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"stop", this); + refresh_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"refresh", this); + home_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"home", this); + settargetname_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetName", this); + onbeforenavigate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onBeforeNavigate", this); + ondocumentcomplete_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onDocumentComplete", this); + onmedialink_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMediaLink", this); + } + inited = 1; +} + +C_Browser::~C_Browser() { +} + +ScriptObject *C_Browser::getScriptObject() { + if (obj != NULL) return obj; + return C_BROWSER_PARENT::getScriptObject(); +} + +void C_Browser::navigateUrl(const wchar_t *url) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(url); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), navigateurl_id, params); +} + +void C_Browser::back() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), back_id, NULL); +} + +void C_Browser::forward() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), forward_id, NULL); +} + +void C_Browser::stop() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), stop_id, NULL); +} + +void C_Browser::refresh() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), refresh_id, NULL); +} + +void C_Browser::home() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), home_id, NULL); +} + +void C_Browser::setTargetName(const wchar_t *targetname) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(targetname); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargetname_id, params); +} + +int C_Browser::onBeforeNavigate(const wchar_t *url, int flags, const wchar_t *targetframename) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(url); + scriptVar b = MAKE_SCRIPT_INT(flags); + scriptVar c = MAKE_SCRIPT_STRING(targetframename); + scriptVar *params[3] = {&a, &b, &c}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onbeforenavigate_id, params)); +} + +void C_Browser::onDocumentComplete(const wchar_t *url) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(url); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ondocumentcomplete_id, params); +} + +void C_Browser::onMediaLink(const wchar_t *url) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(url); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmedialink_id, params); +} + +int C_Browser::loaded=0; +int C_Browser::navigateurl_id=0; +int C_Browser::back_id=0; +int C_Browser::forward_id=0; +int C_Browser::stop_id=0; +int C_Browser::refresh_id=0; +int C_Browser::home_id=0; +int C_Browser::settargetname_id=0; +int C_Browser::onbeforenavigate_id=0; +int C_Browser::ondocumentcomplete_id=0; +int C_Browser::onmedialink_id=0; + diff --git a/Src/Wasabi/api/script/objects/c_script/c_browser.h b/Src/Wasabi/api/script/objects/c_script/c_browser.h new file mode 100644 index 00000000..63b12b25 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_browser.h @@ -0,0 +1,49 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_BROWSER_H +#define __C_BROWSER_H + +#include "c_guiobject.h" + +#define C_BROWSER_PARENT C_GuiObject + +class C_Browser : public C_BROWSER_PARENT { + public: + + C_Browser(ScriptObject *object); + C_Browser(); + virtual ~C_Browser(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void navigateUrl(const wchar_t *url); + virtual void back(); + virtual void forward(); + virtual void stop(); + virtual void refresh(); + virtual void home(); + virtual void setTargetName(const wchar_t *targetname); + virtual int onBeforeNavigate(const wchar_t *url, int flags, const wchar_t *targetframename); + virtual void onDocumentComplete(const wchar_t *url); + virtual void onMediaLink(const wchar_t *url); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int navigateurl_id; + static int back_id; + static int forward_id; + static int stop_id; + static int refresh_id; + static int home_id; + static int settargetname_id; + static int onbeforenavigate_id; + static int ondocumentcomplete_id; + static int onmedialink_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_button.cpp b/Src/Wasabi/api/script/objects/c_script/c_button.cpp new file mode 100644 index 00000000..f22c73b6 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_button.cpp @@ -0,0 +1,104 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_button.h" +#include <api/script/objcontroller.h> + +C_Button::C_Button(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + C_hook(object); +} + +C_Button::C_Button() { + inited = 0; + obj = NULL; +} + +void C_Button::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, buttonGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onactivate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onActivate", this); + onleftclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftClick", this); + onrightclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightClick", this); + setactivated_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setActivated", this); + setactivatednocallback_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setActivatedNoCallback", this); + getactivated_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getActivated", this); + leftclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"leftClick", this); + rightclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"rightClick", this); + } + inited = 1; +} + +C_Button::~C_Button() { +} + +ScriptObject *C_Button::getScriptObject() { + if (obj != NULL) return obj; + return C_BUTTON_PARENT::getScriptObject(); +} + +void C_Button::onActivate(int activated) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(activated); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onactivate_id, params); +} + +void C_Button::onLeftClick() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftclick_id, NULL); +} + +void C_Button::onRightClick() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightclick_id, NULL); +} + +void C_Button::setActivated(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setactivated_id, params); +} + +void C_Button::setActivatedNoCallback(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setactivatednocallback_id, params); +} + +int C_Button::getActivated() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getactivated_id, NULL)); +} + +void C_Button::leftClick() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), leftclick_id, NULL); +} + +void C_Button::rightClick() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), rightclick_id, NULL); +} + +int C_Button::loaded=0; +int C_Button::onactivate_id=0; +int C_Button::onleftclick_id=0; +int C_Button::onrightclick_id=0; +int C_Button::setactivated_id=0; +int C_Button::setactivatednocallback_id=0; +int C_Button::getactivated_id=0; +int C_Button::leftclick_id=0; +int C_Button::rightclick_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_button.h b/Src/Wasabi/api/script/objects/c_script/c_button.h new file mode 100644 index 00000000..44af7579 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_button.h @@ -0,0 +1,45 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_BUTTON_H +#define __C_BUTTON_H + +#include "c_guiobject.h" + +#define C_BUTTON_PARENT C_GuiObject + +class C_Button : public C_BUTTON_PARENT { + public: + + C_Button(ScriptObject *object); + C_Button(); + virtual ~C_Button(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onActivate(int activated); + virtual void onLeftClick(); + virtual void onRightClick(); + virtual void setActivated(int onoff); + virtual void setActivatedNoCallback(int onoff); + virtual int getActivated(); + virtual void leftClick(); + virtual void rightClick(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onactivate_id; + static int onleftclick_id; + static int onrightclick_id; + static int setactivated_id; + static int setactivatednocallback_id; + static int getactivated_id; + static int leftclick_id; + static int rightclick_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_checkbox.cpp b/Src/Wasabi/api/script/objects/c_script/c_checkbox.cpp new file mode 100644 index 00000000..f5e82571 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_checkbox.cpp @@ -0,0 +1,84 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_checkbox.h" +#include <api/script/objcontroller.h> + +C_CheckBox::C_CheckBox(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + C_hook(object); +} + +C_CheckBox::C_CheckBox() { + inited = 0; + obj = NULL; +} + +void C_CheckBox::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, checkBoxGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + ontoggle_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onToggle", this); + setchecked_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setChecked", this); + ischecked_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isChecked", this); + settext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setText", this); + gettext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getText", this); + } + inited = 1; +} + +C_CheckBox::~C_CheckBox() { +} + +ScriptObject *C_CheckBox::getScriptObject() { + if (obj != NULL) return obj; + return C_CHECKBOX_PARENT::getScriptObject(); +} + +void C_CheckBox::onToggle(int newstate) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(newstate); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontoggle_id, params); +} + +void C_CheckBox::setChecked(int checked) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(checked); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setchecked_id, params); +} + +int C_CheckBox::isChecked() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), ischecked_id, NULL)); +} + +void C_CheckBox::setText(const wchar_t *txt) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(txt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settext_id, params); +} + +const wchar_t *C_CheckBox::getText() { + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettext_id, NULL)); +} + +int C_CheckBox::loaded=0; +int C_CheckBox::ontoggle_id=0; +int C_CheckBox::setchecked_id=0; +int C_CheckBox::ischecked_id=0; +int C_CheckBox::settext_id=0; +int C_CheckBox::gettext_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_checkbox.h b/Src/Wasabi/api/script/objects/c_script/c_checkbox.h new file mode 100644 index 00000000..7a42a810 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_checkbox.h @@ -0,0 +1,39 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_CHECKBOX_H +#define __C_CHECKBOX_H + +#include "c_guiobject.h" + +#define C_CHECKBOX_PARENT C_GuiObject + +class C_CheckBox : public C_CHECKBOX_PARENT { + public: + + C_CheckBox(ScriptObject *object); + C_CheckBox(); + virtual ~C_CheckBox(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onToggle(int newstate); + virtual void setChecked(int checked); + virtual int isChecked(); + virtual void setText(const wchar_t *txt); + virtual const wchar_t *getText(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontoggle_id; + static int setchecked_id; + static int ischecked_id; + static int settext_id; + static int gettext_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_container.cpp b/Src/Wasabi/api/script/objects/c_script/c_container.cpp new file mode 100644 index 00000000..d9db7641 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_container.cpp @@ -0,0 +1,179 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_container.h" +#include <api/script/objcontroller.h> + +C_Container::C_Container(ScriptObject *object) : C_RootObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Container::C_Container() { + inited = 0; + obj = NULL; +} + +void C_Container::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, containerGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onswitchtolayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSwitchToLayout", this); + onbeforeswitchtolayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onBeforeSwitchToLayout", this); + setxmlparam_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setXmlParam", this); + onhidelayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onHideLayout", this); + onshowlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onShowLayout", this); + getlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getLayout", this); + getnumlayouts_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumLayouts", this); + enumlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumLayout", this); + switchtolayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"switchToLayout", this); + show_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"show", this); + hide_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"hide", this); + close_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"close", this); + toggle_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"toggle", this); + isdynamic_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isDynamic", this); + setname_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setName", this); + getcurlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getCurLayout", this); + } + inited = 1; +} + +C_Container::~C_Container() { +} + +ScriptObject *C_Container::getScriptObject() { + if (obj != NULL) return obj; + return C_CONTAINER_PARENT::getScriptObject(); +} + +void C_Container::onSwitchToLayout(ScriptObject *newlayout) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(newlayout); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onswitchtolayout_id, params); +} + +void C_Container::onBeforeSwitchToLayout(ScriptObject *oldlayout, ScriptObject *newlayout) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(oldlayout); + scriptVar b = MAKE_SCRIPT_OBJECT(newlayout); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onbeforeswitchtolayout_id, params); +} + +void C_Container::setXmlParam(const wchar_t *param, const wchar_t *value) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(param); + scriptVar b = MAKE_SCRIPT_STRING(value); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setxmlparam_id, params); +} + +void C_Container::onHideLayout(ScriptObject *_layout) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(_layout); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onhidelayout_id, params); +} + +void C_Container::onShowLayout(ScriptObject *_layout) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(_layout); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onshowlayout_id, params); +} + +ScriptObject *C_Container::getLayout(const wchar_t *layout_id) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(layout_id); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getlayout_id, params)); +} + +int C_Container::getNumLayouts() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumlayouts_id, NULL)); +} + +ScriptObject *C_Container::enumLayout(int num) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(num); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumlayout_id, params)); +} + +void C_Container::switchToLayout(const wchar_t *layout_id) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(layout_id); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), switchtolayout_id, params); +} + +void C_Container::show() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), show_id, NULL); +} + +void C_Container::hide() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), hide_id, NULL); +} + +void C_Container::close() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), close_id, NULL); +} + +void C_Container::toggle() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), toggle_id, NULL); +} + +int C_Container::isDynamic() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isdynamic_id, NULL)); +} + +void C_Container::setName(const wchar_t *name) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(name); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setname_id, params); +} + +ScriptObject *C_Container::getCurLayout() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcurlayout_id, NULL)); +} + +int C_Container::loaded=0; +int C_Container::onswitchtolayout_id=0; +int C_Container::onbeforeswitchtolayout_id=0; +int C_Container::setxmlparam_id=0; +int C_Container::onhidelayout_id=0; +int C_Container::onshowlayout_id=0; +int C_Container::getlayout_id=0; +int C_Container::getnumlayouts_id=0; +int C_Container::enumlayout_id=0; +int C_Container::switchtolayout_id=0; +int C_Container::show_id=0; +int C_Container::hide_id=0; +int C_Container::close_id=0; +int C_Container::toggle_id=0; +int C_Container::isdynamic_id=0; +int C_Container::setname_id=0; +int C_Container::getcurlayout_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_container.h b/Src/Wasabi/api/script/objects/c_script/c_container.h new file mode 100644 index 00000000..f3fbe908 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_container.h @@ -0,0 +1,61 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_CONTAINER_H +#define __C_CONTAINER_H + +#include "c_rootobj.h" + +#define C_CONTAINER_PARENT C_RootObject + +class C_Container : public C_CONTAINER_PARENT { + public: + + C_Container(ScriptObject *object); + C_Container(); + virtual ~C_Container(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onSwitchToLayout(ScriptObject *newlayout); + virtual void onBeforeSwitchToLayout(ScriptObject *oldlayout, ScriptObject *newlayout); + virtual void setXmlParam(const wchar_t *param, const wchar_t *value); + virtual void onHideLayout(ScriptObject *_layout); + virtual void onShowLayout(ScriptObject *_layout); + virtual ScriptObject *getLayout(const wchar_t *layout_id); + virtual int getNumLayouts(); + virtual ScriptObject *enumLayout(int num); + virtual void switchToLayout(const wchar_t *layout_id); + virtual void show(); + virtual void hide(); + virtual void close(); + virtual void toggle(); + virtual int isDynamic(); + virtual void setName(const wchar_t *name); + virtual ScriptObject *getCurLayout(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onswitchtolayout_id; + static int onbeforeswitchtolayout_id; + static int setxmlparam_id; + static int onhidelayout_id; + static int onshowlayout_id; + static int getlayout_id; + static int getnumlayouts_id; + static int enumlayout_id; + static int switchtolayout_id; + static int show_id; + static int hide_id; + static int close_id; + static int toggle_id; + static int isdynamic_id; + static int setname_id; + static int getcurlayout_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.cpp b/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.cpp new file mode 100644 index 00000000..2dc719fb --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.cpp @@ -0,0 +1,184 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_dropdownlist.h" +#include <api/script/objcontroller.h> + +C_DropDownList::C_DropDownList(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_DropDownList::C_DropDownList() { + inited = 0; + obj = NULL; +} + +void C_DropDownList::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, dropDownListGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + getitemselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemSelected", this); + onselect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSelect", this); + setlistheight_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setListHeight", this); + openlist_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"openList", this); + closelist_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"closeList", this); + setitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setItems", this); + additem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"addItem", this); + delitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"delItem", this); + finditem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"findItem", this); + getnumitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumItems", this); + selectitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectItem", this); + getitemtext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemText", this); + getselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSelected", this); + getselectedtext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSelectedText", this); + getcustomtext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getCustomText", this); + deleteallitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"deleteAllItems", this); + setnoitemtext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setNoItemText", this); + } + inited = 1; +} + +C_DropDownList::~C_DropDownList() { +} + +ScriptObject *C_DropDownList::getScriptObject() { + if (obj != NULL) return obj; + return C_DROPDOWNLIST_PARENT::getScriptObject(); +} + +const wchar_t *C_DropDownList::getItemSelected() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemselected_id, NULL)); +} + +void C_DropDownList::onSelect(int id, int hover) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(id); + scriptVar b = MAKE_SCRIPT_INT(hover); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onselect_id, params); +} + +void C_DropDownList::setListHeight(int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(h); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setlistheight_id, params); +} + +void C_DropDownList::openList() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), openlist_id, NULL); +} + +void C_DropDownList::closeList() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), closelist_id, NULL); +} + +void C_DropDownList::setItems(const wchar_t *lotsofitems) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(lotsofitems); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setitems_id, params); +} + +int C_DropDownList::addItem(const wchar_t *_text) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(_text); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), additem_id, params)); +} + +void C_DropDownList::delItem(int id) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(id); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), delitem_id, params); +} + +int C_DropDownList::findItem(const wchar_t *_text) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(_text); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), finditem_id, params)); +} + +int C_DropDownList::getNumItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumitems_id, NULL)); +} + +void C_DropDownList::selectItem(int id, int hover) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(id); + scriptVar b = MAKE_SCRIPT_INT(hover); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectitem_id, params); +} + +const wchar_t *C_DropDownList::getItemText(int id) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(id); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemtext_id, params)); +} + +int C_DropDownList::getSelected() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getselected_id, NULL)); +} + +const wchar_t *C_DropDownList::getSelectedText() { + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getselectedtext_id, NULL)); +} + +const wchar_t *C_DropDownList::getCustomText() { + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcustomtext_id, NULL)); +} + +void C_DropDownList::deleteAllItems() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), deleteallitems_id, NULL); +} + +void C_DropDownList::setNoItemText(const wchar_t *txt) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(txt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setnoitemtext_id, params); +} + +int C_DropDownList::loaded=0; +int C_DropDownList::getitemselected_id=0; +int C_DropDownList::onselect_id=0; +int C_DropDownList::setlistheight_id=0; +int C_DropDownList::openlist_id=0; +int C_DropDownList::closelist_id=0; +int C_DropDownList::setitems_id=0; +int C_DropDownList::additem_id=0; +int C_DropDownList::delitem_id=0; +int C_DropDownList::finditem_id=0; +int C_DropDownList::getnumitems_id=0; +int C_DropDownList::selectitem_id=0; +int C_DropDownList::getitemtext_id=0; +int C_DropDownList::getselected_id=0; +int C_DropDownList::getselectedtext_id=0; +int C_DropDownList::getcustomtext_id=0; +int C_DropDownList::deleteallitems_id=0; +int C_DropDownList::setnoitemtext_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.h b/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.h new file mode 100644 index 00000000..3beba99f --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_dropdownlist.h @@ -0,0 +1,63 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_DROPDOWNLIST_H +#define __C_DROPDOWNLIST_H + +#include "c_guiobject.h" + +#define C_DROPDOWNLIST_PARENT C_GuiObject + +class C_DropDownList : public C_DROPDOWNLIST_PARENT { + public: + + C_DropDownList(ScriptObject *object); + C_DropDownList(); + virtual ~C_DropDownList(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual const wchar_t *getItemSelected(); + virtual void onSelect(int id, int hover); + virtual void setListHeight(int h); + virtual void openList(); + virtual void closeList(); + virtual void setItems(const wchar_t *lotsofitems); + virtual int addItem(const wchar_t *_text); + virtual void delItem(int id); + virtual int findItem(const wchar_t *_text); + virtual int getNumItems(); + virtual void selectItem(int id, int hover); + virtual const wchar_t *getItemText(int id); + virtual int getSelected(); + virtual const wchar_t *getSelectedText(); + virtual const wchar_t *getCustomText(); + virtual void deleteAllItems(); + virtual void setNoItemText(const wchar_t *txt); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int getitemselected_id; + static int onselect_id; + static int setlistheight_id; + static int openlist_id; + static int closelist_id; + static int setitems_id; + static int additem_id; + static int delitem_id; + static int finditem_id; + static int getnumitems_id; + static int selectitem_id; + static int getitemtext_id; + static int getselected_id; + static int getselectedtext_id; + static int getcustomtext_id; + static int deleteallitems_id; + static int setnoitemtext_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_edit.cpp b/Src/Wasabi/api/script/objects/c_script/c_edit.cpp new file mode 100644 index 00000000..4ce40920 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_edit.cpp @@ -0,0 +1,135 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_edit.h" +#include <api/script/objcontroller.h> + +C_Edit::C_Edit(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Edit::C_Edit() { + inited = 0; + obj = NULL; +} + +void C_Edit::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, editGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onenter_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEnter", this); + onabort_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onAbort", this); + onidleeditupdate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onIdleEditUpdate", this); + oneditupdate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEditUpdate", this); + settext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setText", this); + setautoenter_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAutoEnter", this); + getautoenter_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getAutoEnter", this); + gettext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getText", this); + selectall_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectAll", this); + enter_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enter", this); + setidleenabled_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setIdleEnabled", this); + getidleenabled_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getIdleEnabled", this); + } + inited = 1; +} + +C_Edit::~C_Edit() { +} + +ScriptObject *C_Edit::getScriptObject() { + if (obj != NULL) return obj; + return C_EDIT_PARENT::getScriptObject(); +} + +void C_Edit::onEnter() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onenter_id, NULL); +} + +void C_Edit::onAbort() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onabort_id, NULL); +} + +void C_Edit::onIdleEditUpdate() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onidleeditupdate_id, NULL); +} + +void C_Edit::onEditUpdate() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), oneditupdate_id, NULL); +} + +void C_Edit::setText(const wchar_t *txt) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(txt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settext_id, params); +} + +void C_Edit::setAutoEnter(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setautoenter_id, params); +} + +int C_Edit::getAutoEnter() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getautoenter_id, NULL)); +} + +const wchar_t *C_Edit::getText() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettext_id, NULL)); +} + +void C_Edit::selectAll() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectall_id, NULL); +} + +void C_Edit::enter() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), enter_id, NULL); +} + +void C_Edit::setIdleEnabled(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setidleenabled_id, params); +} + +int C_Edit::getIdleEnabled() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getidleenabled_id, NULL)); +} + +int C_Edit::loaded=0; +int C_Edit::onenter_id=0; +int C_Edit::onabort_id=0; +int C_Edit::onidleeditupdate_id=0; +int C_Edit::oneditupdate_id=0; +int C_Edit::settext_id=0; +int C_Edit::setautoenter_id=0; +int C_Edit::getautoenter_id=0; +int C_Edit::gettext_id=0; +int C_Edit::selectall_id=0; +int C_Edit::enter_id=0; +int C_Edit::setidleenabled_id=0; +int C_Edit::getidleenabled_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_edit.h b/Src/Wasabi/api/script/objects/c_script/c_edit.h new file mode 100644 index 00000000..09f96b24 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_edit.h @@ -0,0 +1,53 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_EDIT_H +#define __C_EDIT_H + +#include "c_guiobject.h" + +#define C_EDIT_PARENT C_GuiObject + +class C_Edit : public C_EDIT_PARENT { + public: + + C_Edit(ScriptObject *object); + C_Edit(); + virtual ~C_Edit(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onEnter(); + virtual void onAbort(); + virtual void onIdleEditUpdate(); + virtual void onEditUpdate(); + virtual void setText(const wchar_t *txt); + virtual void setAutoEnter(int onoff); + virtual int getAutoEnter(); + virtual const wchar_t *getText(); + virtual void selectAll(); + virtual void enter(); + virtual void setIdleEnabled(int onoff); + virtual int getIdleEnabled(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onenter_id; + static int onabort_id; + static int onidleeditupdate_id; + static int oneditupdate_id; + static int settext_id; + static int setautoenter_id; + static int getautoenter_id; + static int gettext_id; + static int selectall_id; + static int enter_id; + static int setidleenabled_id; + static int getidleenabled_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_group.cpp b/Src/Wasabi/api/script/objects/c_script/c_group.cpp new file mode 100644 index 00000000..8d0cb037 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_group.cpp @@ -0,0 +1,99 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_group.h" +#include <api/script/objcontroller.h> + +C_Group::C_Group(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Group::C_Group() { + inited = 0; + obj = NULL; +} + +void C_Group::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, groupGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + getobject_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getObject", this); + getnumobjects_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumObjects", this); + enumobject_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumObject", this); + oncreateobject_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onCreateObject", this); + getmouseposx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getMousePosX", this); + getmouseposy_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getMousePosY", this); + islayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isLayout", this); + } + inited = 1; +} + +C_Group::~C_Group() { +} + +ScriptObject *C_Group::getScriptObject() { + if (obj != NULL) return obj; + return C_GROUP_PARENT::getScriptObject(); +} + +ScriptObject *C_Group::getObject(const wchar_t *object_id) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(object_id); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getobject_id, params)); +} + +int C_Group::getNumObjects() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumobjects_id, NULL)); +} + +ScriptObject *C_Group::enumObject(int num) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(num); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumobject_id, params)); +} + +void C_Group::onCreateObject(ScriptObject *newobj) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(newobj); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncreateobject_id, params); +} + +int C_Group::getMousePosX() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getmouseposx_id, NULL)); +} + +int C_Group::getMousePosY() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getmouseposy_id, NULL)); +} + +int C_Group::isLayout() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), islayout_id, NULL)); +} + +int C_Group::loaded=0; +int C_Group::getobject_id=0; +int C_Group::getnumobjects_id=0; +int C_Group::enumobject_id=0; +int C_Group::oncreateobject_id=0; +int C_Group::getmouseposx_id=0; +int C_Group::getmouseposy_id=0; +int C_Group::islayout_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_group.h b/Src/Wasabi/api/script/objects/c_script/c_group.h new file mode 100644 index 00000000..2204ec6f --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_group.h @@ -0,0 +1,43 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_GROUP_H +#define __C_GROUP_H + +#include "c_guiobject.h" + +#define C_GROUP_PARENT C_GuiObject + +class C_Group : public C_GROUP_PARENT { + public: + + C_Group(ScriptObject *object); + C_Group(); + virtual ~C_Group(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual ScriptObject *getObject(const wchar_t *object_id); + virtual int getNumObjects(); + virtual ScriptObject *enumObject(int num); + virtual void onCreateObject(ScriptObject *newobj); + virtual int getMousePosX(); + virtual int getMousePosY(); + virtual int isLayout(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int getobject_id; + static int getnumobjects_id; + static int enumobject_id; + static int oncreateobject_id; + static int getmouseposx_id; + static int getmouseposy_id; + static int islayout_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_grouplist.cpp b/Src/Wasabi/api/script/objects/c_script/c_grouplist.cpp new file mode 100644 index 00000000..e5462602 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_grouplist.cpp @@ -0,0 +1,85 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> +#include <api/api.h> +#include "c_grouplist.h" +#include <api/script/objcontroller.h> + +C_GroupList::C_GroupList(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_GroupList::C_GroupList() { + inited = 0; + obj = NULL; +} + +void C_GroupList::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, groupListGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + instantiate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"instantiate", this); + getnumitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumItems", this); + enumitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumItem", this); + removeall_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"removeAll", this); + scrolltopercent_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollToPercent", this); + } + inited = 1; +} + +C_GroupList::~C_GroupList() { +} + +ScriptObject *C_GroupList::getScriptObject() { + if (obj != NULL) return obj; + return C_GROUPLIST_PARENT::getScriptObject(); +} + +ScriptObject *C_GroupList::instantiate(const char *group_id, int num_groups) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(group_id); + scriptVar b = MAKE_SCRIPT_INT(num_groups); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), instantiate_id, params)); +} + +int C_GroupList::getNumItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumitems_id, NULL)); +} + +ScriptObject *C_GroupList::enumItem(int num) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(num); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumitem_id, params)); +} + +void C_GroupList::removeAll() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), removeall_id, NULL); +} + +void C_GroupList::scrollToPercent(int percent) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(percent); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrolltopercent_id, params); +} + +int C_GroupList::loaded=0; +int C_GroupList::instantiate_id=0; +int C_GroupList::getnumitems_id=0; +int C_GroupList::enumitem_id=0; +int C_GroupList::removeall_id=0; +int C_GroupList::scrolltopercent_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_grouplist.h b/Src/Wasabi/api/script/objects/c_script/c_grouplist.h new file mode 100644 index 00000000..0977e0c4 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_grouplist.h @@ -0,0 +1,39 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_GROUPLIST_H +#define __C_GROUPLIST_H + +#include "c_guiobject.h" + +#define C_GROUPLIST_PARENT C_GuiObject + +class C_GroupList : public C_GROUPLIST_PARENT { + public: + + C_GroupList(ScriptObject *object); + C_GroupList(); + virtual ~C_GroupList(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual ScriptObject *instantiate(const char *group_id, int num_groups); + virtual int getNumItems(); + virtual ScriptObject *enumItem(int num); + virtual void removeAll(); + virtual void scrollToPercent(int percent); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int instantiate_id; + static int getnumitems_id; + static int enumitem_id; + static int removeall_id; + static int scrolltopercent_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_guilist.cpp b/Src/Wasabi/api/script/objects/c_script/c_guilist.cpp new file mode 100644 index 00000000..f28e168a --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guilist.cpp @@ -0,0 +1,722 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_guilist.h" +#include <api/script/objcontroller.h> + +C_GuiList::C_GuiList(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_GuiList::C_GuiList() { + inited = 0; + obj = NULL; +} + +void C_GuiList::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, guiListGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + getnumitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumItems", this); + getwantautodeselect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getWantAutoDeselect", this); + setwantautodeselect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setWantAutoDeselect", this); + onsetvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSetVisible", this); + setautosort_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAutoSort", this); + next_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"next", this); + selectcurrent_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectCurrent", this); + selectfirstentry_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectFirstEntry", this); + previous_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"previous", this); + pagedown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"pagedown", this); + pageup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"pageup", this); + home_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"home", this); + end_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"end", this); + reset_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"reset", this); + addcolumn_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"addColumn", this); + getnumcolumns_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumColumns", this); + getcolumnwidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getColumnWidth", this); + setcolumnwidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setColumnWidth", this); + getcolumnlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getColumnLabel", this); + setcolumnlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setColumnLabel", this); + getcolumnnumeric_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getColumnNumeric", this); + setcolumndynamic_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setColumnDynamic", this); + iscolumndynamic_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isColumnDynamic", this); + setminimumsize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setMinimumSize", this); + additem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"addItem", this); + insertitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"insertItem", this); + getlastaddeditempos_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getLastAddedItemPos", this); + setsubitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSubItem", this); + deleteallitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"deleteAllItems", this); + deletebypos_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"deleteByPos", this); + getitemlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemLabel", this); + setitemlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setItemLabel", this); + getitemselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemSelected", this); + isitemfocused_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isItemFocused", this); + getitemfocused_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemFocused", this); + setitemfocused_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setItemFocused", this); + ensureitemvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"ensureItemVisible", this); + invalidatecolumns_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"invalidateColumns", this); + scrollabsolute_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollAbsolute", this); + scrollrelative_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollRelative", this); + scrollleft_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollLeft", this); + scrollright_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollRight", this); + scrollup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollUp", this); + scrolldown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollDown", this); + getsubitemtext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSubitemText", this); + getfirstitemselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getFirstItemSelected", this); + getnextitemselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNextItemSelected", this); + selectall_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectAll", this); + deselectall_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"deselectAll", this); + invertselection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"invertSelection", this); + invalidateitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"invalidateItem", this); + getfirstitemvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getFirstItemVisible", this); + getlastitemvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getLastItemVisible", this); + setfontsize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setFontSize", this); + getfontsize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getFontSize", this); + jumptonext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"jumpToNext", this); + scrolltoitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"scrollToItem", this); + resort_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"resort", this); + getsortdirection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSortDirection", this); + getsortcolumn_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSortColumn", this); + setsortcolumn_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSortColumn", this); + setsortdirection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSortDirection", this); + getitemcount_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemCount", this); + setselectionstart_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSelectionStart", this); + setselectionend_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSelectionEnd", this); + setselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSelected", this); + toggleselection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"toggleSelection", this); + getheaderheight_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getHeaderHeight", this); + getpreventmultipleselection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getPreventMultipleSelection", this); + setpreventmultipleselection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setPreventMultipleSelection", this); + moveitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"moveItem", this); + onselectall_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSelectAll", this); + ondelete_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onDelete", this); + ondoubleclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onDoubleClick", this); + onleftclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftClick", this); + onsecondleftclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSecondLeftClick", this); + onrightclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightClick", this); + oncolumndblclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onColumnDblClick", this); + oncolumnlabelclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onColumnLabelClick", this); + onitemselection_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onItemSelection", this); + } + inited = 1; +} + +C_GuiList::~C_GuiList() { +} + +ScriptObject *C_GuiList::getScriptObject() { + if (obj != NULL) return obj; + return C_GUILIST_PARENT::getScriptObject(); +} + +int C_GuiList::getNumItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumitems_id, NULL)); +} + +int C_GuiList::getWantAutoDeselect() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getwantautodeselect_id, NULL)); +} + +void C_GuiList::setWantAutoDeselect(int want) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(want); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setwantautodeselect_id, params); +} + +void C_GuiList::onSetVisible(int show) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(show); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsetvisible_id, params); +} + +void C_GuiList::setAutoSort(int dosort) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(dosort); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setautosort_id, params); +} + +void C_GuiList::next() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), next_id, NULL); +} + +void C_GuiList::selectCurrent() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectcurrent_id, NULL); +} + +void C_GuiList::selectFirstEntry() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectfirstentry_id, NULL); +} + +void C_GuiList::previous() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), previous_id, NULL); +} + +void C_GuiList::pagedown() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), pagedown_id, NULL); +} + +void C_GuiList::pageup() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), pageup_id, NULL); +} + +void C_GuiList::home() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), home_id, NULL); +} + +void C_GuiList::end() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), end_id, NULL); +} + +void C_GuiList::reset() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), reset_id, NULL); +} + +int C_GuiList::addColumn(const wchar_t *name, int width, int numeric) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(name); + scriptVar b = MAKE_SCRIPT_INT(width); + scriptVar c = MAKE_SCRIPT_INT(numeric); + scriptVar *params[3] = {&a, &b, &c}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), addcolumn_id, params)); +} + +int C_GuiList::getNumColumns() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumcolumns_id, NULL)); +} + +int C_GuiList::getColumnWidth(int column) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcolumnwidth_id, params)); +} + +void C_GuiList::setColumnWidth(int column, int newwidth) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar b = MAKE_SCRIPT_INT(newwidth); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setcolumnwidth_id, params); +} + +const wchar_t *C_GuiList::getColumnLabel(int column) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcolumnlabel_id, params)); +} + +void C_GuiList::setColumnLabel(int column, const wchar_t *newlabel) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar b = MAKE_SCRIPT_STRING(newlabel); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setcolumnlabel_id, params); +} + +int C_GuiList::getColumnNumeric(int column) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcolumnnumeric_id, params)); +} + +void C_GuiList::setColumnDynamic(int column, int isdynamic) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar b = MAKE_SCRIPT_INT(isdynamic); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setcolumndynamic_id, params); +} + +int C_GuiList::isColumnDynamic(int column) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(column); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), iscolumndynamic_id, params)); +} + +void C_GuiList::setMinimumSize(int size) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(size); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setminimumsize_id, params); +} + +int C_GuiList::addItem(const wchar_t *label) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(label); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), additem_id, params)); +} + +int C_GuiList::insertItem(int pos, const wchar_t *label) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_STRING(label); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), insertitem_id, params)); +} + +int C_GuiList::getLastAddedItemPos() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getlastaddeditempos_id, NULL)); +} + +void C_GuiList::setSubItem(int pos, int subpos, const wchar_t *txt) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_INT(subpos); + scriptVar c = MAKE_SCRIPT_STRING(txt); + scriptVar *params[3] = {&a, &b, &c}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setsubitem_id, params); +} + +void C_GuiList::deleteAllItems() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), deleteallitems_id, NULL); +} + +int C_GuiList::deleteByPos(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), deletebypos_id, params)); +} + +const wchar_t *C_GuiList::getItemLabel(int pos, int subpos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_INT(subpos); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemlabel_id, params)); +} + +void C_GuiList::setItemLabel(int pos, const wchar_t *_text) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_STRING(_text); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setitemlabel_id, params); +} + +int C_GuiList::getItemSelected(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemselected_id, params)); +} + +int C_GuiList::isItemFocused(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isitemfocused_id, params)); +} + +int C_GuiList::getItemFocused() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemfocused_id, NULL)); +} + +void C_GuiList::setItemFocused(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setitemfocused_id, params); +} + +void C_GuiList::ensureItemVisible(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ensureitemvisible_id, params); +} + +void C_GuiList::invalidateColumns() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), invalidatecolumns_id, NULL); +} + +int C_GuiList::scrollAbsolute(int x) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrollabsolute_id, params)); +} + +int C_GuiList::scrollRelative(int x) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrollrelative_id, params)); +} + +void C_GuiList::scrollLeft(int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(lines); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrollleft_id, params); +} + +void C_GuiList::scrollRight(int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(lines); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrollright_id, params); +} + +void C_GuiList::scrollUp(int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(lines); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrollup_id, params); +} + +void C_GuiList::scrollDown(int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(lines); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrolldown_id, params); +} + +const wchar_t *C_GuiList::getSubitemText(int pos, int subpos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_INT(subpos); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsubitemtext_id, params)); +} + +int C_GuiList::getFirstItemSelected() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getfirstitemselected_id, NULL)); +} + +int C_GuiList::getNextItemSelected(int lastpos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(lastpos); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnextitemselected_id, params)); +} + +int C_GuiList::selectAll() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectall_id, NULL)); +} + +int C_GuiList::deselectAll() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), deselectall_id, NULL)); +} + +int C_GuiList::invertSelection() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), invertselection_id, NULL)); +} + +int C_GuiList::invalidateItem(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), invalidateitem_id, params)); +} + +int C_GuiList::getFirstItemVisible() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getfirstitemvisible_id, NULL)); +} + +int C_GuiList::getLastItemVisible() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getlastitemvisible_id, NULL)); +} + +int C_GuiList::setFontSize(int size) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(size); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), setfontsize_id, params)); +} + +int C_GuiList::getFontSize() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getfontsize_id, NULL)); +} + +void C_GuiList::jumpToNext(int c) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(c); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), jumptonext_id, params); +} + +void C_GuiList::scrollToItem(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), scrolltoitem_id, params); +} + +void C_GuiList::resort() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), resort_id, NULL); +} + +int C_GuiList::getSortDirection() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsortdirection_id, NULL)); +} + +int C_GuiList::getSortColumn() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsortcolumn_id, NULL)); +} + +void C_GuiList::setSortColumn(int col) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(col); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setsortcolumn_id, params); +} + +void C_GuiList::setSortDirection(int dir) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(dir); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setsortdirection_id, params); +} + +int C_GuiList::getItemCount() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemcount_id, NULL)); +} + +void C_GuiList::setSelectionStart(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setselectionstart_id, params); +} + +void C_GuiList::setSelectionEnd(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setselectionend_id, params); +} + +void C_GuiList::setSelected(int pos, int selected) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_INT(selected); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setselected_id, params); +} + +void C_GuiList::toggleSelection(int pos, int setfocus) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar b = MAKE_SCRIPT_INT(setfocus); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), toggleselection_id, params); +} + +int C_GuiList::getHeaderHeight() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getheaderheight_id, NULL)); +} + +int C_GuiList::getPreventMultipleSelection() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getpreventmultipleselection_id, NULL)); +} + +int C_GuiList::setPreventMultipleSelection(int val) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(val); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), setpreventmultipleselection_id, params)); +} + +void C_GuiList::moveItem(int from, int to) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(from); + scriptVar b = MAKE_SCRIPT_INT(to); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), moveitem_id, params); +} + +void C_GuiList::onSelectAll() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onselectall_id, NULL); +} + +void C_GuiList::onDelete() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ondelete_id, NULL); +} + +void C_GuiList::onDoubleClick(int itemnum) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(itemnum); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ondoubleclick_id, params); +} + +void C_GuiList::onLeftClick(int itemnum) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(itemnum); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftclick_id, params); +} + +void C_GuiList::onSecondLeftClick(int itemnum) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(itemnum); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsecondleftclick_id, params); +} + +int C_GuiList::onRightClick(int itemnum) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(itemnum); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightclick_id, params)); +} + +int C_GuiList::onColumnDblClick(int col, int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(col); + scriptVar b = MAKE_SCRIPT_INT(x); + scriptVar c = MAKE_SCRIPT_INT(y); + scriptVar *params[3] = {&a, &b, &c}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncolumndblclick_id, params)); +} + +int C_GuiList::onColumnLabelClick(int col, int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(col); + scriptVar b = MAKE_SCRIPT_INT(x); + scriptVar c = MAKE_SCRIPT_INT(y); + scriptVar *params[3] = {&a, &b, &c}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncolumnlabelclick_id, params)); +} + +void C_GuiList::onItemSelection(int itemnum, int selected) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(itemnum); + scriptVar b = MAKE_SCRIPT_INT(selected); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onitemselection_id, params); +} + +int C_GuiList::loaded=0; +int C_GuiList::getnumitems_id=0; +int C_GuiList::getwantautodeselect_id=0; +int C_GuiList::setwantautodeselect_id=0; +int C_GuiList::onsetvisible_id=0; +int C_GuiList::setautosort_id=0; +int C_GuiList::next_id=0; +int C_GuiList::selectcurrent_id=0; +int C_GuiList::selectfirstentry_id=0; +int C_GuiList::previous_id=0; +int C_GuiList::pagedown_id=0; +int C_GuiList::pageup_id=0; +int C_GuiList::home_id=0; +int C_GuiList::end_id=0; +int C_GuiList::reset_id=0; +int C_GuiList::addcolumn_id=0; +int C_GuiList::getnumcolumns_id=0; +int C_GuiList::getcolumnwidth_id=0; +int C_GuiList::setcolumnwidth_id=0; +int C_GuiList::getcolumnlabel_id=0; +int C_GuiList::setcolumnlabel_id=0; +int C_GuiList::getcolumnnumeric_id=0; +int C_GuiList::setcolumndynamic_id=0; +int C_GuiList::iscolumndynamic_id=0; +int C_GuiList::setminimumsize_id=0; +int C_GuiList::additem_id=0; +int C_GuiList::insertitem_id=0; +int C_GuiList::getlastaddeditempos_id=0; +int C_GuiList::setsubitem_id=0; +int C_GuiList::deleteallitems_id=0; +int C_GuiList::deletebypos_id=0; +int C_GuiList::getitemlabel_id=0; +int C_GuiList::setitemlabel_id=0; +int C_GuiList::getitemselected_id=0; +int C_GuiList::isitemfocused_id=0; +int C_GuiList::getitemfocused_id=0; +int C_GuiList::setitemfocused_id=0; +int C_GuiList::ensureitemvisible_id=0; +int C_GuiList::invalidatecolumns_id=0; +int C_GuiList::scrollabsolute_id=0; +int C_GuiList::scrollrelative_id=0; +int C_GuiList::scrollleft_id=0; +int C_GuiList::scrollright_id=0; +int C_GuiList::scrollup_id=0; +int C_GuiList::scrolldown_id=0; +int C_GuiList::getsubitemtext_id=0; +int C_GuiList::getfirstitemselected_id=0; +int C_GuiList::getnextitemselected_id=0; +int C_GuiList::selectall_id=0; +int C_GuiList::deselectall_id=0; +int C_GuiList::invertselection_id=0; +int C_GuiList::invalidateitem_id=0; +int C_GuiList::getfirstitemvisible_id=0; +int C_GuiList::getlastitemvisible_id=0; +int C_GuiList::setfontsize_id=0; +int C_GuiList::getfontsize_id=0; +int C_GuiList::jumptonext_id=0; +int C_GuiList::scrolltoitem_id=0; +int C_GuiList::resort_id=0; +int C_GuiList::getsortdirection_id=0; +int C_GuiList::getsortcolumn_id=0; +int C_GuiList::setsortcolumn_id=0; +int C_GuiList::setsortdirection_id=0; +int C_GuiList::getitemcount_id=0; +int C_GuiList::setselectionstart_id=0; +int C_GuiList::setselectionend_id=0; +int C_GuiList::setselected_id=0; +int C_GuiList::toggleselection_id=0; +int C_GuiList::getheaderheight_id=0; +int C_GuiList::getpreventmultipleselection_id=0; +int C_GuiList::setpreventmultipleselection_id=0; +int C_GuiList::moveitem_id=0; +int C_GuiList::onselectall_id=0; +int C_GuiList::ondelete_id=0; +int C_GuiList::ondoubleclick_id=0; +int C_GuiList::onleftclick_id=0; +int C_GuiList::onsecondleftclick_id=0; +int C_GuiList::onrightclick_id=0; +int C_GuiList::oncolumndblclick_id=0; +int C_GuiList::oncolumnlabelclick_id=0; +int C_GuiList::onitemselection_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_guilist.h b/Src/Wasabi/api/script/objects/c_script/c_guilist.h new file mode 100644 index 00000000..8fbc54d3 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guilist.h @@ -0,0 +1,189 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_GUILIST_H +#define __C_GUILIST_H + +#include "c_guiobject.h" + +#define C_GUILIST_PARENT C_GuiObject + +class C_GuiList : public C_GUILIST_PARENT { + public: + + C_GuiList(ScriptObject *object); + C_GuiList(); + virtual ~C_GuiList(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual int getNumItems(); + virtual int getWantAutoDeselect(); + virtual void setWantAutoDeselect(int want); + virtual void onSetVisible(int show); + virtual void setAutoSort(int dosort); + virtual void next(); + virtual void selectCurrent(); + virtual void selectFirstEntry(); + virtual void previous(); + virtual void pagedown(); + virtual void pageup(); + virtual void home(); + virtual void end(); + virtual void reset(); + virtual int addColumn(const wchar_t *name, int width, int numeric); + virtual int getNumColumns(); + virtual int getColumnWidth(int column); + virtual void setColumnWidth(int column, int newwidth); + virtual const wchar_t *getColumnLabel(int column); + virtual void setColumnLabel(int column, const wchar_t *newlabel); + virtual int getColumnNumeric(int column); + virtual void setColumnDynamic(int column, int isdynamic); + virtual int isColumnDynamic(int column); + virtual void setMinimumSize(int size); + virtual int addItem(const wchar_t *label); + virtual int insertItem(int pos, const wchar_t *label); + virtual int getLastAddedItemPos(); + virtual void setSubItem(int pos, int subpos, const wchar_t *txt); + virtual void deleteAllItems(); + virtual int deleteByPos(int pos); + virtual const wchar_t *getItemLabel(int pos, int subpos); + virtual void setItemLabel(int pos, const wchar_t *_text); + virtual int getItemSelected(int pos); + virtual int isItemFocused(int pos); + virtual int getItemFocused(); + virtual void setItemFocused(int pos); + virtual void ensureItemVisible(int pos); + virtual void invalidateColumns(); + virtual int scrollAbsolute(int x); + virtual int scrollRelative(int x); + virtual void scrollLeft(int lines); + virtual void scrollRight(int lines); + virtual void scrollUp(int lines); + virtual void scrollDown(int lines); + virtual const wchar_t *getSubitemText(int pos, int subpos); + virtual int getFirstItemSelected(); + virtual int getNextItemSelected(int lastpos); + virtual int selectAll(); + virtual int deselectAll(); + virtual int invertSelection(); + virtual int invalidateItem(int pos); + virtual int getFirstItemVisible(); + virtual int getLastItemVisible(); + virtual int setFontSize(int size); + virtual int getFontSize(); + virtual void jumpToNext(int c); + virtual void scrollToItem(int pos); + virtual void resort(); + virtual int getSortDirection(); + virtual int getSortColumn(); + virtual void setSortColumn(int col); + virtual void setSortDirection(int dir); + virtual int getItemCount(); + virtual void setSelectionStart(int pos); + virtual void setSelectionEnd(int pos); + virtual void setSelected(int pos, int selected); + virtual void toggleSelection(int pos, int setfocus); + virtual int getHeaderHeight(); + virtual int getPreventMultipleSelection(); + virtual int setPreventMultipleSelection(int val); + virtual void moveItem(int from, int to); + virtual void onSelectAll(); + virtual void onDelete(); + virtual void onDoubleClick(int itemnum); + virtual void onLeftClick(int itemnum); + virtual void onSecondLeftClick(int itemnum); + virtual int onRightClick(int itemnum); + virtual int onColumnDblClick(int col, int x, int y); + virtual int onColumnLabelClick(int col, int x, int y); + virtual void onItemSelection(int itemnum, int selected); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int getnumitems_id; + static int getwantautodeselect_id; + static int setwantautodeselect_id; + static int onsetvisible_id; + static int setautosort_id; + static int next_id; + static int selectcurrent_id; + static int selectfirstentry_id; + static int previous_id; + static int pagedown_id; + static int pageup_id; + static int home_id; + static int end_id; + static int reset_id; + static int addcolumn_id; + static int getnumcolumns_id; + static int getcolumnwidth_id; + static int setcolumnwidth_id; + static int getcolumnlabel_id; + static int setcolumnlabel_id; + static int getcolumnnumeric_id; + static int setcolumndynamic_id; + static int iscolumndynamic_id; + static int setminimumsize_id; + static int additem_id; + static int insertitem_id; + static int getlastaddeditempos_id; + static int setsubitem_id; + static int deleteallitems_id; + static int deletebypos_id; + static int getitemlabel_id; + static int setitemlabel_id; + static int getitemselected_id; + static int isitemfocused_id; + static int getitemfocused_id; + static int setitemfocused_id; + static int ensureitemvisible_id; + static int invalidatecolumns_id; + static int scrollabsolute_id; + static int scrollrelative_id; + static int scrollleft_id; + static int scrollright_id; + static int scrollup_id; + static int scrolldown_id; + static int getsubitemtext_id; + static int getfirstitemselected_id; + static int getnextitemselected_id; + static int selectall_id; + static int deselectall_id; + static int invertselection_id; + static int invalidateitem_id; + static int getfirstitemvisible_id; + static int getlastitemvisible_id; + static int setfontsize_id; + static int getfontsize_id; + static int jumptonext_id; + static int scrolltoitem_id; + static int resort_id; + static int getsortdirection_id; + static int getsortcolumn_id; + static int setsortcolumn_id; + static int setsortdirection_id; + static int getitemcount_id; + static int setselectionstart_id; + static int setselectionend_id; + static int setselected_id; + static int toggleselection_id; + static int getheaderheight_id; + static int getpreventmultipleselection_id; + static int setpreventmultipleselection_id; + static int moveitem_id; + static int onselectall_id; + static int ondelete_id; + static int ondoubleclick_id; + static int onleftclick_id; + static int onsecondleftclick_id; + static int onrightclick_id; + static int oncolumndblclick_id; + static int oncolumnlabelclick_id; + static int onitemselection_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_guiobject.cpp b/Src/Wasabi/api/script/objects/c_script/c_guiobject.cpp new file mode 100644 index 00000000..0b7add98 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guiobject.cpp @@ -0,0 +1,739 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_guiobject.h" +#include <api/script/objcontroller.h> + +C_GuiObject::C_GuiObject(ScriptObject *object) : C_RootObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_GuiObject::C_GuiObject() { + inited = 0; + obj = NULL; +} + +void C_GuiObject::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, guiObjectGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + show_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"show", this); + hide_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"hide", this); + isvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isVisible", this); + onsetvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSetVisible", this); + setalpha_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAlpha", this); + getalpha_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getAlpha", this); + onleftbuttonup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftButtonUp", this); + onleftbuttondown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftButtonDown", this); + onrightbuttonup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightButtonUp", this); + onrightbuttondown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightButtonDown", this); + onrightbuttondblclk_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightButtonDblClk", this); + onleftbuttondblclk_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftButtonDblClk", this); + onmousemove_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMouseMove", this); + onenterarea_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEnterArea", this); + onleavearea_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeaveArea", this); + setenabled_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setEnabled", this); + getenabled_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getEnabled", this); + onenable_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEnable", this); + resize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"resize", this); + onresize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onResize", this); + ismouseover_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isMouseOver", this); + getleft_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getLeft", this); + gettop_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getTop", this); + getwidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getWidth", this); + getheight_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getHeight", this); + settargetx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetX", this); + settargety_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetY", this); + settargetw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetW", this); + settargeth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetH", this); + settargeta_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetA", this); + settargetspeed_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setTargetSpeed", this); + gototarget_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"gotoTarget", this); + ontargetreached_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onTargetReached", this); + canceltarget_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"cancelTarget", this); + reversetarget_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"reverseTarget", this); + onstartup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onStartup", this); + isgoingtotarget_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isGoingToTarget", this); + setxmlparam_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setXmlParam", this); + getxmlparam_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getXmlParam", this); + init_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"init", this); + bringtofront_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"bringToFront", this); + bringtoback_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"bringToBack", this); + bringabove_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"bringAbove", this); + bringbelow_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"bringBelow", this); + getguix_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiX", this); + getguiy_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiY", this); + getguiw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiW", this); + getguih_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiH", this); + getguirelatx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiRelatX", this); + getguirelaty_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiRelatY", this); + getguirelatw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiRelatW", this); + getguirelath_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getGuiRelatH", this); + isactive_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isActive", this); + getparent_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getParent", this); + getparentlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getParentLayout", this); + gettopparent_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getTopParent", this); + runmodal_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"runModal", this); + endmodal_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"endModal", this); + findobject_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"findObject", this); + findobjectxy_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"findObjectXY", this); + getname_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getName", this); + clienttoscreenx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"clientToScreenX", this); + clienttoscreeny_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"clientToScreenY", this); + clienttoscreenw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"clientToScreenW", this); + clienttoscreenh_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"clientToScreenH", this); + screentoclientx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"screenToClientX", this); + screentoclienty_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"screenToClientY", this); + screentoclientw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"screenToClientW", this); + screentoclienth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"screenToClientH", this); + getautowidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getAutoWidth", this); + getautoheight_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getAutoHeight", this); + setfocus_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setFocus", this); + onchar_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onChar", this); + onaccelerator_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onAccelerator", this); + ismouseoverrect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isMouseOverRect", this); + getinterface_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getInterface", this); + onkeydown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onKeyDown", this); + onkeyup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onKeyUp", this); + ongetfocus_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onGetFocus", this); + onkillfocus_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onKillFocus", this); + sendaction_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"sendAction", this); + onaction_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onAction", this); + } + inited = 1; +} + +C_GuiObject::~C_GuiObject() { +} + +ScriptObject *C_GuiObject::getScriptObject() { + if (obj != NULL) return obj; + return C_GUIOBJECT_PARENT::getScriptObject(); +} + +void C_GuiObject::show() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), show_id, NULL); +} + +void C_GuiObject::hide() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), hide_id, NULL); +} + +int C_GuiObject::isVisible() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isvisible_id, NULL)); +} + +void C_GuiObject::onSetVisible(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsetvisible_id, params); +} + +void C_GuiObject::setAlpha(int alpha) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(alpha); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setalpha_id, params); +} + +int C_GuiObject::getAlpha() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getalpha_id, NULL)); +} + +void C_GuiObject::onLeftButtonUp(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftbuttonup_id, params); +} + +void C_GuiObject::onLeftButtonDown(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftbuttondown_id, params); +} + +void C_GuiObject::onRightButtonUp(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightbuttonup_id, params); +} + +void C_GuiObject::onRightButtonDown(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightbuttondown_id, params); +} + +void C_GuiObject::onRightButtonDblClk(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightbuttondblclk_id, params); +} + +void C_GuiObject::onLeftButtonDblClk(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftbuttondblclk_id, params); +} + +void C_GuiObject::onMouseMove(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmousemove_id, params); +} + +void C_GuiObject::onEnterArea() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onenterarea_id, NULL); +} + +void C_GuiObject::onLeaveArea() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleavearea_id, NULL); +} + +void C_GuiObject::setEnabled(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setenabled_id, params); +} + +int C_GuiObject::getEnabled() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getenabled_id, NULL)); +} + +void C_GuiObject::onEnable(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onenable_id, params); +} + +void C_GuiObject::resize(int x, int y, int w, int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar c = MAKE_SCRIPT_INT(w); + scriptVar d = MAKE_SCRIPT_INT(h); + scriptVar *params[4] = {&a, &b, &c, &d}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), resize_id, params); +} + +void C_GuiObject::onResize(int x, int y, int w, int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar c = MAKE_SCRIPT_INT(w); + scriptVar d = MAKE_SCRIPT_INT(h); + scriptVar *params[4] = {&a, &b, &c, &d}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onresize_id, params); +} + +int C_GuiObject::isMouseOver(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), ismouseover_id, params)); +} + +int C_GuiObject::getLeft() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getleft_id, NULL)); +} + +int C_GuiObject::getTop() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettop_id, NULL)); +} + +int C_GuiObject::getWidth() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getwidth_id, NULL)); +} + +int C_GuiObject::getHeight() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getheight_id, NULL)); +} + +void C_GuiObject::setTargetX(int x) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargetx_id, params); +} + +void C_GuiObject::setTargetY(int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(y); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargety_id, params); +} + +void C_GuiObject::setTargetW(int w) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(w); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargetw_id, params); +} + +void C_GuiObject::setTargetH(int r) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(r); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargeth_id, params); +} + +void C_GuiObject::setTargetA(int alpha) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(alpha); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargeta_id, params); +} + +void C_GuiObject::setTargetSpeed(float insecond) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_FLOAT(insecond); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settargetspeed_id, params); +} + +void C_GuiObject::gotoTarget() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), gototarget_id, NULL); +} + +void C_GuiObject::onTargetReached() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontargetreached_id, NULL); +} + +void C_GuiObject::cancelTarget() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), canceltarget_id, NULL); +} + +void C_GuiObject::reverseTarget(int reverse) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(reverse); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), reversetarget_id, params); +} + +void C_GuiObject::onStartup() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onstartup_id, NULL); +} + +int C_GuiObject::isGoingToTarget() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isgoingtotarget_id, NULL)); +} + +void C_GuiObject::setXmlParam(const wchar_t *param, const wchar_t *value) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(param); + scriptVar b = MAKE_SCRIPT_STRING(value); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setxmlparam_id, params); +} + +const wchar_t *C_GuiObject::getXmlParam(const wchar_t *param) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(param); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getxmlparam_id, params)); +} + +void C_GuiObject::init(ScriptObject *parent) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(parent); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), init_id, params); +} + +void C_GuiObject::bringToFront() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), bringtofront_id, NULL); +} + +void C_GuiObject::bringToBack() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), bringtoback_id, NULL); +} + +void C_GuiObject::bringAbove(ScriptObject *guiobj) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(guiobj); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), bringabove_id, params); +} + +void C_GuiObject::bringBelow(ScriptObject *guiobj) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(guiobj); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), bringbelow_id, params); +} + +int C_GuiObject::getGuiX() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguix_id, NULL)); +} + +int C_GuiObject::getGuiY() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguiy_id, NULL)); +} + +int C_GuiObject::getGuiW() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguiw_id, NULL)); +} + +int C_GuiObject::getGuiH() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguih_id, NULL)); +} + +int C_GuiObject::getGuiRelatX() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguirelatx_id, NULL)); +} + +int C_GuiObject::getGuiRelatY() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguirelaty_id, NULL)); +} + +int C_GuiObject::getGuiRelatW() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguirelatw_id, NULL)); +} + +int C_GuiObject::getGuiRelatH() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getguirelath_id, NULL)); +} + +int C_GuiObject::isActive() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isactive_id, NULL)); +} + +ScriptObject *C_GuiObject::getParent() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getparent_id, NULL)); +} + +ScriptObject *C_GuiObject::getParentLayout() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getparentlayout_id, NULL)); +} + +ScriptObject *C_GuiObject::getTopParent() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettopparent_id, NULL)); +} + +int C_GuiObject::runModal() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), runmodal_id, NULL)); +} + +void C_GuiObject::endModal(int retcode) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(retcode); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), endmodal_id, params); +} + +ScriptObject *C_GuiObject::findObject(const wchar_t *id) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(id); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), findobject_id, params)); +} + +ScriptObject *C_GuiObject::findObjectXY(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), findobjectxy_id, params)); +} + +const wchar_t *C_GuiObject::getName() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getname_id, NULL)); +} + +int C_GuiObject::clientToScreenX(int x) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), clienttoscreenx_id, params)); +} + +int C_GuiObject::clientToScreenY(int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(y); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), clienttoscreeny_id, params)); +} + +int C_GuiObject::clientToScreenW(int w) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(w); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), clienttoscreenw_id, params)); +} + +int C_GuiObject::clientToScreenH(int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(h); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), clienttoscreenh_id, params)); +} + +int C_GuiObject::screenToClientX(int x) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), screentoclientx_id, params)); +} + +int C_GuiObject::screenToClientY(int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(y); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), screentoclienty_id, params)); +} + +int C_GuiObject::screenToClientW(int w) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(w); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), screentoclientw_id, params)); +} + +int C_GuiObject::screenToClientH(int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(h); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), screentoclienth_id, params)); +} + +int C_GuiObject::getAutoWidth() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getautowidth_id, NULL)); +} + +int C_GuiObject::getAutoHeight() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getautoheight_id, NULL)); +} + +void C_GuiObject::setFocus() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setfocus_id, NULL); +} + +void C_GuiObject::onChar(const wchar_t *c) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(c); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onchar_id, params); +} + +void C_GuiObject::onAccelerator(const wchar_t *accel) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(accel); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onaccelerator_id, params); +} + +int C_GuiObject::isMouseOverRect() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), ismouseoverrect_id, NULL)); +} + +ScriptObject *C_GuiObject::getInterface(const wchar_t *interface_guid) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(interface_guid); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getinterface_id, params)); +} + +void C_GuiObject::onKeyDown(int vk_code) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(vk_code); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onkeydown_id, params); +} + +void C_GuiObject::onKeyUp(int vk_code) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(vk_code); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onkeyup_id, params); +} + +void C_GuiObject::onGetFocus() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ongetfocus_id, NULL); +} + +void C_GuiObject::onKillFocus() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onkillfocus_id, NULL); +} + +int C_GuiObject::sendAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(action); + scriptVar b = MAKE_SCRIPT_STRING(param); + scriptVar c = MAKE_SCRIPT_INT(x); + scriptVar d = MAKE_SCRIPT_INT(y); + scriptVar e = MAKE_SCRIPT_INT((int)p1); + scriptVar f = MAKE_SCRIPT_INT((int)p2); + scriptVar *params[6] = {&a, &b, &c, &d, &e, &f}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), sendaction_id, params)); +} + +int C_GuiObject::onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, ScriptObject *source) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(action); + scriptVar b = MAKE_SCRIPT_STRING(param); + scriptVar c = MAKE_SCRIPT_INT(x); + scriptVar d = MAKE_SCRIPT_INT(y); + scriptVar e = MAKE_SCRIPT_INT((int)p1); + scriptVar f = MAKE_SCRIPT_INT((int)p2); + scriptVar g = MAKE_SCRIPT_OBJECT(source); + scriptVar *params[7] = {&a, &b, &c, &d, &e, &f, &g}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onaction_id, params)); +} + +int C_GuiObject::loaded=0; +int C_GuiObject::show_id=0; +int C_GuiObject::hide_id=0; +int C_GuiObject::isvisible_id=0; +int C_GuiObject::onsetvisible_id=0; +int C_GuiObject::setalpha_id=0; +int C_GuiObject::getalpha_id=0; +int C_GuiObject::onleftbuttonup_id=0; +int C_GuiObject::onleftbuttondown_id=0; +int C_GuiObject::onrightbuttonup_id=0; +int C_GuiObject::onrightbuttondown_id=0; +int C_GuiObject::onrightbuttondblclk_id=0; +int C_GuiObject::onleftbuttondblclk_id=0; +int C_GuiObject::onmousemove_id=0; +int C_GuiObject::onenterarea_id=0; +int C_GuiObject::onleavearea_id=0; +int C_GuiObject::setenabled_id=0; +int C_GuiObject::getenabled_id=0; +int C_GuiObject::onenable_id=0; +int C_GuiObject::resize_id=0; +int C_GuiObject::onresize_id=0; +int C_GuiObject::ismouseover_id=0; +int C_GuiObject::getleft_id=0; +int C_GuiObject::gettop_id=0; +int C_GuiObject::getwidth_id=0; +int C_GuiObject::getheight_id=0; +int C_GuiObject::settargetx_id=0; +int C_GuiObject::settargety_id=0; +int C_GuiObject::settargetw_id=0; +int C_GuiObject::settargeth_id=0; +int C_GuiObject::settargeta_id=0; +int C_GuiObject::settargetspeed_id=0; +int C_GuiObject::gototarget_id=0; +int C_GuiObject::ontargetreached_id=0; +int C_GuiObject::canceltarget_id=0; +int C_GuiObject::reversetarget_id=0; +int C_GuiObject::onstartup_id=0; +int C_GuiObject::isgoingtotarget_id=0; +int C_GuiObject::setxmlparam_id=0; +int C_GuiObject::getxmlparam_id=0; +int C_GuiObject::init_id=0; +int C_GuiObject::bringtofront_id=0; +int C_GuiObject::bringtoback_id=0; +int C_GuiObject::bringabove_id=0; +int C_GuiObject::bringbelow_id=0; +int C_GuiObject::getguix_id=0; +int C_GuiObject::getguiy_id=0; +int C_GuiObject::getguiw_id=0; +int C_GuiObject::getguih_id=0; +int C_GuiObject::getguirelatx_id=0; +int C_GuiObject::getguirelaty_id=0; +int C_GuiObject::getguirelatw_id=0; +int C_GuiObject::getguirelath_id=0; +int C_GuiObject::isactive_id=0; +int C_GuiObject::getparent_id=0; +int C_GuiObject::getparentlayout_id=0; +int C_GuiObject::gettopparent_id=0; +int C_GuiObject::runmodal_id=0; +int C_GuiObject::endmodal_id=0; +int C_GuiObject::findobject_id=0; +int C_GuiObject::findobjectxy_id=0; +int C_GuiObject::getname_id=0; +int C_GuiObject::clienttoscreenx_id=0; +int C_GuiObject::clienttoscreeny_id=0; +int C_GuiObject::clienttoscreenw_id=0; +int C_GuiObject::clienttoscreenh_id=0; +int C_GuiObject::screentoclientx_id=0; +int C_GuiObject::screentoclienty_id=0; +int C_GuiObject::screentoclientw_id=0; +int C_GuiObject::screentoclienth_id=0; +int C_GuiObject::getautowidth_id=0; +int C_GuiObject::getautoheight_id=0; +int C_GuiObject::setfocus_id=0; +int C_GuiObject::onchar_id=0; +int C_GuiObject::onaccelerator_id=0; +int C_GuiObject::ismouseoverrect_id=0; +int C_GuiObject::getinterface_id=0; +int C_GuiObject::onkeydown_id=0; +int C_GuiObject::onkeyup_id=0; +int C_GuiObject::ongetfocus_id=0; +int C_GuiObject::onkillfocus_id=0; +int C_GuiObject::sendaction_id=0; +int C_GuiObject::onaction_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_guiobject.h b/Src/Wasabi/api/script/objects/c_script/c_guiobject.h new file mode 100644 index 00000000..3922dd20 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guiobject.h @@ -0,0 +1,193 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_GUIOBJECT_H +#define __C_GUIOBJECT_H + +#include "c_rootobj.h" + +#define C_GUIOBJECT_PARENT C_RootObject + +class C_GuiObject : public C_GUIOBJECT_PARENT { + public: + + C_GuiObject(ScriptObject *object); + C_GuiObject(); + virtual ~C_GuiObject(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void show(); + virtual void hide(); + virtual int isVisible(); + virtual void onSetVisible(int onoff); + virtual void setAlpha(int alpha); + virtual int getAlpha(); + virtual void onLeftButtonUp(int x, int y); + virtual void onLeftButtonDown(int x, int y); + virtual void onRightButtonUp(int x, int y); + virtual void onRightButtonDown(int x, int y); + virtual void onRightButtonDblClk(int x, int y); + virtual void onLeftButtonDblClk(int x, int y); + virtual void onMouseMove(int x, int y); + virtual void onEnterArea(); + virtual void onLeaveArea(); + virtual void setEnabled(int onoff); + virtual int getEnabled(); + virtual void onEnable(int onoff); + virtual void resize(int x, int y, int w, int h); + virtual void onResize(int x, int y, int w, int h); + virtual int isMouseOver(int x, int y); + virtual int getLeft(); + virtual int getTop(); + virtual int getWidth(); + virtual int getHeight(); + virtual void setTargetX(int x); + virtual void setTargetY(int y); + virtual void setTargetW(int w); + virtual void setTargetH(int r); + virtual void setTargetA(int alpha); + virtual void setTargetSpeed(float insecond); + virtual void gotoTarget(); + virtual void onTargetReached(); + virtual void cancelTarget(); + virtual void reverseTarget(int reverse); + virtual void onStartup(); + virtual int isGoingToTarget(); + virtual void setXmlParam(const wchar_t *param, const wchar_t *value); + virtual const wchar_t *getXmlParam(const wchar_t *param); + virtual void init(ScriptObject *parent); + virtual void bringToFront(); + virtual void bringToBack(); + virtual void bringAbove(ScriptObject *guiobj); + virtual void bringBelow(ScriptObject *guiobj); + virtual int getGuiX(); + virtual int getGuiY(); + virtual int getGuiW(); + virtual int getGuiH(); + virtual int getGuiRelatX(); + virtual int getGuiRelatY(); + virtual int getGuiRelatW(); + virtual int getGuiRelatH(); + virtual int isActive(); + virtual ScriptObject *getParent(); + virtual ScriptObject *getParentLayout(); + virtual ScriptObject *getTopParent(); + virtual int runModal(); + virtual void endModal(int retcode); + virtual ScriptObject *findObject(const wchar_t *id); + virtual ScriptObject *findObjectXY(int x, int y); + virtual const wchar_t *getName(); + virtual int clientToScreenX(int x); + virtual int clientToScreenY(int y); + virtual int clientToScreenW(int w); + virtual int clientToScreenH(int h); + virtual int screenToClientX(int x); + virtual int screenToClientY(int y); + virtual int screenToClientW(int w); + virtual int screenToClientH(int h); + virtual int getAutoWidth(); + virtual int getAutoHeight(); + virtual void setFocus(); + virtual void onChar(const wchar_t *c); + virtual void onAccelerator(const wchar_t *accel); + virtual int isMouseOverRect(); + virtual ScriptObject *getInterface(const wchar_t *interface_guid); + virtual void onKeyDown(int vk_code); + virtual void onKeyUp(int vk_code); + virtual void onGetFocus(); + virtual void onKillFocus(); + virtual int sendAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2); + virtual int onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, ScriptObject *source); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int show_id; + static int hide_id; + static int isvisible_id; + static int onsetvisible_id; + static int setalpha_id; + static int getalpha_id; + static int onleftbuttonup_id; + static int onleftbuttondown_id; + static int onrightbuttonup_id; + static int onrightbuttondown_id; + static int onrightbuttondblclk_id; + static int onleftbuttondblclk_id; + static int onmousemove_id; + static int onenterarea_id; + static int onleavearea_id; + static int setenabled_id; + static int getenabled_id; + static int onenable_id; + static int resize_id; + static int onresize_id; + static int ismouseover_id; + static int getleft_id; + static int gettop_id; + static int getwidth_id; + static int getheight_id; + static int settargetx_id; + static int settargety_id; + static int settargetw_id; + static int settargeth_id; + static int settargeta_id; + static int settargetspeed_id; + static int gototarget_id; + static int ontargetreached_id; + static int canceltarget_id; + static int reversetarget_id; + static int onstartup_id; + static int isgoingtotarget_id; + static int setxmlparam_id; + static int getxmlparam_id; + static int init_id; + static int bringtofront_id; + static int bringtoback_id; + static int bringabove_id; + static int bringbelow_id; + static int getguix_id; + static int getguiy_id; + static int getguiw_id; + static int getguih_id; + static int getguirelatx_id; + static int getguirelaty_id; + static int getguirelatw_id; + static int getguirelath_id; + static int isactive_id; + static int getparent_id; + static int getparentlayout_id; + static int gettopparent_id; + static int runmodal_id; + static int endmodal_id; + static int findobject_id; + static int findobjectxy_id; + static int getname_id; + static int clienttoscreenx_id; + static int clienttoscreeny_id; + static int clienttoscreenw_id; + static int clienttoscreenh_id; + static int screentoclientx_id; + static int screentoclienty_id; + static int screentoclientw_id; + static int screentoclienth_id; + static int getautowidth_id; + static int getautoheight_id; + static int setfocus_id; + static int onchar_id; + static int onaccelerator_id; + static int ismouseoverrect_id; + static int getinterface_id; + static int onkeydown_id; + static int onkeyup_id; + static int ongetfocus_id; + static int onkillfocus_id; + static int sendaction_id; + static int onaction_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_guitree.cpp b/Src/Wasabi/api/script/objects/c_script/c_guitree.cpp new file mode 100644 index 00000000..aa97f3ee --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guitree.cpp @@ -0,0 +1,491 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_guitree.h" +#include <api/script/objcontroller.h> + +C_GuiTree::C_GuiTree(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_GuiTree::C_GuiTree() { + inited = 0; + obj = NULL; +} + +void C_GuiTree::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, guiTreeGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onwantautocontextmenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onWantAutoContextMenu", this); + onmousewheelup_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMouseWheelUp", this); + onmousewheeldown_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMouseWheelDown", this); + oncontextmenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onContextMenu", this); + onchar_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onChar", this); + onitemrecvdrop_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onItemRecvDrop", this); + onlabelchange_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLabelChange", this); + onitemselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onItemSelected", this); + onitemdeselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onItemDeselected", this); + getnumrootitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumRootItems", this); + enumrootitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumRootItem", this); + jumptonext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"jumpToNext", this); + ensureitemvisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"ensureItemVisible", this); + getcontentswidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getContentsWidth", this); + getcontentsheight_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getContentsHeight", this); + addtreeitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"addTreeItem", this); + removetreeitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"removeTreeItem", this); + movetreeitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"moveTreeItem", this); + deleteallitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"deleteAllItems", this); + expanditem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"expandItem", this); + expanditemdeferred_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"expandItemDeferred", this); + collapseitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"collapseItem", this); + collapseitemdeferred_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"collapseItemDeferred", this); + selectitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectItem", this); + selectitemdeferred_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"selectItemDeferred", this); + delitemdeferred_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"delItemDeferred", this); + hiliteitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"hiliteItem", this); + unhiliteitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"unhiliteItem", this); + getcuritem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getCurItem", this); + hittest_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"hitTest", this); + edititemlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"editItemLabel", this); + canceleditlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"cancelEditLabel", this); + setautoedit_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAutoEdit", this); + getautoedit_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getAutoEdit", this); + getbylabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getByLabel", this); + setsorted_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSorted", this); + getsorted_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSorted", this); + sorttreeitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"sortTreeItems", this); + getsibling_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSibling", this); + setautocollapse_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAutoCollapse", this); + setfontsize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setFontSize", this); + getfontsize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getFontSize", this); + getnumvisiblechilditems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumVisibleChildItems", this); + getnumvisibleitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumVisibleItems", this); + enumvisibleitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumVisibleItems", this); + enumvisiblechilditems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumVisibleChildItems", this); + enumallitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"enumAllItems", this); + getitemrectx_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemRectX", this); + getitemrecty_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemRectY", this); + getitemrectw_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemRectW", this); + getitemrecth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getItemRectH", this); + } + inited = 1; +} + +C_GuiTree::~C_GuiTree() { +} + +ScriptObject *C_GuiTree::getScriptObject() { + if (obj != NULL) return obj; + return C_GUITREE_PARENT::getScriptObject(); +} + +int C_GuiTree::onWantAutoContextMenu() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onwantautocontextmenu_id, NULL)); +} + +int C_GuiTree::onMouseWheelUp(int clicked, int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(clicked); + scriptVar b = MAKE_SCRIPT_INT(lines); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmousewheelup_id, params)); +} + +int C_GuiTree::onMouseWheelDown(int clicked, int lines) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(clicked); + scriptVar b = MAKE_SCRIPT_INT(lines); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmousewheeldown_id, params)); +} + +int C_GuiTree::onContextMenu(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncontextmenu_id, params)); +} + +int C_GuiTree::onChar(int c) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(c); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onchar_id, params)); +} + +void C_GuiTree::onItemRecvDrop(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onitemrecvdrop_id, params); +} + +void C_GuiTree::onLabelChange(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onlabelchange_id, params); +} + +void C_GuiTree::onItemSelected(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onitemselected_id, params); +} + +void C_GuiTree::onItemDeselected(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onitemdeselected_id, params); +} + +int C_GuiTree::getNumRootItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumrootitems_id, NULL)); +} + +ScriptObject *C_GuiTree::enumRootItem(int which) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(which); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumrootitem_id, params)); +} + +void C_GuiTree::jumpToNext(int c) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(c); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), jumptonext_id, params); +} + +void C_GuiTree::ensureItemVisible(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ensureitemvisible_id, params); +} + +int C_GuiTree::getContentsWidth() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcontentswidth_id, NULL)); +} + +int C_GuiTree::getContentsHeight() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcontentsheight_id, NULL)); +} + +ScriptObject *C_GuiTree::addTreeItem(ScriptObject *item, ScriptObject *par, int sorted, int haschildtab) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar b = MAKE_SCRIPT_OBJECT(par); + scriptVar c = MAKE_SCRIPT_INT(sorted); + scriptVar d = MAKE_SCRIPT_INT(haschildtab); + scriptVar *params[4] = {&a, &b, &c, &d}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), addtreeitem_id, params)); +} + +int C_GuiTree::removeTreeItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), removetreeitem_id, params)); +} + +void C_GuiTree::moveTreeItem(ScriptObject *item, ScriptObject *newparent) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar b = MAKE_SCRIPT_OBJECT(newparent); + scriptVar *params[2] = {&a, &b}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), movetreeitem_id, params); +} + +void C_GuiTree::deleteAllItems() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), deleteallitems_id, NULL); +} + +int C_GuiTree::expandItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), expanditem_id, params)); +} + +void C_GuiTree::expandItemDeferred(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), expanditemdeferred_id, params); +} + +int C_GuiTree::collapseItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), collapseitem_id, params)); +} + +void C_GuiTree::collapseItemDeferred(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), collapseitemdeferred_id, params); +} + +void C_GuiTree::selectItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectitem_id, params); +} + +void C_GuiTree::selectItemDeferred(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), selectitemdeferred_id, params); +} + +void C_GuiTree::delItemDeferred(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), delitemdeferred_id, params); +} + +void C_GuiTree::hiliteItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), hiliteitem_id, params); +} + +void C_GuiTree::unhiliteItem(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), unhiliteitem_id, params); +} + +ScriptObject *C_GuiTree::getCurItem() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcuritem_id, NULL)); +} + +ScriptObject *C_GuiTree::hitTest(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), hittest_id, params)); +} + +void C_GuiTree::editItemLabel(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), edititemlabel_id, params); +} + +void C_GuiTree::cancelEditLabel(int destroyit) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(destroyit); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), canceleditlabel_id, params); +} + +void C_GuiTree::setAutoEdit(int ae) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(ae); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setautoedit_id, params); +} + +int C_GuiTree::getAutoEdit() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getautoedit_id, NULL)); +} + +ScriptObject *C_GuiTree::getByLabel(ScriptObject *item, const wchar_t *name) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar b = MAKE_SCRIPT_STRING(name); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getbylabel_id, params)); +} + +void C_GuiTree::setSorted(int dosort) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(dosort); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setsorted_id, params); +} + +int C_GuiTree::getSorted() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsorted_id, NULL)); +} + +void C_GuiTree::sortTreeItems() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), sorttreeitems_id, NULL); +} + +ScriptObject *C_GuiTree::getSibling(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsibling_id, params)); +} + +void C_GuiTree::setAutoCollapse(int doautocollapse) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(doautocollapse); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setautocollapse_id, params); +} + +int C_GuiTree::setFontSize(int newsize) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(newsize); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), setfontsize_id, params)); +} + +int C_GuiTree::getFontSize() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getfontsize_id, NULL)); +} + +int C_GuiTree::getNumVisibleChildItems(ScriptObject *c) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(c); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumvisiblechilditems_id, params)); +} + +int C_GuiTree::getNumVisibleItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumvisibleitems_id, NULL)); +} + +ScriptObject *C_GuiTree::enumVisibleItems(int n) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(n); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumvisibleitems_id, params)); +} + +ScriptObject *C_GuiTree::enumVisibleChildItems(ScriptObject *c, int n) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(c); + scriptVar b = MAKE_SCRIPT_INT(n); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumvisiblechilditems_id, params)); +} + +ScriptObject *C_GuiTree::enumAllItems(int n) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(n); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), enumallitems_id, params)); +} + +int C_GuiTree::getItemRectX(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemrectx_id, params)); +} + +int C_GuiTree::getItemRectY(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemrecty_id, params)); +} + +int C_GuiTree::getItemRectW(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemrectw_id, params)); +} + +int C_GuiTree::getItemRectH(ScriptObject *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getitemrecth_id, params)); +} + +int C_GuiTree::loaded=0; +int C_GuiTree::onwantautocontextmenu_id=0; +int C_GuiTree::onmousewheelup_id=0; +int C_GuiTree::onmousewheeldown_id=0; +int C_GuiTree::oncontextmenu_id=0; +int C_GuiTree::onchar_id=0; +int C_GuiTree::onitemrecvdrop_id=0; +int C_GuiTree::onlabelchange_id=0; +int C_GuiTree::onitemselected_id=0; +int C_GuiTree::onitemdeselected_id=0; +int C_GuiTree::getnumrootitems_id=0; +int C_GuiTree::enumrootitem_id=0; +int C_GuiTree::jumptonext_id=0; +int C_GuiTree::ensureitemvisible_id=0; +int C_GuiTree::getcontentswidth_id=0; +int C_GuiTree::getcontentsheight_id=0; +int C_GuiTree::addtreeitem_id=0; +int C_GuiTree::removetreeitem_id=0; +int C_GuiTree::movetreeitem_id=0; +int C_GuiTree::deleteallitems_id=0; +int C_GuiTree::expanditem_id=0; +int C_GuiTree::expanditemdeferred_id=0; +int C_GuiTree::collapseitem_id=0; +int C_GuiTree::collapseitemdeferred_id=0; +int C_GuiTree::selectitem_id=0; +int C_GuiTree::selectitemdeferred_id=0; +int C_GuiTree::delitemdeferred_id=0; +int C_GuiTree::hiliteitem_id=0; +int C_GuiTree::unhiliteitem_id=0; +int C_GuiTree::getcuritem_id=0; +int C_GuiTree::hittest_id=0; +int C_GuiTree::edititemlabel_id=0; +int C_GuiTree::canceleditlabel_id=0; +int C_GuiTree::setautoedit_id=0; +int C_GuiTree::getautoedit_id=0; +int C_GuiTree::getbylabel_id=0; +int C_GuiTree::setsorted_id=0; +int C_GuiTree::getsorted_id=0; +int C_GuiTree::sorttreeitems_id=0; +int C_GuiTree::getsibling_id=0; +int C_GuiTree::setautocollapse_id=0; +int C_GuiTree::setfontsize_id=0; +int C_GuiTree::getfontsize_id=0; +int C_GuiTree::getnumvisiblechilditems_id=0; +int C_GuiTree::getnumvisibleitems_id=0; +int C_GuiTree::enumvisibleitems_id=0; +int C_GuiTree::enumvisiblechilditems_id=0; +int C_GuiTree::enumallitems_id=0; +int C_GuiTree::getitemrectx_id=0; +int C_GuiTree::getitemrecty_id=0; +int C_GuiTree::getitemrectw_id=0; +int C_GuiTree::getitemrecth_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_guitree.h b/Src/Wasabi/api/script/objects/c_script/c_guitree.h new file mode 100644 index 00000000..296e0043 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_guitree.h @@ -0,0 +1,131 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_GUITREE_H +#define __C_GUITREE_H + +#include "c_guiobject.h" + +#define C_GUITREE_PARENT C_GuiObject + +class C_GuiTree : public C_GUITREE_PARENT { + public: + + C_GuiTree(ScriptObject *object); + C_GuiTree(); + virtual ~C_GuiTree(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual int onWantAutoContextMenu(); + virtual int onMouseWheelUp(int clicked, int lines); + virtual int onMouseWheelDown(int clicked, int lines); + virtual int onContextMenu(int x, int y); + virtual int onChar(int c); + virtual void onItemRecvDrop(ScriptObject *item); + virtual void onLabelChange(ScriptObject *item); + virtual void onItemSelected(ScriptObject *item); + virtual void onItemDeselected(ScriptObject *item); + virtual int getNumRootItems(); + virtual ScriptObject *enumRootItem(int which); + virtual void jumpToNext(int c); + virtual void ensureItemVisible(ScriptObject *item); + virtual int getContentsWidth(); + virtual int getContentsHeight(); + virtual ScriptObject *addTreeItem(ScriptObject *item, ScriptObject *par, int sorted, int haschildtab); + virtual int removeTreeItem(ScriptObject *item); + virtual void moveTreeItem(ScriptObject *item, ScriptObject *newparent); + virtual void deleteAllItems(); + virtual int expandItem(ScriptObject *item); + virtual void expandItemDeferred(ScriptObject *item); + virtual int collapseItem(ScriptObject *item); + virtual void collapseItemDeferred(ScriptObject *item); + virtual void selectItem(ScriptObject *item); + virtual void selectItemDeferred(ScriptObject *item); + virtual void delItemDeferred(ScriptObject *item); + virtual void hiliteItem(ScriptObject *item); + virtual void unhiliteItem(ScriptObject *item); + virtual ScriptObject *getCurItem(); + virtual ScriptObject *hitTest(int x, int y); + virtual void editItemLabel(ScriptObject *item); + virtual void cancelEditLabel(int destroyit); + virtual void setAutoEdit(int ae); + virtual int getAutoEdit(); + virtual ScriptObject *getByLabel(ScriptObject *item, const wchar_t *name); + virtual void setSorted(int dosort); + virtual int getSorted(); + virtual void sortTreeItems(); + virtual ScriptObject *getSibling(ScriptObject *item); + virtual void setAutoCollapse(int doautocollapse); + virtual int setFontSize(int newsize); + virtual int getFontSize(); + virtual int getNumVisibleChildItems(ScriptObject *c); + virtual int getNumVisibleItems(); + virtual ScriptObject *enumVisibleItems(int n); + virtual ScriptObject *enumVisibleChildItems(ScriptObject *c, int n); + virtual ScriptObject *enumAllItems(int n); + virtual int getItemRectX(ScriptObject *item); + virtual int getItemRectY(ScriptObject *item); + virtual int getItemRectW(ScriptObject *item); + virtual int getItemRectH(ScriptObject *item); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onwantautocontextmenu_id; + static int onmousewheelup_id; + static int onmousewheeldown_id; + static int oncontextmenu_id; + static int onchar_id; + static int onitemrecvdrop_id; + static int onlabelchange_id; + static int onitemselected_id; + static int onitemdeselected_id; + static int getnumrootitems_id; + static int enumrootitem_id; + static int jumptonext_id; + static int ensureitemvisible_id; + static int getcontentswidth_id; + static int getcontentsheight_id; + static int addtreeitem_id; + static int removetreeitem_id; + static int movetreeitem_id; + static int deleteallitems_id; + static int expanditem_id; + static int expanditemdeferred_id; + static int collapseitem_id; + static int collapseitemdeferred_id; + static int selectitem_id; + static int selectitemdeferred_id; + static int delitemdeferred_id; + static int hiliteitem_id; + static int unhiliteitem_id; + static int getcuritem_id; + static int hittest_id; + static int edititemlabel_id; + static int canceleditlabel_id; + static int setautoedit_id; + static int getautoedit_id; + static int getbylabel_id; + static int setsorted_id; + static int getsorted_id; + static int sorttreeitems_id; + static int getsibling_id; + static int setautocollapse_id; + static int setfontsize_id; + static int getfontsize_id; + static int getnumvisiblechilditems_id; + static int getnumvisibleitems_id; + static int enumvisibleitems_id; + static int enumvisiblechilditems_id; + static int enumallitems_id; + static int getitemrectx_id; + static int getitemrecty_id; + static int getitemrectw_id; + static int getitemrecth_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_layout.cpp b/Src/Wasabi/api/script/objects/c_script/c_layout.cpp new file mode 100644 index 00000000..cc87042f --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_layout.cpp @@ -0,0 +1,236 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_layout.h" +#include <api/script/objcontroller.h> + +C_Layout::C_Layout(ScriptObject *object) : C_Group(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Layout::C_Layout() { + inited = 0; + obj = NULL; +} + +void C_Layout::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, layoutGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + ondock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onDock", this); + onundock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onUndock", this); + onscale_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onScale", this); + getscale_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getScale", this); + setscale_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setScale", this); + setdesktopalpha_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setDesktopAlpha", this); + getdesktopalpha_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getDesktopAlpha", this); + getcontainer_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getContainer", this); + center_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"center", this); + onmove_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMove", this); + onendmove_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEndMove", this); + onuserresize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onUserResize", this); + snapadjust_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"snapAdjust", this); + getsnapadjusttop_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSnapAdjustTop", this); + getsnapadjustright_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSnapAdjustRight", this); + getsnapadjustleft_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSnapAdjustLeft", this); + getsnapadjustbottom_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSnapAdjustBottom", this); + setredrawonresize_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setRedrawOnResize", this); + beforeredock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"beforeRedock", this); + redock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"redock", this); + istransparencysafe_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isTransparencySafe", this); + islayoutanimationsafe_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isLayoutAnimationSafe", this); + onmouseenterlayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMouseEnterLayout", this); + onmouseleavelayout_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onMouseLeaveLayout", this); + onsnapadjustchanged_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSnapAdjustChanged", this); + } + inited = 1; +} + +C_Layout::~C_Layout() { +} + +ScriptObject *C_Layout::getScriptObject() { + if (obj != NULL) return obj; + return C_LAYOUT_PARENT::getScriptObject(); +} + +void C_Layout::onDock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ondock_id, NULL); +} + +void C_Layout::onUndock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onundock_id, NULL); +} + +void C_Layout::onScale(double newscalevalue) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_DOUBLE(newscalevalue); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onscale_id, params); +} + +double C_Layout::getScale() { + ASSERT(inited); + return GET_SCRIPT_DOUBLE(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getscale_id, NULL)); +} + +void C_Layout::setScale(double scalevalue) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_DOUBLE(scalevalue); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setscale_id, params); +} + +void C_Layout::setDesktopAlpha(int onoff) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(onoff); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setdesktopalpha_id, params); +} + +int C_Layout::getDesktopAlpha() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getdesktopalpha_id, NULL)); +} + +ScriptObject *C_Layout::getContainer() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcontainer_id, NULL)); +} + +void C_Layout::center() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), center_id, NULL); +} + +void C_Layout::onMove() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmove_id, NULL); +} + +void C_Layout::onEndMove() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onendmove_id, NULL); +} + +void C_Layout::onUserResize(int x, int y, int w, int h) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar c = MAKE_SCRIPT_INT(w); + scriptVar d = MAKE_SCRIPT_INT(h); + scriptVar *params[4] = {&a, &b, &c, &d}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onuserresize_id, params); +} + +void C_Layout::snapAdjust(int left, int top, int right, int bottom) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(left); + scriptVar b = MAKE_SCRIPT_INT(top); + scriptVar c = MAKE_SCRIPT_INT(right); + scriptVar d = MAKE_SCRIPT_INT(bottom); + scriptVar *params[4] = {&a, &b, &c, &d}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), snapadjust_id, params); +} + +int C_Layout::getSnapAdjustTop() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsnapadjusttop_id, NULL)); +} + +int C_Layout::getSnapAdjustRight() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsnapadjustright_id, NULL)); +} + +int C_Layout::getSnapAdjustLeft() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsnapadjustleft_id, NULL)); +} + +int C_Layout::getSnapAdjustBottom() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsnapadjustbottom_id, NULL)); +} + +void C_Layout::setRedrawOnResize(int wantredrawonresize) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(wantredrawonresize); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setredrawonresize_id, params); +} + +void C_Layout::beforeRedock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), beforeredock_id, NULL); +} + +void C_Layout::redock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), redock_id, NULL); +} + +int C_Layout::isTransparencySafe() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), istransparencysafe_id, NULL)); +} + +int C_Layout::isLayoutAnimationSafe() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), islayoutanimationsafe_id, NULL)); +} + +void C_Layout::onMouseEnterLayout() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmouseenterlayout_id, NULL); +} + +void C_Layout::onMouseLeaveLayout() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onmouseleavelayout_id, NULL); +} + +void C_Layout::onSnapAdjustChanged() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsnapadjustchanged_id, NULL); +} + +int C_Layout::loaded=0; +int C_Layout::ondock_id=0; +int C_Layout::onundock_id=0; +int C_Layout::onscale_id=0; +int C_Layout::getscale_id=0; +int C_Layout::setscale_id=0; +int C_Layout::setdesktopalpha_id=0; +int C_Layout::getdesktopalpha_id=0; +int C_Layout::getcontainer_id=0; +int C_Layout::center_id=0; +int C_Layout::onmove_id=0; +int C_Layout::onendmove_id=0; +int C_Layout::onuserresize_id=0; +int C_Layout::snapadjust_id=0; +int C_Layout::getsnapadjusttop_id=0; +int C_Layout::getsnapadjustright_id=0; +int C_Layout::getsnapadjustleft_id=0; +int C_Layout::getsnapadjustbottom_id=0; +int C_Layout::setredrawonresize_id=0; +int C_Layout::beforeredock_id=0; +int C_Layout::redock_id=0; +int C_Layout::istransparencysafe_id=0; +int C_Layout::islayoutanimationsafe_id=0; +int C_Layout::onmouseenterlayout_id=0; +int C_Layout::onmouseleavelayout_id=0; +int C_Layout::onsnapadjustchanged_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_layout.h b/Src/Wasabi/api/script/objects/c_script/c_layout.h new file mode 100644 index 00000000..158a0545 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_layout.h @@ -0,0 +1,79 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_LAYOUT_H +#define __C_LAYOUT_H + +#include "c_group.h" + +#define C_LAYOUT_PARENT C_Group + +class C_Layout : public C_LAYOUT_PARENT { + public: + + C_Layout(ScriptObject *object); + C_Layout(); + virtual ~C_Layout(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onDock(); + virtual void onUndock(); + virtual void onScale(double newscalevalue); + virtual double getScale(); + virtual void setScale(double scalevalue); + virtual void setDesktopAlpha(int onoff); + virtual int getDesktopAlpha(); + virtual ScriptObject *getContainer(); + virtual void center(); + virtual void onMove(); + virtual void onEndMove(); + virtual void onUserResize(int x, int y, int w, int h); + virtual void snapAdjust(int left, int top, int right, int bottom); + virtual int getSnapAdjustTop(); + virtual int getSnapAdjustRight(); + virtual int getSnapAdjustLeft(); + virtual int getSnapAdjustBottom(); + virtual void setRedrawOnResize(int wantredrawonresize); + virtual void beforeRedock(); + virtual void redock(); + virtual int isTransparencySafe(); + virtual int isLayoutAnimationSafe(); + virtual void onMouseEnterLayout(); + virtual void onMouseLeaveLayout(); + virtual void onSnapAdjustChanged(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ondock_id; + static int onundock_id; + static int onscale_id; + static int getscale_id; + static int setscale_id; + static int setdesktopalpha_id; + static int getdesktopalpha_id; + static int getcontainer_id; + static int center_id; + static int onmove_id; + static int onendmove_id; + static int onuserresize_id; + static int snapadjust_id; + static int getsnapadjusttop_id; + static int getsnapadjustright_id; + static int getsnapadjustleft_id; + static int getsnapadjustbottom_id; + static int setredrawonresize_id; + static int beforeredock_id; + static int redock_id; + static int istransparencysafe_id; + static int islayoutanimationsafe_id; + static int onmouseenterlayout_id; + static int onmouseleavelayout_id; + static int onsnapadjustchanged_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_menubutton.cpp b/Src/Wasabi/api/script/objects/c_script/c_menubutton.cpp new file mode 100644 index 00000000..a79909e1 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_menubutton.cpp @@ -0,0 +1,80 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_menubutton.h" +#include <api/script/objcontroller.h> + +C_MenuButton::C_MenuButton(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_MenuButton::C_MenuButton() { + inited = 0; + obj = NULL; +} + +void C_MenuButton::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, menuButtonGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onopenmenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onOpenMenu", this); + onclosemenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onCloseMenu", this); + onselectitem_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSelectItem", this); + openmenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"openMenu", this); + closemenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"closeMenu", this); + } + inited = 1; +} + +C_MenuButton::~C_MenuButton() { +} + +ScriptObject *C_MenuButton::getScriptObject() { + if (obj != NULL) return obj; + return C_MENUBUTTON_PARENT::getScriptObject(); +} + +void C_MenuButton::onOpenMenu() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onopenmenu_id, NULL); +} + +void C_MenuButton::onCloseMenu() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onclosemenu_id, NULL); +} + +void C_MenuButton::onSelectItem(const wchar_t *item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(item); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onselectitem_id, params); +} + +void C_MenuButton::openMenu() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), openmenu_id, NULL); +} + +void C_MenuButton::closeMenu() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), closemenu_id, NULL); +} + +int C_MenuButton::loaded=0; +int C_MenuButton::onopenmenu_id=0; +int C_MenuButton::onclosemenu_id=0; +int C_MenuButton::onselectitem_id=0; +int C_MenuButton::openmenu_id=0; +int C_MenuButton::closemenu_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_menubutton.h b/Src/Wasabi/api/script/objects/c_script/c_menubutton.h new file mode 100644 index 00000000..2da559ba --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_menubutton.h @@ -0,0 +1,39 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_MENUBUTTON_H +#define __C_MENUBUTTON_H + +#include "c_guiobject.h" + +#define C_MENUBUTTON_PARENT C_GuiObject + +class C_MenuButton : public C_MENUBUTTON_PARENT { + public: + + C_MenuButton(ScriptObject *object); + C_MenuButton(); + virtual ~C_MenuButton(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onOpenMenu(); + virtual void onCloseMenu(); + virtual void onSelectItem(const wchar_t *item); + virtual void openMenu(); + virtual void closeMenu(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onopenmenu_id; + static int onclosemenu_id; + static int onselectitem_id; + static int openmenu_id; + static int closemenu_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_querylist.cpp b/Src/Wasabi/api/script/objects/c_script/c_querylist.cpp new file mode 100644 index 00000000..8535bcf5 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_querylist.cpp @@ -0,0 +1,49 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_querylist.h" +#include <api/script/objcontroller.h> + +C_QueryList::C_QueryList(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_QueryList::C_QueryList() { + inited = 0; + obj = NULL; +} + +void C_QueryList::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, queryListGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + if (!loaded) { + loaded = 1; + onresetquery_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onResetQuery", this); + } + inited = 1; +} + +C_QueryList::~C_QueryList() { +} + +ScriptObject *C_QueryList::getScriptObject() { + if (obj != NULL) return obj; + return C_QUERYLIST_PARENT::getScriptObject(); +} + +void C_QueryList::onResetQuery() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onresetquery_id, NULL); +} + +int C_QueryList::loaded=0; +int C_QueryList::onresetquery_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_querylist.h b/Src/Wasabi/api/script/objects/c_script/c_querylist.h new file mode 100644 index 00000000..51c18a77 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_querylist.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_QUERYLIST_H +#define __C_QUERYLIST_H + +#include "c_guiobject.h" + +#define C_QUERYLIST_PARENT C_GuiObject + +class C_QueryList : public C_QUERYLIST_PARENT { + public: + + C_QueryList(ScriptObject *object); + C_QueryList(); + virtual ~C_QueryList(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onResetQuery(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onresetquery_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_rootobj.cpp b/Src/Wasabi/api/script/objects/c_script/c_rootobj.cpp new file mode 100644 index 00000000..304d1715 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_rootobj.cpp @@ -0,0 +1,64 @@ +#include <precomp.h> + +#include <api/script/scriptobj.h> +#include <api/script/objcontroller.h> +#include "c_rootobj.h" + +C_RootObject::C_RootObject(ScriptObject *o) +{ + inited = 0; + obj = NULL; + C_hook(o); +} + +C_RootObject::C_RootObject() +{ + inited = 0; + obj = NULL; +} + +void C_RootObject::C_hook(ScriptObject *o) +{ + ASSERT(!inited); + obj = o; + if (count++ == 0) { + getclassname_id = WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"getClassName", this); + notify_id = WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"notify", this); + } + inited=1; +} + +C_RootObject::~C_RootObject() +{ + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); + //count--; +} + +ScriptObject *C_RootObject::getScriptObject() +{ + ASSERT(inited); + return obj; +} + +const wchar_t *C_RootObject::getClassName() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(obj, getclassname_id, NULL)); +} + +void C_RootObject::notify(const wchar_t *a, const wchar_t *b, int c, int d) +{ + ASSERT(inited); + scriptVar _a = MAKE_SCRIPT_STRING(a); + scriptVar _b = MAKE_SCRIPT_STRING(b); + scriptVar _c = MAKE_SCRIPT_INT(c); + scriptVar _d = MAKE_SCRIPT_INT(d); + scriptVar *params[4]={&_a, &_b, &_c, &_d}; + WASABI_API_MAKI->maki_callFunction(obj, notify_id, params); +} + +int C_RootObject::getclassname_id=0; +int C_RootObject::notify_id=0; +int C_RootObject::inited=0; +int C_RootObject::count=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_rootobj.h b/Src/Wasabi/api/script/objects/c_script/c_rootobj.h new file mode 100644 index 00000000..780b83b1 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_rootobj.h @@ -0,0 +1,33 @@ +#ifndef __C_SCRIPTOBJ_H +#define __C_SCRIPTOBJ_H + +#include <api/script/scriptobj.h> + +class C_RootObject{ + + public: + + C_RootObject(ScriptObject *o); + C_RootObject(); + virtual ~C_RootObject(); + + virtual void C_hook(ScriptObject *o); + + virtual const wchar_t *getClassName(); + virtual void notify(const wchar_t *a, const wchar_t *b, int c, int d); + virtual ScriptObject *getScriptObject(); + + operator ScriptObject *() { return getScriptObject(); } + + private: + + ScriptObject *obj; + static int getclassname_id; + static int notify_id; + static int inited; + static int count; +}; + + + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_slider.cpp b/Src/Wasabi/api/script/objects/c_script/c_slider.cpp new file mode 100644 index 00000000..0aaaa4b1 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_slider.cpp @@ -0,0 +1,100 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_slider.h" +#include <api/script/objcontroller.h> + +C_Slider::C_Slider(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Slider::C_Slider() { + inited = 0; + obj = NULL; +} + +void C_Slider::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, sliderGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + onsetposition_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSetPosition", this); + onpostedposition_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onPostedPosition", this); + onsetfinalposition_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSetFinalPosition", this); + setposition_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setPosition", this); + getposition_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getPosition", this); + lock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"lock", this); + unlock_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"unlock", this); + } + inited = 1; +} + +C_Slider::~C_Slider() { +} + +ScriptObject *C_Slider::getScriptObject() { + if (obj != NULL) return obj; + return C_SLIDER_PARENT::getScriptObject(); +} + +void C_Slider::onSetPosition(int newpos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(newpos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsetposition_id, params); +} + +void C_Slider::onPostedPosition(int newpos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(newpos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onpostedposition_id, params); +} + +void C_Slider::onSetFinalPosition(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onsetfinalposition_id, params); +} + +void C_Slider::setPosition(int pos) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(pos); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setposition_id, params); +} + +int C_Slider::getPosition() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getposition_id, NULL)); +} + +void C_Slider::lock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), lock_id, NULL); +} + +void C_Slider::unlock() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), unlock_id, NULL); +} + +int C_Slider::loaded=0; +int C_Slider::onsetposition_id=0; +int C_Slider::onpostedposition_id=0; +int C_Slider::onsetfinalposition_id=0; +int C_Slider::setposition_id=0; +int C_Slider::getposition_id=0; +int C_Slider::lock_id=0; +int C_Slider::unlock_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_slider.h b/Src/Wasabi/api/script/objects/c_script/c_slider.h new file mode 100644 index 00000000..a7d96fc0 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_slider.h @@ -0,0 +1,43 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_SLIDER_H +#define __C_SLIDER_H + +#include "c_guiobject.h" + +#define C_SLIDER_PARENT C_GuiObject + +class C_Slider : public C_SLIDER_PARENT { + public: + + C_Slider(ScriptObject *object); + C_Slider(); + virtual ~C_Slider(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onSetPosition(int newpos); + virtual void onPostedPosition(int newpos); + virtual void onSetFinalPosition(int pos); + virtual void setPosition(int pos); + virtual int getPosition(); + virtual void lock(); + virtual void unlock(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onsetposition_id; + static int onpostedposition_id; + static int onsetfinalposition_id; + static int setposition_id; + static int getposition_id; + static int lock_id; + static int unlock_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_tabsheet.cpp b/Src/Wasabi/api/script/objects/c_script/c_tabsheet.cpp new file mode 100644 index 00000000..b7455187 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_tabsheet.cpp @@ -0,0 +1,59 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> +#include <api/api.h> +#include "c_tabsheet.h" +#include <api/script/objcontroller.h> + +C_TabSheet::C_TabSheet(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_TabSheet::C_TabSheet() { + inited = 0; + obj = NULL; +} + +void C_TabSheet::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, tabSheetGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + getcurpage_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getCurPage", this); + setcurpage_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setCurPage", this); + } + inited = 1; +} + +C_TabSheet::~C_TabSheet() { +} + +ScriptObject *C_TabSheet::getScriptObject() { + if (obj != NULL) return obj; + return C_TABSHEET_PARENT::getScriptObject(); +} + +int C_TabSheet::getCurPage() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcurpage_id, NULL)); +} + +void C_TabSheet::setCurPage(int a) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(a); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setcurpage_id, params); +} + +int C_TabSheet::loaded=0; +int C_TabSheet::getcurpage_id=0; +int C_TabSheet::setcurpage_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_tabsheet.h b/Src/Wasabi/api/script/objects/c_script/c_tabsheet.h new file mode 100644 index 00000000..5d2323d7 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_tabsheet.h @@ -0,0 +1,33 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_TABSHEET_H +#define __C_TABSHEET_H + +#include "c_guiobject.h" + +#define C_TABSHEET_PARENT C_GuiObject + +class C_TabSheet : public C_TABSHEET_PARENT { + public: + + C_TabSheet(ScriptObject *object); + C_TabSheet(); + virtual ~C_TabSheet(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual int getCurPage(); + virtual void setCurPage(int a); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int getcurpage_id; + static int setcurpage_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_text.cpp b/Src/Wasabi/api/script/objects/c_script/c_text.cpp new file mode 100644 index 00000000..0d178d01 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_text.cpp @@ -0,0 +1,89 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_text.h" +#include <api/script/objcontroller.h> + +C_Text::C_Text(ScriptObject *object) : C_GuiObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_Text::C_Text() { + inited = 0; + obj = NULL; +} + +void C_Text::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, textGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + settext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setText", this); + setalternatetext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setAlternateText", this); + gettext_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getText", this); + gettextwidth_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getTextWidth", this); + ontextchanged_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onTextChanged", this); + } + inited = 1; +} + +C_Text::~C_Text() { +} + +ScriptObject *C_Text::getScriptObject() { + if (obj != NULL) return obj; + return C_TEXT_PARENT::getScriptObject(); +} + +void C_Text::setText(const wchar_t *txt) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(txt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), settext_id, params); +} + +void C_Text::setAlternateText(const wchar_t *txt) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(txt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setalternatetext_id, params); +} + +const wchar_t *C_Text::getText() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettext_id, NULL)); +} + +int C_Text::getTextWidth() +{ + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettextwidth_id, NULL)); +} + +void C_Text::onTextChanged(const wchar_t *newtxt) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(newtxt); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontextchanged_id, params); +} + +int C_Text::loaded=0; +int C_Text::settext_id=0; +int C_Text::setalternatetext_id=0; +int C_Text::gettext_id=0; +int C_Text::gettextwidth_id=0; +int C_Text::ontextchanged_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_text.h b/Src/Wasabi/api/script/objects/c_script/c_text.h new file mode 100644 index 00000000..5a997c47 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_text.h @@ -0,0 +1,40 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_TEXT_H +#define __C_TEXT_H + +#include "c_guiobject.h" + +#define C_TEXT_PARENT C_GuiObject + +class C_Text : public C_TEXT_PARENT +{ + public: + + C_Text(ScriptObject *object); + C_Text(); + virtual ~C_Text(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void setText(const wchar_t *txt); + virtual void setAlternateText(const wchar_t *txt); + virtual const wchar_t *getText(); + virtual int getTextWidth(); + virtual void onTextChanged(const wchar_t *newtxt); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int settext_id; + static int setalternatetext_id; + static int gettext_id; + static int gettextwidth_id; + static int ontextchanged_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_togglebutton.cpp b/Src/Wasabi/api/script/objects/c_script/c_togglebutton.cpp new file mode 100644 index 00000000..93a8e0a0 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_togglebutton.cpp @@ -0,0 +1,59 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_togglebutton.h" +#include <api/script/objcontroller.h> + +C_ToggleButton::C_ToggleButton(ScriptObject *object) : C_Button(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_ToggleButton::C_ToggleButton() { + inited = 0; + obj = NULL; +} + +void C_ToggleButton::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, toggleButtonGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + ontoggle_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onToggle", this); + getcurcfgval_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getCurCfgVal", this); + } + inited = 1; +} + +C_ToggleButton::~C_ToggleButton() { +} + +ScriptObject *C_ToggleButton::getScriptObject() { + if (obj != NULL) return obj; + return C_TOGGLEBUTTON_PARENT::getScriptObject(); +} + +void C_ToggleButton::onToggle(int (null)) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT((null)); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontoggle_id, params); +} + +int C_ToggleButton::getCurCfgVal() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getcurcfgval_id, NULL)); +} + +int C_ToggleButton::loaded=0; +int C_ToggleButton::ontoggle_id=0; +int C_ToggleButton::getcurcfgval_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_togglebutton.h b/Src/Wasabi/api/script/objects/c_script/c_togglebutton.h new file mode 100644 index 00000000..0abcb656 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_togglebutton.h @@ -0,0 +1,33 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_TOGGLEBUTTON_H +#define __C_TOGGLEBUTTON_H + +#include "c_button.h" + +#define C_TOGGLEBUTTON_PARENT C_Button + +class C_ToggleButton : public C_TOGGLEBUTTON_PARENT { + public: + + C_ToggleButton(ScriptObject *object); + C_ToggleButton(); + virtual ~C_ToggleButton(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual void onToggle(int (null)); + virtual int getCurCfgVal(); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontoggle_id; + static int getcurcfgval_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/c_treeitem.cpp b/Src/Wasabi/api/script/objects/c_script/c_treeitem.cpp new file mode 100644 index 00000000..337c441b --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_treeitem.cpp @@ -0,0 +1,310 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include "c_treeitem.h" +#include <api/script/objcontroller.h> + +C_TreeItem::C_TreeItem(ScriptObject *object) : C_RootObject(object) { + inited = 0; + obj = NULL; + C_hook(object); +} + +C_TreeItem::C_TreeItem() { + inited = 0; + obj = NULL; +} + +void C_TreeItem::C_hook(ScriptObject *object) { + ASSERT(!inited); + ScriptObjectController *controller = object->vcpu_getController(); + obj = controller->cast(object, treeItemGuid); + if (obj != object && obj != NULL) + controller = obj->vcpu_getController(); + else + obj = NULL; + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = iter; + getnumchildren_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNumChildren", this); + setlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setLabel", this); + getlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getLabel", this); + ensurevisible_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"ensureVisible", this); + getnthchild_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getNthChild", this); + getchild_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getChild", this); + getchildsibling_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getChildSibling", this); + getsibling_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getSibling", this); + getparent_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getParent", this); + editlabel_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"editLabel", this); + hassubitems_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"hasSubItems", this); + setsorted_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setSorted", this); + setchildtab_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setChildTab", this); + issorted_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isSorted", this); + iscollapsed_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isCollapsed", this); + isexpanded_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isExpanded", this); + invalidate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"invalidate", this); + isselected_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isSelected", this); + ishilited_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"isHilited", this); + sethilited_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setHilited", this); + collapse_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"collapse", this); + expand_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"expand", this); + gettree_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getTree", this); + ontreeadd_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onTreeAdd", this); + ontreeremove_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onTreeRemove", this); + onselect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onSelect", this); + ondeselect_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onDeselect", this); + onleftdoubleclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftDoubleClick", this); + onrightdoubleclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightDoubleClick", this); + onchar_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onChar", this); + onexpand_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onExpand", this); + oncollapse_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onCollapse", this); + onbeginlabeledit_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onBeginLabelEdit", this); + onendlabeledit_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onEndLabelEdit", this); + oncontextmenu_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onContextMenu", this); + } + inited = 1; +} + +C_TreeItem::~C_TreeItem() { +} + +ScriptObject *C_TreeItem::getScriptObject() { + if (obj != NULL) return obj; + return C_TREEITEM_PARENT::getScriptObject(); +} + +int C_TreeItem::getNumChildren() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnumchildren_id, NULL)); +} + +void C_TreeItem::setLabel(const wchar_t *label) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(label); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setlabel_id, params); +} + +const wchar_t *C_TreeItem::getLabel() +{ + ASSERT(inited); + return GET_SCRIPT_STRING(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getlabel_id, NULL)); +} + +void C_TreeItem::ensureVisible() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ensurevisible_id, NULL); +} + +ScriptObject *C_TreeItem::getNthChild(int nth) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(nth); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getnthchild_id, params)); +} + +ScriptObject *C_TreeItem::getChild() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getchild_id, NULL)); +} + +ScriptObject *C_TreeItem::getChildSibling(ScriptObject *_item) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_OBJECT(_item); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getchildsibling_id, params)); +} + +ScriptObject *C_TreeItem::getSibling() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getsibling_id, NULL)); +} + +ScriptObject *C_TreeItem::getParent() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getparent_id, NULL)); +} + +void C_TreeItem::editLabel() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), editlabel_id, NULL); +} + +int C_TreeItem::hasSubItems() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), hassubitems_id, NULL)); +} + +void C_TreeItem::setSorted(int issorted) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(issorted); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setsorted_id, params); +} + +void C_TreeItem::setChildTab(int haschildtab) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(haschildtab); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), setchildtab_id, params); +} + +int C_TreeItem::isSorted() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), issorted_id, NULL)); +} + +int C_TreeItem::isCollapsed() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), iscollapsed_id, NULL)); +} + +int C_TreeItem::isExpanded() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isexpanded_id, NULL)); +} + +void C_TreeItem::invalidate() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), invalidate_id, NULL); +} + +int C_TreeItem::isSelected() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), isselected_id, NULL)); +} + +int C_TreeItem::isHilited() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), ishilited_id, NULL)); +} + +void C_TreeItem::setHilited(int ishilited) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(ishilited); + scriptVar *params[1] = {&a}; + WASABI_API_MAKI->maki_callFunction(getScriptObject(), sethilited_id, params); +} + +int C_TreeItem::collapse() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), collapse_id, NULL)); +} + +int C_TreeItem::expand() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), expand_id, NULL)); +} + +ScriptObject *C_TreeItem::getTree() { + ASSERT(inited); + return GET_SCRIPT_OBJECT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), gettree_id, NULL)); +} + +void C_TreeItem::onTreeAdd() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontreeadd_id, NULL); +} + +void C_TreeItem::onTreeRemove() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ontreeremove_id, NULL); +} + +void C_TreeItem::onSelect() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onselect_id, NULL); +} + +void C_TreeItem::onDeselect() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), ondeselect_id, NULL); +} + +int C_TreeItem::onLeftDoubleClick() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftdoubleclick_id, NULL)); +} + +int C_TreeItem::onRightDoubleClick() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightdoubleclick_id, NULL)); +} + +int C_TreeItem::onChar(int key) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(key); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onchar_id, params)); +} + +void C_TreeItem::onExpand() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), onexpand_id, NULL); +} + +void C_TreeItem::onCollapse() { + ASSERT(inited); + WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncollapse_id, NULL); +} + +int C_TreeItem::onBeginLabelEdit() { + ASSERT(inited); + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onbeginlabeledit_id, NULL)); +} + +int C_TreeItem::onEndLabelEdit(const wchar_t *newlabel) +{ + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_STRING(newlabel); + scriptVar *params[1] = {&a}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), onendlabeledit_id, params)); +} + +int C_TreeItem::onContextMenu(int x, int y) { + ASSERT(inited); + scriptVar a = MAKE_SCRIPT_INT(x); + scriptVar b = MAKE_SCRIPT_INT(y); + scriptVar *params[2] = {&a, &b}; + return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), oncontextmenu_id, params)); +} + +int C_TreeItem::loaded=0; +int C_TreeItem::getnumchildren_id=0; +int C_TreeItem::setlabel_id=0; +int C_TreeItem::getlabel_id=0; +int C_TreeItem::ensurevisible_id=0; +int C_TreeItem::getnthchild_id=0; +int C_TreeItem::getchild_id=0; +int C_TreeItem::getchildsibling_id=0; +int C_TreeItem::getsibling_id=0; +int C_TreeItem::getparent_id=0; +int C_TreeItem::editlabel_id=0; +int C_TreeItem::hassubitems_id=0; +int C_TreeItem::setsorted_id=0; +int C_TreeItem::setchildtab_id=0; +int C_TreeItem::issorted_id=0; +int C_TreeItem::iscollapsed_id=0; +int C_TreeItem::isexpanded_id=0; +int C_TreeItem::invalidate_id=0; +int C_TreeItem::isselected_id=0; +int C_TreeItem::ishilited_id=0; +int C_TreeItem::sethilited_id=0; +int C_TreeItem::collapse_id=0; +int C_TreeItem::expand_id=0; +int C_TreeItem::gettree_id=0; +int C_TreeItem::ontreeadd_id=0; +int C_TreeItem::ontreeremove_id=0; +int C_TreeItem::onselect_id=0; +int C_TreeItem::ondeselect_id=0; +int C_TreeItem::onleftdoubleclick_id=0; +int C_TreeItem::onrightdoubleclick_id=0; +int C_TreeItem::onchar_id=0; +int C_TreeItem::onexpand_id=0; +int C_TreeItem::oncollapse_id=0; +int C_TreeItem::onbeginlabeledit_id=0; +int C_TreeItem::onendlabeledit_id=0; +int C_TreeItem::oncontextmenu_id=0; diff --git a/Src/Wasabi/api/script/objects/c_script/c_treeitem.h b/Src/Wasabi/api/script/objects/c_script/c_treeitem.h new file mode 100644 index 00000000..7ff3c78d --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/c_treeitem.h @@ -0,0 +1,99 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __C_TREEITEM_H +#define __C_TREEITEM_H + +#include "c_rootobj.h" + +#define C_TREEITEM_PARENT C_RootObject + +class C_TreeItem : public C_TREEITEM_PARENT { + public: + + C_TreeItem(ScriptObject *object); + C_TreeItem(); + virtual ~C_TreeItem(); + + virtual void C_hook(ScriptObject *o); + + ScriptObject *getScriptObject(); + + virtual int getNumChildren(); + virtual void setLabel(const wchar_t *label); + virtual const wchar_t *getLabel(); + virtual void ensureVisible(); + virtual ScriptObject *getNthChild(int nth); + virtual ScriptObject *getChild(); + virtual ScriptObject *getChildSibling(ScriptObject *_item); + virtual ScriptObject *getSibling(); + virtual ScriptObject *getParent(); + virtual void editLabel(); + virtual int hasSubItems(); + virtual void setSorted(int issorted); + virtual void setChildTab(int haschildtab); + virtual int isSorted(); + virtual int isCollapsed(); + virtual int isExpanded(); + virtual void invalidate(); + virtual int isSelected(); + virtual int isHilited(); + virtual void setHilited(int ishilited); + virtual int collapse(); + virtual int expand(); + virtual ScriptObject *getTree(); + virtual void onTreeAdd(); + virtual void onTreeRemove(); + virtual void onSelect(); + virtual void onDeselect(); + virtual int onLeftDoubleClick(); + virtual int onRightDoubleClick(); + virtual int onChar(int key); + virtual void onExpand(); + virtual void onCollapse(); + virtual int onBeginLabelEdit(); + virtual int onEndLabelEdit(const wchar_t *newlabel); + virtual int onContextMenu(int x, int y); + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int getnumchildren_id; + static int setlabel_id; + static int getlabel_id; + static int ensurevisible_id; + static int getnthchild_id; + static int getchild_id; + static int getchildsibling_id; + static int getsibling_id; + static int getparent_id; + static int editlabel_id; + static int hassubitems_id; + static int setsorted_id; + static int setchildtab_id; + static int issorted_id; + static int iscollapsed_id; + static int isexpanded_id; + static int invalidate_id; + static int isselected_id; + static int ishilited_id; + static int sethilited_id; + static int collapse_id; + static int expand_id; + static int gettree_id; + static int ontreeadd_id; + static int ontreeremove_id; + static int onselect_id; + static int ondeselect_id; + static int onleftdoubleclick_id; + static int onrightdoubleclick_id; + static int onchar_id; + static int onexpand_id; + static int oncollapse_id; + static int onbeginlabeledit_id; + static int onendlabeledit_id; + static int oncontextmenu_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/gen.m b/Src/Wasabi/api/script/objects/c_script/gen.m new file mode 100644 index 00000000..e3f89a27 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/gen.m @@ -0,0 +1,22 @@ +#include <lib/std.mi> + +#export_cclass GuiObject +#export_cclass Browser +#export_cclass Button +#export_cclass Container +#export_cclass DropDownList +#export_cclass Edit +#export_cclass Group +#export_cclass GuiList +#export_cclass GuiTree +#export_cclass Layout +#export_cclass MenuButton +#export_cclass Slider +#export_cclass Text +#export_cclass ToggleButton +#export_cclass TreeItem +#export_cclass CheckBox +#export_cclass GroupList +#export_cclass TabSheet + +#abort "All done." diff --git a/Src/Wasabi/api/script/objects/c_script/h_browser.cpp b/Src/Wasabi/api/script/objects/c_script/h_browser.cpp new file mode 100644 index 00000000..9eb6eaa2 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_browser.cpp @@ -0,0 +1,85 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_browser.h" + +H_Browser::H_Browser(ScriptObject *o) : H_GuiObject(o) +{ + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Browser::H_Browser() +{ + inited = 0; + obj = NULL; +} + +void H_Browser::H_hook(ScriptObject *o) +{ + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, browserGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &browserGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) + { + onbeforenavigate_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onBeforeNavigate", this); + ondocumentcomplete_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDocumentComplete", this); + onmedialink_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMediaLink", this); + loaded = 1; + } + inited=1; +} + +H_Browser::~H_Browser() +{ + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Browser::getHookedObject() +{ + if (obj != NULL) return obj; + return H_BROWSER_PARENT::getHookedObject(); +} + +int H_Browser::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) +{ + if (object != getHookedObject()) return 0; + if (H_BROWSER_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + + if (dlfid == onbeforenavigate_id) + { + hook_onBeforeNavigate(GET_SCRIPT_STRING(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_STRING(*params[2])); + return 1; + } + else if (dlfid == ondocumentcomplete_id) + { + hook_onDocumentComplete(GET_SCRIPT_STRING(*params[0])); + return 1; + } + else if (dlfid == onmedialink_id) + { + + hook_onMediaLink(GET_SCRIPT_STRING(*params[0])); + return 1; + } + + return 0; + +} + +int H_Browser::onbeforenavigate_id=0; +int H_Browser::ondocumentcomplete_id=0; +int H_Browser::onmedialink_id=0; +int H_Browser::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_browser.h b/Src/Wasabi/api/script/objects/c_script/h_browser.h new file mode 100644 index 00000000..1c958f10 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_browser.h @@ -0,0 +1,35 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_BROWSER_H +#define __HOOK_BROWSER_H + +#include "h_guiobject.h" + +#define H_BROWSER_PARENT H_GuiObject + +class H_Browser : public H_BROWSER_PARENT { + +public: + + H_Browser(ScriptObject *o); + H_Browser(); + virtual ~H_Browser(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onBeforeNavigate(const wchar_t *url, int flags, const wchar_t *targetframename) { } + virtual void hook_onDocumentComplete(const wchar_t *url) { } + virtual void hook_onMediaLink(const wchar_t *url) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onbeforenavigate_id; + static int ondocumentcomplete_id; + static int onmedialink_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_button.cpp b/Src/Wasabi/api/script/objects/c_script/h_button.cpp new file mode 100644 index 00000000..5477e4fa --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_button.cpp @@ -0,0 +1,62 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_button.h" + +H_Button::H_Button(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Button::H_Button() { + inited = 0; + obj = NULL; +} + +void H_Button::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, buttonGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &buttonGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onactivate_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onActivate", this); + onleftclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftClick", this); + onrightclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightClick", this); + loaded = 1; + } + inited=1; +} + +H_Button::~H_Button() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Button::getHookedObject() { + if (obj != NULL) return obj; + return H_BUTTON_PARENT::getHookedObject(); +} + +int H_Button::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_BUTTON_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onactivate_id) { hook_onActivate(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onleftclick_id) { hook_onLeftClick(); return 1; } + if (dlfid == onrightclick_id) { hook_onRightClick(); return 1; } + return 0; +} + +int H_Button::onactivate_id=0; +int H_Button::onleftclick_id=0; +int H_Button::onrightclick_id=0; +int H_Button::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_button.h b/Src/Wasabi/api/script/objects/c_script/h_button.h new file mode 100644 index 00000000..32cc15e2 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_button.h @@ -0,0 +1,35 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_BUTTON_H +#define __HOOK_BUTTON_H + +#include "h_guiobject.h" + +#define H_BUTTON_PARENT H_GuiObject + +class H_Button : public H_BUTTON_PARENT { + +public: + + H_Button(ScriptObject *o); + H_Button(); + virtual ~H_Button(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onActivate(int activated) { } + virtual void hook_onLeftClick() { } + virtual void hook_onRightClick() { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onactivate_id; + static int onleftclick_id; + static int onrightclick_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_checkbox.cpp b/Src/Wasabi/api/script/objects/c_script/h_checkbox.cpp new file mode 100644 index 00000000..4c5a0d97 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_checkbox.cpp @@ -0,0 +1,56 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_checkbox.h" + +H_CheckBox::H_CheckBox(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_CheckBox::H_CheckBox() { + inited = 0; + obj = NULL; +} + +void H_CheckBox::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, checkBoxGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &checkBoxGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + ontoggle_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onToggle", this); + loaded = 1; + } + inited=1; +} + +H_CheckBox::~H_CheckBox() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_CheckBox::getHookedObject() { + if (obj != NULL) return obj; + return H_CHECKBOX_PARENT::getHookedObject(); +} + +int H_CheckBox::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_CHECKBOX_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == ontoggle_id) { hook_onToggle(GET_SCRIPT_INT(*params[0])); return 1; } + return 0; +} + +int H_CheckBox::ontoggle_id=0; +int H_CheckBox::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_checkbox.h b/Src/Wasabi/api/script/objects/c_script/h_checkbox.h new file mode 100644 index 00000000..e1725073 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_checkbox.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_CHECKBOX_H +#define __HOOK_CHECKBOX_H + +#include "h_guiobject.h" + +#define H_CHECKBOX_PARENT H_GuiObject + +class H_CheckBox : public H_CHECKBOX_PARENT { + +public: + + H_CheckBox(ScriptObject *o); + H_CheckBox(); + virtual ~H_CheckBox(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onToggle(int newstate) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontoggle_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_container.cpp b/Src/Wasabi/api/script/objects/c_script/h_container.cpp new file mode 100644 index 00000000..b665af5c --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_container.cpp @@ -0,0 +1,65 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_container.h" + +H_Container::H_Container(ScriptObject *o) : H_RootObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Container::H_Container() { + inited = 0; + obj = NULL; +} + +void H_Container::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, containerGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &containerGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onswitchtolayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSwitchToLayout", this); + onbeforeswitchtolayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onBeforeSwitchToLayout", this); + onhidelayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onHideLayout", this); + onshowlayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onShowLayout", this); + loaded = 1; + } + inited=1; +} + +H_Container::~H_Container() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Container::getHookedObject() { + if (obj != NULL) return obj; + return H_CONTAINER_PARENT::getHookedObject(); +} + +int H_Container::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_CONTAINER_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onswitchtolayout_id) { hook_onSwitchToLayout(GET_SCRIPT_OBJECT(*params[0])); return 1; } + if (dlfid == onbeforeswitchtolayout_id) { hook_onBeforeSwitchToLayout(GET_SCRIPT_OBJECT(*params[0]), GET_SCRIPT_OBJECT(*params[1])); return 1; } + if (dlfid == onhidelayout_id) { hook_onHideLayout(GET_SCRIPT_OBJECT(*params[0])); return 1; } + if (dlfid == onshowlayout_id) { hook_onShowLayout(GET_SCRIPT_OBJECT(*params[0])); return 1; } + return 0; +} + +int H_Container::onswitchtolayout_id=0; +int H_Container::onbeforeswitchtolayout_id=0; +int H_Container::onhidelayout_id=0; +int H_Container::onshowlayout_id=0; +int H_Container::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_container.h b/Src/Wasabi/api/script/objects/c_script/h_container.h new file mode 100644 index 00000000..eae5069d --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_container.h @@ -0,0 +1,37 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_CONTAINER_H +#define __HOOK_CONTAINER_H + +#include "h_rootobj.h" + +#define H_CONTAINER_PARENT H_RootObject + +class H_Container : public H_CONTAINER_PARENT { + +public: + + H_Container(ScriptObject *o); + H_Container(); + virtual ~H_Container(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onSwitchToLayout(ScriptObject *newlayout) { } + virtual void hook_onBeforeSwitchToLayout(ScriptObject *oldlayout, ScriptObject *newlayout) { } + virtual void hook_onHideLayout(ScriptObject *_layout) { } + virtual void hook_onShowLayout(ScriptObject *_layout) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onswitchtolayout_id; + static int onbeforeswitchtolayout_id; + static int onhidelayout_id; + static int onshowlayout_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.cpp b/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.cpp new file mode 100644 index 00000000..a6d14f7a --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.cpp @@ -0,0 +1,56 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_dropdownlist.h" + +H_DropDownList::H_DropDownList(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_DropDownList::H_DropDownList() { + inited = 0; + obj = NULL; +} + +void H_DropDownList::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, dropDownListGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &dropDownListGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onselect_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSelect", this); + loaded = 1; + } + inited=1; +} + +H_DropDownList::~H_DropDownList() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_DropDownList::getHookedObject() { + if (obj != NULL) return obj; + return H_DROPDOWNLIST_PARENT::getHookedObject(); +} + +int H_DropDownList::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_DROPDOWNLIST_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onselect_id) { hook_onSelect(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + return 0; +} + +int H_DropDownList::onselect_id=0; +int H_DropDownList::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.h b/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.h new file mode 100644 index 00000000..a044cf8c --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_dropdownlist.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_DROPDOWNLIST_H +#define __HOOK_DROPDOWNLIST_H + +#include "h_guiobject.h" + +#define H_DROPDOWNLIST_PARENT H_GuiObject + +class H_DropDownList : public H_DROPDOWNLIST_PARENT { + +public: + + H_DropDownList(ScriptObject *o); + H_DropDownList(); + virtual ~H_DropDownList(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onSelect(int id, int hover) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onselect_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_edit.cpp b/Src/Wasabi/api/script/objects/c_script/h_edit.cpp new file mode 100644 index 00000000..2bb72698 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_edit.cpp @@ -0,0 +1,65 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_edit.h" + +H_Edit::H_Edit(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Edit::H_Edit() { + inited = 0; + obj = NULL; +} + +void H_Edit::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, editGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &editGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onenter_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEnter", this); + onabort_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onAbort", this); + onidleeditupdate_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onIdleEditUpdate", this); + oneditupdate_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEditUpdate", this); + loaded = 1; + } + inited=1; +} + +H_Edit::~H_Edit() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Edit::getHookedObject() { + if (obj != NULL) return obj; + return H_EDIT_PARENT::getHookedObject(); +} + +int H_Edit::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_EDIT_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onenter_id) { hook_onEnter(); return 1; } + if (dlfid == onabort_id) { hook_onAbort(); return 1; } + if (dlfid == onidleeditupdate_id) { hook_onIdleEditUpdate(); return 1; } + if (dlfid == oneditupdate_id) { hook_onEditUpdate(); return 1; } + return 0; +} + +int H_Edit::onenter_id=0; +int H_Edit::onabort_id=0; +int H_Edit::onidleeditupdate_id=0; +int H_Edit::oneditupdate_id=0; +int H_Edit::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_edit.h b/Src/Wasabi/api/script/objects/c_script/h_edit.h new file mode 100644 index 00000000..d267cd89 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_edit.h @@ -0,0 +1,37 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_EDIT_H +#define __HOOK_EDIT_H + +#include "h_guiobject.h" + +#define H_EDIT_PARENT H_GuiObject + +class H_Edit : public H_EDIT_PARENT { + +public: + + H_Edit(ScriptObject *o); + H_Edit(); + virtual ~H_Edit(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onEnter() { } + virtual void hook_onAbort() { } + virtual void hook_onIdleEditUpdate() { } + virtual void hook_onEditUpdate() { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onenter_id; + static int onabort_id; + static int onidleeditupdate_id; + static int oneditupdate_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_group.cpp b/Src/Wasabi/api/script/objects/c_script/h_group.cpp new file mode 100644 index 00000000..36aaadda --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_group.cpp @@ -0,0 +1,56 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_group.h" + +H_Group::H_Group(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Group::H_Group() { + inited = 0; + obj = NULL; +} + +void H_Group::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, groupGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &groupGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + oncreateobject_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onCreateObject", this); + loaded = 1; + } + inited=1; +} + +H_Group::~H_Group() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Group::getHookedObject() { + if (obj != NULL) return obj; + return H_GROUP_PARENT::getHookedObject(); +} + +int H_Group::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_GROUP_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == oncreateobject_id) { hook_onCreateObject(GET_SCRIPT_OBJECT(*params[0])); return 1; } + return 0; +} + +int H_Group::oncreateobject_id=0; +int H_Group::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_group.h b/Src/Wasabi/api/script/objects/c_script/h_group.h new file mode 100644 index 00000000..06dbefb0 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_group.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_GROUP_H +#define __HOOK_GROUP_H + +#include "h_guiobject.h" + +#define H_GROUP_PARENT H_GuiObject + +class H_Group : public H_GROUP_PARENT { + +public: + + H_Group(ScriptObject *o); + H_Group(); + virtual ~H_Group(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onCreateObject(ScriptObject *newobj) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int oncreateobject_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_grouplist.cpp b/Src/Wasabi/api/script/objects/c_script/h_grouplist.cpp new file mode 100644 index 00000000..4a9aecaa --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_grouplist.cpp @@ -0,0 +1,53 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> +#include <api/api.h> +#include <api/script/objcontroller.h> +#include "h_grouplist.h" + +H_GroupList::H_GroupList(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_GroupList::H_GroupList() { + inited = 0; + obj = NULL; +} + +void H_GroupList::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, groupListGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &groupListGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = 1; + } + inited=1; +} + +H_GroupList::~H_GroupList() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_GroupList::getHookedObject() { + if (obj != NULL) return obj; + return H_GROUPLIST_PARENT::getHookedObject(); +} + +int H_GroupList::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_GROUPLIST_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + return 0; +} + +int H_GroupList::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_grouplist.h b/Src/Wasabi/api/script/objects/c_script/h_grouplist.h new file mode 100644 index 00000000..460b94ab --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_grouplist.h @@ -0,0 +1,29 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_GROUPLIST_H +#define __HOOK_GROUPLIST_H + +#include "h_guiobject.h" + +#define H_GROUPLIST_PARENT H_GuiObject + +class H_GroupList : public H_GROUPLIST_PARENT { + +public: + + H_GroupList(ScriptObject *o); + H_GroupList(); + virtual ~H_GroupList(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + + private: + + ScriptObject *obj; + int inited; + static int loaded; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_guilist.cpp b/Src/Wasabi/api/script/objects/c_script/h_guilist.cpp new file mode 100644 index 00000000..e108c898 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guilist.cpp @@ -0,0 +1,83 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_guilist.h" + +H_GuiList::H_GuiList(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_GuiList::H_GuiList() { + inited = 0; + obj = NULL; +} + +void H_GuiList::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, guiListGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &guiListGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onsetvisible_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSetVisible", this); + onselectall_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSelectAll", this); + ondelete_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDelete", this); + ondoubleclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDoubleClick", this); + onleftclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftClick", this); + onsecondleftclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSecondLeftClick", this); + onrightclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightClick", this); + oncolumndblclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onColumnDblClick", this); + oncolumnlabelclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onColumnLabelClick", this); + onitemselection_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemSelection", this); + loaded = 1; + } + inited=1; +} + +H_GuiList::~H_GuiList() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_GuiList::getHookedObject() { + if (obj != NULL) return obj; + return H_GUILIST_PARENT::getHookedObject(); +} + +int H_GuiList::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_GUILIST_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onsetvisible_id) { hook_onSetVisible(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onselectall_id) { hook_onSelectAll(); return 1; } + if (dlfid == ondelete_id) { hook_onDelete(); return 1; } + if (dlfid == ondoubleclick_id) { hook_onDoubleClick(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onleftclick_id) { hook_onLeftClick(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onsecondleftclick_id) { hook_onSecondLeftClick(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onrightclick_id) { hook_onRightClick(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == oncolumndblclick_id) { hook_onColumnDblClick(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_INT(*params[2])); return 1; } + if (dlfid == oncolumnlabelclick_id) { hook_onColumnLabelClick(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_INT(*params[2])); return 1; } + if (dlfid == onitemselection_id) { hook_onItemSelection(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + return 0; +} + +int H_GuiList::onsetvisible_id=0; +int H_GuiList::onselectall_id=0; +int H_GuiList::ondelete_id=0; +int H_GuiList::ondoubleclick_id=0; +int H_GuiList::onleftclick_id=0; +int H_GuiList::onsecondleftclick_id=0; +int H_GuiList::onrightclick_id=0; +int H_GuiList::oncolumndblclick_id=0; +int H_GuiList::oncolumnlabelclick_id=0; +int H_GuiList::onitemselection_id=0; +int H_GuiList::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_guilist.h b/Src/Wasabi/api/script/objects/c_script/h_guilist.h new file mode 100644 index 00000000..d762abb3 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guilist.h @@ -0,0 +1,49 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_GUILIST_H +#define __HOOK_GUILIST_H + +#include "h_guiobject.h" + +#define H_GUILIST_PARENT H_GuiObject + +class H_GuiList : public H_GUILIST_PARENT { + +public: + + H_GuiList(ScriptObject *o); + H_GuiList(); + virtual ~H_GuiList(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onSetVisible(int show) { } + virtual void hook_onSelectAll() { } + virtual void hook_onDelete() { } + virtual void hook_onDoubleClick(int itemnum) { } + virtual void hook_onLeftClick(int itemnum) { } + virtual void hook_onSecondLeftClick(int itemnum) { } + virtual void hook_onRightClick(int itemnum) { } + virtual void hook_onColumnDblClick(int col, int x, int y) { } + virtual void hook_onColumnLabelClick(int col, int x, int y) { } + virtual void hook_onItemSelection(int itemnum, int selected) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onsetvisible_id; + static int onselectall_id; + static int ondelete_id; + static int ondoubleclick_id; + static int onleftclick_id; + static int onsecondleftclick_id; + static int onrightclick_id; + static int oncolumndblclick_id; + static int oncolumnlabelclick_id; + static int onitemselection_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_guiobject.cpp b/Src/Wasabi/api/script/objects/c_script/h_guiobject.cpp new file mode 100644 index 00000000..b4867dd8 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guiobject.cpp @@ -0,0 +1,117 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_guiobject.h" +#include "../nu/AUtoChar.h" + +H_GuiObject::H_GuiObject(ScriptObject *o) : H_RootObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_GuiObject::H_GuiObject() { + inited = 0; + obj = NULL; +} + +void H_GuiObject::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, guiObjectGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &guiObjectGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onsetvisible_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSetVisible", this); + onleftbuttonup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftButtonUp", this); + onleftbuttondown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftButtonDown", this); + onrightbuttonup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightButtonUp", this); + onrightbuttondown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightButtonDown", this); + onrightbuttondblclk_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightButtonDblClk", this); + onleftbuttondblclk_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftButtonDblClk", this); + onmousemove_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseMove", this); + onenterarea_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEnterArea", this); + onleavearea_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeaveArea", this); + onenable_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEnable", this); + onresize_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onResize", this); + ontargetreached_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTargetReached", this); + onstartup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onStartup", this); + onchar_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onChar", this); + onaccelerator_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onAccelerator", this); + onkeydown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onKeyDown", this); + onkeyup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onKeyUp", this); + ongetfocus_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onGetFocus", this); + onkillfocus_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onKillFocus", this); + onaction_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onAction", this); + loaded = 1; + } + inited=1; +} + +H_GuiObject::~H_GuiObject() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_GuiObject::getHookedObject() { + if (obj != NULL) return obj; + return H_GUIOBJECT_PARENT::getHookedObject(); +} + +int H_GuiObject::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_GUIOBJECT_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onsetvisible_id) { hook_onSetVisible(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onleftbuttonup_id) { hook_onLeftButtonUp(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onleftbuttondown_id) { hook_onLeftButtonDown(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onrightbuttonup_id) { hook_onRightButtonUp(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onrightbuttondown_id) { hook_onRightButtonDown(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onrightbuttondblclk_id) { hook_onRightButtonDblClk(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onleftbuttondblclk_id) { hook_onLeftButtonDblClk(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onmousemove_id) { hook_onMouseMove(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onenterarea_id) { hook_onEnterArea(); return 1; } + if (dlfid == onleavearea_id) { hook_onLeaveArea(); return 1; } + if (dlfid == onenable_id) { hook_onEnable(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onresize_id) { hook_onResize(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_INT(*params[2]), GET_SCRIPT_INT(*params[3])); return 1; } + if (dlfid == ontargetreached_id) { hook_onTargetReached(); return 1; } + if (dlfid == onstartup_id) { hook_onStartup(); return 1; } + if (dlfid == onchar_id) { hook_onChar(GET_SCRIPT_STRING(*params[0])); return 1; } + if (dlfid == onaccelerator_id) { hook_onAccelerator(GET_SCRIPT_STRING(*params[0])); return 1; } + if (dlfid == onkeydown_id) { hook_onKeyDown(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onkeyup_id) { hook_onKeyUp(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == ongetfocus_id) { hook_onGetFocus(); return 1; } + if (dlfid == onkillfocus_id) { hook_onKillFocus(); return 1; } + if (dlfid == onaction_id) { hook_onAction(GET_SCRIPT_STRING(*params[0]), GET_SCRIPT_STRING(*params[1]), GET_SCRIPT_INT(*params[2]), GET_SCRIPT_INT(*params[3]), GET_SCRIPT_INT(*params[4]), GET_SCRIPT_INT(*params[5]), GET_SCRIPT_OBJECT(*params[6])); return 1; } + return 0; +} + +int H_GuiObject::onsetvisible_id=0; +int H_GuiObject::onleftbuttonup_id=0; +int H_GuiObject::onleftbuttondown_id=0; +int H_GuiObject::onrightbuttonup_id=0; +int H_GuiObject::onrightbuttondown_id=0; +int H_GuiObject::onrightbuttondblclk_id=0; +int H_GuiObject::onleftbuttondblclk_id=0; +int H_GuiObject::onmousemove_id=0; +int H_GuiObject::onenterarea_id=0; +int H_GuiObject::onleavearea_id=0; +int H_GuiObject::onenable_id=0; +int H_GuiObject::onresize_id=0; +int H_GuiObject::ontargetreached_id=0; +int H_GuiObject::onstartup_id=0; +int H_GuiObject::onchar_id=0; +int H_GuiObject::onaccelerator_id=0; +int H_GuiObject::onkeydown_id=0; +int H_GuiObject::onkeyup_id=0; +int H_GuiObject::ongetfocus_id=0; +int H_GuiObject::onkillfocus_id=0; +int H_GuiObject::onaction_id=0; +int H_GuiObject::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_guiobject.h b/Src/Wasabi/api/script/objects/c_script/h_guiobject.h new file mode 100644 index 00000000..d73900bf --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guiobject.h @@ -0,0 +1,71 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_GUIOBJECT_H +#define __HOOK_GUIOBJECT_H + +#include "h_rootobj.h" + +#define H_GUIOBJECT_PARENT H_RootObject + +class H_GuiObject : public H_GUIOBJECT_PARENT { + +public: + + H_GuiObject(ScriptObject *o); + H_GuiObject(); + virtual ~H_GuiObject(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onSetVisible(int onoff) { } + virtual void hook_onLeftButtonUp(int x, int y) { } + virtual void hook_onLeftButtonDown(int x, int y) { } + virtual void hook_onRightButtonUp(int x, int y) { } + virtual void hook_onRightButtonDown(int x, int y) { } + virtual void hook_onRightButtonDblClk(int x, int y) { } + virtual void hook_onLeftButtonDblClk(int x, int y) { } + virtual void hook_onMouseMove(int x, int y) { } + virtual void hook_onEnterArea() { } + virtual void hook_onLeaveArea() { } + virtual void hook_onEnable(int onoff) { } + virtual void hook_onResize(int x, int y, int w, int h) { } + virtual void hook_onTargetReached() { } + virtual void hook_onStartup() { } + virtual void hook_onChar(const wchar_t *c) { } + virtual void hook_onAccelerator(const wchar_t *accel) { } + virtual void hook_onKeyDown(int vk_code) { } + virtual void hook_onKeyUp(int vk_code) { } + virtual void hook_onGetFocus() { } + virtual void hook_onKillFocus() { } + virtual void hook_onAction(const wchar_t *action, const wchar_t *param, int x, int y, int p1, int p2, ScriptObject *source) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onsetvisible_id; + static int onleftbuttonup_id; + static int onleftbuttondown_id; + static int onrightbuttonup_id; + static int onrightbuttondown_id; + static int onrightbuttondblclk_id; + static int onleftbuttondblclk_id; + static int onmousemove_id; + static int onenterarea_id; + static int onleavearea_id; + static int onenable_id; + static int onresize_id; + static int ontargetreached_id; + static int onstartup_id; + static int onchar_id; + static int onaccelerator_id; + static int onkeydown_id; + static int onkeyup_id; + static int ongetfocus_id; + static int onkillfocus_id; + static int onaction_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_guitree.cpp b/Src/Wasabi/api/script/objects/c_script/h_guitree.cpp new file mode 100644 index 00000000..28363b06 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guitree.cpp @@ -0,0 +1,80 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_guitree.h" + +H_GuiTree::H_GuiTree(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_GuiTree::H_GuiTree() { + inited = 0; + obj = NULL; +} + +void H_GuiTree::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, guiTreeGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &guiTreeGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onwantautocontextmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onWantAutoContextMenu", this); + onmousewheelup_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseWheelUp", this); + onmousewheeldown_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseWheelDown", this); + oncontextmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onContextMenu", this); + onchar_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onChar", this); + onitemrecvdrop_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemRecvDrop", this); + onlabelchange_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLabelChange", this); + onitemselected_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemSelected", this); + onitemdeselected_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onItemDeselected", this); + loaded = 1; + } + inited=1; +} + +H_GuiTree::~H_GuiTree() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_GuiTree::getHookedObject() { + if (obj != NULL) return obj; + return H_GUITREE_PARENT::getHookedObject(); +} + +int H_GuiTree::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_GUITREE_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onwantautocontextmenu_id) { hook_onWantAutoContextMenu(); return 1; } + if (dlfid == onmousewheelup_id) { hook_onMouseWheelUp(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onmousewheeldown_id) { hook_onMouseWheelDown(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == oncontextmenu_id) { hook_onContextMenu(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + if (dlfid == onchar_id) { hook_onChar(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onitemrecvdrop_id) { hook_onItemRecvDrop(GET_SCRIPT_OBJECT(*params[0])); return 1; } + if (dlfid == onlabelchange_id) { hook_onLabelChange(GET_SCRIPT_OBJECT(*params[0])); return 1; } + if (dlfid == onitemselected_id) { hook_onItemSelected(GET_SCRIPT_OBJECT(*params[0])); return 1; } + if (dlfid == onitemdeselected_id) { hook_onItemDeselected(GET_SCRIPT_OBJECT(*params[0])); return 1; } + return 0; +} + +int H_GuiTree::onwantautocontextmenu_id=0; +int H_GuiTree::onmousewheelup_id=0; +int H_GuiTree::onmousewheeldown_id=0; +int H_GuiTree::oncontextmenu_id=0; +int H_GuiTree::onchar_id=0; +int H_GuiTree::onitemrecvdrop_id=0; +int H_GuiTree::onlabelchange_id=0; +int H_GuiTree::onitemselected_id=0; +int H_GuiTree::onitemdeselected_id=0; +int H_GuiTree::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_guitree.h b/Src/Wasabi/api/script/objects/c_script/h_guitree.h new file mode 100644 index 00000000..c56c28b7 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_guitree.h @@ -0,0 +1,47 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_GUITREE_H +#define __HOOK_GUITREE_H + +#include "h_guiobject.h" + +#define H_GUITREE_PARENT H_GuiObject + +class H_GuiTree : public H_GUITREE_PARENT { + +public: + + H_GuiTree(ScriptObject *o); + H_GuiTree(); + virtual ~H_GuiTree(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onWantAutoContextMenu() { } + virtual void hook_onMouseWheelUp(int clicked, int lines) { } + virtual void hook_onMouseWheelDown(int clicked, int lines) { } + virtual void hook_onContextMenu(int x, int y) { } + virtual void hook_onChar(wchar_t c) { } + virtual void hook_onItemRecvDrop(ScriptObject *item) { } + virtual void hook_onLabelChange(ScriptObject *item) { } + virtual void hook_onItemSelected(ScriptObject *item) { } + virtual void hook_onItemDeselected(ScriptObject *item) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onwantautocontextmenu_id; + static int onmousewheelup_id; + static int onmousewheeldown_id; + static int oncontextmenu_id; + static int onchar_id; + static int onitemrecvdrop_id; + static int onlabelchange_id; + static int onitemselected_id; + static int onitemdeselected_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_layout.cpp b/Src/Wasabi/api/script/objects/c_script/h_layout.cpp new file mode 100644 index 00000000..385cc852 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_layout.cpp @@ -0,0 +1,80 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_layout.h" + +H_Layout::H_Layout(ScriptObject *o) : H_Group(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Layout::H_Layout() { + inited = 0; + obj = NULL; +} + +void H_Layout::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, layoutGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &layoutGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + ondock_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDock", this); + onundock_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onUndock", this); + onscale_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onScale", this); + onmove_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMove", this); + onendmove_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEndMove", this); + onuserresize_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onUserResize", this); + onmouseenterlayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseEnterLayout", this); + onmouseleavelayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMouseLeaveLayout", this); + onsnapadjustchanged_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSnapAdjustChanged", this); + loaded = 1; + } + inited=1; +} + +H_Layout::~H_Layout() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Layout::getHookedObject() { + if (obj != NULL) return obj; + return H_LAYOUT_PARENT::getHookedObject(); +} + +int H_Layout::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_LAYOUT_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == ondock_id) { hook_onDock(); return 1; } + if (dlfid == onundock_id) { hook_onUndock(); return 1; } + if (dlfid == onscale_id) { hook_onScale(GET_SCRIPT_DOUBLE(*params[0])); return 1; } + if (dlfid == onmove_id) { hook_onMove(); return 1; } + if (dlfid == onendmove_id) { hook_onEndMove(); return 1; } + if (dlfid == onuserresize_id) { hook_onUserResize(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_INT(*params[2]), GET_SCRIPT_INT(*params[3])); return 1; } + if (dlfid == onmouseenterlayout_id) { hook_onMouseEnterLayout(); return 1; } + if (dlfid == onmouseleavelayout_id) { hook_onMouseLeaveLayout(); return 1; } + if (dlfid == onsnapadjustchanged_id) { hook_onSnapAdjustChanged(); return 1; } + return 0; +} + +int H_Layout::ondock_id=0; +int H_Layout::onundock_id=0; +int H_Layout::onscale_id=0; +int H_Layout::onmove_id=0; +int H_Layout::onendmove_id=0; +int H_Layout::onuserresize_id=0; +int H_Layout::onmouseenterlayout_id=0; +int H_Layout::onmouseleavelayout_id=0; +int H_Layout::onsnapadjustchanged_id=0; +int H_Layout::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_layout.h b/Src/Wasabi/api/script/objects/c_script/h_layout.h new file mode 100644 index 00000000..1b19c3e7 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_layout.h @@ -0,0 +1,47 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_LAYOUT_H +#define __HOOK_LAYOUT_H + +#include "h_group.h" + +#define H_LAYOUT_PARENT H_Group + +class H_Layout : public H_LAYOUT_PARENT { + +public: + + H_Layout(ScriptObject *o); + H_Layout(); + virtual ~H_Layout(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onDock() { } + virtual void hook_onUndock() { } + virtual void hook_onScale(double newscalevalue) { } + virtual void hook_onMove() { } + virtual void hook_onEndMove() { } + virtual void hook_onUserResize(int x, int y, int w, int h) { } + virtual void hook_onMouseEnterLayout() { } + virtual void hook_onMouseLeaveLayout() { } + virtual void hook_onSnapAdjustChanged() { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ondock_id; + static int onundock_id; + static int onscale_id; + static int onmove_id; + static int onendmove_id; + static int onuserresize_id; + static int onmouseenterlayout_id; + static int onmouseleavelayout_id; + static int onsnapadjustchanged_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_menubutton.cpp b/Src/Wasabi/api/script/objects/c_script/h_menubutton.cpp new file mode 100644 index 00000000..bce0f405 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_menubutton.cpp @@ -0,0 +1,62 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_menubutton.h" + +H_MenuButton::H_MenuButton(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_MenuButton::H_MenuButton() { + inited = 0; + obj = NULL; +} + +void H_MenuButton::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, menuButtonGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &menuButtonGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onopenmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onOpenMenu", this); + onclosemenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onCloseMenu", this); + onselectitem_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSelectItem", this); + loaded = 1; + } + inited=1; +} + +H_MenuButton::~H_MenuButton() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_MenuButton::getHookedObject() { + if (obj != NULL) return obj; + return H_MENUBUTTON_PARENT::getHookedObject(); +} + +int H_MenuButton::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_MENUBUTTON_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onopenmenu_id) { hook_onOpenMenu(); return 1; } + if (dlfid == onclosemenu_id) { hook_onCloseMenu(); return 1; } + if (dlfid == onselectitem_id) { hook_onSelectItem(GET_SCRIPT_STRING(*params[0])); return 1; } + return 0; +} + +int H_MenuButton::onopenmenu_id=0; +int H_MenuButton::onclosemenu_id=0; +int H_MenuButton::onselectitem_id=0; +int H_MenuButton::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_menubutton.h b/Src/Wasabi/api/script/objects/c_script/h_menubutton.h new file mode 100644 index 00000000..c55b4791 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_menubutton.h @@ -0,0 +1,35 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_MENUBUTTON_H +#define __HOOK_MENUBUTTON_H + +#include "h_guiobject.h" + +#define H_MENUBUTTON_PARENT H_GuiObject + +class H_MenuButton : public H_MENUBUTTON_PARENT { + +public: + + H_MenuButton(ScriptObject *o); + H_MenuButton(); + virtual ~H_MenuButton(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onOpenMenu() { } + virtual void hook_onCloseMenu() { } + virtual void hook_onSelectItem(const wchar_t *item) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onopenmenu_id; + static int onclosemenu_id; + static int onselectitem_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_querylist.cpp b/Src/Wasabi/api/script/objects/c_script/h_querylist.cpp new file mode 100644 index 00000000..061f298e --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_querylist.cpp @@ -0,0 +1,54 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_querylist.h" + +H_QueryList::H_QueryList(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_QueryList::H_QueryList() { + inited = 0; + obj = NULL; +} + +void H_QueryList::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, queryListGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &queryListGuid); + if (loaded == 0) { + onresetquery_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onResetQuery", this); + loaded = 1; + } + inited=1; +} + +H_QueryList::~H_QueryList() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_QueryList::getHookedObject() { + if (obj != NULL) return obj; + return H_QUERYLIST_PARENT::getHookedObject(); +} + +int H_QueryList::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_QUERYLIST_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onresetquery_id) { hook_onResetQuery(); return 1; } + return 0; +} + +int H_QueryList::onresetquery_id=0; +int H_QueryList::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_querylist.h b/Src/Wasabi/api/script/objects/c_script/h_querylist.h new file mode 100644 index 00000000..e95b3015 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_querylist.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_QUERYLIST_H +#define __HOOK_QUERYLIST_H + +#include "h_guiobject.h" + +#define H_QUERYLIST_PARENT H_GuiObject + +class H_QueryList : public H_QUERYLIST_PARENT { + +public: + + H_QueryList(ScriptObject *o); + H_QueryList(); + virtual ~H_QueryList(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onResetQuery() { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onresetquery_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_rootobj.cpp b/Src/Wasabi/api/script/objects/c_script/h_rootobj.cpp new file mode 100644 index 00000000..72ccc990 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_rootobj.cpp @@ -0,0 +1,41 @@ +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_rootobj.h" + +H_RootObject::H_RootObject(ScriptObject *o) { + inited = 0; + me = NULL; + H_hook(o); +} + +H_RootObject::H_RootObject() { + inited = 0; + me = NULL; +} + +void H_RootObject::H_hook(ScriptObject *o) { + ASSERT(!inited); + me = o; + addMonitorObject(o, &rootObjectGuid); + if (count++ == 0) { + onnotify_id = WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onNotify", this); + } + inited=1; +} + +H_RootObject::~H_RootObject() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); + //count--; +} + +int H_RootObject::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (dlfid == onnotify_id) { hook_onNotify(GET_SCRIPT_STRING(*params[0]), GET_SCRIPT_STRING(*params[1]), GET_SCRIPT_INT(*params[2]), GET_SCRIPT_INT(*params[3])); return 1; } + return 0; +} + +int H_RootObject::onnotify_id=0; +int H_RootObject::inited=0; +int H_RootObject::count=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_rootobj.h b/Src/Wasabi/api/script/objects/c_script/h_rootobj.h new file mode 100644 index 00000000..8488f7c7 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_rootobj.h @@ -0,0 +1,30 @@ +#ifndef __HOOK_SCRIPTOBJECT_H +#define __HOOK_SCRIPTOBJECT_H + +#include <api/script/objects/c_script/scripthook.h> + +class H_RootObject : public ScriptHookI { + + public: + + H_RootObject(ScriptObject *o); + H_RootObject(); + virtual ~H_RootObject(); + + virtual void H_hook(ScriptObject *o); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + + virtual void hook_onNotify(const wchar_t *s, const wchar_t *t, int u, int v) {} + + virtual ScriptObject *getHookedObject() { return me; } + + private: + + ScriptObject *me; + static int onnotify_id; + static int inited; + static int count; +}; + +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/c_script/h_slider.cpp b/Src/Wasabi/api/script/objects/c_script/h_slider.cpp new file mode 100644 index 00000000..bca6dc96 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_slider.cpp @@ -0,0 +1,62 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_slider.h" + +H_Slider::H_Slider(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Slider::H_Slider() { + inited = 0; + obj = NULL; +} + +void H_Slider::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, sliderGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &sliderGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + onsetposition_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSetPosition", this); + onpostedposition_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onPostedPosition", this); + onsetfinalposition_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSetFinalPosition", this); + loaded = 1; + } + inited=1; +} + +H_Slider::~H_Slider() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Slider::getHookedObject() { + if (obj != NULL) return obj; + return H_SLIDER_PARENT::getHookedObject(); +} + +int H_Slider::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_SLIDER_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == onsetposition_id) { hook_onSetPosition(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onpostedposition_id) { hook_onPostedPosition(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onsetfinalposition_id) { hook_onSetFinalPosition(GET_SCRIPT_INT(*params[0])); return 1; } + return 0; +} + +int H_Slider::onsetposition_id=0; +int H_Slider::onpostedposition_id=0; +int H_Slider::onsetfinalposition_id=0; +int H_Slider::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_slider.h b/Src/Wasabi/api/script/objects/c_script/h_slider.h new file mode 100644 index 00000000..c7539746 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_slider.h @@ -0,0 +1,35 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_SLIDER_H +#define __HOOK_SLIDER_H + +#include "h_guiobject.h" + +#define H_SLIDER_PARENT H_GuiObject + +class H_Slider : public H_SLIDER_PARENT { + +public: + + H_Slider(ScriptObject *o); + H_Slider(); + virtual ~H_Slider(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onSetPosition(int newpos) { } + virtual void hook_onPostedPosition(int newpos) { } + virtual void hook_onSetFinalPosition(int pos) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int onsetposition_id; + static int onpostedposition_id; + static int onsetfinalposition_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_tabsheet.cpp b/Src/Wasabi/api/script/objects/c_script/h_tabsheet.cpp new file mode 100644 index 00000000..7c66f043 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_tabsheet.cpp @@ -0,0 +1,53 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> +#include <api/api.h> +#include <api/script/objcontroller.h> +#include "h_tabsheet.h" + +H_TabSheet::H_TabSheet(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_TabSheet::H_TabSheet() { + inited = 0; + obj = NULL; +} + +void H_TabSheet::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, tabSheetGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &tabSheetGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + loaded = 1; + } + inited=1; +} + +H_TabSheet::~H_TabSheet() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_TabSheet::getHookedObject() { + if (obj != NULL) return obj; + return H_TABSHEET_PARENT::getHookedObject(); +} + +int H_TabSheet::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_TABSHEET_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + return 0; +} + +int H_TabSheet::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_tabsheet.h b/Src/Wasabi/api/script/objects/c_script/h_tabsheet.h new file mode 100644 index 00000000..d68714d5 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_tabsheet.h @@ -0,0 +1,29 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_TABSHEET_H +#define __HOOK_TABSHEET_H + +#include "h_guiobject.h" + +#define H_TABSHEET_PARENT H_GuiObject + +class H_TabSheet : public H_TABSHEET_PARENT { + +public: + + H_TabSheet(ScriptObject *o); + H_TabSheet(); + virtual ~H_TabSheet(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + + private: + + ScriptObject *obj; + int inited; + static int loaded; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_text.cpp b/Src/Wasabi/api/script/objects/c_script/h_text.cpp new file mode 100644 index 00000000..37afc9bf --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_text.cpp @@ -0,0 +1,56 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_text.h" + +H_Text::H_Text(ScriptObject *o) : H_GuiObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_Text::H_Text() { + inited = 0; + obj = NULL; +} + +void H_Text::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, textGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &textGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + ontextchanged_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTextChanged", this); + loaded = 1; + } + inited=1; +} + +H_Text::~H_Text() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_Text::getHookedObject() { + if (obj != NULL) return obj; + return H_TEXT_PARENT::getHookedObject(); +} + +int H_Text::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_TEXT_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == ontextchanged_id) { hook_onTextChanged(GET_SCRIPT_STRING(*params[0])); return 1; } + return 0; +} + +int H_Text::ontextchanged_id=0; +int H_Text::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_text.h b/Src/Wasabi/api/script/objects/c_script/h_text.h new file mode 100644 index 00000000..f91285eb --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_text.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_TEXT_H +#define __HOOK_TEXT_H + +#include "h_guiobject.h" + +#define H_TEXT_PARENT H_GuiObject + +class H_Text : public H_TEXT_PARENT { + +public: + + H_Text(ScriptObject *o); + H_Text(); + virtual ~H_Text(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onTextChanged(const wchar_t *newtxt) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontextchanged_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_togglebutton.cpp b/Src/Wasabi/api/script/objects/c_script/h_togglebutton.cpp new file mode 100644 index 00000000..a3e64678 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_togglebutton.cpp @@ -0,0 +1,56 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_togglebutton.h" + +H_ToggleButton::H_ToggleButton(ScriptObject *o) : H_Button(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_ToggleButton::H_ToggleButton() { + inited = 0; + obj = NULL; +} + +void H_ToggleButton::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, toggleButtonGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &toggleButtonGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + ontoggle_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onToggle", this); + loaded = 1; + } + inited=1; +} + +H_ToggleButton::~H_ToggleButton() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_ToggleButton::getHookedObject() { + if (obj != NULL) return obj; + return H_TOGGLEBUTTON_PARENT::getHookedObject(); +} + +int H_ToggleButton::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_TOGGLEBUTTON_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == ontoggle_id) { hook_onToggle(GET_SCRIPT_INT(*params[0])); return 1; } + return 0; +} + +int H_ToggleButton::ontoggle_id=0; +int H_ToggleButton::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_togglebutton.h b/Src/Wasabi/api/script/objects/c_script/h_togglebutton.h new file mode 100644 index 00000000..ce76fa35 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_togglebutton.h @@ -0,0 +1,31 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_TOGGLEBUTTON_H +#define __HOOK_TOGGLEBUTTON_H + +#include "h_button.h" + +#define H_TOGGLEBUTTON_PARENT H_Button + +class H_ToggleButton : public H_TOGGLEBUTTON_PARENT { + +public: + + H_ToggleButton(ScriptObject *o); + H_ToggleButton(); + virtual ~H_ToggleButton(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onToggle(int (null)) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontoggle_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/h_treeitem.cpp b/Src/Wasabi/api/script/objects/c_script/h_treeitem.cpp new file mode 100644 index 00000000..1191d0bf --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_treeitem.cpp @@ -0,0 +1,89 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#include <precomp.h> + +#include <api/script/objcontroller.h> +#include "h_treeitem.h" + +H_TreeItem::H_TreeItem(ScriptObject *o) : H_RootObject(o) { + inited = 0; + obj = NULL; + H_hook(o); +} + +H_TreeItem::H_TreeItem() { + inited = 0; + obj = NULL; +} + +void H_TreeItem::H_hook(ScriptObject *o) { + ASSERT(!inited); + ScriptObjectController *controller = o->vcpu_getController(); + obj = controller->cast(o, treeItemGuid); + if (obj != o && obj != NULL) + o = obj; + else + obj = NULL; + + addMonitorObject(o, &treeItemGuid); + + int iter = WASABI_API_APP->app_getInitCount(); + if (!loaded || loaded != iter) { + ontreeadd_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTreeAdd", this); + ontreeremove_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onTreeRemove", this); + onselect_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSelect", this); + ondeselect_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDeselect", this); + onleftdoubleclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftDoubleClick", this); + onrightdoubleclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightDoubleClick", this); + onchar_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onChar", this); + onexpand_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onExpand", this); + oncollapse_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onCollapse", this); + onbeginlabeledit_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onBeginLabelEdit", this); + onendlabeledit_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onEndLabelEdit", this); + oncontextmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onContextMenu", this); + loaded = 1; + } + inited=1; +} + +H_TreeItem::~H_TreeItem() { + if (!inited) return; + WASABI_API_MAKI->maki_remDlfRef(this); +} + +ScriptObject *H_TreeItem::getHookedObject() { + if (obj != NULL) return obj; + return H_TREEITEM_PARENT::getHookedObject(); +} + +int H_TreeItem::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + if (object != getHookedObject()) return 0; + if (H_TREEITEM_PARENT::eventCallback(object, dlfid, params, nparams)) return 1; + if (dlfid == ontreeadd_id) { hook_onTreeAdd(); return 1; } + if (dlfid == ontreeremove_id) { hook_onTreeRemove(); return 1; } + if (dlfid == onselect_id) { hook_onSelect(); return 1; } + if (dlfid == ondeselect_id) { hook_onDeselect(); return 1; } + if (dlfid == onleftdoubleclick_id) { hook_onLeftDoubleClick(); return 1; } + if (dlfid == onrightdoubleclick_id) { hook_onRightDoubleClick(); return 1; } + if (dlfid == onchar_id) { hook_onChar(GET_SCRIPT_INT(*params[0])); return 1; } + if (dlfid == onexpand_id) { hook_onExpand(); return 1; } + if (dlfid == oncollapse_id) { hook_onCollapse(); return 1; } + if (dlfid == onbeginlabeledit_id) { hook_onBeginLabelEdit(); return 1; } + if (dlfid == onendlabeledit_id) { hook_onEndLabelEdit(GET_SCRIPT_STRING(*params[0])); return 1; } + if (dlfid == oncontextmenu_id) { hook_onContextMenu(GET_SCRIPT_INT(*params[0]), GET_SCRIPT_INT(*params[1])); return 1; } + return 0; +} + +int H_TreeItem::ontreeadd_id=0; +int H_TreeItem::ontreeremove_id=0; +int H_TreeItem::onselect_id=0; +int H_TreeItem::ondeselect_id=0; +int H_TreeItem::onleftdoubleclick_id=0; +int H_TreeItem::onrightdoubleclick_id=0; +int H_TreeItem::onchar_id=0; +int H_TreeItem::onexpand_id=0; +int H_TreeItem::oncollapse_id=0; +int H_TreeItem::onbeginlabeledit_id=0; +int H_TreeItem::onendlabeledit_id=0; +int H_TreeItem::oncontextmenu_id=0; +int H_TreeItem::loaded=0; diff --git a/Src/Wasabi/api/script/objects/c_script/h_treeitem.h b/Src/Wasabi/api/script/objects/c_script/h_treeitem.h new file mode 100644 index 00000000..173ce1a0 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/h_treeitem.h @@ -0,0 +1,53 @@ +/* This file was generated by Maki Compiler, do not edit manually */ + +#ifndef __HOOK_TREEITEM_H +#define __HOOK_TREEITEM_H + +#include "h_rootobj.h" + +#define H_TREEITEM_PARENT H_RootObject + +class H_TreeItem : public H_TREEITEM_PARENT { + +public: + + H_TreeItem(ScriptObject *o); + H_TreeItem(); + virtual ~H_TreeItem(); + virtual void H_hook(ScriptObject *o); + ScriptObject *getHookedObject(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + virtual void hook_onTreeAdd() { } + virtual void hook_onTreeRemove() { } + virtual void hook_onSelect() { } + virtual void hook_onDeselect() { } + virtual void hook_onLeftDoubleClick() { } + virtual void hook_onRightDoubleClick() { } + virtual void hook_onChar(wchar_t key) { } + virtual void hook_onExpand() { } + virtual void hook_onCollapse() { } + virtual void hook_onBeginLabelEdit() { } + virtual void hook_onEndLabelEdit(const wchar_t *newlabel) { } + virtual void hook_onContextMenu(int x, int y) { } + + private: + + ScriptObject *obj; + int inited; + static int loaded; + static int ontreeadd_id; + static int ontreeremove_id; + static int onselect_id; + static int ondeselect_id; + static int onleftdoubleclick_id; + static int onrightdoubleclick_id; + static int onchar_id; + static int onexpand_id; + static int oncollapse_id; + static int onbeginlabeledit_id; + static int onendlabeledit_id; + static int oncontextmenu_id; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/c_script/scripthook.cpp b/Src/Wasabi/api/script/objects/c_script/scripthook.cpp new file mode 100644 index 00000000..a57ced19 --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/scripthook.cpp @@ -0,0 +1,47 @@ +#include <precomp.h> + +#include <api/script/scriptobj.h> +#include <api/script/objcontroller.h> +#include "scripthook.h" + +#define CBCLASS ScriptHookI +START_DISPATCH; + CB(EVENTCALLBACK, eventCallback); +END_DISPATCH; + +ScriptHookI::ScriptHookI() { +} + +ScriptHookI::~ScriptHookI() { + WASABI_API_MAKI->maki_remDlfRef(this); + foreach(controllers) + controllers.getfor()->removeHooks(this); + endfor + +} + + +void ScriptHookI::addMonitorObject(ScriptObject *o, const GUID *hookedclass) { + WASABI_API_MAKI->maki_addDlfClassRef(o->vcpu_getController(), this); + ScriptObjectController *cont = o->vcpu_getController(); + if (hookedclass == NULL) { + cont->addObjectHook(this, o); + } else { + while (cont) { + if (cont->getClassGuid() == *hookedclass) { + cont->addObjectHook(this, o); + break; + } + cont = cont->getAncestorController(); + } + } + if (cont == NULL) // guid not found + return; + controllers.addItem(cont); +} + +void ScriptHookI::addMonitorClass(ScriptObject *o) { + WASABI_API_MAKI->maki_addDlfClassRef(o->vcpu_getController(), this); + o->vcpu_getController()->addClassHook(this); + controllers.addItem(o->vcpu_getController()); +} diff --git a/Src/Wasabi/api/script/objects/c_script/scripthook.h b/Src/Wasabi/api/script/objects/c_script/scripthook.h new file mode 100644 index 00000000..f529ee6f --- /dev/null +++ b/Src/Wasabi/api/script/objects/c_script/scripthook.h @@ -0,0 +1,49 @@ +#ifndef __SCRIPTHOOK_H +#define __SCRIPTHOOK_H + +#include <api/script/vcputypes.h> +#include <bfc/dispatch.h> +#include <bfc/ptrlist.h> + + +class ScriptObject; +class ScriptObjectController; + +// ---------------------------------------------------------------------------------------------------------- + +class ScriptHook : public Dispatchable { + protected: + ScriptHook() {}; + + public: + int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams); + + enum { + EVENTCALLBACK = 100, + }; + +}; + +inline int ScriptHook::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) { + return _call(EVENTCALLBACK, 0, object, dlfid, params, nparams); +} + +class ScriptHookI : public ScriptHook { + +public: + + ScriptHookI(); + virtual ~ScriptHookI(); + + virtual int eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams)=0; + + void addMonitorObject(ScriptObject *o, const GUID *hookedclass=NULL); // NULL = all classes of object o + void addMonitorClass(ScriptObject *o); + +protected: + RECVS_DISPATCH; + + PtrList<ScriptObjectController> controllers; +}; + +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/compoobj.cpp b/Src/Wasabi/api/script/objects/compoobj.cpp new file mode 100644 index 00000000..7b7ba8bb --- /dev/null +++ b/Src/Wasabi/api/script/objects/compoobj.cpp @@ -0,0 +1,361 @@ +#include "precomp.h" +#ifndef _NOSTUDIO + +#include "../../common/std.h" +#include "script.h" +#include "scriptmgr.h" +#include "../../common/script/scriptobj.h" +#include "compoobj.h" +#include "../api.h" +#include "vcpu.h" +#include "../smap.h" +#include "sregion.h" +#include "../skinparse.h" +#include "../compon.h" +#include "../compwnd.h" +#include "../cbmgr.h" +#include "../smap.h" +#include "../../common/wndcb.h" + +#else +#include "compoobj.h" +#endif + +CompoObjScriptController _compoController; +CompoObjScriptController *compoController=&_compoController; + +// -- Functions table ------------------------------------- +function_descriptor_struct CompoObjScriptController::exportedFunction[] = { + {"getGUID", 1, (void*)ComponentObject::script_vcpu_getGUID }, + {"getWac", 0, (void*)ComponentObject::script_vcpu_getWac }, + {"setRegionFromMap", 3, (void*)ComponentObject::script_vcpu_setRegionFromMap }, + {"setRegion", 1, (void*)ComponentObject::script_vcpu_setRegion }, + {"onGetWac", 1, (void*)ComponentObject::script_vcpu_onGetWac }, + {"onGiveUpWac", 1, (void*)ComponentObject::script_vcpu_onGiveUpWac }, + {"setAcceptWac", 1, (void*)ComponentObject::script_vcpu_setAcceptWac }, +}; +// -------------------------------------------------------- + +const char *CompoObjScriptController::getClassName() { + return "Component"; +} + +const wchar_t *CompoObjScriptController::getAncestorClassName() { + return "GuiObject"; +} + +int CompoObjScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *CompoObjScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID CompoObjScriptController::getClassGuid() { + return componentObjectGuid; +} + +ScriptObject *CompoObjScriptController::instantiate() { + ComponentObject *obj = new ComponentObject(); + return obj->getScriptObject(); +} + +void CompoObjScriptController::destroy(ScriptObject *o) { + ComponentObject *obj = static_cast<ComponentObject *>(o->vcpu_getInterface(componentObjectGuid)); + ASSERT(obj != NULL); + delete obj; +} + +void *CompoObjScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for componentobject yet +} + +void CompoObjScriptController::deencapsulate(void *) { +} + + +ComponentObject::ComponentObject() { + getScriptObject()->vcpu_setInterface(componentObjectGuid, (void *)static_cast<ComponentObject *>(this)); + getScriptObject()->vcpu_setClassName("Component"); + getScriptObject()->vcpu_setController(compoController); + deleting = 0; + compwnd = NULL; + noshowcmdbar = 0; + noshowbtnbar = 0; + MEMCPY(&myGUID, &INVALID_GUID, sizeof(GUID)); + MEMCPY(&myCompGuid, &INVALID_GUID, sizeof(GUID)); + my_region_clone = NULL; + ComponentManager::registerComponentObject(this); + autoopen = 0; + autoclose = 0; + accept = 1; + denyDesktopAlpha = 0; + denyTransparency = 0; + noanimrects = 0; +} + +int ComponentObject::setXmlParam(const char *name, const char *value) { + if (COMPONENTOBJECT_PARENT::setXmlParam(name, value)) return 1; + else if (STRCASEEQL(name, "param")) { + GUID *g; + g = SkinParser::getComponentGuid(value); + if (g) + setGUID(*g); + } else if (STRCASEEQL(name, "noshowcmdbar")) { + noshowcmdbar = WTOI(value); + } else if (STRCASEEQL(name, "autoopen")) { + autoopen = WTOI(value); + } else if (STRCASEEQL(name, "autoclose")) { + autoclose = WTOI(value); + } else if (STRCASEEQL(name, "disableanimatedrects")) { + noanimrects = WTOI(value); + } else return 0; + return 1; +} + +ComponentObject::~ComponentObject() { + deleting = 1; + ComponentManager::unregisterComponentObject(this, 1); + delete my_region_clone; +} + +int ComponentObject::onResize() { + COMPONENTOBJECT_PARENT::onResize(); + RECT r = clientRect(); + if (compwnd) { + compwnd->resize(&r); + } + return 1; +} + +int ComponentObject::handleRatio() { + return compwnd ? compwnd->handleRatio() : 0; +} + +void ComponentObject::setGUID(GUID g) { + myGUID = g; +} + +void ComponentObject::setCompGUID(GUID g) { + myCompGuid = g; +} + +GUID ComponentObject::getGUID(void) { + if (!MEMCMP(&myCompGuid, &INVALID_GUID, sizeof(GUID))) + return myGUID; + else + return myCompGuid; +} + +void ComponentObject::script_resetRegion() { + HWND h = ComponentManager::getComponentHWnd(myGUID); + if (h) SetWindowRgn(h, NULL, TRUE); + delete my_region_clone; + my_region_clone = NULL; +} + +void ComponentObject::script_setRegionFromMap(SMap *map, int byte, int inv) { + RECT r={map->getBitmap()->getX(), map->getBitmap()->getY(), map->getBitmap()->getWidth(), map->getBitmap()->getHeight()}; + api_region *reg = new api_region(map->getBitmap(), &r, 0, 0, FALSE, 1, (unsigned char)byte, inv); + if (!reg) { script_resetRegion(); return; } + delete my_region_clone; + my_region_clone = new api_region(); + my_region_clone->add(reg); + delete reg; + HWND h = ComponentManager::getComponentHWnd(myGUID); + if (h) { + api_region *clone = my_region_clone->clone(); + clone->scale(getRenderRatio()); + SetWindowRgn(h, clone->makeWindowRegion(), TRUE); + my_region_clone->disposeClone(clone); + } +} + +void ComponentObject::script_setRegion(SRegion *r) { + api_region *reg = r->getRegion(); + if (!reg) { script_resetRegion(); return; } + delete my_region_clone; + my_region_clone = new api_region(); + my_region_clone->add(reg); + HWND h = ComponentManager::getComponentHWnd(myGUID); + if (h) { + api_region *clone = my_region_clone->clone(); + clone->scale(getRenderRatio()); + SetWindowRgn(h, clone->makeWindowRegion(), TRUE); + my_region_clone->disposeClone(clone); + } +} + +void ComponentObject::onSetVisible(int s) { + COMPONENTOBJECT_PARENT::onSetVisible(s); + if (compwnd) { + compwnd->setVisible(s); + onResize(); + } else { + if (s && autoopen && myGUID != INVALID_GUID && myGUID != GENERIC_GUID) + api->setComponentVisible(myGUID, 1); + } +} + +void ComponentObject::deniedComponentCompWnd(CompWnd *c, GUID g) { + if (!deleting) { + Container *_c = getGuiObject()->guiobject_getParentGroup()->getParentContainer(); + if (_c) _c->resetGUID(); + } + compwnd = c; + compwnd->suppressStatusBar(noshowcmdbar); + + CallbackManager::issueCallback(SysCallback::WINDOW, WndCallback::HIDEWINDOW, reinterpret_cast<int>((int *)&g)); + + onReleaseComponent(); + compwnd = NULL; + denyDesktopAlpha = 0; + denyTransparency = 0; + if (!deleting) getGuiObject()->guiobject_getParentLayout()->onGuiObjectSetVisible(getGuiObject(), 0); +} + +void ComponentObject::grantedComponentCompWnd(CompWnd *c, GUID g) { + Container *_c = getGuiObject()->guiobject_getParentGroup()->getParentContainer(); + if (_c) _c->setGUID(g); // tells the container to change its script_id to id:{guid} + compwnd = c; + compwnd->suppressStatusBar(noshowcmdbar); + + onResize(); + + if (isVisible()) + c->setVisible(1); + + CallbackManager::issueCallback(SysCallback::WINDOW, WndCallback::SHOWWINDOW, reinterpret_cast<int>((int *)&g)); + + onGetComponent(g); +} + +void ComponentObject::onReleaseComponent() { + HWND h = ComponentManager::getComponentHWnd(myGUID); + SetWindowRgn(h, NULL, FALSE); +} + +void ComponentObject::onGetComponent(GUID g) { + HWND h = ComponentManager::getComponentHWnd(myGUID); + if (h) { + if (my_region_clone) { + api_region *clone = my_region_clone->clone(); + clone->scale(getRenderRatio()); + SetWindowRgn(h, clone->makeWindowRegion(), TRUE); + my_region_clone->disposeClone(clone); + } else + SetWindowRgn(h, NULL, FALSE); + } +} + +int ComponentObject::wantGUID(GUID *g) { + if (!accept || !getGuiObject()->guiobject_getParentGroup()) return 0; + Container *_c = getGuiObject()->guiobject_getParentGroup()->getParentContainer(); + if (_c && _c->isDynamic() && compwnd) return 0; + if (!MEMCMP(&myGUID, &GENERIC_GUID, sizeof(GUID))) return 1; + return !MEMCMP(&myGUID, g, sizeof(GUID)); +} + +void ComponentObject::onBeforeGetWac(GUID g, CompWnd *c) { +// if (!Std::isXPOrGreater()) + if (!c->handleDesktopAlpha()) + denyDesktopAlpha = 1; + if (!c->handleTransparency()) + denyTransparency = 1; + getGuiObject()->guiobject_getParentLayout()->onGuiObjectSetVisible(getGuiObject(), 1); + WACObject *wo = SOM::getWACObject(g); + script_vcpu_onGetWac(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_OBJECT(wo ? wo->getScriptObject() : NULL)); +} + +void ComponentObject::onBeforeGiveUpWac(GUID g, CompWnd *c) { + WACObject *wo = SOM::getWACObject(g); + script_vcpu_onGiveUpWac(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_OBJECT(wo ? wo->getScriptObject() : NULL)); +} + +int ComponentObject::getAutoClose() { + return autoclose; +} + +void ComponentObject::setAcceptWac(int a) { + accept = a; +} + +int ComponentObject::handleDesktopAlpha() { + if (denyDesktopAlpha) return 0; + if (!compwnd) return 1; + return 0; +} + +int ComponentObject::handleTransparency() { + if (denyTransparency) return 0; + if (!compwnd) return 1; + return compwnd->handleTransparency(); +} + +int ComponentObject::getPreferences(int what) { + if (compwnd) return compwnd->getPreferences(what); + return COMPONENTOBJECT_PARENT::getPreferences(what); +} + +scriptVar ComponentObject::script_vcpu_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + + OLECHAR oguid[256] = {0}; // NONPORTABLE + ComponentObject *co = static_cast<ComponentObject *>(o->vcpu_getInterface(componentObjectGuid)); + if (co) { + static char guid[256]; + StringFromGUID2(((ComponentObject *)o)->myGUID, oguid, 256); + wsprintf(guid, "%$", oguid); + return MAKE_SCRIPT_STRING(guid); + } + return MAKE_SCRIPT_STRING(""); +} + +scriptVar ComponentObject::script_vcpu_getWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; ; + ComponentObject *co = static_cast<ComponentObject *>(o->vcpu_getInterface(componentObjectGuid)); + return MAKE_SCRIPT_OBJECT(co ? SOM::getWACObject(co->getGUID())->getScriptObject() : NULL); +} + +scriptVar ComponentObject::script_vcpu_setRegionFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inv) { + SCRIPT_FUNCTION_INIT; ; + ASSERT(SOM::isNumeric(&byte)); + ASSERT(SOM::isNumeric(&inv)); + ComponentObject *co = static_cast<ComponentObject *>(o->vcpu_getInterface(componentObjectGuid)); + SMap *sm = static_cast<SMap *>(GET_SCRIPT_OBJECT_AS(map, mapGuid)); + co->script_setRegionFromMap(sm, SOM::makeInt(&byte), SOM::makeBoolean(&inv)); + RETURN_SCRIPT_VOID; +} + +scriptVar ComponentObject::script_vcpu_setRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) { + SCRIPT_FUNCTION_INIT; ; + ComponentObject *co = static_cast<ComponentObject *>(o->vcpu_getInterface(componentObjectGuid)); + SRegion *reg = static_cast<SRegion *>(GET_SCRIPT_OBJECT_AS(r, regionGuid)); + if (co) co->script_setRegion(reg); + RETURN_SCRIPT_VOID; +} + +scriptVar ComponentObject::script_vcpu_onGetWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar wac) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, compoController, wac); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, wac); +} + +scriptVar ComponentObject::script_vcpu_onGiveUpWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar wac) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, compoController, wac); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, wac); +} + +scriptVar ComponentObject::script_vcpu_setAcceptWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar on) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&on)); + ComponentObject *co = static_cast<ComponentObject *>(o->vcpu_getInterface(componentObjectGuid)); + if (co) co->setAcceptWac(GET_SCRIPT_BOOLEAN(on)); + RETURN_SCRIPT_VOID; +} + + diff --git a/Src/Wasabi/api/script/objects/compoobj.h b/Src/Wasabi/api/script/objects/compoobj.h new file mode 100644 index 00000000..6e18f84b --- /dev/null +++ b/Src/Wasabi/api/script/objects/compoobj.h @@ -0,0 +1,119 @@ +#ifndef _COMPONENTOBJ_H +#define _COMPONENTOBJ_H + +#include <api/script/script.h> +#include <api/script/scriptobj.h> +#include <api/wnd/wndclass/guiobjwnd.h> +#include <api/script/objects/guiobj.h> + +class SMap; +class SRegion; +class Container; +class Layout; +class CompWnd; + +// {403ABCC0-6F22-4bd6-8BA4-10C829932547} +static const GUID componentObjectGuid = +{ 0x403abcc0, 0x6f22, 0x4bd6, { 0x8b, 0xa4, 0x10, 0xc8, 0x29, 0x93, 0x25, 0x47 } }; + +#define COMPONENTOBJECT_PARENT GuiObjectWnd + +class CompoObjScriptController : public GuiObjectScriptController { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return guiController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern CompoObjScriptController *compoController; + + +#ifndef _NOSTUDIO + +#include <api/wnd/virtualwnd.h> + +class ComponentObject : public COMPONENTOBJECT_PARENT { +public: + ComponentObject(); + virtual ~ComponentObject(); + + virtual int setXmlParam(const wchar_t *name, const wchar_t *value); + + virtual int onResize(); + virtual void onSetVisible(int s); + virtual int handleRatio(); + + void deniedComponentCompWnd(CompWnd *c, GUID g); + void grantedComponentCompWnd(CompWnd *c, GUID g); + int wantGUID(GUID *g); + + void onReleaseComponent(); + void onGetComponent(GUID g); + + void onBeforeGetWac(GUID g, CompWnd *c); + void onBeforeGiveUpWac(GUID g, CompWnd *c); + + void setGUID(GUID g); + void setCompGUID(GUID g); + GUID getGUID(void); + int getAutoClose(); + void setAcceptWac(int a); + int getAnimatedRects() { return !noanimrects; } + virtual int getPreferences(int what); + + virtual void script_resetRegion(); + virtual void script_setRegionFromMap(SMap *map, int byte, int inv); + virtual void script_setRegion(SRegion *r); + virtual int handleDesktopAlpha(); + virtual int handleTransparency(); + + // VCPU + static scriptVar script_vcpu_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onShow(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onHide(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onGetWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar wac); + static scriptVar script_vcpu_onGiveUpWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar wac); + static scriptVar script_vcpu_setRegionFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inv); + static scriptVar script_vcpu_setRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar script_vcpu_setAcceptWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar on); + // End VCPU + +private: + GUID myGUID; + GUID myCompGuid; + + int deleting; + + CompWnd *compwnd; + int noshowcmdbar; + int noshowbtnbar; + + api_region *my_region_clone; + int autoopen, autoclose; + int accept; + int denyDesktopAlpha; + int denyTransparency; + int noanimrects; + +#else +class ComponentObject : public COMPONENTOBJECT_SCRIPTPARENT { +#endif + +}; + + +#endif diff --git a/Src/Wasabi/api/script/objects/core/coreadminobj.cpp b/Src/Wasabi/api/script/objects/core/coreadminobj.cpp new file mode 100644 index 00000000..505fa2e8 --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/coreadminobj.cpp @@ -0,0 +1,184 @@ +#include <precomp.h> + +#include <api/service/svcs/svc_coreadmin.h> +#include <api/script/objects/core/coreadminobj.h> +#include <api/script/objects/core/coreobj.h> + +static CoreAdminScriptObjectController _coreAdminController; +ScriptObjectController *coreAdminController = &_coreAdminController; + +// Table of exported functions and events +// "function name", n. params, function_pointer +function_descriptor_struct CoreAdminScriptObjectController::exportedFunction[] = { + {L"getNamedCore", 1, (void*)coreadmin_getNamedCore}, + {L"newNamedCore", 1, (void*)coreadmin_newNamedCore}, + {L"freeCore", 1, (void*)coreadmin_freeCore}, + {L"freeCoreByName", 1, (void*)coreadmin_freeCoreByName}, +}; + +int CoreAdminScriptObjectController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +ScriptObject *CoreAdminScriptObjectController::instantiate() { + ScriptCoreAdminObject *scao = new ScriptCoreAdminObject; + ASSERT(scao != NULL); + return scao->getScriptObject(); +} + +void CoreAdminScriptObjectController::destroy(ScriptObject *o) { + ScriptCoreAdminObject *scao = static_cast<ScriptCoreAdminObject *>(o->vcpu_getInterface(COREADMIN_SCRIPTOBJECT_GUID)); + ASSERT(scao != NULL); + delete scao; +} + +void *CoreAdminScriptObjectController::encapsulate(ScriptObject *o) { + return NULL; +} + +void CoreAdminScriptObjectController::deencapsulate(void *o) { +} + +scriptVar CoreAdminScriptObjectController::coreadmin_getNamedCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) +{ + SCRIPT_FUNCTION_INIT + ScriptCoreAdminObject *scao = static_cast<ScriptCoreAdminObject *>(o->vcpu_getInterface(COREADMIN_SCRIPTOBJECT_GUID)); + if (scao) { + const wchar_t *cname = GET_SCRIPT_STRING(name); + if (cname) { +#ifndef FAKE_SCRIPTCORE + // Get the token for the requested core. + CoreToken core = scao->getNamedCore(cname); + if (core == -1) { + RETURN_SCRIPT_VOID; + } +#endif + // Make a new Core scriptobj to point to the requested core. + CoreScriptObjectController *controller = static_cast<CoreScriptObjectController *>(coreController); +#ifndef FAKE_SCRIPTCORE + ScriptObject *coreobj = controller->instantiate(core); +#else + ScriptObject *coreobj = controller->instantiate(NULL); +#endif + return MAKE_SCRIPT_OBJECT(coreobj); + } + } + RETURN_SCRIPT_NULL; +} + +scriptVar CoreAdminScriptObjectController::coreadmin_newNamedCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) { + SCRIPT_FUNCTION_INIT + ScriptCoreAdminObject *scao = static_cast<ScriptCoreAdminObject *>(o->vcpu_getInterface(COREADMIN_SCRIPTOBJECT_GUID)); + if (scao) { + const wchar_t *cname = GET_SCRIPT_STRING(name); + if (cname) { + // Get the token for the created core. + /*CoreToken core = */scao->newNamedCore(cname); + // Make a new Core scriptobj to point to the created core. + CoreScriptObjectController *controller = static_cast<CoreScriptObjectController *>(coreController); +#ifndef FAKE_SCRIPTCORE + ScriptObject *coreobj = controller->instantiate(core); + // Then get the object back and bind a sequencer and stuff to it. Like we just said "new Core" + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(coreobj->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + sco->initAsCreated(); + } +#else + ScriptObject *coreobj = controller->instantiate(NULL); +#endif + return MAKE_SCRIPT_OBJECT(coreobj); + } + } + RETURN_SCRIPT_VOID; +} + +scriptVar CoreAdminScriptObjectController::coreadmin_freeCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar core) { + SCRIPT_FUNCTION_INIT + ScriptCoreAdminObject *scao = static_cast<ScriptCoreAdminObject *>(o->vcpu_getInterface(COREADMIN_SCRIPTOBJECT_GUID)); + if (scao) { + // Pull the ScriptCoreObject from the scriptVar + ScriptObject *coreobj = GET_SCRIPT_OBJECT(core); + if (coreobj) { + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(coreobj->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { +#ifndef FAKE_SCRIPTCORE + scao->freeCore(sco->core_handle); +#endif + return MAKE_SCRIPT_INT(1); + } + } + } + return MAKE_SCRIPT_INT(0); +} + +scriptVar CoreAdminScriptObjectController::coreadmin_freeCoreByName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) { + SCRIPT_FUNCTION_INIT + ScriptCoreAdminObject *scao = static_cast<ScriptCoreAdminObject *>(o->vcpu_getInterface(COREADMIN_SCRIPTOBJECT_GUID)); + if (scao) { + const wchar_t *cname = GET_SCRIPT_STRING(name); + if (cname) { + // Try to remove it. + int retval = scao->freeCoreByName(cname); + return MAKE_SCRIPT_INT(retval); + } + } + return MAKE_SCRIPT_INT(0); +} + + +// ----------------------------------------------------------------------------------------------------- + +ScriptCoreAdminObject::ScriptCoreAdminObject() { + getScriptObject()->vcpu_setClassName(L"CoreAdmin"); + getScriptObject()->vcpu_setController(coreAdminController); + getScriptObject()->vcpu_setInterface(COREADMIN_SCRIPTOBJECT_GUID, static_cast<ScriptCoreAdminObject *>(this)); + +#ifndef FAKE_SCRIPTCORE + waServiceFactory *s = api->service_enumService(WaSvc::COREADMIN,0); + ASSERTPR(s,"Core Admin must be present to use ScriptCore!"); + admin = castService<svc_coreAdmin>(s); +#endif +} + +ScriptCoreAdminObject::~ScriptCoreAdminObject() { +#ifndef FAKE_SCRIPTCORE + api->service_release(admin); + admin = NULL; +#endif +} + +CoreToken ScriptCoreAdminObject::getNamedCore(const wchar_t *name) { +#ifndef FAKE_SCRIPTCORE + return admin->nameToToken(name); +#else + return 0; +#endif +} + +CoreToken ScriptCoreAdminObject::newNamedCore(const wchar_t *name) { +#ifndef FAKE_SCRIPTCORE + return admin->createCore(name); +#else + return 0; +#endif +} + +int ScriptCoreAdminObject::freeCore(CoreToken core) { +#ifndef FAKE_SCRIPTCORE + if (core == 0) return 0; // don't touch the main core. + return admin->freeCoreByToken(core); +#else + return 0; +#endif +} + +int ScriptCoreAdminObject::freeCoreByName(const wchar_t *name) { +#ifndef FAKE_SCRIPTCORE + CoreToken core = admin->nameToToken(name); + if (core == 0) return 0; // don't touch the main core. + return admin->freeCoreByToken(core); +#else + return 0; +#endif +} + diff --git a/Src/Wasabi/api/script/objects/core/coreadminobj.h b/Src/Wasabi/api/script/objects/core/coreadminobj.h new file mode 100644 index 00000000..c0322edf --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/coreadminobj.h @@ -0,0 +1,67 @@ +#ifndef __COREADMINOBJ_H +#define __COREADMINOBJ_H + +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> +#include <api/core/sequence.h> +#include <api/syscb/callbacks/corecbi.h> + +#ifdef GEN_FF +#ifndef FAKE_SCRIPTCORE +#define FAKE_SCRIPTCORE +#endif +#endif + +class svc_coreAdmin; + +// {F857BECA-8E19-41f1-973E-097E39649F03} +static const GUID COREADMIN_SCRIPTOBJECT_GUID = + { 0xf857beca, 0x8e19, 0x41f1, { 0x97, 0x3e, 0x9, 0x7e, 0x39, 0x64, 0x9f, 0x3 } }; + +extern ScriptObjectController *coreAdminController; + +// ----------------------------------------------------------------------------------------------------- +class ScriptCoreAdminObject : public RootObjectInstance +{ +public: + ScriptCoreAdminObject(); + virtual ~ScriptCoreAdminObject(); + + CoreToken getNamedCore(const wchar_t *name); + CoreToken newNamedCore(const wchar_t *name); + int freeCore(CoreToken core); + int freeCoreByName(const wchar_t *name); + +private: +#ifndef FAKE_SCRIPTCORE + svc_coreAdmin *admin; +#endif +}; + +// ----------------------------------------------------------------------------------------------------- +class CoreAdminScriptObjectController : public ScriptObjectControllerI +{ +public: + virtual const wchar_t *getClassName() { return L"CoreAdmin"; } + virtual const wchar_t *getAncestorClassName() { return L"Object"; } + virtual ScriptObjectController *getAncestorController() { return WASABI_API_MAKI->maki_getController(rootObjectGuid); } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions() { return exportedFunction; } + virtual GUID getClassGuid() { return COREADMIN_SCRIPTOBJECT_GUID; } + virtual int getInstantiable() { return 0; } + virtual int getReferenceable() { return 0; } + virtual ScriptObject *instantiate(); + virtual void *encapsulate(ScriptObject *o); + virtual void destroy(ScriptObject *o); + virtual void deencapsulate(void *o); + + static scriptVar coreadmin_getNamedCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name); + static scriptVar coreadmin_newNamedCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name); + static scriptVar coreadmin_freeCore(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar core); + static scriptVar coreadmin_freeCoreByName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name); + +private: + static function_descriptor_struct exportedFunction[]; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/core/coreobj.cpp b/Src/Wasabi/api/script/objects/core/coreobj.cpp new file mode 100644 index 00000000..a3b47bc6 --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/coreobj.cpp @@ -0,0 +1,1151 @@ +#include <precomp.h> + +#include <api/script/objects/core/coreobj.h> +#include <api/core/buttons.h> +#include <api/service/svcs/svc_coreadmin.h> + +static CoreScriptObjectController _coreController; +ScriptObjectController *coreController = &_coreController; + +#define TRICK_VOLUME 0 + +// Table of exported functions and events +// "function name", n. params, function_pointer +function_descriptor_struct CoreScriptObjectController::exportedFunction[] = { + {L"playFile", 1, (void*)ScriptCoreObject::maki_playFile}, + {L"stop", 0, (void*)ScriptCoreObject::maki_stop}, + {L"setVolume", 1, (void*)ScriptCoreObject::maki_setVolume}, +// {L"onStop", 0, (void*)ScriptCoreObject::maki_onStop}, + {L"getStatus", 0, (void*)ScriptCoreObject::maki_getStatus}, +// {L"getStuff", 0, (void*)ScriptCoreObject::maki_getStuff}, + + // Here come the new ones + {L"onStarted", 0, (void*)ScriptCoreObject::maki_onStarted}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onStopped", 0, (void*)ScriptCoreObject::maki_onStopped}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onPaused", 0, (void*)ScriptCoreObject::maki_onPaused}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onUnpaused", 0, (void*)ScriptCoreObject::maki_onUnpaused}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onSeeked", 1, (void*)ScriptCoreObject::maki_onSeeked}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpos); + {L"onVolumeChange", 1, (void*)ScriptCoreObject::maki_onVolumeChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newvol); + {L"onPanChange", 1, (void*)ScriptCoreObject::maki_onPanChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpan); + {L"onEQStatusChange", 1, (void*)ScriptCoreObject::maki_onEQStatusChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + {L"onEQPreampChange", 1, (void*)ScriptCoreObject::maki_onEQPreampChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + {L"onEQBandChange", 2, (void*)ScriptCoreObject::maki_onEQBandChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band, scriptVar /*int*/ newval); + {L"onEQFreqChange", 1, (void*)ScriptCoreObject::maki_onEQFreqChange}, + {L"onEQAutoChange", 1, (void*)ScriptCoreObject::maki_onEQAutoChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + {L"onCoreStatusMsg", 1, (void*)ScriptCoreObject::maki_onStatusMsg}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + {L"onWarningMsg", 1, (void*)ScriptCoreObject::maki_onWarningMsg}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + {L"onErrorMsg", 1, (void*)ScriptCoreObject::maki_onErrorMsg}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + {L"onTitleChange", 1, (void*)ScriptCoreObject::maki_onTitleChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title); + {L"onTitle2Change", 1, (void*)ScriptCoreObject::maki_onTitle2Change}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title2); + {L"onInfoChange", 1, (void*)ScriptCoreObject::maki_onInfoChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ info); + {L"onUrlChange", 1, (void*)ScriptCoreObject::maki_onUrlChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ url); + {L"onLengthChange", 1, (void*)ScriptCoreObject::maki_onLengthChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newlength); + {L"onNextFile", 0, (void*)ScriptCoreObject::maki_onNextFile}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onNeedNextFile", 1, (void*)ScriptCoreObject::maki_onNeedNextFile}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ fileid); + {L"onSetNextFile", 1, (void*)ScriptCoreObject::maki_onSetNextFile}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring); + {L"onErrorOccured", 2, (void*)ScriptCoreObject::maki_onErrorOccured}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ severity, scriptVar /*String*/ text); + {L"onAbortCurrentSong", 0, (void*)ScriptCoreObject::maki_onAbortCurrentSong}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onEndOfDecode", 0, (void*)ScriptCoreObject::maki_onEndOfDecode}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onFileComplete", 1, (void*)ScriptCoreObject::maki_onFileComplete}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring); + {L"onConvertersChainRebuilt", 0, (void*)ScriptCoreObject::maki_onConvertersChainRebuilt}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + {L"onMediaFamilyChange", 1, (void*)ScriptCoreObject::maki_onMediaFamilyChange}, // (SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ newfamily); + + {L"setNextFile", 1, (void*)ScriptCoreObject::maki_setNextFile}, // (scriptVar /*String*/ playstr); +// {L"getStatus", 0, (void*)ScriptCoreObject::maki_getStatus}, // (); + {L"getCurrent", 0, (void*)ScriptCoreObject::maki_getCurrent}, // (); + {L"getCurPlaybackNumber", 0, (void*)ScriptCoreObject::maki_getCurPlaybackNumber}, // (); + {L"getNumTracks", 0, (void*)ScriptCoreObject::maki_getNumTracks}, // (); + {L"getPosition", 0, (void*)ScriptCoreObject::maki_getPosition}, // (); + {L"getWritePosition", 0, (void*)ScriptCoreObject::maki_getWritePosition}, // (); + {L"setPosition", 1, (void*)ScriptCoreObject::maki_setPosition}, // (scriptVar /*int*/ ms); + {L"getLength", 0, (void*)ScriptCoreObject::maki_getLength}, // (); + {L"getVolume", 0, (void*)ScriptCoreObject::maki_getVolume}, // (); +// {L"setVolume", 1, (void*)ScriptCoreObject::maki_setVolume}, // (scriptVar /*int*/ vol); + {L"getPan", 0, (void*)ScriptCoreObject::maki_getPan}, // (); + {L"setPan", 1, (void*)ScriptCoreObject::maki_setPan}, // (scriptVar /*int*/ bal); + {L"setMute", 1, (void*)ScriptCoreObject::maki_setMute}, // (scriptVar /*int*/ mute); + {L"getMute", 0, (void*)ScriptCoreObject::maki_getMute}, // (); + {L"getLeftVuMeter", 0, (void*)ScriptCoreObject::maki_getLeftVuMeter}, // (); + {L"getRightVuMeter", 0, (void*)ScriptCoreObject::maki_getRightVuMeter}, // (); + {L"userButton", 1, (void*)ScriptCoreObject::maki_userButton}, // (scriptVar /*int*/ button); + {L"getEqStatus", 0, (void*)ScriptCoreObject::maki_getEqStatus}, // (); + {L"setEqStatus", 1, (void*)ScriptCoreObject::maki_setEqStatus}, // (scriptVar /*int*/ enable); + {L"getEqPreamp", 0, (void*)ScriptCoreObject::maki_getEqPreamp}, // (); + {L"setEqPreamp", 1, (void*)ScriptCoreObject::maki_setEqPreamp}, // (scriptVar /*int*/ pre); + {L"getEqBand", 1, (void*)ScriptCoreObject::maki_getEqBand}, // (scriptVar /*int*/ band); + {L"setEqBand", 2, (void*)ScriptCoreObject::maki_setEqBand}, // (scriptVar /*int*/ band, scriptVar /*int*/ val); + {L"getEqAuto", 0, (void*)ScriptCoreObject::maki_getEqAuto}, // (); + {L"setEqAuto", 1, (void*)ScriptCoreObject::maki_setEqAuto}, // (scriptVar /*int*/ enable); + {L"setCustomMsg", 1, (void*)ScriptCoreObject::maki_setCustomMsg}, // (scriptVar /*String*/ text); + {L"setPriority", 1, (void*)ScriptCoreObject::maki_setPriority}, // (scriptVar /*int*/ priority); + {L"getPriority", 0, (void*)ScriptCoreObject::maki_getPriority}, // (); + {L"rebuildConvertersChain", 0, (void*)ScriptCoreObject::maki_rebuildConvertersChain}, // (); + +}; + +int CoreScriptObjectController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +// Only called by us and our friend the admin. +ScriptObject *CoreScriptObjectController::instantiate(CoreToken token) { + ScriptCoreObject *gvo = new ScriptCoreObject(token); + ASSERT(gvo != NULL); + ScriptCoreObject::objects.addItem(gvo); + return gvo->getScriptObject(); +} + +ScriptObject *CoreScriptObjectController::instantiate() { + // magic value to make a new one. + return instantiate(0x80000000); +} + +void CoreScriptObjectController::destroy(ScriptObject *o) { + ScriptCoreObject *gvo = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + ASSERT(gvo != NULL); + ScriptCoreObject::objects.removeItem(gvo); + delete gvo; +} + +void *CoreScriptObjectController::encapsulate(ScriptObject *o) { + return NULL; +} + +void CoreScriptObjectController::deencapsulate(void *o) { +} + +// ----------------------------------------------------------------------------------------------------- + +ScriptCoreObject::ScriptCoreObject(CoreToken token) { + getScriptObject()->vcpu_setClassName(L"Core"); + getScriptObject()->vcpu_setController(coreController); + getScriptObject()->vcpu_setInterface(CORE_SCRIPTOBJECT_GUID, static_cast<ScriptCoreObject *>(this)); +#ifndef FAKE_SCRIPTCORE + curvol = -1; + if (token == 0x80000000) { + // If we create it new for the script, bind a sequencer and set the volume + core_handle = api->core_create(); + initAsCreated(); + } else { + // If the ScriptCoreAdminObject caused this object to be created, + // it will worry about calling initAsCreated() -- otherwise we don't + // bind ourselves as a sequencer to the core. + core_handle = token; + registered_sequencer = 0; + } + + waServiceFactory *s = api->service_enumService(WaSvc::COREADMIN,0); + ASSERTPR(s,"Core Admin must be present to use ScriptCore!"); + svc = castService<svc_coreAdmin>(s); + if (svc) { + svc->addCallback(core_handle, this); + } +#endif +} + +ScriptCoreObject::~ScriptCoreObject() { +#ifndef FAKE_SCRIPTCORE + if (registered_sequencer) { + // don't remove a sequencer if we didn't add one + api->core_deregisterSequencer(core_handle, this); + } + api->core_delCallback(0, this); +#endif +} + +#ifndef FAKE_SCRIPTCORE +void ScriptCoreObject::initAsCreated() { + api->core_registerSequencer(core_handle, this); +#if TRICK_VOLUME + api->core_setVolume(core_handle, api->core_getVolume(0)); + setVolume(255); +#endif + registered_sequencer = 1; +} +#endif + +/*int ScriptCoreObject::corecb_onStopped() { + maki_onStop(SCRIPT_CALL, getScriptObject()); + return 0; +} + +int ScriptCoreObject::corecb_onEndOfDecode() { + maki_onStop(SCRIPT_CALL, getScriptObject()); + return 0; +}*/ + +int ScriptCoreObject::getStatus() { +#ifndef FAKE_SCRIPTCORE + return api->core_getStatus(core_handle); +#else + return 0; +#endif +} + +void ScriptCoreObject::playFile(const wchar_t *file) { +#ifndef FAKE_SCRIPTCORE + if (registered_sequencer) { + filetoplay = file; + } else { + String playstring = "FILE:"; + playstring += file; + api->core_setNextFile(core_handle, playstring); + } + api->core_userButton(core_handle, UserButton::PLAY); +#endif +} + +#ifndef FAKE_SCRIPTCORE +const char *ScriptCoreObject::enumItem(int pos) { + return filetoplay; +} +#endif + +void ScriptCoreObject::stop() { +#ifndef FAKE_SCRIPTCORE + filetoplay = ""; + api->core_userButton(core_handle, UserButton::STOP); +#endif +} + +void ScriptCoreObject::setVolume(int v) { +#ifndef FAKE_SCRIPTCORE +#if TRICK_VOLUME + // if we're not the main core.... + if (core_handle) { + // set this core's volume as a percentage of the main core volume. + if (v == -1) v = curvol; + curvol = v; + int mainvolume = api->core_getVolume(0); + v = (int)( ((float)mainvolume * (float)v) / 256.0 ); + if ((unsigned)v == api->core_getVolume(core_handle)) return; + api->core_setVolume(core_handle, MIN(MAX(0, v), 255)); + } else { + // if we are the main core, don't cause recursion. + if ((v > 0) && (v != curvol)) { + curvol = v; + api->core_setVolume(core_handle, v); + } + } +#else + api->core_setVolume(core_handle, v); +#endif +#endif +} + +/* + Moved to be with all his friends. + +int ScriptCoreObject::corecb_onVolumeChange(int newvol) { + foreach(objects) + objects.getfor()->setVolume(-1); + endfor; + return 0; +} +*/ + +/*scriptVar ScriptCoreObject::maki_onStop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +}*/ + +scriptVar ScriptCoreObject::maki_playFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar f) { + SCRIPT_FUNCTION_INIT + ScriptCoreObject *gvo = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (gvo) + gvo->playFile(GET_SCRIPT_STRING(f)); + RETURN_SCRIPT_VOID; +} + +scriptVar ScriptCoreObject::maki_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + ScriptCoreObject *gvo = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (gvo) + gvo->stop(); + RETURN_SCRIPT_VOID; +} + +/* +scriptVar ScriptCoreObject::maki_setVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT + ScriptCoreObject *gvo = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (gvo) gvo->setVolume(GET_SCRIPT_INT(v)); + RETURN_SCRIPT_VOID; +} + +scriptVar ScriptCoreObject::maki_getStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + ScriptCoreObject *gvo = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (gvo) return MAKE_SCRIPT_INT(gvo->getStatus()); + RETURN_SCRIPT_ZERO; +} +*/ + +PtrList<ScriptCoreObject> ScriptCoreObject::objects; + + +int ScriptCoreObject::corecb_onStarted() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onStarted(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onStopped() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onStopped(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onPaused() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onPaused(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onUnpaused() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onUnpaused(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onSeeked(int newpos) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onSeeked(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newpos)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onVolumeChange(int newvol) { +#ifndef FAKE_SCRIPTCORE +#if TRICK_VOLUME + foreach(objects) + objects.getfor()->setVolume(-1); + endfor; +#endif + scriptVar svInt = maki_onVolumeChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newvol)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onPanChange(int newpan) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onPanChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newpan)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEQStatusChange(int newval) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEQStatusChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newval)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEQPreampChange(int newval) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEQPreampChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newval)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEQBandChange(int band, int newval) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEQBandChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(band), MAKE_SCRIPT_INT(newval)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEQFreqChange(int newval) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEQFreqChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newval)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEQAutoChange(int newval) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEQAutoChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newval)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onStatusMsg(const wchar_t *text) +{ +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onStatusMsg(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(text)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onWarningMsg(const wchar_t *text) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onWarningMsg(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(text)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onErrorMsg(const wchar_t *text) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onErrorMsg(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(text)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onTitleChange(const wchar_t *title) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onTitleChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(title)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onTitle2Change(const wchar_t *title2) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onTitle2Change(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(title2)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onInfoChange(const wchar_t *info) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onInfoChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(info)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onUrlChange(const wchar_t *url) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onUrlChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(url)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onLengthChange(int newlength) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onLengthChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(newlength)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onNextFile() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onNextFile(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onNeedNextFile(int fileid) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onNeedNextFile(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(fileid)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onSetNextFile(const wchar_t *playstring) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onSetNextFile(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(playstring)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onErrorOccured(int severity, const wchar_t *text) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onErrorOccured(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT(severity), MAKE_SCRIPT_STRING(text)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onAbortCurrentSong() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onAbortCurrentSong(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onEndOfDecode() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onEndOfDecode(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onFileComplete(const wchar_t *playstring) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onFileComplete(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(playstring)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onConvertersChainRebuilt() { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onConvertersChainRebuilt(SCRIPT_CALL, getScriptObject()); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + +int ScriptCoreObject::corecb_onMediaFamilyChange(const wchar_t *newfamily) { +#ifndef FAKE_SCRIPTCORE + scriptVar svInt = maki_onMediaFamilyChange(SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING(newfamily)); + if ((svInt.type != SCRIPT_VOID) && (svInt.type != SCRIPT_OBJECT) && (svInt.type != SCRIPT_STRING)) { + return GET_SCRIPT_INT(svInt); + } +#endif + return 0; +} + + +scriptVar /*int*/ ScriptCoreObject::maki_onStarted(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onStopped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onPaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onUnpaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onSeeked(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpos) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newpos); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newpos); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onVolumeChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newvol) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newvol); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newvol); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onPanChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpan) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newpan); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newpan); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onEQStatusChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newval); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newval); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onEQPreampChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newval); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newval); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onEQBandChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band, scriptVar /*int*/ newval) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS2(o, coreController, band, newval); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, band, newval); +} + + +scriptVar /*int*/ ScriptCoreObject::maki_onEQFreqChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval) +{ + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newval); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newval); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onEQAutoChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newval); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newval); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onStatusMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, text); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, text); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onWarningMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, text); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, text); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onErrorMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, text); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, text); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onTitleChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, title); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, title); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onTitle2Change(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title2) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, title2); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, title2); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onInfoChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ info) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, info); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, info); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onUrlChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ url) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, url); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, url); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onLengthChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newlength) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newlength); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newlength); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onNeedNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ fileid) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, fileid); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, fileid); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onSetNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, playstring); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, playstring); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onErrorOccured(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ severity, scriptVar /*String*/ text) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS2(o, coreController, severity, text); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, severity, text); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onAbortCurrentSong(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onEndOfDecode(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onFileComplete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, playstring); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, playstring); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onConvertersChainRebuilt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS0(o, coreController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar /*int*/ ScriptCoreObject::maki_onMediaFamilyChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ newfamily) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS1(o, coreController, newfamily); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newfamily); +} + + +scriptVar /*int*/ ScriptCoreObject::maki_setNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstr) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->setNextFile(sco->core_handle, GET_SCRIPT_STRING(playstr))); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getStatus(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*String*/ ScriptCoreObject::maki_getCurrent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_STRING(sco->svc->getCurrent(sco->core_handle)); + } +#endif + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar /*int*/ ScriptCoreObject::maki_getCurPlaybackNumber(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getCurPlaybackNumber(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getNumTracks(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getNumTracks(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getPosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getPosition(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getWritePosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getWritePosition(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_setPosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ ms) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->setPosition(sco->core_handle, GET_SCRIPT_INT(ms))); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getLength(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getVolume(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ vol) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setVolume(sco->core_handle, GET_SCRIPT_INT(vol)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getPan(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getPan(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setPan(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ bal) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setPan(sco->core_handle, GET_SCRIPT_INT(bal)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setMute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ mute) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setMute(sco->core_handle, GET_SCRIPT_INT(mute)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getMute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getMute(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getLeftVuMeter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getLeftVuMeter(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getRightVuMeter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getRightVuMeter(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_userButton(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ button) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->userButton(sco->core_handle, GET_SCRIPT_INT(button)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getEqStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getEqStatus(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setEqStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ enable) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setEqStatus(sco->core_handle, GET_SCRIPT_INT(enable)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getEqPreamp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getEqPreamp(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setEqPreamp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ pre) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setEqPreamp(sco->core_handle, GET_SCRIPT_INT(pre)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getEqBand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getEqBand(sco->core_handle, GET_SCRIPT_INT(band))); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setEqBand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band, scriptVar /*int*/ val) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setEqBand(sco->core_handle, GET_SCRIPT_INT(band), GET_SCRIPT_INT(val)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getEqAuto(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getEqAuto(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setEqAuto(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ enable) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setEqAuto(sco->core_handle, GET_SCRIPT_INT(enable)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setCustomMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setCustomMsg(sco->core_handle, GET_SCRIPT_STRING(text)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*void*/ ScriptCoreObject::maki_setPriority(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ priority) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->setPriority(sco->core_handle, GET_SCRIPT_INT(priority)); + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar /*int*/ ScriptCoreObject::maki_getPriority(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + return MAKE_SCRIPT_INT(sco->svc->getPriority(sco->core_handle)); + } +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar /*void*/ ScriptCoreObject::maki_rebuildConvertersChain(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT +#ifndef FAKE_SCRIPTCORE + ScriptCoreObject *sco = static_cast<ScriptCoreObject *>(o->vcpu_getInterface(CORE_SCRIPTOBJECT_GUID)); + if (sco) { + ASSERT(sco->svc != NULL); + sco->svc->rebuildConvertersChain(sco->core_handle); + } +#endif + RETURN_SCRIPT_VOID; +} + diff --git a/Src/Wasabi/api/script/objects/core/coreobj.h b/Src/Wasabi/api/script/objects/core/coreobj.h new file mode 100644 index 00000000..75b77346 --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/coreobj.h @@ -0,0 +1,192 @@ +#ifndef __CONOBJ_H +#define __CONOBJ_H + +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> +#include <api/core/sequence.h> +#include <api/syscb/callbacks/corecbi.h> +#include <api/core/corehandle.h> +#ifdef GEN_FF +#ifndef FAKE_SCRIPTCORE +#define FAKE_SCRIPTCORE +#endif +#endif + +// {2825A91B-D488-4245-AAF1-7059CF88437B} +static const GUID CORE_SCRIPTOBJECT_GUID = +{ 0x2825a91b, 0xd488, 0x4245, { 0xaa, 0xf1, 0x70, 0x59, 0xcf, 0x88, 0x43, 0x7b } }; + +extern ScriptObjectController *coreController; +class PlayItem; +class CoreAdminScriptObjectController; +class svc_coreAdmin; + +// ----------------------------------------------------------------------------------------------------- +class ScriptCoreObject : public RootObjectInstance +#ifndef FAKE_SCRIPTCORE +, public ListSequencer, public CoreCallbackI/*, public CoreCallbackI*/ +#endif +{ + friend class CoreAdminScriptObjectController; + public: + + ScriptCoreObject(CoreToken token = 0x80000000); + virtual ~ScriptCoreObject(); + + void playFile(const wchar_t *file); + void stop(); + void setVolume(int v); + int getStatus(); + +/* virtual int corecb_onStopped(); + virtual int corecb_onEndOfDecode();*/ + + static scriptVar maki_playFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar file); + static scriptVar maki_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +// static scriptVar maki_onStop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +// static scriptVar maki_setVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); +// static scriptVar maki_getStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + // Callback Methods in Maki. + static scriptVar /*int*/ maki_onStarted(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onStopped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onPaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onUnpaused(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onSeeked(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpos); + static scriptVar /*int*/ maki_onVolumeChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newvol); + static scriptVar /*int*/ maki_onPanChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newpan); + static scriptVar /*int*/ maki_onEQStatusChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + static scriptVar /*int*/ maki_onEQPreampChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + static scriptVar /*int*/ maki_onEQBandChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band, scriptVar /*int*/ newval); + static scriptVar /*int*/ maki_onEQFreqChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + static scriptVar /*int*/ maki_onEQAutoChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newval); + static scriptVar /*int*/ maki_onStatusMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + static scriptVar /*int*/ maki_onWarningMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + static scriptVar /*int*/ maki_onErrorMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + static scriptVar /*int*/ maki_onTitleChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title); + static scriptVar /*int*/ maki_onTitle2Change(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ title2); + static scriptVar /*int*/ maki_onInfoChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ info); + static scriptVar /*int*/ maki_onUrlChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ url); + static scriptVar /*int*/ maki_onLengthChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ newlength); + static scriptVar /*int*/ maki_onNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onNeedNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ fileid); + static scriptVar /*int*/ maki_onSetNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring); + static scriptVar /*int*/ maki_onErrorOccured(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ severity, scriptVar /*String*/ text); + static scriptVar /*int*/ maki_onAbortCurrentSong(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onEndOfDecode(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onFileComplete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstring); + static scriptVar /*int*/ maki_onConvertersChainRebuilt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_onMediaFamilyChange(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ newfamily); + + static scriptVar /*int*/ maki_setNextFile(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ playstr); + static scriptVar /*int*/ maki_getStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*String*/ maki_getCurrent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getCurPlaybackNumber(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getNumTracks(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getPosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getWritePosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_setPosition(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ ms); + static scriptVar /*int*/ maki_getLength(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_setVolume(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ vol); + static scriptVar /*int*/ maki_getPan(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_setPan(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ bal); + static scriptVar /*void*/ maki_setMute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ mute); + static scriptVar /*int*/ maki_getMute(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getLeftVuMeter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*int*/ maki_getRightVuMeter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_userButton(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ button); + static scriptVar /*int*/ maki_getEqStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_setEqStatus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ enable); + static scriptVar /*int*/ maki_getEqPreamp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_setEqPreamp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ pre); + static scriptVar /*int*/ maki_getEqBand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band); + static scriptVar /*void*/ maki_setEqBand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ band, scriptVar /*int*/ val); + static scriptVar /*int*/ maki_getEqAuto(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_setEqAuto(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ enable); + static scriptVar /*void*/ maki_setCustomMsg(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*String*/ text); + static scriptVar /*void*/ maki_setPriority(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar /*int*/ priority); + static scriptVar /*int*/ maki_getPriority(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar /*void*/ maki_rebuildConvertersChain(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + static PtrList<ScriptCoreObject> objects; + + protected: +#ifndef FAKE_SCRIPTCORE + virtual int getNumEntries() { return 1; } + virtual const char *enumItem(int pos); + virtual int getCurrent() { return 0; } + virtual int setCurrent(int cur) { return 0; } +#endif + + // Callback Methods forwarded to Maki. + virtual int corecb_onStarted(); + virtual int corecb_onStopped(); + virtual int corecb_onPaused(); + virtual int corecb_onUnpaused(); + virtual int corecb_onSeeked(int newpos); + virtual int corecb_onVolumeChange(int newvol); + virtual int corecb_onPanChange(int newpan); + virtual int corecb_onEQStatusChange(int newval); + virtual int corecb_onEQPreampChange(int newval); + virtual int corecb_onEQBandChange(int band, int newval); + virtual int corecb_onEQFreqChange(int newval); + virtual int corecb_onEQAutoChange(int newval); + virtual int corecb_onStatusMsg(const wchar_t *text); + virtual int corecb_onWarningMsg(const wchar_t *text); + virtual int corecb_onErrorMsg(const wchar_t *text); + virtual int corecb_onTitleChange(const wchar_t *title); + virtual int corecb_onTitle2Change(const wchar_t *title2); + virtual int corecb_onInfoChange(const wchar_t *info); + virtual int corecb_onUrlChange(const wchar_t *url); + virtual int corecb_onLengthChange(int newlength); + virtual int corecb_onNextFile(); + virtual int corecb_onNeedNextFile(int fileid); + virtual int corecb_onSetNextFile(const wchar_t *playstring); + virtual int corecb_onErrorOccured(int severity, const wchar_t *text); + virtual int corecb_onAbortCurrentSong(); + virtual int corecb_onEndOfDecode(); + virtual int corecb_onFileComplete(const wchar_t *playstring); + virtual int corecb_onConvertersChainRebuilt(); + virtual int corecb_onMediaFamilyChange(const wchar_t *newfamily); + + private: + // Only called by us and our friend the admin. +#ifndef FAKE_SCRIPTCORE + virtual void initAsCreated(); + + svc_coreAdmin *svc; + CoreToken core_handle; + String filetoplay; + int curvol; + int registered_sequencer; +#endif +}; + +// ----------------------------------------------------------------------------------------------------- +class CoreScriptObjectController : public ScriptObjectControllerI { + friend CoreAdminScriptObjectController; + public: + virtual const wchar_t *getClassName() { return L"Core"; } + virtual const wchar_t *getAncestorClassName() { return L"Object"; } + virtual ScriptObjectController *getAncestorController() { return WASABI_API_MAKI->maki_getController(rootObjectGuid); } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions() { return exportedFunction; } + virtual GUID getClassGuid() { return CORE_SCRIPTOBJECT_GUID; } + virtual int getInstantiable() { return 1; } + virtual int getReferenceable() { return 1; } + virtual ScriptObject *instantiate(); + virtual void *encapsulate(ScriptObject *o); + virtual void destroy(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + static function_descriptor_struct exportedFunction[]; + + // Only called by us and our friend the admin. + virtual ScriptObject *instantiate(CoreToken token = 0x80000000); +}; + +// ----------------------------------------------------------------------- + +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/core/svc_scriptcore.cpp b/Src/Wasabi/api/script/objects/core/svc_scriptcore.cpp new file mode 100644 index 00000000..a4c3ed1c --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/svc_scriptcore.cpp @@ -0,0 +1,38 @@ +#include <precomp.h> +#include "svc_scriptcore.h" +#include <api/script/objects/core/coreobj.h> +#include <api/script/objects/core/coreadminobj.h> + +#ifndef _WASABIRUNTIME + +BEGIN_SERVICES(ScriptCore_Svc); +DECLARE_SERVICETSINGLE(svc_scriptObject, CoreScriptObjectSvc); +END_SERVICES(ScriptCore_Svc, _ScriptCore_Svc); + +#ifdef _X86_ +extern "C" { int _link_ScriptCore_Svc; } +#else +extern "C" { int __link_ScriptCore_Svc; } +#endif + +#endif + +// ----------------------------------------------------------------------------------------------------- +// Service + +ScriptObjectController *CoreScriptObjectSvc::getController(int n) { + switch (n) { + case 0: + return coreController; + } + return NULL; +} + +ScriptObjectController *CoreAdminScriptObjectSvc::getController(int n) { + switch (n) { + case 0: + return coreAdminController; + } + return NULL; +} + diff --git a/Src/Wasabi/api/script/objects/core/svc_scriptcore.h b/Src/Wasabi/api/script/objects/core/svc_scriptcore.h new file mode 100644 index 00000000..c6530aa5 --- /dev/null +++ b/Src/Wasabi/api/script/objects/core/svc_scriptcore.h @@ -0,0 +1,27 @@ +#ifndef __GUIVIDEOSVC_H +#define __GUIVIDEOSVC_H + +#include <api/service/svcs/svc_scriptobji.h> + +class CoreScriptObjectSvc : public svc_scriptObjectI { + +public: + CoreScriptObjectSvc() {}; + virtual ~CoreScriptObjectSvc() {}; + + static const char *getServiceName() { return "MediaCore maki object"; } + virtual ScriptObjectController *getController(int n); +}; + +class CoreAdminScriptObjectSvc : public svc_scriptObjectI { + +public: + CoreAdminScriptObjectSvc() {}; + virtual ~CoreAdminScriptObjectSvc() {}; + + static const char *getServiceName() { return "MediaCoreAdmin maki object"; } + virtual ScriptObjectController *getController(int n); +}; + +#endif + diff --git a/Src/Wasabi/api/script/objects/guiobj.cpp b/Src/Wasabi/api/script/objects/guiobj.cpp new file mode 100644 index 00000000..dd7b5903 --- /dev/null +++ b/Src/Wasabi/api/script/objects/guiobj.cpp @@ -0,0 +1,2880 @@ +#include <precomp.h> +#include <bfc/wasabi_std.h> +#include <api/wnd/notifmsg.h> +#include <api/script/scriptmgr.h> +#include <api/script/script.h> +#include <api/script/objects/guiobj.h> +#include <api/script/vcpu.h> +#include <api/skin/widgets/group.h> +//#include <api/wac/main.h> +#include <math.h> +#include <api/skin/skinparse.h> +#include <api/wndmgr/layout.h> +#include <api/script/objecttable.h> +#include <api/wnd/cwndtrack.h> +#include <api/wnd/popup.h> +#include <bfc/parse/paramparser.h> +#include <api/wnd/cursor.h> +#include <api/wnd/wndtrack.h> +#include <bfc/string/stringdict.h> +#include <api/config/items/cfgitem.h> +#include <api/config/items/attrbool.h> +#ifndef PI +#define PI 3.1415926536F +#endif + +#include <api/script/objects/guiobject.h> + +const wchar_t guiobjectXuiStr[] = L"GuiObject"; // This is the xml tag +char guiobjectXuiSvcName[] = "GuiObject xui object"; // this is the name of the xuiservice + +#ifdef USEAPPBAR +extern _bool cfg_options_appbarondrag; +#endif + +static wchar_t txt[4096]; + +GuiObjectI::GuiObjectI(ScriptObject *o) { + translate = 1; + my_script_object = o; + my_root_wnd = NULL; + + redock.l = NULL; + MEMSET(&redock.original_rect, 0, sizeof(RECT)); + targetstatus = TARGET_FROZEN; + targetspeed = 4; + start_time = 0; + reversetarget = 0; + dodragcheck = 0; + gui_rx = 0; + gui_ry = 0; + gui_rw = 0; + gui_rh = 0; + gui_x = 0; + gui_y = 0; + gui_w = AUTOWH; + gui_h = AUTOWH; + p_group = NULL; + targetx = AUTOWH; + targety = AUTOWH; + targetw = AUTOWH; + targeth = AUTOWH; + targeta = AUTOWH; + in_area = 0; + clickthrough = 0; + autosysmetricsx = 0; + autosysmetricsy = 0; + autosysmetricsw = 0; + autosysmetricsh = 0; + xuisvc = NULL; + xuifac = NULL; + mover = 0; + moving = 0; + droptarget = 0; +#ifdef WASABI_COMPILE_CONFIG + cfgitem = NULL; +#endif + timer.setGuiObjectI(this); + wantfocus = 0; + anchorage = ANCHOR_NONE; + anchor_x1 = anchor_x2 = anchor_y1 = anchor_y2 = 0; + anchorage_invalidated = 0; + anchorage = ANCHOR_LEFT|ANCHOR_TOP; + cursor = NULL; +#ifdef USEAPPBAR + m_dock_side = APPBAR_NOTDOCKED; +#endif + m_lastnondocked_x = -0xFFFF; + m_lastnondocked_y = -0xFFFF; +} + +GuiObjectI::~GuiObjectI() { + notifylist.deleteAll(); + delete cursor; + if (guiobject_getParentGroup()) + guiobject_getParentGroup()->removeObject(this); + if (targetstatus == TARGET_RUNNING) + stopTargetTimer(); +#ifdef WASABI_COMPILE_CONFIG + if (cfgitem) viewer_delViewItem(cfgitem); +#endif +} + +ScriptObject *GuiObjectI::guiobject_getScriptObject() +{ + return my_script_object; +} + +// Used by us when parsing xml to assign the object's ID, shouldn't be used elsewhere +void GuiObjectI::guiobject_setId(const wchar_t *id) +{ + guiobject_id = id; +} + +const wchar_t *GuiObjectI::guiobject_getId() +{ + if (guiobject_id.isempty()) return L""; + return guiobject_id; //FG> avoid returning NULL +} + +int GuiObjectI::guiobject_setXmlParam(const wchar_t *paramname, const wchar_t *strvalue) +{ + int r = 0; + //ifc_window *w = guiobject_getRootWnd(); + XmlObject *xo = static_cast<XmlObject *>(guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid)); + if (xo != NULL) { + r = xo->setXmlParam(paramname, strvalue); + } + return r; +} + +const wchar_t *GuiObjectI::guiobject_getXmlParam(const wchar_t *paramname) { + const wchar_t *rt = NULL; + //ifc_window *w = guiobject_getRootWnd(); + XmlObject *xo = static_cast<XmlObject *>(guiobject_getScriptObject()->vcpu_getInterface(xmlObjectGuid)); + if (xo != NULL) { + int r = xo->getXmlParam(paramname); + rt = xo->getXmlParamValue(r); + } + return rt; +} + +int GuiObjectI::guiobject_setXmlParamById(int id, const wchar_t *strvalue) +{ + int a; + switch (id) { + case GuiObjectWnd::GUIOBJECT_ID: + guiobject_setId(strvalue); + break; + case GuiObjectWnd::GUIOBJECT_ALPHA: + if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something + guiobject_setAlpha(255); + else + guiobject_setAlpha(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_ACTIVEALPHA: + if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something + guiobject_setActiveAlpha(255); + else + guiobject_setActiveAlpha(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_INACTIVEALPHA: + if (wcschr(strvalue, ',')) // erroneous value, this is probably a color, or something + guiobject_setInactiveAlpha(255); + else + guiobject_setInactiveAlpha(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SYSREGION: + guiobject_setRegionOp(WASABI_API_SKIN->parse(strvalue, L"regionop")); + break; + case GuiObjectWnd::GUIOBJECT_RECTRGN: + guiobject_setRectRgn(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_TOOLTIP: + guiobject_getRootWnd()->setTip(strvalue); + break; + case GuiObjectWnd::GUIOBJECT_SYSMETRICSX: + guiobject_setAutoSysMetricsX(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SYSMETRICSY: + guiobject_setAutoSysMetricsY(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SYSMETRICSW: + guiobject_setAutoSysMetricsW(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SYSMETRICSH: + guiobject_setAutoSysMetricsH(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_MOVE: + guiobject_setMover(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_RENDERBASETEXTURE: + guiobject_getRootWnd()->setRenderBaseTexture(WTOI(strvalue)); + break; +#ifdef WASABI_COMPILE_CONFIG + case GuiObjectWnd::GUIOBJECT_CFGATTR: + setCfgAttr(strvalue); + break; +#endif + case GuiObjectWnd::GUIOBJECT_TABORDER: + guiobject_setTabOrder(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_X: { + a = WTOI(strvalue); + guiobject_setGuiPosition(&a, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_Y: { + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, &a, NULL, NULL, NULL, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_W: { + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, &a, NULL, NULL, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_H: { + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, NULL, &a, NULL, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_FITTOPARENT: { + int v = WTOI(strvalue); + if (v) { + int one = 1; + int x = 0, y = 0, w = 0, h = 0; + if (v < 0) { + v = -v; + x += v; + y += v; + w -= v * 2; + h -= v * 2; + } + guiobject_setGuiPosition(&x, &y, &w, &h, NULL, NULL, &one, &one); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + } + break; } + case GuiObjectWnd::GUIOBJECT_WANTFOCUS: + wantfocus = WTOI(strvalue); + if (guiobject_getRootWnd()->isPostOnInit()) { + if (wantfocus) { + if (guiobject_getRootWnd()->getTabOrder() == -1) + guiobject_getRootWnd()->setAutoTabOrder(); + } else { + if (guiobject_getRootWnd()->getTabOrder() != -1) + guiobject_getRootWnd()->setTabOrder(-1); + } + } + break; + case GuiObjectWnd::GUIOBJECT_VISIBLE: { + a = WTOI(strvalue); + ifc_window *w = guiobject_getRootWnd(); + if (w->isPostOnInit()) + w->setVisible(a); + else + w->setStartHidden(!a); + break; } + case GuiObjectWnd::GUIOBJECT_RELATX: { + if (strvalue && *strvalue == '%') + a = 2; + else + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, NULL, NULL, &a, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_RELATY: { + if (strvalue && *strvalue == '%') + a = 2; + else + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, &a, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_RELATW: { + if (strvalue && *strvalue == '%') + a = 2; + else + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, &a, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_RELATH: { + if (strvalue && *strvalue == '%') + a = 2; + else + a = WTOI(strvalue); + guiobject_setGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, NULL, &a); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; } + case GuiObjectWnd::GUIOBJECT_DROPTARGET: + guiobject_setDropTarget(strvalue); + break; + case GuiObjectWnd::GUIOBJECT_GHOST: + guiobject_setClickThrough(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETNODBLCLICK: + guiobject_setNoDoubleClick(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETNOLEFTCLICK: + guiobject_setNoLeftClick(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETNORIGHTCLICK: + guiobject_setNoRightClick(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETNOMOUSEMOVE: + guiobject_setNoMouseMove(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETNOCONTEXTMENU: + guiobject_setNoContextMenu(WTOI(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_SETX1: { + a = WTOI(strvalue); + guiobject_setAnchoragePosition(&a, NULL, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; + } + case GuiObjectWnd::GUIOBJECT_SETY1:{ + a = WTOI(strvalue); + guiobject_setAnchoragePosition(NULL, &a, NULL, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; + } + case GuiObjectWnd::GUIOBJECT_SETX2:{ + a = WTOI(strvalue); + guiobject_setAnchoragePosition(NULL, NULL, &a, NULL, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; + } + case GuiObjectWnd::GUIOBJECT_SETY2:{ + a = WTOI(strvalue); + guiobject_setAnchoragePosition(NULL, NULL, NULL, &a, NULL); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + break; + } + case GuiObjectWnd::GUIOBJECT_SETANCHOR: { + int anchorage=ANCHOR_NONE; + ParamParser pp(strvalue, L"|"); + for (int m=0;m<pp.getNumItems();m++) + { + const wchar_t *s = pp.enumItem(m); + if (!WCSICMP(s, L"left")) anchorage |= ANCHOR_LEFT; + else if (!WCSICMP(s, L"top")) anchorage |= ANCHOR_TOP; + else if (!WCSICMP(s, L"right")) anchorage |= ANCHOR_RIGHT; + else if (!WCSICMP(s, L"bottom")) anchorage |= ANCHOR_BOTTOM; + } + guiobject_setAnchoragePosition(NULL, NULL, NULL, NULL, &anchorage); + Group *g = guiobject_getParentGroup(); + if (g != NULL && guiobject_getRootWnd()->isPostOnInit()) + g->updatePos(this); + } + break; + case GuiObjectWnd::GUIOBJECT_SETCURSOR: + guiobject_setCursor(strvalue); + break; + case GuiObjectWnd::GUIOBJECT_NOTIFY: + notifylist.addItem(new StringW(strvalue)); + break; + case GuiObjectWnd::GUIOBJECT_USERDATA: + // nothing to do, param goes in xmlobject + break; +#ifdef USEAPPBAR + case GuiObjectWnd::GUIOBJECT_APPBAR: + setAppBar(strvalue); + break; +#endif + case GuiObjectWnd::GUIOBJECT_TRANSLATE: + translate = WTOI(strvalue); + break; + default: + return 0; + } + return 1; +} + +void GuiObjectI::guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) { + if (x) *x = gui_x; + if (y) *y = gui_y; + if (w) *w = gui_w; + if (h) *h = gui_h; + if (rx) *rx = gui_rx; + if (ry) *ry = gui_ry; + if (rw) *rw = gui_rw; + if (rh) *rh = gui_rh; +} + +void GuiObjectI::guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) { + if (x && *x != NOCHANGE && *x != AUTOWH) gui_x = *x; + if (y && *y != NOCHANGE && *y != AUTOWH) gui_y = *y; + if (w && *w != NOCHANGE && *w != AUTOWH) gui_w = *w; + if (h && *h != NOCHANGE && *h != AUTOWH) gui_h = *h; + if (rx && *rx != NOCHANGE && *rx != AUTOWH) gui_rx = *rx; + if (ry && *ry != NOCHANGE && *ry != AUTOWH) gui_ry = *ry; + if (rw && *rw != NOCHANGE && *rw != AUTOWH) gui_rw = *rw; + if (rh && *rh != NOCHANGE && *rh != AUTOWH) gui_rh = *rh; + if (guiobject_getRootWnd()->isInited() && guiobject_getParentGroup()) + guiobject_getParentGroup()->updatePos(this); + else { + if (!guiobject_getRootWnd()->isVirtual()) + guiobject_getRootWnd()->resize(gui_x, gui_y, gui_w, gui_h); + } +} + +int GuiObjectI::guiobject_getAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) { + if (x1) *x1 = anchor_x1; + if (y1) *y1 = anchor_y1; + if (x2) *x2 = anchor_x2; + if (y2) *y2 = anchor_y2; + if (anchor) *anchor = anchorage; + return anchorage_invalidated; +} + +void GuiObjectI::guiobject_setAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) { + anchorage_invalidated = 1; + if (x1) anchor_x1 = *x1; + if (x2) anchor_x2 = *x2; + if (y1) anchor_y1 = *y1; + if (y2) anchor_y2 = *y2; + if (anchor) anchorage = *anchor; + if (guiobject_getRootWnd()->isInited() && guiobject_getParentGroup()) { + guiobject_getParentGroup()->updatePos(this); + } +} + +void GuiObjectI::guiobject_validateAnchorage() { + anchorage_invalidated = 0; +} + +void GuiObjectI::guiobject_setClickThrough(int c) { + guiobject_getRootWnd()->setClickThrough(c); +} + +void GuiObjectI::guiobject_setRegionOp(int op) { + guiobject_getRootWnd()->setRegionOp(op); +} + +int GuiObjectI::guiobject_getRegionOp() { + return guiobject_getRootWnd()->getRegionOp(); +} + +void GuiObjectI::guiobject_setRectRgn(int rrgn) { + guiobject_getRootWnd()->setRectRgn(rrgn); +} + +void GuiObjectI::guiobject_setMover(int n) { + mover = n; +} + +int GuiObjectI::guiobject_getMover() { + return mover; +} + +FOURCC GuiObjectI::guiobject_getDropTarget() { + return droptarget; +} + +void GuiObjectI::guiobject_setDropTarget(const wchar_t *strval) +{ + if (strval == NULL) + droptarget = 0; + else + { + uint8_t *temp = (uint8_t *)&droptarget; + temp[3]=(uint8_t)strval[0]; + temp[2]=(uint8_t)strval[1]; + temp[1]=(uint8_t)strval[2]; + temp[0]=(uint8_t)strval[3]; + } +} + +int GuiObjectI::guiobject_isRectRgn() { + return guiobject_getRootWnd()->isRectRgn(); +} + +int GuiObjectI::guiobject_isClickThrough() { + return guiobject_getRootWnd()->isClickThrough(); +} + +void GuiObjectI::guiobject_setParentGroup(Group *l) { + if (!l) { p_group = NULL; return; } + p_group = l; +} + +Group *GuiObjectI::guiobject_getParentGroup() { + if (!p_group) return NULL; + return p_group; +} + +GuiObject *GuiObjectI::guiobject_getParent() { + ifc_window *grw = guiobject_getRootWnd(); + if (!grw) return NULL; + ifc_window *w = grw->getParent(); + if (!w) return NULL; + return static_cast<GuiObject *>(w->getInterface(guiObjectGuid)); +} + +#ifdef WASABI_COMPILE_WNDMGR +Layout *GuiObjectI::guiobject_getParentLayout() { + Group *m = p_group; + Layout *l = NULL; + while (m) { + if (m->isLayout()) { + l = static_cast<Layout *>(m); + break; + } + m = m->getGuiObject()->guiobject_getParentGroup(); + } + if (!l) { + ifc_window *w = guiobject_getRootWnd()->getDesktopParent(); + if (w) + l = static_cast<Layout *>(w->getInterface(layoutGuid)); + } + if (l && l->isDeleting()) return NULL; + return l; +} +#endif + +GuiObject *GuiObjectI::guiobject_getTopParent() { + ifc_window *m = guiobject_getRootWnd(); + GuiObject *top = this; + + while (m != NULL) { + m = m->getParent(); + if (m != NULL) { + GuiObject *g = m->getGuiObject(); + if (g != NULL) + top = g; + } + } + + return top; +} + +/*void GuiObjectI::parseNotify(const char *s) { + scriptNotify(s, "", 0, 0); +}*/ + +void GuiObjectI::guiobject_bringToFront() { + ifc_window *b = guiobject_getRootWnd(); + if (b) { + if (b->getParent()) + b->getParent()->bringVirtualToFront(b); + } +} + +void GuiObjectI::guiobject_bringToBack() { + ifc_window *b = guiobject_getRootWnd(); + if (b) { + if (b->getParent()) + b->getParent()->bringVirtualToBack(b); + } +} + +void GuiObjectI::guiobject_bringAbove(GuiObject *o) { + ASSERT(o != NULL); + ifc_window *b = guiobject_getRootWnd(); + ifc_window *c = o->guiobject_getRootWnd(); + if (b && c) { + if (b->getParent()) + b->getParent()->bringVirtualAbove(b, c); + } +} + +void GuiObjectI::guiobject_bringBelow(GuiObject *o) { + ASSERT(o != NULL); + ifc_window *b = guiobject_getRootWnd(); + ifc_window *c = o->guiobject_getRootWnd(); + if (b && c) { + if (b->getParent()) + b->getParent()->bringVirtualBelow(b, c); + } +} + +void GuiObjectI::guiobject_setTargetSpeed(float s) { // s == n of seconds + if (targetspeed == (int)(s * 4.0)) return; + targetspeed = (int)(s * 4.0); // units of 250ms + if (targetstatus == TARGET_RUNNING) { + stopTargetTimer(); + startTargetTimer(); + } +} + +void GuiObjectTimer::timerclient_timerCallback(int id) { + if (id == TARGETTIMER_ID && obj) + obj->onTargetTimer(); +} + +void GuiObjectI::guiobject_setTargetX(int x) { + targetx = x; +} + +void GuiObjectI::guiobject_setTargetY(int y) { + targety = y; +} + +void GuiObjectI::guiobject_setTargetW(int w) { + targetw = w; +} + +void GuiObjectI::guiobject_setTargetH(int h) { + targeth = h; +} + +void GuiObjectI::guiobject_setTargetA(int a) { + targeta = a; +} + +void GuiObjectI::guiobject_gotoTarget() { + if (!guiobject_getRootWnd()) return; + start_time=0; + guiobject_getGuiPosition(&startx, &starty, &startw, &starth, NULL, NULL, NULL, NULL); + starta = guiobject_getAlpha(); + if (targetx == AUTOWH || targetx == NOCHANGE) + targetx = startx; + if (targety == AUTOWH || targety == NOCHANGE) + targety = starty; + if (targetw == AUTOWH || targetw == NOCHANGE) + targetw = startw; + if (targeth == AUTOWH || targeth == NOCHANGE) + targeth = starth; + if (targeta == AUTOWH || targeta == NOCHANGE) + targeta = starta; + startTargetTimer(); + Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid)); + if (targetx != startx || + targety != starty || + targetw != startw || + targeth != starth) { + if (l) windowTracker->beforeRedock(l, &redock); + } +} + +void GuiObjectI::startTargetTimer() { + timer.timerclient_setTimer(TARGETTIMER_ID, 20); + targetstatus = TARGET_RUNNING; +} + +void GuiObjectI::stopTargetTimer() { + timer.timerclient_killTimer(TARGETTIMER_ID); + targetstatus = TARGET_FROZEN; +} + +void GuiObjectI::onTargetTimer() { + + if (targetstatus != TARGET_RUNNING) return; + if (!guiobject_getRootWnd()) return; + + RECT r; + guiobject_getRootWnd()->getClientRect(&r); + RECT wr; + guiobject_getRootWnd()->getWindowRect(&wr); + + int ttime=250*targetspeed; + if (ttime < 0) ttime = 0; + + int n; + if (!start_time) + { + n=0; + start_time = Wasabi::Std::getTickCount(); + } + else + { + n=MulDiv(Wasabi::Std::getTickCount()-start_time,256,ttime); + } + + if (ttime == 0) n = 255; + + if (n >= 255) n=255; + + float sintrans = (float)(sin(((float)n/255)*PI-PI/2)/2+0.5); // used for smoothing transitions + + float nw = ((float)(targetw - startw) * sintrans) + startw; + float nh = ((float)(targeth - starth) * sintrans) + starth; + float na = ((float)(targeta - starta) * sintrans) + starta; + + Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid)); + int islayout = l != NULL && static_cast<ifc_window*>(l) == guiobject_getRootWnd(); + + float rat = 1.0f; + if (islayout) rat = (float)l->getRenderRatio(); + + float nx; + float ny; + if (!reversetarget) { + nx = ((float)(targetx - startx) * sintrans) + startx; + ny = ((float)(targety - starty) * sintrans) + starty; + } else { + nx = startx - ((float)(targetw - startw) * sintrans) * rat; + ny = starty - ((float)(targeth - starth) * sintrans) * rat; + } + + int zx=(int)nx; + int zy=(int)ny; + int zw=(int)nw; + int zh=(int)nh; + + if (reversetarget) { + while (zy + zh * rat < wr.bottom) zy++; + while (zx + zw * rat < wr.right) zx++; + } + + int oldredraw = -1; + if (reversetarget && islayout) { + oldredraw = l->wantRedrawOnResize(); + l->setWantRedrawOnResize(0); + + int paddtop = wr.top - (int)ny; + int paddleft = wr.left - (int)nx; + +#ifdef _WIN32 + if (paddtop > 0 || paddleft > 0) { + RegionI r; + GetWindowRgn(l->gethWnd(), r.getOSHandle()); + r.offset(MAX(0, paddleft), MAX(0, paddtop)); + SetWindowRgn(l->gethWnd(), r.makeWindowRegion(), FALSE); + } +#else +#warning port me +#endif + } + guiobject_setGuiPosition(&zx, &zy, &zw, &zh, NULL, NULL, NULL, NULL); + guiobject_getRootWnd()->cascadeRepaint(0); + guiobject_setAlpha((int)na); + if (n==255) { + stopTargetTimer(); + guiobject_onTargetReached(); + } + if (l != NULL) l->savePosition(); + if (oldredraw != -1 && l) { + l->setWantRedrawOnResize(oldredraw); + } +} + +void GuiObjectI::guiobject_cancelTarget() { + stopTargetTimer(); + Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid)); + if (l && redock.l) windowTracker->afterRedock(l, &redock); +} + +void GuiObjectI::guiobject_reverseTarget(int reverse) { + reversetarget = reverse; +} + +#ifdef WASABI_COMPILE_WNDMGR +void GuiObjectI::guiobject_popParentLayout() { + Layout *l = guiobject_getParentLayout(); + if (l && l->getParentContainer()) { + SkinParser::showContainer(l->getParentContainer()->getId(), TRUE); +#ifdef WIN32 + SetForegroundWindow(l->gethWnd()); +#else + l->bringToFront(); +#endif + } +} +#endif + +int GuiObjectI::guiobject_movingToTarget() { + return targetstatus == TARGET_RUNNING; +} + +void GuiObjectI::guiobject_onLeftButtonDown(int x, int y) { + if (!VCPU::getComplete()) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onLeftButtonDown(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); + if (mover && !VCPU::getComplete()) { + #ifdef WASABI_COMPILE_WNDMGR + Layout *l = guiobject_getParentLayout(); + if (l) { + // Martin> (9/9/8) added l->getGuiObject()->guiobject_getMover() so setting move="0" to layouts will disable moving it around + if (!l->isLocked() && l->getGuiObject()->guiobject_getMover()) { +#ifdef USEAPPBAR + if (cfg_options_appbarondrag) { + m_initial_dock_side = m_dock_side = l->appbar_getSide(); + if (m_dock_side != APPBAR_NOTDOCKED) { + dodragcheck = 1; + goto skipit; + } + } +#endif + l->maximize(0); + skipit: + l->beginMove(); + if (l->getParentContainer() && l->getParentContainer()->isMainContainer() || Std::keyModifier(STDKEY_ALT)) + WASABI_API_WNDMGR->wndTrackStartCooperative(l); + moving = 1; + anchor.x = (int)((float)x * guiobject_getRootWnd()->getRenderRatio()); + anchor.y = (int)((float)y * guiobject_getRootWnd()->getRenderRatio()); + } + } + #endif //WASABI_COMPILE_WNDMGR + } + } +} + +void GuiObjectI::guiobject_onLeftButtonUp(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onLeftButtonUp(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); + if (moving) { + int sendendmove = 0; +#ifdef WASABI_COMPILE_WNDMGR + Group *l = guiobject_getParentLayout(); + if (l) { + if (WASABI_API_WNDMGR->wndTrackWasCooperative()) + WASABI_API_WNDMGR->wndTrackEndCooperative(); + moving = 0; + sendendmove = 1; + } +#ifdef USEAPPBAR + if (cfg_options_appbarondrag) { + if (m_dock_side != m_initial_dock_side) { + ifc_window *dw = guiobject_getRootWnd()->getDesktopParent(); + if (dw) { + AppBar *ab = reinterpret_cast<AppBar *>(dw->getInterface(appBarGuid)); + if (ab) { + if (m_dock_side == APPBAR_NOTDOCKED) ab->appbar_setNoRestore(1); + ab->appbar_dock(m_dock_side); + if (m_dock_side == APPBAR_NOTDOCKED) ab->appbar_setNoRestore(0); + } + } + } + if (m_dock_side == APPBAR_NOTDOCKED) { + ifc_window *dp = guiobject_getRootWnd()->getDesktopParent(); + if (dp) dp->restore(0); + } + } else { + ifc_window *dp = guiobject_getRootWnd()->getDesktopParent(); + if (dp) dp->restore(0); + } +#else + ifc_window *dp = guiobject_getRootWnd()->getDesktopParent(); + if (dp) dp->restore(0); +#endif // USEAPPBAR + if (sendendmove && l) l->endMove(); +#endif //WASABI_COMPILE_WNDMGR + } +} + +void GuiObjectI::guiobject_onRightButtonDown(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onRightButtonDown(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); +} + +#ifdef WASABI_CUSTOM_CONTEXTMENUS +extern void appContextMenu(ifc_window *wnd); +extern void appControlMenu(ifc_window *wnd); +#endif + +void GuiObjectI::guiobject_onRightButtonUp(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onRightButtonUp(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); + ifc_window *w = guiobject_getRootWnd(); + if (Std::keyModifier(STDKEY_CONTROL) && + Std::keyModifier(STDKEY_SHIFT)) { + GuiObjectI::infoMenu(this, x, y); + } else { + if (w && w->wantAutoContextMenu() && !VCPU::getComplete() && WASABI_API_WNDMGR->getModalWnd() == NULL) { + ifc_window *par = w->getParent(); + if (par && guiobject_getParentLayout()) { + if (!Std::keyModifier(STDKEY_CONTROL)) { +#if defined(WA3COMPATIBILITY) + Main::appContextMenu(par, TRUE, guiobject_getParentLayout()->isTransparencySafe()); +#elif defined(WASABI_CUSTOM_CONTEXTMENUS) + appContextMenu(par); +#endif + } else { + Layout *l = guiobject_getParentLayout(); + if (l->getParent() == NULL) { +#if defined(WA3COMPATIBILITY) + l->controlMenu(); +#elif defined(WASABI_CUSTOM_CONTEXTMENUS) + appControlMenu(l); +#endif + } + } + } else { + Layout *l = static_cast<Layout *>(w->getInterface(layoutGuid)); + if (l != NULL) { + if (!Std::keyModifier(STDKEY_CONTROL)) { +#if defined(WA3COMPATIBILITY) + Main::appContextMenu(w, TRUE, l->isTransparencySafe()); +#elif defined(WASABI_CUSTOM_CONTEXTMENUS) + appContextMenu(w); +#endif + } else { +#if defined(WA3COMPATIBILITY) + l->controlMenu(); +#elif defined(WASABI_CUSTOM_CONTEXTMENUS) + appControlMenu(l); +#endif + } + } + } + } + } +} + +void GuiObjectI::guiobject_onRightButtonDblClk(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onRightButtonDblClk(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); +} + +void GuiObjectI::guiobject_onLeftButtonDblClk(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x/* - wr.left*/); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y/* - wr.top*/); + GuiObject_ScriptMethods::onLeftButtonDblClk(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); +} + +int GuiObjectI::guiobject_onMouseWheelUp(int clicked, int lines) +{ + scriptVar retval; + retval = GuiObject_ScriptMethods::onMouseWheelUp(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(clicked), MAKE_SCRIPT_INT(lines) ); + int retv; + + if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING)) + retv = 0; + else + retv = GET_SCRIPT_INT(retval); + + return retv; +} + +int GuiObjectI::guiobject_onMouseWheelDown(int clicked, int lines) +{ + scriptVar retval; + retval = GuiObject_ScriptMethods::onMouseWheelDown(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(clicked), MAKE_SCRIPT_INT(lines) ); + int retv; + + if ((retval.type == SCRIPT_VOID) || (retval.type == SCRIPT_OBJECT) || (retval.type == SCRIPT_STRING)) + retv = 0; + else + retv = GET_SCRIPT_INT(retval); + + return retv; +} + +void GuiObjectI::guiobject_onMouseMove(int x, int y) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + GuiObject_ScriptMethods::onMouseMove(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y); + POINT pos={x,y}; + guiobject_getRootWnd()->clientToScreen((int *)&pos.x, (int *)&pos.y); +#ifdef WASABI_COMPILE_WNDMGR + if (moving) { +#ifdef _WIN32 + if (!Std::keyDown(MK_LBUTTON)) { +#else +#warning port me + if (0) { +#endif + moving = 0; + } else { +#ifdef WIN32 + int drag_x = GetSystemMetrics(SM_CXDRAG); + int drag_y = GetSystemMetrics(SM_CYDRAG); +#else +#warning port me + int drag_x = 5; + int drag_y = 5; +#endif + POINT relatpos; + relatpos.x = (int)((float)x*guiobject_getRootWnd()->getRenderRatio()) - anchor.x; + relatpos.y = (int)((float)y*guiobject_getRootWnd()->getRenderRatio()) - anchor.y; + if (!dodragcheck || (ABS(relatpos.x) >= drag_x || ABS(relatpos.y) >= drag_y)) { + dodragcheck = 0; + ifc_window *p = guiobject_getRootWnd()->getDesktopParent(); + if (p) { + RECT r, cr; + p->getWindowRect(&r); + p->getClientRect(&cr); + RECT nr=r; + int w,h; + + #ifdef USEAPPBAR + int side = APPBAR_NOTDOCKED; + if (cfg_options_appbarondrag) { + AppBar *ab = reinterpret_cast<AppBar *>(p->getInterface(appBarGuid)); + if (ab) { + int _x=x, _y=y; + p->clientToScreen(&_x, &_y); + side = ab->appbar_testDock(_x, _y, &nr); + if (ABS(p->getRenderRatio() - 1.0) > 0.01f) { + int _w = nr.right-nr.left; + int _h = nr.bottom-nr.top; + double rr = p->getRenderRatio(); + _w = (int)((double)(_w) / rr + 0.5); + _h = (int)((double)(_h) / rr + 0.5); + nr.right = nr.left + _w; + nr.bottom = nr.top + _h; + } + } + } + #endif + w = cr.right-cr.left; + h = cr.bottom-cr.top; + int resize=0; +#ifdef USEAPPBAR + if (cfg_options_appbarondrag) { + if (side != m_dock_side) { + if (side != APPBAR_NOTDOCKED) { + m_lastnondocked_x = r.left; + m_lastnondocked_y = r.top; + resize=1; + } else { + RECT rr; + p->getRestoredRect(&rr); + w = (rr.right-rr.left); + h = (rr.bottom-rr.top); + if (m_lastnondocked_x != -0xFFFF) { + r.left = m_lastnondocked_x; + r.top = m_lastnondocked_y; + } + r.right = r.left + w; + r.bottom = r.top + h; + snapAdjust(p, &r, -1); + nr=r; + resize=1; + } + } + } +#endif + + // use the scaling to adjust the overall size so docking will be correct + double rr = p->getRenderRatio(); + r.left += relatpos.x; + r.top += relatpos.y; + r.right = r.left + (int)((double)w * rr); + r.bottom = r.top + (int)((double)h * rr); + +#ifdef USEAPPBAR + + if (side == APPBAR_NOTDOCKED && m_dock_side == APPBAR_NOTDOCKED) + WASABI_API_WNDMGR->wndTrackDock(p, &r, &nr, LEFT|TOP|RIGHT|BOTTOM|KEEPSIZE); + + if (side != APPBAR_NOTDOCKED || resize) { + Layout *l = (Layout *)p->getInterface(layoutGuid); + if (l) l->pushForceUnlink(); + { + RECT adj = nr; + snapAdjust(p, &adj, 1); + int _w = adj.right-adj.left; + int _h = adj.bottom-adj.top; + if (ABS(p->getRenderRatio() - 1.0) > 0.01f) { + double rr = p->getRenderRatio(); + if ((int)((double)(_w) * rr) == (int)((double)(w) * rr)) _w = w; + if ((int)((double)(_h) * rr) == (int)((double)(h) * rr)) _h = h; + } + p->resize(adj.left, adj.top, _w, _h); + } + if (l) l->popForceUnlink(); + } else { + p->move(r.left, r.top); + } + + m_dock_side = side; + guiobject_getParentLayout()->onMove(); + if (GetCapture() != guiobject_getRootWnd()->getRootParent()->gethWnd()) { + DebugStringW(L"not mine anymore :(\n"); + } +#endif + } + } + } + } +#endif +} + +// ----------------------------------------------------------------------- +void GuiObjectI::snapAdjust(ifc_window *rw, RECT *r, int way) { + RECT s; + Layout *l = static_cast<Layout*>(rw->getInterface(layoutGuid)); + if (!l) return; + l->getSnapAdjust(&s); + int h = r->bottom - r->top; + int w = r->right - r->left; + if (way == 1) { + h += s.top + s.bottom; + w += s.left + s.right; + r->left -= s.left; + r->top -= s.top; + r->bottom = r->top + h; + r->right = r->left + w; + } else if (way == -1) { + h -= s.top + s.bottom; + w -= s.left + s.right; + r->left += s.left; + r->top += s.top; + r->bottom = r->top + h; + r->right = r->left + w; + } +} + +#ifdef USEAPPBAR +int GuiObjectI::guiobject_getAppBar() { + AppBar *ab = reinterpret_cast<AppBar *>(guiobject_getRootWnd()->getInterface(appBarGuid)); + if (ab) return ab->appbar_getEnabledSides(); + return 0; +} + +BEGIN_STRINGDICTIONARY(_appbarvalues) +SDI(L"top", APPBAR_TOP_ENABLED); +SDI(L"left", APPBAR_LEFT_ENABLED); +SDI(L"right", APPBAR_RIGHT_ENABLED); +SDI(L"bottom", APPBAR_BOTTOM_ENABLED); +END_STRINGDICTIONARY(_appbarvalues, appbarvalues) + +void GuiObjectI::guiobject_setAppBar(int en) { + AppBar *ab = reinterpret_cast<AppBar *>(guiobject_getRootWnd()->getInterface(appBarGuid)); + if (ab) ab->appbar_setEnabledSides(en); +} + +void GuiObjectI::setAppBar(const wchar_t *en) +{ + AppBar *ab = reinterpret_cast<AppBar *>(guiobject_getRootWnd()->getInterface(appBarGuid)); + if (ab) { + int e = 0; + ParamParser pp(en, L"|;"); + for (int i=0;i<pp.getNumItems();i++) + { + const wchar_t *s = pp.enumItem(i); + if (!_wcsicmp(s, L"left")) e |= APPBAR_LEFT_ENABLED; + else if (!_wcsicmp(s, L"top")) e |= APPBAR_TOP_ENABLED; + else if (!_wcsicmp(s, L"right")) e |= APPBAR_RIGHT_ENABLED; + else if (!_wcsicmp(s, L"bottom")) e |= APPBAR_BOTTOM_ENABLED; + } + ab->appbar_setEnabledSides(e); + } +} +#endif + +const wchar_t *GuiObjectI::guiobject_getName() +{ + const wchar_t *ret = NULL; + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + ret = w->getRootWndName(); + return ret; +} + +void GuiObjectI::guiobject_onEnable(int en) { + scriptVar _is = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_is, en); + GuiObject_ScriptMethods::onEnable(SCRIPT_CALL, guiobject_getScriptObject(), _is); +} + +void GuiObjectI::guiobject_onStartup() { + GuiObject_ScriptMethods::onStartup(SCRIPT_CALL, guiobject_getScriptObject()); + if (guiobject_getRootObject()) { + foreach (notifylist) + guiobject_getRootObject()->rootobject_notify(notifylist.getfor()->getValue(), L"", 0, 0); + endfor; + } +} + +void GuiObjectI::guiobject_onEnterArea() { + if (in_area) return; + GuiObject_ScriptMethods::onEnterArea(SCRIPT_CALL, guiobject_getScriptObject()); + in_area = 1; +} + +void GuiObjectI::guiobject_onLeaveArea() { + if (!in_area) return; + GuiObject_ScriptMethods::onLeaveArea(SCRIPT_CALL, guiobject_getScriptObject()); + in_area = 0; +} + +void GuiObjectI::guiobject_onCancelCapture() { + moving = 0; +} + +ifc_window *GuiObjectI::guiobject_getRootWnd(void) { + return my_root_wnd; +} + +void GuiObjectI::guiobject_setRootWnd(ifc_window *r) { + my_root_wnd = r; +} + +RootObject *GuiObjectI::guiobject_getRootObject() { + ScriptObject *o = guiobject_getScriptObject(); + if (!o) return NULL; + return static_cast<RootObject *>(o->vcpu_getInterface(rootObjectGuid)); +} + +void GuiObjectI::guiobject_onResize(int x, int y, int w, int h) { + scriptVar _x = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_x, x); + scriptVar _y = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_y, y); + scriptVar _w = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_w, w); + scriptVar _h = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_h, h); + GuiObject_ScriptMethods::onResize(SCRIPT_CALL, guiobject_getScriptObject(), _x, _y, _w, _h); +} + +void GuiObjectI::guiobject_onSetVisible(int v) { +#ifdef WASABI_COMPILE_WNDMGR + if (guiobject_getParentLayout()) + guiobject_getParentLayout()->onGuiObjectSetVisible(this, v); +#endif + scriptVar _v = SOM::makeVar(SCRIPT_BOOLEAN); + SOM::assign(&_v, v); + GuiObject_ScriptMethods::onSetVisible(SCRIPT_CALL, guiobject_getScriptObject(), _v); +#ifdef WASABI_COMPILE_WNDMGR + if (moving) { + if (WASABI_API_WNDMGR->wndTrackWasCooperative()) + WASABI_API_WNDMGR->wndTrackEndCooperative(); + moving = 0; + ifc_window *dp = guiobject_getRootWnd()->getDesktopParent(); + if (dp) dp->restore(0); + guiobject_getParentGroup()->endMove(); + } +#endif //WASABI_COMPILE_WNDMGR +} + +void GuiObjectI::guiobject_setAlpha(int a) { + if (!my_root_wnd) return; + Layout *l = static_cast<Layout*>(my_root_wnd->getInterface(layoutGuid)); + if (l) l->setAlpha(a); + else my_root_wnd->setAlpha(a); +} + +int GuiObjectI::guiobject_getAlpha() { + if (!my_root_wnd) return 255; + Layout *l = static_cast<Layout*>(my_root_wnd->getInterface(layoutGuid)); + if (l) return l->getAlpha(); + return my_root_wnd->getPaintingAlpha(); +} + +void GuiObjectI::guiobject_setActiveAlpha(int a) { + if (my_root_wnd) { + int i; + my_root_wnd->getAlpha(NULL, &i); + my_root_wnd->setAlpha(a, i); + } +} + +int GuiObjectI::guiobject_getActiveAlpha() { + int a = 255; + if (my_root_wnd) my_root_wnd->getAlpha(&a); + return a; +} + +void GuiObjectI::guiobject_setInactiveAlpha(int a) { + if (my_root_wnd) { + int _a; + my_root_wnd->getAlpha(&_a); + my_root_wnd->setAlpha(_a, a); + } +} + +int GuiObjectI::guiobject_getInactiveAlpha() { + if (my_root_wnd) { + int i; + my_root_wnd->getAlpha(NULL, &i); + return i; + } + return 255; +} + +void GuiObjectI::guiobject_onTargetReached() { + GuiObject_ScriptMethods::onTargetReached(SCRIPT_CALL, guiobject_getScriptObject()); + Layout *l = static_cast<Layout *>(guiobject_getScriptObject()->vcpu_getInterface(layoutGuid)); + if (l && redock.l) windowTracker->afterRedock(l, &redock); +} + +void GuiObjectI::guiobject_setAutoSysMetricsX(int a) { + if (a == autosysmetricsx) return; + autosysmetricsx = a; + if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited()) + if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this); +} + +void GuiObjectI::guiobject_setAutoSysMetricsY(int a) { + if (a == autosysmetricsy) return; + autosysmetricsy = a; + if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited()) + if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this); +} + +void GuiObjectI::guiobject_setAutoSysMetricsW(int a) { + if (a == autosysmetricsw) return; + autosysmetricsw = a; + if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited()) + if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this); +} + +void GuiObjectI::guiobject_setAutoSysMetricsH(int a) { + if (a == autosysmetricsh) return; + autosysmetricsh = a; + if (guiobject_getRootWnd() && guiobject_getRootWnd()->isInited()) + if (guiobject_getParentGroup()) guiobject_getParentGroup()->updatePos(this); +} + +int GuiObjectI::guiobject_getAutoSysMetricsX() { + return autosysmetricsx; +} + +int GuiObjectI::guiobject_getAutoSysMetricsY() { + return autosysmetricsy; +} + +int GuiObjectI::guiobject_getAutoSysMetricsW() { + return autosysmetricsw; +} + +int GuiObjectI::guiobject_getAutoSysMetricsH() { + return autosysmetricsh; +} + +int GuiObjectI::guiobject_getAutoWidth() { + if (!guiobject_getRootWnd()) return AUTOWH; + return guiobject_getRootWnd()->getPreferences(SUGGESTED_W); +} + +int GuiObjectI::guiobject_getAutoHeight() { + if (!guiobject_getRootWnd()) return AUTOWH; + return guiobject_getRootWnd()->getPreferences(SUGGESTED_H); +} + +#ifdef WASABI_COMPILE_WNDMGR +int GuiObjectI::guiobject_runModal() { + if (!guiobject_getRootWnd()) return 0; + ifc_window *w = guiobject_getRootWnd()->getDesktopParent(); + #ifdef WASABI_MODAL_PUSH + WASABI_MODAL_PUSH + #endif + int r = w->runModal(); + #ifdef WASABI_MODAL_POP + WASABI_MODAL_POP + #endif + return r; +} + +void GuiObjectI::guiobject_endModal(int retcode) { + if (!guiobject_getRootWnd()) return; + ifc_window *w = guiobject_getRootWnd()->getDesktopParent(); + w->endModal(retcode); +} +#endif + +int GuiObjectI::guiobject_isActive() { + if (!guiobject_getRootWnd()) return 0; + return guiobject_getRootWnd()->isActive(); +} + +svc_xuiObject *GuiObjectI::guiobject_getXuiService() { + return xuisvc; +} + +void GuiObjectI::guiobject_setXuiService(svc_xuiObject *svc) { + xuisvc = svc; +} + +waServiceFactory *GuiObjectI::guiobject_getXuiServiceFactory() { + return xuifac; +} +void GuiObjectI::guiobject_setXuiServiceFactory(waServiceFactory *fac) { + xuifac = fac; +} + +#ifdef WASABI_COMPILE_WNDMGR +void GuiObjectI::guiobject_setStatusText(const wchar_t *text, int overlay) +{ + Layout *l = guiobject_getParentLayout(); + if (l) + l->setStatusText(text, overlay); +} + +void GuiObjectI::guiobject_registerStatusCB(GuiStatusCallback *cb) { + Layout *l = guiobject_getParentLayout(); + if (l) l->registerStatusCallback(cb); +} + +void GuiObjectI::guiobject_addAppCmds(AppCmds *commands){ + Layout *l = guiobject_getParentLayout(); + if (l) l->addAppCmds(commands); +} + +void GuiObjectI::guiobject_removeAppCmds(AppCmds *commands){ + Layout *l = guiobject_getParentLayout(); + if (l) l->removeAppCmds(commands); +} + +void GuiObjectI::guiobject_pushCompleted(int max) { + Layout *l = guiobject_getParentLayout(); + if (l) l->pushCompleted(max); +} +void GuiObjectI::guiobject_incCompleted(int add) { + Layout *l = guiobject_getParentLayout(); + if (l) l->incCompleted(add); +} +void GuiObjectI::guiobject_setCompleted(int pos) { + Layout *l = guiobject_getParentLayout(); + if (l) l->setCompleted(pos); +} +void GuiObjectI::guiobject_popCompleted() { + Layout *l = guiobject_getParentLayout(); + if (l) l->popCompleted(); +} +#endif //WASABI_COMPILE_WNDMGR + +void GuiObjectI::infoMenu(GuiObject *o, int x, int y) +{ + PopupMenu pop; + pop.addCommand(StringPrintfW(L"Class : %s", o->guiobject_getScriptObject()->vcpu_getClassName()), 0, 0, 1); + pop.addCommand(StringPrintfW(L"Id : %s", o->guiobject_getId()), 0, 0, 1); + RECT r; + guiobject_getRootWnd()->getNonClientRect(&r); + pop.addCommand(StringPrintfW(L"Coordinates : %d,%d (%d x %d)", r.left, r.top, r.right-r.left, r.bottom-r.top), 0, 0, 1); + int _x, _y, _w, _h, _rx, _ry, _rw, _rh; + guiobject_getGuiPosition(&_x, &_y, &_w, &_h, &_rx, &_ry, &_rw, &_rh); + pop.addCommand(StringPrintfW(L"GuiPos : x=%d relatx=%d, y=%d relaty=%d, w=%d relatw=%d, h=%d relath=%d", _x, _rx, _y, _ry, _w, _rw, _h, _rh), 0, 0, 1); + + if (guiobject_wantTranslation() == 2) + { + if (!_wcsicmp(o->guiobject_getScriptObject()->vcpu_getClassName(), L"Text")) + { + pop.addCommand(StringPrintfW(L"StringEntry : %s", guiobject_getXmlParam(L"text")), 0, 0, 1); + } + else if (!_wcsicmp(o->guiobject_getScriptObject()->vcpu_getClassName(), L"TitleBar")) + { + pop.addCommand(StringPrintfW(L"StringEntry : %s", guiobject_getXmlParam(L"title")), 0, 0, 1); + } + } + guiobject_getRootWnd()->clientToScreen(&x, &y); + pop.popAtXY(x, y, 1); +} + +#ifdef WASABI_COMPILE_CONFIG + +void GuiObjectI::guiobject_setCfgAttrib(CfgItem *item, const wchar_t *name) +{ + if (cfgitem) viewer_delViewItem(cfgitem); + cfgitem = item; + cfgattrname = name; + if (cfgitem) { + viewer_addViewItem(cfgitem); + } + ifc_window *mw = guiobject_getRootWnd(); + if (mw != NULL) { + if (mw->isPostOnInit()) + dataChanged(); + } +} + +int GuiObjectI::viewer_onEvent(CfgItem *item, int event, intptr_t param, void *ptr, size_t ptrlen) { + if (item == cfgitem) + dataChanged(); + return 1; +} + +void GuiObjectI::dataChanged() { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) { + w->onAction(L"reload_config", NULL, -1, -1, 0, 0, NULL, 0, w); + } + GuiObject_ScriptMethods::onCfgChanged(SCRIPT_CALL, guiobject_getScriptObject()); +} + + +CfgItem *GuiObjectI::guiobject_getCfgItem() { + return cfgitem; +} + +const wchar_t *GuiObjectI::guiobject_getCfgAttrib() +{ + return cfgattrname; +} +#endif //WASABI_COMPILE_CONFIG + +void GuiObjectI::guiobject_onChar(wchar_t c) +{ + wchar_t _c[2]=L"X"; + _c[0]=c; + GuiObject_ScriptMethods::onChar(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(_c)); +} + +void GuiObjectI::guiobject_onKeyDown(int vkcode) { + GuiObject_ScriptMethods::onKeyDown(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(vkcode)); +} + +void GuiObjectI::guiobject_onKeyUp(int vkcode) { + GuiObject_ScriptMethods::onKeyUp(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(vkcode)); +} + +void GuiObjectI::guiobject_setCursor(const wchar_t *c) +{ + ifc_window *w = guiobject_getRootWnd(); +#ifdef _WIN32 + if (w != NULL) { + delete cursor; + cursor = new SkinCursor(c); + w->setDefaultCursor(cursor); + } +#else +#warning port me +#endif +} + +void GuiObjectI::guiobject_setEnabled(int en) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) w->setEnabled(en); +} + +int GuiObjectI::guiobject_wantTranslation() +{ + return translate; +} +int GuiObjectI::guiobject_dragEnter(ifc_window *sourceWnd) +{ + GuiObject_ScriptMethods::onDragEnter(SCRIPT_CALL, guiobject_getScriptObject()); + return 1; +} + +int GuiObjectI::guiobject_dragOver(int x, int y, ifc_window *sourceWnd) +{ + GuiObject_ScriptMethods::onDragOver(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y) ); + return 1; +} + +int GuiObjectI::guiobject_dragLeave(ifc_window *sourceWnd) +{ + GuiObject_ScriptMethods::onDragLeave(SCRIPT_CALL, guiobject_getScriptObject()); + return 1; +} + +GuiObjectScriptController _guiController; +GuiObjectScriptController *guiController = &_guiController; + +// -- Functions table ------------------------------------- +function_descriptor_struct GuiObjectScriptController::exportedFunction[] = { + {L"getId", 0, (void*)GuiObject_ScriptMethods::getId }, + {L"show", 0, (void*)GuiObject_ScriptMethods::show }, + {L"hide", 0, (void*)GuiObject_ScriptMethods::hide }, + {L"onSetVisible", 1, (void*)GuiObject_ScriptMethods::onSetVisible}, + {L"isVisible", 0, (void*)GuiObject_ScriptMethods::isvisible }, + {L"setAlpha", 1, (void*)GuiObject_ScriptMethods::setAlpha }, + {L"getAlpha", 0, (void*)GuiObject_ScriptMethods::getAlpha }, + {L"setActiveAlpha", 1, (void*)GuiObject_ScriptMethods::setActiveAlpha }, + {L"getActiveAlpha", 0, (void*)GuiObject_ScriptMethods::getActiveAlpha }, + {L"setInactiveAlpha", 1, (void*)GuiObject_ScriptMethods::setInactiveAlpha }, + {L"getInactiveAlpha", 0, (void*)GuiObject_ScriptMethods::getInactiveAlpha }, + {L"onLeftButtonDown", 2, (void*)GuiObject_ScriptMethods::onLeftButtonDown }, + {L"onLeftButtonUp", 2, (void*)GuiObject_ScriptMethods::onLeftButtonUp }, + {L"onRightButtonDown", 2, (void*)GuiObject_ScriptMethods::onRightButtonDown }, + {L"onRightButtonUp", 2, (void*)GuiObject_ScriptMethods::onRightButtonUp }, + {L"onRightButtonDblClk", 2, (void*)GuiObject_ScriptMethods::onRightButtonDblClk }, + {L"onLeftButtonDblClk", 2, (void*)GuiObject_ScriptMethods::onLeftButtonDblClk }, + {L"onMouseWheelUp", 2, (void*)GuiObject_ScriptMethods::onMouseWheelUp }, + {L"onMouseWheelDown", 2, (void*)GuiObject_ScriptMethods::onMouseWheelDown }, + {L"onMouseMove", 2, (void*)GuiObject_ScriptMethods::onMouseMove }, + {L"onEnterArea", 0, (void*)GuiObject_ScriptMethods::onEnterArea }, + {L"onLeaveArea", 0, (void*)GuiObject_ScriptMethods::onLeaveArea }, + {L"isMouseOverRect", 0, (void*)GuiObject_ScriptMethods::isMouseOverRect}, + {L"onStartup", 0, (void*)GuiObject_ScriptMethods::onStartup }, + {L"onChar", 1, (void*)GuiObject_ScriptMethods::onChar }, + {L"onKeyDown", 1, (void*)GuiObject_ScriptMethods::onKeyDown}, + {L"onKeyUp", 1, (void*)GuiObject_ScriptMethods::onKeyUp}, + {L"setEnabled", 1, (void*)GuiObject_ScriptMethods::setEnabled }, + {L"getEnabled", 0, (void*)GuiObject_ScriptMethods::getEnabled }, + {L"onEnable", 1, (void*)GuiObject_ScriptMethods::onEnable }, + {L"resize", 4, (void*)GuiObject_ScriptMethods::resize }, + {L"onResize", 4, (void*)GuiObject_ScriptMethods::onResize }, + {L"isMouseOver", 2, (void*)GuiObject_ScriptMethods::isMouseOver }, + {L"getLeft", 0, (void*)GuiObject_ScriptMethods::getLeft }, + {L"getTop", 0, (void*)GuiObject_ScriptMethods::getTop }, + {L"getWidth", 0, (void*)GuiObject_ScriptMethods::getWidth }, + {L"getHeight", 0, (void*)GuiObject_ScriptMethods::getHeight }, + {L"getGuiX", 0, (void*)GuiObject_ScriptMethods::getGuiX }, + {L"getGuiY", 0, (void*)GuiObject_ScriptMethods::getGuiY }, + {L"getGuiW", 0, (void*)GuiObject_ScriptMethods::getGuiW }, + {L"getGuiH", 0, (void*)GuiObject_ScriptMethods::getGuiH }, + {L"getGuiRelatX", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX }, + {L"getGuiRelatY", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX }, + {L"getGuiRelatW", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX }, + {L"getGuiRelatH", 0, (void*)GuiObject_ScriptMethods::getGuiRelatX }, + {L"clientToScreenX", 1, (void*)GuiObject_ScriptMethods::clientToScreenX }, + {L"clientToScreenY", 1, (void*)GuiObject_ScriptMethods::clientToScreenY }, + {L"clientToScreenW", 1, (void*)GuiObject_ScriptMethods::clientToScreenW }, + {L"clientToScreenH", 1, (void*)GuiObject_ScriptMethods::clientToScreenH }, + {L"screenToClientX", 1, (void*)GuiObject_ScriptMethods::screenToClientX }, + {L"screenToClientY", 1, (void*)GuiObject_ScriptMethods::screenToClientY }, + {L"screenToClientW", 1, (void*)GuiObject_ScriptMethods::screenToClientW }, + {L"screenToClientH", 1, (void*)GuiObject_ScriptMethods::screenToClientH }, + {L"setTargetX", 1, (void*)GuiObject_ScriptMethods::setTargetX }, + {L"setTargetY", 1, (void*)GuiObject_ScriptMethods::setTargetY }, + {L"setTargetW", 1, (void*)GuiObject_ScriptMethods::setTargetW }, + {L"setTargetH", 1, (void*)GuiObject_ScriptMethods::setTargetH }, + {L"setTargetA", 1, (void*)GuiObject_ScriptMethods::setTargetA }, + {L"setTargetSpeed", 1, (void*)GuiObject_ScriptMethods::setTargetSpeed }, + {L"gotoTarget", 0, (void*)GuiObject_ScriptMethods::gotoTarget }, + {L"onTargetReached", 0, (void*)GuiObject_ScriptMethods::onTargetReached }, + {L"cancelTarget", 0, (void*)GuiObject_ScriptMethods::cancelTarget }, + {L"reverseTarget", 1, (void*)GuiObject_ScriptMethods::reverseTarget }, + {L"isGoingToTarget", 0, (void*)GuiObject_ScriptMethods::movingToTarget }, + {L"setXmlParam", 2, (void*)GuiObject_ScriptMethods::setXmlParam }, + {L"getXmlParam", 1, (void*)GuiObject_ScriptMethods::getXmlParam }, + {L"init", 1, (void*)GuiObject_ScriptMethods::init }, + {L"bringToFront", 0, (void*)GuiObject_ScriptMethods::bringToFront }, + {L"bringToBack", 0, (void*)GuiObject_ScriptMethods::bringToBack }, + {L"bringAbove", 1, (void*)GuiObject_ScriptMethods::bringAbove }, + {L"bringBelow", 1, (void*)GuiObject_ScriptMethods::bringBelow }, + {L"isActive", 0, (void*)GuiObject_ScriptMethods::isActive}, + {L"getParent", 0, (void*)GuiObject_ScriptMethods::getParent}, + {L"getTopParent", 0, (void*)GuiObject_ScriptMethods::getTopParent}, + {L"getInterface", 1, (void*)GuiObject_ScriptMethods::getInterface}, + {L"onAction", 7, (void*)GuiObject_ScriptMethods::onAction}, +#ifdef WASABI_COMPILE_WNDMGR + {L"getParentLayout", 0, (void*)GuiObject_ScriptMethods::getParentLayout}, + {L"runModal", 0, (void*)GuiObject_ScriptMethods::runModal}, + {L"endModal", 1, (void*)GuiObject_ScriptMethods::endModal}, + {L"popParentLayout", 0, (void*)GuiObject_ScriptMethods::popParentLayout}, + {L"setStatusText", 2, (void*)GuiObject_ScriptMethods::setStatusText}, +#endif + {L"findObject", 1, (void*)GuiObject_ScriptMethods::findObject}, + {L"findObjectXY", 2, (void*)GuiObject_ScriptMethods::findObjectXY}, + {L"getName", 0, (void*)GuiObject_ScriptMethods::getName}, + {L"getAutoWidth", 0, (void*)GuiObject_ScriptMethods::getAutoWidth }, + {L"getAutoHeight", 0, (void*)GuiObject_ScriptMethods::getAutoHeight }, + {L"setFocus", 0, (void*)GuiObject_ScriptMethods::setFocus}, + {L"onGetFocus", 0, (void*)GuiObject_ScriptMethods::onGetFocus}, + {L"onKillFocus", 0, (void*)GuiObject_ScriptMethods::onKillFocus}, + {L"sendAction", 6, (void*)GuiObject_ScriptMethods::sendAction}, + {L"onAccelerator", 1, (void*)GuiObject_ScriptMethods::onAccelerator}, +#ifdef WASABI_COMPILE_CONFIG + {L"cfg_getInt", 0, (void*)GuiObject_ScriptMethods::cfgGetInt }, + {L"cfg_setInt", 1, (void*)GuiObject_ScriptMethods::cfgSetInt }, + {L"cfg_getFloat", 0, (void*)GuiObject_ScriptMethods::cfgGetFloat }, + {L"cfg_setFloat", 1, (void*)GuiObject_ScriptMethods::cfgSetFloat }, + {L"cfg_getString", 0, (void*)GuiObject_ScriptMethods::cfgGetString }, + {L"cfg_setString", 1, (void*)GuiObject_ScriptMethods::cfgSetString }, + {L"cfg_onDataChanged", 0, (void*)GuiObject_ScriptMethods::onCfgChanged }, + {L"cfg_getItemGuid", 0, (void*)GuiObject_ScriptMethods::cfgGetGuid}, + {L"cfg_getAttributeName", 0, (void*)GuiObject_ScriptMethods::cfgGetAttributeName}, +#endif + {L"onDragEnter", 0, (void*)GuiObject_ScriptMethods::onDragEnter }, + {L"onDragOver", 2, (void*)GuiObject_ScriptMethods::onDragOver}, + {L"onDragLeave", 0, (void*)GuiObject_ScriptMethods::onDragLeave}, +}; + +const wchar_t *GuiObjectScriptController::getClassName() { + return L"GuiObject"; +} + +const wchar_t *GuiObjectScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *GuiObjectScriptController::getAncestorController() { + return rootScriptObjectController;} + +int GuiObjectScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *GuiObjectScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID GuiObjectScriptController::getClassGuid() { + return guiObjectGuid; +} + +int GuiObjectScriptController::getInstantiable() { + return 1; +} + +ScriptObject *GuiObjectScriptController::instantiate() { + GuiObjectWnd *w = new GuiObjectWnd; + ASSERT(w != NULL); + return w->getScriptObject(); +} + +void GuiObjectScriptController::destroy(ScriptObject *o) { + GuiObjectWnd *w = static_cast<GuiObjectWnd *>(o->vcpu_getInterface(guiObjectWndGuid)); + ASSERT(w != NULL); + delete w; +} + +void *GuiObjectScriptController::encapsulate(ScriptObject *o) { + return static_cast<void *>(new GuiObjectI(o)); +} + +void GuiObjectScriptController::deencapsulate(void *o) { + delete static_cast<GuiObjectI *>(o); +} + +// ---------------------------------------------------------------------------------------------------------------------------------- + +// returns a new ScriptString object containing the xml id of this object +scriptVar GuiObject_ScriptMethods::getId(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + + if (g) + return MAKE_SCRIPT_STRING(g->guiobject_getId()); + + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar GuiObject_ScriptMethods::hide(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w) + w->setVisible(0); + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::show(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w) + w->setVisible(1); + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::isvisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w) return MAKE_SCRIPT_BOOLEAN(w->isVisible()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar GuiObject_ScriptMethods::getAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) return MAKE_SCRIPT_INT(g->guiobject_getAlpha()); + return MAKE_SCRIPT_INT(255); +} + +scriptVar GuiObject_ScriptMethods::setAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setAlpha(GET_SCRIPT_INT(a)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) return MAKE_SCRIPT_INT(g->guiobject_getActiveAlpha()); + return MAKE_SCRIPT_INT(255); +} + +scriptVar GuiObject_ScriptMethods::setActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setActiveAlpha(GET_SCRIPT_INT(a)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) return MAKE_SCRIPT_INT(g->guiobject_getInactiveAlpha()); + return MAKE_SCRIPT_INT(255); +} + +scriptVar GuiObject_ScriptMethods::setInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setInactiveAlpha(GET_SCRIPT_INT(a)); + RETURN_SCRIPT_VOID; +} + + +scriptVar GuiObject_ScriptMethods::onMouseMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onLeftButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onLeftButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onRightButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onRightButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onLeftButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onRightButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onMouseWheelUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, clicked, lines); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, clicked, lines); +} + +scriptVar GuiObject_ScriptMethods::onMouseWheelDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, clicked, lines); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, clicked, lines); +} + +scriptVar GuiObject_ScriptMethods::onEnterArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::onLeaveArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::setEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&v)); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *b = g->guiobject_getRootWnd(); + if (b) b->setEnabled(GET_SCRIPT_BOOLEAN(v)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *b = g->guiobject_getRootWnd(); + if (b) return MAKE_SCRIPT_BOOLEAN(b->isEnabled()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar GuiObject_ScriptMethods::onEnable(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, v); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, v); +} + +scriptVar GuiObject_ScriptMethods::onSetVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, v); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, v); +} + +scriptVar GuiObject_ScriptMethods::onResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS4(o, guiController, x, y, w, h); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT4(o, x, y, w, h); +} + +scriptVar GuiObject_ScriptMethods::resize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + ASSERT(SOM::isNumeric(&w)); + ASSERT(SOM::isNumeric(&h)); + GuiObject *go = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (go) { + int _x = SOM::makeInt(&x); + int _y = SOM::makeInt(&y); + int _w = SOM::makeInt(&w); + int _h = SOM::makeInt(&h); + ifc_window *b = go->guiobject_getRootWnd(); + if (b) b->resize(_x, _y, _w, _h); + go->guiobject_setGuiPosition(_x == NOCHANGE ? &_x : NULL, _y == NOCHANGE ? &_y : NULL, _w == NOCHANGE ? &_w : NULL, _h == NOCHANGE ? &_h : NULL, NULL, NULL, NULL, NULL); + if (b && b->getInterface(layoutGuid)) { + b->cascadeRepaint(); + ((Layout *)b->getInterface(layoutGuid))->savePosition(); + } + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::isMouseOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *b = g->guiobject_getRootWnd(); + POINT pt={GET_SCRIPT_INT(x), GET_SCRIPT_INT(y)}; + b->clientToScreen((int *)&pt.x, (int *)&pt.y); + return MAKE_SCRIPT_BOOLEAN(WASABI_API_WND->rootWndFromPoint(&pt) == b); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar GuiObject_ScriptMethods::getLeft(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + ifc_window *b = go->guiobject_getRootWnd(); + int r=0; + if (b && b->isInited()) { + POINT pt; + b->getPosition(&pt); + r = pt.x; + } else if (b && !b->isInited()) { + go->guiobject_getGuiPosition(&r, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + } + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::movingToTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) return MAKE_SCRIPT_BOOLEAN(g->guiobject_movingToTarget()); + RETURN_SCRIPT_ZERO; +} + +scriptVar GuiObject_ScriptMethods::cancelTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g && g->guiobject_movingToTarget()) g->guiobject_cancelTarget(); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::reverseTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_reverseTarget(GET_SCRIPT_INT(r)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getTop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + ifc_window *b = go->guiobject_getRootWnd(); + int r=0; + if (b && b->isInited()) { + POINT pt; + b->getPosition(&pt); + r = pt.y; + } else if (b && !b->isInited()) { + go->guiobject_getGuiPosition(NULL, &r, NULL, NULL, NULL, NULL, NULL, NULL); + } + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::getWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + ifc_window *b = go->guiobject_getRootWnd(); + int r=0; + if (b && b->isInited()) { + RECT rc; + b->getClientRect(&rc); + r = rc.right-rc.left; + } else if (b && !b->isInited()) { + go->guiobject_getGuiPosition(NULL, NULL, &r, NULL, NULL, NULL, NULL, NULL); + } + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::getHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + ifc_window *b = go->guiobject_getRootWnd(); + int r=0; + if (b && b->isInited()) { + RECT rc; + b->getClientRect(&rc); + r = rc.bottom-rc.top; + } else if (b && !b->isInited()) { + go->guiobject_getGuiPosition(NULL, NULL, NULL, &r, NULL, NULL, NULL, NULL); + } + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::setTargetX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetX(GET_SCRIPT_INT(x)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setTargetY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&y)); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetY(GET_SCRIPT_INT(y)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setTargetW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&w)); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetW(GET_SCRIPT_INT(w)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setTargetH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&h)); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetH(GET_SCRIPT_INT(h)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setTargetA(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&a)); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetA(GET_SCRIPT_INT(a)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setTargetSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&s)); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setTargetSpeed(GET_SCRIPT_FLOAT(s)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::gotoTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_gotoTarget(); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::bringToFront(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_bringToFront(); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::bringToBack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_bringToBack(); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::bringAbove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) { + SCRIPT_FUNCTION_INIT; + ASSERT(obj.data.odata != NULL); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_bringAbove((static_cast<GuiObject *>(GET_SCRIPT_OBJECT_AS(obj, guiObjectGuid)))); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::bringBelow(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) { + SCRIPT_FUNCTION_INIT; + ASSERT(obj.data.odata != NULL); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_bringBelow((static_cast<GuiObject *>(GET_SCRIPT_OBJECT_AS(obj, guiObjectGuid)))); + RETURN_SCRIPT_VOID; +} + + +scriptVar GuiObject_ScriptMethods::onTargetReached(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::setXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value) +{ + SCRIPT_FUNCTION_INIT; + XmlObject *x = static_cast<XmlObject*>(o->vcpu_getInterface(xmlObjectGuid)); + if (x) + x->setXmlParam(GET_SCRIPT_STRING(param), GET_SCRIPT_STRING(value)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param) { + SCRIPT_FUNCTION_INIT; + const wchar_t *rt = NULL; + XmlObject *x = static_cast<XmlObject*>(o->vcpu_getInterface(xmlObjectGuid)); + if (x) { + int r = x->getXmlParam(GET_SCRIPT_STRING(param)); + if (r != -1) + rt = x->getXmlParamValue(r); + } + if (rt == NULL) + rt = L""; // returning null in a string is kinda bad, y'know? + + return MAKE_SCRIPT_STRING(rt); +} + +scriptVar GuiObject_ScriptMethods::onStartup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::getGuiX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(&v, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, &v, NULL, NULL, NULL, NULL, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, &v, NULL, NULL, NULL, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, &v, NULL, NULL, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiRelatX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, &v, NULL, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiRelatY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, &v, NULL, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiRelatW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, &v, NULL); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getGuiRelatH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_getGuiPosition(NULL, NULL, NULL, NULL, NULL, NULL, NULL, &v); + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::clientToScreenX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(x); + w->clientToScreen(&v, NULL); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::clientToScreenY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(y); + w->clientToScreen(NULL, &v); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::clientToScreenW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *wn = g->guiobject_getRootWnd(); + if (wn != NULL) { + v = GET_SCRIPT_INT(w); + double rr = wn->getRenderRatio(); + v = (int)((double)(v) * rr); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::clientToScreenH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(h); + double rr = w->getRenderRatio(); + v = (int)((double)(v) * rr); + } + } + return MAKE_SCRIPT_INT(v); +} + + +scriptVar GuiObject_ScriptMethods::screenToClientX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(x); + w->screenToClient(&v, NULL); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::screenToClientY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(y); + w->screenToClient(NULL, &v); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::screenToClientW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar w) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *wn = g->guiobject_getRootWnd(); + if (wn != NULL) { + v = GET_SCRIPT_INT(w); + double rr = wn->getRenderRatio(); + v = (int)((double)(v) / rr); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::screenToClientH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar h) { + SCRIPT_FUNCTION_INIT; + int v=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + v = GET_SCRIPT_INT(h); + double rr = w->getRenderRatio(); + v = (int)((double)(v) / rr); + } + } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::isActive(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)))->guiobject_getRootWnd(); + if (w) return MAKE_SCRIPT_INT(w->isActive()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar GuiObject_ScriptMethods::getParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid))); + if (go) { + GuiObject *g = go->guiobject_getParent(); + ScriptObject *so = NULL; + if (g != NULL) + so = g->guiobject_getScriptObject(); + return MAKE_SCRIPT_OBJECT(so); + } + RETURN_SCRIPT_VOID; +} + +#ifdef WASABI_COMPILE_WNDMGR +scriptVar GuiObject_ScriptMethods::getParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid))); + if (go) { + Layout *l = go->guiobject_getParentLayout(); + return MAKE_SCRIPT_OBJECT(l ? l->getGuiObject()->guiobject_getScriptObject() : NULL); + } + RETURN_SCRIPT_VOID; +} +#endif + +scriptVar GuiObject_ScriptMethods::getTopParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid))); + if (go) { + GuiObject *l = go->guiobject_getTopParent(); + return MAKE_SCRIPT_OBJECT(l ? l->guiobject_getScriptObject() : NULL); + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::getAutoWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid))); + int v = 0; + if (go) { v = go->guiobject_getRootWnd()->getPreferences(SUGGESTED_W); if (v == AUTOWH) v = go->guiobject_getAutoWidth(); } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::getAutoHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *go = (static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid))); + int v = 0; + if (go) { v = go->guiobject_getRootWnd()->getPreferences(SUGGESTED_H); if (v == AUTOWH) v = go->guiobject_getAutoHeight(); } + return MAKE_SCRIPT_INT(v); +} + +scriptVar GuiObject_ScriptMethods::init(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar parentGroup) { + SCRIPT_FUNCTION_INIT; + ASSERT(parentGroup.data.odata != NULL); + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + Group *pg = static_cast<Group *>(GET_SCRIPT_OBJECT_AS(parentGroup, groupGuid)); + pg->addChild(g); + if (!g->guiobject_getRootWnd()->isInited()) + g->guiobject_getRootWnd()->init(pg); + } + RETURN_SCRIPT_VOID; +} + +#ifdef WASABI_COMPILE_WNDMGR +scriptVar GuiObject_ScriptMethods::runModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int r=0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) r = g->guiobject_runModal(); + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::endModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar retcode) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_endModal(GET_SCRIPT_INT(retcode)); + RETURN_SCRIPT_VOID; +} +#endif + +scriptVar GuiObject_ScriptMethods::setFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) { + ifc_window *w = g->guiobject_getRootWnd(); + if (w != NULL) { + w->setFocus(); + } + } + RETURN_SCRIPT_VOID; +} + +#ifdef WASABI_COMPILE_WNDMGR +scriptVar GuiObject_ScriptMethods::popParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_popParentLayout(); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setStatusText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar text, scriptVar overlay) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) + g->guiobject_setStatusText(GET_SCRIPT_STRING(text), GET_SCRIPT_INT(overlay)); + RETURN_SCRIPT_VOID; +} +#endif + +scriptVar GuiObject_ScriptMethods::findObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar id) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + ScriptObject *s = NULL; + if (g) { + GuiObject *o = g->guiobject_findObject(GET_SCRIPT_STRING(id)); + if (o != NULL) s = o->guiobject_getScriptObject(); + } + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar GuiObject_ScriptMethods::findObjectXY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + ScriptObject *s = NULL; + if (g) { + GuiObject *o = g->guiobject_findObjectXY(GET_SCRIPT_INT(x), GET_SCRIPT_INT(y)); + if (o != NULL) s = o->guiobject_getScriptObject(); + } + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar GuiObject_ScriptMethods::getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) + return MAKE_SCRIPT_STRING(g->guiobject_getName()); + + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar GuiObject_ScriptMethods::getMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int r = 0; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) r = g->guiobject_getMover(); + return MAKE_SCRIPT_INT(r); +} + +scriptVar GuiObject_ScriptMethods::setMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) { + SCRIPT_FUNCTION_INIT; + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + if (g) g->guiobject_setMover(GET_SCRIPT_INT(i)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::setDropTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar targ) { + GuiObject *g = static_cast<GuiObject*>(o->vcpu_getInterface(guiObjectGuid)); + const wchar_t *s = GET_SCRIPT_STRING(targ); + if (g) + g->guiobject_setDropTarget(s); + RETURN_SCRIPT_VOID; +} + +#ifdef WASABI_COMPILE_CONFIG +scriptVar GuiObject_ScriptMethods::cfgGetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + if (go) return MAKE_SCRIPT_INT(go->guiobject_getCfgInt()); + return MAKE_SCRIPT_INT(0); +} + +scriptVar GuiObject_ScriptMethods::cfgSetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT + ASSERT(SOM::isNumeric(&v)); + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + if (go) go->guiobject_setCfgInt(GET_SCRIPT_INT(v)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::cfgGetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + + if (go) + return MAKE_SCRIPT_STRING(go->guiobject_getCfgString()); + + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar GuiObject_ScriptMethods::cfgSetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + if (go) go->guiobject_setCfgString(GET_SCRIPT_STRING(v)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::cfgGetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + if (go) return MAKE_SCRIPT_FLOAT(go->guiobject_getCfgFloat()); + return MAKE_SCRIPT_FLOAT(0); +} + +scriptVar GuiObject_ScriptMethods::cfgSetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + if (go) go->guiobject_setCfgFloat(GET_SCRIPT_FLOAT(v)); + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::cfgGetGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + if (go) { + CfgItem *i = go->guiobject_getCfgItem(); + if (i != NULL) + { + GUID guid = i->getGuid(); + nsGUID::toCharW(guid, txt); + return MAKE_SCRIPT_STRING(txt); + } + } + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar GuiObject_ScriptMethods::cfgGetAttributeName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + + if (go) + return MAKE_SCRIPT_STRING(go->guiobject_getCfgAttrib()); + + return MAKE_SCRIPT_STRING(L""); +} +#endif + +scriptVar GuiObject_ScriptMethods::isMouseOverRect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + int r = 0; + if (go) { + ifc_window *w = go->guiobject_getRootWnd(); + if (w != NULL) { + RECT rc; + int x, y; + w->getWindowRect(&rc); + Wasabi::Std::getMousePos(&x, &y); + if (x >= rc.left && x <= rc.right && y >= rc.top && y <= rc.bottom) r = 1; + } + } + return MAKE_SCRIPT_BOOLEAN(r); +} + +#ifdef WASABI_COMPILE_CONFIG +scriptVar GuiObject_ScriptMethods::onCfgChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} +#endif + +scriptVar GuiObject_ScriptMethods::onChar(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, c); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, c); +} + +scriptVar GuiObject_ScriptMethods::onKeyDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, c); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, c); +} + +scriptVar GuiObject_ScriptMethods::onKeyUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, c); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, c); +} + +scriptVar GuiObject_ScriptMethods::onGetFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::onKillFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::sendAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2) { + SCRIPT_FUNCTION_INIT + GuiObject *go = static_cast<GuiObject *>(o->vcpu_getInterface(guiObjectGuid)); + int a = 0; + if (go) { + ifc_window *w = go->guiobject_getRootWnd(); + if (w!=NULL) { + a = w->onAction(GET_SCRIPT_STRING(action), GET_SCRIPT_STRING(param), GET_SCRIPT_INT(x), GET_SCRIPT_INT(y), GET_SCRIPT_INT(p1), GET_SCRIPT_INT(p2)); + } + } + return MAKE_SCRIPT_INT(a); +} + +scriptVar GuiObject_ScriptMethods::onAccelerator(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar accel) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, guiController, accel); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, accel); +} + +scriptVar GuiObject_ScriptMethods::onAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2, scriptVar source) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS7(o, guiController, action, param, x, y, p1, p2, source); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT7(o, action, param, x, y, p1, p2, source); +} + +#ifdef WASABI_COMPILE_CONFIG +int GuiObjectI::guiobject_getCfgInt() +{ + if (!cfgitem) + return 0; + return + cfgitem->getDataAsInt(cfgattrname); +} + +void GuiObjectI::guiobject_setCfgInt(int i) { + if (!cfgitem) return; + cfgitem->setDataAsInt(cfgattrname, i); +} + +float GuiObjectI::guiobject_getCfgFloat() { + if (!cfgitem) return 0; + return (float)cfgitem->getDataAsFloat(cfgattrname); +} + +void GuiObjectI::guiobject_setCfgFloat(float f) { + if (!cfgitem) return; + cfgitem->setDataAsFloat(cfgattrname, f); +} + +const wchar_t *GuiObjectI::guiobject_getCfgString() +{ + static StringW blah; + if (!cfgitem) return 0; + cfgitem->getData(cfgattrname, txt, 4096); + return txt; +} + +void GuiObjectI::guiobject_setCfgString(const wchar_t *s) +{ + if (!cfgitem) + return; + cfgitem->setData(cfgattrname, s); +} + +void GuiObjectI::setCfgAttr(const wchar_t *strvalue) +{ + ParamParser pp(strvalue); + if (pp.getNumItems() < 2) return; + + GUID g = nsGUID::fromCharW(pp.enumItem(0)); + if (g == INVALID_GUID) return; + CfgItem *i = WASABI_API_CONFIG->config_getCfgItemByGuid(g); + if (i == NULL) return; + cfgattrname = pp.enumItem(1); + guiobject_setCfgAttrib(i, cfgattrname); +} + +int GuiObjectI::guiobject_hasCfgAttrib() { + return (guiobject_getCfgItem() && guiobject_getCfgAttrib()); +} +#endif + +GuiObject *GuiObjectI::guiobject_findObject(const wchar_t *id) +{ + ifc_window *me = guiobject_getRootWnd(); + ifc_window *w = me->findWindow(id); + if (w != NULL) return w->getGuiObject(); + return NULL; +} + +GuiObject *GuiObjectI::guiobject_findObjectXY(int x, int y) { + ifc_window *me = guiobject_getRootWnd(); + POINT pt={x,y}; + me->clientToScreen((int *)&pt.x, (int *)&pt.y); + ifc_window *w = WASABI_API_WND->rootWndFromPoint(&pt); + if (w != NULL) return w->getGuiObject(); + return NULL; +} + +GuiObject *GuiObjectI::guiobject_findObjectByInterface(GUID interface_guid) { + ifc_window *me = guiobject_getRootWnd(); + ifc_window *w = me->findWindowByInterface(interface_guid); + if (w != NULL) return w->getGuiObject(); + return NULL; +} + +GuiObject *GuiObjectI::guiobject_findObjectByCallback(FindObjectCallback *cb) { + ifc_window *me = guiobject_getRootWnd(); + ifc_window *w = me->findWindowByCallback(cb); + if (w != NULL) return w->getGuiObject(); + return NULL; +} + +void GuiObjectI::guiobject_onAccelerator(const wchar_t *accel) +{ + GuiObject_ScriptMethods::onAccelerator(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(accel)); +} + +int GuiObjectI::guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source) +{ + GuiObject *gsourceobj = (source == NULL) ? NULL : source->getGuiObject(); + ScriptObject *sourceobj = (gsourceobj == NULL) ? NULL : gsourceobj->guiobject_getScriptObject(); + GuiObject_ScriptMethods::onAction(SCRIPT_CALL, guiobject_getScriptObject(), MAKE_SCRIPT_STRING(action), MAKE_SCRIPT_STRING(param), MAKE_SCRIPT_INT(x), MAKE_SCRIPT_INT(y), MAKE_SCRIPT_INT(p1), MAKE_SCRIPT_INT(p2), MAKE_SCRIPT_OBJECT(sourceobj)); + return 1; +} + +void GuiObjectI::guiobject_setTabOrder(int a) { + ifc_window *me = guiobject_getRootWnd(); + me->setTabOrder(a); +} + +void GuiObjectI::guiobject_onInit() { + // api_window *me = guiobject_getRootWnd(); + // nothing to do here anymore, for now + return; +} + +int GuiObjectI::guiobject_wantFocus() { + return wantfocus; +} + +void GuiObjectI::guiobject_setNoDoubleClick(int no) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + w->setNoDoubleClicks(no); +} + +void GuiObjectI::guiobject_setNoLeftClick(int no) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + w->setNoLeftClicks(no); +} + +void GuiObjectI::guiobject_setNoRightClick(int no) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + w->setNoRightClicks(no); +} + +void GuiObjectI::guiobject_setNoMouseMove(int no) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + w->setNoMouseMoves(no); +} + +void GuiObjectI::guiobject_setNoContextMenu(int no) { + ifc_window *w = guiobject_getRootWnd(); + if (w != NULL) + w->setNoContextMenus(no); +} + +scriptVar GuiObject_ScriptMethods::getInterface(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid) { + SCRIPT_FUNCTION_INIT; + int type=-1; + GUID _g = nsGUID::fromCharW(GET_SCRIPT_STRING(guid)); + void *i = o->vcpu_getInterface(_g, &type); + if (i != NULL && type == INTERFACE_SCRIPTOBJECT) { + return MAKE_SCRIPT_OBJECT(reinterpret_cast<ScriptObject*>(i)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar GuiObject_ScriptMethods::onDragEnter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar GuiObject_ScriptMethods::onDragOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2(o, guiController, x, y); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, x, y); +} + +scriptVar GuiObject_ScriptMethods::onDragLeave(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, guiController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} diff --git a/Src/Wasabi/api/script/objects/guiobj.h b/Src/Wasabi/api/script/objects/guiobj.h new file mode 100644 index 00000000..7997299d --- /dev/null +++ b/Src/Wasabi/api/script/objects/guiobj.h @@ -0,0 +1,423 @@ +#ifndef __GUIOBJ_H +#define __GUIOBJ_H + +#include <api/timer/timerclient.h> +#include <api/wnd/api_window.h> +#include <bfc/string/StringW.h> +#include <bfc/depview.h> +#include <api/skin/xmlobject.h> +#include <api/script/objects/guiobjectx.h> +#include <api/config/items/cfgitem.h> +#include <api/wnd/wndclass/guiobjwnd.h> +#include <api/script/objcontroller.h> + +class Layout; +class FindObjectCallback; +class ScriptObject; +class SkinCursor; + +#ifndef _REDOCK_STRUCT_DEFINED +#define _REDOCK_STRUCT_DEFINED +typedef struct +{ + Layout *l; + RECT original_rect; +} +redock_struct; +#endif + +class GuiObjectScriptController : public ScriptObjectControllerI +{ +public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + virtual int getInstantiable(); + +private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern GuiObjectScriptController *guiController; + +#define GUIOBJECT_SCRIPTPARENT RootObject + +#define TARGET_FROZEN 0 +#define TARGET_RUNNING 1 +#define TARGETTIMER_ID 0x1879 + +#define ANCHOR_NONE 0 +#define ANCHOR_LEFT 1 +#define ANCHOR_TOP 2 +#define ANCHOR_RIGHT 4 +#define ANCHOR_BOTTOM 8 + +class GuiObjectI; + +class GuiObjectTimer : public TimerClientDI +{ +public: + GuiObjectTimer() { obj = NULL; } + virtual ~GuiObjectTimer() { } + +public: + virtual void timerclient_timerCallback(int id); + virtual void setGuiObjectI(GuiObjectI *o) { obj = o; } + +private: + GuiObjectI *obj; +}; + +class GuiObjectI : public GuiObjectX, public DependentViewerTPtr<CfgItem> +{ +public: + GuiObjectI(ScriptObject *o); + virtual ~GuiObjectI(); + + virtual ifc_window *guiobject_getRootWnd(); + virtual void guiobject_setRootWnd(ifc_window *w); + virtual void guiobject_onInit(); + + virtual void guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh); + virtual void guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh); + virtual int guiobject_getAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor); + virtual void guiobject_setAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor); + virtual void guiobject_validateAnchorage(); + + virtual void guiobject_setParentGroup(Group *g); + virtual ScriptObject *guiobject_getScriptObject(); + virtual RootObject *guiobject_getRootObject(); + virtual Group *guiobject_getParentGroup(); + virtual GuiObject *guiobject_getParent(); + virtual void guiobject_setTabOrder(int a); + + virtual void guiobject_setId(const wchar_t *id); + virtual const wchar_t *guiobject_getId(); + + virtual void guiobject_setTargetX(int tx); + virtual void guiobject_setTargetY(int ty); + virtual void guiobject_setTargetW(int tw); + virtual void guiobject_setTargetH(int th); + virtual void guiobject_setTargetA(int th); + virtual void guiobject_setTargetSpeed(float s); + virtual void guiobject_gotoTarget(void); + virtual void guiobject_cancelTarget(); + virtual void guiobject_reverseTarget(int reverse); + + virtual int guiobject_getAutoWidth(); + virtual int guiobject_getAutoHeight(); + virtual int guiobject_movingToTarget(); + + virtual void guiobject_bringToFront(); + virtual void guiobject_bringToBack(); + virtual void guiobject_bringAbove(GuiObject *o); + virtual void guiobject_bringBelow(GuiObject *o); + + virtual void guiobject_setClickThrough(int ct); + virtual int guiobject_isClickThrough(); + + virtual void guiobject_setAutoSysMetricsX(int a); + virtual void guiobject_setAutoSysMetricsY(int a); + virtual void guiobject_setAutoSysMetricsW(int a); + virtual void guiobject_setAutoSysMetricsH(int a); + virtual int guiobject_getAutoSysMetricsX(); + virtual int guiobject_getAutoSysMetricsY(); + virtual int guiobject_getAutoSysMetricsW(); + virtual int guiobject_getAutoSysMetricsH(); + + virtual int guiobject_getRegionOp(); + virtual void guiobject_setRegionOp(int op); + virtual int guiobject_isRectRgn(); + virtual void guiobject_setRectRgn(int rrgn); + + virtual void guiobject_onLeftButtonDown(int x, int y); + virtual void guiobject_onLeftButtonUp(int x, int y); + virtual void guiobject_onRightButtonDown(int x, int y); + virtual void guiobject_onRightButtonUp(int x, int y); + virtual void guiobject_onLeftButtonDblClk(int x, int y); + virtual void guiobject_onRightButtonDblClk(int x, int y); + virtual int guiobject_onMouseWheelUp(int click, int lines); + virtual int guiobject_onMouseWheelDown(int click, int lines); + virtual void guiobject_onMouseMove(int x, int y); + virtual void guiobject_onEnterArea(); + virtual void guiobject_onLeaveArea(); + virtual void guiobject_onEnable(int en); + virtual void guiobject_setEnabled(int en); + virtual void guiobject_onResize(int x, int y, int w, int h); + virtual void guiobject_onSetVisible(int v); + virtual void guiobject_onTargetReached(); + virtual void guiobject_setAlpha(int a); + virtual void guiobject_setActiveAlpha(int a); + virtual void guiobject_setInactiveAlpha(int a); + virtual int guiobject_getAlpha(); + virtual int guiobject_getActiveAlpha(); + virtual int guiobject_getInactiveAlpha(); + virtual int guiobject_isActive(); + virtual void guiobject_onStartup(); + virtual int guiobject_setXmlParam(const wchar_t *param, const wchar_t *value); + virtual const wchar_t *guiobject_getXmlParam(const wchar_t *param); + virtual int guiobject_setXmlParamById(int id, const wchar_t *value); + virtual svc_xuiObject *guiobject_getXuiService(); + virtual void guiobject_setXuiService(svc_xuiObject *svc); + virtual waServiceFactory *guiobject_getXuiServiceFactory(); + virtual void guiobject_setXuiServiceFactory(waServiceFactory *fac); + virtual GuiObject *guiobject_getTopParent(); + virtual Layout *guiobject_getParentLayout(); + virtual int guiobject_runModal(); + virtual void guiobject_endModal(int retcode); + virtual void guiobject_popParentLayout(); + virtual void guiobject_registerStatusCB(GuiStatusCallback *cb); + virtual void guiobject_setStatusText(const wchar_t *txt, int overlay = FALSE); + virtual void guiobject_addAppCmds(AppCmds *commands); + virtual void guiobject_removeAppCmds(AppCmds *commands); + virtual void guiobject_pushCompleted(int max = 100); + virtual void guiobject_incCompleted(int add = 1); + virtual void guiobject_setCompleted(int pos); + virtual void guiobject_popCompleted(); + virtual GuiObject *guiobject_findObject(const wchar_t *id); + virtual GuiObject *guiobject_findObjectXY(int x, int y); // in client coordinates relative to this object + virtual GuiObject *guiobject_findObjectByInterface(GUID interface_guid); + virtual GuiObject *guiobject_findObjectByCallback(FindObjectCallback *cb); + virtual void guiobject_setMover(int m); + virtual int guiobject_getMover(); + virtual void guiobject_onCancelCapture(); + virtual void guiobject_onChar(wchar_t c); + virtual void guiobject_onKeyDown(int vkcode); + virtual void guiobject_onKeyUp(int vkcode); + + virtual FOURCC guiobject_getDropTarget(); + virtual void guiobject_setDropTarget(const wchar_t *strval); + + virtual void onTargetTimer(); +#ifdef USEAPPBAR + virtual int guiobject_getAppBar(); + virtual void guiobject_setAppBar(int en); + virtual void setAppBar(const wchar_t *en); +#endif + + virtual void guiobject_setCfgAttrib(CfgItem *item, const wchar_t *name); + + virtual int viewer_onEvent(CfgItem *item, int event, intptr_t param, void *ptr, size_t ptrlen); + virtual CfgItem *guiobject_getCfgItem(); + const wchar_t *guiobject_getCfgAttrib(); + + virtual int guiobject_getCfgInt(); + virtual void guiobject_setCfgInt(int i); + virtual float guiobject_getCfgFloat(); + virtual void guiobject_setCfgFloat(float f); + virtual const wchar_t *guiobject_getCfgString(); + virtual void guiobject_setCfgString(const wchar_t *s); + virtual int guiobject_hasCfgAttrib(); + + virtual const wchar_t *guiobject_getName(); + virtual void guiobject_onAccelerator(const wchar_t *accel); + virtual int guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source); + + virtual int guiobject_wantFocus(); + virtual void guiobject_setNoDoubleClick(int no); + virtual void guiobject_setNoLeftClick(int no); + virtual void guiobject_setNoRightClick(int no); + virtual void guiobject_setNoMouseMove(int no); + virtual void guiobject_setNoContextMenu(int no); + + virtual void guiobject_setCursor(const wchar_t *c); + + virtual int guiobject_wantTranslation(); + + virtual int guiobject_dragEnter(ifc_window *sourceWnd); + virtual int guiobject_dragOver(int x, int y, ifc_window *sourceWnd); + virtual int guiobject_dragLeave(ifc_window *sourceWnd); + +private: + void setCfgAttr(const wchar_t *strvalue); + virtual void dataChanged(); + + void snapAdjust(ifc_window *w, RECT *r, int way); + void infoMenu(GuiObject *o, int x, int y); + + int targetx, targety, targetw, targeth, targeta, targetspeed; + int start_time; + int targetstatus; + + void startTargetTimer(); + void stopTargetTimer(); + void ensureTimerOk(); + + int autosysmetricsx, autosysmetricsy, autosysmetricsw, autosysmetricsh; + + int startx, starty, startw, starth, starta; + + int in_area; + StringW guiobject_id; + int clickthrough; + StringW autonotify; + ifc_window *my_root_wnd; + ScriptObject *my_script_object; + GuiObjectTimer timer; + + int gui_x; + int gui_y; + int gui_w; + int gui_h; + int gui_rx; + int gui_ry; + int gui_rw; + int gui_rh; + int mover, moving; + FOURCC droptarget; + Group *p_group; + POINT anchor; + svc_xuiObject *xuisvc; + waServiceFactory *xuifac; + PtrList<StringW> notifylist; + int wantfocus; + int anchor_x1, anchor_y1, anchor_x2, anchor_y2, anchorage, anchorage_invalidated; + int reversetarget; + SkinCursor *cursor; + redock_struct redock; + int dodragcheck; + int m_lastnondocked_x, m_lastnondocked_y; +#ifdef USEAPPBAR + int m_dock_side; + int m_initial_dock_side; +#endif + StringW cfgattrname; + StringW cfgguid; + CfgItem *cfgitem; + int translate; +}; + + + + +class GuiObject_ScriptMethods +{ +public: + + static scriptVar getId(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar show(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar hide(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar isvisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar getActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setActiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar getInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setInactiveAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar resize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h); + static scriptVar onResize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar w, scriptVar h); + static scriptVar init(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar parentGroup); + static scriptVar bringToFront(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar bringToBack(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar bringAbove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar bringBelow(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar getIdVar(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onLeftButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onLeftButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onRightButtonDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onRightButtonUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onRightButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onLeftButtonDblClk(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onMouseWheelUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines); + static scriptVar onMouseWheelDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar clicked, scriptVar lines); + static scriptVar onMouseMove(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onEnterArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onLeaveArea(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onChar(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c); + static scriptVar onKeyDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c); + static scriptVar onKeyUp(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar c); + static scriptVar setEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar getEnabled(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onEnable(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar isMouseOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar getLeft(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getTop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setTargetX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar setTargetY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar setTargetW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar setTargetH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar setTargetA(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar setTargetSpeed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar gotoTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onTargetReached(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cancelTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar reverseTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar movingToTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value); + static scriptVar getXmlParam(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param); + static scriptVar onSetVisible(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar onStartup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiRelatX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiRelatY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiRelatW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getGuiRelatH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar isActive(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getTopParent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar runModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar endModal(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar retcode); + static scriptVar popParentLayout(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setStatusText(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar text, scriptVar overlay); + static scriptVar findObject(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar id); + static scriptVar findObjectXY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setMover(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar is); + static scriptVar setDropTarget(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar targ); + + static scriptVar onCfgChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cfgGetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cfgSetInt(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar cfgGetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cfgSetString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar cfgGetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cfgSetFloat(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar cfgGetGuid(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar cfgGetAttributeName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + static scriptVar clientToScreenX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x); + static scriptVar clientToScreenY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y); + static scriptVar clientToScreenW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x); + static scriptVar clientToScreenH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y); + static scriptVar screenToClientX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x); + static scriptVar screenToClientY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y); + static scriptVar screenToClientW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x); + static scriptVar screenToClientH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar y); + static scriptVar getAutoWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getAutoHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar setFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onGetFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onKillFocus(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onAccelerator(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar accel); + static scriptVar sendAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *obj, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2); + static scriptVar onAction(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar param, scriptVar x, scriptVar y, scriptVar p1, scriptVar p2, scriptVar source); + static scriptVar isMouseOverRect(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar getInterface(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar interfaceguid); + static scriptVar onDragEnter(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onDragOver(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar onDragLeave(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +extern const wchar_t guiobjectXuiStr[]; +extern char guiobjectXuiSvcName[]; +class GuiObjectXuiSvc : public XuiObjectSvc<GuiObjectWnd, guiobjectXuiStr, guiobjectXuiSvcName> {}; + + +#endif diff --git a/Src/Wasabi/api/script/objects/guiobject.h b/Src/Wasabi/api/script/objects/guiobject.h new file mode 100644 index 00000000..f4cccfa2 --- /dev/null +++ b/Src/Wasabi/api/script/objects/guiobject.h @@ -0,0 +1,855 @@ +#ifndef __GUIOBJECT_H +#define __GUIOBJECT_H + +#include <bfc/dispatch.h> +#include <bfc/nsguid.h> +#include <api/service/waservicefactory.h> + +class ifc_window; +class ScriptObject; // scriptobj.h +class GuiObject; // this file +class RootObject; // rootobj.h +class svc_xuiObject; // studio/services/svc_xuiobject.h +class GuiStatusCallback; +class AppCmds; +class CfgItem; +class FindObjectCallback; + +class Group; +class Layout; + +class GuiObject : public Dispatchable +{ +public: + + ifc_window *guiobject_getRootWnd(); + void guiobject_setRootWnd(ifc_window *w); + void guiobject_onInit(); + + void guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh); + void guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh); + int guiobject_getAnchoragePosition(int *x1, int *x2, int *y1, int *y2, int *anchor); // returns anchor invalidation flag + void guiobject_setAnchoragePosition(int *x1, int *x2, int *y1, int *y2, int *anchor); + void guiobject_validateAnchorage(); // clears up anchor invalidation flag + void guiobject_setParentGroup(Group *l); + ScriptObject *guiobject_getScriptObject(); + RootObject *guiobject_getRootObject(); + Group *guiobject_getParentGroup(); + GuiObject *guiobject_getParent(); + Layout *guiobject_getParentLayout(); + + int guiobject_wantAutoContextMenu(); + + void guiobject_setId(const wchar_t *id); + const wchar_t *guiobject_getId(); + + void guiobject_setTargetX(int tx); + void guiobject_setTargetY(int ty); + void guiobject_setTargetW(int tw); + void guiobject_setTargetH(int th); + void guiobject_setTargetA(int th); + void guiobject_setTargetSpeed(float s); + void guiobject_gotoTarget(void); + void guiobject_cancelTarget(); + void guiobject_reverseTarget(int reverse); + + int guiobject_getAutoWidth(); + int guiobject_getAutoHeight(); + int guiobject_movingToTarget(); + + void guiobject_bringToFront(); + void guiobject_bringToBack(); + void guiobject_bringAbove(GuiObject *o); + void guiobject_bringBelow(GuiObject *o); + + void guiobject_setClickThrough(int ct); + int guiobject_isClickThrough(); + + void guiobject_setAutoSysMetricsX(int a); + void guiobject_setAutoSysMetricsY(int a); + void guiobject_setAutoSysMetricsW(int a); + void guiobject_setAutoSysMetricsH(int a); + int guiobject_getAutoSysMetricsX(); + int guiobject_getAutoSysMetricsY(); + int guiobject_getAutoSysMetricsW(); + int guiobject_getAutoSysMetricsH(); + + void guiobject_setRegionOp(int op); + int guiobject_getRegionOp(); + void guiobject_setRectRgn(int rrgn); + int guiobject_isRectRgn(); + + void guiobject_setMover(int mover); + int guiobject_getMover(); + + FOURCC guiobject_getDropTarget(); + void guiobject_setDropTarget(const wchar_t *target); + + void guiobject_onLeftButtonDown(int x, int y); + void guiobject_onLeftButtonUp(int x, int y); + void guiobject_onRightButtonDown(int x, int y); + void guiobject_onRightButtonUp(int x, int y); + void guiobject_onLeftButtonDblClk(int x, int y); + void guiobject_onRightButtonDblClk(int x, int y); + void guiobject_onMouseMove(int x, int y); + int guiobject_onMouseWheelUp(int click, int lines); // Need to return 1 if handled + int guiobject_onMouseWheelDown(int click, int lines); // Need to return 1 if handled + void guiobject_onEnterArea(); + void guiobject_onLeaveArea(); + void guiobject_onCancelCapture(); + void guiobject_setEnabled(int en); + void guiobject_onEnable(int en); + void guiobject_onResize(int x, int y, int w, int h); + void guiobject_onSetVisible(int v); + void guiobject_onTargetReached(); + void guiobject_setAlpha(int a); + int guiobject_getAlpha(); + void guiobject_setActiveAlpha(int a); + int guiobject_getActiveAlpha(); + void guiobject_setInactiveAlpha(int a); + int guiobject_getInactiveAlpha(); + void guiobject_onStartup(); + const wchar_t *guiobject_getXmlParam(const wchar_t *param); + int guiobject_setXmlParam(const wchar_t *param, const wchar_t *value); + int guiobject_setXmlParamById(int id, const wchar_t *value); + GuiObject *guiobject_getTopParent(); +#ifdef WASABI_COMPILE_WNDMGR + int guiobject_runModal(); + void guiobject_endModal(int retcode); + void guiobject_popParentLayout(); + void guiobject_registerStatusCB(GuiStatusCallback *cb); + void guiobject_setStatusText(const wchar_t *text, int overlay=FALSE); + void guiobject_addAppCmds(AppCmds *commands); + void guiobject_removeAppCmds(AppCmds *commands); + void guiobject_pushCompleted(int max=100); + void guiobject_incCompleted(int add=1); + void guiobject_setCompleted(int pos); + void guiobject_popCompleted(); +#endif + + void guiobject_onChar(wchar_t c); + void guiobject_onKeyDown(int vkcode); + void guiobject_onKeyUp(int vkcode); + + svc_xuiObject *guiobject_getXuiService(); + void guiobject_setXuiService(svc_xuiObject *svc); + waServiceFactory *guiobject_getXuiServiceFactory(); + void guiobject_setXuiServiceFactory(waServiceFactory *fac); + GuiObject *guiobject_findObject(const wchar_t *id); + GuiObject *guiobject_findObjectXY(int x, int y); + GuiObject *guiobject_findObjectByInterface(GUID interface_guid); + GuiObject *guiobject_findObjectByCallback(FindObjectCallback *cb); + GuiObject *guiobject_findObjectChain(FindObjectCallback *cb, GuiObject *caller=NULL); + const wchar_t *guiobject_getName(); + +#ifdef WASABI_COMPILE_CONFIG + void guiobject_setCfgAttrib(CfgItem *i, const wchar_t *attrib); + CfgItem *guiobject_getCfgItem(); + const wchar_t *guiobject_getCfgAttrib(); + + int guiobject_getCfgInt(); + void guiobject_setCfgInt(int i); + float guiobject_getCfgFloat(); + void guiobject_setCfgFloat(float v); + const wchar_t *guiobject_getCfgString(); + void guiobject_setCfgString(const wchar_t *s); + int guiobject_hasCfgAttrib(); +#endif + + void guiobject_onGetFocus(); + void guiobject_onKillFocus(); + void guiobject_onAccelerator(const wchar_t *accel); + int guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source); + + int guiobject_wantFocus(); + + void guiobject_setNoDoubleClick(int no); + void guiobject_setNoLeftClick(int no); + void guiobject_setNoRightClick(int no); + void guiobject_setNoMouseMove(int no); + void guiobject_setNoContextMenu(int no); + + void guiobject_setCursor(const wchar_t *c); + + void guiobject_setAppBar(int enabled); + int guiobject_getAppBar(); + + int guiobject_wantTranslation(); + + int guiobject_dragEnter(ifc_window *sourceWnd); + int guiobject_dragOver(int x, int y, ifc_window *sourceWnd); + int guiobject_dragLeave(ifc_window *sourceWnd); + + enum { + GUI_GETGUIPOSITION=10, + GUI_GETANCHORAGEPOSITION=11, + GUI_SETGUIPOSITION=20, + GUI_SETANCHORAGEPOSITION=21, + GUI_VALIDATEANCHORAGE=22, + GUI_SETPARENTGROUP=30, + GUI_GETPARENTGROUP=40, + GUI_GETPARENT=45, + GUI_GETPARENTLAYOUT=50, + GUI_GETTOPPARENT=55, + GUI_GETROOTWND=60, + GUI_WANTAUTOCTXMENU=70, + GUI_SETID=80, + GUI_GETID=90, + GUI_SETTARGETX=100, + GUI_SETTARGETY=110, + GUI_SETTARGETW=120, + GUI_SETTARGETH=130, + GUI_SETTARGETA=140, + GUI_SETTARGETSPEED=150, + GUI_GOTOTARGET=160, + GUI_CANCELTARGET=161, + GUI_REVERSETARGET=162, + GUI_MOVINGTOTARGET=170, + GUI_GETAUTOWIDTH=180, + GUI_GETAUTOHEIGHT=190, + GUI_BRINGTOFRONT=200, + GUI_BRINGTOBACK=210, + GUI_BRINGBELOW=220, + GUI_BRINGABOVE=230, + GUI_SETCLICKTHROUGH=240, + GUI_ISCLICKTHROUGH=250, + GUI_SETAUTOSMX=260, + GUI_SETAUTOSMY=270, + GUI_SETAUTOSMW=280, + GUI_SETAUTOSMH=290, + GUI_GETAUTOSMX=300, + GUI_GETAUTOSMY=310, + GUI_GETAUTOSMW=320, + GUI_GETAUTOSMH=330, + GUI_ONLEFTBUTTONDOWN=340, + GUI_ONLEFTBUTTONUP=350, + GUI_ONRIGHTBUTTONDOWN=360, + GUI_ONRIGHTBUTTONUP=370, + GUI_ONLEFTBUTTONDBLCLK=380, + GUI_ONRIGHTBUTTONDBLCLK=390, + GUI_ONMOUSEWHEELUP=394, + GUI_ONMOUSEWHEELDOWN=396, + GUI_ONMOUSEMOVE=400, + GUI_ONENTERAREA=410, + GUI_ONLEAVEAREA=420, + GUI_ONENABLE=430, + GUI_SETENABLED=431, + GUI_ONRESIZE=440, + GUI_ONSETVISIBLE=450, + GUI_ONTARGETREACHED=460, + GUI_SETALPHA=470, + GUI_GETALPHA=480, + GUI_SETACTIVEALPHA=490, + GUI_GETACTIVEALPHA=500, + GUI_SETINACTIVEALPHA=510, + GUI_GETINACTIVEALPHA=520, + GUI_ONSTARTUP=530, + GUI_SETXMLPARAM=540, + GUI_SETXMLPARAMBYID=541, + GUI_GETXMLPARAM=542, +// GUI_ONUNKNOWNXMLPARAM=545, retired + GUI_SETROOTWND=550, + GUI_GETSCRIPTOBJECT=560, + GUI_GETROOTOBJECT=570, + GUI_RUNMODAL=580, + GUI_ENDMODAL=590, + GUI_SETXUISVC=600, + GUI_GETXUISVC=610, + GUI_POPPARENTLAYOUT=620, + GUI_SETREGIONOP=630, + GUI_GETREGIONOP=640, + GUI_SETRECTRGN=650, + GUI_ISRECTRGN=660, + GUI_REGISTERSTATUSCB=670, + GUI_SETSTATUSTXT=680, + GUI_ADDCTXTCMDS=690, + GUI_REMCTXTCMDS=700, + GUI_FINDOBJECT=800, + GUI_FINDOBJECTBYGUID=801, + GUI_FINDOBJECTBYCB=802, + GUI_FINDOBJECTCHAIN=803, + GUI_FINDOBJECTXY=804, + GUI_GETNAME=805, + GUI_GETMOVER=810, + GUI_SETMOVER=820, + GUI_GETDROPTARGET=830, + GUI_SETDROPTARGET=840, + GUI_ONCANCELCAPTURE=850, + GUI_SETCFGATTRIB=860, + GUI_GETCFGITEM=870, + GUI_GETCFGATTRIB=880, + GUI_SETCFGINT=890, + GUI_GETCFGINT=900, + GUI_GETCFGFLOAT=910, + GUI_SETCFGFLOAT=920, + GUI_SETCFGSTRING=930, + GUI_GETCFGSTRING=940, + GUI_HASATTRIB=950, + GUI_PUSHCOMPLETED=1000, + GUI_INCCOMPLETED=1010, + GUI_SETCOMPLETED=1020, + GUI_POPCOMPLETED=1030, + GUI_ONCHAR=1100, + GUI_ONKEYDOWN=1110, + GUI_ONKEYUP=1120, + GUI_ONGETFOCUS=1200, + GUI_ONKILLFOCUS=1210, + GUI_ONACCELERATOR=1300, + GUI_ONACTION=1400, + GUI_ONINIT=1500, + GUI_WANTFOCUS=1600, + GUI_SETNOMOUSEMOVE=1700, + GUI_SETNOLEFTCLICK=1800, + GUI_SETNORIGHTCLICK=1900, + GUI_SETNODOUBLECLICK=2000, + GUI_SETNOCONTEXTMENU=2100, + GUI_SETCURSOR=2200, + GUI_SETXUIFAC=2300, + GUI_GETXUIFAC=2310, + GUI_SETAPPBAR=2400, + GUI_GETAPPBAR=2410, + GUI_WANTTRANSLATION=2420, + GUI_DRAGENTER = 2430, + GUI_DRAGOVER = 2440, + GUI_DRAGLEAVE = 2450, + }; + + operator ScriptObject *() { return (this == NULL) ? NULL : guiobject_getScriptObject(); } + operator ifc_window *() { return (this == NULL) ? NULL : guiobject_getRootWnd(); } +}; + +inline void GuiObject::guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) { + _voidcall(GUI_GETGUIPOSITION, x, y, w, h, rx, ry, rw, rh); +} + +inline void GuiObject::guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh) { + _voidcall(GUI_SETGUIPOSITION, x, y, w, h, rx, ry, rw, rh); +} + +inline int GuiObject::guiobject_getAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) { + return _call(GUI_GETANCHORAGEPOSITION, 0, x1, y1, x2, y2, anchor); +} + +inline void GuiObject::guiobject_setAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor) { + _voidcall(GUI_SETANCHORAGEPOSITION, x1, y1, x2, y2, anchor); +} + +inline void GuiObject::guiobject_validateAnchorage() { + _voidcall(GUI_VALIDATEANCHORAGE); +} + +inline void GuiObject::guiobject_setParentGroup(Group *g) { + _voidcall(GUI_SETPARENTGROUP, g); +} + +inline Group *GuiObject::guiobject_getParentGroup() { + return _call(GUI_GETPARENTGROUP, (Group *)NULL); +} + +inline GuiObject *GuiObject::guiobject_getParent() { + return _call(GUI_GETPARENT, (GuiObject *)NULL); +} + +inline Layout *GuiObject::guiobject_getParentLayout() { + return _call(GUI_GETPARENTLAYOUT, (Layout*)NULL); +} + +inline GuiObject *GuiObject::guiobject_getTopParent() { + return _call(GUI_GETTOPPARENT, (GuiObject *)NULL); +} + +inline ifc_window *GuiObject::guiobject_getRootWnd() { + return _call(GUI_GETROOTWND, (ifc_window *)NULL); +} + +inline void GuiObject::guiobject_setRootWnd(ifc_window *r) { + _voidcall(GUI_SETROOTWND, r); +} + +inline int GuiObject::guiobject_wantAutoContextMenu() { + return _call(GUI_WANTAUTOCTXMENU, 0); +} + +inline void GuiObject::guiobject_setId(const wchar_t *id) { + _voidcall(GUI_SETID, id); +} + +inline const wchar_t *GuiObject::guiobject_getId() { + return _call(GUI_GETID, (const wchar_t *)NULL); +} + +inline void GuiObject::guiobject_setTargetX(int tx) { + _voidcall(GUI_SETTARGETX, tx); +} + +inline void GuiObject::guiobject_setTargetY(int ty) { + _voidcall(GUI_SETTARGETY, ty); +} + +inline void GuiObject::guiobject_setTargetW(int tw) { + _voidcall(GUI_SETTARGETW, tw); +} + +inline void GuiObject::guiobject_setTargetH(int th) { + _voidcall(GUI_SETTARGETH, th); +} + +inline void GuiObject::guiobject_setTargetA(int ta) { + _voidcall(GUI_SETTARGETA, ta); +} + +inline void GuiObject::guiobject_setTargetSpeed(float s) { + _voidcall(GUI_SETTARGETSPEED, s); +} + +inline void GuiObject::guiobject_gotoTarget(void) { + _voidcall(GUI_GOTOTARGET); +} + +inline void GuiObject::guiobject_cancelTarget() { + _voidcall(GUI_CANCELTARGET); +} + +inline int GuiObject::guiobject_getAutoWidth() { + return _call(GUI_GETAUTOWIDTH, 0); +} + +inline int GuiObject::guiobject_getAutoHeight() { + return _call(GUI_GETAUTOHEIGHT, 0); +} + +inline int GuiObject::guiobject_movingToTarget() { + return _call(GUI_MOVINGTOTARGET, 0); +} + +inline void GuiObject::guiobject_bringToFront() { + _voidcall(GUI_BRINGTOFRONT); +} + +inline void GuiObject::guiobject_bringToBack() { + _voidcall(GUI_BRINGTOBACK); +} + +inline void GuiObject::guiobject_bringAbove(GuiObject *o) { + _voidcall(GUI_BRINGABOVE, o); +} + +inline void GuiObject::guiobject_bringBelow(GuiObject *o) { + _voidcall(GUI_BRINGBELOW, o); +} + +inline void GuiObject::guiobject_setClickThrough(int ct) { + _voidcall(GUI_SETCLICKTHROUGH, ct); +} + +inline void GuiObject::guiobject_setRegionOp(int op) { + _voidcall(GUI_SETREGIONOP, op); +} + +inline int GuiObject::guiobject_getRegionOp() { + return _call(GUI_GETREGIONOP, 0); +} + +inline void GuiObject::guiobject_setRectRgn(int rrgn) { + _voidcall(GUI_SETRECTRGN, rrgn); +} + +inline int GuiObject::guiobject_isRectRgn() { + return _call(GUI_ISRECTRGN, 0); +} + +inline int GuiObject::guiobject_isClickThrough() { + return _call(GUI_ISCLICKTHROUGH, 0); +} + +inline void GuiObject::guiobject_setAutoSysMetricsX(int a) { + _voidcall(GUI_SETAUTOSMX, a); +} + +inline void GuiObject::guiobject_setAutoSysMetricsY(int a) { + _voidcall(GUI_SETAUTOSMY, a); +} + +inline void GuiObject::guiobject_setAutoSysMetricsW(int a) { + _voidcall(GUI_SETAUTOSMW, a); +} + +inline void GuiObject::guiobject_setAutoSysMetricsH(int a) { + _voidcall(GUI_SETAUTOSMH, a); +} + +inline int GuiObject::guiobject_getAutoSysMetricsX() { + return _call(GUI_GETAUTOSMX, 0); +} + +inline int GuiObject::guiobject_getAutoSysMetricsY() { + return _call(GUI_GETAUTOSMY, 0); +} + +inline int GuiObject::guiobject_getAutoSysMetricsW() { + return _call(GUI_GETAUTOSMW, 0); +} + +inline int GuiObject::guiobject_getAutoSysMetricsH() { + return _call(GUI_GETAUTOSMH, 0); +} + +inline void GuiObject::guiobject_onLeftButtonDown(int x, int y) { + _voidcall(GUI_ONLEFTBUTTONDOWN, x, y); +} + +inline void GuiObject::guiobject_onLeftButtonUp(int x, int y) { + _voidcall(GUI_ONLEFTBUTTONUP, x, y); +} + +inline void GuiObject::guiobject_onRightButtonDown(int x, int y) { + _voidcall(GUI_ONRIGHTBUTTONDOWN, x, y); +} + +inline void GuiObject::guiobject_onRightButtonUp(int x, int y) { + _voidcall(GUI_ONRIGHTBUTTONUP, x, y); +} + +inline void GuiObject::guiobject_onLeftButtonDblClk(int x, int y) { + _voidcall(GUI_ONLEFTBUTTONDBLCLK, x, y); +} + +inline void GuiObject::guiobject_onRightButtonDblClk(int x, int y) { + _voidcall(GUI_ONRIGHTBUTTONDBLCLK, x, y); +} + +inline int GuiObject::guiobject_onMouseWheelUp(int click, int lines) +{ + return _call(GUI_ONMOUSEWHEELUP, 0, click, lines); +} + +inline int GuiObject::guiobject_onMouseWheelDown(int click, int lines) +{ + return _call(GUI_ONMOUSEWHEELDOWN, 0, click, lines); +} + +inline void GuiObject::guiobject_onMouseMove(int x, int y) { + _voidcall(GUI_ONMOUSEMOVE, x, y); +} + +inline void GuiObject::guiobject_onEnterArea() { + _voidcall(GUI_ONENTERAREA); +} + +inline void GuiObject::guiobject_onLeaveArea() { + _voidcall(GUI_ONLEAVEAREA); +} + +inline void GuiObject::guiobject_onEnable(int en) { + _voidcall(GUI_ONENABLE, en); +} + +inline void GuiObject::guiobject_setEnabled(int en) { + _voidcall(GUI_SETENABLED, en); +} + +inline void GuiObject::guiobject_onResize(int x, int y, int w, int h) { + _voidcall(GUI_ONRESIZE, x, y, w, h); +} + +inline void GuiObject::guiobject_onSetVisible(int v) { + _voidcall(GUI_ONSETVISIBLE, v); +} + +inline void GuiObject::guiobject_onTargetReached() { + _voidcall(GUI_ONTARGETREACHED); +} + +inline void GuiObject::guiobject_setAlpha(int a) { + _voidcall(GUI_SETALPHA, a); +} + +inline int GuiObject::guiobject_getAlpha() { + return _call(GUI_GETALPHA, 255); +} + +inline void GuiObject::guiobject_setActiveAlpha(int a) { + _voidcall(GUI_SETACTIVEALPHA, a); +} + +inline int GuiObject::guiobject_getActiveAlpha() { + return _call(GUI_GETACTIVEALPHA, 255); +} + +inline void GuiObject::guiobject_setInactiveAlpha(int a) { + _voidcall(GUI_SETINACTIVEALPHA, a); +} + +inline int GuiObject::guiobject_getInactiveAlpha() { + return _call(GUI_GETINACTIVEALPHA, 255); +} + +inline void GuiObject::guiobject_onStartup() { + _voidcall(GUI_ONSTARTUP); +} + +inline int GuiObject::guiobject_setXmlParam(const wchar_t *param, const wchar_t *value) { + return _call(GUI_SETXMLPARAM, 0, param, value); +} + +inline int GuiObject::guiobject_setXmlParamById(int id, const wchar_t *value) { + return _call(GUI_SETXMLPARAMBYID, 0, id, value); +} + +inline const wchar_t *GuiObject::guiobject_getXmlParam(const wchar_t *param) { + return _call(GUI_GETXMLPARAM, (const wchar_t *)NULL, param); +} + +inline ScriptObject *GuiObject::guiobject_getScriptObject() { + return _call(GUI_GETSCRIPTOBJECT, (ScriptObject *)NULL); +} + +inline RootObject *GuiObject::guiobject_getRootObject() { + return _call(GUI_GETROOTOBJECT, (RootObject *)NULL); +} + +#ifdef WASABI_COMPILE_WNDMGR +inline int GuiObject::guiobject_runModal() { + return _call(GUI_RUNMODAL, 0); +} + +inline void GuiObject::guiobject_endModal(int retcode) { + _voidcall(GUI_ENDMODAL, retcode); +} +#endif + +inline svc_xuiObject *GuiObject::guiobject_getXuiService() { + return _call(GUI_GETXUISVC, (svc_xuiObject *)NULL); +} + +inline void GuiObject::guiobject_setXuiService(svc_xuiObject *svc) { + _voidcall(GUI_SETXUISVC, svc); +} + +inline waServiceFactory *GuiObject::guiobject_getXuiServiceFactory() { + return _call(GUI_GETXUIFAC, (waServiceFactory*)NULL); +} + +inline void GuiObject::guiobject_setXuiServiceFactory(waServiceFactory *fac) { + _voidcall(GUI_SETXUIFAC, fac); +} + +#ifdef WASABI_COMPILE_WNDMGR +inline void GuiObject::guiobject_popParentLayout() { + _voidcall(GUI_POPPARENTLAYOUT); +} + +inline void GuiObject::guiobject_setStatusText(const wchar_t *txt, int overlay) { + _voidcall(GUI_SETSTATUSTXT, txt, overlay); +} + +inline void GuiObject::guiobject_addAppCmds(AppCmds *commands) { + _voidcall(GUI_ADDCTXTCMDS, commands); +} + +inline void GuiObject::guiobject_removeAppCmds(AppCmds *commands) { + _voidcall(GUI_REMCTXTCMDS, commands); +} + +inline +void GuiObject::guiobject_pushCompleted(int max) { + _voidcall(GUI_PUSHCOMPLETED, max); +} +inline +void GuiObject::guiobject_incCompleted(int add) { + _voidcall(GUI_INCCOMPLETED, add); +} +inline +void GuiObject::guiobject_setCompleted(int pos) { + _voidcall(GUI_SETCOMPLETED, pos); +} + +inline +void GuiObject::guiobject_popCompleted() { + _voidcall(GUI_POPCOMPLETED); +} + +inline void GuiObject::guiobject_registerStatusCB(GuiStatusCallback *callback) { + _voidcall(GUI_REGISTERSTATUSCB, callback); +} +#endif + +inline GuiObject *GuiObject::guiobject_findObject(const wchar_t *id) { + return _call(GUI_FINDOBJECT, (GuiObject *)NULL, id); +} + +inline GuiObject *GuiObject::guiobject_findObjectXY(int x, int y) { + return _call(GUI_FINDOBJECTXY, (GuiObject *)NULL, x, y); +} + +inline GuiObject *GuiObject::guiobject_findObjectByInterface(GUID interface_guid) { + return _call(GUI_FINDOBJECTBYGUID, (GuiObject *)NULL, interface_guid); +} + +inline GuiObject *GuiObject::guiobject_findObjectByCallback(FindObjectCallback *cb) { + return _call(GUI_FINDOBJECTBYCB, (GuiObject *)NULL, cb); +} + +inline GuiObject *GuiObject::guiobject_findObjectChain(FindObjectCallback *cb, GuiObject *caller) { + return _call(GUI_FINDOBJECTCHAIN, (GuiObject *)NULL, cb, caller); +} + +inline const wchar_t *GuiObject::guiobject_getName() { + return _call(GUI_GETNAME, (const wchar_t *)NULL); +} + +inline int GuiObject::guiobject_getMover() { + return _call(GUI_GETMOVER, 0); +} + +inline void GuiObject::guiobject_setMover(int s) { + _voidcall(GUI_SETMOVER, s); +} + +inline FOURCC GuiObject::guiobject_getDropTarget() { + return _call(GUI_GETDROPTARGET, (FOURCC)0); +} + +inline void GuiObject::guiobject_setDropTarget(const wchar_t *target) { + _voidcall(GUI_SETDROPTARGET, target); +} + +inline void GuiObject::guiobject_onCancelCapture() { + _voidcall(GUI_ONCANCELCAPTURE); +} + +#ifdef WASABI_COMPILE_CONFIG +inline void GuiObject::guiobject_setCfgAttrib(CfgItem *item, const wchar_t *attr) { + _voidcall(GUI_SETCFGATTRIB, item, attr); +} + +inline CfgItem *GuiObject::guiobject_getCfgItem() { + return _call(GUI_GETCFGITEM, (CfgItem *)NULL); +} + +inline const wchar_t *GuiObject::guiobject_getCfgAttrib() { + return _call(GUI_GETCFGATTRIB, (const wchar_t *)NULL); +} + +inline int GuiObject::guiobject_getCfgInt() { + return _call(GUI_GETCFGINT, 0); +} + +inline void GuiObject::guiobject_setCfgInt(int i) { + _voidcall(GUI_SETCFGINT, i); +} + +inline float GuiObject::guiobject_getCfgFloat() { + return _call(GUI_GETCFGFLOAT, (float)0); +} + +inline void GuiObject::guiobject_setCfgFloat(float v) { + _voidcall(GUI_SETCFGFLOAT, v); +} + +inline const wchar_t *GuiObject::guiobject_getCfgString() { + return _call(GUI_GETCFGSTRING, (const wchar_t *)NULL); +} + +inline void GuiObject::guiobject_setCfgString(const wchar_t *s) { + _voidcall(GUI_SETCFGSTRING, s); +} + +inline int GuiObject::guiobject_hasCfgAttrib() { + return _call(GUI_HASATTRIB, 0); +} +#endif + +inline void GuiObject::guiobject_onChar(wchar_t c) { + _voidcall(GUI_ONCHAR, c); +} + +inline void GuiObject::guiobject_onKeyDown(int k) { + _voidcall(GUI_ONKEYDOWN, k); +} + +inline void GuiObject::guiobject_onKeyUp(int k) { + _voidcall(GUI_ONKEYUP, k); +} + +inline void GuiObject::guiobject_onGetFocus() { + _voidcall(GUI_ONGETFOCUS); +} + +inline void GuiObject::guiobject_onKillFocus() { + _voidcall(GUI_ONKILLFOCUS); +} + +inline void GuiObject::guiobject_onAccelerator(const wchar_t *accel) { + _voidcall(GUI_ONACCELERATOR, accel); +} + +inline int GuiObject::guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source) { + return _call(GUI_ONACTION, 0, action, param, x, y, p1, p2, data, datalen, source); +} + +inline void GuiObject::guiobject_onInit() { + _voidcall(GUI_ONINIT); +} + +inline int GuiObject::guiobject_wantFocus() { + return _call(GUI_WANTFOCUS, 0); +} + +inline void GuiObject::guiobject_setNoDoubleClick(int no) { + _voidcall(GUI_SETNODOUBLECLICK, no); +} + +inline void GuiObject::guiobject_setNoLeftClick(int no) { + _voidcall(GUI_SETNOLEFTCLICK, no); +} + +inline void GuiObject::guiobject_setNoRightClick(int no) { + _voidcall(GUI_SETNORIGHTCLICK, no); +} + +inline void GuiObject::guiobject_setNoMouseMove(int no) { + _voidcall(GUI_SETNOMOUSEMOVE, no); +} + +inline void GuiObject::guiobject_setNoContextMenu(int no) { + _voidcall(GUI_SETNOCONTEXTMENU, no); +} + +inline void GuiObject::guiobject_setCursor(const wchar_t *c) { + _voidcall(GUI_SETCURSOR, c); +} + +inline void GuiObject::guiobject_reverseTarget(int reverse) { + _voidcall(GUI_REVERSETARGET, reverse); +} + +inline void GuiObject::guiobject_setAppBar(int enabled) { + _voidcall(GUI_SETAPPBAR, enabled); +} + +inline int GuiObject::guiobject_getAppBar() { + return _call(GUI_GETAPPBAR, 0); +} + +inline int GuiObject::guiobject_wantTranslation() +{ + return _call(GUI_WANTTRANSLATION, (int)1); +} + +inline int GuiObject::guiobject_dragEnter(ifc_window *sourceWnd) +{ + return _call(GUI_DRAGENTER, (int)1, sourceWnd); +} + +inline int GuiObject::guiobject_dragOver(int x, int y, ifc_window *sourceWnd) +{ + return _call(GUI_DRAGOVER, (int)1, sourceWnd, x, y); +} + +inline int GuiObject::guiobject_dragLeave(ifc_window *sourceWnd) +{ + return _call(GUI_DRAGLEAVE, (int)1, sourceWnd); +} + +#endif diff --git a/Src/Wasabi/api/script/objects/guiobjectx.cpp b/Src/Wasabi/api/script/objects/guiobjectx.cpp new file mode 100644 index 00000000..44d0ca83 --- /dev/null +++ b/Src/Wasabi/api/script/objects/guiobjectx.cpp @@ -0,0 +1,131 @@ +#include <precomp.h> +#include "guiobjectx.h" + +#define CBCLASS GuiObjectX +START_DISPATCH; + CB(GUI_GETSCRIPTOBJECT, guiobject_getScriptObject); + CB(GUI_GETROOTWND, guiobject_getRootWnd); + CB(GUI_GETROOTOBJECT, guiobject_getRootObject); + VCB(GUI_SETROOTWND, guiobject_setRootWnd); + CB(GUI_SETXMLPARAM, guiobject_setXmlParam); + CB(GUI_SETXMLPARAMBYID, guiobject_setXmlParamById); + CB(GUI_GETXMLPARAM, guiobject_getXmlParam); + VCB(GUI_SETPARENTGROUP, guiobject_setParentGroup); + CB(GUI_GETPARENTGROUP, guiobject_getParentGroup); + CB(GUI_GETPARENT, guiobject_getParent); + CB(GUI_GETPARENTLAYOUT, guiobject_getParentLayout); + CB(GUI_GETTOPPARENT, guiobject_getTopParent); + VCB(GUI_GETGUIPOSITION, guiobject_getGuiPosition); + VCB(GUI_SETGUIPOSITION, guiobject_setGuiPosition); + CB(GUI_GETANCHORAGEPOSITION, guiobject_getAnchoragePosition); + VCB(GUI_SETANCHORAGEPOSITION, guiobject_setAnchoragePosition); + VCB(GUI_VALIDATEANCHORAGE, guiobject_validateAnchorage); + VCB(GUI_SETID, guiobject_setId); + CB(GUI_GETID, guiobject_getId); + VCB(GUI_SETTARGETX, guiobject_setTargetX); + VCB(GUI_SETTARGETY, guiobject_setTargetY); + VCB(GUI_SETTARGETW, guiobject_setTargetW); + VCB(GUI_SETTARGETH, guiobject_setTargetH); + VCB(GUI_SETTARGETA, guiobject_setTargetA); + VCB(GUI_SETTARGETSPEED, guiobject_setTargetSpeed); + VCB(GUI_GOTOTARGET, guiobject_gotoTarget); + VCB(GUI_CANCELTARGET, guiobject_cancelTarget); + VCB(GUI_REVERSETARGET, guiobject_reverseTarget); + CB(GUI_GETAUTOWIDTH, guiobject_getAutoWidth); + CB(GUI_GETAUTOHEIGHT, guiobject_getAutoHeight); + CB(GUI_MOVINGTOTARGET, guiobject_movingToTarget); + VCB(GUI_BRINGTOFRONT, guiobject_bringToFront); + VCB(GUI_BRINGTOBACK, guiobject_bringToBack); + VCB(GUI_BRINGABOVE, guiobject_bringAbove); + VCB(GUI_BRINGBELOW, guiobject_bringBelow); + VCB(GUI_SETCLICKTHROUGH, guiobject_setClickThrough); + CB(GUI_ISCLICKTHROUGH, guiobject_isClickThrough); + VCB(GUI_SETAUTOSMX, guiobject_setAutoSysMetricsX); + VCB(GUI_SETAUTOSMY, guiobject_setAutoSysMetricsY); + VCB(GUI_SETAUTOSMW, guiobject_setAutoSysMetricsW); + VCB(GUI_SETAUTOSMH, guiobject_setAutoSysMetricsH); + CB(GUI_GETAUTOSMX, guiobject_getAutoSysMetricsX); + CB(GUI_GETAUTOSMY, guiobject_getAutoSysMetricsY); + CB(GUI_GETAUTOSMW, guiobject_getAutoSysMetricsW); + CB(GUI_GETAUTOSMH, guiobject_getAutoSysMetricsH); + VCB(GUI_ONLEFTBUTTONDOWN, guiobject_onLeftButtonDown); + VCB(GUI_ONLEFTBUTTONUP, guiobject_onLeftButtonUp); + VCB(GUI_ONRIGHTBUTTONDOWN, guiobject_onRightButtonDown); + VCB(GUI_ONRIGHTBUTTONUP, guiobject_onRightButtonUp); + VCB(GUI_ONLEFTBUTTONDBLCLK, guiobject_onLeftButtonDblClk); + VCB(GUI_ONRIGHTBUTTONDBLCLK, guiobject_onRightButtonDblClk); + CB(GUI_ONMOUSEWHEELUP, guiobject_onMouseWheelUp); + CB(GUI_ONMOUSEWHEELDOWN, guiobject_onMouseWheelDown); + VCB(GUI_ONMOUSEMOVE, guiobject_onMouseMove); + VCB(GUI_ONENTERAREA, guiobject_onEnterArea); + VCB(GUI_ONLEAVEAREA, guiobject_onLeaveArea); + VCB(GUI_ONENABLE, guiobject_onEnable); + VCB(GUI_SETENABLED, guiobject_setEnabled); + VCB(GUI_ONRESIZE, guiobject_onResize); + VCB(GUI_ONSETVISIBLE, guiobject_onSetVisible); + VCB(GUI_ONTARGETREACHED, guiobject_onTargetReached); + VCB(GUI_SETALPHA, guiobject_setAlpha); + CB(GUI_GETALPHA, guiobject_getAlpha); + VCB(GUI_ONSTARTUP, guiobject_onStartup); + CB(GUI_GETXUISVC, guiobject_getXuiService); + VCB(GUI_SETXUISVC, guiobject_setXuiService); + CB(GUI_GETXUIFAC, guiobject_getXuiServiceFactory); + VCB(GUI_SETXUIFAC, guiobject_setXuiServiceFactory); + VCB(GUI_SETREGIONOP, guiobject_setRegionOp); + CB(GUI_GETREGIONOP, guiobject_getRegionOp); + VCB(GUI_SETRECTRGN, guiobject_setRectRgn); + CB(GUI_ISRECTRGN, guiobject_isRectRgn); + VCB(GUI_SETMOVER, guiobject_setMover); + CB(GUI_GETMOVER, guiobject_getMover); + CB(GUI_GETDROPTARGET, guiobject_getDropTarget); + VCB(GUI_ONCANCELCAPTURE, guiobject_onCancelCapture); + CB(GUI_ONACTION, guiobject_onAction); +#ifdef WASABI_COMPILE_CONFIG + CB(GUI_GETCFGITEM, guiobject_getCfgItem); + CB(GUI_GETCFGATTRIB, guiobject_getCfgAttrib); + VCB(GUI_SETCFGATTRIB, guiobject_setCfgAttrib); + VCB(GUI_SETCFGINT, guiobject_setCfgInt); + CB(GUI_GETCFGINT, guiobject_getCfgInt); + CB(GUI_GETCFGFLOAT, guiobject_getCfgFloat); + VCB(GUI_SETCFGFLOAT, guiobject_setCfgFloat); + VCB(GUI_SETCFGSTRING, guiobject_setCfgString); + CB(GUI_GETCFGSTRING, guiobject_getCfgString); + CB(GUI_HASATTRIB, guiobject_hasCfgAttrib); +#endif + VCB(GUI_ONCHAR, guiobject_onChar); + VCB(GUI_ONKEYDOWN, guiobject_onKeyDown); + VCB(GUI_ONKEYUP, guiobject_onKeyUp); + CB(GUI_FINDOBJECT, guiobject_findObject); + CB(GUI_FINDOBJECTBYGUID, guiobject_findObjectByInterface); + CB(GUI_FINDOBJECTBYCB, guiobject_findObjectByCallback); + CB(GUI_FINDOBJECTXY, guiobject_findObjectXY); + VCB(GUI_ONACCELERATOR, guiobject_onAccelerator); + VCB(GUI_ONINIT, guiobject_onInit); + CB(GUI_WANTFOCUS, guiobject_wantFocus); + VCB(GUI_SETNODOUBLECLICK, guiobject_setNoDoubleClick); + VCB(GUI_SETNOLEFTCLICK, guiobject_setNoLeftClick); + VCB(GUI_SETNORIGHTCLICK, guiobject_setNoRightClick); + VCB(GUI_SETNOMOUSEMOVE, guiobject_setNoMouseMove); + VCB(GUI_SETNOCONTEXTMENU, guiobject_setNoContextMenu); + VCB(GUI_SETCURSOR, guiobject_setCursor); +#ifdef WASABI_COMPILE_WNDMGR + CB(GUI_RUNMODAL, guiobject_runModal); + VCB(GUI_ENDMODAL, guiobject_endModal); + VCB(GUI_SETDROPTARGET, guiobject_setDropTarget); + VCB(GUI_SETSTATUSTXT, guiobject_setStatusText); + VCB(GUI_ADDCTXTCMDS, guiobject_addAppCmds); + VCB(GUI_REMCTXTCMDS, guiobject_removeAppCmds); + VCB(GUI_PUSHCOMPLETED, guiobject_pushCompleted); + VCB(GUI_INCCOMPLETED, guiobject_incCompleted); + VCB(GUI_SETCOMPLETED, guiobject_setCompleted); + VCB(GUI_POPCOMPLETED, guiobject_popCompleted); + VCB(GUI_REGISTERSTATUSCB, guiobject_registerStatusCB); + VCB(GUI_POPPARENTLAYOUT, guiobject_popParentLayout); +#endif + VCB(GUI_SETAPPBAR, guiobject_setAppBar); + CB(GUI_GETAPPBAR, guiobject_getAppBar); + CB(GUI_WANTTRANSLATION, guiobject_wantTranslation); + CB(GUI_DRAGENTER, guiobject_dragEnter); + CB(GUI_DRAGOVER, guiobject_dragOver); + CB(GUI_DRAGLEAVE, guiobject_dragLeave); +END_DISPATCH; diff --git a/Src/Wasabi/api/script/objects/guiobjectx.h b/Src/Wasabi/api/script/objects/guiobjectx.h new file mode 100644 index 00000000..c840476c --- /dev/null +++ b/Src/Wasabi/api/script/objects/guiobjectx.h @@ -0,0 +1,177 @@ +#ifndef NULLSOFT_WASABI_GUIOBJECTX_H +#define NULLSOFT_WASABI_GUIOBJECTX_H + +#include <wasabicfg.h> +#include <api/script/objects/guiobject.h> + +class GuiObjectX : public GuiObject +{ +public: + virtual ~GuiObjectX() {} + + virtual ifc_window *guiobject_getRootWnd()=0; + virtual void guiobject_setRootWnd(ifc_window *w)=0; + virtual void guiobject_onInit()=0; + + virtual void guiobject_getGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh)=0; + virtual void guiobject_setGuiPosition(int *x, int *y, int *w, int *h, int *rx, int *ry, int *rw, int *rh)=0; + virtual int guiobject_getAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor)=0; + virtual void guiobject_setAnchoragePosition(int *x1, int *y1, int *x2, int *y2, int *anchor)=0; + virtual void guiobject_validateAnchorage()=0; + + virtual void guiobject_setParentGroup(Group *g)=0; + virtual ScriptObject *guiobject_getScriptObject()=0; + virtual RootObject *guiobject_getRootObject()=0; + virtual Group *guiobject_getParentGroup()=0; + virtual GuiObject *guiobject_getParent()=0; + virtual void guiobject_setTabOrder(int a)=0; + + virtual void guiobject_setId(const wchar_t *id)=0; + virtual const wchar_t *guiobject_getId()=0; + + virtual void guiobject_setTargetX(int tx)=0; + virtual void guiobject_setTargetY(int ty)=0; + virtual void guiobject_setTargetW(int tw)=0; + virtual void guiobject_setTargetH(int th)=0; + virtual void guiobject_setTargetA(int th)=0; + virtual void guiobject_setTargetSpeed(float s)=0; + virtual void guiobject_gotoTarget(void)=0; + virtual void guiobject_cancelTarget()=0; + virtual void guiobject_reverseTarget(int reverse)=0; + + virtual int guiobject_getAutoWidth()=0; + virtual int guiobject_getAutoHeight()=0; + virtual int guiobject_movingToTarget()=0; + + virtual void guiobject_bringToFront()=0; + virtual void guiobject_bringToBack()=0; + virtual void guiobject_bringAbove(GuiObject *o)=0; + virtual void guiobject_bringBelow(GuiObject *o)=0; + + virtual void guiobject_setClickThrough(int ct)=0; + virtual int guiobject_isClickThrough()=0; + + virtual void guiobject_setAutoSysMetricsX(int a)=0; + virtual void guiobject_setAutoSysMetricsY(int a)=0; + virtual void guiobject_setAutoSysMetricsW(int a)=0; + virtual void guiobject_setAutoSysMetricsH(int a)=0; + virtual int guiobject_getAutoSysMetricsX()=0; + virtual int guiobject_getAutoSysMetricsY()=0; + virtual int guiobject_getAutoSysMetricsW()=0; + virtual int guiobject_getAutoSysMetricsH()=0; + + virtual int guiobject_getRegionOp()=0; + virtual void guiobject_setRegionOp(int op)=0; + virtual int guiobject_isRectRgn()=0; + virtual void guiobject_setRectRgn(int rrgn)=0; + + virtual void guiobject_onLeftButtonDown(int x, int y)=0; + virtual void guiobject_onLeftButtonUp(int x, int y)=0; + virtual void guiobject_onRightButtonDown(int x, int y)=0; + virtual void guiobject_onRightButtonUp(int x, int y)=0; + virtual void guiobject_onLeftButtonDblClk(int x, int y)=0; + virtual void guiobject_onRightButtonDblClk(int x, int y)=0; + virtual int guiobject_onMouseWheelUp(int click, int lines)=0; + virtual int guiobject_onMouseWheelDown(int click, int lines)=0; + virtual void guiobject_onMouseMove(int x, int y)=0; + virtual void guiobject_onEnterArea()=0; + virtual void guiobject_onLeaveArea()=0; + virtual void guiobject_onEnable(int en)=0; + virtual void guiobject_setEnabled(int en)=0; + virtual void guiobject_onResize(int x, int y, int w, int h)=0; + virtual void guiobject_onSetVisible(int v)=0; + virtual void guiobject_onTargetReached()=0; + virtual void guiobject_setAlpha(int a)=0; + virtual void guiobject_setActiveAlpha(int a)=0; + virtual void guiobject_setInactiveAlpha(int a)=0; + virtual int guiobject_getAlpha()=0; + virtual int guiobject_getActiveAlpha()=0; + virtual int guiobject_getInactiveAlpha()=0; + virtual int guiobject_isActive()=0; + virtual void guiobject_onStartup()=0; + virtual int guiobject_setXmlParam(const wchar_t *param, const wchar_t *value)=0; + virtual const wchar_t *guiobject_getXmlParam(const wchar_t *param)=0; + virtual int guiobject_setXmlParamById(int id, const wchar_t *value)=0; + virtual svc_xuiObject *guiobject_getXuiService()=0; + virtual void guiobject_setXuiService(svc_xuiObject *svc)=0; + virtual waServiceFactory *guiobject_getXuiServiceFactory()=0; + virtual void guiobject_setXuiServiceFactory(waServiceFactory *fac)=0; + virtual GuiObject *guiobject_getTopParent()=0; +#ifdef WASABI_COMPILE_WNDMGR + virtual Layout *guiobject_getParentLayout()=0; + virtual int guiobject_runModal()=0; + virtual void guiobject_endModal(int retcode)=0; + virtual void guiobject_popParentLayout()=0; + virtual void guiobject_registerStatusCB(GuiStatusCallback *cb)=0; + virtual void guiobject_setStatusText(const wchar_t *txt, int overlay = FALSE)=0; + virtual void guiobject_addAppCmds(AppCmds *commands)=0; + virtual void guiobject_removeAppCmds(AppCmds *commands)=0; + virtual void guiobject_pushCompleted(int max = 100)=0; + virtual void guiobject_incCompleted(int add = 1)=0; + virtual void guiobject_setCompleted(int pos)=0; + virtual void guiobject_popCompleted()=0; +#endif + virtual GuiObject *guiobject_findObject(const wchar_t *id)=0; + virtual GuiObject *guiobject_findObjectXY(int x, int y)=0; // in client coordinates relative to this object + virtual GuiObject *guiobject_findObjectByInterface(GUID interface_guid)=0; + virtual GuiObject *guiobject_findObjectByCallback(FindObjectCallback *cb)=0; + virtual void guiobject_setMover(int m)=0; + virtual int guiobject_getMover()=0; + virtual void guiobject_onCancelCapture()=0; + virtual void guiobject_onChar(wchar_t c)=0; + virtual void guiobject_onKeyDown(int vkcode)=0; + virtual void guiobject_onKeyUp(int vkcode)=0; + + virtual FOURCC guiobject_getDropTarget()=0; + virtual void guiobject_setDropTarget(const wchar_t *strval)=0; + + virtual void onTargetTimer()=0; +#ifdef USEAPPBAR + virtual int guiobject_getAppBar()=0; + virtual void guiobject_setAppBar(int en)=0; + virtual void setAppBar(const wchar_t *en)=0; +#endif + +#ifdef WASABI_COMPILE_CONFIG + virtual void guiobject_setCfgAttrib(CfgItem *item, const wchar_t *name)=0; + + virtual CfgItem *guiobject_getCfgItem()=0; + virtual const wchar_t *guiobject_getCfgAttrib()=0; + + virtual int guiobject_getCfgInt()=0; + virtual void guiobject_setCfgInt(int i)=0; + virtual float guiobject_getCfgFloat()=0; + virtual void guiobject_setCfgFloat(float f)=0; + virtual const wchar_t *guiobject_getCfgString()=0; + virtual void guiobject_setCfgString(const wchar_t *s)=0; + virtual int guiobject_hasCfgAttrib()=0; +#endif + + virtual const wchar_t *guiobject_getName()=0; + virtual void guiobject_onAccelerator(const wchar_t *accel)=0; + virtual int guiobject_onAction(const wchar_t *action, const wchar_t *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, ifc_window *source)=0; + + virtual int guiobject_wantFocus()=0; + virtual void guiobject_setNoDoubleClick(int no)=0; + virtual void guiobject_setNoLeftClick(int no)=0; + virtual void guiobject_setNoRightClick(int no)=0; + virtual void guiobject_setNoMouseMove(int no)=0; + virtual void guiobject_setNoContextMenu(int no)=0; + + virtual void guiobject_setCursor(const wchar_t *c)=0; + virtual int guiobject_wantTranslation()=0; + + virtual int guiobject_dragEnter(ifc_window *sourceWnd)=0; + virtual int guiobject_dragOver(int x, int y, ifc_window *sourceWnd)=0; + virtual int guiobject_dragLeave(ifc_window *sourceWnd)=0; + +protected: + RECVS_DISPATCH; + +}; + + + + + +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/rootobj.cpp b/Src/Wasabi/api/script/objects/rootobj.cpp new file mode 100644 index 00000000..8791f430 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobj.cpp @@ -0,0 +1,42 @@ +#include <api/script/objcontroller.h> +#include "rootobj.h" +#include <api/script/objects/rootobject.h> +#include "api.h" +#include <api/script/scriptguid.h> + +RootObjectInstance::RootObjectInstance() +{ + ASSERT(WASABI_API_MAKI != 0); + rootobject_init(); +} + +RootObjectInstance::~RootObjectInstance() +{ + WASABI_API_MAKI->maki_deencapsulate(rootObjectGuid, my_root_object); +} + +RootObject *RootObjectInstance::getRootObject() { + return my_root_object; +} + +ScriptObject *RootObjectInstance::getScriptObject() { + return &my_script_object; +} + +const wchar_t *RootObjectInstance::getClassName() +{ + return my_root_object->rootobject_getClassName(); +} + +void RootObjectInstance::notify(const wchar_t *s, const wchar_t *t, int u, int v) { + my_root_object->rootobject_notify(s, t, u, v); +} + +void RootObjectInstance::rootobject_init() +{ + my_root_object = static_cast<RootObject *>(WASABI_API_MAKI->maki_encapsulate(rootObjectGuid, &my_script_object)); // creates an encapsulated RootObject + my_script_object.vcpu_setInterface(rootObjectInstanceGuid, static_cast<void *>(this)); + my_script_object.vcpu_setClassName(L"Object"); + my_script_object.vcpu_setController(WASABI_API_MAKI->maki_getController(rootObjectGuid)); +} + diff --git a/Src/Wasabi/api/script/objects/rootobj.h b/Src/Wasabi/api/script/objects/rootobj.h new file mode 100644 index 00000000..4a44f8c2 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobj.h @@ -0,0 +1,40 @@ +#ifndef __ROOTOBJ_H +#define __ROOTOBJ_H + +#include <bfc/dispatch.h> +#include <api/script/objects/rootobjcbi.h> +#include <api/script/scriptobji.h> + +class ScriptObject; +class ScriptObjectI; +class RootObject; + +// RootObjectInstance::this == RootObjectInstance::getScriptObject()->vcpu_getInterface(rootObjectInstanceGuid); +// {F6D49468-4036-41a1-9683-C372416AD31B} +static const GUID rootObjectInstanceGuid = +{ 0xf6d49468, 0x4036, 0x41a1, { 0x96, 0x83, 0xc3, 0x72, 0x41, 0x6a, 0xd3, 0x1b } }; + +// Instantiate this class to create an object from which you can trap notify events, or inherit from +// it if you want to implement your own descendant of script class 'Object' (see GuiObjectWnd) +class RootObjectInstance : public RootObjectCallbackI +{ +public: + + RootObjectInstance(); + virtual ~RootObjectInstance(); + + virtual RootObject *getRootObject(); + virtual ScriptObject *getScriptObject(); + + virtual void rootobjectcb_onNotify(const wchar_t *a, const wchar_t *b, int c, int d) {}; + virtual const wchar_t *getClassName(); + virtual void notify(const wchar_t *s, const wchar_t *t, int u, int v); + + private: + void rootobject_init(); + ScriptObjectI my_script_object; + RootObject * my_root_object; +}; + + +#endif diff --git a/Src/Wasabi/api/script/objects/rootobjcb.cpp b/Src/Wasabi/api/script/objects/rootobjcb.cpp new file mode 100644 index 00000000..212a943e --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcb.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:33 2003] +// +// File : rootobjcb.cpp +// Class : RootObjectCallback +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include <precomp.h> +#include "rootobjcb.h" + + diff --git a/Src/Wasabi/api/script/objects/rootobjcb.h b/Src/Wasabi/api/script/objects/rootobjcb.h new file mode 100644 index 00000000..9e3f1e3c --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcb.h @@ -0,0 +1,40 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:33 2003] +// +// File : rootobjcb.h +// Class : RootObjectCallback +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __ROOTOBJECTCALLBACK_H +#define __ROOTOBJECTCALLBACK_H + +#include <bfc/dispatch.h> +#include <bfc/common.h> + + + +// ---------------------------------------------------------------------------- + +class RootObjectCallback: public Dispatchable { + protected: + RootObjectCallback() {} + ~RootObjectCallback() {} + public: + void rootobjectcb_onNotify(const wchar_t *a, const wchar_t *b, int c, int d); + + protected: + enum { + ROOTOBJECTCALLBACK_ROOTOBJECTCB_ONNOTIFY = 10, + }; +}; + +// ---------------------------------------------------------------------------- + +inline void RootObjectCallback::rootobjectcb_onNotify(const wchar_t *a, const wchar_t *b, int c, int d) { + _voidcall(ROOTOBJECTCALLBACK_ROOTOBJECTCB_ONNOTIFY, a, b, c, d); +} + +// ---------------------------------------------------------------------------- + +#endif // __ROOTOBJECTCALLBACK_H diff --git a/Src/Wasabi/api/script/objects/rootobjcbi.cpp b/Src/Wasabi/api/script/objects/rootobjcbi.cpp new file mode 100644 index 00000000..9545e59e --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcbi.cpp @@ -0,0 +1,3 @@ +#include <precomp.h> +#include "rootobjcb.h" + diff --git a/Src/Wasabi/api/script/objects/rootobjcbi.h b/Src/Wasabi/api/script/objects/rootobjcbi.h new file mode 100644 index 00000000..14dd63ad --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcbi.h @@ -0,0 +1,15 @@ +#ifndef __ROOTOBJCB_H +#define __ROOTOBJCB_H + +//<?<autoheader/> +#include "rootobjcb.h" +#include "rootobjcbx.h" + +//?> + +class NOVTABLE RootObjectCallbackI : public RootObjectCallbackX { + public: + DISPATCH(10) virtual void rootobjectcb_onNotify(const wchar_t *a, const wchar_t *b, int c, int d)=0; +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/rootobjcbx.cpp b/Src/Wasabi/api/script/objects/rootobjcbx.cpp new file mode 100644 index 00000000..84ce169c --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcbx.cpp @@ -0,0 +1,20 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:33 2003] +// +// File : rootobjcbx.cpp +// Class : RootObjectCallback +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include "rootobjcbx.h" +#include "rootobjcbi.h" + +#ifdef CBCLASS +#undef CBCLASS +#endif + +#define CBCLASS RootObjectCallbackX +START_DISPATCH; + VCB(ROOTOBJECTCALLBACK_ROOTOBJECTCB_ONNOTIFY, rootobjectcb_onNotify); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/script/objects/rootobjcbx.h b/Src/Wasabi/api/script/objects/rootobjcbx.h new file mode 100644 index 00000000..eb07530c --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcbx.h @@ -0,0 +1,29 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Thu May 15 21:06:33 2003] +// +// File : rootobjcbx.h +// Class : RootObjectCallback +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __ROOTOBJECTCALLBACKX_H +#define __ROOTOBJECTCALLBACKX_H + +#include "rootobjcb.h" + + + + +// ---------------------------------------------------------------------------- + +class RootObjectCallbackX : public RootObjectCallback { + protected: + RootObjectCallbackX() {} + public: + virtual void rootobjectcb_onNotify(const wchar_t *a, const wchar_t *b, int c, int d)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __ROOTOBJECTCALLBACKX_H diff --git a/Src/Wasabi/api/script/objects/rootobjcontroller.cpp b/Src/Wasabi/api/script/objects/rootobjcontroller.cpp new file mode 100644 index 00000000..94a6f396 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcontroller.cpp @@ -0,0 +1,81 @@ +#include "precomp.h" +//<?#include "<class data="implementationheader"/>" +#include "rootobjcontroller.h" +//?> + +#include <api/script/objects/rootobj.h> +#include <api/script/objects/rootobjecti.h> + +RootScriptObjectController _rootScriptObjectController; +RootScriptObjectController *rootScriptObjectController = &_rootScriptObjectController; + +// -- Functions table ------------------------------------- +function_descriptor_struct RootScriptObjectController::exportedFunction[] = { + {L"getClassName", 0, (void*)RootObject_ScriptMethods::getClassName }, + {L"notify", 4, (void*)RootObject_ScriptMethods::notify }, + {L"onNotify", 4, (void*)RootObject_ScriptMethods::onNotify }, +}; + +const wchar_t *RootScriptObjectController::getClassName() { + return L"Object"; +} + +const wchar_t *RootScriptObjectController::getAncestorClassName() { + return NULL; +} + +int RootScriptObjectController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *RootScriptObjectController::getExportedFunctions() { + return exportedFunction; +} + +GUID RootScriptObjectController::getClassGuid() { + return rootObjectGuid; +} + +ScriptObject *RootScriptObjectController::instantiate() { + RootObjectInstance *o = new RootObjectInstance; + ASSERT(o != NULL); + return o->getScriptObject(); +} + +void RootScriptObjectController::destroy(ScriptObject *o) { + RootObjectInstance *obj = static_cast<RootObjectInstance *>(o->vcpu_getInterface(rootObjectGuid)); + ASSERT(obj != NULL); + delete obj; +} + +void RootScriptObjectController::deencapsulate(void *o) { + RootObjectI *obj = static_cast<RootObjectI *>(o); + delete obj; +} + +void *RootScriptObjectController::encapsulate(ScriptObject *o) { + return new RootObjectI(o); +} + +// ------------------------------------------------------------------------------------------------------------------------------------- +// Script Methods and Events for RootObject (Object) +// ------------------------------------------------------------------------------------------------------------------------------------- + +scriptVar RootObject_ScriptMethods::getClassName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(o->vcpu_getClassName()); +} + +scriptVar RootObject_ScriptMethods::onNotify(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s, scriptVar s2, scriptVar i1, scriptVar i2) { + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS4(o, rootScriptObjectController, s, s2, i1, i2); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT4(o, s, s2, i1, i2); +} + +scriptVar RootObject_ScriptMethods::notify(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s, scriptVar s2, scriptVar i1, scriptVar i2) { + SCRIPT_FUNCTION_INIT + RootObject *ro = static_cast<RootObject*>(o->vcpu_getInterface(rootObjectGuid)); + if (ro) ro->rootobject_notify(GET_SCRIPT_STRING(s), GET_SCRIPT_STRING(s2), GET_SCRIPT_INT(i1), GET_SCRIPT_INT(i2)); + RETURN_SCRIPT_VOID; +} diff --git a/Src/Wasabi/api/script/objects/rootobjcontroller.h b/Src/Wasabi/api/script/objects/rootobjcontroller.h new file mode 100644 index 00000000..4dbb81fb --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjcontroller.h @@ -0,0 +1,36 @@ +#ifndef __ROOTSCRIPTOBJECTCONTROLLER_IMPL_H +#define __ROOTSCRIPTOBJECTCONTROLLER_IMPL_H + +#include <api/script/objcontroller.h> +/*<?<autoheader/>*/ +class ScriptObject; +class ScriptObjectController; +/*?>*/ + +class RootScriptObjectController : public ScriptObjectControllerI +{ + public: + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return NULL; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void deencapsulate(void *o); + virtual void *encapsulate(ScriptObject *o); + private: + static function_descriptor_struct exportedFunction[]; +}; + +class RootObject_ScriptMethods { + public: + static scriptVar getClassName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar onNotify(SCRIPT_FUNCTION_PARAMS, ScriptObject *on, scriptVar s, scriptVar s2, scriptVar i1, scriptVar i2); + static scriptVar notify(SCRIPT_FUNCTION_PARAMS, ScriptObject *on, scriptVar s, scriptVar s2, scriptVar i1, scriptVar i2); +}; + +extern RootScriptObjectController *rootScriptObjectController; + +#endif // __ROOTSCRIPTOBJECTCONTROLLER_IMPL_H diff --git a/Src/Wasabi/api/script/objects/rootobject.cpp b/Src/Wasabi/api/script/objects/rootobject.cpp new file mode 100644 index 00000000..1ebc36f1 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobject.cpp @@ -0,0 +1,12 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri May 16 23:15:13 2003] +// +// File : rootobject.cpp +// Class : RootObject +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#include <precomp.h> +#include "rootobject.h" + + diff --git a/Src/Wasabi/api/script/objects/rootobject.h b/Src/Wasabi/api/script/objects/rootobject.h new file mode 100644 index 00000000..c18fd1f9 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobject.h @@ -0,0 +1,71 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri May 16 23:15:13 2003] +// +// File : rootobject.h +// Class : RootObject +// class layer : Dispatchable Interface +// ---------------------------------------------------------------------------- + +#ifndef __ROOTOBJECT_H +#define __ROOTOBJECT_H + +#include <bfc/dispatch.h> +#include <bfc/common.h> + +class RootObjectCallback; +class ScriptObject; + + + +#include <api/script/objects/rootobjcontroller.h> + +// ---------------------------------------------------------------------------- + +class RootObject: public Dispatchable { + protected: + RootObject() {} + ~RootObject() {} + public: + const wchar_t *rootobject_getClassName(); + void rootobject_notify(const wchar_t *s, const wchar_t *t, int u, int v); + ScriptObject *rootobject_getScriptObject(); + void rootobject_setScriptObject(ScriptObject *obj); + void rootobject_addCB(RootObjectCallback *cb); + + protected: + enum { + ROOTOBJECT_ROOTOBJECT_GETCLASSNAME = 10, + ROOTOBJECT_ROOTOBJECT_NOTIFY = 20, + ROOTOBJECT_ROOTOBJECT_GETSCRIPTOBJECT = 30, + ROOTOBJECT_ROOTOBJECT_SETSCRIPTOBJECT = 40, + ROOTOBJECT_ROOTOBJECT_ADDCB = 50, + }; +}; + +// ---------------------------------------------------------------------------- + +inline const wchar_t *RootObject::rootobject_getClassName() { + const wchar_t *__retval = _call(ROOTOBJECT_ROOTOBJECT_GETCLASSNAME, (const wchar_t *)0); + return __retval; +} + +inline void RootObject::rootobject_notify(const wchar_t *s, const wchar_t *t, int u, int v) { + _voidcall(ROOTOBJECT_ROOTOBJECT_NOTIFY, s, t, u, v); +} + +inline ScriptObject *RootObject::rootobject_getScriptObject() { + ScriptObject *__retval = _call(ROOTOBJECT_ROOTOBJECT_GETSCRIPTOBJECT, (ScriptObject *)NULL); + return __retval; +} + +inline void RootObject::rootobject_setScriptObject(ScriptObject *obj) { + _voidcall(ROOTOBJECT_ROOTOBJECT_SETSCRIPTOBJECT, obj); +} + +inline void RootObject::rootobject_addCB(RootObjectCallback *cb) { + _voidcall(ROOTOBJECT_ROOTOBJECT_ADDCB, cb); +} + +// ---------------------------------------------------------------------------- + +#endif // __ROOTOBJECT_H diff --git a/Src/Wasabi/api/script/objects/rootobjecti.cpp b/Src/Wasabi/api/script/objects/rootobjecti.cpp new file mode 100644 index 00000000..cb6e2f3b --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjecti.cpp @@ -0,0 +1,46 @@ +#include <precomp.h> + +//<?#include "<class data="implementationheader"/>" +#include "rootobjecti.h" +//?> + +#include <bfc/wasabi_std.h> +#include <api/script/scriptmgr.h> +#include <api/script/scriptobj.h> +#include <bfc/foreach.h> + + +// -------------------------------------------------------------------------------------------- + +RootObjectI::RootObjectI(ScriptObject *o) { + my_script_object = o; +} + +RootObjectI::~RootObjectI() { +} + +const wchar_t *RootObjectI::rootobject_getClassName() +{ + if (!my_script_object) return NULL; + return my_script_object->vcpu_getClassName(); +} + +void RootObjectI::rootobject_notify(const wchar_t *s, const wchar_t *t, int u, int v) { + foreach(cbs) + cbs.getfor()->rootobjectcb_onNotify(s, t, u, v); + endfor; + RootObject_ScriptMethods::onNotify(SCRIPT_CALL, rootobject_getScriptObject(), MAKE_SCRIPT_STRING(s), MAKE_SCRIPT_STRING(t), MAKE_SCRIPT_INT(u), MAKE_SCRIPT_INT(v)); +} + +ScriptObject *RootObjectI::rootobject_getScriptObject() { + return my_script_object; +} + +void RootObjectI::rootobject_setScriptObject(ScriptObject *obj) { + my_script_object = obj; +} + +void RootObjectI::rootobject_addCB(RootObjectCallback *cb) { + cbs.addItem(cb); +} + diff --git a/Src/Wasabi/api/script/objects/rootobjecti.h b/Src/Wasabi/api/script/objects/rootobjecti.h new file mode 100644 index 00000000..a76361e2 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjecti.h @@ -0,0 +1,32 @@ +#ifndef __ROOTOBJECTI_IMPL_H +#define __ROOTOBJECTI_IMPL_H + +/*<?<autoheader/>*/ +#include "rootobject.h" +#include "rootobjectx.h" + +class RootObjectCallback; +class ScriptObject; +/*?>*/ + +/*[interface.header.h] +#include "common/script/rootobjcontroller.h" +*/ + +extern RootScriptObjectController *rootScriptObjectController; + +class RootObjectI : public RootObjectX { +public: + RootObjectI(ScriptObject *o); + virtual ~RootObjectI(); + DISPATCH(10) virtual const wchar_t *rootobject_getClassName(); + DISPATCH(20) virtual void rootobject_notify(const wchar_t *s, const wchar_t *t, int u, int v); + DISPATCH(30) virtual ScriptObject *rootobject_getScriptObject(); + DISPATCH(40) virtual void rootobject_setScriptObject(ScriptObject *obj); + DISPATCH(50) virtual void rootobject_addCB(RootObjectCallback *cb); + PtrList < RootObjectCallback > cbs; + ScriptObject * my_script_object; +}; + + +#endif // __ROOTOBJECTI_IMPL_H diff --git a/Src/Wasabi/api/script/objects/rootobjectx.cpp b/Src/Wasabi/api/script/objects/rootobjectx.cpp new file mode 100644 index 00000000..824a6825 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjectx.cpp @@ -0,0 +1,22 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri May 16 23:15:13 2003] +// +// File : rootobjectx.cpp +// Class : RootObject +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- +#include "precomp.h" + +#include "rootobjectx.h" +#include "rootobjecti.h" + +#define CBCLASS RootObjectX +START_DISPATCH; + CB(ROOTOBJECT_ROOTOBJECT_GETCLASSNAME, rootobject_getClassName); + VCB(ROOTOBJECT_ROOTOBJECT_NOTIFY, rootobject_notify); + CB(ROOTOBJECT_ROOTOBJECT_GETSCRIPTOBJECT, rootobject_getScriptObject); + VCB(ROOTOBJECT_ROOTOBJECT_SETSCRIPTOBJECT, rootobject_setScriptObject); + VCB(ROOTOBJECT_ROOTOBJECT_ADDCB, rootobject_addCB); +END_DISPATCH; +#undef CBCLASS + diff --git a/Src/Wasabi/api/script/objects/rootobjectx.h b/Src/Wasabi/api/script/objects/rootobjectx.h new file mode 100644 index 00000000..687293a7 --- /dev/null +++ b/Src/Wasabi/api/script/objects/rootobjectx.h @@ -0,0 +1,35 @@ +// ---------------------------------------------------------------------------- +// Generated by InterfaceFactory [Fri May 16 23:15:13 2003] +// +// File : rootobjectx.h +// Class : RootObject +// class layer : Dispatchable Receiver +// ---------------------------------------------------------------------------- + +#ifndef __ROOTOBJECTX_H +#define __ROOTOBJECTX_H + +#include "rootobject.h" + +class RootObjectCallback; +class ScriptObject; + + + +// ---------------------------------------------------------------------------- + +class RootObjectX : public RootObject { + protected: + RootObjectX() {} + public: + virtual const wchar_t *rootobject_getClassName()=0; + virtual void rootobject_notify(const wchar_t *s, const wchar_t *t, int u, int v)=0; + virtual ScriptObject *rootobject_getScriptObject()=0; + virtual void rootobject_setScriptObject(ScriptObject *obj)=0; + virtual void rootobject_addCB(RootObjectCallback *cb)=0; + + protected: + RECVS_DISPATCH; +}; + +#endif // __ROOTOBJECTX_H diff --git a/Src/Wasabi/api/script/objects/sapplication.cpp b/Src/Wasabi/api/script/objects/sapplication.cpp new file mode 100644 index 00000000..d1dca910 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sapplication.cpp @@ -0,0 +1,213 @@ +#include "sapplication.h" +#include <api/application/api_application.h> +#include <api.h> + +// {B8E867B0-2715-4da7-A5BA-53DBA1FCFEAC} +static const GUID application_script_object_guid = +{ 0xb8e867b0, 0x2715, 0x4da7, { 0xa5, 0xba, 0x53, 0xdb, 0xa1, 0xfc, 0xfe, 0xac } }; + +static ApplicationScriptObjectController _applicationController; +ScriptObjectController *applicationController=&_applicationController; + +// -- Functions table ------------------------------------- +function_descriptor_struct ApplicationScriptObjectController::exportedFunction[] = +{ + {L"GetApplicationName", 0, (void*)SApplication::GetApplicationName }, + {L"GetVersionString", 0, (void*)SApplication::GetVersionString }, + {L"GetVersionNumberString", 0, (void*)SApplication::GetVersionNumberString }, + {L"GetBuildNumber",0, (void*)SApplication::GetBuildNumber }, + {L"GetGUID",0, (void*)SApplication::GetGUID }, + {L"GetCommandLine",0, (void*)SApplication::GetCommandLine }, + {L"Shutdown",0, (void*)SApplication::Shutdown }, + {L"CancelShutdown",0, (void*)SApplication::CancelShutdown }, + {L"IsShuttingDown",0, (void*)SApplication::IsShuttingDown }, + {L"GetApplicationPath",0, (void*)SApplication::GetApplicationPath }, + {L"GetSettingsPath",0, (void*)SApplication::GetSettingsPath }, + {L"GetWorkingPath",0, (void*)SApplication::GetWorkingPath }, + {L"SetWorkingPath",1, (void*)SApplication::SetWorkingPath }, + {L"GetMachineGUID",0, (void*)SApplication::GetMachineGUID }, + {L"GetUserGUID",0, (void*)SApplication::GetUserGUID }, + {L"GetSessionGUID",0, (void*)SApplication::GetSessionGUID }, +}; +// -------------------------------------------------------- + +const wchar_t *ApplicationScriptObjectController::getClassName() +{ + return L"Application"; +} + +const wchar_t *ApplicationScriptObjectController::getAncestorClassName() +{ + return L"Object"; +} + +ScriptObjectController *ApplicationScriptObjectController::getAncestorController() +{ + return NULL; +} + +ScriptObject *ApplicationScriptObjectController::instantiate() +{ + SApplication *c = new SApplication; + if (!c) return NULL; + return c->getScriptObject(); +} + +int ApplicationScriptObjectController::getInstantiable() +{ + return 0; +} + +void ApplicationScriptObjectController::destroy(ScriptObject *o) +{ + SApplication *obj = static_cast<SApplication *>(o->vcpu_getInterface(application_script_object_guid)); + ASSERT(obj != NULL); + delete obj; +} + +void *ApplicationScriptObjectController::encapsulate(ScriptObject *o) +{ + return NULL; +} + +void ApplicationScriptObjectController::deencapsulate(void *o) +{ +} + +int ApplicationScriptObjectController::getNumFunctions() +{ + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *ApplicationScriptObjectController::getExportedFunctions() +{ + return exportedFunction; +} + +GUID ApplicationScriptObjectController::getClassGuid() +{ + return application_script_object_guid; +} + + +SApplication::SApplication() +{ + getScriptObject()->vcpu_setInterface(application_script_object_guid, static_cast<SApplication *>(this)); + getScriptObject()->vcpu_setClassName(L"Application"); + getScriptObject()->vcpu_setController(applicationController); +} +SApplication::~SApplication() +{ +} + +static wchar_t guid_scratchpad[40]; + +scriptVar SApplication::GetApplicationName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->main_getAppName()); +} + +scriptVar SApplication::GetVersionString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->main_getVersionString()); +} + +scriptVar SApplication::GetVersionNumberString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->main_getVersionNumString()); +} + +scriptVar SApplication::GetBuildNumber(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT(WASABI_API_APP->main_getBuildNumber()); +} + +scriptVar SApplication::GetGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + GUID g = WASABI_API_APP->main_getGUID(); + nsGUID::toCharW(g, guid_scratchpad); + return MAKE_SCRIPT_STRING(guid_scratchpad); +} + +scriptVar SApplication::GetCommandLine(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->main_getCommandLine()); +} + +scriptVar SApplication::Shutdown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_APP->main_shutdown(); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SApplication::CancelShutdown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_APP->main_cancelShutdown(); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SApplication::IsShuttingDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_BOOLEAN(WASABI_API_APP->main_isShuttingDown()); +} + +scriptVar SApplication::GetApplicationPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->path_getAppPath()); +} + +scriptVar SApplication::GetSettingsPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->path_getUserSettingsPath()); +} + +scriptVar SApplication::GetWorkingPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING(WASABI_API_APP->path_getWorkingPath()); +} + +scriptVar SApplication::SetWorkingPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar string_path) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_APP->path_setWorkingPath(GET_SCRIPT_STRING(string_path)); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SApplication::GetMachineGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + GUID g; + WASABI_API_APP->GetMachineID(&g); + nsGUID::toCharW(g, guid_scratchpad); + return MAKE_SCRIPT_STRING(guid_scratchpad); +} + +scriptVar SApplication::GetUserGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + GUID g; + WASABI_API_APP->GetUserID(&g); + nsGUID::toCharW(g, guid_scratchpad); + return MAKE_SCRIPT_STRING(guid_scratchpad); +} + +scriptVar SApplication::GetSessionGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + GUID g; + WASABI_API_APP->GetSessionID(&g); + nsGUID::toCharW(g, guid_scratchpad); + return MAKE_SCRIPT_STRING(guid_scratchpad); +} diff --git a/Src/Wasabi/api/script/objects/sapplication.h b/Src/Wasabi/api/script/objects/sapplication.h new file mode 100644 index 00000000..f6ec099f --- /dev/null +++ b/Src/Wasabi/api/script/objects/sapplication.h @@ -0,0 +1,57 @@ +#pragma once +#include <api/script/api_maki.h> +#include <api/script/script.h> +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> +#include <api/script/objects/rootobject.h> + +#define SApplication_SCRIPTPARENT RootObjectInstance + +class ApplicationScriptObjectController : public ScriptObjectControllerI +{ + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual int getInstantiable(); + virtual int getReferenceable() {return 0;} + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + static function_descriptor_struct exportedFunction[]; + +}; + +extern ScriptObjectController *applicationController; + +class SApplication : public SApplication_SCRIPTPARENT +{ +public: + SApplication(); + virtual ~SApplication(); + +public: + static scriptVar GetApplicationName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetVersionString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetVersionNumberString(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetBuildNumber(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetCommandLine(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar Shutdown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar CancelShutdown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar IsShuttingDown(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetApplicationPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetSettingsPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetWorkingPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar SetWorkingPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar string_path); + static scriptVar GetMachineGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetUserGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar GetSessionGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; diff --git a/Src/Wasabi/api/script/objects/sbitlist.cpp b/Src/Wasabi/api/script/objects/sbitlist.cpp new file mode 100644 index 00000000..d41afa47 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sbitlist.cpp @@ -0,0 +1,118 @@ +#include <precomp.h> +#include "sbitlist.h" +#include <bfc/bitlist.h> + +#include <api/script/script.h> +#include <api/script/scriptmgr.h> + +// {87C65778-E743-49fe-85F9-09CC532AFD56} +static const GUID bitlistGuid = +{ 0x87c65778, 0xe743, 0x49fe, { 0x85, 0xf9, 0x9, 0xcc, 0x53, 0x2a, 0xfd, 0x56 } }; + +BitlistScriptController _bitlistController; +BitlistScriptController *bitlistController = &_bitlistController; + +// -- Functions table ------------------------------------- +function_descriptor_struct BitlistScriptController::exportedFunction[] = { + {L"getItem", 1, (void*)SBitlist::script_vcpu_getitem }, + {L"setItem", 2, (void*)SBitlist::script_vcpu_setitem }, + {L"setSize", 1, (void*)SBitlist::script_vcpu_setsize }, + {L"getSize", 0, (void*)SBitlist::script_vcpu_getsize }, +}; +// -------------------------------------------------------- + +const wchar_t *BitlistScriptController::getClassName() { + return L"BitList"; +} + +const wchar_t *BitlistScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObject *BitlistScriptController::instantiate() { + SBitlist *bl = new SBitlist; + ASSERT(bl != NULL); + return bl->getScriptObject(); +} + +void BitlistScriptController::destroy(ScriptObject *o) +{ + // TODO? + SBitlist *bl = static_cast<SBitlist *>(o->vcpu_getInterface(bitlistGuid)); +} + +void *BitlistScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for bitlist yet +} + +void BitlistScriptController::deencapsulate(void *o) { +} + +int BitlistScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *BitlistScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID BitlistScriptController::getClassGuid() { + return bitlistGuid; +} + +//------------------------------------------------------------------------------------------------------------- + + +SBitlist::SBitlist() { + list = new BitList; + getScriptObject()->vcpu_setInterface(bitlistGuid, (void *)static_cast<SBitlist *>(this)); + getScriptObject()->vcpu_setClassName(L"BitList"); + getScriptObject()->vcpu_setController(bitlistController); +} + +SBitlist::~SBitlist() { + delete list; +} + +BitList *SBitlist::getBitList() { + return list; +} + +scriptVar SBitlist::script_vcpu_getitem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&n)); // Compiler shouldn't do this + scriptVar r; + r = SOM::makeVar(SCRIPT_INT); + SBitlist *bl = static_cast<SBitlist *>(o->vcpu_getInterface(bitlistGuid)); + if (bl) SOM::assign(&r, bl->getBitList()->getitem(SOM::makeInt(&n))); + return r; +} + +scriptVar SBitlist::script_vcpu_setitem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n, scriptVar v) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&n)); // Compiler shouldn't do this + ASSERT(SOM::isNumeric(&v)); // Compiler shouldn't do this + SBitlist *bl = static_cast<SBitlist *>(o->vcpu_getInterface(bitlistGuid)); + if (bl) bl->getBitList()->setitem(SOM::makeInt(&n), SOM::makeBoolean(&v)); + RETURN_SCRIPT_VOID; +} + +scriptVar SBitlist::script_vcpu_setsize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newsize) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&newsize)); // Compiler shouldn't do this + SBitlist *bl = static_cast<SBitlist *>(o->vcpu_getInterface(bitlistGuid)); + if (bl) bl->getBitList()->setSize(SOM::makeInt(&newsize)); + RETURN_SCRIPT_VOID; +} + +scriptVar SBitlist::script_vcpu_getsize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + scriptVar r; + r = SOM::makeVar(SCRIPT_INT); + SBitlist *bl = static_cast<SBitlist *>(o->vcpu_getInterface(bitlistGuid)); + if (bl) SOM::assign(&r, bl->getBitList()->getsize()); + return r; +} + + + diff --git a/Src/Wasabi/api/script/objects/sbitlist.h b/Src/Wasabi/api/script/objects/sbitlist.h new file mode 100644 index 00000000..9c6f023a --- /dev/null +++ b/Src/Wasabi/api/script/objects/sbitlist.h @@ -0,0 +1,56 @@ +#ifndef __SBITLIST_H +#define __SBITLIST_H + +#include <api/script/objects/rootobj.h> + +#include <api/script/script.h> +#include <api/script/objects/rootobject.h> + +class BitList; + +#define SBITLIST_SCRIPTPARENT RootObjectInstance + +class BitlistScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return rootScriptObjectController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern BitlistScriptController *bitlistController; + + +class SBitlist : public SBITLIST_SCRIPTPARENT { + +public: + SBitlist(); + virtual ~SBitlist(); + + BitList *getBitList(); + +private: + + BitList *list; + +public: + static scriptVar script_vcpu_getitem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n); + static scriptVar script_vcpu_setitem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n, scriptVar v); + static scriptVar script_vcpu_setsize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newsize); + static scriptVar script_vcpu_getsize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/scolor.cpp b/Src/Wasabi/api/script/objects/scolor.cpp new file mode 100644 index 00000000..cd00642d --- /dev/null +++ b/Src/Wasabi/api/script/objects/scolor.cpp @@ -0,0 +1,236 @@ +#include <precomp.h> +#include "SColor.h" +#include <api.h> +#include <api/script/script.h> +#include <api/script/scriptmgr.h> +#include <api/script/objecttable.h> +#include <api/imgldr/imgldr.h> + + +// {95DDB221-00E3-4e2b-8EA5-833548C13C10} +static const GUID colorSoGuid = +{ 0x95ddb221, 0xe3, 0x4e2b, { 0x8e, 0xa5, 0x83, 0x35, 0x48, 0xc1, 0x3c, 0x10 } }; + + +colorScriptController _colorController; +colorScriptController *colorController=&_colorController; + +// -- Functions table ------------------------------------- +function_descriptor_struct colorScriptController::exportedFunction[] = { + {L"getID", 0, (void*)SColor::script_vcpu_getColorID }, + {L"getRed", 0, (void*)SColor::script_vcpu_getRed }, + {L"getGreen", 0, (void*)SColor::script_vcpu_getGreen }, + {L"getBlue", 0, (void*)SColor::script_vcpu_getBlue }, + {L"getAlpha", 0, (void*)SColor::script_vcpu_getAlpha }, + {L"getGreenWithGamma", 0, (void*)SColor::script_vcpu_getGreenWithGamma }, + {L"getBlueWithGamma", 0, (void*)SColor::script_vcpu_getBlueWithGamma }, + {L"getRedWithGamma", 0, (void*)SColor::script_vcpu_getRedWithGamma }, + {L"getGammagroup", 0, (void*)SColor::script_vcpu_getGammagroup }, +}; +// -------------------------------------------------------- + +const wchar_t *colorScriptController::getClassName() { + return L"Color"; +} + +const wchar_t *colorScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *colorScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *colorScriptController::instantiate() { + SColor *xd = new SColor; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void colorScriptController::destroy(ScriptObject *o) { + SColor *xd = static_cast<SColor *>(o->vcpu_getInterface(colorSoGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *colorScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for now +} + +void colorScriptController::deencapsulate(void *o) { +} + +int colorScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *colorScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID colorScriptController::getClassGuid() { + return colorSoGuid; +} + +void SColor::__construct() +{ + getScriptObject()->vcpu_setInterface(colorSoGuid, (void *)static_cast<SColor *>(this)); + getScriptObject()->vcpu_setClassName(L"Color"); + getScriptObject()->vcpu_setController(colorController); + gammagroup = NULL; + colorID = NULL; + color = 0; +} + +SColor::SColor() +{ + SColor::__construct(); +} + +SColor::SColor(const wchar_t* colorID) +{ + __construct(); + this->colorID = colorID; + color = WASABI_API_PALETTE->getColorElement(colorID, &gammagroup); +} + +SColor::SColor(int n) +{ + __construct(); + colorID = WASABI_API_PALETTE->enumColorElement(n); + color = WASABI_API_PALETTE->getColorElement(colorID, &gammagroup); +} + +SColor::~SColor() +{ +} + +int SColor::getARGBValue(int whichCol) +{ + + whichCol %= 4; + + /** + whichCol + 0: red + 1: green + 2: blue + 3: alpha + */ + + ARGB32 c = this->color; + + c = c >> (whichCol * 8); + c &= 0x000000FF; + + return (int)c; +} + +int SColor::getARGBValueWithGamma(int whichCol) +{ + ARGB32 c = imageLoader::filterSkinColor(this->color, this->colorID, NULL); + whichCol %= 4; + + /** + whichCol + 0: red + 1: green + 2: blue + 3: alpha + */ + + c = c >> (whichCol * 8); + c &= 0x000000FF; + + return (int)c; +} + +// VCPU + +scriptVar SColor::script_vcpu_getBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast<SColor *>(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValue(2)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast<SColor *>(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValue(1)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast<SColor *>(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValue(0)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getBlueWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast<SColor *>(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValueWithGamma(2)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getGreenWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast<SColor *>(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValueWithGamma(1)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getRedWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast<SColor *>(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValueWithGamma(0)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast<SColor *>(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->getARGBValue(3)); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SColor::script_vcpu_getColorID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast<SColor *>(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_STRING(m->colorID); + } + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar SColor::script_vcpu_getGammagroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SColor *m = static_cast<SColor *>(o->vcpu_getInterface(colorSoGuid)); + if (m) + { + return MAKE_SCRIPT_STRING(m->gammagroup?m->gammagroup:L""); + } + return MAKE_SCRIPT_STRING(L""); +}
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/scolor.h b/Src/Wasabi/api/script/objects/scolor.h new file mode 100644 index 00000000..94f03671 --- /dev/null +++ b/Src/Wasabi/api/script/objects/scolor.h @@ -0,0 +1,66 @@ +#ifndef __SColor_H +#define __SColor_H + +class SColor; + +#include <api/script/script.h> +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> +#include <api/script/objects/rootobject.h> +#include <api/skin/skinelem.h> +#include <api/skin/gammamgr.h> +#define SCOLOR_SCRIPTPARENT RootObjectInstance + +class colorScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern colorScriptController *colorController; + +class SColor : public SCOLOR_SCRIPTPARENT { +public: + SColor(); + SColor(const wchar_t*); + SColor(int i); + virtual ~SColor(); + void enumColor(int n); + int getARGBValue(int whichCol); + int getARGBValueWithGamma(int whichCol); + +protected: + const wchar_t *gammagroup; + const wchar_t *colorID; + ARGB32 color; + +private: + void __construct(); + +public: + static scriptVar script_vcpu_getRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getRedWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGreenWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBlueWithGamma(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getAlpha(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGammagroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getColorID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/scolormgr.cpp b/Src/Wasabi/api/script/objects/scolormgr.cpp new file mode 100644 index 00000000..fb135bdf --- /dev/null +++ b/Src/Wasabi/api/script/objects/scolormgr.cpp @@ -0,0 +1,235 @@ +#include <precomp.h> +#include "SColorMgr.h" +#include <api.h> +#include <api/script/script.h> +#include <api/script/scriptmgr.h> +#include <api/script/objecttable.h> + + +// {AEE235FF-EBD1-498f-96AF-D7E0DAD4541A} +static const GUID colorMgrSoGuid = +{ 0xaee235ff, 0xebd1, 0x498f, { 0x96, 0xaf, 0xd7, 0xe0, 0xda, 0xd4, 0x54, 0x1a } }; + +ColorMgrScriptController _colorMgrController; +ColorMgrScriptController *colorMgrController=&_colorMgrController; + +// -- Functions table ------------------------------------- +function_descriptor_struct ColorMgrScriptController::exportedFunction[] = { + {L"getColor", 1, (void*)SColorMgr::script_vcpu_getColor }, + {L"enumColor", 1, (void*)SColorMgr::script_vcpu_enumColor }, + {L"getNumColors", 0, (void*)SColorMgr::script_vcpu_getNumColors }, + {L"getGammaSet", 1, (void*)SColorMgr::script_vcpu_getGammaSet }, + {L"getCurrentGammaSet", 0, (void*)SColorMgr::script_vcpu_getCurrentGammaSet }, + {L"enumGammaSet", 1, (void*)SColorMgr::script_vcpu_enumGammaSet }, + {L"getNumGammaSets", 0, (void*)SColorMgr::script_vcpu_getNumGammaSets }, + {L"onGuiLoaded", 0, (void*)SColorMgr::script_vcpu_onGuiLoaded }, + {L"onLoaded", 0, (void*)SColorMgr::script_vcpu_onLoaded }, + {L"newGammaSet", 1, (void*)SColorMgr::script_vcpu_newGammaSet }, + {L"onBeforeLoadingElements", 0, (void*)SColorMgr::script_vcpu_onBeforeLoadingElements }, + {L"onColorThemeChanged", 1, (void*)SColorMgr::script_vcpu_onColorThemeChanged }, + {L"onColorThemesListChanged", 0, (void*)SColorMgr::script_vcpu_onColorThemesListChanged }, +}; +// -------------------------------------------------------- + +const wchar_t *ColorMgrScriptController::getClassName() { + return L"ColorMgr"; +} + +const wchar_t *ColorMgrScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *ColorMgrScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *ColorMgrScriptController::instantiate() { + SColorMgr *xd = new SColorMgr; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void ColorMgrScriptController::destroy(ScriptObject *o) { + SColorMgr *xd = static_cast<SColorMgr *>(o->vcpu_getInterface(colorMgrSoGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *ColorMgrScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for now +} + +void ColorMgrScriptController::deencapsulate(void *o) { +} + +int ColorMgrScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *ColorMgrScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID ColorMgrScriptController::getClassGuid() { + return colorMgrSoGuid; +} + +SColorMgr::SColorMgr() +{ + getScriptObject()->vcpu_setInterface(colorMgrSoGuid, (void *)static_cast<SColorMgr *>(this)); + getScriptObject()->vcpu_setClassName(L"ColorMgr"); + getScriptObject()->vcpu_setController(colorMgrController); + WASABI_API_SYSCB->syscb_registerCallback(static_cast<SkinCallbackI*>(this)); +} + +SColorMgr::~SColorMgr() +{ + WASABI_API_SYSCB->syscb_deregisterCallback(static_cast<SkinCallbackI*>(this)); +} + +int SColorMgr::skincb_onGuiLoaded () +{ + script_vcpu_onGuiLoaded(SCRIPT_CALL, this->getScriptObject()); + return 0; +} + +int SColorMgr::skincb_onLoaded () +{ + script_vcpu_onLoaded(SCRIPT_CALL, this->getScriptObject()); + return 0; +} + +int SColorMgr::skincb_onBeforeLoadingElements () +{ + script_vcpu_onBeforeLoadingElements(SCRIPT_CALL, this->getScriptObject()); + return 0; +} + +int SColorMgr::skincb_onColorThemeChanged (const wchar_t* newcolortheme) +{ + script_vcpu_onColorThemeChanged(SCRIPT_CALL, this->getScriptObject(), MAKE_SCRIPT_STRING(newcolortheme)); + return 0; +} + + +int SColorMgr::skincb_onColorThemesListChanged() +{ + script_vcpu_onColorThemesListChanged(SCRIPT_CALL, this->getScriptObject()); + return 0; +} + + +// VCPU + +scriptVar SColorMgr::script_vcpu_getColor(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(colorID.type == SCRIPT_STRING); + ScriptObject *s = NULL; + SColor *sc = new SColor(colorID.data.sdata); + if (sc != NULL) s = sc->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_enumColor(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(n.type == SCRIPT_INT); + ScriptObject *s = NULL; + SColor *sc = new SColor(n.data.idata); + if (sc != NULL) s = sc->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_getNumColors(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT(WASABI_API_PALETTE->getNumColorElements()); +} + +scriptVar SColorMgr::script_vcpu_getGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(colorID.type == SCRIPT_STRING); + ScriptObject *s = NULL; + SGammaset *gs = new SGammaset(colorID.data.sdata); + if (gs != NULL) s = gs->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_newGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(colorID.type == SCRIPT_STRING); + WASABI_API_COLORTHEMES->newGammaSet(colorID.data.sdata); + ScriptObject *s = NULL; + SGammaset *gs = new SGammaset(colorID.data.sdata); + if (gs != NULL) s = gs->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_enumGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(n.type == SCRIPT_INT); + ScriptObject *s = NULL; + SGammaset *gs = new SGammaset(n.data.idata); + if (gs != NULL) s = gs->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_getCurrentGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + ScriptObject *s = NULL; + const wchar_t * cur = WASABI_API_COLORTHEMES->getGammaSet(); + SGammaset *gs = NULL; + if (cur != NULL) new SGammaset(cur); + if (gs != NULL) s = gs->getScriptObject(); + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SColorMgr::script_vcpu_getNumGammaSets(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT(WASABI_API_COLORTHEMES->getNumGammaSets()); +} + +scriptVar SColorMgr::script_vcpu_onGuiLoaded(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, colorMgrController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar SColorMgr::script_vcpu_onLoaded(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, colorMgrController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + + +scriptVar SColorMgr::script_vcpu_onBeforeLoadingElements(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, colorMgrController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar SColorMgr::script_vcpu_onColorThemesListChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, colorMgrController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar SColorMgr::script_vcpu_onColorThemeChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newTheme) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1(o, colorMgrController, newTheme); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT1(o, newTheme); +}
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/scolormgr.h b/Src/Wasabi/api/script/objects/scolormgr.h new file mode 100644 index 00000000..35258e2d --- /dev/null +++ b/Src/Wasabi/api/script/objects/scolormgr.h @@ -0,0 +1,66 @@ +#ifndef __SColorMgr_H +#define __SColorMgr_H + +class SColorMgr; + +#include <api/script/script.h> +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> +#include <api/script/objects/rootobject.h> +#include <api/skin/skinelem.h> +#include <api/skin/gammamgr.h> +#include "scolor.h" +#include "sgammaset.h" +#define SCOLORMGR_SCRIPTPARENT RootObjectInstance + +class ColorMgrScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern ColorMgrScriptController *colorMgrController; + +class SColorMgr : public SCOLORMGR_SCRIPTPARENT, public SkinCallbackI { +public: + SColorMgr(); + virtual ~SColorMgr(); + + virtual int skincb_onBeforeLoadingElements(); + virtual int skincb_onGuiLoaded(); + virtual int skincb_onLoaded(); + virtual int skincb_onColorThemeChanged(const wchar_t *newcolortheme); + virtual int skincb_onColorThemesListChanged(); + +public: + static scriptVar script_vcpu_getColor(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID); + static scriptVar script_vcpu_enumColor(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n); + static scriptVar script_vcpu_getNumColors(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getCurrentGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID); + static scriptVar script_vcpu_enumGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n); + static scriptVar script_vcpu_getNumGammaSets(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_newGammaSet(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar colorID); + + static scriptVar script_vcpu_onBeforeLoadingElements(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onGuiLoaded(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onColorThemeChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar newcolortheme); + static scriptVar script_vcpu_onColorThemesListChanged(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onLoaded(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/sfile.cpp b/Src/Wasabi/api/script/objects/sfile.cpp new file mode 100644 index 00000000..e7feaaac --- /dev/null +++ b/Src/Wasabi/api/script/objects/sfile.cpp @@ -0,0 +1,119 @@ +#include <precomp.h> +#include "SFile.h" + +#include <api/script/script.h> +#include <api/script/scriptmgr.h> +#include <api/script/objecttable.h> + + +// {836F8B2E-E0D1-4db4-937F-0D0A04C8DCD1} +static const GUID fileGuid = +{ 0x836f8b2e, 0xe0d1, 0x4db4, { 0x93, 0x7f, 0xd, 0xa, 0x4, 0xc8, 0xdc, 0xd1 } }; + + +fileScriptController _fileController; +fileScriptController *fileController=&_fileController; + +// -- Functions table ------------------------------------- +function_descriptor_struct fileScriptController::exportedFunction[] = { + {L"load", 1, (void*)SFile::script_vcpu_load }, + {L"getSize", 0, (void*)SFile::script_vcpu_getSize }, + {L"exists", 0, (void*)SFile::script_vcpu_exists }, +}; +// -------------------------------------------------------- + +const wchar_t *fileScriptController::getClassName() { + return L"File"; +} + +const wchar_t *fileScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *fileScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *fileScriptController::instantiate() { + SFile *xd = new SFile; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void fileScriptController::destroy(ScriptObject *o) { + SFile *xd = static_cast<SFile *>(o->vcpu_getInterface(fileGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *fileScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for files for now +} + +void fileScriptController::deencapsulate(void *o) { +} + +int fileScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *fileScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID fileScriptController::getClassGuid() { + return fileGuid; +} + + + +SFile::SFile() { + getScriptObject()->vcpu_setInterface(fileGuid, (void *)static_cast<SFile *>(this)); + getScriptObject()->vcpu_setClassName(L"File"); + getScriptObject()->vcpu_setController(fileController); + filename = NULL; +} + +SFile::~SFile() { + //if (bmp) delete bmp; +} + +void SFile::loadfile(const wchar_t *b) +{ + filename = b; +} + +// VCPU + +scriptVar SFile::script_vcpu_load(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar fn) { + SCRIPT_FUNCTION_INIT; + ASSERT(fn.type == SCRIPT_STRING); + SFile *m = static_cast<SFile *>(o->vcpu_getInterface(fileGuid)); + if (m) m->loadfile(fn.data.sdata); + RETURN_SCRIPT_VOID; +} + +scriptVar SFile::script_vcpu_getSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SFile *m = static_cast<SFile *>(o->vcpu_getInterface(fileGuid)); + if (m) + { + OSFILETYPE in = WFOPEN(m->filename, WF_READONLY_BINARY); + if (in == OPEN_FAILED) RETURN_SCRIPT_ZERO; + int size = (int)FGETSIZE(in); + FCLOSE(in); + return MAKE_SCRIPT_INT(size); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SFile::script_vcpu_exists(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SFile *m = static_cast<SFile *>(o->vcpu_getInterface(fileGuid)); + if (m) + { + OSFILETYPE in = WFOPEN(m->filename, WF_READONLY_BINARY); + if (in == OPEN_FAILED) return MAKE_SCRIPT_BOOLEAN(0); + FCLOSE(in); + return MAKE_SCRIPT_BOOLEAN(1); + } + return MAKE_SCRIPT_BOOLEAN(0); +}
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/sfile.h b/Src/Wasabi/api/script/objects/sfile.h new file mode 100644 index 00000000..91a0ee9c --- /dev/null +++ b/Src/Wasabi/api/script/objects/sfile.h @@ -0,0 +1,53 @@ +#ifndef __SFile_H +#define __SFile_H + +class SFile; + +#include <api/script/script.h> +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> +#include <api/script/objects/rootobject.h> + +#define SFile_SCRIPTPARENT RootObjectInstance + +class fileScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern fileScriptController *fileController; + +class SFile : public SFile_SCRIPTPARENT { +public: + SFile(); + virtual ~SFile(); + + + void loadfile(const wchar_t *b); + + +protected: + const wchar_t *filename; + +public: + static scriptVar script_vcpu_load(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar fn); + static scriptVar script_vcpu_getSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_exists(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/sgammagroup.cpp b/Src/Wasabi/api/script/objects/sgammagroup.cpp new file mode 100644 index 00000000..55c1b872 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sgammagroup.cpp @@ -0,0 +1,235 @@ +#include <precomp.h> +#include "SGammagroup.h" + +#include <api/script/script.h> +#include <api/script/scriptmgr.h> +#include <api/script/objecttable.h> + +// {B81F004D-ACBA-453d-A06B-30192A1DA17D} +static const GUID gammagroupSoGuid = +{ 0xb81f004d, 0xacba, 0x453d, { 0xa0, 0x6b, 0x30, 0x19, 0x2a, 0x1d, 0xa1, 0x7d } }; + + +GammagroupScriptController _gammagroupController; +GammagroupScriptController *gammagroupController=&_gammagroupController; + +// -- Functions table ------------------------------------- +function_descriptor_struct GammagroupScriptController::exportedFunction[] = { + {L"getRed", 0, (void*)SGammagroup::script_vcpu_getRed }, + {L"getGreen", 0, (void*)SGammagroup::script_vcpu_getGreen }, + {L"getBlue", 0, (void*)SGammagroup::script_vcpu_getBlue }, + {L"getBoost", 0, (void*)SGammagroup::script_vcpu_getBoost }, + {L"getGray", 0, (void*)SGammagroup::script_vcpu_getGray }, + {L"setRed", 1, (void*)SGammagroup::script_vcpu_setRed }, + {L"setGreen", 1, (void*)SGammagroup::script_vcpu_setGreen }, + {L"setBlue", 1, (void*)SGammagroup::script_vcpu_setBlue }, + {L"setBoost", 1, (void*)SGammagroup::script_vcpu_setBoost }, + {L"setGray", 1, (void*)SGammagroup::script_vcpu_setGray }, + {L"getID", 0, (void*)SGammagroup::script_vcpu_getID }, + {L"setID", 1, (void*)SGammagroup::script_vcpu_setID }, +}; +// -------------------------------------------------------- + +const wchar_t *GammagroupScriptController::getClassName() { + return L"Gammagroup"; +} + +const wchar_t *GammagroupScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *GammagroupScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *GammagroupScriptController::instantiate() { + SGammagroup *xd = new SGammagroup; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void GammagroupScriptController::destroy(ScriptObject *o) { + SGammagroup *xd = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *GammagroupScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for now +} + +void GammagroupScriptController::deencapsulate(void *o) { +} + +int GammagroupScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *GammagroupScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID GammagroupScriptController::getClassGuid() { + return gammagroupSoGuid; +} + +void SGammagroup::__construct() +{ + getScriptObject()->vcpu_setInterface(gammagroupSoGuid, (void *)static_cast<SGammagroup *>(this)); + getScriptObject()->vcpu_setClassName(L"Gammagroup"); + getScriptObject()->vcpu_setController(gammagroupController); + this->grp = NULL; +} + +SGammagroup::SGammagroup() +{ + this->__construct(); +} + +SGammagroup::SGammagroup(const wchar_t * parentSet, const wchar_t * grp) +{ + this->__construct(); + this->parentSet = parentSet; + this->grp = WASABI_API_COLORTHEMES->getColorThemeGroup(parentSet, grp); +} + +SGammagroup::SGammagroup(const wchar_t * parentSet, int n) +{ + this->__construct(); + this->parentSet = parentSet; + for (int i = 0; i < (int)WASABI_API_COLORTHEMES->getNumGammaSets(); i++) + { + if(WCSICMPSAFE(parentSet, WASABI_API_COLORTHEMES->enumGammaSet(i))) + { + continue; + } + + this->grp = WASABI_API_COLORTHEMES->enumColorThemeGroup(i, n); + break; + } +} + +SGammagroup::~SGammagroup() +{ +} + +// VCPU + + +scriptVar SGammagroup::script_vcpu_getID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_STRING(m->grp->getName()); + } + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar SGammagroup::script_vcpu_getBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->grp->getBlue()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SGammagroup::script_vcpu_getGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->grp->getGreen()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SGammagroup::script_vcpu_getRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->grp->getRed()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SGammagroup::script_vcpu_getBoost(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->grp->getBoost()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SGammagroup::script_vcpu_getGray(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + return MAKE_SCRIPT_INT(m->grp->getGray()); + } + RETURN_SCRIPT_ZERO; +} + +scriptVar SGammagroup::script_vcpu_setID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setName(color.data.sdata)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammagroup::script_vcpu_setBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setBlue(color.data.idata)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammagroup::script_vcpu_setGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setGreen(color.data.idata)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammagroup::script_vcpu_setRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setRed(color.data.idata)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammagroup::script_vcpu_setBoost(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setBoost(color.data.idata)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammagroup::script_vcpu_setGray(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) { + SCRIPT_FUNCTION_INIT; + SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid)); + if (m) + { + (m->grp->setGray(color.data.idata)); + } + RETURN_SCRIPT_VOID; +}
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/sgammagroup.h b/Src/Wasabi/api/script/objects/sgammagroup.h new file mode 100644 index 00000000..01113039 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sgammagroup.h @@ -0,0 +1,66 @@ +#ifndef __SGammagroup_H +#define __SGammagroup_H + +class SGamma; + +#include <api/script/script.h> +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> +#include <api/script/objects/rootobject.h> +#include <api/skin/skinelem.h> +#include <api/skin/gammamgr.h> +#define SGAMMAGROUP_SCRIPTPARENT RootObjectInstance + +class GammagroupScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern GammagroupScriptController *gammagroupController; + +class SGammagroup : public SGAMMAGROUP_SCRIPTPARENT { +public: + SGammagroup(); + SGammagroup(const wchar_t * parentSet, const wchar_t * grpName); + SGammagroup(const wchar_t * parentSet, int i); + virtual ~SGammagroup(); + +//protected: + ColorThemeGroup * grp; + const wchar_t * parentSet; + +private: + void __construct(); + +public: + static scriptVar script_vcpu_setRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + static scriptVar script_vcpu_setGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + static scriptVar script_vcpu_setBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + static scriptVar script_vcpu_setBoost(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + static scriptVar script_vcpu_setGray(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + static scriptVar script_vcpu_setID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color); + + static scriptVar script_vcpu_getRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBoost(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGray(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/sgammaset.cpp b/Src/Wasabi/api/script/objects/sgammaset.cpp new file mode 100644 index 00000000..e1913e43 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sgammaset.cpp @@ -0,0 +1,201 @@ +#include <precomp.h> +#include "SGammaset.h" + +#include <api.h> +#include <api/script/script.h> +#include <api/script/scriptmgr.h> +#include <api/script/objecttable.h> + +// {0D024DB9-9574-42d0-B8C7-26B553F1F987} +static const GUID gammasetSoGuid = +{ 0xd024db9, 0x9574, 0x42d0, { 0xb8, 0xc7, 0x26, 0xb5, 0x53, 0xf1, 0xf9, 0x87 } }; + +GammasetScriptController _gammasetController; +GammasetScriptController *gammasetController=&_gammasetController; + +// -- Functions table ------------------------------------- +function_descriptor_struct GammasetScriptController::exportedFunction[] = { + {L"apply", 0, (void*)SGammaset::script_vcpu_apply }, + {L"getID", 0, (void*)SGammaset::script_vcpu_getID }, + {L"rename", 1, (void*)SGammaset::script_vcpu_rename }, + {L"remove", 0, (void*)SGammaset::script_vcpu_update }, + {L"delete", 0, (void*)SGammaset::script_vcpu_delete }, + {L"getGeneralGroup", 0, (void*)SGammaset::script_vcpu_getDefaultGammaGroup }, + {L"getGammaGroup", 1, (void*)SGammaset::script_vcpu_getGammaGroup }, + {L"getNumGammaGroups", 0, (void*)SGammaset::script_vcpu_getNumGammaGroups }, + {L"enumGammaGroup", 0, (void*)SGammaset::script_vcpu_enumGammaGroup }, +}; +// -------------------------------------------------------- + +const wchar_t *GammasetScriptController::getClassName() { + return L"Gammaset"; +} + +const wchar_t *GammasetScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *GammasetScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *GammasetScriptController::instantiate() { + SGammaset *xd = new SGammaset; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void GammasetScriptController::destroy(ScriptObject *o) { + SGammaset *xd = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *GammasetScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for now +} + +void GammasetScriptController::deencapsulate(void *o) { +} + +int GammasetScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *GammasetScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID GammasetScriptController::getClassGuid() { + return gammasetSoGuid; +} + +void SGammaset::__construct() +{ + getScriptObject()->vcpu_setInterface(gammasetSoGuid, (void *)static_cast<SGammaset *>(this)); + getScriptObject()->vcpu_setClassName(L"Gammaset"); + getScriptObject()->vcpu_setController(gammasetController); + this->gammasetID = NULL; +} + +SGammaset::SGammaset() +{ + this->__construct(); +} + +SGammaset::SGammaset(const wchar_t * gammaSetID) +{ + this->__construct(); + this->gammasetID = gammaSetID; +} + +SGammaset::SGammaset(int n) +{ + this->__construct(); + this->gammasetID = WASABI_API_COLORTHEMES->enumGammaSet(n); +} + +SGammaset::~SGammaset() +{ +} + +// VCPU + +scriptVar SGammaset::script_vcpu_apply(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + WASABI_API_SKIN->colortheme_setColorSet(m->gammasetID); + //WASABI_API_COLORTHEMES->setGammaSet(m->gammasetID); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammaset::script_vcpu_update(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + WASABI_API_COLORTHEMES->updateGammaSet(m->gammasetID); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammaset::script_vcpu_delete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + WASABI_API_COLORTHEMES->deleteGammaSet(m->gammasetID); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammaset::script_vcpu_rename(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) { + SCRIPT_FUNCTION_INIT; + ASSERT(name.type == SCRIPT_STRING); + SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + WASABI_API_COLORTHEMES->renameGammaSet(m->gammasetID, name.data.sdata); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SGammaset::script_vcpu_getID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + return MAKE_SCRIPT_STRING(m->gammasetID); + } + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar SGammaset::script_vcpu_getDefaultGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + ScriptObject *s = NULL; + SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + SGammagroup *gg = new SGammagroup(m->gammasetID, -1); + if (gg != NULL && gg->grp != NULL) s = gg->getScriptObject(); + } + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SGammaset::script_vcpu_getGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) { + SCRIPT_FUNCTION_INIT; + ASSERT(name.type == SCRIPT_STRING); + ScriptObject *s = NULL; + SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + SGammagroup *gg = new SGammagroup(m->gammasetID, GET_SCRIPT_STRING(name)); + if (gg != NULL) s = gg->getScriptObject(); + } + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SGammaset::script_vcpu_enumGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n) { + SCRIPT_FUNCTION_INIT; + ASSERT(n.type == SCRIPT_INT); + ScriptObject *s = NULL; + SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + SGammagroup *gg = new SGammagroup(m->gammasetID, GET_SCRIPT_INT(n)); + if (gg != NULL) s = gg->getScriptObject(); + } + return MAKE_SCRIPT_OBJECT(s); +} + +scriptVar SGammaset::script_vcpu_getNumGammaGroups(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + int n = 0; + SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid)); + if (m) + { + n = WASABI_API_COLORTHEMES->getNumGammaGroups(m->gammasetID); + } + return MAKE_SCRIPT_INT(n); +}
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/sgammaset.h b/Src/Wasabi/api/script/objects/sgammaset.h new file mode 100644 index 00000000..ea4343d4 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sgammaset.h @@ -0,0 +1,62 @@ +#ifndef __SGammaset_H +#define __SGammaset_H + +class SGamma; + +#include <api/script/script.h> +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> +#include <api/script/objects/rootobject.h> +#include <api/skin/skinelem.h> +#include <api/skin/gammamgr.h> +#include "sgammagroup.h" +#define SGAMMASET_SCRIPTPARENT RootObjectInstance + +class GammasetScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern GammasetScriptController *gammasetController; + +class SGammaset : public SGAMMASET_SCRIPTPARENT { +public: + SGammaset(); + SGammaset(const wchar_t *); + SGammaset(int i); + virtual ~SGammaset(); + +protected: + const wchar_t *gammasetID; + +private: + void __construct(); + +public: + static scriptVar script_vcpu_apply(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_rename(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name); + static scriptVar script_vcpu_update(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_delete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getDefaultGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name); + static scriptVar script_vcpu_getNumGammaGroups(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_enumGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/slist.cpp b/Src/Wasabi/api/script/objects/slist.cpp new file mode 100644 index 00000000..1bfe53bf --- /dev/null +++ b/Src/Wasabi/api/script/objects/slist.cpp @@ -0,0 +1,172 @@ +#include <precomp.h> +#include "slist.h" + +#include <api/script/script.h> +#include <api/script/scriptmgr.h> + +ListScriptController _listController; +ListScriptController *listController=&_listController; + +// -- Functions table ------------------------------------- +function_descriptor_struct ListScriptController::exportedFunction[] = { + {L"addItem", 1, (void*)SList::script_vcpu_addItem }, + {L"removeItem", 1, (void*)SList::script_vcpu_removeItem }, + {L"enumItem", 1, (void*)SList::script_vcpu_enumItem }, + {L"findItem2", 2, (void*)SList::script_vcpu_findItem2 }, + {L"findItem", 1, (void*)SList::script_vcpu_findItem }, + {L"getNumItems", 0, (void*)SList::script_vcpu_getNumItems }, + {L"removeAll", 0, (void*)SList::script_vcpu_removeAll }, +}; +// -------------------------------------------------------- + +const wchar_t *ListScriptController::getClassName() { + return L"List"; +} + +const wchar_t *ListScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObject *ListScriptController::instantiate() { + SList *l = new SList; + ASSERT(l != NULL); + return l->getScriptObject(); +} + +void ListScriptController::destroy(ScriptObject *o) { + SList *obj = static_cast<SList *>(o->vcpu_getInterface(slistGuid)); + ASSERT(obj != NULL); + delete obj; +} + +void *ListScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for list yet +} + +void ListScriptController::deencapsulate(void *o) { +} + +int ListScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *ListScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID ListScriptController::getClassGuid() { + return slistGuid; +} + +//------------------------------------------------------------------------ + +SList::SList() { + getScriptObject()->vcpu_setInterface(slistGuid, (void *)static_cast<SList *>(this)); + getScriptObject()->vcpu_setClassName(L"List"); + getScriptObject()->vcpu_setController(listController); +} + +SList::~SList() { +} + +TList<scriptVar> *SList::getTList() { + return &list; +} + +scriptVar SList::script_vcpu_enumItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&i)); + SList *l = static_cast<SList *>(o->vcpu_getInterface(slistGuid)); + if (l) return l->getTList()->enumItem(SOM::makeInt(&i)); + RETURN_SCRIPT_ZERO; +} + +scriptVar SList::script_vcpu_addItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) { + SCRIPT_FUNCTION_INIT; + scriptVar dup; + dup = SOM::makeVar(obj.type); + SOM::assignPersistent(&dup, &obj); + SList *l = static_cast<SList *>(o->vcpu_getInterface(slistGuid)); + if (l) l->getTList()->addItem(dup); + RETURN_SCRIPT_VOID; +} + +scriptVar SList::script_vcpu_removeItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&i)); + SList *l = static_cast<SList *>(o->vcpu_getInterface(slistGuid)); + if (l) { + scriptVar dup = l->getTList()->enumItem(SOM::makeInt(&i)); + if (dup.type == SCRIPT_STRING) { + if (dup.data.odata) FREE(dup.data.odata); + } + l->getTList()->delByPos(SOM::makeInt(&i)); + } + RETURN_SCRIPT_VOID; +} + +scriptVar SList::script_vcpu_getNumItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SList *l = static_cast<SList *>(o->vcpu_getInterface(slistGuid)); + if (l) return MAKE_SCRIPT_INT(l->getTList()->getNumItems()); + return MAKE_SCRIPT_INT(0); +} + +scriptVar SList::script_vcpu_findItem2(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj, scriptVar start) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&start)); + SList *l = static_cast<SList *>(o->vcpu_getInterface(slistGuid)); + if (l) { + if (obj.type != SCRIPT_STRING) { + for (int i=SOM::makeInt(&start);i<l->getTList()->getNumItems();i++) { + if (!MEMCMP(&l->getTList()->enumItem(i), &obj, sizeof(scriptVar))) { + return MAKE_SCRIPT_INT(i); + } + } + } else { + for (int i=SOM::makeInt(&start);i<l->getTList()->getNumItems();i++) { + if (!wcscmp(l->getTList()->enumItem(i).data.sdata, obj.data.sdata)) { + return MAKE_SCRIPT_INT(i); + } + } + } + } + return MAKE_SCRIPT_INT(-1); +} + +scriptVar SList::script_vcpu_findItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj) { + SCRIPT_FUNCTION_INIT; + SList *l = static_cast<SList *>(o->vcpu_getInterface(slistGuid)); + if (l) { + if (obj.type != SCRIPT_STRING) { + for (int i=0;i<l->getTList()->getNumItems();i++) { + if (!MEMCMP(&l->getTList()->enumItem(i), &obj, sizeof(scriptVar))) { + return MAKE_SCRIPT_INT(i); + } + } + } else { + for (int i=0;i<l->getTList()->getNumItems();i++) { + if (!wcscmp(l->getTList()->enumItem(i).data.sdata, obj.data.sdata)) { + return MAKE_SCRIPT_INT(i); + } + } + } + } + return MAKE_SCRIPT_INT(-1); +} + +scriptVar SList::script_vcpu_removeAll(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SList *l = static_cast<SList *>(o->vcpu_getInterface(slistGuid)); + if (l) { + for (int i=0;i<l->getTList()->getNumItems();i++) { + scriptVar v = l->getTList()->enumItem(i); + if (v.type == SCRIPT_STRING) + FREE((wchar_t *)v.data.sdata); + } + l->getTList()->removeAll(); + } + RETURN_SCRIPT_VOID; +} + + diff --git a/Src/Wasabi/api/script/objects/slist.h b/Src/Wasabi/api/script/objects/slist.h new file mode 100644 index 00000000..c81c2dd6 --- /dev/null +++ b/Src/Wasabi/api/script/objects/slist.h @@ -0,0 +1,62 @@ +#ifndef __SLIST_H +#define __SLIST_H + +#include <api/script/objects/rootobject.h> +#include <api/script/objects/rootobj.h> +#include <bfc/ptrlist.h> +#include <bfc/tlist.h> +class ScriptObject; + +// {B2023AB5-434D-4ba1-BEAE-59637503F3C6} +static const GUID slistGuid = +{ 0xb2023ab5, 0x434d, 0x4ba1, { 0xbe, 0xae, 0x59, 0x63, 0x75, 0x3, 0xf3, 0xc6 } }; + +#define SLIST_SCRIPTPARENT RootObjectInstance + +class ListScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return rootScriptObjectController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern ListScriptController *listController; + + +class SList : public SLIST_SCRIPTPARENT { + +public: + SList(); + virtual ~SList(); + + TList<scriptVar> *getTList(); + +private: + TList<scriptVar> list; + +// -- SCRIPT ----------------------------------------------------- +public: +// INSERT_SCRIPT_OBJECT_CONTROL + static scriptVar script_vcpu_enumItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i); + static scriptVar script_vcpu_addItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar script_vcpu_removeItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar script_vcpu_getNumItems(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_findItem2(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj, scriptVar start); + static scriptVar script_vcpu_findItem(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar obj); + static scriptVar script_vcpu_removeAll(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/smap.cpp b/Src/Wasabi/api/script/objects/smap.cpp new file mode 100644 index 00000000..6c829628 --- /dev/null +++ b/Src/Wasabi/api/script/objects/smap.cpp @@ -0,0 +1,205 @@ +#include <precomp.h> +#include "smap.h" + +#include <api/script/script.h> +#include <api/script/scriptmgr.h> +#include <api/script/objects/sregion.h> +#include <api/script/objecttable.h> + +MapScriptController _mapController; +MapScriptController *mapController=&_mapController; + +// -- Functions table ------------------------------------- +function_descriptor_struct MapScriptController::exportedFunction[] = { + {L"getValue", 2, (void*)SMap::script_vcpu_getValue }, + {L"getARGBValue", 3, (void*)SMap::script_vcpu_getARGBValue }, + {L"inRegion", 2, (void*)SMap::script_vcpu_inRegion }, + {L"loadMap", 1, (void*)SMap::script_vcpu_loadMap }, + {L"getWidth", 0, (void*)SMap::script_vcpu_getWidth }, + {L"getHeight", 0, (void*)SMap::script_vcpu_getHeight }, + {L"getRegion", 0, (void*)SMap::script_vcpu_getRegion }, + // todo: stretch +}; +// -------------------------------------------------------- + +const wchar_t *MapScriptController::getClassName() { + return L"Map"; +} + +const wchar_t *MapScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *MapScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *MapScriptController::instantiate() { + SMap *m = new SMap; + ASSERT(m != NULL); + return m->getScriptObject(); +} + +void MapScriptController::destroy(ScriptObject *o) { + SMap *m = static_cast<SMap *>(o->vcpu_getInterface(mapGuid)); + ASSERT(m != NULL); + delete m; +} + +void *MapScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for maps for now +} + +void MapScriptController::deencapsulate(void *o) { +} + +int MapScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *MapScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID MapScriptController::getClassGuid() { + return mapGuid; +} + + + +SMap::SMap() { + getScriptObject()->vcpu_setInterface(mapGuid, (void *)static_cast<SMap *>(this)); + getScriptObject()->vcpu_setClassName(L"Map"); + getScriptObject()->vcpu_setController(mapController); + bmp = NULL; + region_so = ObjectTable::instantiate(ObjectTable::getClassFromName(L"Region")); + reg = static_cast<SRegion *>(region_so->vcpu_getInterface(regionGuid)); +} + +SMap::~SMap() { + if (bmp) delete bmp; + ObjectTable::destroy(region_so); +} + +int SMap::getValue(int x, int y) { + if (!bmp) return 0; + ARGB32 c = bmp->getPixel(x, y); +// if ((c & 0xFF000000) >> 24 != 0xFF) return -1; + int v = MAX(MAX((c & 0xFF0000) >> 16, (c & 0xFF00) >> 8), c & 0xFF); + return v; +} + +int SMap::getARGBValue(int x, int y, int whichCol) { + if (!bmp) return 0; + ARGB32 c = bmp->getPixel(x, y); + + whichCol %= 4; + + /** + whichCol + 0: blue + 1: green + 2: red + 3: alpha + */ + + ARGB32 a = c >> 24; + a &= 0x000000FF; //just to be sure + + if (whichCol == 3) return a; + + c = c >> (whichCol * 8); + c &= 0x000000FF; + + if (0 == a || 255 == a) return c; + + double d = c*255/a; // Correction for bitmaps w/ alpha channel, otherwise a lesser rgb value is returned + d = ceil(d); + + return (int)d; +} + +void SMap::loadMap(const wchar_t *b) +{ + bmp = new SkinBitmap(b, 0); + reg->loadFromBitmap(b); +} + +int SMap::getWidth() { + if (!bmp) return 0; + return bmp->getWidth(); +} + +int SMap::getHeight() { + if (!bmp) return 0; + return bmp->getHeight(); +} + +int SMap::inRegion(int x, int y) { + POINT pt={x,y}; + return reg->getRegion()->ptInRegion(&pt); +} + +SRegion *SMap::getSRegion() { + return reg; +} + +// VCPU + +scriptVar SMap::script_vcpu_loadMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar bmp) { + SCRIPT_FUNCTION_INIT; + ASSERT(bmp.type == SCRIPT_STRING); + SMap *m = static_cast<SMap *>(o->vcpu_getInterface(mapGuid)); + if (m) m->loadMap(bmp.data.sdata); + RETURN_SCRIPT_VOID; +} + +scriptVar SMap::script_vcpu_getValue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + SMap *m = static_cast<SMap *>(o->vcpu_getInterface(mapGuid)); + if (m) return MAKE_SCRIPT_INT(m->getValue(SOM::makeInt(&x), SOM::makeInt(&y))); + RETURN_SCRIPT_ZERO; +} + +scriptVar SMap::script_vcpu_getARGBValue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar wichCol) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + ASSERT(SOM::isNumeric(&wichCol)); + SMap *m = static_cast<SMap *>(o->vcpu_getInterface(mapGuid)); + if (m) return MAKE_SCRIPT_INT(m->getARGBValue(SOM::makeInt(&x), SOM::makeInt(&y), SOM::makeInt(&wichCol))); + RETURN_SCRIPT_ZERO; +} + +scriptVar SMap::script_vcpu_getWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SMap *m = static_cast<SMap *>(o->vcpu_getInterface(mapGuid)); + if (m) return MAKE_SCRIPT_INT(m->getWidth()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SMap::script_vcpu_getHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SMap *m = static_cast<SMap *>(o->vcpu_getInterface(mapGuid)); + if (m) return MAKE_SCRIPT_INT(m->getHeight()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SMap::script_vcpu_inRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + SMap *m = static_cast<SMap *>(o->vcpu_getInterface(mapGuid)); + if (m) return MAKE_SCRIPT_BOOLEAN(m->inRegion(SOM::makeInt(&x), SOM::makeInt(&y))); + RETURN_SCRIPT_ZERO; +} + +scriptVar SMap::script_vcpu_getRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SMap *m = static_cast<SMap *>(o->vcpu_getInterface(mapGuid)); + if (m) { + SRegion *s = m->getSRegion(); + if (s) return MAKE_SCRIPT_OBJECT(s->getScriptObject()); + } + RETURN_SCRIPT_ZERO; +}
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/smap.h b/Src/Wasabi/api/script/objects/smap.h new file mode 100644 index 00000000..7cd04b41 --- /dev/null +++ b/Src/Wasabi/api/script/objects/smap.h @@ -0,0 +1,74 @@ +#ifndef __SMAP_H +#define __SMAP_H + +class SMap; +class SRegion; + +#include <tataki/bitmap/bitmap.h> +#include <api/script/script.h> +#ifdef WASABI_WIDGETS_GUIOBJECT +#include <api/script/objects/guiobj.h> +#endif +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> + +// {38603665-461B-42a7-AA75-D83F6667BF73} +static const GUID mapGuid = +{ 0x38603665, 0x461b, 0x42a7, { 0xaa, 0x75, 0xd8, 0x3f, 0x66, 0x67, 0xbf, 0x73 } }; + +#define SMAP_SCRIPTPARENT RootObjectInstance + +class MapScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern MapScriptController *mapController; + +class SMap : public SMAP_SCRIPTPARENT { +public: + SMap(); + virtual ~SMap(); + + int getValue(int x, int y); + int getARGBValue(int x, int y, int whichCol); + int inRegion(int x, int y); + int getWidth(); + int getHeight(); + void loadMap(const wchar_t *b); + static void instantiate(SMap *s); + virtual SkinBitmap *getBitmap() { return bmp; }; + SRegion *getSRegion(); + +private: + SkinBitmap *bmp; + SRegion *reg; + ScriptObject *region_so; + +public: + static scriptVar script_vcpu_loadMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar bitmap); + static scriptVar script_vcpu_getValue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar script_vcpu_getARGBValue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y, scriptVar whichCol); + static scriptVar script_vcpu_getWidth(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getHeight(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_inRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar script_vcpu_getRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/spopup.cpp b/Src/Wasabi/api/script/objects/spopup.cpp new file mode 100644 index 00000000..84cc6254 --- /dev/null +++ b/Src/Wasabi/api/script/objects/spopup.cpp @@ -0,0 +1,140 @@ +#include <precomp.h> +#include <api/script/objects/spopup.h> +#include <api/script/scriptmgr.h> + +SPopup::SPopup() { + getScriptObject()->vcpu_setInterface(popupGuid, (void *)static_cast<SPopup*>(this)); + getScriptObject()->vcpu_setClassName(L"Popup"); + getScriptObject()->vcpu_setController(popupController); +} + +SPopup::~SPopup() { +} + +PopupScriptController _popupController; +PopupScriptController *popupController = &_popupController; + +// -- Functions table ------------------------------------- +function_descriptor_struct PopupScriptController::exportedFunction[] = { + {L"addSubMenu", 2, (void*)SPopup::script_vcpu_addSubMenu }, + {L"addCommand", 4, (void*)SPopup::script_vcpu_addCommand }, + {L"addSeparator", 0, (void*)SPopup::script_vcpu_addSeparator }, + {L"popAtXY", 2, (void*)SPopup::script_vcpu_popAtXY }, + {L"popAtMouse", 0, (void*)SPopup::script_vcpu_popAtMouse }, + {L"getNumCommands", 0, (void*)SPopup::script_vcpu_getNumCommands }, + {L"checkCommand", 2, (void*)SPopup::script_vcpu_checkCommand }, + {L"disableCommand", 2, (void*)SPopup::script_vcpu_disableCommand }, + +//todo: events +}; + +// -------------------------------------------------------- +const wchar_t *PopupScriptController::getClassName() { + return L"Popup"; +} + +const wchar_t *PopupScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObject *PopupScriptController::instantiate() { + SPopup *p = new SPopup; + ASSERT(p != NULL); + return p->getScriptObject(); +} + +void PopupScriptController::destroy(ScriptObject *o) { + SPopup *p = static_cast<SPopup *>(o->vcpu_getInterface(popupGuid)); + ASSERT(p != NULL); + delete p; +} + +void *PopupScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for popups yet +} + +void PopupScriptController::deencapsulate(void *o) { +} + +int PopupScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *PopupScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID PopupScriptController::getClassGuid() { + return popupGuid; +} + +// ----------------------------------------------------------------------- +scriptVar SPopup::script_vcpu_addSubMenu(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar popup, scriptVar str) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(str.type == SCRIPT_STRING); // compiler discarded + SPopup *p = static_cast<SPopup *>(o->vcpu_getInterface(popupGuid)); + SPopup *p2 = static_cast<SPopup *>(GET_SCRIPT_OBJECT_AS(popup, popupGuid)); + if (p) p->addSubMenu(p2, GET_SCRIPT_STRING(str)); + RETURN_SCRIPT_VOID; +} + +scriptVar SPopup::script_vcpu_addCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str, scriptVar cmd, scriptVar checked, scriptVar disabled) { + SCRIPT_FUNCTION_INIT; + ASSERT(str.type == SCRIPT_STRING); // compiler discarded + ASSERT(SOM::isNumeric(&cmd)); // compiler discarded + ASSERT(SOM::isNumeric(&checked)); // compiler discarded + ASSERT(SOM::isNumeric(&disabled)); // compiler discarded + SPopup *p = static_cast<SPopup *>(o->vcpu_getInterface(popupGuid)); + if (p) + p->addCommand(str.data.sdata, SOM::makeInt(&cmd), SOM::makeBoolean(&checked), SOM::makeBoolean(&disabled)); + RETURN_SCRIPT_VOID; +} + +scriptVar SPopup::script_vcpu_addSeparator(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SPopup *p = static_cast<SPopup *>(o->vcpu_getInterface(popupGuid)); + if (p) p->addSeparator(); + RETURN_SCRIPT_VOID; +} + +scriptVar SPopup::script_vcpu_checkCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i, scriptVar check) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&i)); + ASSERT(SOM::isNumeric(&check)); + SPopup *p = static_cast<SPopup *>(o->vcpu_getInterface(popupGuid)); + if (p) p->checkCommand(SOM::makeInt(&i), SOM::makeBoolean(&check)); + RETURN_SCRIPT_VOID; +} + +scriptVar SPopup::script_vcpu_disableCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar i, scriptVar disable) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&i)); + ASSERT(SOM::isNumeric(&disable)); + SPopup *p = static_cast<SPopup *>(o->vcpu_getInterface(popupGuid)); + if (p) p->disableCommand(SOM::makeInt(&i), SOM::makeBoolean(&disable)); + RETURN_SCRIPT_VOID; +} + +scriptVar SPopup::script_vcpu_popAtXY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + SPopup *p = static_cast<SPopup *>(o->vcpu_getInterface(popupGuid)); + if (p) return MAKE_SCRIPT_INT(p->popAtXY(SOM::makeInt(&x), SOM::makeInt(&y))); + RETURN_SCRIPT_ZERO; +} + +scriptVar SPopup::script_vcpu_popAtMouse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SPopup *p = static_cast<SPopup *>(o->vcpu_getInterface(popupGuid)); + if (p) return MAKE_SCRIPT_INT(p->popAtMouse()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SPopup::script_vcpu_getNumCommands(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SPopup *p = static_cast<SPopup *>(o->vcpu_getInterface(popupGuid)); + if (p) return MAKE_SCRIPT_INT(p->getNumCommands()); + RETURN_SCRIPT_ZERO; +} diff --git a/Src/Wasabi/api/script/objects/spopup.h b/Src/Wasabi/api/script/objects/spopup.h new file mode 100644 index 00000000..07bd82df --- /dev/null +++ b/Src/Wasabi/api/script/objects/spopup.h @@ -0,0 +1,60 @@ +//PORTABLE +#ifndef _SPOPUP_H +#define _SPOPUP_H + +#include <api/wnd/popup.h> +#include <api/script/objects/rootobject.h> + +// {F4787AF4-B2BB-4ef7-9CFB-E74BA9BEA88D} +static const GUID popupGuid = +{ 0xf4787af4, 0xb2bb, 0x4ef7, { 0x9c, 0xfb, 0xe7, 0x4b, 0xa9, 0xbe, 0xa8, 0x8d } }; + +#define SPOPUP_PARENT PopupMenu + +class PopupScriptController: public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return rootScriptObjectController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern PopupScriptController *popupController; + + +#ifndef WANT_NEW_POPUPMENU +class SPopup : public SPOPUP_PARENT, public RootObjectInstance { +#else +class SPopup : public SPOPUP_PARENT { +#endif +public: + SPopup(); + virtual ~SPopup(); + +private: + +public: + + static scriptVar script_vcpu_addSubMenu(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar popup, scriptVar str); + static scriptVar script_vcpu_addCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str, scriptVar cmd, scriptVar checked, scriptVar disabled); + static scriptVar script_vcpu_addSeparator(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_popAtXY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar script_vcpu_popAtMouse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getNumCommands(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_disableCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar cmd, scriptVar disable); + static scriptVar script_vcpu_checkCommand(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar cmd, scriptVar check); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/sprivate.cpp b/Src/Wasabi/api/script/objects/sprivate.cpp new file mode 100644 index 00000000..515fbb08 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sprivate.cpp @@ -0,0 +1,258 @@ +#include <precomp.h> +#include "sprivate.h" +#include "main.h" +#include <api/application/api_application.h> +#include "wa2frontend.h" +#include <api.h> +#include "../Agave/Language/api_language.h" +#include "../../../../Components/wac_network/wac_network_http_receiver_api.h" +#include "../nu/AutoWide.h" +#include "../nu/AutoChar.h" +#include "../nu/ns_wc.h" +#include "../Winamp/buildtype.h" +#include "../nu/refcount.h" +#include <shlobj.h> +#include <shlwapi.h> + +// {78BD6ED9-0DBC-4fa5-B5CD-5977E3A912F8} +static const GUID SPrivate_script_object_guid = +{ 0x78bd6ed9, 0xdbc, 0x4fa5, { 0xb5, 0xcd, 0x59, 0x77, 0xe3, 0xa9, 0x12, 0xf8 } }; + + +static SPrivateScriptObjectController _SPrivateController; +ScriptObjectController *SPrivateController=&_SPrivateController; + +// -- Functions table ------------------------------------- +function_descriptor_struct SPrivateScriptObjectController::exportedFunction[] = +{ + {L"updateLinks", 2, (void*)SPrivate::vcpu_updateLinks }, + {L"onLinksUpdated", 1, (void*)SPrivate::vcpu_onLinksUpdated }, +}; +// -------------------------------------------------------- + +const wchar_t *SPrivateScriptObjectController::getClassName() +{ + return L"Private"; +} + +const wchar_t *SPrivateScriptObjectController::getAncestorClassName() +{ + return L"Object"; +} + +ScriptObjectController *SPrivateScriptObjectController::getAncestorController() +{ + return NULL; +} + +ScriptObject *SPrivateScriptObjectController::instantiate() +{ + SPrivate *c = new SPrivate; + if (!c) return NULL; + return c->getScriptObject(); +} + +int SPrivateScriptObjectController::getInstantiable() +{ + return 1; +} + +void SPrivateScriptObjectController::destroy(ScriptObject *o) +{ + SPrivate *obj = static_cast<SPrivate *>(o->vcpu_getInterface(SPrivate_script_object_guid)); + ASSERT(obj != NULL); + obj->dlcb = false; + delete obj; +} + +void *SPrivateScriptObjectController::encapsulate(ScriptObject *o) +{ + return NULL; +} + +void SPrivateScriptObjectController::deencapsulate(void *o) +{ +} + +int SPrivateScriptObjectController::getNumFunctions() +{ + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *SPrivateScriptObjectController::getExportedFunctions() +{ + return exportedFunction; +} + +GUID SPrivateScriptObjectController::getClassGuid() +{ + return SPrivate_script_object_guid; +} + +/*-----------------------------------*/ + +static void DoAPC(PAPCFUNC apc, ULONG_PTR data) +{ + HANDLE hMainThread = WASABI_API_APP->main_getMainThreadHandle(); + if (hMainThread) + { + QueueUserAPC(apc, hMainThread, data); + CloseHandle(hMainThread); + } +} + +static void CALLBACK LinksUpdatedAPC(ULONG_PTR data) +{ + ScriptObject* scriptCallback = (ScriptObject *)data; + SPrivate::vcpu_onLinksUpdated(SCRIPT_CALL, scriptCallback); +} + +class PDownloadCallback : public Countable<ifc_downloadManagerCallback> +{ +public: + PDownloadCallback (const char *url, ScriptObject* scriptCallback) + { + this->scriptCallback = scriptCallback; + validSO = true; + } + + ~PDownloadCallback () + { + } + + + void OnFinish (DownloadToken token) + { + if (!validSO) + { + DeleteFileW(WAC_API_DOWNLOADMANAGER->GetLocation(token)); + delete this; + return; + } + + api_httpreceiver *http = WAC_API_DOWNLOADMANAGER->GetReceiver(token); + if (http) + { + int replyCode; + replyCode = http->getreplycode(); + if (204 != replyCode) + { + BOOL succeeded; + HANDLE hDest; + const wchar_t *downloadDest; + wchar_t finalFileName[MAX_PATH] = {0}; + + downloadDest = WAC_API_DOWNLOADMANAGER->GetLocation(token); + succeeded = FALSE; + + hDest = CreateFileW(downloadDest, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, 0, NULL); + if (INVALID_HANDLE_VALUE != hDest) + { + LARGE_INTEGER fileSize; + if (FALSE != GetFileSizeEx(hDest, &fileSize) && + 0 != fileSize.QuadPart) + { + succeeded = TRUE; + } + + CloseHandle(hDest); + + if (FALSE == succeeded) + { + DeleteFileW(downloadDest); + downloadDest = NULL; + } + } + + if (FALSE != succeeded && + NULL != (PathCombineW(finalFileName, WASABI_API_APP->path_getUserSettingsPath(), L"links.xml"))) + { + // then move the file there + succeeded = MoveFileW(downloadDest, finalFileName); + if (FALSE == succeeded) + { + succeeded = CopyFileW(downloadDest, finalFileName, FALSE); + DeleteFileW(downloadDest); + } + if (FALSE != succeeded) + { + // hop back on the main thread for the callback + DoAPC(LinksUpdatedAPC, (ULONG_PTR)scriptCallback); + } + } + } + } + Release(); + } + + void OnError (DownloadToken token, int error) + { + Release(); + } + void OnCancel (DownloadToken token) + { + Release(); + } + + void OnTick (DownloadToken token) {} + + ScriptObject* scriptCallback; + bool validSO; + REFERENCE_COUNT_IMPLEMENTATION; + +protected: + RECVS_DISPATCH; +}; + + +SPrivate::SPrivate() +{ + getScriptObject()->vcpu_setInterface(SPrivate_script_object_guid, static_cast<SPrivate *>(this)); + getScriptObject()->vcpu_setClassName(L"Private"); + getScriptObject()->vcpu_setController(SPrivateController); + dlcb = false; +} +SPrivate::~SPrivate() +{ +} + +scriptVar SPrivate::vcpu_updateLinks(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar version, scriptVar bversion) +{ + SCRIPT_FUNCTION_INIT; + + String url; + + //if defined(BETA) || defined(INTERNAL) + const wchar_t *langIdentifier = WASABI_API_LNG?(WASABI_API_LNG->GetLanguageIdentifier(LANG_IDENT_STR)):0; + if (!langIdentifier) + langIdentifier = L"en-US"; + + url = StringPrintf("http://client.winamp.com/data/skins?o=links&sid=bento&version=%s&waversion=%s&build=%i&browserversion=%s&lang=%s", AutoChar(version.data.sdata), WASABI_API_APP->main_getVersionNumString(), WASABI_API_APP->main_getBuildNumber(),AutoChar(bversion.data.sdata), AutoChar(langIdentifier)); + //url = StringPrintf("http://martin.skinconsortium.com/links.php?o=links&sid=bento&version=%s&waversion=%s&build=%i&browserversion=%s", AutoChar(version.data.sdata), WASABI_API_APP->main_getVersionNumString(), WASABI_API_APP->main_getBuildNumber(),AutoChar(bversion.data.sdata)); + + SPrivate *sp = static_cast<SPrivate *>(object->vcpu_getInterface(SPrivate_script_object_guid)); + sp->dlcb = new PDownloadCallback(url, object); + WAC_API_DOWNLOADMANAGER->Download(url, sp->dlcb); + + RETURN_SCRIPT_VOID; +} + +scriptVar SPrivate::vcpu_onLinksUpdated(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, SPrivateController); + SCRIPT_FUNCTION_CHECKABORTEVENT(o); + SCRIPT_EXEC_EVENT0(o); +} + + +#define CBCLASS PDownloadCallback +START_DISPATCH; +REFERENCE_COUNTED; +VCB(IFC_DOWNLOADMANAGERCALLBACK_ONFINISH, OnFinish) +VCB(IFC_DOWNLOADMANAGERCALLBACK_ONTICK, OnTick) +VCB(IFC_DOWNLOADMANAGERCALLBACK_ONERROR, OnError) +VCB(IFC_DOWNLOADMANAGERCALLBACK_ONCANCEL, OnCancel) +END_DISPATCH; +#undef CBCLASS
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/sprivate.h b/Src/Wasabi/api/script/objects/sprivate.h new file mode 100644 index 00000000..503fbb1a --- /dev/null +++ b/Src/Wasabi/api/script/objects/sprivate.h @@ -0,0 +1,47 @@ +#pragma once +#include <api/script/api_maki.h> +#include <api/script/script.h> +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> +#include <api/script/objects/rootobject.h> + +class PDownloadCallback; + +#define SPRIVATE_SCRIPTPARENT RootObjectInstance + +class SPrivateScriptObjectController : public ScriptObjectControllerI +{ + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual int getInstantiable(); + virtual int getReferenceable() {return 0;} + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + static function_descriptor_struct exportedFunction[]; + +}; + +extern ScriptObjectController *SPrivateController; + +class SPrivate : public SPRIVATE_SCRIPTPARENT +{ +public: + SPrivate(); + virtual ~SPrivate(); + + PDownloadCallback * dlcb; + +public: + static scriptVar vcpu_updateLinks(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar version, scriptVar bversion); + static scriptVar vcpu_onLinksUpdated(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; diff --git a/Src/Wasabi/api/script/objects/sregion.cpp b/Src/Wasabi/api/script/objects/sregion.cpp new file mode 100644 index 00000000..0a966f8a --- /dev/null +++ b/Src/Wasabi/api/script/objects/sregion.cpp @@ -0,0 +1,256 @@ +#include <precomp.h> +#include "sregion.h" + +#include <api/script/script.h> +#include <api/script/scriptmgr.h> + +RegionScriptController _regionController; +RegionScriptController *regionController=&_regionController; + +// -- Functions table ------------------------------------- +function_descriptor_struct RegionScriptController::exportedFunction[] = { + {L"add", 1, (void*)SRegion::script_vcpu_add }, + {L"sub", 1, (void*)SRegion::script_vcpu_sub }, + {L"offset", 2, (void*)SRegion::script_vcpu_offset }, + {L"stretch", 1, (void*)SRegion::script_vcpu_stretch }, + {L"copy", 1, (void*)SRegion::script_vcpu_copy }, + {L"loadFromMap", 3, (void*)SRegion::script_vcpu_loadFromMap }, + {L"loadFromBitmap", 1, (void*)SRegion::script_vcpu_loadFromBitmap }, + {L"getBoundingBoxX", 0, (void*)SRegion::script_vcpu_getBoundX }, + {L"getBoundingBoxY", 0, (void*)SRegion::script_vcpu_getBoundY }, + {L"getBoundingBoxW", 0, (void*)SRegion::script_vcpu_getBoundW }, + {L"getBoundingBoxH", 0, (void*)SRegion::script_vcpu_getBoundH }, +}; +// -------------------------------------------------------- + +const wchar_t *RegionScriptController::getClassName() { + return L"Region"; +} + +const wchar_t *RegionScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *RegionScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *RegionScriptController::instantiate() { + SRegion *r = new SRegion; + ASSERT(r != NULL); + return r->getScriptObject(); +} + +void RegionScriptController::destroy(ScriptObject *o) { + SRegion *r = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + ASSERT(r != NULL); + delete r; +} + +void *RegionScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for regions yet +} + +void RegionScriptController::deencapsulate(void *o) { +} + +int RegionScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *RegionScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID RegionScriptController::getClassGuid() { + return regionGuid; +} + +SRegion::SRegion() { + getScriptObject()->vcpu_setInterface(regionGuid, (void *)static_cast<SRegion*>(this)); + getScriptObject()->vcpu_setClassName(L"Region"); + getScriptObject()->vcpu_setController(regionController); + reg = new RegionI; +} + +SRegion::~SRegion() { + delete reg; +} + +int SRegion::inRegion(int x, int y) { + if (!reg) return 0; + POINT pt={x,y}; + return reg->ptInRegion(&pt); +} + +int SRegion::getBoundX() { + if (!reg) return 0; + RECT r; + reg->getBox(&r); + return r.left; +} + +int SRegion::getBoundY() { + if (!reg) return 0; + RECT r; + reg->getBox(&r); + return r.top; +} + +int SRegion::getBoundW() { + if (!reg) return 0; + RECT r; + reg->getBox(&r); + return r.right-r.left; +} + +int SRegion::getBoundH() { + if (!reg) return 0; + RECT r; + reg->getBox(&r); + return r.bottom-r.top; +} + +api_region *SRegion::getRegion() { + return reg; +} + +void SRegion::addRegion(SRegion *s) { + if (!reg) reg = new RegionI; + reg->addRegion(s->getRegion()); +} + +void SRegion::subRegion(SRegion *s) { + if (!reg) return; + reg->subtractRgn(s->getRegion()); +} + +void SRegion::offset(int x, int y) { + if (!reg) return; + reg->offset(x, y); +} + +void SRegion::stretch(double s) { + if (!reg) return; + reg->scale(s, s); +} + +void SRegion::copy(SRegion *s) { + if (!reg) reg = new RegionI; + else reg->empty(); + reg->addRegion(s->getRegion()); +} + +void SRegion::loadFromMap(SMap *m, int byte, int inverted) { + delete reg; + RECT r={m->getBitmap()->getX(), m->getBitmap()->getY(), m->getBitmap()->getWidth(), m->getBitmap()->getHeight()}; + reg = new RegionI(m->getBitmap(), &r, 0, 0, FALSE, 1, byte, inverted); +} + +void SRegion::loadFromBitmap(const wchar_t *p) +{ + delete reg; + SkinBitmap *b = new SkinBitmap(p); + ASSERT(b); // TODO: should be guru + reg = new RegionI(b); + delete b; +} + +// ----------------------------------------------------------------------- + +scriptVar SRegion::script_vcpu_loadFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inv) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&byte)); + ASSERT(SOM::isNumeric(&inv)); + SRegion *r = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + SMap *m = static_cast<SMap *>(GET_SCRIPT_OBJECT_AS(map, mapGuid)); + if (r) r->loadFromMap(m, GET_SCRIPT_INT(byte), GET_SCRIPT_BOOLEAN(inv)); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_loadFromBitmap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar b) +{ + SCRIPT_FUNCTION_INIT; + ASSERT(b.type == SCRIPT_STRING); + SRegion *r = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + if (r) r->loadFromBitmap(GET_SCRIPT_STRING(b)); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_inRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + SRegion *r = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + if (r) return MAKE_SCRIPT_INT(r->inRegion(GET_SCRIPT_INT(x), GET_SCRIPT_INT(y))); + RETURN_SCRIPT_ZERO; +} + +scriptVar SRegion::script_vcpu_add(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) { + SCRIPT_FUNCTION_INIT; + SRegion *r1 = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + SRegion *r2 = static_cast<SRegion *>(GET_SCRIPT_OBJECT_AS(r, regionGuid)); + if (r1) r1->addRegion(r2); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_sub(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) { + SCRIPT_FUNCTION_INIT; + SRegion *r1 = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + SRegion *r2 = static_cast<SRegion *>(GET_SCRIPT_OBJECT_AS(r, regionGuid)); + if (r1) r1->subRegion(r2); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_offset(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&x)); + ASSERT(SOM::isNumeric(&y)); + SRegion *r = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + if (r) r->offset(GET_SCRIPT_INT(x), GET_SCRIPT_INT(y)); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_stretch(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&s)); + SRegion *r = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + if (r) r->stretch(SOM::makeDouble(&s)); + RETURN_SCRIPT_VOID; +} + +scriptVar SRegion::script_vcpu_getBoundX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SRegion *r = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + if (r) return MAKE_SCRIPT_INT(r->getBoundX()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SRegion::script_vcpu_getBoundY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SRegion *r = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + if (r) return MAKE_SCRIPT_INT(r->getBoundY()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SRegion::script_vcpu_getBoundW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SRegion *r = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + if (r) return MAKE_SCRIPT_INT(r->getBoundW()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SRegion::script_vcpu_getBoundH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SRegion *r = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + if (r) return MAKE_SCRIPT_INT(r->getBoundH()); + RETURN_SCRIPT_ZERO; +} + +scriptVar SRegion::script_vcpu_copy(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r) { + SCRIPT_FUNCTION_INIT; + SRegion *r1 = static_cast<SRegion *>(o->vcpu_getInterface(regionGuid)); + SRegion *r2 = static_cast<SRegion *>(GET_SCRIPT_OBJECT_AS(r, regionGuid)); + if (r1) r1->copy(r2); + RETURN_SCRIPT_VOID; +} + + diff --git a/Src/Wasabi/api/script/objects/sregion.h b/Src/Wasabi/api/script/objects/sregion.h new file mode 100644 index 00000000..00d0e607 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sregion.h @@ -0,0 +1,92 @@ +#ifndef __SREGION_H +#define __SREGION_H + +class SRegion; + +#ifndef _NOSTUDIO + +#include <tataki/region/region.h> +#include <api/script/objects/smap.h> + +#endif + +#include <api/script/script.h> +#include <api/script/scriptobj.h> + +// {3A370C02-3CBF-439f-84F1-86885BCF1E36} +static const GUID regionGuid = +{ 0x3a370c02, 0x3cbf, 0x439f, { 0x84, 0xf1, 0x86, 0x88, 0x5b, 0xcf, 0x1e, 0x36 } }; + +#define SREGION_SCRIPTPARENT RootObjectInstance + +class RegionScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern RegionScriptController *regionController; + + +#ifndef _NOSTUDIO + +class SRegion : public SREGION_SCRIPTPARENT { +public: + SRegion(); + virtual ~SRegion(); + + int inRegion(int x, int y); + void loadFromMap(SMap *map, int byte, int inv); + void loadFromBitmap(const wchar_t *p); + int getBoundX(); + int getBoundY(); + int getBoundW(); + int getBoundH(); + api_region *getRegion(); + void addRegion(SRegion *s); + void subRegion(SRegion *s); + void offset(int x, int y); + void stretch(double s); + void copy(SRegion *s); + + +private: + RegionI *reg; + +#else +class SRegion : SREGION_SCRIPTPARENT { +#endif + +// FG> +// -- SCRIPT ----------------------------------------------------- +public: + static scriptVar script_vcpu_loadFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inv); + static scriptVar script_vcpu_loadFromBitmap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map); + static scriptVar script_vcpu_inRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar script_vcpu_add(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar script_vcpu_sub(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar script_vcpu_offset(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar x, scriptVar y); + static scriptVar script_vcpu_stretch(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar s); + static scriptVar script_vcpu_copy(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar r); + static scriptVar script_vcpu_getBoundX(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBoundY(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBoundW(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getBoundH(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/svcwnd.cpp b/Src/Wasabi/api/script/objects/svcwnd.cpp new file mode 100644 index 00000000..2ab301e9 --- /dev/null +++ b/Src/Wasabi/api/script/objects/svcwnd.cpp @@ -0,0 +1,239 @@ +#include "precomp.h" +#include "../../bfc/std.h" +#include "script.h" +#include "scriptmgr.h" +#include "../../bfc/notifmsg.h" +#include "../../common/script/scriptobj.h" +#include "compoobj.h" +#include "../api.h" +#include "vcpu.h" +#include "../smap.h" +#include "../skinparse.h" +#include "svcwnd.h" +#include "../services/services.h" +#include "../services/servicei.h" +#include "../svcmgr.h" +#include "../services/svc_wndcreate.h" + +char svcWndXuiObjectStr[] = "SvcWnd"; // This is the xml tag +char svcWndXuiSvcName[] = "SvcWnd xui object"; // this is the name of the xuiservice + + +SvcWndScriptController _svcWndController; +SvcWndScriptController *svcWndController = &_svcWndController; + +// -- Functions table ------------------------------------- +function_descriptor_struct SvcWndScriptController::exportedFunction[] = { + {"getGUID", 1, (void*)SvcWnd::script_vcpu_getGUID }, + {"getWac", 0, (void*)SvcWnd::script_vcpu_getWac }, +}; +// -------------------------------------------------------- + +const wchar_t *SvcWndScriptController::getClassName() { + return L"SvcGuiObject"; +} + +const wchar_t *SvcWndScriptController::getAncestorClassName() { + return "GuiObject"; +} + +int SvcWndScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *SvcWndScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID SvcWndScriptController::getClassGuid() { + return svcWndGuid; +} + +ScriptObject *SvcWndScriptController::instantiate() { + SvcWnd *sv = new SvcWnd(); + ASSERT(sv != NULL); + return sv->getScriptObject(); +} + +void SvcWndScriptController::destroy(ScriptObject *o) { + SvcWnd *obj = static_cast<SvcWnd*>(o->vcpu_getInterface(svcWndGuid)); + ASSERT(obj != NULL); + delete obj; +} + +void *SvcWndScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for svcwnd yet +} + +void SvcWndScriptController::deencapsulate(void *o) { +} + +char SvcWndParams[][] = +{ + "DBLCLICKACTION", //SVCWND_DBLCLKACTION + "GUID" // SVCWND_GUID +}; +SvcWnd::SvcWnd() { + getScriptObject()->vcpu_setInterface(svcWndGuid, (void *)static_cast<SvcWnd*>(this)); + getScriptObject()->vcpu_setClassName("SvcGuiObject"); + getScriptObject()->vcpu_setController(svcWndController); + myGUID = INVALID_GUID; + svcwnd = NULL; + svc = NULL; + forwarded = 0; + xuihandle = newXuiHandle(); + + addParam(xuihandle, SvcWndParams[0], SVCWND_DBLCLKACTION, XUI_ATTRIBUTE_IMPLIED); + addParam(xuihandle, SvcWndParams[1], SVCWND_GUID, XUI_ATTRIBUTE_IMPLIED); + +} + +// servicewnd to svcwnd + +int SvcWnd::childNotify(api_window *child, int msg, intptr_t param1, intptr_t param2) { + if (child == svcwnd) { + switch (msg) { + case ChildNotify::SVCWND_LBUTTONDOWN: + onLeftButtonDown(param1, param2); + break; + case ChildNotify::SVCWND_RBUTTONDOWN: + onRightButtonDown(param1, param2); + break; + case ChildNotify::SVCWND_LBUTTONUP: + onLeftButtonUp(param1, param2); + break; + case ChildNotify::SVCWND_RBUTTONUP: + onRightButtonUp(param1, param2); + break; + case ChildNotify::SVCWND_LBUTTONDBLCLK: + onLeftButtonDblClk(param1, param2); + break; + case ChildNotify::SVCWND_RBUTTONDBLCLK: + onRightButtonDblClk(param1, param2); + break; + case ChildNotify::SVCWND_MOUSEMOVE: + onMouseMove(param1, param2); + break; + } + forwarded = 0; + } else + return SVCWND_PARENT::childNotify(child, msg, param1, param2); + return 1; +} + +// virtualwnd to guiobject bridging + +int SvcWnd::onLeftButtonDblClk(int x, int y) { + if(!dblClickAction.isempty()) { + const char *toCheck="SWITCH;"; + if(!STRNINCMP(dblClickAction,toCheck)) { + onLeftButtonUp(x,y); + getGuiObject()->guiobject_getParentGroup()->getParentContainer()->switchToLayout(dblClickAction.getValue()+STRLEN(toCheck)); + } + } + return SVCWND_PARENT::onLeftButtonDblClk(x, y); +} + +int SvcWnd::onResize() { + SVCWND_PARENT::onResize(); + RECT r = clientRect(); + if (svcwnd) + svcwnd->resize(r.left, r.top, r.right-r.left, r.bottom-r.top); + return 1; +} + +void SvcWnd::onSetVisible(int v) { + if (svcwnd) svcwnd->setVisible(v); + SVCWND_PARENT::onSetVisible(v); +} + +int SvcWnd::setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) { + if (_xuihandle == xuihandle) { + switch (xmlattributeid) { + case SVCWND_GUID: { + GUID *g; + g = SkinParser::getComponentGuid(value); + if (g) + setGUID(*g); + return 1; + } + case SVCWND_DBLCLKACTION: + dblClickAction = value; + return 1; + } + } + return SVCWND_PARENT::setXuiParam(_xuihandle,xmlattributeid,xmlattributename,value); +} + +int SvcWnd::onUnknownXuiParam(const wchar_t *param, const wchar_t *value) { + params.addItem(new String(param)); + params.addItem(new String(value)); + return 0; +} + +int SvcWnd::onInit() { + int r = SVCWND_PARENT::onInit(); + WindowCreateByGuidEnum wce(getGUID()); + for (;;) { + if (!svc) + svc = wce.getNext(); + if (!svc) return 0; + svcwnd = svc->createWindowByGuid(getGUID(), this); + if (svcwnd != NULL) break; + SvcEnum::release(svc); svc = NULL; + } + if (svcwnd != NULL) + { + svcwnd->setStartHidden(1); + if (!svcwnd->isInited()) + r &= svcwnd->init(this); + if (params.getNumItems() > 0) { + for (int i=0;i<params.getNumItems();i+=2) { + svcwnd->getGuiObject()->guiobject_setXmlParam(params[i]->getValue(), params[i+1]->getValue()); + } + } + } + params.deleteAll(); + return r; +} + +SvcWnd::~SvcWnd() { + if (svc) { + svc->destroyWindow(svcwnd); + ServiceManager::release(svc); + } +} + +int SvcWnd::handleRatio() { + return 1; // todo: ask window +} + +void SvcWnd::setGUID(GUID g) { + myGUID = g; +} + +GUID SvcWnd::getGUID(void) { + return myGUID; +} + +int SvcWnd::getPreferences(int what) { + if (svcwnd) return svcwnd->getPreferences(what); + return SVCWND_PARENT::getPreferences(what); +} + +scriptVar SvcWnd::script_vcpu_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SvcWnd *s = static_cast<SvcWnd *>(o->vcpu_getInterface(svcWndGuid)); + if (s) + return MAKE_SCRIPT_STRING(StringPrintf(s->myGUID)); + else + return MAKE_SCRIPT_STRING(""); +} + +scriptVar SvcWnd::script_vcpu_getWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SvcWnd *s = static_cast<SvcWnd *>(o->vcpu_getInterface(svcWndGuid)); + if (s) return MAKE_SCRIPT_OBJECT(SOM::getWACObject(s->getGUID())->getScriptObject()); + RETURN_SCRIPT_VOID; +} + diff --git a/Src/Wasabi/api/script/objects/svcwnd.h b/Src/Wasabi/api/script/objects/svcwnd.h new file mode 100644 index 00000000..41f83f28 --- /dev/null +++ b/Src/Wasabi/api/script/objects/svcwnd.h @@ -0,0 +1,89 @@ +#ifndef _SVCWND_H +#define _SVCWND_H + +#include "script.h" +#include "../../common/script/scriptobj.h" +#include "guiobj.h" +#include "../../bfc/svc_enum.h" + +class SMap; +class SRegion; +class Container; +class Layout; + +// {8776F715-503A-41f9-BD63-FB148AD05765} +static const GUID svcWndGuid = +{ 0x8776f715, 0x503a, 0x41f9, { 0xbd, 0x63, 0xfb, 0x14, 0x8a, 0xd0, 0x57, 0x65 } }; + +#define SVCWND_PARENT GuiObjectWnd + +class SvcWndScriptController : public GuiObjectScriptController { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return guiController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern SvcWndScriptController *svcWndController; + +class SvcWnd : public SVCWND_PARENT { +public: + SvcWnd(); + virtual ~SvcWnd(); + + virtual int onLeftButtonDblClk(int x, int y); + virtual int onResize(); + virtual void onSetVisible(int v); + virtual int onInit(); + + virtual int getPreferences(int what); + virtual int handleRatio(); + + void setGUID(GUID g); + GUID getGUID(void); + + virtual int childNotify(ifc_window *child, int msg, intptr_t param1, intptr_t param2); + virtual int setXuiParam(int _xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value); + virtual int onUnknownXuiParam(const wchar_t *param, const wchar_t *value); + + // VCPU + static scriptVar script_vcpu_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_getWac(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + PtrList<StringW> params; + // End VCPU + +protected: + + enum { + SVCWND_GUID=0, + SVCWND_DBLCLKACTION, + }; + +private: + GUID myGUID; + ifc_window *svcwnd; + svc_windowCreate *svc; + int forwarded; + StringW dblClickAction; + int xuihandle; +}; + +extern char svcWndXuiObjectStr[]; +extern char svcWndXuiSvcName[]; +class SvcWndXuiSvc : public XuiObjectSvc<SvcWnd, svcWndXuiObjectStr, svcWndXuiSvcName> {}; + + +#endif diff --git a/Src/Wasabi/api/script/objects/sxmldoc.cpp b/Src/Wasabi/api/script/objects/sxmldoc.cpp new file mode 100644 index 00000000..f5954c20 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sxmldoc.cpp @@ -0,0 +1,231 @@ +#include <precomp.h> +#include "sxmldoc.h" + +#include "slist.h" + +#include <api/script/script.h> +#include <api/script/scriptmgr.h> +#include <api/script/objecttable.h> + + +// {417FFB69-987F-4be8-8D87-D9965EEEC868} +static const GUID xmlDocGuid = +{ 0x417ffb69, 0x987f, 0x4be8, { 0x8d, 0x87, 0xd9, 0x96, 0x5e, 0xee, 0xc8, 0x68 } }; + + +XmlDocScriptController _xmlDocController; +XmlDocScriptController *xmlDocController=&_xmlDocController; + +// -- Functions table ------------------------------------- +function_descriptor_struct XmlDocScriptController::exportedFunction[] = { + {L"parser_addCallback", 1, (void*)SXmlDoc::script_vcpu_addParserCallback }, + {L"parser_start", 0, (void*)SXmlDoc::script_vcpu_parse }, + {L"parser_destroy", 0, (void*)SXmlDoc::script_vcpu_destroyParser }, + {L"parser_onCallback", 4, (void*)SXmlDoc::script_vcpu_onXmlParserCallback}, + {L"parser_onCloseCallback", 2, (void*)SXmlDoc::script_vcpu_onXmlParserEndCallback}, + {L"parser_onError", 5, (void*)SXmlDoc::script_vcpu_onXmlParserError}, +}; +// -------------------------------------------------------- + +const wchar_t *XmlDocScriptController::getClassName() { + return L"XmlDoc"; +} + +const wchar_t *XmlDocScriptController::getAncestorClassName() { + return L"File"; +} + +ScriptObjectController *XmlDocScriptController::getAncestorController() { return rootScriptObjectController; } + +ScriptObject *XmlDocScriptController::instantiate() { + SXmlDoc *xd = new SXmlDoc; + ASSERT(xd != NULL); + return xd->getScriptObject(); +} + +void XmlDocScriptController::destroy(ScriptObject *o) { + SXmlDoc *xd = static_cast<SXmlDoc *>(o->vcpu_getInterface(xmlDocGuid)); + ASSERT(xd != NULL); + delete xd; +} + +void *XmlDocScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for XmlDocs for now +} + +void XmlDocScriptController::deencapsulate(void *o) { +} + +int XmlDocScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *XmlDocScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID XmlDocScriptController::getClassGuid() { + return xmlDocGuid; +} + + +SXmlDoc::SXmlDoc() { + getScriptObject()->vcpu_setInterface(xmlDocGuid, (void *)static_cast<SXmlDoc *>(this)); + getScriptObject()->vcpu_setClassName(L"XmlDoc"); + getScriptObject()->vcpu_setController(xmlDocController); + filename = NULL; + myXmlParser = NULL; +} + +SXmlDoc::~SXmlDoc() { + destroyParser(); +} + +void SXmlDoc::addParserCallback(const wchar_t *name) +{ + createParser(); + StringW sw_name = name; + sw_name.replace(L"/", L"\f"); // We call subsections in Maki with a single /. in Wasabi \f is used + //debug: Std::messageBox(sw_name,name,0); + myXmlParser->xmlreader_registerCallback(sw_name, &myXmlParserCallback); + //debug: myXmlParser->xmlreader_registerCallback(L"WasabiXML\fbla", &myXmlParserCallback); +} + +void LoadXmlFile(obj_xml *parser, const wchar_t *filename); + +void SXmlDoc::startParsing() +{ +/* debug: createParser(); +myXmlParser->xmlreader_registerCallback(L"WasabiXML\fbla", &myXmlParserCallback); +myXmlParser->xmlreader_registerCallback(L"WasabiXML\fbrowserQuickLinks", &myXmlParserCallback);*/ + + if (!myXmlParser) return; + myXmlParser->xmlreader_open(); + LoadXmlFile(myXmlParser, filename); +} + +void SXmlDoc::createParser() +{ + if (myXmlParser != NULL) return; + + myXmlParserCallback.parent = this; + + myXmlParserFactory = WASABI_API_SVC->service_getServiceByGuid(obj_xmlGUID); + if (myXmlParserFactory) + { + myXmlParser = (obj_xml *)myXmlParserFactory->getInterface(); + + if (myXmlParser) + { + const wchar_t *file = Wasabi::Std::filename(filename); + int fnlen = wcslen(file); + StringW path = filename; + path.trunc( -fnlen); + XMLAutoInclude include(myXmlParser, path); + } + } +} + +void SXmlDoc::destroyParser() +{ + if (!myXmlParser) return; + myXmlParser->xmlreader_unregisterCallback(&myXmlParserCallback); + myXmlParser->xmlreader_close(); + myXmlParserFactory->releaseInterface(myXmlParser); + myXmlParser = NULL; +} + +// ParserCallbacks + +void SXmlDocParserCallback::xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params) +{ + //debug: Std::messageBox(xmlpath,xmltag,0); + StringW sw_xmlpath = xmlpath; + sw_xmlpath.replace(L"\f", L"/"); + + // Store the params and paramvalues in a SList + SList param; + SList paramvalue; + + for (size_t i = 0; i != params->getNbItems(); i++) + { + SList::script_vcpu_addItem(SCRIPT_CALL, param.getScriptObject(), MAKE_SCRIPT_STRING(params->getItemName(i))); + SList::script_vcpu_addItem(SCRIPT_CALL, paramvalue.getScriptObject(), MAKE_SCRIPT_STRING(params->getItemValue(i))); + } + + // and now the monster call ;) + SXmlDoc::script_vcpu_onXmlParserCallback( + SCRIPT_CALL, parent->getScriptObject(), + MAKE_SCRIPT_STRING(sw_xmlpath), + MAKE_SCRIPT_STRING(xmltag), + MAKE_SCRIPT_OBJECT(param.getScriptObject()), + MAKE_SCRIPT_OBJECT(paramvalue.getScriptObject()) ); +} + +void SXmlDocParserCallback::xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag) +{ + StringW sw_xmlpath = xmlpath; + sw_xmlpath.replace(L"\f", L"/"); + + SXmlDoc::script_vcpu_onXmlParserEndCallback(SCRIPT_CALL, parent->getScriptObject(), MAKE_SCRIPT_STRING(sw_xmlpath), MAKE_SCRIPT_STRING(xmltag)); +} + +void SXmlDocParserCallback::xmlReaderOnError(int linenum, int errcode, const wchar_t *errstr) +{ + SXmlDoc::script_vcpu_onXmlParserError( + SCRIPT_CALL, parent->getScriptObject(), + MAKE_SCRIPT_STRING(L""), // xml api changed, but we should keep the same maki function! + MAKE_SCRIPT_INT(linenum), + MAKE_SCRIPT_STRING(L""), // xml api changed, but we should keep the same maki function! + MAKE_SCRIPT_INT(errcode), + MAKE_SCRIPT_STRING(errstr) ); +} + +// VCPU + +scriptVar SXmlDoc::script_vcpu_addParserCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar fn) { + SCRIPT_FUNCTION_INIT; + ASSERT(fn.type == SCRIPT_STRING); + SXmlDoc *m = static_cast<SXmlDoc *>(o->vcpu_getInterface(xmlDocGuid)); + if (m) m->addParserCallback(fn.data.sdata); + + RETURN_SCRIPT_VOID; +} + +scriptVar SXmlDoc::script_vcpu_parse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SXmlDoc *m = static_cast<SXmlDoc *>(o->vcpu_getInterface(xmlDocGuid)); + if (m) m->startParsing(); + + RETURN_SCRIPT_VOID; +} + +scriptVar SXmlDoc::script_vcpu_destroyParser(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + SXmlDoc *m = static_cast<SXmlDoc *>(o->vcpu_getInterface(xmlDocGuid)); + if (m) m->destroyParser(); + + RETURN_SCRIPT_VOID; +} + +scriptVar SXmlDoc::script_vcpu_onXmlParserCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar xmlpath, scriptVar xmltag, scriptVar param, scriptVar paramvalue) +{ + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS4(o, xmlDocController, xmlpath, xmltag, param, paramvalue); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT4(o, xmlpath, xmltag, param, paramvalue); +} +scriptVar SXmlDoc::script_vcpu_onXmlParserEndCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar xmlpath, scriptVar xmltag) +{ + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS2(o, xmlDocController, xmlpath, xmltag); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT2(o, xmlpath, xmltag); +} +scriptVar SXmlDoc::script_vcpu_onXmlParserError(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar filename, scriptVar linenum, scriptVar incpath, scriptVar errcode, scriptVar errstr) +{ + SCRIPT_FUNCTION_INIT + PROCESS_HOOKS5(o, xmlDocController, filename, linenum, incpath, errcode, errstr); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT5(o, filename, linenum, incpath, errcode, errstr); +}
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/sxmldoc.h b/Src/Wasabi/api/script/objects/sxmldoc.h new file mode 100644 index 00000000..cfee2551 --- /dev/null +++ b/Src/Wasabi/api/script/objects/sxmldoc.h @@ -0,0 +1,76 @@ +#ifndef __SXMLDOC_H +#define __SXMLDOC_H + +class SXmlDoc; + +#include <api/script/objects/sfile.h> + +#include <api/script/script.h> +#include <api/script/objcontroller.h> +#include <api/script/objects/rootobj.h> +#include <api/script/objects/rootobject.h> + +#include <api/xml/XMLAutoInclude.h> + +#define SXMLDOC_SCRIPTPARENT SFile + +class XmlDocScriptController : public fileScriptController { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +class SXmlDocParserCallback : public ifc_xmlreadercallbackI +{ + void xmlReaderOnStartElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params); + void xmlReaderOnEndElementCallback(const wchar_t *xmlpath, const wchar_t *xmltag); + void xmlReaderOnError(int linenum, int errcode, const wchar_t *errstr); + +public: SXmlDoc *parent; // reference to the xmldoc that triggered this callback +}; + +extern XmlDocScriptController *xmlDocController; + +class SXmlDoc : public SXMLDOC_SCRIPTPARENT +{ +public: + SXmlDoc(); + virtual ~SXmlDoc(); + + void addParserCallback(const wchar_t *b); + void startParsing(); + void destroyParser(); + void elementCallback(const wchar_t *xmltag); + +private: + obj_xml *myXmlParser; + SXmlDocParserCallback myXmlParserCallback; + waServiceFactory *myXmlParserFactory; + + void createParser(); + +public: + static scriptVar script_vcpu_addParserCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar fn); + static scriptVar script_vcpu_parse(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_destroyParser(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onXmlParserCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar xmlpath, scriptVar xmltag, scriptVar param, scriptVar paramvalue); + static scriptVar script_vcpu_onXmlParserError(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar filename, scriptVar linenum, scriptVar incpath, scriptVar errcode, scriptVar errstr); + static scriptVar script_vcpu_onXmlParserEndCallback(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar xmlpath, scriptVar xmltag); + +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/systemobj.cpp b/Src/Wasabi/api/script/objects/systemobj.cpp new file mode 100644 index 00000000..fb13ee2b --- /dev/null +++ b/Src/Wasabi/api/script/objects/systemobj.cpp @@ -0,0 +1,3500 @@ +#include <precomp.h> + +#include <bfc/wasabi_std.h> +#include <bfc/wasabi_std_wnd.h> +#include <api/script/script.h> +#include <api/script/scriptmgr.h> +#include <api/script/scriptobj.h> +#include <api/script/scriptguid.h> +#include <api/script/objects/systemobj.h> +#include <api/service/svcs/svc_action.h> +#include <api/util/selectfile.h> +#include <api/script/vcpu.h> // for getAtom, CUT + +#ifdef WASABI_COMPILE_WNDMGR +#include <api/wnd/wndclass/wndholder.h> +#include <api/wndmgr/skinembed.h> +#endif + +#include <api/script/objects/timer.h> +#include <time.h> +#include <api.h> + +#ifdef WASABI_COMPILE_SKIN +#include <api/skin/skinparse.h> +#include <api/skin/skin.h> +#endif +#include <math.h> +#include <shlobj.h> + +#include <bfc/string/url.h> +#include <bfc/parse/pathparse.h> +#include <bfc/tlist.h> +#ifdef WASABI_COMPILE_WNDMGR +#include <api/util/varmgr.h> +#endif + +#include <bfc/nsguid.h> +#include <api/script/objecttable.h> +#include <api/skin/groupmgr.h> + +#ifdef WA3COMPATIBILITY +#include <api/skin/widgets/mb/xuibrowser.h> +#include <api/skin/widgets/mb/mainminibrowser.h> +#include <api/util/dde.h> +#include <api/wac/main.h>//CUT!! +#endif + +#ifdef WASABI_COMPILE_MEDIACORE +#include <api/service/svcs/svc_player.h> +#include <api/core/buttons.h> +#include <api/core/api_core.h> +#include <api/core/corehandle.h> // safe to include even if core isn't there +#endif + +#ifdef WASABI_COMPILE_CONFIG +#include <api/config/items/attrbool.h> +#endif + +#include <api/locales/xlatstr.h> +#include "../Agave/Language/api_language.h" +#include <api/syscb/callbacks/consolecb.h> +#include "../nu/AutoChar.h" +#include "../nu/AutoUrl.h" +#include "../nu/AutoWide.h" +#ifdef _WIN32 +#include <shlwapi.h> +extern HINSTANCE hInstance; +#endif + +#ifdef GEN_FF +#include "../../../../Plugins/General/gen_ff/wa2frontend.h" +#endif + +SystemScriptObjectController _systemController; +SystemScriptObjectController *systemController = &_systemController; + +#define MAKI_RUNTIME_VERSION 2 + +// -- Functions table ------------------------------------- +function_descriptor_struct SystemScriptObjectController::exportedFunction[] = +{ + {L"getRuntimeVersion", 0, (void*)SystemObject::vcpu_getVersion}, + {L"onScriptLoaded", 0, (void*)SystemObject::vcpu_onScriptLoaded}, + {L"onScriptUnloading", 0, (void*)SystemObject::vcpu_onScriptUnloading}, + {L"onQuit", 0, (void*)SystemObject::vcpu_onQuit}, + {L"onKeyDown", 1, (void*)SystemObject::vcpu_onKeyDown}, + {L"onKeyUp", 1, (void*)SystemObject::vcpu_onKeyUp}, + {L"onAccelerator", 3, (void*)SystemObject::vcpu_onAccelerator}, + {L"getMousePosX", 0, (void*)SystemObject::vcpu_getMousePosX}, + {L"getMousePosY", 0, (void*)SystemObject::vcpu_getMousePosY}, + {L"isMinimized", 0, (void*)SystemObject::vcpu_isMinimized}, + {L"restoreApplication", 0, (void*)SystemObject::vcpu_restoreApplication}, + {L"activateApplication", 0, (void*)SystemObject::vcpu_activateApplication}, + {L"minimizeApplication", 0, (void*)SystemObject::vcpu_minimizeApplication}, + {L"isDesktopAlphaAvailable", 0, (void*)SystemObject::vcpu_isDesktopAlphaAvailable}, + {L"isTransparencyAvailable", 0, (void*)SystemObject::vcpu_isTransparencyAvailable}, +//----- + {L"integerToString", 1, (void*)SystemObject::vcpu_integerToString}, + {L"stringToInteger", 1, (void*)SystemObject::vcpu_stringToInteger}, + {L"floatToString", 2, (void*)SystemObject::vcpu_floatToString}, + {L"stringToFloat", 1, (void*)SystemObject::vcpu_stringToFloat}, + {L"integerToTime", 1, (void*)SystemObject::vcpu_integerToTime}, + {L"integerToLongTime", 1, (void*)SystemObject::vcpu_integerToLongTime}, + {L"dateToTime", 1, (void*)SystemObject::vcpu_dateToTime}, + {L"dateToLongTime", 1, (void*)SystemObject::vcpu_dateToLongTime}, + {L"formatDate", 1, (void*)SystemObject::vcpu_formatDate}, + {L"formatLongDate", 1, (void*)SystemObject::vcpu_formatLongDate}, + {L"getDateYear", 1, (void*)SystemObject::vcpu_getDateYear}, + {L"getDateMonth", 1, (void*)SystemObject::vcpu_getDateMonth}, + {L"getDateDay", 1, (void*)SystemObject::vcpu_getDateDay}, + {L"getDateDow", 1, (void*)SystemObject::vcpu_getDateDow}, + {L"getDateDoy", 1, (void*)SystemObject::vcpu_getDateDoy}, + {L"getDateHour", 1, (void*)SystemObject::vcpu_getDateHour}, + {L"getDateMin", 1, (void*)SystemObject::vcpu_getDateMin}, + {L"getDateSec", 1, (void*)SystemObject::vcpu_getDateSec}, + {L"getDateDst", 1, (void*)SystemObject::vcpu_getDateDst}, + {L"getDate", 0, (void*)SystemObject::vcpu_getDate}, + {L"StrMid", 3, (void*)SystemObject::vcpu_strmid}, + {L"StrLeft", 2, (void*)SystemObject::vcpu_strleft}, + {L"StrRight", 2, (void*)SystemObject::vcpu_strright}, + {L"StrSearch", 2, (void*)SystemObject::vcpu_strsearch}, + {L"StrLen", 1, (void*)SystemObject::vcpu_strlen}, + {L"StrUpper", 1, (void*)SystemObject::vcpu_strupper}, + {L"StrLower", 1, (void*)SystemObject::vcpu_strlower}, + {L"UrlEncode", 1, (void*)SystemObject::vcpu_urlencode}, + {L"UrlDecode", 1, (void*)SystemObject::vcpu_urldecode}, + {L"RemovePath", 1, (void*)SystemObject::vcpu_removepath}, + {L"GetPath", 1, (void*)SystemObject::vcpu_getpath}, + {L"GetExtension", 1, (void*)SystemObject::vcpu_getextension}, + {L"getToken", 3, (void*)SystemObject::vcpu_gettoken}, +//----- + {L"sin", 1, (void*)SystemObject::vcpu_sin}, + {L"cos", 1, (void*)SystemObject::vcpu_cos}, + {L"tan", 1, (void*)SystemObject::vcpu_tan}, + {L"asin", 1, (void*)SystemObject::vcpu_asin}, + {L"acos", 1, (void*)SystemObject::vcpu_acos}, + {L"atan", 1, (void*)SystemObject::vcpu_atan}, + {L"atan2", 2, (void*)SystemObject::vcpu_atan2}, + {L"pow", 2, (void*)SystemObject::vcpu_pow}, + {L"sqr", 1, (void*)SystemObject::vcpu_sqr}, + {L"sqrt", 1, (void*)SystemObject::vcpu_sqrt}, + {L"random", 1, (void*)SystemObject::vcpu_random}, + {L"integer", 1, (void*)SystemObject::vcpu_integer}, + {L"frac", 1, (void*)SystemObject::vcpu_frac}, + {L"ln", 1, (void*)SystemObject::vcpu_log}, + {L"log10", 1, (void*)SystemObject::vcpu_log10}, +//----- + {L"getParam", 0, (void*)SystemObject::vcpu_getParam}, + {L"getViewportWidth", 0, (void*)SystemObject::vcpu_getViewportWidth}, + {L"getViewportHeight", 0, (void*)SystemObject::vcpu_getViewportHeight}, + {L"getViewportLeft", 0, (void*)SystemObject::vcpu_getViewportLeft}, + {L"getViewportTop", 0, (void*)SystemObject::vcpu_getViewportTop}, + {L"getViewportWidthFromPoint", 2, (void*)SystemObject::vcpu_getViewportWidthFP}, + {L"getViewportHeightFromPoint",2, (void*)SystemObject::vcpu_getViewportHeightFP}, + {L"getViewportLeftFromPoint", 2, (void*)SystemObject::vcpu_getViewportLeftFP}, + {L"getViewportTopFromPoint", 2, (void*)SystemObject::vcpu_getViewportTopFP}, + {L"getViewportWidthFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportWidthGO}, + {L"getViewportHeightFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportHeightGO}, + {L"getViewportLeftFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportLeftGO}, + {L"getViewportTopFromGuiObject", 1, (void*)SystemObject::vcpu_getViewportTopGO}, + {L"onViewPortChanged", 2, (void*)SystemObject::vcpu_onViewPortChanged}, + {L"debugString", 2, (void*)SystemObject::vcpu_debugString}, + {L"isObjectValid", 1, (void*)SystemObject::vcpu_isObjectValid}, + {L"getTimeOfDay", 0, (void*)SystemObject::vcpu_getTimeOfDay}, + {L"navigateUrl", 1, (void*)SystemObject::vcpu_navigateUrl}, + {L"navigateUrlBrowser", 1, (void*)SystemObject::vcpu_navigateUrlBrowser}, + {L"isKeyDown", 1, (void*)SystemObject::vcpu_isKeyDown}, + {L"setClipboardText", 1, (void*)SystemObject::vcpu_setClipboard}, + {L"Chr", 1, (void*)SystemObject::vcpu_chr}, + {L"triggerAction", 3, (void*)SystemObject::vcpu_triggerAction}, + {L"messageBox", 4, (void*)SystemObject::vcpu_messageBox}, + {L"setAtom", 2, (void*)SystemObject::vcpu_setAtom}, + {L"getAtom", 1, (void*)SystemObject::vcpu_getAtom}, +#ifdef WASABI_COMPILE_MAKIDEBUG + {L"invokeDebugger", 0, (void*)SystemObject::vcpu_invokeDebugger}, +#endif +#ifdef WASABI_COMPILE_SKIN + {L"newGroup", 1, (void*)SystemObject::vcpu_newGroup}, + {L"onSetXuiParam", 2, (void*)SystemObject::vcpu_onSetXuiParam}, + {L"getScriptGroup", 0, (void*)SystemObject::vcpu_getScriptGroup}, + {L"getSkinName", 0, (void*)SystemObject::vcpu_getSkinName}, + {L"newGroupAsLayout", 1, (void*)SystemObject::vcpu_newGroupAsLayout}, + {L"getNumContainers", 0, (void*)SystemObject::vcpu_getNumContainers}, + {L"enumContainer", 1, (void*)SystemObject::vcpu_enumContainer}, + {L"onCreateLayout", 1, (void*)SystemObject::vcpu_onCreateLayout}, + {L"onShowLayout", 1, (void*)SystemObject::vcpu_onShowLayout}, + {L"onHideLayout", 1, (void*)SystemObject::vcpu_onHideLayout}, + {L"switchSkin", 1, (void*)SystemObject::vcpu_switchSkin}, + {L"isLoadingSkin", 0, (void*)SystemObject::vcpu_isLoadingSkin}, + {L"lockUI", 0, (void*)SystemObject::vcpu_lockUI}, + {L"unlockUI", 0, (void*)SystemObject::vcpu_unlockUI}, +#endif +#if defined(WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"getContainer", 1, (void*)SystemObject::vcpu_getContainer + }, + {L"newDynamicContainer", 1, (void*)SystemObject::vcpu_newDynamicContainer}, + {L"onGetCancelComponent", 2, (void*)SystemObject::vcpu_onGetCancelComponent}, + {L"onLookForComponent", 1, (void*)SystemObject::vcpu_onLookForComponent}, + {L"isAppActive", 0, (void*)SystemObject::vcpu_isAppActive}, + {L"showWindow", 3, (void*)SystemObject::vcpu_showWindow}, + {L"hideWindow", 1, (void*)SystemObject::vcpu_hideWindow}, + {L"hideNamedWindow", 1, (void*)SystemObject::vcpu_hideNamedWindow}, + {L"isNamedWindowVisible", 1, (void*)SystemObject::vcpu_isNamedWindowVisible}, + {L"getCurAppLeft", 0, (void*)SystemObject::vcpu_getCurAppLeft}, + {L"getCurAppTop", 0, (void*)SystemObject::vcpu_getCurAppTop}, + {L"getCurAppWidth", 0, (void*)SystemObject::vcpu_getCurAppWidth}, + {L"getCurAppHeight", 0, (void*)SystemObject::vcpu_getCurAppHeight}, +#endif +#if defined (WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"setPrivateString", 3, (void*)SystemObject::vcpu_setPrivateString + }, + {L"setPrivateInt", 3, (void*)SystemObject::vcpu_setPrivateInt}, + {L"getPrivateString", 3, (void*)SystemObject::vcpu_getPrivateString}, + {L"getPrivateInt", 3, (void*)SystemObject::vcpu_getPrivateInt}, + {L"setPublicString", 2, (void*)SystemObject::vcpu_setPublicString}, + {L"setPublicInt", 2, (void*)SystemObject::vcpu_setPublicInt}, + {L"getPublicString", 2, (void*)SystemObject::vcpu_getPublicString}, + {L"getPublicInt", 2, (void*)SystemObject::vcpu_getPublicInt}, +#endif +#if defined (WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"getPlayItemString", 0, (void*)SystemObject::vcpu_getPlayItemString + }, + {L"getPlayItemLength", 0, (void*)SystemObject::vcpu_getPlayItemLength}, + {L"getPlayItemMetadataString", 1, (void*)SystemObject::vcpu_getPlayItemMetadataString}, + {L"getMetadataString", 2, (void*)SystemObject::vcpu_getMetadataString}, + {L"getPlayItemDisplayTitle", 0, (void*)SystemObject::vcpu_getPlayItemDisplayTitle}, + {L"getExtFamily", 1, (void*)SystemObject::vcpu_getExtFamily}, + {L"getDecoderName", 1, (void*)SystemObject::vcpu_getDecoderName}, + {L"playFile", 1, (void*)SystemObject::vcpu_playFile}, + {L"enqueueFile", 1, (void*)SystemObject::vcpu_enqueueFile}, + {L"clearPlaylist", 0, (void*)SystemObject::vcpu_clearPlaylist}, + {L"onStop", 0, (void*)SystemObject::vcpu_onStop}, + {L"onPlay", 0, (void*)SystemObject::vcpu_onPlay}, + {L"onPause", 0, (void*)SystemObject::vcpu_onPause}, + {L"onResume", 0, (void*)SystemObject::vcpu_onResume}, + {L"onTitleChange", 1, (void*)SystemObject::vcpu_onTitleChange}, + {L"onTitle2Change", 1, (void*)SystemObject::vcpu_onTitle2Change}, + {L"onUrlChange", 1, (void*)SystemObject::vcpu_onUrlChange}, + {L"onInfoChange", 1, (void*)SystemObject::vcpu_onInfoChange}, + {L"onStatusMsg", 1, (void*)SystemObject::vcpu_onStatusMsg}, + {L"getLeftVuMeter", 0, (void*)SystemObject::vcpu_getLeftVuMeter}, + {L"getRightVuMeter", 0, (void*)SystemObject::vcpu_getRightVuMeter}, + {L"getVisBand", 2, (void*)SystemObject::vcpu_getVisBand}, + {L"getVolume", 0, (void*)SystemObject::vcpu_getVolume}, + {L"setVolume", 1, (void*)SystemObject::vcpu_setVolume}, + {L"play", 0, (void*)SystemObject::vcpu_play}, + {L"stop", 0, (void*)SystemObject::vcpu_stop}, + {L"pause", 0, (void*)SystemObject::vcpu_pause}, + {L"next", 0, (void*)SystemObject::vcpu_next}, + {L"previous", 0, (void*)SystemObject::vcpu_previous}, + {L"eject", 0, (void*)SystemObject::vcpu_eject}, + {L"seekTo", 1, (void*)SystemObject::vcpu_seekTo}, + {L"getPosition", 0, (void*)SystemObject::vcpu_getPosition}, + {L"setEqBand", 2, (void*)SystemObject::vcpu_setEqBand}, + {L"setEqPreAmp", 1, (void*)SystemObject::vcpu_setEqPreAmp}, + {L"setEq", 1, (void*)SystemObject::vcpu_setEq}, + {L"getEqBand", 1, (void*)SystemObject::vcpu_getEqBand}, + {L"getEqPreAmp", 0, (void*)SystemObject::vcpu_getEqPreAmp}, + {L"getEq", 0, (void*)SystemObject::vcpu_getEq}, + {L"onEqBandChanged", 2, (void*)SystemObject::vcpu_onEqBandChanged}, + {L"onEqFreqChanged", 1, (void*)SystemObject::vcpu_onEqFreqChanged}, + {L"onEqPreAmpChanged", 1, (void*)SystemObject::vcpu_onEqPreAmpChanged}, + {L"onEqChanged", 1, (void*)SystemObject::vcpu_onEqChanged}, + {L"onVolumeChanged", 1, (void*)SystemObject::vcpu_onVolumeChanged}, + {L"onSeek", 1, (void*)SystemObject::vcpu_onSeeked}, + {L"getStatus", 0, (void*)SystemObject::vcpu_getStatus}, + {L"getStatus", 0, (void*)SystemObject::vcpu_getStatus}, + {L"getSongInfoText", 0, (void*)SystemObject::vcpu_getSongInfoText}, + {L"getSongInfoTextTranslated", 0, (void*)SystemObject::vcpu_getSongInfoTextTranslated}, + {L"hasVideoSupport", 0, (void*)SystemObject::vcpu_hasVideoSupport}, + {L"isVideo", 0, (void*)SystemObject::vcpu_isVideo}, + {L"isVideoFullscreen", 0, (void*)SystemObject::vcpu_isVideoFullscreen}, + {L"setVideoFullscreen", 1, (void*)SystemObject::vcpu_setVideoFullscreen}, + {L"getIdealVideoWidth", 0, (void*)SystemObject::vcpu_getIdealVideoWidth}, + {L"getIdealVideoHeight", 0, (void*)SystemObject::vcpu_getIdealVideoHeight}, + {L"getPlaylistIndex", 0, (void*)SystemObject::vcpu_getPlaylistIndex}, + {L"onShowNotification", 0, (void*)SystemObject::vcpu_onShowNotification}, + {L"getPlaylistLength", 0, (void*)SystemObject::vcpu_getPlaylistLength}, + {L"getCurrentTrackRating", 0, (void *)SystemObject::vcpu_getRating}, + {L"setCurrentTrackRating", 1, (void *)SystemObject::vcpu_setRating}, +#endif +#if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"getWac", 1, (void*)SystemObject::vcpu_getWac + }, +#endif +#if defined(WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"ddesend", 3, (void*)SystemObject::vcpu_ddeSend + }, + {L"setMenuTransparency", 1, (void*)SystemObject::vcpu_setMenuTransparency}, + {L"popMainBrowser", 0, (void*)SystemObject::vcpu_popMb}, + {L"getMainBrowser", 0, (void*)SystemObject::vcpu_getMainMB}, + {L"windowMenu", 0, (void*)SystemObject::vcpu_windowMenu}, + {L"systemMenu", 0, (void*)SystemObject::vcpu_systemMenu}, +#endif +#if defined (WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + { + L"selectFile", 3, (void*)SystemObject::vcpu_selectFile + }, +#endif + {L"selectFolder", 3, (void*)SystemObject::vcpu_selectFolder}, + {L"onOpenURL", 1, (void*)SystemObject::vcpu_onOpenURL}, + {L"getMonitorLeft", 0, (void*)SystemObject::vcpu_getMonitorLeftGO}, + {L"getMonitorTop", 0, (void*)SystemObject::vcpu_getMonitorTopGO}, + {L"getMonitorLeftFromPoint", 2, (void*)SystemObject::vcpu_getMonitorLeftFP}, + {L"getMonitorTopFromPoint", 2, (void*)SystemObject::vcpu_getMonitorTopFP}, + {L"getMonitorLeftFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorLeftGO}, + {L"getMonitorTopFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorTopGO}, + {L"getMonitorWidth", 0, (void*)SystemObject::vcpu_getMonitorWidth}, + {L"getMonitorHeight", 0, (void*)SystemObject::vcpu_getMonitorHeight}, + {L"getMonitorWidthFromPoint", 2, (void*)SystemObject::vcpu_getMonitorWidthFP}, + {L"getMonitorHeightFromPoint",2, (void*)SystemObject::vcpu_getMonitorHeightFP}, + {L"getMonitorWidthFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorWidthGO}, + {L"getMonitorHeightFromGuiObject", 1, (void*)SystemObject::vcpu_getMonitorHeightGO}, + {L"downloadURL", 3, (void*)SystemObject::vcpu_downloadURL}, + {L"downloadMedia", 4, (void*)SystemObject::vcpu_downloadMedia}, + {L"onDownloadFinished", 3, (void*)SystemObject::vcpu_onDownloadFinished}, + {L"getDownloadPath", 0, (void*)SystemObject::vcpu_getDownloadPath}, + {L"setDownloadPath", 1, (void*)SystemObject::vcpu_setDownloadPath}, + {L"getAlbumArt", 1, (void*)SystemObject::vcpu_getAlbumArt}, + {L"isProVersion", 0, (void*)SystemObject::vcpu_isWinampPro}, // ugh, i hate putting this here but ohh well + {L"enumEmbedGUID", 1, (void*)SystemObject::vcpu_enumEmbedGUID}, // ugh, i hate putting this here but ohh well + {L"getWinampVersion",0, (void*)SystemObject::vcpu_getWinampVersion}, + {L"getBuildNumber",0, (void*)SystemObject::vcpu_getBuildNumber}, + {L"getFileSize",1, (void*)SystemObject::vcpu_getFileSize}, + {L"getString", 2, (void*)SystemObject::vcpu_getString}, + {L"translate", 1, (void*)SystemObject::vcpu_translate}, + {L"getLanguageId", 0, (void*)SystemObject::vcpu_getLanguageId} +}; +// -------------------------------------------------------- + + +const wchar_t *SystemScriptObjectController::getClassName() +{ + return L"SystemObject"; +} + +const wchar_t *SystemScriptObjectController::getAncestorClassName() +{ + return L"Object"; +} + +ScriptObject *SystemScriptObjectController::instantiate() +{ + return NULL; +} + +void SystemScriptObjectController::destroy(ScriptObject *o) +{ + ASSERTALWAYS("don't delete systemobject!"); +} + +void *SystemScriptObjectController::encapsulate(ScriptObject *o) +{ + return NULL; +} + +void SystemScriptObjectController::deencapsulate(void *o) +{ +} + +int SystemScriptObjectController::getNumFunctions() +{ + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *SystemScriptObjectController::getExportedFunctions() +{ + return exportedFunction; +} + +GUID SystemScriptObjectController::getClassGuid() +{ + return systemObjectGuid; +} + +int SystemScriptObjectController::getReferenceable() +{ + return 0; +} + +int SystemScriptObjectController::getInstantiable() +{ + return 0; +} + +#ifndef _NOSTUDIO + +SystemObject::SystemObject() +{ + getScriptObject()->vcpu_setInterface( systemObjectGuid, ( void * )static_cast<SystemObject *>( this ) ); + getScriptObject()->vcpu_setClassName( L"System" ); + getScriptObject()->vcpu_setController( systemController ); + + loaded = 0; + started_up = 0; + scriptVCPUId = -1; + isoldformat = 0; + parentGroup = NULL; + +#ifdef WASABI_COMPILE_SKIN + skinpartid = WASABI_API_PALETTE->getSkinPartIterator(); +#else + skinpartid = -1; +#endif + + SOM::registerSystemObject( this ); + +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_addCallback( 0, this ); +#endif + + WASABI_API_SYSCB->syscb_registerCallback( this ); +} + +SystemObject::~SystemObject() +{ + SOM::unregisterSystemObject( this ); +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_delCallback( 0, this ); +#endif + WASABI_API_SYSCB->syscb_deregisterCallback( this ); +} + +void SystemObject::setScriptId( int id ) +{ + scriptVCPUId = id; +} + +int SystemObject::getScriptId() +{ + return scriptVCPUId; +} + +void SystemObject::setParam( const wchar_t *p ) +{ +#ifdef WASABI_COMPILE_WNDMGR + StringW *s = PublicVarManager::translate_nocontext( p ); + if ( s ) + param.swap( s ); + else + param = p; + delete s; +#else + param = p; +#endif +} + +void SystemObject::setParentGroup( Group *g ) +{ + parentGroup = g; +} + +Group *SystemObject::getParentGroup() +{ + return parentGroup; +} + +const wchar_t *SystemObject::getParam() +{ + return param; +} + +void SystemObject::onLoad() +{ + loaded = 1; + vcpu_onScriptLoaded( SCRIPT_CALL, getScriptObject() ); + started_up = 1; +} + +void SystemObject::onUnload() +{ + if ( loaded && started_up ) + vcpu_onScriptUnloading( SCRIPT_CALL, getScriptObject() ); + + // that was the script's last chance to delete its stuff, now we need to garbageCollect whatever is left + garbageCollect(); +} + +#ifdef WASABI_COMPILE_WNDMGR +WindowHolder *SystemObject::getSuitableWindowHolderByGuid( GUID g ) +{ + wchar_t guidstr[ 256 ] = { 0 }; + nsGUID::toCharW( g, guidstr ); + scriptVar v = vcpu_onLookForComponent( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( guidstr ) ); + + if ( v.type == SCRIPT_OBJECT ) + { + ScriptObject *ret = GET_SCRIPT_OBJECT( v ); + if ( ret ) + { + WindowHolder *co = static_cast<WindowHolder *>( ret->vcpu_getInterface( windowHolderGuid ) ); + return co; + } + } + return NULL; +} + +int SystemObject::onGetCancelComponent( GUID g, int i ) +{ + wchar_t guidstr[ 256 ] = { 0 }; + nsGUID::toCharW( g, guidstr ); + scriptVar v = vcpu_onGetCancelComponent( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( guidstr ), MAKE_SCRIPT_BOOLEAN( i ) ); + + if ( v.type != SCRIPT_VOID ) + return GET_SCRIPT_INT( v ); + + return 0; +} + +void SystemObject::onViewPortChanged( int width, int height ) +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onViewPortChanged( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_INT( width ), MAKE_SCRIPT_INT( height ) ); +} + +int SystemObject::onShowNotification() +{ + WASABI_API_MAKI->vcpu_resetComplete(); +#if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- ) + { + scriptVar v = vcpu_onShowNotification( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject() ); + if ( v.type != SCRIPT_VOID ) + return GET_SCRIPT_INT( v ); + } +#endif + return 0; +} + +void SystemObject::onCreateLayout( Layout *l ) +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onCreateLayout( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_OBJECT( l->getGuiObject()->guiobject_getScriptObject() ) ); +} + +void SystemObject::onShowLayout( Layout *l ) +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onShowLayout( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_OBJECT( l->getGuiObject()->guiobject_getScriptObject() ) ); +} + +void SystemObject::onHideLayout( Layout *l ) +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onHideLayout( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_OBJECT( l->getGuiObject()->guiobject_getScriptObject() ) ); +} + +int SystemObject::getCurAppRect( RECT *r ) +{ + ASSERT( r ); +#ifdef WIN32 + HWND w = GetForegroundWindow(); + if ( !IsWindowVisible( w ) ) return 0; + GetWindowRect( w, r ); +#else + DebugString( "portme SystemObject::getCurAppRect\n" ); +#endif + return 1; +} + +void SystemObject::onQuit() +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onQuit( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject() ); +} + +#endif // wndmgr + +static bool FilterBrowserUrl( const wchar_t *url ) +{ + const wchar_t filterNowPlaying[] = L"http://client.winamp.com/nowplaying"; + size_t urlLength, filterLength; + + if ( NULL == url ) + return false; + + urlLength = wcslen( url ); + filterLength = sizeof( filterNowPlaying ) / sizeof( filterNowPlaying[ 0 ] ) - 1; + if ( urlLength >= filterLength && + 0 == _wcsnicmp( url, filterNowPlaying, filterLength ) ) + { + return true; + } + + return false; +} + +void SystemObject::browsercb_onOpenURL( wchar_t *url, bool *override ) +{ + if ( !*override && false == FilterBrowserUrl( url ) ) // ignore if someone else already overrode + { + scriptVar v = vcpu_onOpenURL( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( url ) ); + if ( v.type == SCRIPT_INT ) + { + if ( v.data.idata == 1 ) + *override = true; + } + } +} + +scriptVar SystemObject::vcpu_onOpenURL( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, url ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, url ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +void SystemObject::onKeyDown( const wchar_t *s ) +{ + WASABI_API_MAKI->vcpu_resetComplete(); + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- ) + vcpu_onKeyDown( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( s ) ); +} + +void SystemObject::onKeyUp( const wchar_t *s ) +{ + WASABI_API_MAKI->vcpu_resetComplete(); + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- ) + vcpu_onKeyUp( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( s ) ); +} + +int SystemObject::onAccelerator( const wchar_t *action, const wchar_t *section, const wchar_t *key ) +{ + int r = 0; + WASABI_API_MAKI->vcpu_resetComplete(); + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0 && !WASABI_API_MAKI->vcpu_getComplete(); i-- ) + { + scriptVar v = vcpu_onAccelerator( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( action ), MAKE_SCRIPT_STRING( section ), MAKE_SCRIPT_STRING( key ) ); + if ( SOM::isNumeric( &v ) ) + r |= GET_SCRIPT_INT( v ); + } + return r; +} + +void SystemObject::onDownloadFinished( const wchar_t *url, boolean success, const wchar_t *filename ) +{ + for ( int i = SOM::getNumSystemObjects() - 1; i >= 0; i-- ) + vcpu_onDownloadFinished( SCRIPT_CALL, SOM::getSystemObject( i )->getScriptObject(), MAKE_SCRIPT_STRING( url ), MAKE_SCRIPT_BOOLEAN( success ), MAKE_SCRIPT_STRING( filename ) ); +} + +TList < int > *SystemObject::getTypesList() +{ + return &typeslist; +} + +void SystemObject::setIsOldFormat( int is ) +{ + isoldformat = is; +} + +int SystemObject::isOldFormat() +{ + return isoldformat; +} +#endif + +#ifdef WASABI_COMPILE_WND +int SystemObject::isAppActive() +{ +#ifdef WIN32 + HWND w = GetForegroundWindow(); + wchar_t classname[ 256 ] = L""; + GetClassNameW( w, classname, 256 ); + return ( w == WASABI_API_WND->main_getRootWnd()->gethWnd() || !wcscmp( classname, BASEWNDCLASSNAME ) ); +#else + DebugString( "portme SystemObject::isAppActive\n" ); + return 1; +#endif +} +#endif + +void SystemObject::setSkinPartId( int _skinpartid ) +{ + skinpartid = _skinpartid; +} + +int SystemObject::getSkinPartId() +{ + return skinpartid; +} + +void SystemObject::addInstantiatedObject( ScriptObject *obj ) +{ + ASSERT( !instantiated.haveItem( obj ) ); + instantiated.addItem( obj ); +} + +void SystemObject::removeInstantiatedObject( ScriptObject *obj ) +{ + int n = instantiated.searchItem( obj ); + if ( n < 0 ) return; //ASSERT(n >= 0); + instantiated.removeByPos( n ); +} + +void SystemObject::garbageCollect() +{ + foreach( instantiated ) + ObjectTable::destroy( instantiated.getfor() ); + endfor + instantiated.removeAll(); +} + +int SystemObject::isObjectValid( ScriptObject *o ) +{ + static ScriptObject *cached = NULL; + static int cachedn = -1; + if ( o == cached && scriptobjects.enumItem( cachedn ) == o ) return 1; + int is = scriptobjects.searchItem( o ); + if ( is >= 0 ) + { + cached = o; + cachedn = is; + } + return ( is > -1 ); +} + +void SystemObject::addScriptObject( ScriptObject *o ) +{ + ASSERT( !scriptobjects.haveItem( o ) ); + scriptobjects.addItem( o ); +} + +void SystemObject::removeScriptObject( ScriptObject *o ) +{ + int pos = scriptobjects.searchItem( o ); + if ( pos < 0 ) return; + scriptobjects.removeByPos( pos ); +} + +#ifdef WASABI_COMPILE_SKIN +void SystemObject::onSetXuiParam( const wchar_t *param, const wchar_t *value ) +{ + vcpu_onSetXuiParam( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( param ), MAKE_SCRIPT_STRING( value ) ); +} +#endif + +void SystemObject::navigateUrl( const wchar_t *url ) +{ +#ifdef WA3COMPATIBILITY + if ( MainMiniBrowser::getScriptObject() ) + { + MainMiniBrowser::navigateUrl( url ); + MainMiniBrowser::popMb(); + } + else // no minibrowser container -> launch IE + { + Std::shellExec( url ); + } +#else + Wasabi::Std::shellExec( url ); +#endif +} + +void SystemObject::navigateUrlBrowser( const wchar_t *url ) +{ + wa2.openUrl( url ); +} + +scriptVar SystemObject::vcpu_getVersion( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + return MAKE_SCRIPT_DOUBLE( MAKI_RUNTIME_VERSION ); +} + +scriptVar SystemObject::vcpu_onScriptLoaded( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SystemObject *so = static_cast<SystemObject *>( o->vcpu_getInterface( systemObjectGuid ) ); + ASSERT( so != NULL ); + return WASABI_API_MAKI->maki_triggerEvent( o, DLF_ID, 0, so->scriptVCPUId ); +} + +scriptVar SystemObject::vcpu_onScriptUnloading( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SystemObject *so = static_cast<SystemObject *>( o->vcpu_getInterface( systemObjectGuid ) ); + ASSERT( so != NULL ); + return WASABI_API_MAKI->maki_triggerEvent( o, DLF_ID, 0, so->scriptVCPUId ); +} + +scriptVar SystemObject::vcpu_onQuit( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +} + +#ifdef WASABI_COMPILE_SKIN +scriptVar SystemObject::vcpu_onSetXuiParam( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2( o, systemController, param, value ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT2( o, param, value ); +} + +scriptVar SystemObject::vcpu_getSkinName( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_STRING( WASABI_API_SKIN->getSkinName() ); +} + +scriptVar SystemObject::vcpu_switchSkin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar skinname ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef SWITCH_SKIN + SWITCH_SKIN( GET_SCRIPT_STRING( skinname ) ); +#else + WASABI_API_SKIN->skin_switchSkin( GET_SCRIPT_STRING( skinname ) ); +#endif + RETURN_SCRIPT_ZERO; +} + +scriptVar SystemObject::vcpu_isLoadingSkin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + int l = 0; +#ifdef IS_SKIN_STILL_LOADING + IS_SKIN_STILL_LOADING( l ); +#endif + if ( !l ) return MAKE_SCRIPT_INT( Skin::isLoading() ); + return MAKE_SCRIPT_INT( l ); +} + +scriptVar SystemObject::vcpu_lockUI( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_SKIN->skin_setLockUI( 1 ); + RETURN_SCRIPT_NULL; +} + +scriptVar SystemObject::vcpu_unlockUI( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_SKIN->skin_setLockUI( 0 ); + RETURN_SCRIPT_NULL; +} + +#endif + +scriptVar SystemObject::vcpu_isObjectValid( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar o ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_BOOLEAN( SystemObject::isObjectValid( GET_SCRIPT_OBJECT( o ) ) ); +} + +scriptVar SystemObject::vcpu_getTimeOfDay( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + time_t ts = Wasabi::Std::getTimeStamp(); + struct tm *tm_now; + tm_now = localtime( (const time_t *)&ts ); + uint32_t tcnow = Wasabi::Std::getTickCount(); + static uint32_t lasttc = 0; + + int v = tm_now->tm_hour * 3600000 + tm_now->tm_min * 60000 + tm_now->tm_sec * 1000; + + // yay milliseconds! + + static int lastv = 0; + static int total = 0; + int tv = v; + if ( v == lastv ) + { + total += tcnow - lasttc; + v += total; + } + else total = 0; + lasttc = tcnow; + lastv = tv; + + return MAKE_SCRIPT_INT( v ); +} + +scriptVar SystemObject::vcpu_navigateUrl( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url ) +{ + SCRIPT_FUNCTION_INIT; + SystemObject::navigateUrl( GET_SCRIPT_STRING( url ) ); + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_navigateUrlBrowser( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url ) +{ + SCRIPT_FUNCTION_INIT; + SystemObject::navigateUrlBrowser( GET_SCRIPT_STRING( url ) ); + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_isKeyDown( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar vk_code ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( Std::keyDown( GET_SCRIPT_INT( vk_code ) ) ); +} + +scriptVar SystemObject::vcpu_setClipboard( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar text ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef _WIN32 + const wchar_t *source = GET_SCRIPT_STRING( text ); + DebugStringW( L"%s\n", source ); + OpenClipboard( 0 ); + EmptyClipboard(); + int len = ( wcslen( source ) + 1 ); + HGLOBAL clipbuffer = GlobalAlloc( GMEM_DDESHARE, sizeof( wchar_t ) * len ); + wchar_t *buffer = (wchar_t *)GlobalLock( clipbuffer ); + wcsncpy( buffer, source, len - 1 ); + GlobalUnlock( clipbuffer ); + SetClipboardData( CF_UNICODETEXT, clipbuffer ); + CloseClipboard(); +#else + DebugString( "portme SystemObject::vcpu_setClipboard\n" ); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_chr( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar n ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( staticStr, StringPrintfW( L"%c", GET_SCRIPT_INT( n ) ), 4096 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_onAccelerator( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar section, scriptVar key ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS3( o, systemController, action, section, key ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT3( o, action, section, key ); +} + +scriptVar SystemObject::vcpu_triggerAction( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guiobj, scriptVar actionstr, scriptVar paramstr ) +{ + SCRIPT_FUNCTION_INIT; + ASSERT( actionstr.type == SCRIPT_STRING ); + ASSERT( paramstr.type == SCRIPT_STRING ); + const wchar_t *astr = GET_SCRIPT_STRING( actionstr ); + const wchar_t *pstr = GET_SCRIPT_STRING( paramstr ); +#ifdef WASABI_COMPILE_WNDMGR + ScriptObject *context = guiobj.data.odata; + if ( context != NULL ) + { + GuiObject *go = static_cast<GuiObject *>( context->vcpu_getInterface( guiObjectGuid ) ); + if ( go != NULL ) + { + ifc_window *wc = go->guiobject_getRootWnd(); + if ( wc != NULL ) + { + ifc_window *lr = wc->getDesktopParent(); + if ( lr != NULL ) + { + Layout *lay = static_cast<Layout *>( lr->getInterface( layoutGuid ) ); + if ( lay != NULL ) + { + int ia = WASABI_API_SKIN->parse( astr, L"internal_action" ); + if ( ia == ACTION_NONE ) + { + ActionEnum ae( astr ); + svc_action *act = ae.getFirst(); + if ( act ) + { + act->onAction( astr, pstr, 0, 0, NULL, 0, wc ); + SvcEnum::release( act ); + } + } + else + lay->runAction( ia, pstr ); + } + } + } + } + } + else + { + ActionEnum ae( astr ); + svc_action *act = ae.getFirst(); + if ( act ) + { + act->onAction( astr, pstr ); + SvcEnum::release( act ); + } + } +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_getParam( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + SystemObject *o = static_cast<SystemObject *>( object->vcpu_getInterface( systemObjectGuid ) ); + if ( o ) return MAKE_SCRIPT_STRING( o->getParam() ); + return MAKE_SCRIPT_STRING( L"" ); +} + +#ifdef WASABI_COMPILE_SKIN +scriptVar SystemObject::vcpu_getScriptGroup( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + SystemObject *o = static_cast<SystemObject *>( object->vcpu_getInterface( systemObjectGuid ) ); + if ( o ) + { + Group *g = o->getParentGroup(); + return MAKE_SCRIPT_OBJECT( g ? g->getScriptObject() : NULL ); + } + return MAKE_SCRIPT_OBJECT( NULL ); +} + +scriptVar SystemObject::vcpu_newGroup( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar groupname ) +{ + SCRIPT_FUNCTION_INIT; + GuiObject *g = SkinParser::newDynamicGroup( GET_SCRIPT_STRING( groupname ), GROUP_GROUP ); + if ( g != NULL ) + { + SystemObject *so = static_cast<SystemObject *>( object->vcpu_getInterface( systemObjectGuid ) ); + so->addInstantiatedObject( g->guiobject_getScriptObject() ); + } + return MAKE_SCRIPT_OBJECT( g ? g->guiobject_getScriptObject() : NULL ); +} +#endif + +scriptVar SystemObject::vcpu_getMousePosX( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt; + Wasabi::Std::getMousePos( &pt ); + return MAKE_SCRIPT_INT( pt.x ); +} + +scriptVar SystemObject::vcpu_getMousePosY( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt; + Wasabi::Std::getMousePos( &pt ); + return MAKE_SCRIPT_INT( pt.y ); +} + +scriptVar SystemObject::vcpu_minimizeApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef _WIN32 + ShowWindow( WASABI_API_WND->main_getRootWnd()->gethWnd(), SW_MINIMIZE ); +#else + #warning port me +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_activateApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef _WIN32 + SetForegroundWindow( WASABI_API_WND->main_getRootWnd()->gethWnd() ); +#else + #warning port me +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_restoreApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef _WIN32 + ShowWindow( WASABI_API_WND->main_getRootWnd()->gethWnd(), SW_RESTORE ); +#else + #warning port me +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_isDesktopAlphaAvailable( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + extern _bool cfg_uioptions_desktopalpha; + return MAKE_SCRIPT_INT( Wasabi::Std::Wnd::isDesktopAlphaAvailable() && cfg_uioptions_desktopalpha.getValueAsInt() ); +#else + return MAKE_SCRIPT_INT( Wasabi::Std::Wnd::isDesktopAlphaAvailable() ); +#endif +} + +scriptVar SystemObject::vcpu_isTransparencyAvailable( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( Wasabi::Std::Wnd::isTransparencyAvailable() ); +} + +scriptVar SystemObject::vcpu_isMinimized( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef _WIN32 + return MAKE_SCRIPT_INT( IsIconic( WASABI_API_WND->main_getRootWnd()->gethWnd() ) ); +#else + #warning port me + RETURN_SCRIPT_ZERO; +#endif +} + +// extern String System.translate(String str); +scriptVar SystemObject::vcpu_translate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( translateStr, _( GET_SCRIPT_STRING( str ) ), ( sizeof( translateStr ) / sizeof( *translateStr ) ) ); + return MAKE_SCRIPT_STRING( translateStr ); +} + +// extern String System.getString(String table, Int id); +scriptVar SystemObject::vcpu_getString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar table, scriptVar id ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *xlat = LocalesManager::GetString( GET_SCRIPT_STRING( table ), GET_SCRIPT_INT( id ) ); + if ( xlat ) + return MAKE_SCRIPT_STRING( xlat ); + else + return MAKE_SCRIPT_STRING( L"" ); +} + +// extern String System.getString(String table, Int id); +scriptVar SystemObject::vcpu_getLanguageId( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *langId = WASABI_API_LNG->GetLanguageIdentifier( LANG_IDENT_STR ); + if ( langId ) + return MAKE_SCRIPT_STRING( langId ); + else + return MAKE_SCRIPT_STRING( L"" ); +} + +scriptVar SystemObject::vcpu_integerToString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar i ) +{ + SCRIPT_FUNCTION_INIT; + WCSNPRINTF( staticStr, 4096, L"%d", GET_SCRIPT_INT( i ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_stringToInteger( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar s ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( WTOI( GET_SCRIPT_STRING( s ) ) ); +} + +scriptVar SystemObject::vcpu_floatToString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar f, scriptVar digits ) +{ + SCRIPT_FUNCTION_INIT; + // to whoever made this use StringPrintf, you left out the digits param, GRRRRRR!! + double v = GET_SCRIPT_DOUBLE( f ); + StringPrintfW tmp( v ); + WCSCPYN( staticStr, tmp, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + wchar_t *p = wcschr( staticStr, '.' ); + if ( p ) + { + int numdigits = GET_SCRIPT_INT( digits ); + if ( numdigits > 0 ) + { + int n = numdigits; + int curnumdigits = staticStr + wcslen( staticStr ) - ( p + 1 ); + n -= curnumdigits; + if ( n > 0 ) + { + for ( int i = 0; i < n && i < ( sizeof( staticStr ) / sizeof( *staticStr ) ) - 128; i++ ) + wcscat( staticStr, L"0" ); + } + else if ( n < 0 ) + { + *( p + 1 + numdigits ) = 0; + } + } + else + { + *p = 0; + } + } + else + { + int n = GET_SCRIPT_INT( digits ); + if ( n > 0 ) + { + wcscat( staticStr, L"." ); + for ( int i = 0; i < n && i < ( sizeof( staticStr ) / sizeof( *staticStr ) ) - 128; i++ ) + wcscat( staticStr, L"0" ); + } + } + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_stringToFloat( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar s ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_FLOAT( (float)WTOF( GET_SCRIPT_STRING( s ) ) ); +} + +scriptVar SystemObject::vcpu_integerToTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + int i = GET_SCRIPT_INT( _i ); + WCSNPRINTF( staticStr, 4096, L"%d:%02d", i / 60000, i % 60000 / 1000 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_integerToLongTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + int i = GET_SCRIPT_INT( _i ); + WCSNPRINTF( staticStr, 4096, L"%d:%02d:%02d", i / 3600000, ( i % 3600000 ) / 60000, i % 60000 / 1000 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_dateToTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + WCSNPRINTF( staticStr, 4096, L"%d:%02d", t->tm_hour, t->tm_min ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_dateToLongTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + WCSNPRINTF( staticStr, 4096, L"%d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_formatDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + wcsftime( staticStr, 4096, L"%c", t ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_formatLongDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + wcsftime( staticStr, 4096, L"%#c", t ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_getDateYear( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_year ); +} + +scriptVar SystemObject::vcpu_getDateMonth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_mon ); +} + +scriptVar SystemObject::vcpu_getDateDay( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_mday ); +} + +scriptVar SystemObject::vcpu_getDateDow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_wday ); +} + +scriptVar SystemObject::vcpu_getDateDoy( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_yday ); +} + +scriptVar SystemObject::vcpu_getDateHour( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_hour ); +} + +scriptVar SystemObject::vcpu_getDateMin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_min ); +} + +scriptVar SystemObject::vcpu_getDateSec( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_sec ); +} + +scriptVar SystemObject::vcpu_getDateDst( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i ) +{ + SCRIPT_FUNCTION_INIT; + //CUT: int i = GET_SCRIPT_INT(_i); + time_t tt = GET_SCRIPT_INT( _i ); + struct tm *t = localtime( &tt ); + return MAKE_SCRIPT_INT( t->tm_isdst ); +} + +scriptVar SystemObject::vcpu_getDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + time_t t; + time( &t ); + return MAKE_SCRIPT_INT( (int)t ); +} + +scriptVar SystemObject::vcpu_strmid( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar start, scriptVar len ) +{ + SCRIPT_FUNCTION_INIT; + SOM::mid( staticStr, GET_SCRIPT_STRING( str ), MIN( GET_SCRIPT_INT( start ), 4096 ), MIN( GET_SCRIPT_INT( len ), 4096 ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_strleft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar len ) +{ + SCRIPT_FUNCTION_INIT; + SOM::mid( staticStr, GET_SCRIPT_STRING( str ), 0, MIN( GET_SCRIPT_INT( len ), 4096 ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_strright( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str, scriptVar _len ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *str = GET_SCRIPT_STRING( _str ); + int len = GET_SCRIPT_INT( _len ); + SOM::mid( staticStr, str, MIN( (int)( wcslen( str ) - len ), 4096 ), MIN( len, 4096 ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_strsearch( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str, scriptVar substr ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *str = GET_SCRIPT_STRING( _str ); + const wchar_t *p = wcsstr( str, GET_SCRIPT_STRING( substr ) ); + return MAKE_SCRIPT_INT( p ? p - str : -1 ); +} + +scriptVar SystemObject::vcpu_strlen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( wcslen( GET_SCRIPT_STRING( str ) ) ); +} + +scriptVar SystemObject::vcpu_strupper( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( staticStr, GET_SCRIPT_STRING( _str ), ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + WCSTOUPPER( staticStr ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_strlower( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( staticStr, GET_SCRIPT_STRING( _str ), ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + WCSTOLOWER( staticStr ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_urlencode( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + StringW str( GET_SCRIPT_STRING( _str ) ); + str = AutoWide( AutoUrl( str ) ); + *staticStr = 0; + if ( !str.isempty() ) WCSCPYN( staticStr, str, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_urldecode( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + StringW str( GET_SCRIPT_STRING( _str ) ); + Url::decode( str ); // Martin> I know there might be something nicer than this, but this does at least work + *staticStr = 0; + if ( !str.isempty() ) WCSCPYN( staticStr, str, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_removepath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + PathParserW pp( GET_SCRIPT_STRING( _str ) ); +// ASSERT(pp.getNumStrings() >= 1); // shouldn't happen ever + wchar_t *lastString = pp.getLastString(); + if ( lastString ) + { + WCSCPYN( staticStr, lastString, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + } + else + { + staticStr[ 0 ] = 0; + } + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_getpath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( staticStr, GET_SCRIPT_STRING( _str ), ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); +#ifdef _WIN32 + PathRemoveFileSpecW( staticStr ); + PathRemoveBackslashW( staticStr ); +#else + #warning port me +#endif + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_getextension( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *pt = Wasabi::Std::extension( GET_SCRIPT_STRING( _str ) ); + if ( pt != NULL ) WCSCPYN( staticStr, pt, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ); + else *staticStr = '\0'; + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_gettoken( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar tok, scriptVar sep, scriptVar num ) +{ + SCRIPT_FUNCTION_INIT; + wchar_t *p = const_cast<wchar_t *>( GET_SCRIPT_STRING( tok ) ); + wchar_t *d = const_cast<wchar_t *>( GET_SCRIPT_STRING( sep ) ); + int i = GET_SCRIPT_INT( num ); + if ( !d ) return MAKE_SCRIPT_STRING( L"" ); + if ( !p ) return MAKE_SCRIPT_STRING( L"" ); + wchar_t c = *d; + d = staticStr; + int n = 0, ct = 0; + while ( p && *p && ct < 4096 ) + { + if ( *p == c ) + { + n++; p++; continue; + } + if ( n > i ) break; + if ( n == i ) + *d++ = *p; + p++; + ct++; + } + *d = 0; + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_sin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::sin( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_cos( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::cos( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_tan( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::tan( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_asin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::asin( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_acos( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::acos( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_atan( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::atan( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_atan2( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar y, scriptVar x ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::atan2( GET_SCRIPT_DOUBLE( y ), GET_SCRIPT_DOUBLE( x ) ) ); +} + +scriptVar SystemObject::vcpu_pow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::pow( GET_SCRIPT_DOUBLE( x ), GET_SCRIPT_DOUBLE( y ) ) ); +} + +scriptVar SystemObject::vcpu_sqr( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _d ) +{ + SCRIPT_FUNCTION_INIT; + double d = GET_SCRIPT_DOUBLE( _d ); + return MAKE_SCRIPT_DOUBLE( d * d ); +} + +scriptVar SystemObject::vcpu_sqrt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::sqrt( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_log10( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::log10( GET_SCRIPT_DOUBLE( d ) ) ); +} + +scriptVar SystemObject::vcpu_log( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_DOUBLE( ::log( GET_SCRIPT_DOUBLE( d ) ) ); +} + + +scriptVar SystemObject::vcpu_random( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar m ) +{ + SCRIPT_FUNCTION_INIT; + int m_ = GET_SCRIPT_INT( m ); + return MAKE_SCRIPT_INT( m_ <= 0 ? 0 : ::rand() % m_ ); +} + +scriptVar SystemObject::vcpu_integer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; + // precision will get lost automatically + int _v = GET_SCRIPT_INT( v ); + return MAKE_SCRIPT_INT( _v ); +} + +scriptVar SystemObject::vcpu_frac( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; + double _v = GET_SCRIPT_DOUBLE( v ) - GET_SCRIPT_INT( v ); + return MAKE_SCRIPT_DOUBLE( _v ); +} + +scriptVar SystemObject::vcpu_onViewPortChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar width, scriptVar height ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS2( o, systemController, width, height ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT2( o, width, height ); +} + +scriptVar SystemObject::vcpu_getViewportWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.right - r.left ); +} + +scriptVar SystemObject::vcpu_getViewportHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); +} + +scriptVar SystemObject::vcpu_getViewportWidthGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() ); + return MAKE_SCRIPT_INT( r.right - r.left ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.right - r.left ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getViewportHeightGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() ); + + // benski> this prevents the window from going "fullscreen" but adds a one-line space at the bottom + RECT full = { 0 }; + Wasabi::Std::getViewport( &full, o->guiobject_getRootWnd()->getOsWindowHandle(), true ); + if (Wasabi::Std::rectEqual( &full, &r ) ) + r.bottom--; + + return MAKE_SCRIPT_INT( r.bottom - r.top ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getMonitorLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.left ); +} + +scriptVar SystemObject::vcpu_getMonitorLeftFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.left ); +} + +scriptVar SystemObject::vcpu_getMonitorLeftGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), 1 ); + return MAKE_SCRIPT_INT( r.left ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.left ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getMonitorTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.top ); +} + +scriptVar SystemObject::vcpu_getMonitorTopFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.top ); +} + +scriptVar SystemObject::vcpu_getMonitorTopGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), 1 ); + return MAKE_SCRIPT_INT( r.top ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.top ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getMonitorWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.right - r.left ); +} + +scriptVar SystemObject::vcpu_getMonitorHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); +} + +scriptVar SystemObject::vcpu_getMonitorWidthGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), 1 ); + return MAKE_SCRIPT_INT( r.right - r.left ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.right - r.left ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getMonitorHeightGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle(), true ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getViewportLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.left ); +} + +scriptVar SystemObject::vcpu_getViewportTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { 0 }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.top ); +} + +scriptVar SystemObject::vcpu_getViewportLeftGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() ); + return MAKE_SCRIPT_INT( r.left ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.left ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getViewportTopGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + RECT r = { 0 }; + GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( obj, guiObjectGuid ) ); + if ( o ) + { + Wasabi::Std::getViewport( &r, o->guiobject_getRootWnd()->getOsWindowHandle() ); + return MAKE_SCRIPT_INT( r.top ); + } + else + { + POINT pt = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.top ); + } + return MAKE_SCRIPT_INT( 0 ); +} + +scriptVar SystemObject::vcpu_getViewportWidthFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.right - r.left ); +} + +scriptVar SystemObject::vcpu_getMonitorHeightFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); +} + +scriptVar SystemObject::vcpu_getMonitorWidthFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt, 1 ); + return MAKE_SCRIPT_INT( r.right - r.left ); +} + +scriptVar SystemObject::vcpu_getViewportHeightFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.bottom - r.top ); +} + +scriptVar SystemObject::vcpu_getViewportLeftFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.left ); +} + +scriptVar SystemObject::vcpu_getViewportTopFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y ) +{ + SCRIPT_FUNCTION_INIT; + POINT pt = { GET_SCRIPT_INT( x ),GET_SCRIPT_INT( y ) }; + RECT r = { 0 }; + Wasabi::Std::getViewport( &r, &pt ); + return MAKE_SCRIPT_INT( r.top ); +} + +scriptVar SystemObject::vcpu_getTickCount( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT(Wasabi::Std::getTickCount() ); +} + +scriptVar SystemObject::vcpu_onKeyDown( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1( o, systemController, v ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, v ); +} + +scriptVar SystemObject::vcpu_onKeyUp( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS1( o, systemController, v ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, v ); +} + +scriptVar SystemObject::vcpu_debugString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar severity ) +{ + SCRIPT_FUNCTION_INIT; + DebugStringW( L"%s", GET_SCRIPT_STRING( str ) ); + WASABI_API_SYSCB->syscb_issueCallback( SysCallback::CONSOLE, ConsoleCallback::DEBUGMESSAGE, GET_SCRIPT_INT( severity ), reinterpret_cast<intptr_t>( GET_SCRIPT_STRING( str ) ) ); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SystemObject::vcpu_messageBox( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar msg, scriptVar title, scriptVar flags, scriptVar nam ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + return MAKE_SCRIPT_INT( WASABI_API_WNDMGR->messageBox( GET_SCRIPT_STRING( msg ), GET_SCRIPT_STRING( title ), GET_SCRIPT_INT( flags ), GET_SCRIPT_STRING( nam ), NULL ) ); +#else + return MAKE_SCRIPT_INT( MessageBox( NULL, GET_SCRIPT_STRING( msg ), GET_SCRIPT_STRING( title ), GET_SCRIPT_INT( flags ) ) ); +#endif +} + +scriptVar SystemObject::vcpu_getAtom( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar atomname ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_OBJECT( VCPU::getAtom( GET_SCRIPT_STRING( atomname ) ) ); +} + +scriptVar SystemObject::vcpu_setAtom( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar atomname, scriptVar obj ) +{ + SCRIPT_FUNCTION_INIT; + VCPU::setAtom( GET_SCRIPT_STRING( atomname ), GET_SCRIPT_OBJECT( obj ) ); + RETURN_SCRIPT_VOID; +} + +#ifdef WASABI_COMPILE_MAKIDEBUG +scriptVar SystemObject::vcpu_invokeDebugger( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + WASABI_API_MAKIDEBUG->debugger_createJITD( object->vcpu_getScriptId(), 1 ); + RETURN_SCRIPT_VOID; +} +#endif + +#if defined (WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +scriptVar SystemObject::vcpu_onCreateLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + PROCESS_HOOKS1( o, systemController, l ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, l ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onShowLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + PROCESS_HOOKS1( o, systemController, l ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, l ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onHideLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + PROCESS_HOOKS1( o, systemController, l ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, l ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar contname ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + Container *c = SkinParser::script_getContainer( GET_SCRIPT_STRING( contname ) ); + return MAKE_SCRIPT_OBJECT( c ? c->getScriptObject() : NULL ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_newDynamicContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar contname ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + Container *c = SkinParser::newDynamicContainer( GET_SCRIPT_STRING( contname ) ); + return MAKE_SCRIPT_OBJECT( c ? c->getScriptObject() : NULL ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_newGroupAsLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar groupname ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + Group *g = GroupMgr::instantiate( GET_SCRIPT_STRING( groupname ), GROUP_LAYOUTGROUP ); + if ( g ) + { + Layout *l = static_cast<Layout *>( g ); + ifc_window *par = l->getCustomOwner(); + if ( !par ) par = WASABI_API_WND->main_getRootWnd(); + g->setAutoResizeAfterInit( 0 ); + g->setStartHidden( 1 ); + g->setParent( par ); + +#ifdef _WIN32 + g->init( hInstance, par->gethWnd(), TRUE ); +#else + #warning port me + g->init( 0, par->gethWnd(), TRUE ); +#endif + SystemObject *so = SOM::getSystemObjectByScriptId( __vsd ); + if ( so != NULL ) so->addInstantiatedObject( g->getScriptObject() ); + } + return MAKE_SCRIPT_OBJECT( g ? g->getScriptObject() : NULL ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_getNumContainers( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + return MAKE_SCRIPT_INT( SkinParser::getNumContainers() ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_enumContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar n ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + Container *c = SkinParser::enumContainer( GET_SCRIPT_INT( n ) ); + return MAKE_SCRIPT_OBJECT( c ? c->getScriptObject() : NULL ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_onLookForComponent( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + PROCESS_HOOKS1( o, systemController, guid ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, guid ); +#else + RETURN_SCRIPT_VOID +#endif +} + +scriptVar SystemObject::vcpu_onGetCancelComponent( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid, scriptVar i ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + PROCESS_HOOKS2( o, systemController, guid, i ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT2( o, guid, i ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_getCurAppLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + RECT r = { 0 }; + int s = getCurAppRect( &r ); + return MAKE_SCRIPT_INT( s ? r.left : -1 ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_getCurAppTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + RECT r = { 0 }; + int s = getCurAppRect( &r ); + return MAKE_SCRIPT_INT( s ? r.top : -1 ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_getCurAppWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + RECT r = { 0 }; + int s = getCurAppRect( &r ); + return MAKE_SCRIPT_INT( s ? r.right - r.left : -1 ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_getCurAppHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + RECT r = { 0 }; + int s = getCurAppRect( &r ); + return MAKE_SCRIPT_INT( s ? r.bottom - r.top : -1 ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_isAppActive( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + return MAKE_SCRIPT_BOOLEAN( isAppActive() ); +#else + RETURN_SCRIPT_ZERO +#endif +} + +scriptVar SystemObject::vcpu_showWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar wndguidorgroup, scriptVar prefcontainer, scriptVar transient ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + const wchar_t *s = GET_SCRIPT_STRING( wndguidorgroup ); + const wchar_t *p = GET_SCRIPT_STRING( prefcontainer ); + int t = GET_SCRIPT_INT( transient ); + if ( p != NULL && *p == 0 ) p = NULL; + GUID _g = nsGUID::fromCharW( s ); +#ifdef ON_CREATE_EXTERNAL_WINDOW_GUID + if ( _g != INVALID_GUID ) + { + int y = 0; + ON_CREATE_EXTERNAL_WINDOW_GUID( _g, y ); + if ( y ) RETURN_SCRIPT_NULL; + } +#endif + ifc_window *ret = NULL; + if ( _g != INVALID_GUID ) + ret = WASABI_API_WNDMGR->skinwnd_createByGuid( _g, p, 0, NULL, t ); + else + ret = WASABI_API_WNDMGR->skinwnd_createByGroupId( s, p, 0, NULL, t ); + if ( ret ) + { + if ( ret->getGuiObject() ) + { + return MAKE_SCRIPT_OBJECT( ret->getGuiObject()->guiobject_getScriptObject() ); + } + } +#endif + RETURN_SCRIPT_NULL; +} + +scriptVar SystemObject::vcpu_hideWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar hw ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + GuiObject *o = static_cast<GuiObject *>( GET_SCRIPT_OBJECT_AS( hw, guiObjectGuid ) ); + if ( o ) + WASABI_API_WNDMGR->skinwnd_destroy( o->guiobject_getRootWnd() ); +#endif + RETURN_SCRIPT_NULL; +} + +scriptVar SystemObject::vcpu_hideNamedWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guidorgroup ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_WNDMGR + const wchar_t *s = GET_SCRIPT_STRING( guidorgroup ); + GUID _g = nsGUID::fromCharW( s ); + ifc_window *w = NULL; + if ( _g != INVALID_GUID ) + { + int n = WASABI_API_WNDMGR->skinwnd_getNumByGuid( _g ); // benski> CUT: int n = skinEmbedder->getNumItems(_g); + if ( n > 0 ) + w = WASABI_API_WNDMGR->skinwnd_enumByGuid( _g, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(_g, n-1); + } + else + { + int n = WASABI_API_WNDMGR->skinwnd_getNumByGroupId( s ); // benski> CUT: int n = skinEmbedder->getNumItems(s); + if ( n > 0 ) + w = WASABI_API_WNDMGR->skinwnd_enumByGroupId( s, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(s, n-1); + } + if ( w ) + { + GuiObject *o = w->getGuiObject(); + if ( o ) + WASABI_API_WNDMGR->skinwnd_destroy( o->guiobject_getRootWnd() ); + } +#endif + RETURN_SCRIPT_NULL; +} + +scriptVar SystemObject::vcpu_isNamedWindowVisible( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guidorgroup ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *s = GET_SCRIPT_STRING( guidorgroup ); + GUID _g = nsGUID::fromCharW( s ); + ifc_window *w = NULL; + if ( _g != INVALID_GUID ) + { + int n = WASABI_API_WNDMGR->skinwnd_getNumByGuid( _g ); // benski> CUT: int n = skinEmbedder->getNumItems(_g); + if ( n > 0 ) + w = WASABI_API_WNDMGR->skinwnd_enumByGuid( _g, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(_g, n-1); + } + else + { + int n = WASABI_API_WNDMGR->skinwnd_getNumByGroupId( s ); // benski> CUT: int n = skinEmbedder->getNumItems(s); + if ( n > 0 ) + w = WASABI_API_WNDMGR->skinwnd_enumByGroupId( s, n - 1 ); // benski> CUT: w = skinEmbedder->enumItem(s, n-1); + } + if ( w ) + { + return MAKE_SCRIPT_BOOLEAN( w->isVisible() ); + } + RETURN_SCRIPT_ZERO; +} + +#endif // if defined (WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +#if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +scriptVar SystemObject::vcpu_getStatus( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getStatus( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getSongInfoText( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + +#ifdef GET_SONG_INFO_TEXT + const wchar_t *c; + GET_SONG_INFO_TEXT( c ); + WCSCPYN( staticStr, c, 4096 ); +#else + *staticStr = 0; +#pragma CHAT("lone", "bas", "need to get the song info text, the same as would be in a text field with SONGINFO") +#endif + return MAKE_SCRIPT_STRING( staticStr ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getSongInfoTextTranslated( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + +#ifdef GET_SONG_INFO_TEXT_TRANSLATED + const wchar_t *c; + GET_SONG_INFO_TEXT_TRANSLATED( c ); + WCSCPYN( staticStr, c, 4096 ); +#else + *staticStr = 0; +#endif + return MAKE_SCRIPT_STRING( staticStr ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +#ifdef GEN_FF +#include "../../../../Plugins/General/gen_ff/wa2frontend.h" +#endif + +scriptVar SystemObject::vcpu_hasVideoSupport( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + return MAKE_SCRIPT_INT( wa2.hasVideoSupport() ); +#else +#pragma CHAT("lone", "bas", "how can we ask if the currently playing file is video thru the core objects ?") + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_isVideo( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + return MAKE_SCRIPT_INT( wa2.isPlayingVideo() ); +#else +#pragma CHAT("lone", "bas", "how can we ask if the currently playing file is video thru the core objects ?") + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_isVideoFullscreen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + return MAKE_SCRIPT_INT( wa2.isPlayingVideoFullscreen() ); +#else +#pragma CHAT("lone", "bas", "how can we ask if we are running fullscreen (either vis or video) ?") + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_setVideoFullscreen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + const bool vidfs = GET_SCRIPT_BOOLEAN( v ); + if ( vidfs ) + { + wa2.sendVidCmd( Winamp2FrontEnd::WA2_VIDCMD_FULLSCREEN ); + } + else + { + wa2.sendVidCmd( Winamp2FrontEnd::WA2_VIDCMD_EXIT_FS ); + } + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getPlaylistIndex( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + return MAKE_SCRIPT_INT( wa2.getCurPlaylistEntry() ); +#else +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( CoreHandle().getCurPlaybackNumber() ); +#else + RETURN_SCRIPT_ZERO; +#endif +#endif +} + +scriptVar SystemObject::vcpu_getPlaylistLength( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + return MAKE_SCRIPT_INT( wa2.getPlaylistLength() ); +#else +#ifdef WASABI_COMPILE_MEDIACORE + //BU CoreHandle is your friend + return MAKE_SCRIPT_INT( CoreHandle().getNumTracks() ); +#else + //FG not always, heh + RETURN_SCRIPT_ZERO; +#endif +#endif +} + +scriptVar SystemObject::vcpu_getIdealVideoHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + int h = -1; + wa2.getIdealVideoSize( NULL, &h ); + return MAKE_SCRIPT_INT( h ); +#else +#pragma CHAT("lone", "bas", "how can we ask for the ideal video size thru the core objects ?") + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getIdealVideoWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef GEN_FF + int w = -1; + wa2.getIdealVideoSize( &w, NULL ); + return MAKE_SCRIPT_INT( w ); +#else +#pragma CHAT("lone", "bas", "how can we ask for the ideal video size thru the core objects ?") + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_onStop( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onShowNotification( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onPlay( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onPause( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onResume( SCRIPT_FUNCTION_PARAMS, ScriptObject *o ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS0( o, systemController ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT0( o ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onTitleChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, title ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, title ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onTitle2Change( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, title ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, title ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onUrlChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, title ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, title ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onInfoChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar info ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, info ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, info ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onStatusMsg( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar info ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, info ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, info ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onEqBandChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar band, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS2( o, systemController, band, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT2( o, band, val ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onEqFreqChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, val ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onEqPreAmpChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, val ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onEqChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, val ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_onVolumeChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, val ); +#else + RETURN_SCRIPT_VOID +#endif +} + +scriptVar SystemObject::vcpu_onSeeked( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + PROCESS_HOOKS1( o, systemController, val ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT1( o, val ); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getPlayItemString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + const wchar_t *cur = WASABI_API_MEDIACORE->core_getCurrent( 0 ); + if ( cur == NULL ) cur = L""; + return MAKE_SCRIPT_STRING( cur ); +#else + return MAKE_SCRIPT_STRING( L"" ); +#endif +} + +scriptVar SystemObject::vcpu_getPlayItemLength( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getLength( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getPlayItemDisplayTitle( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + WCSCPYN( staticStr, WASABI_API_MEDIACORE->core_getTitle( 0 ), 4096 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_getPlayItemMetadataString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar name ) +{ + SCRIPT_FUNCTION_INIT; +#if defined(WASABI_COMPILE_MEDIACORE) & defined(WASABI_COMPILE_METADB) + const char *cur = WASABI_API_MEDIACORE->core_getCurrent( 0 ); + if ( cur == NULL ) return MAKE_SCRIPT_STRING( "" ); + if ( cur && WASABI_API_METADB->metadb_getMetaData( cur, GET_SCRIPT_STRING( name ), staticStr, ( sizeof( staticStr ) / sizeof( *staticStr ) ) ) <= 0 ) return MAKE_SCRIPT_STRING( "" ); + return MAKE_SCRIPT_STRING( staticStr ); +#elif defined(WASABI_CUSTOM_MINIDB) + WASABI_CUSTOM_MINIDB( GET_SCRIPT_STRING( name ), staticStr, 4096 ); staticStr[ 4095 ] = 0; + return MAKE_SCRIPT_STRING( staticStr ); +#elif defined(WASABI_COMPILE_MEDIACORE) + STRNCPY( staticStr, WASABI_API_MEDIACORE->core_getCurrent( 0 ), 4095 ); staticStr[ 4095 ] = 0; + return MAKE_SCRIPT_STRING( staticStr ); +#endif +} + +scriptVar SystemObject::vcpu_getMetadataString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar filename, scriptVar name ) +{ + SCRIPT_FUNCTION_INIT; + wa2.getMetaData( GET_SCRIPT_STRING( filename ), GET_SCRIPT_STRING( name ), staticStr, 4096 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_getExtFamily( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ext ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + const wchar_t *ps = GET_SCRIPT_STRING( ext ); + staticStr[ 0 ] = '\0'; + if ( ps != NULL ) + { + const wchar_t *f = WASABI_API_MEDIACORE->core_getExtensionFamily( ps ); + if ( f == NULL ) f = L""; + WCSCPYN( staticStr, f, 4096 ); + } + return MAKE_SCRIPT_STRING( staticStr ); +#else + return MAKE_SCRIPT_STRING( L"" ); +#endif +} + +scriptVar SystemObject::vcpu_getDecoderName( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ext ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + const wchar_t *ps = GET_SCRIPT_STRING( ext ); + staticStr[ 0 ] = '\0'; + if ( ps != NULL ) + { + const wchar_t *f = WASABI_API_MEDIACORE->core_getDecoderName( ps ); + if ( f == NULL ) f = L""; + WCSCPYN( staticStr, f, 4096 ); + } + return MAKE_SCRIPT_STRING( staticStr ); +#else + return MAKE_SCRIPT_STRING( L"" ); +#endif +} + +scriptVar SystemObject::vcpu_playFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE +#ifdef GEN_FF + StringW _file = GET_SCRIPT_STRING( file ); + const wchar_t *f = _file.getValue(); + if ( f && *f ) + { + if ( wcsstr( _file, L"://" ) ) + { + wa2.playFile( _file ); + } + else if ( f[ 1 ] != ':' && f[ 0 ] != '\\' && f[ 0 ] != '/' ) + { + PathParserW pp( f ); + if ( WCSCASEEQLSAFE( pp.enumString( 0 ), L"skins" ) + && WCSCASEEQLSAFE( pp.enumString( 1 ), WASABI_API_SKIN->getSkinName() ) ) + { + _file = L""; + for ( int i = 0; i < pp.getNumStrings() - 2; i++ ) + { + if ( i > 0 ) _file += L"\\"; + _file += pp.enumString( i + 2 ); + } + } + _file = StringPathCombine( WASABI_API_SKIN->getSkinPath(), _file ); + if ( !WACCESS( _file, 0 ) ) // avoid clearing playlist if file not found + wa2.playFile( _file ); + } + } +#else + svc_player *sp = SvcEnumByGuid<svc_player>(); + if ( sp ) sp->openFile( GET_SCRIPT_STRING( file ) ); + WASABI_API_SVC->service_release( sp ); +#endif + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_enqueueFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE +#ifdef GEN_FF + StringW _file = GET_SCRIPT_STRING( file ); + const wchar_t *f = _file.getValue(); + if ( f && *f ) + { + if ( wcsstr( _file, L"://" ) ) + { + wa2.enqueueFile( _file ); + } + else if ( f[ 1 ] != ':' && f[ 0 ] != '\\' && f[ 0 ] != '/' ) + { + PathParserW pp( f ); + if ( WCSCASEEQLSAFE( pp.enumString( 0 ), L"skins" ) + && WCSCASEEQLSAFE( pp.enumString( 1 ), WASABI_API_SKIN->getSkinName() ) ) + { + _file = L""; + for ( int i = 0; i < pp.getNumStrings() - 2; i++ ) + { + if ( i > 0 ) _file += L"\\"; + _file += pp.enumString( i + 2 ); + } + } + _file = StringPathCombine( WASABI_API_SKIN->getSkinPath(), _file ); + wa2.enqueueFile( _file ); + } + } +#else + svc_player *sp = SvcEnumByGuid<svc_player>(); + if ( sp ) sp->openFile( GET_SCRIPT_STRING( file ) ); + WASABI_API_SVC->service_release( sp ); +#endif + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_clearPlaylist( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + wa2.clearPlaylist(); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SystemObject::vcpu_getLeftVuMeter( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getLeftVuMeter( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getVisBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar chan, scriptVar band ) +{ + { + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + unsigned char visdata[ 576 * 2 * 2 ] = { 0 }; + int ret = WASABI_API_MEDIACORE->core_getVisData( 0, &visdata, sizeof( visdata ) ); + if ( !ret ) MEMSET( visdata, 0, sizeof( visdata ) ); + int b = MIN( MAX( 0, GET_SCRIPT_INT( band ) ), 74 ); + int a = MIN( MAX( 0, GET_SCRIPT_INT( chan ) ), 1 ); + return MAKE_SCRIPT_INT( MIN( 255, visdata[ 576 * a + b ] * 16 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif + } +} + +scriptVar SystemObject::vcpu_getRightVuMeter( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getRightVuMeter( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getVolume( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getVolume( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_setVolume( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setVolume( 0, GET_SCRIPT_INT( v ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_play( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_userButton( 0, UserButton::PLAY ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_stop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_userButton( 0, UserButton::STOP ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_pause( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_userButton( 0, UserButton::PAUSE ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_next( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_userButton( 0, UserButton::NEXT ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_previous( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_userButton( 0, UserButton::PREV ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_eject( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE +#ifdef GEN_FF + wa2.openFileDialog( WASABI_API_WND->main_getRootWnd()->gethWnd() ); +#else + svc_player *sp = SvcEnumByGuid<svc_player>(); + sp->openFiles(); + WASABI_API_SVC->service_release( sp ); +#endif + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_seekTo( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar to ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setPosition( 0, GET_SCRIPT_INT( to ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_setEqBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar band, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setEqBand( 0, MAX( 0, MIN( 9, GET_SCRIPT_INT( band ) ) ), GET_SCRIPT_INT( val ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_setEqPreAmp( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setEqPreamp( 0, GET_SCRIPT_INT( v ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_setEq( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setEqStatus( 0, GET_SCRIPT_INT( v ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getPosition( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getPosition( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getEqBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar band ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getEqBand( 0, MAX( 0, MIN( 9, GET_SCRIPT_INT( band ) ) ) ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getEqPreAmp( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getEqPreamp( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_getEq( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getEqStatus( 0 ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +#endif // #if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +#if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +scriptVar SystemObject::vcpu_getWac( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guid ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_COMPONENTS + WACObject *wo = SOM::getWACObject( GET_SCRIPT_STRING( guid ) ); + return MAKE_SCRIPT_OBJECT( wo ? wo->getScriptObject() : NULL ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +#endif // if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +#if defined(WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +scriptVar SystemObject::vcpu_setPrivateString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar str ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + WCSNPRINTF( staticStr, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) ); + WASABI_API_CONFIG->setStringPrivate( staticStr, GET_SCRIPT_STRING( str ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_setPrivateInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + WCSNPRINTF( staticStr, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) ); + WASABI_API_CONFIG->setIntPrivate( staticStr, GET_SCRIPT_INT( val ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getPrivateString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar defstr ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + wchar_t t[ 4096 ] = { 0 }; + StringCchPrintfW( t, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) ); + WASABI_API_CONFIG->getStringPrivate( t, staticStr, 4095, GET_SCRIPT_STRING( defstr ) ); + return MAKE_SCRIPT_STRING( staticStr ); +#else + return MAKE_SCRIPT_STRING( L"" ); +#endif +} + +scriptVar SystemObject::vcpu_getPrivateInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar defval ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + wchar_t t[ 4096 ] = { 0 }; + StringCchPrintfW( t, 4096, L"%s_%s", GET_SCRIPT_STRING( section ), GET_SCRIPT_STRING( item ) ); + return MAKE_SCRIPT_INT( WASABI_API_CONFIG->getIntPrivate( t, GET_SCRIPT_INT( defval ) ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_setPublicString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar str ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + WASABI_API_CONFIG->setStringPrivate( GET_SCRIPT_STRING( item ), GET_SCRIPT_STRING( str ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_setPublicInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar val ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + WASABI_API_CONFIG->setIntPrivate( GET_SCRIPT_STRING( item ), GET_SCRIPT_INT( val ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getPublicString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar defstr ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + WASABI_API_CONFIG->getStringPrivate( GET_SCRIPT_STRING( item ), staticStr, 4095, GET_SCRIPT_STRING( defstr ) ); + return MAKE_SCRIPT_STRING( staticStr ); +#else + return MAKE_SCRIPT_STRING( L"" ); +#endif +} + +scriptVar SystemObject::vcpu_getPublicInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar defval ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_CONFIG + return MAKE_SCRIPT_INT( WASABI_API_CONFIG->getIntPrivate( GET_SCRIPT_STRING( item ), GET_SCRIPT_INT( defval ) ) ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +#endif // #if defined(WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +#if defined (WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + +scriptVar SystemObject::vcpu_ddeSend( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar ddetarget, scriptVar cmd, scriptVar minInterval ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + DdeCom::sendCommand( GET_SCRIPT_STRING( ddetarget ), GET_SCRIPT_STRING( cmd ), GET_SCRIPT_INT( minInterval ) ); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_popMb( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + MainMiniBrowser::popMb(); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_getMainMB( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + return MAKE_SCRIPT_OBJECT( MainMiniBrowser::getScriptObject() ); +#else + RETURN_SCRIPT_NULL; +#endif +} + +scriptVar SystemObject::vcpu_setMenuTransparency( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar a ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + WASABI_API_CONFIG->setIntPublic( "Popup alpha", GET_SCRIPT_INT( a ) ); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_windowMenu( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + Main::thingerContextMenu( NULL ); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_systemMenu( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WA3COMPATIBILITY + Main::appContextMenu( NULL, FALSE, FALSE ); +#endif + RETURN_SCRIPT_VOID; +} + +scriptVar SystemObject::vcpu_selectFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar extlist, scriptVar id, scriptVar prevfn ) +{ + SCRIPT_FUNCTION_INIT; + SelectFile sf( WASABI_API_WND->main_getRootWnd() ); + sf.setIdent( GET_SCRIPT_STRING( id ) ); + StringW ff = GET_SCRIPT_STRING( prevfn ); + if ( !ff.isempty() ) + { + wchar_t *p = const_cast<wchar_t *>(Wasabi::Std::filename( ff ) ); + if ( p != NULL ) *p = 0; + sf.setDefaultDir( ff ); + } + StringW exts = GET_SCRIPT_STRING( extlist ); + if ( exts.isempty() ) + exts = L"All files(*.*)|*.*||"; + exts.changeChar( '|', '\0' ); + int r = sf.runSelector( L"files", FALSE, exts ); + StringW t; + if ( !r || sf.getNumFiles() < 1 ) + { + t = GET_SCRIPT_STRING( prevfn ); + } + else + { + t = sf.enumFilename( 0 ); + } + WCSCPYN( staticStr, t, 4096 ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +#endif + +const wchar_t *dldir; + +BOOL CALLBACK browseEnumProc( HWND hwnd, LPARAM lParam ) +{ + wchar_t cl[ 32 ] = { 0 }; + GetClassName( hwnd, cl, ARRAYSIZE( cl ) ); + if ( !lstrcmpi( cl, WC_TREEVIEW ) ) + { + PostMessage( hwnd, TVM_ENSUREVISIBLE, 0, (LPARAM)TreeView_GetSelection( hwnd ) ); + return FALSE; + } + + return TRUE; +} + +static int CALLBACK BrowseCallbackProcX( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData ) +{ + switch ( uMsg ) + { + case BFFM_INITIALIZED: + { + const wchar_t *wnd_title = (wchar_t *)lpData; + //if(wnd_title) wnd_title = _(wnd_title); + if ( WCSICMP( _( wnd_title ), L"" ) ) SetWindowTextW( hwnd, _( wnd_title ) ); + SendMessageW( hwnd, BFFM_SETSELECTIONW, 1, (LPARAM)dldir ); + + // this is not nice but it fixes the selection not working correctly on all OSes + EnumChildWindows( hwnd, browseEnumProc, 0 ); + } + return 0; + } + return 0; +} + +void Shell_Free( void *p ) +{ + IMalloc *m; + SHGetMalloc( &m ); + m->Free( p ); +} + +scriptVar SystemObject::vcpu_selectFolder( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar title, scriptVar info, scriptVar defPath ) +{ + SCRIPT_FUNCTION_INIT; + + dldir = defPath.data.sdata; + + BROWSEINFOW bi = { 0 }; + bi.hwndOwner = WASABI_API_WND->main_getRootWnd()->gethWnd(); + bi.lpszTitle = _( info.data.sdata ); // Info Text + bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; + bi.lpfn = BrowseCallbackProcX; + bi.lParam = (LPARAM)title.data.sdata; // Window Title + + ITEMIDLIST *idlist = SHBrowseForFolderW( &bi ); + if ( idlist ) + { + SHGetPathFromIDListW( idlist, staticStr ); + Shell_Free( idlist ); + + return MAKE_SCRIPT_STRING( staticStr ); + } + + return MAKE_SCRIPT_STRING( L"" ); +} + +#ifdef WASABI_COMPILE_MEDIACORE + +int SystemObject::corecb_onVolumeChange( int newvol ) +{ + vcpu_onVolumeChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newvol ) ); + return 0; +} + +int SystemObject::corecb_onEQStatusChange( int newval ) +{ + vcpu_onEqChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newval ) ); + return 0; +} + +int SystemObject::corecb_onEQPreampChange( int newval ) +{ + vcpu_onEqPreAmpChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newval ) ); + return 0; +} + +int SystemObject::corecb_onEQBandChange( int band, int newval ) +{ + vcpu_onEqBandChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( band ), MAKE_SCRIPT_INT( newval ) ); + return 0; +} + +int SystemObject::corecb_onEQFreqChange( int newval ) +{ + vcpu_onEqFreqChanged( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newval ) ); + return 0; +} + +int SystemObject::corecb_onStarted() +{ + vcpu_onPlay( SCRIPT_CALL, getScriptObject() ); + return 0; +} + +int SystemObject::corecb_onStopped() +{ + vcpu_onStop( SCRIPT_CALL, getScriptObject() ); + return 0; +} + +int SystemObject::corecb_onPaused() +{ + vcpu_onPause( SCRIPT_CALL, getScriptObject() ); + return 0; +} + +int SystemObject::corecb_onUnpaused() +{ + vcpu_onResume( SCRIPT_CALL, getScriptObject() ); + return 0; +} + +int SystemObject::corecb_onSeeked( int newpos ) +{ + vcpu_onSeeked( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_INT( newpos ) ); + return 0; +} + +int SystemObject::corecb_onTitleChange( const wchar_t *title ) +{ + vcpu_onTitleChange( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( title ) ); + return 0; +} + +int SystemObject::corecb_onTitle2Change( const wchar_t *title ) +{ + vcpu_onTitle2Change( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( title ) ); + return 0; +} + +int SystemObject::corecb_onUrlChange( const wchar_t *url ) +{ + vcpu_onUrlChange( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( url ) ); + return 0; +} + +int SystemObject::corecb_onInfoChange( const wchar_t *info ) +{ + vcpu_onInfoChange( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( info ) ); + return 0; +} + +int SystemObject::corecb_onStatusMsg( const wchar_t *info ) +{ + vcpu_onStatusMsg( SCRIPT_CALL, getScriptObject(), MAKE_SCRIPT_STRING( info ) ); + return 0; +} +#endif + +scriptVar SystemObject::vcpu_getRating( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + return MAKE_SCRIPT_INT( WASABI_API_MEDIACORE->core_getRating() ); +#else + RETURN_SCRIPT_ZERO; +#endif +} + +scriptVar SystemObject::vcpu_setRating( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v ) +{ + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_MEDIACORE + WASABI_API_MEDIACORE->core_setRating( GET_SCRIPT_INT( v ) ); + return MAKE_SCRIPT_VOID(); +#else + RETURN_SCRIPT_VOID; +#endif +} + +scriptVar SystemObject::vcpu_getDownloadPath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + wa2.getDownloadPath( staticStr ); + return MAKE_SCRIPT_STRING( staticStr ); +} + +scriptVar SystemObject::vcpu_setDownloadPath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar new_path ) +{ + SCRIPT_FUNCTION_INIT; + wa2.setDownloadPath( new_path.data.sdata ); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SystemObject::vcpu_downloadURL( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url, scriptVar filename, scriptVar title ) +{ + SCRIPT_FUNCTION_INIT; + wa2.DownloadFile( AutoChar( GET_SCRIPT_STRING( url ) ) ); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SystemObject::vcpu_downloadMedia( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url, scriptVar filepath, scriptVar storeInMl, scriptVar notifyDownloadsList ) +{ + SCRIPT_FUNCTION_INIT; + wa2.DownloadFile( AutoChar( GET_SCRIPT_STRING( url ) ), GET_SCRIPT_STRING( filepath ), GET_SCRIPT_BOOLEAN( storeInMl ), GET_SCRIPT_BOOLEAN( notifyDownloadsList ) ); + return MAKE_SCRIPT_VOID(); +} + +scriptVar SystemObject::vcpu_onDownloadFinished( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url, scriptVar success, scriptVar filename ) +{ + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS3( o, systemController, url, success, filename ); + SCRIPT_FUNCTION_CHECKABORTEVENT_SYS( o ); + SCRIPT_EXEC_EVENT3( o, url, success, filename ); +} + +scriptVar SystemObject::vcpu_getAlbumArt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar filename ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( !!wa2.GetAlbumArt( GET_SCRIPT_STRING( filename ) ) ); +} + +scriptVar SystemObject::vcpu_isWinampPro( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( !!wa2.IsWinampPro() ); +} + +static PtrList<StringW> embed_guids; + +static int embed_guid_enumProc( embedWindowState *ws, struct embedEnumStruct *param ) +{ + if ( ws->flags & EMBED_FLAGS_GUID ) + { + wchar_t guid[ 39 ] = { 0 }; + nsGUID::toCharW( GET_EMBED_GUID( ws ), guid ); + embed_guids.addItem( new StringW( guid ) ); + } + return 0; +} +scriptVar SystemObject::vcpu_enumEmbedGUID( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _index ) +{ + SCRIPT_FUNCTION_INIT; + int index = GET_SCRIPT_INT( _index ); + if ( index == 0 ) // make the table + { + embed_guids.deleteAll(); + embedEnumStruct param; + param.user_data = 0; + param.enumProc = embed_guid_enumProc; + SendMessageW( wa2.getMainWindow(), WM_WA_IPC, (WPARAM)¶m, IPC_EMBED_ENUM ); + } + if ( index >= 0 && index < embed_guids.getNumItems() ) + return MAKE_SCRIPT_STRING( embed_guids[ index ]->getValue() ); + + return MAKE_SCRIPT_STRING( L"" ); +} + +scriptVar SystemObject::vcpu_getWinampVersion( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; +/** This would have been the code to return a double. + double r = atof(wa2.getVersion()); + return MAKE_SCRIPT_DOUBLE(r); +*/ + return MAKE_SCRIPT_STRING( applicationApi->main_getVersionNumString() ); +} + +scriptVar SystemObject::vcpu_getBuildNumber( SCRIPT_FUNCTION_PARAMS, ScriptObject *object ) +{ + SCRIPT_FUNCTION_INIT; + return MAKE_SCRIPT_INT( applicationApi->main_getBuildNumber() ); +} + +scriptVar SystemObject::vcpu_getFileSize( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _file ) +{ + SCRIPT_FUNCTION_INIT; + const wchar_t *file = GET_SCRIPT_STRING( _file ); + if ( file == NULL ) // make the table + { + return MAKE_SCRIPT_INT( 0 ); + } + /*fileApi->fileOpen(file, 0); + int size = fileApi->fileGetFileSize(); + fileApi->fileClose(;*/ + OSFILETYPE in = WFOPEN( file, WF_READONLY_BINARY ); + if ( in == OPEN_FAILED ) return MAKE_SCRIPT_INT( 0 ); + int size = (int)FGETSIZE( in ); + FCLOSE( in ); + return MAKE_SCRIPT_INT( size ); +} + +wchar_t SystemObject::staticStr[ 4096 ] = { 0 }; +wchar_t SystemObject::translateStr[ 4096 ] = { 0 }; +PtrList < ScriptObject > SystemObject::scriptobjects; + +// END VCPU + +// --------------------------------------------------------------- +// -- END SCRIPT ------------------------------------------------- +// ---------------------------------------------------------------
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/systemobj.h b/Src/Wasabi/api/script/objects/systemobj.h new file mode 100644 index 00000000..4b388692 --- /dev/null +++ b/Src/Wasabi/api/script/objects/systemobj.h @@ -0,0 +1,397 @@ +#ifndef _SYSTEMOBJ_H +#define _SYSTEMOBJ_H + +#include <api/script/script.h> +#include <api/script/objects/rootobj.h> +#include <api/script/objects/timer.h> +#ifdef WASABI_COMPILE_MEDIACORE +#include <api/syscb/callbacks/corecbi.h> +#endif +#include <api/syscb/callbacks/browsercbi.h> +#include <bfc/string/bfcstring.h> + +#ifdef WASABI_COMPILE_WNDMGR +class WindowHolder; +#endif + +// {D6F50F64-93FA-49b7-93F1-BA66EFAE3E98} +static const GUID systemObjectGuid = +{ 0xd6f50f64, 0x93fa, 0x49b7, { 0x93, 0xf1, 0xba, 0x66, 0xef, 0xae, 0x3e, 0x98 } }; + +class SystemScriptObjectController : public ScriptObjectControllerI { + public: + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController() { return rootScriptObjectController; } + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual int getInstantiable(); + virtual int getReferenceable(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + static function_descriptor_struct exportedFunction[]; +}; + +extern SystemScriptObjectController *systemController; + +class Group; + +#ifdef WASABI_COMPILE_WNDMGR +class Layout; +class Container; +class WindowHolder; +#endif + +#ifdef WASABI_COMPILE_COMPONENTS +class WACObject; +#endif + +#define SYSTEMOBJECT_SCRIPTPARENT RootObjectInstance + +#ifdef WASABI_COMPILE_MEDIACORE +#define SYSTEMOBJECT_PARENT SYSTEMOBJECT_SCRIPTPARENT, public CoreCallbackI +#else +#define SYSTEMOBJECT_PARENT SYSTEMOBJECT_SCRIPTPARENT +#endif + +class SystemObject : public SYSTEMOBJECT_PARENT, public BrowserCallbackI { + public: + SystemObject(); + virtual ~SystemObject(); + void setScriptId(int id); + int getScriptId(); + void setTimer(int delay); + void setParam(const wchar_t *p); + void setParentGroup(Group *g); + Group *getParentGroup(); + const wchar_t *getParam(); + virtual void onLoad(); + virtual void onUnload(); + virtual int isLoaded() { return loaded; } +#ifdef WASABI_COMPILE_WNDMGR + WindowHolder *getSuitableWindowHolderByGuid(GUID g); + int onGetCancelComponent(GUID g, int i); + static void onCreateLayout(Layout *l); + static void onShowLayout(Layout *l); + static void onHideLayout(Layout *l); + static int getCurAppRect(RECT *r); +#endif + static void onQuit(); + static void onKeyDown(const wchar_t *s); + static void onKeyUp(const wchar_t *s); + static int onAccelerator(const wchar_t *action, const wchar_t *section, const wchar_t *key); + TList < int > *getTypesList(); + void setIsOldFormat(int is); + int isOldFormat(); + static int isAppActive(); + + static void onViewPortChanged(int width, int height); + static int onShowNotification(); + static void onDownloadFinished(const wchar_t * url, boolean success, const wchar_t * filename); + + static PtrList < ScriptObject > *getAllScriptObjects() { return &scriptobjects; } + void setSkinPartId(int _skinpartid); + int getSkinPartId(); + + void addInstantiatedObject(ScriptObject *obj); + void removeInstantiatedObject(ScriptObject *obj); + void garbageCollect(); + + static int isObjectValid(ScriptObject *o); + static void addScriptObject(ScriptObject *o); + static void removeScriptObject(ScriptObject *o); + +#ifdef WASABI_COMPILE_SKIN + void onSetXuiParam(const wchar_t *param, const wchar_t *value); +#endif + + const wchar_t *getFilename() { return filename; } + void setFilename(const wchar_t *file) { filename = file; } + static void navigateUrl(const wchar_t *url); + static void navigateUrlBrowser(const wchar_t *url); + + // called by vcpu + static scriptVar vcpu_getVersion( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onScriptLoaded( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onScriptUnloading( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onQuit( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +#ifdef WASABI_COMPILE_SKIN + static scriptVar vcpu_onSetXuiParam( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar param, scriptVar value); + static scriptVar vcpu_getSkinName( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_switchSkin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar skinname); + static scriptVar vcpu_isLoadingSkin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_lockUI( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_unlockUI( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); +#endif + static scriptVar vcpu_isObjectValid( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar o); + static scriptVar vcpu_getTimeOfDay( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_navigateUrl( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url); + static scriptVar vcpu_navigateUrlBrowser( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url); + static scriptVar vcpu_isKeyDown( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar vk_code); + static scriptVar vcpu_setClipboard( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar text); + static scriptVar vcpu_chr( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar n); + static scriptVar vcpu_onAccelerator( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar action, scriptVar section, scriptVar key); + static scriptVar vcpu_triggerAction( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guiobj, scriptVar actionstr, scriptVar paramstr); + static scriptVar vcpu_getParam( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); +#ifdef WASABI_COMPILE_SKIN + static scriptVar vcpu_getScriptGroup( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_newGroup( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar groupname); +#endif + static scriptVar vcpu_getMousePosX( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMousePosY( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isMinimized( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isDesktopAlphaAvailable( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isTransparencyAvailable( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_minimizeApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_restoreApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_activateApplication( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_integerToString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar i); + static scriptVar vcpu_stringToInteger( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar s); + static scriptVar vcpu_floatToString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar f, scriptVar digits); + static scriptVar vcpu_stringToFloat( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar s); + static scriptVar vcpu_integerToTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_integerToLongTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_dateToTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_dateToLongTime( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_formatDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_formatLongDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateYear( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateMonth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateDay( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateDow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateDoy( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateHour( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateMin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateSec( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDateDst( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _i); + static scriptVar vcpu_getDate( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_strmid( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar start, scriptVar len); + static scriptVar vcpu_strleft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar len); + static scriptVar vcpu_strright( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str, scriptVar _len); + static scriptVar vcpu_strsearch( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str, scriptVar substr); + static scriptVar vcpu_strlen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str); + static scriptVar vcpu_strupper( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_strlower( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_urlencode( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_urldecode( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_removepath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_getpath( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_getextension( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _str); + static scriptVar vcpu_gettoken( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar tok, scriptVar sep, scriptVar num); + static scriptVar vcpu_sin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_cos( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_tan( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_asin( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_acos( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_atan( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_atan2( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar y, scriptVar x); + static scriptVar vcpu_pow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_sqr( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar _d); + static scriptVar vcpu_sqrt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar d); + static scriptVar vcpu_random( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar m); + static scriptVar vcpu_integer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_frac( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_log( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_log10( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_getMonitorLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMonitorTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMonitorWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMonitorHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMonitorLeftFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getMonitorTopFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getMonitorLeftGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getMonitorTopGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getMonitorWidthFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getMonitorHeightFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getMonitorWidthGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getMonitorHeightGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_onViewPortChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar width, scriptVar height); + static scriptVar vcpu_getViewportWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getViewportHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getViewportWidthGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getViewportHeightGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getViewportLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getViewportTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getViewportLeftGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getViewportTopGO( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar obj); + static scriptVar vcpu_getViewportWidthFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getViewportHeightFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getViewportLeftFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getViewportTopFP( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar x, scriptVar y); + static scriptVar vcpu_getTickCount( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_onKeyDown( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar vcpu_onKeyUp( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar v); + static scriptVar vcpu_debugString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str, scriptVar severity); + static scriptVar vcpu_messageBox( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar msg, scriptVar title, scriptVar flags, scriptVar nam); + static scriptVar vcpu_getAtom( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar atomname); + static scriptVar vcpu_setAtom( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar atomname, scriptVar obj); +#ifdef WASABI_COMPILE_MAKIDEBUG + static scriptVar vcpu_invokeDebugger( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); +#endif +#if defined (WASABI_COMPILE_WNDMGR) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + static scriptVar vcpu_onCreateLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l); + static scriptVar vcpu_onShowLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l); + static scriptVar vcpu_onHideLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar l); + static scriptVar vcpu_getContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar contname); + static scriptVar vcpu_newDynamicContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar contname); + static scriptVar vcpu_newGroupAsLayout( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar groupname); + static scriptVar vcpu_getNumContainers( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_enumContainer( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar n); + static scriptVar vcpu_onLookForComponent( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid); + static scriptVar vcpu_onGetCancelComponent( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar guid, scriptVar i); + static scriptVar vcpu_getCurAppLeft( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getCurAppTop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getCurAppWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getCurAppHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isAppActive( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_showWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar wndguidorgroup, scriptVar prefcontainer, scriptVar transient); + static scriptVar vcpu_hideWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar container); + static scriptVar vcpu_hideNamedWindow( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar wndguidorgroup); + static scriptVar vcpu_isNamedWindowVisible( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar wndguidorgroup); +#endif +#if defined(WASABI_COMPILE_MEDIACORE) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + static scriptVar vcpu_getStatus( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_onStop( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onPlay( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onPause( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onResume( SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar vcpu_onTitleChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title); + static scriptVar vcpu_onTitle2Change( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title); + static scriptVar vcpu_onUrlChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar title); + static scriptVar vcpu_onInfoChange( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar info); + static scriptVar vcpu_onStatusMsg( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar info); + static scriptVar vcpu_onEqBandChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar band, scriptVar val); + static scriptVar vcpu_onEqFreqChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar vcpu_onEqPreAmpChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar vcpu_onEqChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar vcpu_onVolumeChanged( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar vcpu_onSeeked( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar val); + static scriptVar vcpu_getPlayItemDisplayTitle( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getPlayItemString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getPlayItemLength( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getPlayItemMetadataString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar name); + static scriptVar vcpu_getMetadataString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar filename, scriptVar name); + static scriptVar vcpu_getExtFamily( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ext); + static scriptVar vcpu_getDecoderName( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar ext); + static scriptVar vcpu_playFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file); + static scriptVar vcpu_enqueueFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file); + static scriptVar vcpu_clearPlaylist( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getLeftVuMeter( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getRightVuMeter( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getVisBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar chan, scriptVar band); + static scriptVar vcpu_getVolume( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_setVolume( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_play( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_stop( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_pause( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_next( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_previous( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_eject( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_seekTo( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar to); + static scriptVar vcpu_setEqBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar band, scriptVar val); + static scriptVar vcpu_setEqPreAmp( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_setEq( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + static scriptVar vcpu_getPosition( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getEqBand( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar band); + static scriptVar vcpu_getEqPreAmp( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getEq( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_hasVideoSupport( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isVideo( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_isVideoFullscreen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_setVideoFullscreen( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar val); + static scriptVar vcpu_getIdealVideoWidth( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getIdealVideoHeight( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getPlaylistLength( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getPlaylistIndex( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_onShowNotification( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getSongInfoText( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getSongInfoTextTranslated( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); +#endif +#if defined(WASABI_COMPILE_COMPONENTS) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + static scriptVar vcpu_getWac( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar guid); +#endif +#if defined (WASABI_COMPILE_CONFIG) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + static scriptVar vcpu_setPrivateString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar str); + static scriptVar vcpu_setPrivateInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar val); + static scriptVar vcpu_getPrivateString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar defstr); + static scriptVar vcpu_getPrivateInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar section, scriptVar item, scriptVar defval); + static scriptVar vcpu_setPublicString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar str); + static scriptVar vcpu_setPublicInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar val); + static scriptVar vcpu_getPublicString( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar defstr); + static scriptVar vcpu_getPublicInt( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar item, scriptVar defval); +#endif +#if defined (WA3COMPATIBILITY) || defined(WASABI_SCRIPT_SYSTEMOBJECT_WA3COMPATIBLE) + static scriptVar vcpu_ddeSend( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar ddetarget, scriptVar cmd, scriptVar minInterval); + static scriptVar vcpu_popMb( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getMainMB( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_setMenuTransparency( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar a); + static scriptVar vcpu_windowMenu( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_systemMenu( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); +#endif + static scriptVar vcpu_selectFile( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar extlist, scriptVar id, scriptVar prevfn); + static scriptVar vcpu_selectFolder( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar title, scriptVar info, scriptVar defpath); + + static scriptVar vcpu_getRating( SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_setRating ( SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar v); + +#ifdef WASABI_COMPILE_MEDIACORE + // core callbacks + virtual int corecb_onVolumeChange(int newvol); + virtual int corecb_onEQStatusChange(int newval); + virtual int corecb_onEQPreampChange(int newval); + virtual int corecb_onEQBandChange(int band, int newval); + virtual int corecb_onEQFreqChange(int newval); + virtual int corecb_onStarted(); + virtual int corecb_onStopped(); + virtual int corecb_onPaused(); + virtual int corecb_onUnpaused(); + virtual int corecb_onSeeked(int newpos); + virtual int corecb_onTitleChange(const wchar_t *title); + virtual int corecb_onTitle2Change(const wchar_t *title); + virtual int corecb_onUrlChange(const wchar_t *url); + virtual int corecb_onInfoChange(const wchar_t *info); + virtual int corecb_onStatusMsg(const wchar_t *info); +#endif + + virtual void browsercb_onOpenURL(wchar_t *url, bool *override); + static scriptVar vcpu_onOpenURL( SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar url); + + static scriptVar vcpu_downloadURL(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url,scriptVar filename,scriptVar title); + static scriptVar vcpu_downloadMedia(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url, scriptVar filepath, scriptVar storeInMl, scriptVar notifyDownloadsList); + static scriptVar vcpu_onDownloadFinished(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar url,scriptVar success, scriptVar filename); + static scriptVar vcpu_getDownloadPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_setDownloadPath(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar new_path); + static scriptVar vcpu_getAlbumArt(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar filename); + static scriptVar vcpu_isWinampPro(SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_enumEmbedGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar index); + static scriptVar vcpu_getWinampVersion(SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getBuildNumber(SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + static scriptVar vcpu_getFileSize(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar file); + static scriptVar vcpu_translate(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar str); + static scriptVar vcpu_getString(SCRIPT_FUNCTION_PARAMS, ScriptObject *object, scriptVar table, scriptVar id); + static scriptVar vcpu_getLanguageId(SCRIPT_FUNCTION_PARAMS, ScriptObject *object); + + private: + int scriptVCPUId; + StringW param; + static wchar_t staticStr[4096]; + static wchar_t translateStr[4096]; + TList < int > typeslist; + int isoldformat; + Group * parentGroup; + int skinpartid; + static PtrList < ScriptObject > scriptobjects; + PtrList < ScriptObject > instantiated; + int loaded; + int started_up; + StringW filename; + + public: +}; + +#endif
\ No newline at end of file diff --git a/Src/Wasabi/api/script/objects/timer.cpp b/Src/Wasabi/api/script/objects/timer.cpp new file mode 100644 index 00000000..36449940 --- /dev/null +++ b/Src/Wasabi/api/script/objects/timer.cpp @@ -0,0 +1,165 @@ +#include <precomp.h> +#include "timer.h" +#include <api/script/scriptmgr.h> +#include <api/script/objects/rootobject.h> +//#include <api/wac/main.h>//CUT!! +//#include <api/timer/genwnd.h> //CUT!! + +STimer::STimer() { + getScriptObject()->vcpu_setInterface(timerGuid, (void *)static_cast<STimer *>(this)); + getScriptObject()->vcpu_setClassName(L"Timer"); + getScriptObject()->vcpu_setController(timerController); + delay = 1000; + started = 0; +} + +STimer::~STimer() { +} + +void STimer::setDelay(int d) { + delay = d; + if (started) + timerclient_setTimer(STIMER_ID, getDelay()); +} + +int STimer::getDelay(void) { + return delay; +} + +void STimer::start(void) { + if (started) { stop(); } + timerclient_setTimer(STIMER_ID, getDelay()); + started = 1; +} + +void STimer::stop(void) { + if (!started) return; + timerclient_killTimer(STIMER_ID); + started = 0; +} + +void STimer::onTimer(void) +{ + if (started) + { + script_onTimer(SCRIPT_CALL, getScriptObject()); + } +} + +void STimer::timerclient_timerCallback(int id) +{ + if (id == STIMER_ID) + onTimer(); +} + +int STimer::isRunning() { + return started; +} + +TimerScriptController _timerController; +TimerScriptController *timerController=&_timerController; + +// -- Functions table ------------------------------------- +function_descriptor_struct TimerScriptController::exportedFunction[] = { + {L"setDelay", 1, (void*)STimer::script_setDelay }, + {L"getDelay", 0, (void*)STimer::script_getDelay }, + {L"start", 0, (void*)STimer::script_start }, + {L"stop", 0, (void*)STimer::script_stop }, + {L"onTimer", 0, (void*)STimer::script_onTimer }, + {L"isRunning",0, (void*)STimer::script_isRunning }, + {L"getSkipped",0, (void*)STimer::script_getSkipped }, +}; +// -------------------------------------------------------- + +const wchar_t *TimerScriptController::getClassName() { + return L"Timer"; +} + +const wchar_t *TimerScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *TimerScriptController::getAncestorController() { + return rootScriptObjectController; +} + +ScriptObject *TimerScriptController::instantiate() { + STimer *s = new STimer; + ASSERT(s != NULL); + return s->getScriptObject(); +} + +void TimerScriptController::destroy(ScriptObject *o) { + STimer *s = static_cast<STimer *>(o->vcpu_getInterface(timerGuid)); + ASSERT(s != NULL); + delete s; +} + +void *TimerScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for timer yet +} + +void TimerScriptController::deencapsulate(void *o) { +} + +int TimerScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *TimerScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID TimerScriptController::getClassGuid() { + return timerGuid; +} + +scriptVar STimer::script_onTimer(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS0(o, timerController); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT0(o); +} + +scriptVar STimer::script_setDelay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar d) { + SCRIPT_FUNCTION_INIT; + ASSERT(SOM::isNumeric(&d)); + STimer *t = static_cast<STimer *>(o->vcpu_getInterface(timerGuid)); + if (t) t->setDelay(SOM::makeInt(&d)); + RETURN_SCRIPT_VOID; +} + +scriptVar STimer::script_getDelay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + STimer *t = static_cast<STimer *>(o->vcpu_getInterface(timerGuid)); + if (t) return MAKE_SCRIPT_INT(t->getDelay()); + RETURN_SCRIPT_ZERO; +} + +scriptVar STimer::script_start(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + STimer *t = static_cast<STimer *>(o->vcpu_getInterface(timerGuid)); + if (t) t->start(); + RETURN_SCRIPT_VOID; +} + +scriptVar STimer::script_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + STimer *t = static_cast<STimer *>(o->vcpu_getInterface(timerGuid)); + if (t) t->stop(); + RETURN_SCRIPT_VOID; +} + +scriptVar STimer::script_isRunning(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + STimer *t = static_cast<STimer *>(o->vcpu_getInterface(timerGuid)); + if (t) return MAKE_SCRIPT_BOOLEAN(t->isRunning()); + RETURN_SCRIPT_ZERO; +} + +scriptVar STimer::script_getSkipped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + STimer *t = static_cast<STimer *>(o->vcpu_getInterface(timerGuid)); + if (t) return MAKE_SCRIPT_INT(t->timerclient_getSkipped()); + RETURN_SCRIPT_ZERO; +} diff --git a/Src/Wasabi/api/script/objects/timer.h b/Src/Wasabi/api/script/objects/timer.h new file mode 100644 index 00000000..5506a20a --- /dev/null +++ b/Src/Wasabi/api/script/objects/timer.h @@ -0,0 +1,77 @@ +//PORTABLE +#ifndef _STIMER_H +#define _STIMER_H + +#include <api/wnd/basewnd.h> +#include <api/script/objects/rootobject.h> +#include <api/script/objects/rootobj.h> + +#include <api/timer/timerclient.h> + +#define STIMER_PARENT RootObjectInstance + +// {5D0C5BB6-7DE1-4b1f-A70F-8D1659941941} +static const GUID timerGuid = +{ 0x5d0c5bb6, 0x7de1, 0x4b1f, { 0xa7, 0xf, 0x8d, 0x16, 0x59, 0x94, 0x19, 0x41 } }; + +class TimerScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern TimerScriptController *timerController; + + +#ifndef _NOSTUDIO + +#define STIMER_ID 2481 + +class STimer : public STIMER_PARENT, public TimerClientDI { +public: + STimer(); + virtual ~STimer(); + + void start(void); + void stop(void); + int getDelay(void); + void setDelay(int d); + void onTimer(void); + int isRunning(); + + void timerclient_timerCallback(int id); + +private: + int delay; + int started; + +#else +class STimer : public STIMER_SCRIPTPARENT { +#endif + +public: + + static scriptVar script_onTimer(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_setDelay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar d); + static scriptVar script_getDelay(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_start(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_stop(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_isRunning(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_getSkipped(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); +}; + +#endif diff --git a/Src/Wasabi/api/script/objects/wacobj.cpp b/Src/Wasabi/api/script/objects/wacobj.cpp new file mode 100644 index 00000000..6abba5bc --- /dev/null +++ b/Src/Wasabi/api/script/objects/wacobj.cpp @@ -0,0 +1,161 @@ +#include <precomp.h> +#include <bfc/wasabi_std.h> +#include <bfc/nsguid.h> +#include <api/script/script.h> +#include <api/script/scriptobj.h> +#include <api/script/scriptmgr.h> +#include <api/script/objects/wacobj.h> + +#ifdef _WASABIRUNTIME +#include <api/api.h> +#include <api/wac/compon.h> +#endif + +WacScriptController _wacController; +WacScriptController *wacController = &_wacController; + +// -- Functions table ------------------------------------- +function_descriptor_struct WacScriptController::exportedFunction[] = { + {L"getGUID", 1, (void*)WACObject::script_getGUID }, + {L"getName", 1, (void*)WACObject::script_getName }, + {L"onNotify", 3, (void*)WACObject::script_vcpu_onNotify }, + +// DEPRECATED! DO NOTHING + {L"sendCommand", 4, (void*)WACObject::script_vcpu_dummy4}, + {L"show", 0, (void*)WACObject::script_vcpu_dummy0}, + {L"hide", 0, (void*)WACObject::script_vcpu_dummy0}, + {L"isVisible", 0, (void*)WACObject::script_vcpu_dummy0}, + {L"onShow", 0, (void*)WACObject::script_vcpu_dummy0}, + {L"onHide", 0, (void*)WACObject::script_vcpu_dummy0}, + {L"setStatusBar", 1, (void*)WACObject::script_vcpu_dummy1}, + {L"getStatusBar", 0, (void*)WACObject::script_vcpu_dummy0}, +}; +// -------------------------------------------------------- + +const wchar_t *WacScriptController::getClassName() { + return L"Wac"; +} + +const wchar_t *WacScriptController::getAncestorClassName() { + return L"Object"; +} + +ScriptObjectController *WacScriptController::getAncestorController() { return rootScriptObjectController; } + +int WacScriptController::getInstantiable() { + return 0; +} + +int WacScriptController::getNumFunctions() { + return sizeof(exportedFunction) / sizeof(function_descriptor_struct); +} + +const function_descriptor_struct *WacScriptController::getExportedFunctions() { + return exportedFunction; +} + +GUID WacScriptController::getClassGuid() { + return wacGuid; +} + +ScriptObject *WacScriptController::instantiate() { + return NULL; +} + +void WacScriptController::destroy(ScriptObject *o) { +} + +void *WacScriptController::encapsulate(ScriptObject *o) { + return NULL; // no encapsulation for wacobject yet +} + +void WacScriptController::deencapsulate(void *o ) { +} + +WACObject::WACObject() { + getScriptObject()->vcpu_setInterface(wacGuid, (void *)static_cast<WACObject *>(this)); + getScriptObject()->vcpu_setClassName(L"Wac"); + getScriptObject()->vcpu_setController(wacController); + wacobjs.addItem(this); +} + +WACObject::~WACObject() { + wacobjs.delItem(this); +} + +void WACObject::setGUID(GUID g) { + myGUID = g; +} + +GUID WACObject::getGUID(void) { + return myGUID; +} + +int WACObject::onScriptNotify(const wchar_t *s, int i1, int i2) +{ + scriptVar _i1 = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_i1, i1); + scriptVar _i2 = SOM::makeVar(SCRIPT_INT); + SOM::assign(&_i2, i2); + scriptVar _str = SOM::makeVar(SCRIPT_STRING); + SOM::assign(&_str, (wchar_t *)s); + script_vcpu_onNotify(SCRIPT_CALL, getScriptObject(), _str, _i1, _i2); + return 1; +} + +int WACObject::notifyScripts(WaComponent *comp, const wchar_t *s, int i1, int i2) +{ + for (int i=0;i<wacobjs.getNumItems();i++) + { + GUID g = comp->getGUID(); + if (!MEMCMP(&g, &wacobjs.enumItem(i)->myGUID, sizeof(GUID))) + return wacobjs.enumItem(i)->onScriptNotify(s, i1, i2); + } + return 0; +} + +scriptVar WACObject::script_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) +{ + SCRIPT_FUNCTION_INIT; + static wchar_t guid[nsGUID::GUID_STRLEN+1]; + WACObject *wo = static_cast<WACObject *>(o->vcpu_getInterface(wacGuid)); + *guid=0; + if (wo) + nsGUID::toCharW(wo->myGUID, guid); + return MAKE_SCRIPT_STRING(guid); +} + +scriptVar WACObject::script_getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; +#ifdef WASABI_COMPILE_COMPONENTS + WACObject *wo = static_cast<WACObject *>(o->vcpu_getInterface(wacGuid)); + if (wo) return MAKE_SCRIPT_STRING(WASABI_API_COMPONENT->getComponentName(wo->myGUID)); +#endif + return MAKE_SCRIPT_STRING(L""); +} + +scriptVar WACObject::script_vcpu_onNotify(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str, scriptVar i1, scriptVar i2) { + SCRIPT_FUNCTION_INIT; + PROCESS_HOOKS3(o, wacController, str, i1, i2); + SCRIPT_FUNCTION_CHECKABORTEVENT; + SCRIPT_EXEC_EVENT3(o, str, i1, i2); +} + +scriptVar WACObject::script_vcpu_dummy4(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a, scriptVar b, scriptVar c, scriptVar d) { + SCRIPT_FUNCTION_INIT; + RETURN_SCRIPT_ZERO; +} + +scriptVar WACObject::script_vcpu_dummy1(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a) { + SCRIPT_FUNCTION_INIT; + RETURN_SCRIPT_ZERO; +} + +scriptVar WACObject::script_vcpu_dummy0(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { + SCRIPT_FUNCTION_INIT; + RETURN_SCRIPT_ZERO; +} + + +PtrList<WACObject> WACObject::wacobjs; + diff --git a/Src/Wasabi/api/script/objects/wacobj.h b/Src/Wasabi/api/script/objects/wacobj.h new file mode 100644 index 00000000..44cf2d3e --- /dev/null +++ b/Src/Wasabi/api/script/objects/wacobj.h @@ -0,0 +1,75 @@ +#ifndef _WACOBJ_H +#define _WACOBJ_H + +#include <api/script/script.h> +#include <api/script/scriptobj.h> +#include <api/script/objects/guiobj.h> +#include <bfc/ptrlist.h> +#include <api/wac/wac.h> + +// {00C074A0-FEA2-49a0-BE8D-FABBDB161640} +static const GUID wacGuid = +{ 0xc074a0, 0xfea2, 0x49a0, { 0xbe, 0x8d, 0xfa, 0xbb, 0xdb, 0x16, 0x16, 0x40 } }; + +#define WACOBJECT_SCRIPTPARENT RootObjectInstance + +class WacScriptController : public ScriptObjectControllerI { + public: + + virtual const wchar_t *getClassName(); + virtual const wchar_t *getAncestorClassName(); + virtual ScriptObjectController *getAncestorController(); + virtual int getNumFunctions(); + virtual const function_descriptor_struct *getExportedFunctions(); + virtual GUID getClassGuid(); + virtual ScriptObject *instantiate(); + virtual void destroy(ScriptObject *o); + virtual int getInstantiable(); + virtual void *encapsulate(ScriptObject *o); + virtual void deencapsulate(void *o); + + private: + + static function_descriptor_struct exportedFunction[]; + +}; + +extern WacScriptController *wacController; + +#include <api/wnd/virtualwnd.h> + +class WACObject : public WACOBJECT_SCRIPTPARENT { + +public: + WACObject(); + virtual ~WACObject(); + + void setGUID(GUID g); + GUID getGUID(void); + + int onScriptNotify(const wchar_t *s, int i1, int i2); + + // VCPU + static scriptVar script_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_getName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + static scriptVar script_vcpu_onNotify(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar str, scriptVar i1, scriptVar i2); + + static scriptVar script_vcpu_dummy4(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a, scriptVar b, scriptVar c, scriptVar d); + static scriptVar script_vcpu_dummy1(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar a); + static scriptVar script_vcpu_dummy0(SCRIPT_FUNCTION_PARAMS, ScriptObject *o); + + // End VCPU + + static int notifyScripts(WaComponent *comp, const wchar_t *s, int i1, int i2); + + GUID myGUID; + +private: + + static PtrList<WACObject> wacobjs; + +public: +}; + + +#endif |