Exemplo n.º 1
0
void
CX11Window::SetDisplay( ::Display* display )
{GUCEF_TRACE;

    // Cleanup whatever we have already
    WindowDestroy();
    m_display = display;
}
long FAR PASCAL _export _EasyWinProc(HWND Window, UINT Message,
                                   WPARAM WParam, LONG LParam)
{
    CrtWindow = Window;
    switch (Message)
        {
        case WM_CREATE:
            WindowCreate();
            break;
        case WM_PAINT:
            WindowPaint();
            break;
        case WM_VSCROLL:
            WindowScroll(SB_VERT, WParam, LoVal(LParam));
            break;
        case WM_HSCROLL:
            WindowScroll(SB_HORZ, WParam, LoVal(LParam));
            break;
        case WM_SIZE:
            WindowResize(LoVal(LParam), HiVal(LParam));
            break;
        case WM_GETMINMAXINFO:
            WindowMinMaxInfo((TMinMaxInfo far *) LParam);
            break;
        case WM_CHAR:
            WindowChar((char)WParam);
            break;
        case WM_KEYDOWN:
            WindowKeyDown((BYTE)WParam);
            break;
        case WM_SETFOCUS:
            WindowSetFocus();
            break;

        case WM_KILLFOCUS:
            WindowKillFocus();
            break;
        case WM_DESTROY:
            WindowDestroy();
            break;
        default:
            return DefWindowProc(Window, Message, WParam, LParam);
        }
    return NULL;
}
Exemplo n.º 3
0
bool
CX11Window::WindowCreate( const Int32 xPosition ,
                          const Int32 yPosition ,
                          const UInt32 width    ,
                          const UInt32 height   ,
                          ::Window parentWindow )
{GUCEF_TRACE;

    // If we already have a window destroy it
    WindowDestroy();

    if ( NULL == m_display )
    {
        m_display = CX11EventDispatcher::Instance()->GetDisplay();
    }
    if ( NULL == m_display )
    {
        GUCEF_ERROR_LOG( LOGLEVEL_IMPORTANT, "CX11Window::WindowCreate(): Failed to open display" );
        return false;
    }
    m_screenNr = DefaultScreen( m_display );

    if ( 0 == parentWindow )
    {
        // no parent window was provided so we will make this window a child of the default display's root
        parentWindow = RootWindow( m_display, m_screenNr );
    }

    m_window = ::XCreateSimpleWindow( m_display,
                                      parentWindow,
                                      xPosition, yPosition, width, height, 1,
                                      BlackPixel( m_display, m_screenNr ),
                                      WhitePixel( m_display, m_screenNr ) );

    // Subscribe to window events at the centralized dispatcher
    CX11EventDispatcher::Instance()->SubscribeOnBehalfOfWindow( AsObserver(), m_window );

    // register interest in the delete window message
//    m_wmDeleteWindow = ::XInternAtom( m_display, "WM_DELETE_WINDOW", False );
//    ::XSetWMProtocols( m_display, m_window, &m_wmDeleteWindow, 1 );

    Show();
    Repaint();
    return true;
}
Exemplo n.º 4
0
	void Window::mProcess(void* param)
	{
		auto message = (dMESSAGE*)param;
		if (!message) return;
		if (!message->Optional) return;
		auto window = (Window*)message->Optional;

		if (message->Type == eMESSAGE::PAINT)
			window->OnPaint();
		else if (message->Type == eMESSAGE::SIZE)
		{
			if (!message->Message) return;
			auto data = (dSIZE*)message->Message;
			window->OnResize(data->Width, data->Height);
		}
		else if (message->Type == eMESSAGE::CLOSE)
			WindowDestroy(window->mHandle);
	}
Exemplo n.º 5
0
bool SysInit(HINSTANCE hInst)
{
	assert(hInst != NULL);
	
	appInst = hInst;

	bool fullscr = true;
	if(Message(MB_YESNO,"Run windowed ?") == IDYES)
		fullscr = false;

	if(!WindowCreate(START_RES_X, START_RES_Y, 16,fullscr))
		return false;
	
	if(!buffer.Init(dispDC, START_RES_X, START_RES_Y))
	{
		WindowDestroy();
		return false;
	}

	return true;
}
Exemplo n.º 6
0
void
CX11Window::SetWindow( ::Window window )
{GUCEF_TRACE;

    // Cleanup whatever we have already
    WindowDestroy();

    m_window = window;

    // Setup the new window
    if ( 0 != m_window )
    {
        // Subscribe to window events at the centralized dispatcher
        CX11EventDispatcher::Instance()->SubscribeOnBehalfOfWindow( AsObserver(), m_window );

        // register interest in the delete window message
        ::Atom wmDeleteMessage = ::XInternAtom( m_display, "WM_DELETE_WINDOW", False );
        ::XSetWMProtocols( m_display, m_window, &wmDeleteMessage, 1 );

        Show();
        Repaint();
    }
}
Exemplo n.º 7
0
CX11Window::~CX11Window()
{GUCEF_TRACE;

    WindowDestroy();
    SetDisplay( NULL );
}
Exemplo n.º 8
0
void
CX11Window::Close( void )
{GUCEF_TRACE;

    WindowDestroy();
}
Exemplo n.º 9
0
/* ---------------------------------------------------------------------
 * ComboboxShowDropdown
 * Display dropdown window
 * ---------------------------------------------------------------------
 */
static void
ComboboxShowDropdown(CUIWINDOW* win, COMBOBOXDATA* data, int capture)
{
	CUIWINDOW* listbox;
	CUIRECT rc;
	int height;

	WindowGetWindowRect(win, &rc);

	height = ((data->NumItems + 2) > data->Height) ? data->Height : (data->NumItems + 2);
	if ((LINES - rc.Y) > height)
	{
		listbox = WindowNew(win, rc.X, rc.Y + 1, rc.W, height, 
			CWS_POPUP | CWS_BORDER | CWS_TABSTOP);
	}
	else if (rc.Y > (LINES / 2))
	{
		if (height > (rc.Y - 1))
		{
			height = rc.Y - 1;
		}
		listbox = WindowNew(win, rc.X, rc.Y - height - 1, rc.W, height, 
			CWS_POPUP | CWS_BORDER | CWS_TABSTOP);
	}
	else
	{
		if (height > (LINES - rc.Y - 1))
		{
			height = LINES - rc.Y - 1;
		}
		listbox = WindowNew(win, rc.X, rc.Y + 1, rc.W, height, 
			CWS_POPUP | CWS_BORDER | CWS_TABSTOP);
	}

	listbox->Class = _T("CBDROPDOWN");
	WindowSetPaintHook(listbox, CbDropdownPaintHook);
	WindowSetKeyHook(listbox, CbDropdownKeyHook);
	WindowSetMButtonHook(listbox, CbDropdownMButtonHook);
	WindowSetVScrollHook(listbox, CbDropdownVScrollHook);
	WindowSetSizeHook(listbox, CbDropdownSizeHook);
	WindowSetSetFocusHook(listbox, CbDropdownSetFocusHook);
	WindowSetKillFocusHook(listbox, CbDropdownKillFocusHook);
	WindowEnableVScroll(listbox, TRUE);

	listbox->InstData = (void*) data;
	data->SelIndex = data->CtrlSelIndex;
	data->MouseDown = capture;
	data->DropdownState = TRUE;
	data->CloseKey = 0;

	if (height > 0)
	{
		WindowCreate(listbox);
		if (capture)
		{
			WindowSetCapture(listbox);
		}
		WindowModal(listbox);
		WindowReleaseCapture();
	}
	WindowDestroy(listbox);

	data->DropdownState = FALSE;
	ComboboxUpdate(win);

	switch(data->CloseKey)
	{
	case KEY_TAB:
	case KEY_RIGHT:
		WindowFocusNext(win->Parent);
		break;
	case KEY_LEFT:
		WindowFocusPrevious(win->Parent);
		break;
	}
}
Exemplo n.º 10
0
bool WindowCreate(dword w,dword h,dword bpp,bool fullscr)
{
	WNDCLASS	wc;
	RECT		winRect;
	dword		style = WS_OVERLAPPEDWINDOW;

	assert(dispWnd == NULL);
	assert(dispDC == NULL);
	assert(appInst != NULL);

	wc.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	wc.lpfnWndProc		= (WNDPROC)WindowProc;
	wc.cbClsExtra		= 0;
	wc.cbWndExtra		= 0;
	wc.hInstance		= appInst;
	wc.hIcon			= LoadIcon(NULL,IDI_WINLOGO);
	wc.hCursor			= LoadCursor(NULL,IDC_ARROW);
	wc.hbrBackground	= (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.lpszMenuName		= NULL;
	wc.lpszClassName	= TITLE;
	
	if(!RegisterClass(&wc))
	{
		Message(MB_OK|MB_ICONERROR,"WindowCreate - Cannot register class!");
		return false;
	}

	if(fullscr)
	{
		if(!ChangeDispSettings(w,h,bpp))
		{
			Message(MB_OK|MB_ICONEXCLAMATION,"WindowCreate - Cannot change display settings to "
											 "%dx%d %d bpp!\nProceeding in windowed mode!",w,h,bpp);
			fullscr = false;
		}
		else
		{
			while(ShowCursor(FALSE) >= 0);
			style = WS_POPUP;
		}
	
		isFullscr = fullscr;
	}

	winRect.left	= 0;
	winRect.top		= 0;
	winRect.right	= w-1;
	winRect.bottom	= h-1;

	AdjustWindowRect(&winRect,style,FALSE);

	dispWnd = CreateWindow(TITLE,
						   TITLE,
						   style,
						   0,
						   0,
						   (winRect.right - winRect.left) + 1,
						   (winRect.bottom - winRect.top) + 1,
						   NULL,
						   NULL,
						   appInst,
						   0);
	if(!dispWnd)
	{
		Message(MB_OK|MB_ICONERROR,"WindowCreate - Cannot create window!");
		WindowDestroy();
		return false;
	}

	dispDC = GetDC(dispWnd);
	if(!dispDC)
	{
		Message(MB_OK|MB_ICONERROR,"WindowCreate - Cannot get DC!");
		WindowDestroy();
		return false;
	}

	ShowWindow(dispWnd,SW_SHOWNORMAL);
	SetForegroundWindow(dispWnd);

	return true;
}
Exemplo n.º 11
0
void SysDeinit(void)
{
	buffer.Deinit();
	WindowDestroy();
}