示例#1
0
static void fb_dowindow(TAPTR task)
{
	struct TExecBase *TExecBase = TGetExecBase(task);
	WINWINDOW *win = TGetTaskData(task);
	WINDISPLAY *mod = win->fbv_Display;
	MSG msg;
	TUINT sig;

	TDBPRINTF(TDB_INFO,("DoWindow...\n"));

	do
	{
		WaitMessage();

		while (PeekMessage(&msg, win->fbv_HWnd, 0,0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

// 		PostMessage(win->fbv_HWnd, WM_USER, 0, 0);
		sig = TSetSignal(0, TTASK_SIG_ABORT);

	} while (!(sig & TTASK_SIG_ABORT));

	TDBPRINTF(TDB_INFO,("Window Done\n"));

	TLock(mod->fbd_Lock);
	TRemove(&win->fbv_Node);
	TUnlock(mod->fbd_Lock);

	fb_closeall(mod, win, TTRUE);
}
示例#2
0
LOCAL void
fb_closewindow(WINDISPLAY *mod, struct TVRequest *req)
{
	WINWINDOW *win = req->tvr_Op.CloseWindow.Window;
	if (win == TNULL)
		return;
	TRemove(&win->fbv_Node);
	fb_closeall(mod, win, TTRUE);
}
示例#3
0
LOCAL void
fb_openwindow(WINDISPLAY *mod, struct TVRequest *req)
{
	struct TExecBase *TExecBase = TGetExecBase(mod);
	TTAGITEM *tags = req->tvr_Op.OpenWindow.Tags;
	WINWINDOW *win;

	req->tvr_Op.OpenWindow.Window = TNULL;

	for (;;)
	{
		RECT wrect;
		BITMAPINFOHEADER *bmi;
		TUINT style;
		TUINT exstyle;
		TIMSG *imsg;
		const char *classname;
		TSTRPTR title;

		win = TAlloc0(mod->fbd_MemMgr, sizeof(WINWINDOW));
		if (win == TNULL)
			break;

		TInitList(&win->penlist);

		InitializeCriticalSection(&win->fbv_LockExtents);

		win->fbv_Width = (TUINT) TGetTag(tags, TVisual_Width, FB_DEF_WIDTH);
		win->fbv_Height = (TUINT) TGetTag(tags, TVisual_Height, FB_DEF_HEIGHT);
		win->fbv_Left = (TUINT) TGetTag(tags, TVisual_WinLeft, 0xffffffff);
		win->fbv_Top = (TUINT) TGetTag(tags, TVisual_WinTop, 0xffffffff);
		win->fbv_Title = (TSTRPTR) TGetTag(tags, TVisual_Title,
			(TTAG) "TEKlib Visual");
		win->fbv_Borderless = TGetTag(tags, TVisual_Borderless, TFALSE);
		win->fbv_UserData = TGetTag(tags, TVisual_UserData, TNULL);

		win->fbv_MinWidth = (TINT) TGetTag(tags, TVisual_MinWidth, (TTAG) -1);
		win->fbv_MinHeight = (TINT) TGetTag(tags, TVisual_MinHeight, (TTAG) -1);
		win->fbv_MaxWidth = (TINT) TGetTag(tags, TVisual_MaxWidth, (TTAG) -1);
		win->fbv_MaxHeight = (TINT) TGetTag(tags, TVisual_MaxHeight, (TTAG) -1);

		if (win->fbv_Borderless)
		{
			style = (WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS) & ~WS_BORDER;
			classname = FB_DISPLAY_CLASSNAME_POPUP;
			title = NULL;
			exstyle = WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
		}
		else
		{
			style = WS_OVERLAPPEDWINDOW;
			classname = FB_DISPLAY_CLASSNAME;
			title = win->fbv_Title;
			exstyle = 0;
		}

		wrect.left = wrect.right = wrect.top = wrect.bottom = 0;
		AdjustWindowRectEx(&wrect, style, FALSE, exstyle);
		win->fbv_BorderWidth = wrect.right - wrect.left;
		win->fbv_BorderHeight = wrect.bottom - wrect.top;
		win->fbv_BorderLeft = -wrect.left;
		win->fbv_BorderTop = -wrect.top;

		if (!win->fbv_Borderless)
		{
			TINT m1, m2, m3, m4;
			win_getminmax(win, &m1, &m2, &m3, &m4, TTRUE);
			win->fbv_Width = TCLAMP(m1, (TINT) win->fbv_Width, m3);
			win->fbv_Height = TCLAMP(m2, (TINT) win->fbv_Height, m4);
		}

		if (win->fbv_Left != 0xffffffff && win->fbv_Top != 0xffffffff)
		{
			wrect.left = win->fbv_Left;
			wrect.top = win->fbv_Top;
			wrect.right = win->fbv_Left + win->fbv_Width;
			wrect.bottom = win->fbv_Top + win->fbv_Height;
			if (!AdjustWindowRectEx(&wrect, style, FALSE, exstyle))
				break;

			win->fbv_Left = wrect.left;
			win->fbv_Top = wrect.top;
			win->fbv_HWnd = CreateWindowEx(exstyle, classname,
				title, style, win->fbv_Left, win->fbv_Top,
				wrect.right - wrect.left - win->fbv_BorderWidth, 
				wrect.bottom - wrect.top - win->fbv_BorderHeight,
				(HWND) NULL, (HMENU) NULL, mod->fbd_HInst, (LPVOID) NULL);
		}
		else
		{
			win->fbv_HWnd = CreateWindowEx(exstyle, classname,
				title, style, CW_USEDEFAULT, CW_USEDEFAULT,
				win->fbv_Width, win->fbv_Height,
				(HWND) NULL, (HMENU) NULL, mod->fbd_HInst, (LPVOID) NULL);
		}

		if (win->fbv_HWnd == TNULL)
			break;

		GetWindowRect(win->fbv_HWnd, &wrect);
		win->fbv_Left = wrect.left + win->fbv_BorderLeft;
		win->fbv_Top = wrect.top + win->fbv_BorderHeight;
		win->fbv_Width = wrect.right - wrect.left - win->fbv_BorderWidth;
		win->fbv_Height = wrect.bottom - wrect.top - win->fbv_BorderHeight;

		SetWindowLongPtr(win->fbv_HWnd, GWLP_USERDATA, (LONG_PTR) win);

		win->fbv_HDC = GetDC(win->fbv_HWnd);
		win->fbv_Display = mod;
		win->fbv_InputMask = (TUINT) TGetTag(tags, TVisual_EventMask, 0);
		win->fbv_IMsgPort = req->tvr_Op.OpenWindow.IMsgPort;

		bmi = &win->fbv_DrawBitMap;
		bmi->biSize = sizeof(BITMAPINFOHEADER);
		bmi->biPlanes = 1;
		bmi->biBitCount = 32;
		bmi->biCompression = BI_RGB;
		bmi->biSizeImage = 0;
		bmi->biXPelsPerMeter = 1;
		bmi->biYPelsPerMeter = 1;
		bmi->biClrUsed = 0;
		bmi->biClrImportant = 0;

		TInitList(&win->fbv_IMsgQueue);

		req->tvr_Op.OpenWindow.Window = win;

		/* init default font */
		win->fbv_CurrentFont = mod->fbd_FontManager.deffont;
		mod->fbd_FontManager.defref++;

		if (win->fbv_InputMask & TITYPE_INTERVAL)
			++mod->fbd_NumInterval;

		/* register default font */
		/*TDBPRINTF(TDB_TRACE,("Add window: %p\n", win->window));*/

		/* add window on top of window stack: */
		TAddHead(&mod->fbd_VisualList, &win->fbv_Node);

		SetBkMode(win->fbv_HDC, TRANSPARENT);
		
		ShowWindow(win->fbv_HWnd, SW_SHOWNORMAL);
		UpdateWindow(win->fbv_HWnd);

		if ((win->fbv_InputMask & TITYPE_FOCUS) &&
			(fb_getimsg(mod, win, &imsg, TITYPE_FOCUS)))
		{
			imsg->timsg_Code = 1;
			TAddTail(&win->fbv_IMsgQueue, &imsg->timsg_Node);
		}
		if ((win->fbv_InputMask & TITYPE_REFRESH) &&
			(fb_getimsg(mod, win, &imsg, TITYPE_REFRESH)))
		{
			imsg->timsg_X = 0;
			imsg->timsg_Y = 0;
			imsg->timsg_Width = win->fbv_Width;
			imsg->timsg_Height = win->fbv_Height;
			TAddTail(&win->fbv_IMsgQueue, &imsg->timsg_Node);
		}
		
		return;
	}

	TDBPRINTF(TDB_ERROR,("Window open failed\n"));
	fb_closeall(mod, win, TFALSE);
}