forked from audetto/AppleWin
/
Win32Frame.h
200 lines (167 loc) · 6.44 KB
/
Win32Frame.h
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#pragma once
#include "FrameBase.h"
#include "DiskImage.h"
class Video;
#if 0 // enable non-integral full-screen scaling
#define FULLSCREEN_SCALE_TYPE float
#else
#define FULLSCREEN_SCALE_TYPE int
#endif
// 3D border around the 560x384 Apple II display
#define VIEWPORTX 5
#define VIEWPORTY 5
#define BUTTONX (g_nViewportCX + VIEWPORTX*2)
#define BUTTONY 0
#define BUTTONCX 45
#define BUTTONCY 45
#define BUTTONS 8
class Win32Frame : public FrameBase
{
public:
Win32Frame(void);
virtual ~Win32Frame(void){}
static Win32Frame& GetWin32Frame();
static LRESULT CALLBACK FrameWndProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
virtual void FrameDrawDiskLEDS();
virtual void FrameDrawDiskStatus();
virtual void FrameRefreshStatus(int drawflags);
virtual void FrameUpdateApple2Type();
virtual void FrameSetCursorPosByMousePos();
virtual void SetFullScreenShowSubunitStatus(bool bShow);
virtual bool GetBestDisplayResolutionForFullScreen(UINT& bestWidth, UINT& bestHeight, UINT userSpecifiedWidth=0, UINT userSpecifiedHeight=0);
virtual int SetViewportScale(int nNewScale, bool bForce = false);
virtual void SetAltEnterToggleFullScreen(bool mode);
virtual void SetLoadedSaveStateFlag(const bool bFlag);
virtual void Initialize(bool resetVideoState);
virtual void Destroy(void);
virtual void VideoPresentScreen(void);
virtual void ResizeWindow(void);
virtual int FrameMessageBox(LPCSTR lpText, LPCSTR lpCaption, UINT uType);
virtual void GetBitmap(LPCSTR lpBitmapName, LONG cb, LPVOID lpvBits);
virtual BYTE* GetResource(WORD id, LPCSTR lpType, DWORD expectedSize);
virtual void Restart();
virtual std::string Video_GetScreenShotFolder();
bool GetFullScreenShowSubunitStatus(void);
int GetFullScreenOffsetX(void);
int GetFullScreenOffsetY(void);
bool IsFullScreen(void);
void FrameRegisterClass();
void FrameCreateWindow(void);
void ChooseMonochromeColor(void);
UINT Get3DBorderWidth(void);
UINT Get3DBorderHeight(void);
int GetViewportScale(void);
void GetViewportCXCY(int& nViewportCX, int& nViewportCY);
void SetFullScreenViewportScale(int nNewXScale, int nNewYScale);
void ApplyVideoModeChange(void);
HDC FrameGetDC();
void FrameReleaseDC();
bool g_bScrollLock_FullSpeed;
private:
static BOOL CALLBACK DDEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext);
LRESULT WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
void VideoCreateDIBSection(bool resetVideoState);
void VideoDrawLogoBitmap(HDC hDstDC, int xoff, int yoff, int srcw, int srch, int scale);
bool DDInit(void);
void DDUninit(void);
void Benchmark(void);
void DisplayLogo(void);
void FrameDrawDiskLEDS(HDC hdc); // overloaded Win32 only, call via GetWin32Frame()
void FrameDrawDiskStatus(HDC hdc); // overloaded Win32 only, call via GetWin32Frame()
void EraseButton(int number);
void DrawButton(HDC passdc, int number);
void DrawCrosshairs(int x, int y);
void DrawFrameWindow(bool bPaintingWindow = false);
void DrawStatusArea(HDC passdc, int drawflags);
void Draw3dRect(HDC dc, int x1, int y1, int x2, int y2, BOOL out);
void DrawBitmapRect(HDC dc, int x, int y, LPRECT rect, HBITMAP bitmap);
void ProcessButtonClick(int button, bool bFromButtonUI = false);
bool ConfirmReboot(bool bFromButtonUI);
void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive);
void RelayEvent(UINT message, WPARAM wparam, LPARAM lparam);
void SetFullScreenMode(void);
void SetNormalMode(void);
void SetUsingCursor(BOOL bNewValue);
void SetupTooltipControls(void);
void FrameResizeWindow(int nNewScale);
void RevealCursor();
void ScreenWindowResize(const bool bCtrlKey);
void UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int x=0, int y=0);
void DrawCrosshairsMouse();
void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeavingAppleScreen);
void CreateGdiObjects(void);
void DeleteGdiObjects(void);
void FrameShowCursor(BOOL bShow);
void FullScreenRevealCursor(void);
void GetWidthHeight(int& nWidth, int& nHeight);
bool g_bAltEnter_ToggleFullScreen; // Default for ALT+ENTER is to toggle between windowed and full-screen modes
bool g_bIsFullScreen;
bool g_bShowingCursor;
bool g_bLastCursorInAppleViewport;
UINT_PTR g_TimerIDEvent_100msec;
UINT g_uCount100msec;
COLORREF customcolors[256]; // MONOCHROME is last custom color
HBITMAP g_hLogoBitmap;
HBITMAP g_hDeviceBitmap;
HDC g_hDeviceDC;
LPBITMAPINFO g_pFramebufferinfo;
BOOL g_bUsingCursor; // TRUE = AppleWin is using (hiding) the mouse-cursor && restricting cursor to window - see SetUsingCursor()
bool g_bAppActive;
bool g_bFrameActive;
bool g_windowMinimized;
std::string driveTooltip;
bool g_bFullScreen_ShowSubunitStatus;
int g_win_fullscreen_offsetx;
int g_win_fullscreen_offsety;
UINT m_bestWidthForFullScreen;
UINT m_bestHeightForFullScreen;
bool m_changedDisplaySettings;
static const UINT MAX_DRAW_DEVICES = 10;
char* draw_devices[MAX_DRAW_DEVICES];
GUID draw_device_guid[MAX_DRAW_DEVICES];
int num_draw_devices;
LPDIRECTDRAW g_lpDD;
HBITMAP buttonbitmap[BUTTONS];
HBRUSH btnfacebrush;
HPEN btnfacepen;
HPEN btnhighlightpen;
HPEN btnshadowpen;
int buttonactive;
int buttondown;
int buttonover;
int buttonx;
int buttony;
HDC g_hFrameDC;
RECT framerect;
BOOL helpquit;
HFONT smallfont;
HWND tooltipwindow;
int viewportx; // Default to Normal (non-FullScreen) mode
int viewporty; // Default to Normal (non-FullScreen) mode
RECT g_main_window_saved_rect;
int g_main_window_saved_style;
int g_main_window_saved_exstyle;
HBITMAP g_hCapsLockBitmap[2];
HBITMAP g_hHardDiskBitmap[2];
//Pravets8 only
HBITMAP g_hCapsBitmapP8[2];
HBITMAP g_hCapsBitmapLat[2];
//HBITMAP charsetbitmap [4]; //The idea was to add a charset indicator on the front panel, but it was given up. All charsetbitmap occurences must be REMOVED!
//===========================
HBITMAP g_hDiskWindowedLED[NUM_DISK_STATUS];
int g_nTrackDrive1;
int g_nTrackDrive2;
int g_nSectorDrive1;
int g_nSectorDrive2;
TCHAR g_sTrackDrive1[8];
TCHAR g_sTrackDrive2[8];
TCHAR g_sSectorDrive1[8];
TCHAR g_sSectorDrive2[8];
Disk_Status_e g_eStatusDrive1;
Disk_Status_e g_eStatusDrive2;
static const int kDEFAULT_VIEWPORT_SCALE = 2;
int g_nViewportCX;
int g_nViewportCY;
int g_nViewportScale; // saved REGSAVE
int g_nMaxViewportScale; // Max scale in Windowed mode with borders, buttons etc (full-screen may be +1)
};