Exemplo n.º 1
0
	NewsWindow(WindowDesc *desc, const NewsItem *ni) : Window(desc), ni(ni)
	{
		NewsWindow::duration = 555;
		const Window *w = FindWindowByClass(WC_SEND_NETWORK_MSG);
		this->chat_height = (w != NULL) ? w->height : 0;
		this->status_height = FindWindowById(WC_STATUS_BAR, 0)->height;

		this->flags |= WF_DISABLE_VP_SCROLL;

		this->CreateNestedTree();

		/* For company news with a face we have a separate headline in param[0] */
		if (desc == &_company_news_desc) this->GetWidget<NWidgetCore>(WID_N_TITLE)->widget_data = this->ni->params[0];

		this->FinishInitNested(0);

		/* Initialize viewport if it exists. */
		NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_N_VIEWPORT);
		if (nvp != NULL) {
			nvp->InitializeViewport(this, ni->reftype1 == NR_VEHICLE ? 0x80000000 | ni->ref1 : GetReferenceTile(ni->reftype1, ni->ref1), ZOOM_LVL_NEWS);
			if (this->ni->flags & NF_NO_TRANSPARENT) nvp->disp_flags |= ND_NO_TRANSPARENCY;
			if ((this->ni->flags & NF_INCOLOUR) == 0) {
				nvp->disp_flags |= ND_SHADE_GREY;
			} else if (this->ni->flags & NF_SHADE) {
				nvp->disp_flags |= ND_SHADE_DIMMED;
			}
		}

		PositionNewsMessage(this);
	}
Exemplo n.º 2
0
void FixTitleGameZoom()
{
	if (_game_mode != GM_MENU) return;

	ViewPort *vp = FindWindowByClass(WC_MAIN_WINDOW)->viewport;
	vp->zoom = _gui_zoom;
	vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
	vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
}
Exemplo n.º 3
0
/* static */ bool ScriptWindow::IsOpen(WindowClass window, uint32 number)
{
	if (ScriptGame::IsMultiplayer()) return false;

	if (number == NUMBER_ALL) {
		return (FindWindowByClass((::WindowClass)window) != NULL);
	}

	return FindWindowById((::WindowClass)window, number) != NULL;
}
Exemplo n.º 4
0
	NewsWindow(const WindowDesc *desc, const NewsItem *ni) : Window(), ni(ni)
	{
		NewsWindow::duration = 555;
		const Window *w = FindWindowByClass(WC_SEND_NETWORK_MSG);
		this->chat_height = (w != NULL) ? w->height : 0;
		this->status_height = FindWindowById(WC_STATUS_BAR, 0)->height;

		this->flags4 |= WF_DISABLE_VP_SCROLL;

		this->CreateNestedTree(desc);
		switch (this->ni->subtype) {
			case NS_COMPANY_TROUBLE:
				this->GetWidget<NWidgetCore>(NTW_TITLE)->widget_data = STR_NEWS_COMPANY_IN_TROUBLE_TITLE;
				break;

			case NS_COMPANY_MERGER:
				this->GetWidget<NWidgetCore>(NTW_TITLE)->widget_data = STR_NEWS_COMPANY_MERGER_TITLE;
				break;

			case NS_COMPANY_BANKRUPT:
				this->GetWidget<NWidgetCore>(NTW_TITLE)->widget_data = STR_NEWS_COMPANY_BANKRUPT_TITLE;
				break;

			case NS_COMPANY_NEW:
				this->GetWidget<NWidgetCore>(NTW_TITLE)->widget_data = STR_NEWS_COMPANY_LAUNCH_TITLE;
				break;

			default:
				break;
		}
		this->FinishInitNested(desc, 0);

		/* Initialize viewport if it exists. */
		NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(NTW_VIEWPORT);
		if (nvp != NULL) {
			nvp->InitializeViewport(this, ni->reftype1 == NR_VEHICLE ? 0x80000000 | ni->ref1 : GetReferenceTile(ni->reftype1, ni->ref1), ZOOM_LVL_NEWS);
			if (this->ni->flags & NF_NO_TRANSPARENT) nvp->disp_flags |= ND_NO_TRANSPARENCY;
			if ((this->ni->flags & NF_INCOLOUR) == 0) {
				nvp->disp_flags |= ND_SHADE_GREY;
			} else if (this->ni->flags & NF_SHADE) {
				nvp->disp_flags |= ND_SHADE_DIMMED;
			}
		}
	}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
	XDisplay=XOpenDisplay(NULL);



	const char* windowClassName = "SkypeTab";
	const char* wClPrefix = "--skypetab-class=";
	size_t wClPrefixLen = strlen(wClPrefix);
	for(int c=1; c<argc; c++)
	{
		if(strncmp(argv[c], wClPrefix, wClPrefixLen) == 0)
		{
			windowClassName=argv[c] + wClPrefixLen;
		}
	}

	Window instance = FindWindowByClass (windowClassName);
	if(instance!=0)
	{
		SendXMessage(instance, "ACT");
		printf("Activated previous instance\n");
		return 0;
	}

	char*newArgv[1024];
	memset(newArgv, 0, sizeof(newArgv));
	newArgv[0]="skype";
	for(int c=1; c<argc; c++)
		newArgv[c]=argv[c];

	execvp("skype", newArgv);
	int err=errno;

	char errS[1024];
	errS[0]=0;
	strerror_r(err, errS, 1024);
	printf("execvp(\"skype\", ...) failed: %i %s\n", err, errS);

}
Exemplo n.º 6
0
Window FindWindowByClass(Window parent, const char* className)
{
	Window root, *children;
	unsigned int nchildren;
	Atom WM_CLASS = XInternAtom(XDisplay, "WM_CLASS",0);
	XQueryTree(XDisplay, parent, &root, &parent,&children, &nchildren);
	Window ret=0;
	for(unsigned int c=0; c<nchildren; c++)
	{
		Window win=children[c];

		unsigned long bytes_after, len;
		unsigned char *value;
		int format;
		Atom actual_type;
		if(XGetWindowProperty(XDisplay,win,WM_CLASS,0,1024,False,XA_STRING, &actual_type, &format,
						   &len,&bytes_after,&value)==Success)
		{
			if(value!=0)
			{
				value[len-1]=0;


				if(strcmp((char*)value, className) == 0)
				{
					XFree(value);
					ret=win;
					break;
				}
				XFree(value);
			}
			ret=FindWindowByClass(win, className);
			if(ret!=0)
				break;
		}
	}
	XFree(children);
	return ret;
}
Exemplo n.º 7
0
Window FindWindowByClass(const char* className)
{
	return FindWindowByClass(XRootWindow(XDisplay, 0), className);
}