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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
Copyright (c) 2001 Palm, Inc. or its subsidiaries.
All rights reserved.
This file is part of the Palm OS Emulator.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
\* ===================================================================== */
#ifndef EmWindow_h
#define EmWindow_h
#include "EmPixMap.h" // EmPixMap
#include "EmRegion.h" // EmRegion
#include "EmStructs.h" // RGBList
#include "PreferenceMgr.h" // PrefKeyType
/*
EmWindow is the cross-platform object representing the window that
displays the emulation. It is not the actual thing that appears on
the monitor as a window, but merely deals with cross-platform
aspects of handling it, such as updating its contents, changing
skins, etc.
EmWindow handles all the cross-platform issues. It can deal with
the upper-level parts of updating the LCD area, wiggling the window
if the vibrator is going, changing skins, etc.
EmWindow manages most of the platform-specific aspects by defining
HostFoo methods, which are then defined differently on each
platform. These HostFoo methods are implemented in
EmWindow<Host>.cpp.
EmWindow<Host> is also defined in EmWindow<Host>.cpp, and holds any
platform-specific data (such as the HWND on Windows, etc.). It
declares and implements any support functions needed on that
particular platform, but which can't be declared in EmWindow because
either not all platforms need those functions, or they involve
platform-specific types.
One creates a window by calling "window = new EmWindow<Host>;"
followed by "window->WindowInit();". Cross-platform code can then
call high-level functions in EmWindow such as HandleUpdate and
HandlePen. Platform-specific code can perform platform-specific
operations. When it's time to close the window, call
"window->WindowDispose();" followed by "delete window;"
*/
class EmPoint;
class EmScreenUpdateInfo;
class EmWindow
{
public:
EmWindow (void);
virtual ~EmWindow (void);
static EmWindow* NewWindow (void);
void WindowInit (void);
void WindowReset (void);
void HandlePenEvent (const EmPoint&, Bool down);
void HandleUpdate (void);
void HandlePalette (void);
void HandleDisplayChange (void);
void HandleActivate (Bool active);
virtual void HandleIdle (void);
void HandleDebugMode (Bool debugMode);
void HandleGremlinMode (Bool gremlinMode);
void GetLCDContents (EmScreenUpdateInfo& info);
private:
void PaintScreen (Bool drawCase, Bool always);
void PaintCase (const EmScreenUpdateInfo& info);
void PaintLCDFrame (const EmScreenUpdateInfo& info);
void PaintLCD (const EmScreenUpdateInfo& info);
void PaintLED (uint16 ledState);
void PaintButtonFrames (void);
static void PrefsChangedCB (PrefKeyType key, void* data);
void PrefsChanged (PrefKeyType key);
EmRect GetLCDBounds (void);
EmRect GetLEDBounds (void);
Bool GetSkin (EmPixMap&);
void GetDefaultSkin (EmPixMap&);
protected:
void PreDestroy (void);
Bool PrevLCDColorsChanged(const RGBList& newLCDColors);
void SaveLCDColors (const RGBList& newLCDColors);
void GetSystemColors (const EmScreenUpdateInfo&,
RGBList&);
void QuantizeSkinColors (const EmPixMap& skin,
RGBList& colors,
Bool polite);
const EmPixMap& GetCurrentSkin (void);
const RGBList& GetCurrentSkinColors(Bool polite);
const EmRegion& GetCurrentSkinRegion(void);
private:
virtual void HostWindowReset (void) = 0;
virtual void HostMouseCapture (void);
virtual void HostMouseRelease (void);
virtual void HostUpdateBegin (void);
virtual void HostUpdateEnd (void);
virtual void HostDrawingBegin (void);
virtual void HostDrawingEnd (void);
virtual void HostPaletteSet (const EmScreenUpdateInfo&);
virtual void HostPaletteRestore (void);
virtual void HostWindowMoveBy (const EmPoint&) = 0;
virtual void HostWindowMoveTo (const EmPoint&) = 0;
virtual EmRect HostWindowBoundsGet (void) = 0;
virtual void HostWindowCenter (void) = 0;
virtual void HostWindowShow (void) = 0;
virtual void HostWindowDrag (void);
virtual void HostWindowStayOnTop (void);
virtual void HostRectFrame (const EmRect&, const EmPoint&, const RGBType&) = 0;
virtual void HostOvalPaint (const EmRect&, const RGBType&) = 0;
virtual void HostPaintCase (const EmScreenUpdateInfo&) = 0;
virtual void HostPaintLCD (const EmScreenUpdateInfo& info,
const EmRect& srcRect,
const EmRect& destRect,
Bool scaled) = 0;
virtual void HostPalette (void);
virtual void HostDisplayChange (void);
virtual void HostGetDefaultSkin (EmPixMap&, int scale) = 0;
virtual EmPoint HostGetCurrentMouse (void) = 0;
private:
static EmWindow* fgWindow;
EmPixMap fSkinBase;
EmPixMap fSkinCurrent;
RGBList fSkinColors[16];
EmRegion fSkinRegion;
RGBList fPrevLCDColors;
SkinElementType fCurrentButton;
Bool fNeedWindowReset;
Bool fNeedWindowInvalidate;
Bool fOldLCDOn;
Bool fOldBacklightOn;
uint16 fOldLEDState;
Bool fWiggled;
Bool fActive;
Bool fDebugMode;
Bool fGremlinMode;
};
extern EmWindow* gWindow;
#endif // EmWindow_h
|