2001-11-19 00:33:36 +00:00
|
|
|
#ifndef CMSWINDOWSSCREEN_H
|
|
|
|
#define CMSWINDOWSSCREEN_H
|
|
|
|
|
|
|
|
#include "IClipboard.h"
|
2002-06-10 22:06:45 +00:00
|
|
|
#include "CMutex.h"
|
2002-06-11 20:09:59 +00:00
|
|
|
#include "CString.h"
|
2002-06-10 16:49:46 +00:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2001-11-19 00:33:36 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2002-06-23 21:53:31 +00:00
|
|
|
class CMSWindowsScreenSaver;
|
2001-11-19 00:33:36 +00:00
|
|
|
class CThread;
|
|
|
|
|
2002-07-12 20:41:23 +00:00
|
|
|
class CEvent {
|
|
|
|
public:
|
|
|
|
MSG m_msg;
|
|
|
|
LRESULT m_result;
|
|
|
|
};
|
|
|
|
|
2001-11-19 00:33:36 +00:00
|
|
|
class CMSWindowsScreen {
|
2002-04-29 14:40:01 +00:00
|
|
|
public:
|
2001-11-19 00:33:36 +00:00
|
|
|
CMSWindowsScreen();
|
|
|
|
virtual ~CMSWindowsScreen();
|
|
|
|
|
|
|
|
// manipulators
|
|
|
|
|
|
|
|
static void init(HINSTANCE);
|
|
|
|
|
2002-06-08 21:48:00 +00:00
|
|
|
// accessors
|
|
|
|
|
|
|
|
// get the application instance handle
|
|
|
|
static HINSTANCE getInstance();
|
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
protected:
|
2002-07-12 20:41:23 +00:00
|
|
|
// runs an event loop and returns when exitMainLoop() is called
|
|
|
|
void mainLoop();
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-12 20:41:23 +00:00
|
|
|
// force mainLoop() to return
|
|
|
|
void exitMainLoop();
|
2001-11-19 00:33:36 +00:00
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
2002-06-08 21:48:00 +00:00
|
|
|
// get the registered window class atom
|
2001-11-19 00:33:36 +00:00
|
|
|
ATOM getClass() const;
|
|
|
|
|
2002-05-24 17:54:28 +00:00
|
|
|
// update screen size cache
|
2002-06-19 17:03:29 +00:00
|
|
|
void updateScreenShape();
|
2002-05-24 17:54:28 +00:00
|
|
|
|
2001-11-19 00:33:36 +00:00
|
|
|
// get the size of the screen
|
2002-06-19 17:03:29 +00:00
|
|
|
void getScreenShape(SInt32& x, SInt32& y,
|
|
|
|
SInt32& width, SInt32& height) const;
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-07-11 18:58:49 +00:00
|
|
|
// get the current cursor position
|
|
|
|
void getCursorPos(SInt32& x, SInt32& y) const;
|
|
|
|
|
|
|
|
// get the cursor center position
|
|
|
|
void getCursorCenter(SInt32& x, SInt32& y) const;
|
|
|
|
|
2002-06-08 21:48:00 +00:00
|
|
|
// get the input desktop. caller must CloseDesktop() the result.
|
|
|
|
// do not call under windows 95/98/me.
|
|
|
|
HDESK openInputDesktop() const;
|
|
|
|
|
|
|
|
// get the desktop's name. do not call under windows 95/98/me.
|
|
|
|
CString getDesktopName(HDESK) const;
|
|
|
|
|
|
|
|
// returns true iff desk is the current desk. do not call under
|
|
|
|
// windows 95/98/me.
|
|
|
|
bool isCurrentDesktop(HDESK desk) const;
|
|
|
|
|
2002-06-23 21:53:31 +00:00
|
|
|
// get the screen saver object
|
|
|
|
CMSWindowsScreenSaver*
|
|
|
|
getScreenSaver() const;
|
|
|
|
|
2002-07-12 20:41:23 +00:00
|
|
|
// called for each event before event translation and dispatch. return
|
|
|
|
// true to skip translation and dispatch. subclasses should call the
|
|
|
|
// superclass's version first and return true if it returns true.
|
|
|
|
virtual bool onPreDispatch(const CEvent* event);
|
2001-11-25 18:32:41 +00:00
|
|
|
|
2002-07-12 20:41:23 +00:00
|
|
|
// called by mainLoop(). iff the event was handled return true and
|
|
|
|
// store the result, if any, in m_result, which defaults to zero.
|
|
|
|
virtual bool onEvent(CEvent* event) = 0;
|
2001-11-19 00:33:36 +00:00
|
|
|
|
2002-06-08 21:48:00 +00:00
|
|
|
// called by isCurrentDesktop() to get the current desktop name
|
|
|
|
virtual CString getCurrentDesktopName() const = 0;
|
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2002-07-11 18:58:49 +00:00
|
|
|
// create the transparent cursor
|
|
|
|
void createBlankCursor();
|
|
|
|
|
2002-07-12 20:41:23 +00:00
|
|
|
// our window proc
|
2001-11-19 00:33:36 +00:00
|
|
|
static LRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
|
2002-04-29 14:40:01 +00:00
|
|
|
private:
|
2001-11-19 00:33:36 +00:00
|
|
|
static HINSTANCE s_instance;
|
|
|
|
ATOM m_class;
|
|
|
|
HICON m_icon;
|
|
|
|
HCURSOR m_cursor;
|
2002-06-19 17:03:29 +00:00
|
|
|
SInt32 m_x, m_y;
|
2001-11-19 00:33:36 +00:00
|
|
|
SInt32 m_w, m_h;
|
|
|
|
DWORD m_thread;
|
2002-06-23 21:53:31 +00:00
|
|
|
CMSWindowsScreenSaver* m_screenSaver;
|
2001-11-25 18:32:41 +00:00
|
|
|
static CMSWindowsScreen* s_screen;
|
2001-11-19 00:33:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|