#include #include "xuiwndholder.h" #include #include #include // ----------------------------------------------------------------------- const wchar_t WindowHolderXuiObjectStr[] = L"WindowHolder"; // This is the xml tag const wchar_t WindowHolderXuiObjectStrCompat[] = L"Component"; // This is the old xml tag char WindowHolderXuiSvcName[] = "WindowHolder xui object"; char WindowHolderXuiSvcNameCompat[] = "Component xui object"; // {7DB51C8C-36C0-4585-9240-A2DB22B1B8F7} static const GUID pvt_xuiWindowHolder = { 0x7db51c8c, 0x36c0, 0x4585, { 0x92, 0x40, 0xa2, 0xdb, 0x22, 0xb1, 0xb8, 0xf7 } }; XMLParamPair XuiWindowHolder::params[] = { {XUIWNDHOLDER_ADDHOLD, L"PARAM"}, {XUIWNDHOLDER_ADDHOLD, L"COMPONENT"}, {XUIWNDHOLDER_ADDHOLD, L"HOLD"}, {XUIWNDHOLDER_SETNOSHOWCMDBAR, L"NOSHOWCMDBAR"}, {XUIWNDHOLDER_SETNOANIMRECTS, L"NOANIMATEDRECTS"}, {XUIWNDHOLDER_SETNOANIMRECTS, L"DISABLEANIMATEDRECTS"}, {XUIWNDHOLDER_SETAUTOOPEN, L"AUTOOPEN"}, {XUIWNDHOLDER_SETAUTOCLOSE, L"AUTOCLOSE"}, {XUIWNDHOLDER_SETAUTOFOCUS, L"AUTOFOCUS"}, {XUIWNDHOLDER_SETAUTOAVAILABLE, L"AUTOAVAILABLE"}, }; // ----------------------------------------------------------------------- XuiWindowHolder::XuiWindowHolder() { getScriptObject()->vcpu_setInterface(windowHolderGuid, (void *)static_cast(this)); getScriptObject()->vcpu_setInterface(pvt_xuiWindowHolder, (void *)static_cast(this)); getScriptObject()->vcpu_setClassName(L"WindowHolder"); // this is the script class name getScriptObject()->vcpu_setController(windowHolderController); myxuihandle = newXuiHandle(); CreateXMLParameters(myxuihandle); setXmlParam(L"autofocus", L"1"); } void XuiWindowHolder::CreateXMLParameters(int master_handle) { //XUIWNDHOLDER_PARENT::CreateXMLParameters(master_handle); int numParams = sizeof(params) / sizeof(params[0]); hintNumberOfParams(myxuihandle, numParams); for (int i = 0;i < numParams;i++) addParam(myxuihandle, params[i], XUI_ATTRIBUTE_IMPLIED); } XuiWindowHolder::~XuiWindowHolder() { } void XuiWindowHolder::setRegionFromMap(ScriptObject *map, int byte, int inverse) { } void XuiWindowHolder::setRegion(ScriptObject *_region) { //#pragma CHAT("bas", "lone", "I implemented setRegion for ya once SRegion is safe") #if 1// if SRegion were cross-dll safe this would work const GUID regionGuid = { 0x3a370c02, 0x3cbf, 0x439f, { 0x84, 0xf1, 0x86, 0x88, 0x5b, 0xcf, 0x1e, 0x36 } }; void *reg = _region->vcpu_getInterface(regionGuid); ASSERT(reg != NULL); SRegion *sr = static_cast(reg); ASSERT(sr != NULL); api_region *region = sr->getRegion(); ASSERT(region != NULL); api_region *clone = region->clone(); clone->scale(getRenderRatio(), getRenderRatio()); ifc_window *curRootWnd = getCurRootWnd(); if (curRootWnd) { #ifdef _WIN32 OSWINDOWHANDLE osWnd = curRootWnd->gethWnd(); if (osWnd) SetWindowRgn(osWnd, clone->makeWindowRegion(), TRUE); #else #warning port me // can probably use a mask here #endif } region->disposeClone(clone); #endif } // ----------------------------------------------------------------------- int XuiWindowHolder::setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) { if (xuihandle != myxuihandle) return XUIWNDHOLDER_PARENT::setXuiParam(xuihandle, xmlattributeid, xmlattributename, value); switch (xmlattributeid) { case XUIWNDHOLDER_ADDHOLD: if (!WCSICMP(value, L"@ALL@") || !WCSICMP(value, L"guid:default")) { setAcceptAllGuids(1); setAcceptAllGroups(1); } else { setAcceptAllGuids(0); setAcceptAllGroups(0); ParamParser pp(value); for (int i=0;igetScriptObject(); } void WindowHolderScriptController::destroy(ScriptObject *o) { XuiWindowHolder *wh = static_cast(o->vcpu_getInterface(pvt_xuiWindowHolder)); ASSERT(wh != NULL); delete wh; } void *WindowHolderScriptController::encapsulate(ScriptObject *o) { return NULL; // no encapsulation for windowholder yet } void WindowHolderScriptController::deencapsulate(void *o) { } int WindowHolderScriptController::getNumFunctions() { return sizeof(exportedFunction) / sizeof(function_descriptor_struct); } const function_descriptor_struct *WindowHolderScriptController::getExportedFunctions() { return exportedFunction; } scriptVar WindowHolderScriptController::script_getComponentName(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { SCRIPT_FUNCTION_INIT XuiWindowHolder *wh = static_cast(o->vcpu_getInterface(pvt_xuiWindowHolder)); if (wh) { ifc_window *ro = wh->getCurRootWnd(); if (ro) { return MAKE_SCRIPT_STRING(ro->getRootWndName()); } } return MAKE_SCRIPT_STRING(L""); } scriptVar WindowHolderScriptController::script_getGUID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { SCRIPT_FUNCTION_INIT XuiWindowHolder *wh = static_cast(o->vcpu_getInterface(pvt_xuiWindowHolder)); if (wh) { static wchar_t guidstr[256]; nsGUID::toCharW(wh->getCurGuid(), guidstr); return MAKE_SCRIPT_STRING(guidstr); } return MAKE_SCRIPT_STRING(L""); } scriptVar WindowHolderScriptController::script_setRegionFromMap(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar map, scriptVar byte, scriptVar inv) { SCRIPT_FUNCTION_INIT XuiWindowHolder *xu = static_cast(o->vcpu_getInterface(pvt_xuiWindowHolder)); if (xu) xu->setRegionFromMap(GET_SCRIPT_OBJECT(map), GET_SCRIPT_INT(byte), GET_SCRIPT_INT(inv)); RETURN_SCRIPT_VOID; } scriptVar WindowHolderScriptController::script_setRegion(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar reg) { SCRIPT_FUNCTION_INIT XuiWindowHolder *xu= static_cast(o->vcpu_getInterface(pvt_xuiWindowHolder)); if (xu) xu->setRegion(GET_SCRIPT_OBJECT(reg)); RETURN_SCRIPT_VOID; } scriptVar WindowHolderScriptController::script_getContent(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) { SCRIPT_FUNCTION_INIT XuiWindowHolder *xu= static_cast(o->vcpu_getInterface(pvt_xuiWindowHolder)); if (xu) { ifc_window *w = xu->getRootWndPtr(); if (w) { GuiObject *o = w->getGuiObject(); if (o) return MAKE_SCRIPT_OBJECT(o->guiobject_getScriptObject()); } } RETURN_SCRIPT_NULL; }