2001-11-19 03:33:36 +03:00
|
|
|
#ifndef CMSWINDOWSSCREEN_H
|
|
|
|
#define CMSWINDOWSSCREEN_H
|
|
|
|
|
|
|
|
#include "CMutex.h"
|
|
|
|
#include "IClipboard.h"
|
|
|
|
#include "BasicTypes.h"
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
class CString;
|
|
|
|
class CThread;
|
|
|
|
|
|
|
|
class CMSWindowsScreen {
|
2002-04-29 18:40:01 +04:00
|
|
|
public:
|
2001-11-19 03:33:36 +03:00
|
|
|
CMSWindowsScreen();
|
|
|
|
virtual ~CMSWindowsScreen();
|
|
|
|
|
|
|
|
// manipulators
|
|
|
|
|
|
|
|
static void init(HINSTANCE);
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
protected:
|
2001-11-19 03:33:36 +03:00
|
|
|
// runs an event loop and returns when WM_QUIT is received
|
|
|
|
void doRun();
|
|
|
|
|
|
|
|
// sends WM_QUIT to force doRun() to return
|
|
|
|
void doStop();
|
|
|
|
|
|
|
|
// open the X display. calls onOpenDisplay() after opening the display,
|
|
|
|
// getting the screen, its size, and root window. then it starts the
|
|
|
|
// event thread.
|
|
|
|
void openDisplay();
|
|
|
|
|
|
|
|
// destroy the window and close the display. calls onCloseDisplay()
|
|
|
|
// after the event thread has been shut down but before the display
|
|
|
|
// is closed.
|
|
|
|
void closeDisplay();
|
|
|
|
|
|
|
|
// get the application instance handle and the registered window
|
|
|
|
// class atom
|
|
|
|
static HINSTANCE getInstance();
|
|
|
|
ATOM getClass() const;
|
|
|
|
|
2002-05-24 21:54:28 +04:00
|
|
|
// update screen size cache
|
|
|
|
void updateScreenSize();
|
|
|
|
|
2001-11-19 03:33:36 +03:00
|
|
|
// get the size of the screen
|
|
|
|
void getScreenSize(SInt32* w, SInt32* h) const;
|
|
|
|
|
|
|
|
// wait for and get the next message. cancellable.
|
|
|
|
void getEvent(MSG*) const;
|
|
|
|
|
2001-11-25 21:32:41 +03:00
|
|
|
// called by doRun() to handle an event. return true to skip
|
|
|
|
// event translation and dispatch.
|
|
|
|
virtual bool onPreTranslate(MSG*) = 0;
|
|
|
|
|
|
|
|
// called by window proc. subclass must call DefWindowProc() if necessary
|
|
|
|
virtual LRESULT onEvent(HWND, UINT, WPARAM, LPARAM) = 0;
|
2001-11-19 03:33:36 +03:00
|
|
|
|
|
|
|
// called by openDisplay() to allow subclasses to prepare the display
|
|
|
|
virtual void onOpenDisplay() = 0;
|
|
|
|
|
|
|
|
// called by closeDisplay() to
|
|
|
|
virtual void onCloseDisplay() = 0;
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
private:
|
2001-11-19 03:33:36 +03:00
|
|
|
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
private:
|
2001-11-19 03:33:36 +03:00
|
|
|
static HINSTANCE s_instance;
|
|
|
|
ATOM m_class;
|
|
|
|
HICON m_icon;
|
|
|
|
HCURSOR m_cursor;
|
|
|
|
SInt32 m_w, m_h;
|
|
|
|
DWORD m_thread;
|
2001-11-25 21:32:41 +03:00
|
|
|
static CMSWindowsScreen* s_screen;
|
2001-11-19 03:33:36 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|