예제 #1
0
Win32UserWindow::Win32UserWindow(SharedUIBinding binding, WindowConfig* config, SharedUserWindow& parent) :
	UserWindow(binding, config, parent),
	script_evaluator(binding->GetHost()),
	menuBarHandle(NULL),
	menuInUse(NULL),
	menu(NULL),
	contextMenuHandle(NULL),
	initial_icon(NULL),
	web_inspector(NULL)
{
	static bool initialized = false;
	win32_host = static_cast<kroll::Win32Host*>(binding->GetHost());
	if (!initialized) {
		INITCOMMONCONTROLSEX InitCtrlEx;

		InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
		InitCtrlEx.dwICC = 0x00004000; //ICC_STANDARD_CLASSES;
		InitCommonControlsEx(&InitCtrlEx);

		curl_register_local_handler(&Titanium_app_url_handler);
		curl_register_local_handler(&Titanium_ti_url_handler);
		addScriptEvaluator(&script_evaluator);
	}

	Win32UserWindow::RegisterWindowClass(win32_host->GetInstanceHandle());
	window_handle
			= CreateWindowEx(WS_EX_LAYERED, windowClassName,
					config->GetTitle().c_str(), WS_CLIPCHILDREN, CW_USEDEFAULT,
					0, CW_USEDEFAULT, 0, NULL, NULL,
					win32_host->GetInstanceHandle(), NULL);

	if (window_handle == NULL) {
		std::cout << "Error Creating Window: " << GetLastError() << std::endl;
	}
	std::cout << "window_handle = " << (int) window_handle << std::endl;

	// make our HWND available to 3rd party devs without needing our headers
	SharedValue windowHandle = Value::NewVoidPtr((void*) window_handle);
	this->Set("windowHandle", windowHandle);
	this->SetMethod("addMessageHandler", &Win32UserWindow::AddMessageHandler);

	SetWindowUserData(window_handle, this);

	this->ReloadTiWindowConfig();
	this->SetupDecorations(false);

	Bounds b;
	b.x = config->GetX();
	b.y = config->GetY();
	b.width = config->GetWidth();
	b.height = config->GetHeight();
	SetBounds(b);

	//web_view = WebView::createInstance();
	HRESULT hr = CoCreateInstance(CLSID_WebView, 0, CLSCTX_ALL, IID_IWebView,
			(void**) &web_view);
	if (FAILED(hr)) {
		std::cerr << "Error Creating WebView: ";
		if (hr == REGDB_E_CLASSNOTREG)
			std::cerr << "REGDB_E_CLASSNOTREG" << std::endl;
		else if (hr == CLASS_E_NOAGGREGATION)
			std::cerr << "CLASS_E_NOAGGREGATION" << std::endl;
		else if (hr == E_NOINTERFACE)
			std::cerr << "E_NOINTERFACE" << std::endl;
		else if (hr == E_UNEXPECTED)
			std::cerr << "E_UNEXPECTED" << std::endl;
		else if (hr == E_OUTOFMEMORY)
			std::cerr << "E_OUTOFMEMORY" << std::endl;
		else if (hr == E_INVALIDARG)
			std::cerr << "E_INVALIDARG" << std::endl;
		else
			fprintf(stderr, "Unknown Error? %x\n", hr);
	}

	// set the custom user agent for Titanium
	double version = host->GetGlobalObject()->Get("version")->ToDouble();
	char userAgent[128];
	sprintf(userAgent, "%s/%0.2f", PRODUCT_NAME, version);
	_bstr_t ua(userAgent);
	web_view->setApplicationNameForUserAgent(ua.copy());

	// place our user agent string in the global so we can later use it
	SharedBoundObject global = host->GetGlobalObject();
	_bstr_t uaurl("http://titaniumapp.com");
	BSTR uaresp;
	web_view->userAgentForURL(uaurl.copy(), &uaresp);
	std::string ua_str = _bstr_t(uaresp);
	global->Set("userAgent", Value::NewString(ua_str.c_str()));

	std::cout << "create frame load delegate " << std::endl;
	frameLoadDelegate = new Win32WebKitFrameLoadDelegate(this);
	uiDelegate = new Win32WebKitUIDelegate(this);
	policyDelegate = new Win32WebKitPolicyDelegate(this);

	std::cout << "set delegates, set host window, webview=" << (int) web_view
			<< std::endl;
	hr = web_view->setFrameLoadDelegate(frameLoadDelegate);
	hr = web_view->setUIDelegate(uiDelegate);
	hr = web_view->setPolicyDelegate(policyDelegate);
	hr = web_view->setHostWindow((OLE_HANDLE) window_handle);

	std::cout << "init with frame" << std::endl;
	RECT client_rect;
	GetClientRect(window_handle, &client_rect);
	hr = web_view->initWithFrame(client_rect, 0, 0);

	AppConfig *appConfig = AppConfig::Instance();
	std::string appid = appConfig->GetAppID();

	IWebPreferences *prefs = NULL;
	hr = CoCreateInstance(CLSID_WebPreferences, 0, CLSCTX_ALL,
			IID_IWebPreferences, (void**) &prefs);
	if (FAILED(hr) || prefs == NULL) {
		std::cerr << "Couldn't create the preferences object" << std::endl;
	} else {
		_bstr_t pi(appid.c_str());
		prefs->initWithIdentifier(pi.copy(), &prefs);

		prefs->setCacheModel(WebCacheModelDocumentBrowser);
		prefs->setPlugInsEnabled(true);
		prefs->setJavaEnabled(true);
		prefs->setJavaScriptEnabled(true);
		prefs->setDOMPasteAllowed(true);

		IWebPreferencesPrivate* privatePrefs = NULL;
		hr = prefs->QueryInterface(IID_IWebPreferencesPrivate,
				(void**) &privatePrefs);
		if (FAILED(hr)) {
			std::cerr << "Failed to get private preferences" << std::endl;
		} else {
			privatePrefs->setDeveloperExtrasEnabled(host->IsDebugMode());
			//privatePrefs->setDeveloperExtrasEnabled(host->IsDebugMode());
			privatePrefs->setDatabasesEnabled(true);
			privatePrefs->setLocalStorageEnabled(true);
			privatePrefs->setOfflineWebApplicationCacheEnabled(true);

			_bstr_t db_path(
					FileUtils::GetApplicationDataDirectory(appid).c_str());
			privatePrefs->setLocalStorageDatabasePath(db_path.copy());
			privatePrefs->Release();
		}

		web_view->setPreferences(prefs);
		prefs->Release();
	}

	// allow app:// and ti:// to run with local permissions (cross-domain ajax,etc)
	_bstr_t app_proto("app");
	web_view->registerURLSchemeAsLocal(app_proto.copy());

	_bstr_t ti_proto("ti");
	web_view->registerURLSchemeAsLocal(ti_proto.copy());

	IWebViewPrivate *web_view_private;
	hr = web_view->QueryInterface(IID_IWebViewPrivate,
			(void**) &web_view_private);
	hr = web_view_private->viewWindow((OLE_HANDLE*) &view_window_handle);

	hr = web_view_private->inspector(&web_inspector);
	if (FAILED(hr) || web_inspector == NULL) {
		std::cerr << "Couldn't retrieve the web inspector object" << std::endl;
	}

	web_view_private->Release();

	_bstr_t inspector_url("ti://com.titaniumapp/runtime/inspector/inspector.html");
	_bstr_t localized_strings_url("ti://com.titaniumapp/runtime/inspector/localizedStrings.js");
	web_inspector->setInspectorURL(inspector_url.copy());
	web_inspector->setLocalizedStringsURL(localized_strings_url.copy());

	hr = web_view->mainFrame(&web_frame);
	//web_view->setShouldCloseWithWindow(TRUE);

	std::cout << "resize subviews" << std::endl;
	ResizeSubViews();

	// ensure we have valid restore values
	restore_bounds = GetBounds();
	restore_styles = GetWindowLong(window_handle, GWL_STYLE);

	if (this->config->IsFullScreen()) {
		this->SetFullScreen(true);
	}

	if (this->config->IsTopMost() && this->config->IsVisible()) {
		this->SetTopMost(true);
	}

	// set this flag to indicate that when the frame is loaded
	// we want to show the window - we do this to prevent white screen
	// while the URL is being fetched
	this->requires_display = true;

	// set initial window icon to icon associated with exe file
	char exePath[MAX_PATH];
	GetModuleFileNameA(GetModuleHandle(NULL), exePath, MAX_PATH);
	initial_icon = ExtractIcon(win32_host->GetInstanceHandle(), exePath, 0);
	if (initial_icon) {
		SendMessageA(window_handle, (UINT) WM_SETICON, ICON_BIG,
				(LPARAM) initial_icon);
	}
}
예제 #2
0
UserWindow::UserWindow(SharedUIBinding binding, WindowConfig *config, SharedUserWindow& parent) :
	kroll::StaticBoundObject(),
	binding(binding),
	host(binding->GetHost()),
	config(config),
	parent(parent),
	next_listener_id(0),
	active(false),
	initialized(false)
{
	this->shared_this = this;

	/**
	 * @tiapi(method=True,name=UI.getCurrentWindow,since=0.4) get the current 
	 */
	// This method is on Titanium.UI, but will be delegated to this class.
	this->SetMethod("getCurrentWindow", &UserWindow::_GetCurrentWindow);

	/**
	 * @tiapi(property=True,type=integer,name=UI.UserWindow.CENTERED,since=0.3) CENTERED constant
	 */
	this->Set("CENTERED", Value::NewInt(UserWindow::CENTERED));

	/**
	 * @tiapi(method=True,name=UI.UserWindow.hide,since=0.2) hides the window
	 */
	this->SetMethod("hide", &UserWindow::_Hide);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.show,since=0.2) shows the window
	 */
	this->SetMethod("show", &UserWindow::_Show);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.minimize,since=0.2) minimize the window
	 */
	this->SetMethod("minimize", &UserWindow::_Minimize);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.unminimize,since=0.2) unminimize the window
	 */
	this->SetMethod("unminimize", &UserWindow::_Unminimize);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.maximize,since=0.2) maximize the window
	 */
	this->SetMethod("maximize", &UserWindow::_Maximize);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.unmaximize,since=0.2) unmaximize the window
	 */
	this->SetMethod("unmaximize", &UserWindow::_Unmaximize);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.focus,since=0.2) focus the window
	 */
	this->SetMethod("focus", &UserWindow::_Focus);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.unfocus,since=0.2) unfocus the window
	 */
	this->SetMethod("unfocus", &UserWindow::_Unfocus);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.isUsingChrome,since=0.2) returns true if the window has system chrome
	 * @tiresult(for=UI.UserWindow.isUsingChrome,type=boolean) true if using system chrome
	 */
	this->SetMethod("isUsingChrome", &UserWindow::_IsUsingChrome);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setUsingChrome,since=0.2) sets true if the window should use system chrome
	 * @tiarg(for=UI.UserWindow.setUsingChrome,name=chrome,type=boolean) true to use system chrome
	 */
	this->SetMethod("setUsingChrome", &UserWindow::_SetUsingChrome);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.isFullscreen,since=0.2) returns true if the window is full screen
	 * @tiarg(for=UI.UserWindow.isFullscreen,name=chrome,type=boolean) true if system chrome
	 */
	this->SetMethod("isFullScreen", &UserWindow::_IsFullScreen);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setFullScreen,since=0.2) make the window fullscreen
	 * @tiarg(for=UI.UserWindow.setFullScreen,name=fullscreen,type=boolean) true for fullscreen
	 */
	this->SetMethod("setFullScreen", &UserWindow::_SetFullScreen);

	/**
	 * @tiapi(method=True,returns=integer,name=UI.UserWindow.getID,since=0.2) return the window id
	 * @tiresult(for=UI.UserWindow.getID,type=string) return id
	 */
	this->SetMethod("getID", &UserWindow::_GetId);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.open,since=0.2) open the window
	 */
	this->SetMethod("open", &UserWindow::_Open);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.close,since=0.2) close the window
	 */
	this->SetMethod("close", &UserWindow::_Close);

	/**
	 * @tiapi(method=True,returns=double,name=UI.UserWindow.getX,since=0.2) return the windows X position
	 * @tiresult(for=UI.UserWindow.getX,type=double) return the x value
	 */
	this->SetMethod("getX", &UserWindow::_GetX);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setX,since=0.2) sets the windows X position
	 * @tiarg(for=UI.UserWindow.setX,type=double,name=x) x position
	 */
	this->SetMethod("setX", &UserWindow::_SetX);

	/**
	 * @tiapi(method=True,returns=double,name=UI.UserWindow.getY,since=0.2) returns the windows Y position
	 * @tiresult(for=UI.UserWindow.getY,type=double) return the y value
	 */
	this->SetMethod("getY", &UserWindow::_GetY);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setY,since=0.2) sets the windows Y position
	 * @tiarg(for=UI.UserWindow.setY,type=double,name=y) y position
	 */
	this->SetMethod("setY", &UserWindow::_SetY);

	/**
	 * @tiapi(method=True,returns=double,name=UI.UserWindow.getWidth,since=0.2) returns the windows width
	 * @tiresult(for=UI.UserWindow.getWidth,type=double) return the width value
	 */
	this->SetMethod("getWidth", &UserWindow::_GetWidth);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setWidth,since=0.2) sets the windows width
	 * @tiarg(for=UI.UserWindow.setWidth,type=double,name=width) width
	 */
	this->SetMethod("setWidth", &UserWindow::_SetWidth);

	/**
	 * @tiapi(method=True,returns=double,name=UI.UserWindow.getMaxWidth,since=0.2) gets the windows max width
	 * @tiresult(for=UI.UserWindow.getMaxWidth,type=double) return the max width value
	 */
	this->SetMethod("getMaxWidth", &UserWindow::_GetMaxWidth);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setMaxWidth,since=0.2) sets the windows max width
	 * @tiarg(for=UI.UserWindow.setMaxWidth,type=double,name=width) max width
	 */
	this->SetMethod("setMaxWidth", &UserWindow::_SetMaxWidth);

	/**
	 * @tiapi(method=True,returns=double,name=UI.UserWindow.getMinWidth,since=0.2) gets the windows min width
	 * @tiresult(for=UI.UserWindow.getMinWidth,type=double) return the min width value
	 */
	this->SetMethod("getMinWidth", &UserWindow::_GetMinWidth);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setMinWidth,since=0.2) sets the windows min width
	 * @tiarg(for=UI.UserWindow.setMinWidth,type=double,name=width) min width
	 */
	this->SetMethod("setMinWidth", &UserWindow::_SetMinWidth);

	/**
	 * @tiapi(method=True,returns=double,name=UI.UserWindow.getHeight,since=0.2) get the windows height
	 * @tiresult(for=UI.UserWindow.getHeight,type=double) return the height value
	 */
	this->SetMethod("getHeight", &UserWindow::_GetHeight);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setHeight,since=0.2) set the windows height
	 * @tiarg(for=UI.UserWindow.setHeight,type=double,name=height) height
	 */
	this->SetMethod("setHeight", &UserWindow::_SetHeight);

	/**
	 * @tiapi(method=True,returns=double,name=UI.UserWindow.getMaxHeight,since=0.2) get the windows max height
	 * @tiresult(for=UI.UserWindow.getMaxHeight,type=double) return the max height value
	 */
	this->SetMethod("getMaxHeight", &UserWindow::_GetMaxHeight);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setMaxHeight,since=0.2) set the windows max height
	 * @tiarg(for=UI.UserWindow.setMaxHeight,type=double,name=height) max height
	 */
	this->SetMethod("setMaxHeight", &UserWindow::_SetMaxHeight);

	/**
	 * @tiapi(method=True,returns=double,name=UI.UserWindow.getMinHeight,since=0.2) get the windows min height
	 * @tiresult(for=UI.UserWindow.getMinHeight,type=double) return the min height value
	 */
	this->SetMethod("getMinHeight", &UserWindow::_GetMinHeight);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setMinHeight,since=0.2) sets the windows min height
	 * @tiarg(for=UI.UserWindow.setMinHeight,type=double,name=height) min height
	 */
	this->SetMethod("setMinHeight", &UserWindow::_SetMinHeight);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.getBounds,since=0.2) get the window bounds
	 * @tiresult(for=UI.UserWindow.getBounds,type=object) returns bound object
	 */
	this->SetMethod("getBounds", &UserWindow::_GetBounds);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setBounds,since=0.2) set the window bounds
	 * @tiarg(for=UI.UserWindow.setBounds,type=object,name=bounds) bounds object
	 */
	this->SetMethod("setBounds", &UserWindow::_SetBounds);

	/**
	 * @tiapi(method=True,returns=string,name=UI.UserWindow.getTitle,since=0.2) get the title of the window
	 * @tiresult(for=UI.UserWindow.isUsingChrome,type=boolean) true if using system chrome
	 */
	this->SetMethod("getTitle", &UserWindow::_GetTitle);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setTitle,since=0.2) set the title of the window
	 * @tiarg(for=UI.UserWindow.setTitle,type=object,name=title) title
	 */
	this->SetMethod("setTitle", &UserWindow::_SetTitle);

	/**
	 * @tiapi(method=True,returns=string,name=UI.UserWindow.getURL,since=0.2) get the url for the window
	 * @tiresult(for=UI.UserWindow.isUsingChrome,type=boolean) true if using system chrome
	 */
	this->SetMethod("getURL", &UserWindow::_GetURL);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setURL,since=0.2) set the url for the window
	 * @tiarg(for=UI.UserWindow.setURL,type=string,name=url) url
	 */
	this->SetMethod("setURL", &UserWindow::_SetURL);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.isResizable,since=0.2) returns true if the window is resizable
	 * @tiresult(for=UI.UserWindow.isResizable,type=boolean) true if using resizable
	 */
	this->SetMethod("isResizable", &UserWindow::_IsResizable);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setResizable,since=0.2) sets the resizability of the window
	 * @tiarg(for=UI.UserWindow.setResizable,type=boolean,name=resizable) resizable
	 */
	this->SetMethod("setResizable", &UserWindow::_SetResizable);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.isMaximizable,since=0.2) returns true if the window is maximizable
	 * @tiresult(for=UI.UserWindow.isUsingChrome,type=boolean) true if using system chrome
	 */
	this->SetMethod("isMaximizable", &UserWindow::_IsMaximizable);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setMaximizable,since=0.2) sets the maximizability of the window
	 * @tiarg(for=UI.UserWindow.setMaximizable,type=boolean,name=maximizable) maximizable
	 */
	this->SetMethod("setMaximizable", &UserWindow::_SetMaximizable);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.isMinimizable,since=0.2) returns true if the window is minimizable
	 * @tiresult(for=UI.UserWindow.isMinimizable,type=boolean) true if minimizable
	 */
	this->SetMethod("isMinimizable", &UserWindow::_IsMinimizable);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setMinimizable,since=0.2) sets the minimizability of the window
	 * @tiarg(for=UI.UserWindow.setMinimizable,type=boolean,name=minimizable) minimizable
	 */
	this->SetMethod("setMinimizable", &UserWindow::_SetMinimizable);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.isCloseable,since=0.2) returns true if the window is closeable
	 * @tiresult(for=UI.UserWindow.isCloseable,type=boolean) true if closeable
	 */
	this->SetMethod("isCloseable", &UserWindow::_IsCloseable);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setCloseable,since=0.2) sets the closeability of the window
	 * @tiarg(for=UI.UserWindow.setCloseable,type=boolean,name=closeable) closeable
	 */
	this->SetMethod("setCloseable", &UserWindow::_SetCloseable);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.isVisible,since=0.2) returns true if the window is visible
	 * @tiresult(for=UI.UserWindow.isVisible,type=boolean) true if visible
	 */
	this->SetMethod("isVisible", &UserWindow::_IsVisible);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setVisible,since=0.2) sets the visibility of the window
	 * @tiarg(for=UI.UserWindow.setVisible,type=boolean,name=visible) visible
	 */
	this->SetMethod("setVisible", &UserWindow::_SetVisible);

	/**
	 * @tiapi(method=True,returns=double,name=UI.UserWindow.getTransparency,since=0.2) returns the window transparency
	 * @tiresult(for=UI.UserWindow.getTransparency,type=double) return transparency value
	 */
	this->SetMethod("getTransparency", &UserWindow::_GetTransparency);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setTransparency,since=0.2) gets the windows transparency
	 * @tiarg(for=UI.UserWindow.setTransparency,type=double,name=url) transparency value
	 */

	this->SetMethod("setTransparency", &UserWindow::_SetTransparency);

	/**
	 * @tiapi(method=True,returns=string,name=UI.UserWindow.getTransparencyColor,since=0.2) returns the transparency color for the window
	 * @tiresult(for=UI.UserWindow.getTransparencyColor,type=string) color
	 */
	this->SetMethod("getTransparencyColor", &UserWindow::_GetTransparencyColor);


	/**
	 * @tiapi(method=True,name=UI.UserWindow.setMenu,since=0.2) set the window menu
	 * @tiarg(for=UI.UserWindow.setMenu,type=object,name=menu) menu
	 */
	this->SetMethod("setMenu", &UserWindow::_SetMenu);


	/**
	 * @tiapi(method=True,name=UI.UserWindow.getMenu,since=0.2) gets the window menu
	 * @tiresult(for=UI.UserWindow.getMenu,type=object) return the menu
	 */
	this->SetMethod("getMenu", &UserWindow::_GetMenu);


	/**
	 * @tiapi(method=True,name=UI.UserWindow.setContextMenu,since=0.2) set the window context menu
	 * @tiarg(for=UI.UserWindow.setContextMenu,type=object,name=menu) menu
	 */
	this->SetMethod("setContextMenu", &UserWindow::_SetContextMenu);


	/**
	 * @tiapi(method=True,name=UI.UserWindow.getContextMenu,since=0.2) get the window context menu
	 * @tiresult(for=UI.UserWindow.getContextMenu,type=object) returns context menu
	 */
	this->SetMethod("getContextMenu", &UserWindow::_GetContextMenu);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setIcon,since=0.2) set the window icon
	 * @tiarg(for=UI.UserWindow.setIcon,type=string,name=icon) icon
	 */
	this->SetMethod("setIcon", &UserWindow::_SetIcon);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.getIcon,since=0.2) get the window icon
	 * @tiresult(for=UI.UserWindow.getIcon,type=string) icon
	 */
	this->SetMethod("getIcon", &UserWindow::_GetIcon);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.setTopMost,since=0.3) sets whether the window is top most (above other windows)
	 * @tiarg(for=UI.UserWindow.setTopMost,type=boolean,name=topmost) true if top most
	 */
	this->SetMethod("setTopMost", &UserWindow::_SetTopMost);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.isTopMost,since=0.3) returns true if the window is top most
	 * @tiresult(for=UI.UserWindow.isTopMost,type=boolean) true if top most
	 */
	this->SetMethod("isTopMost", &UserWindow::_IsTopMost);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.createWindow,since=0.2) create a new window as a child of this window
	 * @tiarg(for=UI.UserWindow.createWindow,name=options,type=object,optional=True) pass in either an object of properties or a url to the window content
	 * @tiresult(for=UI.UserWindow.createWindow,type=object) return window
	 */
	this->SetMethod("createWindow", &UserWindow::_CreateWindow);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.openFileChooserDialog,since=0.4) show the file chooser dialog
	 * @tiarg(for=UI.UserWindow.openFileChooserDialog,type=method,name=callback) callback method
	 * @tiarg(for=UI.UserWindow.openFileChooserDialog,type=object,name=options,optional=True) options
	 */
	this->SetMethod("openFileChooserDialog", &UserWindow::_OpenFileChooserDialog);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.openFolderChooserDialog,since=0.4) show the folder chooser dialog
	 * @tiarg(for=UI.UserWindow.openFolderChooserDialog,type=method,name=callback) callback method
	 * @tiarg(for=UI.UserWindow.openFolderChooserDialog,type=object,name=options,optional=True) an options object
	 */
	this->SetMethod("openFolderChooserDialog", &UserWindow::_OpenFolderChooserDialog);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.openSaveAsDialog,since=0.4) show the save as file dialog
	 * @tiarg(for=UI.UserWindow.openSaveAsDialog,type=method,name=callback) callback method
	 * @tiarg(for=UI.UserWindow.openSaveAsDialog,type=object,name=options,optional=True) an options object
	 */
	this->SetMethod("openSaveAsDialog", &UserWindow::_OpenSaveAsDialog);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.getParent,since=0.3) get the window parent
	 * @tiresult(for=UI.UserWindow.getParent,type=object) return the parent window or NULL if no parent
	 */
	this->SetMethod("getParent", &UserWindow::_GetParent);

	/**
	 * @tiapi(method=True,returns=integer,name=UI.UserWindow.addEventListener,since=0.3) add an event listener to the window and returns integer to use when removing
	 * @tiarg(for=UI.UserWindow.addEventListener,type=method,name=listener) listener method
	 * @tiresult(for=UI.UserWindow.addEventListener,type=integer) return the listener id
	 */
	this->SetMethod("addEventListener", &UserWindow::_AddEventListener);

	/**
	 * @tiapi(method=True,name=UI.UserWindow.removeEventListener,since=0.3) removes an event listener from the window
	 * @tiarg(for=UI.UserWindow.removeEventListener,type=integer,name=id) the id returned from addEventListener
	 * @tiresult(for=UI.UserWindow.removeEventListener,type=boolean) return true if removed
	 */
	this->SetMethod("removeEventListener", &UserWindow::_RemoveEventListener);

	this->api = host->GetGlobalObject()->GetNS("API.fire")->ToMethod();
	this->FireEvent(CREATE);
}