2020-12-24 15:08:50 +00:00
# pragma once
# include "FrameBase.h"
2021-01-16 21:57:28 +00:00
# include "DiskImage.h"
2020-12-24 15:08:50 +00:00
2021-01-03 16:21:24 +00:00
class Video ;
2021-01-10 16:33:06 +00:00
#if 0 // enable non-integral full-screen scaling
# define FULLSCREEN_SCALE_TYPE float
# else
# define FULLSCREEN_SCALE_TYPE int
# endif
2021-01-16 21:57:28 +00:00
// 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
2020-12-24 15:08:50 +00:00
class Win32Frame : public FrameBase
{
public :
2021-11-30 21:41:02 +00:00
Win32Frame ( void ) ;
virtual ~ Win32Frame ( void ) { }
2021-01-03 16:21:24 +00:00
2021-01-10 16:33:06 +00:00
static Win32Frame & GetWin32Frame ( ) ;
2021-01-16 21:57:28 +00:00
static LRESULT CALLBACK FrameWndProc ( HWND window , UINT message , WPARAM wparam , LPARAM lparam ) ;
2021-01-10 16:33:06 +00:00
virtual void FrameDrawDiskLEDS ( ) ;
virtual void FrameDrawDiskStatus ( ) ;
virtual void FrameRefreshStatus ( int drawflags ) ;
2020-12-24 15:08:50 +00:00
virtual void FrameUpdateApple2Type ( ) ;
virtual void FrameSetCursorPosByMousePos ( ) ;
virtual void SetFullScreenShowSubunitStatus ( bool bShow ) ;
2021-11-30 21:41:02 +00:00
virtual bool GetBestDisplayResolutionForFullScreen ( UINT & bestWidth , UINT & bestHeight , UINT userSpecifiedWidth = 0 , UINT userSpecifiedHeight = 0 ) ;
2020-12-24 15:08:50 +00:00
virtual int SetViewportScale ( int nNewScale , bool bForce = false ) ;
virtual void SetAltEnterToggleFullScreen ( bool mode ) ;
virtual void SetLoadedSaveStateFlag ( const bool bFlag ) ;
2021-01-03 16:21:24 +00:00
2021-11-30 21:41:02 +00:00
virtual void Initialize ( bool resetVideoState ) ;
2021-01-03 16:21:24 +00:00
virtual void Destroy ( void ) ;
virtual void VideoPresentScreen ( void ) ;
2021-11-30 21:41:02 +00:00
virtual void ResizeWindow ( void ) ;
2021-01-10 16:33:06 +00:00
2021-01-19 20:37:43 +00:00
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 ( ) ;
2022-02-15 18:48:20 +00:00
virtual std : : string Video_GetScreenShotFolder ( ) const ;
2022-01-03 14:41:03 +00:00
2021-01-10 16:33:06 +00:00
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 ) ;
2021-01-16 21:57:28 +00:00
int GetViewportScale ( void ) ;
void GetViewportCXCY ( int & nViewportCX , int & nViewportCY ) ;
2021-11-30 21:41:02 +00:00
void SetFullScreenViewportScale ( int nNewXScale , int nNewYScale ) ;
2021-01-16 21:57:28 +00:00
2021-01-13 22:02:48 +00:00
void ApplyVideoModeChange ( void ) ;
2021-01-16 21:57:28 +00:00
HDC FrameGetDC ( ) ;
void FrameReleaseDC ( ) ;
bool g_bScrollLock_FullSpeed ;
2021-01-10 16:33:06 +00:00
2021-01-03 16:21:24 +00:00
private :
2021-01-10 16:33:06 +00:00
static BOOL CALLBACK DDEnumProc ( LPGUID lpGUID , LPCTSTR lpszDesc , LPCTSTR lpszDrvName , LPVOID lpContext ) ;
2021-01-16 21:57:28 +00:00
LRESULT WndProc ( HWND window , UINT message , WPARAM wparam , LPARAM lparam ) ;
2021-01-10 16:33:06 +00:00
2021-11-30 21:41:02 +00:00
void VideoCreateDIBSection ( bool resetVideoState ) ;
2021-01-03 16:21:24 +00:00
void VideoDrawLogoBitmap ( HDC hDstDC , int xoff , int yoff , int srcw , int srch , int scale ) ;
bool DDInit ( void ) ;
void DDUninit ( void ) ;
2021-01-10 16:33:06 +00:00
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 ) ;
2021-01-16 21:57:28 +00:00
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 ) ;
2021-01-10 16:33:06 +00:00
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 ) ;
2021-05-31 15:09:39 +00:00
void SetFullScreenMode ( void ) ;
void SetNormalMode ( void ) ;
2021-01-10 16:33:06 +00:00
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 ) ;
2021-01-16 21:57:28 +00:00
void DeleteGdiObjects ( void ) ;
2021-01-10 16:33:06 +00:00
void FrameShowCursor ( BOOL bShow ) ;
void FullScreenRevealCursor ( void ) ;
2021-01-16 21:57:28 +00:00
void GetWidthHeight ( int & nWidth , int & nHeight ) ;
2021-01-10 16:33:06 +00:00
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 ;
2021-01-03 16:21:24 +00:00
COLORREF customcolors [ 256 ] ; // MONOCHROME is last custom color
HBITMAP g_hLogoBitmap ;
HBITMAP g_hDeviceBitmap ;
HDC g_hDeviceDC ;
LPBITMAPINFO g_pFramebufferinfo ;
2021-01-10 16:33:06 +00:00
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 ;
2021-05-31 15:09:39 +00:00
UINT m_bestWidthForFullScreen ;
UINT m_bestHeightForFullScreen ;
2021-06-19 14:06:04 +00:00
bool m_changedDisplaySettings ;
2021-01-03 16:21:24 +00:00
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 ;
2021-01-16 21:57:28 +00:00
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 ;
2021-01-16 22:13:02 +00:00
TCHAR g_sTrackDrive1 [ 8 ] ;
TCHAR g_sTrackDrive2 [ 8 ] ;
TCHAR g_sSectorDrive1 [ 8 ] ;
TCHAR g_sSectorDrive2 [ 8 ] ;
2021-01-16 21:57:28 +00:00
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)
2020-12-24 15:08:50 +00:00
} ;