summaryrefslogtreecommitdiff
path: root/osframework/source/SexyAppFramework/NativeDisplay.h
blob: d6a13892830f61f96d50443461c8586a3dc852ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#ifndef __NATIVEDISPLAY_H__
#define __NATIVEDISPLAY_H__
#include "Common.h"
#include "Rect.h"
#include "CritSect.h"
#include "Ratio.h"
#include "Event.h"
#include "SexyThread.h"
#include "InputInterface.h"

namespace Sexy
{

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class Font;
class Image;
class SexyAppBase;
class Graphics;
class MemoryImage;
class Widget;
struct InputInfo;

class DelayedWork
{
public:
	virtual ~DelayedWork()
	{
	}

	virtual void Work(void) = 0;
};

enum KeyboardMode {
	KEYBOARD_NORMAL,
	KEYBOARD_PASSWORD,
	KEYBOARD_URL,
	KEYBOARD_EMAIL
};

class NativeDisplay
{
 public:
	CritSect				mCritSect;

	bool                                    mPreserveBits;
	int					mRGBBits;
	ulong					mRedMask;
	ulong					mGreenMask;
	ulong					mBlueMask;
	int					mRedBits;
	int					mGreenBits;
	int					mBlueBits;
	int					mRedShift;
	int					mGreenShift;
	int				        mBlueShift;

        int                                     mCursorX;
        int                                     mCursorY;

	int					mWidth;
	int					mHeight;
	Ratio					mAspect;
	int					mDesktopWidth;
	int					mDesktopHeight;
	Ratio					mDesktopAspect;
	bool					mIsWidescreen;
	int					mDisplayWidth;
	int					mDisplayHeight;
	Ratio					mDisplayAspect;

	Rect					mPresentationRect;

	std::list<DelayedWork*>                 mWorkQueue;
	CritSect				mWorkQueuCritSect;
	Thread                                  mMainThread;

	CritSect				mTexMemSpaceCritSect;
	bool                                    mTraceTexMemAlloc;
	DWORD                                   mCurTexMemSpace;
	DWORD                                   mMaxTexMemSpace;
	SexyAppBase*				mApp;

 public:
	NativeDisplay();
	virtual ~NativeDisplay();

 public:
        virtual int                                Init();
	virtual bool                               CanReinit();
	virtual bool                               Reinit();

	virtual bool				   Is3DAccelerated();
	virtual bool				   Is3DAccelerationSupported();
	virtual bool				   Is3DAccelerationRecommended();

	virtual bool                               CanFullscreen();
	virtual bool                               CanWindowed();

        virtual Font *                             CreateFont(SexyAppBase * theApp,
                                                              const std::string theFace,
                                                              int thePointSize,
                                                              bool bold = false,
                                                              bool italics = false,
                                                              bool underline = false);
        virtual Image *                             CreateImage(SexyAppBase * theApp,
                                                                int width, int height);

	virtual Image*			            GetScreenImage() = 0;
	virtual bool				    Redraw(Rect* theClipRect = 0) = 0;
	virtual void				    RemapMouse(int& theX, int& theY) = 0;

        virtual bool                                UpdateCursor(int theCursorX, int theCursorY);
        virtual bool                                DrawCursor(Graphics* g);

        virtual bool                                EnableCursor(bool enable);
	virtual bool				    SetCursorImage(Image* theImage,
								   int theHotX = 0,
								   int theHotY = 0);
	virtual void				    SetCursorPos(int theCursorX, int theCursorY);


 public:
	virtual void                                EnsureImageData(MemoryImage* theMemoryImage,
								    bool thePurgeBits = false,
								    bool theForce = false);
	virtual bool                                CreateImageData(MemoryImage* theMemoryImage);
	virtual void                                RemoveImageData(MemoryImage * theMemoryImage);

 public:
        virtual bool                                HasEvent();
        virtual bool                                GetEvent(struct Event & event);
	virtual bool                                GetInputInfo(InputInfo &anInfo);

	virtual bool                                ShowKeyboard(Widget* theWidget,
								 KeyboardMode mode,
								 const std::string &title,
								 const std::string &hint,
								 const std::string &initial);
	virtual void                                HideKeyboard();

 public:
	void                                        FlushWork(void);
	void                                        PushWork(DelayedWork* theWork);
	bool                                        IsWorkPending(void);

	virtual void                                Update();

 public:
	virtual void                                AllocTexMemSpace(DWORD theTexMemSize);
	virtual void                                FreeTexMemSpace(DWORD theTexMemSize);
	virtual bool                                EnsureTexMemSpace(DWORD theTexMemSize);

 private:
	DelayedWork*                                PopWork(void);
};

};


#endif