support retina display

This commit is contained in:
Grant Paul 2012-12-23 21:33:52 +13:00 committed by Matthew Parlane
parent e3eebdf591
commit 3aa9901618
7 changed files with 107 additions and 34 deletions

View File

@ -50,7 +50,7 @@ public:
DSPDebuggerLLE(wxWindow *parent, wxWindowID id = wxID_ANY); DSPDebuggerLLE(wxWindow *parent, wxWindowID id = wxID_ANY);
virtual ~DSPDebuggerLLE(); virtual ~DSPDebuggerLLE();
void Refresh(); virtual void Refresh();
private: private:
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();

View File

@ -450,11 +450,26 @@ CFrame::~CFrame()
bool CFrame::RendererIsFullscreen() bool CFrame::RendererIsFullscreen()
{ {
bool fullscreen = false;
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE) if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE)
{ {
return m_RenderFrame->IsFullScreen(); fullscreen = m_RenderFrame->IsFullScreen();
} }
return false;
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if (m_RenderFrame != NULL)
{
NSView *view = (NSView *) m_RenderFrame->GetHandle();
NSWindow *window = [view window];
if ([window respondsToSelector:@selector(toggleFullScreen:)]) {
fullscreen = (([window styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask);
}
}
#endif
return fullscreen;
} }
void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event)) void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event))
@ -1002,7 +1017,23 @@ void CFrame::DoFullscreen(bool bF)
{ {
ToggleDisplayMode(bF); ToggleDisplayMode(bF);
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
NSView *view = (NSView *) m_RenderFrame->GetHandle();
NSWindow *window = [view window];
if ([window respondsToSelector:@selector(toggleFullScreen:)])
{
if (bF != RendererIsFullscreen())
{
[window toggleFullScreen:nil];
}
}
else
#endif
{
m_RenderFrame->ShowFullScreen(bF, wxFULLSCREEN_ALL); m_RenderFrame->ShowFullScreen(bF, wxFULLSCREEN_ALL);
}
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{ {
if (bF) if (bF)

View File

@ -29,6 +29,10 @@
#include <string> #include <string>
#include <vector> #include <vector>
#ifdef __APPLE__
#include <Cocoa/Cocoa.h>
#endif
#include "CDUtils.h" #include "CDUtils.h"
#include "Debugger/CodeWindow.h" #include "Debugger/CodeWindow.h"
#include "LogWindow.h" #include "LogWindow.h"

View File

@ -876,6 +876,13 @@ void CFrame::ToggleDisplayMode(bool bFullscreen)
#elif defined(HAVE_XRANDR) && HAVE_XRANDR #elif defined(HAVE_XRANDR) && HAVE_XRANDR
m_XRRConfig->ToggleDisplayMode(bFullscreen); m_XRRConfig->ToggleDisplayMode(bFullscreen);
#elif defined __APPLE__ #elif defined __APPLE__
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
NSView *view = (NSView *) m_RenderFrame->GetHandle();
NSWindow *window = [view window];
if (![window respondsToSelector:@selector(toggleFullScreen:)])
#endif
{
if (!bFullscreen) { if (!bFullscreen) {
CGRestorePermanentDisplayConfiguration(); CGRestorePermanentDisplayConfiguration();
CGDisplayRelease(CGMainDisplayID()); CGDisplayRelease(CGMainDisplayID());
@ -908,7 +915,7 @@ void CFrame::ToggleDisplayMode(bool bFullscreen)
CGDisplaySwitchToMode(CGMainDisplayID(), mode); CGDisplaySwitchToMode(CGMainDisplayID(), mode);
} }
}
#endif #endif
} }
@ -968,6 +975,14 @@ void CFrame::StartGame(const std::string& filename)
m_RenderFrame->Show(); m_RenderFrame->Show();
} }
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
NSView *view = (NSView *) m_RenderFrame->GetHandle();
NSWindow *window = [view window];
if ([window respondsToSelector:@selector(setCollectionBehavior:)])
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
#endif
wxBeginBusyCursor(); wxBeginBusyCursor();
DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen); DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
@ -1140,8 +1155,23 @@ void CFrame::DoStop()
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
m_RenderParent->SetCursor(wxNullCursor); m_RenderParent->SetCursor(wxNullCursor);
DoFullscreen(false); DoFullscreen(false);
if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
{
m_RenderFrame->Destroy(); m_RenderFrame->Destroy();
}
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
else
{
// Disable the full screen button when not in a game.
NSView *view = (NSView *) m_RenderFrame->GetHandle();
NSWindow *window = [view window];
if ([window respondsToSelector:@selector(setCollectionBehavior:)])
[window setCollectionBehavior:NSWindowCollectionBehaviorDefault];
}
#endif
m_RenderParent = NULL; m_RenderParent = NULL;
// Clean framerate indications from the status bar. // Clean framerate indications from the status bar.

View File

@ -680,7 +680,7 @@ void TASInputDlg::OnCloseWindow(wxCloseEvent& event)
} }
} }
bool TASInputDlg::HasFocus() bool TASInputDlg::HasFocus() const
{ {
//allows numbers to be used as hotkeys //allows numbers to be used as hotkeys
if(TextBoxHasFocus()) if(TextBoxHasFocus())
@ -695,7 +695,7 @@ bool TASInputDlg::HasFocus()
return false; return false;
} }
bool TASInputDlg::TextBoxHasFocus() bool TASInputDlg::TextBoxHasFocus() const
{ {
if(wxWindow::FindFocus() == wx_mainX_t) if(wxWindow::FindFocus() == wx_mainX_t)
return true; return true;

View File

@ -45,8 +45,8 @@ class TASInputDlg : public wxDialog
void SetTurboFalse(wxMouseEvent& event); void SetTurboFalse(wxMouseEvent& event);
void ButtonTurbo(); void ButtonTurbo();
void GetKeyBoardInput(SPADStatus *PadStatus); void GetKeyBoardInput(SPADStatus *PadStatus);
bool TextBoxHasFocus(); virtual bool TextBoxHasFocus() const;
bool HasFocus(); virtual bool HasFocus() const;
wxBitmap CreateStickBitmap(int x, int y); wxBitmap CreateStickBitmap(int x, int y);

View File

@ -252,6 +252,14 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
wxFlexGridSizer* const szr_display = new wxFlexGridSizer(2, 5, 5); wxFlexGridSizer* const szr_display = new wxFlexGridSizer(2, 5, 5);
{ {
#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
NSView *view = (NSView *) parent->GetHandle();
NSWindow *window = [view window];
if (![window respondsToSelector:@selector(toggleFullScreen:)])
#endif
// display resolution // display resolution
{ {
wxArrayString res_list = GetListOfResolutions(); wxArrayString res_list = GetListOfResolutions();