X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ef1717a963dfb76bac26b9f4277ae590b3c0a2e6..3cfcae3b4d5a8a84c19d74a211a97da47ffe0dc6:/src/mac/carbon/display.cpp diff --git a/src/mac/carbon/display.cpp b/src/mac/carbon/display.cpp index 79c727f1f1..3e9d8d50a1 100644 --- a/src/mac/carbon/display.cpp +++ b/src/mac/carbon/display.cpp @@ -25,9 +25,13 @@ #if wxUSE_DISPLAY +#include "wx/display.h" + #ifndef WX_PRECOMP - #include "wx/dynarray.h" - #include "wx/log.h" + #include "wx/dynarray.h" + #include "wx/log.h" + #include "wx/string.h" + #include "wx/gdicmn.h" #endif #ifdef __DARWIN__ @@ -41,10 +45,7 @@ #include #endif -#include "wx/display.h" #include "wx/display_impl.h" -#include "wx/gdicmn.h" -#include "wx/string.h" // ---------------------------------------------------------------------------- // display classes implementation @@ -55,9 +56,14 @@ class wxDisplayImplMacOSX : public wxDisplayImpl { public: - wxDisplayImplMacOSX(CGDirectDisplayID id) : m_id(id) { } + wxDisplayImplMacOSX(unsigned n, CGDirectDisplayID id) + : wxDisplayImpl(n), + m_id(id) + { + } virtual wxRect GetGeometry() const; + virtual wxRect GetClientArea() const; virtual wxString GetName() const { return wxString(); } virtual wxArrayVideoModes GetModes(const wxVideoMode& mode) const; @@ -73,10 +79,10 @@ private: class wxDisplayFactoryMacOSX : public wxDisplayFactory { public: - wxDisplayFactoryMacOSX(); + wxDisplayFactoryMacOSX() {} - virtual wxDisplayImpl *CreateDisplay(size_t n); - virtual size_t GetCount(); + virtual wxDisplayImpl *CreateDisplay(unsigned n); + virtual unsigned GetCount(); virtual int GetFromPoint(const wxPoint& pt); protected: @@ -87,7 +93,7 @@ protected: // wxDisplayFactoryMacOSX implementation // ============================================================================ -size_t wxDisplayFactoryMacOSX::GetCount() +unsigned wxDisplayFactoryMacOSX::GetCount() { CGDisplayCount count; #ifdef __WXDEBUG__ @@ -135,7 +141,7 @@ int wxDisplayFactoryMacOSX::GetFromPoint(const wxPoint& p) return nWhich; } -wxDisplayImpl *wxDisplayFactoryMacOSX::CreateDisplay(size_t n) +wxDisplayImpl *wxDisplayFactoryMacOSX::CreateDisplay(unsigned n) { CGDisplayCount theCount = GetCount(); CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount]; @@ -148,7 +154,7 @@ wxDisplayImpl *wxDisplayFactoryMacOSX::CreateDisplay(size_t n) wxASSERT( err == CGDisplayNoErr ); wxASSERT( n < theCount ); - wxDisplayImplMacOSX *display = new wxDisplayImplMacOSX(theIDs[n]); + wxDisplayImplMacOSX *display = new wxDisplayImplMacOSX(n, theIDs[n]); delete [] theIDs; @@ -168,6 +174,17 @@ wxRect wxDisplayImplMacOSX::GetGeometry() const (int)theRect.size.height ); //floats } +wxRect wxDisplayImplMacOSX::GetClientArea() const +{ + // VZ: I don't know how to get client area for arbitrary display but + // wxGetClientDisplayRect() does work correctly for at least the main + // one (TODO: do it correctly for the other displays too) + if ( IsPrimary() ) + return wxGetClientDisplayRect(); + + return wxDisplayImpl::GetClientArea(); +} + static int wxCFDictKeyToInt( CFDictionaryRef desc, CFStringRef key ) { CFNumberRef value = (CFNumberRef) CFDictionaryGetValue( desc, key ); @@ -251,7 +268,11 @@ bool wxDisplayImplMacOSX::ChangeMode( const wxVideoMode& mode ) class wxDisplayImplMac : public wxDisplayImpl { public: - wxDisplayImplMac(GDHandle hndl) : m_hndl(hndl) { } + wxDisplayImplMac(unsigned n, GDHandle hndl) + : wxDisplayImpl(n), + m_hndl(hndl) + { + } virtual wxRect GetGeometry() const; virtual wxString GetName() const { return wxString(); } @@ -271,8 +292,8 @@ class wxDisplayFactoryMac : public wxDisplayFactory public: wxDisplayFactoryMac(); - virtual wxDisplayImpl *CreateDisplay(size_t n); - virtual size_t GetCount(); + virtual wxDisplayImpl *CreateDisplay(unsigned n); + virtual unsigned GetCount(); virtual int GetFromPoint(const wxPoint& pt); protected: @@ -283,9 +304,9 @@ protected: // wxDisplayFactoryMac implementation // ============================================================================ -size_t wxDisplayFactoryMac::GetCount() +unsigned wxDisplayFactoryMac::GetCount() { - size_t num = 0; + unsigned num = 0; GDHandle hndl = DMGetFirstScreenDevice(true); while(hndl) { @@ -297,7 +318,7 @@ size_t wxDisplayFactoryMac::GetCount() int wxDisplayFactoryMac::GetFromPoint(const wxPoint &p) { - size_t num = 0; + unsigned num = 0; GDHandle hndl = DMGetFirstScreenDevice(true); while(hndl) { @@ -316,14 +337,16 @@ int wxDisplayFactoryMac::GetFromPoint(const wxPoint &p) return wxNOT_FOUND; } -wxDisplayImpl *wxDisplayFactoryMac::CreateDisplay(size_t n) +wxDisplayImpl *wxDisplayFactoryMac::CreateDisplay(unsigned n) { + unsigned nOrig = n; + GDHandle hndl = DMGetFirstScreenDevice(true); while(hndl) { if (n == 0) { - return new wxDisplayImplMac(hndl); + return new wxDisplayImplMac(nOrig, hndl); } n--; hndl = DMGetNextScreenDevice(hndl, true);