Applied patch [ 573644 ] wxDisplay for Mac (again)
Applied patch [ 573172 ] Implements wxDisplay for mac Applied patch [ 573356 ] wxDisplay for MSW Alterations: Put sample in regular samples, not contrib Removed multimon.h for copyright reasons git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16217 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
81
include/wx/display.h
Normal file
81
include/wx/display.h
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: display.h
|
||||||
|
// Purpose: wxDisplay class
|
||||||
|
// Author: Royce Mitchell III
|
||||||
|
// Modified by:
|
||||||
|
// Created: 06/21/02
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) wxWindows team
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_DISPLAY_H_BASE_
|
||||||
|
#define _WX_DISPLAY_H_BASE_
|
||||||
|
|
||||||
|
#if wxUSE_DISPLAY
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface "display.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class wxPoint;
|
||||||
|
class wxRect;
|
||||||
|
class wxString;
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxDisplayBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// initialize the object containing all information about the given
|
||||||
|
// display
|
||||||
|
wxDisplayBase ( size_t index = 0 ) : m_index ( index )
|
||||||
|
{
|
||||||
|
wxASSERT_MSG(m_index < wxDisplayBase::GetCount(), wxT("An invalid index was passed to wxDisplay"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// accessors
|
||||||
|
|
||||||
|
// return the number of available displays, valid parameters to
|
||||||
|
// wxDisplay ctor are from 0 up to this number
|
||||||
|
static size_t GetCount();
|
||||||
|
|
||||||
|
// find the display where the given point lies, return -1 if
|
||||||
|
// it doesn't belong to any display
|
||||||
|
static int GetFromPoint ( const wxPoint& pt );
|
||||||
|
|
||||||
|
virtual wxRect GetGeometry() const = 0;
|
||||||
|
virtual int GetDepth() const = 0;
|
||||||
|
bool IsColour() const { return GetDepth() != 1; }
|
||||||
|
|
||||||
|
// some people never learn to spell ;-)
|
||||||
|
bool IsColor() const { return IsColour(); }
|
||||||
|
|
||||||
|
// name may be empty
|
||||||
|
virtual wxString GetName() const = 0;
|
||||||
|
|
||||||
|
// let display 0 always be the primary display
|
||||||
|
bool IsPrimary() { return m_index == 0; }
|
||||||
|
|
||||||
|
|
||||||
|
virtual ~wxDisplayBase() {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
size_t m_index; // which display did we select when creating this file?
|
||||||
|
|
||||||
|
DECLARE_NO_COPY_CLASS(wxDisplayBase);
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(__WXMSW__)
|
||||||
|
#include "wx/msw/display.h"
|
||||||
|
#elif defined(__WXMOTIF__)
|
||||||
|
#include "wx/motif/display.h"
|
||||||
|
#elif defined(__WXGTK__)
|
||||||
|
#include "wx/gtk/display.h"
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
|
#include "wx/mac/display.h"
|
||||||
|
#elif defined(__WXPM__)
|
||||||
|
#include "wx/os2/display.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // wxUSE_DISPLAY
|
||||||
|
|
||||||
|
#endif // _WX_DISPLAY_H_BASE_
|
40
include/wx/mac/display.h
Normal file
40
include/wx/mac/display.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: display.h
|
||||||
|
// Purpose: wxDisplay class customization for Mac
|
||||||
|
// Author: Brian Victor
|
||||||
|
// Modified by: Royce Mitchell III
|
||||||
|
// Created: 06/21/02
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) wxWindows team
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_MAC_DISPLAY_H_
|
||||||
|
#define _WX_MAC_DISPLAY_H_
|
||||||
|
|
||||||
|
#include "wx/object.h"
|
||||||
|
#include "wx/display.h"
|
||||||
|
|
||||||
|
class wxDisplayMacPriv;
|
||||||
|
class wxRect;
|
||||||
|
class wxString;
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxDisplay : public wxDisplayBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxDisplay ( size_t index = 0 );
|
||||||
|
|
||||||
|
virtual wxRect GetGeometry() const;
|
||||||
|
virtual int GetDepth() const;
|
||||||
|
virtual wxString GetName() const;
|
||||||
|
|
||||||
|
|
||||||
|
~wxDisplay();
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDisplayMacPriv* m_priv;
|
||||||
|
|
||||||
|
DECLARE_NO_COPY_CLASS(wxDisplay);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _WX_MAC_DISPLAY_H_
|
27
include/wx/msw/display.h
Normal file
27
include/wx/msw/display.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: display.h
|
||||||
|
// Purpose: wxDisplay class customization for WXMSW
|
||||||
|
// Author: Royce Mitchell III
|
||||||
|
// Modified by:
|
||||||
|
// Created: 06/21/02
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) wxWindows team
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_MSW_DISPLAY_H_
|
||||||
|
#define _WX_MSW_DISPLAY_H_
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxDisplay : public wxDisplayBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxDisplay ( size_t index = 0 );
|
||||||
|
|
||||||
|
virtual wxRect GetGeometry() const;
|
||||||
|
virtual int GetDepth() const;
|
||||||
|
virtual wxString GetName() const;
|
||||||
|
|
||||||
|
DECLARE_NO_COPY_CLASS(wxDisplay);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _WX_MSW_DISPLAY_H_
|
39
samples/multimon/multimon_test.cpp
Normal file
39
samples/multimon/multimon_test.cpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: multimon_test.cpp
|
||||||
|
// Purpose: tests wxDisplay class
|
||||||
|
// Author: Royce Mitchell III
|
||||||
|
// Modified by:
|
||||||
|
// Created: 06/21/02
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) wxWindows team
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#define wxUSE_DISPLAY 1
|
||||||
|
#include <wx/display.h>
|
||||||
|
|
||||||
|
class TestApp : public wxApp
|
||||||
|
{
|
||||||
|
bool OnInit();
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_APP(TestApp)
|
||||||
|
IMPLEMENT_APP(TestApp)
|
||||||
|
|
||||||
|
bool TestApp::OnInit()
|
||||||
|
{
|
||||||
|
size_t count = wxDisplay::GetCount();
|
||||||
|
wxLogDebug ( "I detected %i display(s) on your system", count );
|
||||||
|
size_t i = 0;
|
||||||
|
while ( i < count )
|
||||||
|
{
|
||||||
|
wxDisplay display ( i );
|
||||||
|
wxRect r = display.GetGeometry();
|
||||||
|
wxLogDebug ( "Display #%i \"%s\" = ( %i, %i, %i, %i ) @ %i bits",
|
||||||
|
i, display.GetName().c_str(), r.GetLeft(), r.GetTop(), r.GetWidth(), r.GetHeight(),
|
||||||
|
display.GetDepth() );
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
114
samples/multimon/multimon_test.dsp
Normal file
114
samples/multimon/multimon_test.dsp
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
# Microsoft Developer Studio Project File - Name="multimon_test" - Package Owner=<4>
|
||||||
|
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||||
|
# ** DO NOT EDIT **
|
||||||
|
|
||||||
|
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||||
|
|
||||||
|
CFG=multimon_test - Win32 Debug
|
||||||
|
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||||
|
!MESSAGE use the Export Makefile command and run
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "multimon_test.mak".
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE You can specify a configuration when running NMAKE
|
||||||
|
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE NMAKE /f "multimon_test.mak" CFG="multimon_test - Win32 Debug"
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE Possible choices for configuration are:
|
||||||
|
!MESSAGE
|
||||||
|
!MESSAGE "multimon_test - Win32 Release" (based on "Win32 (x86) Application")
|
||||||
|
!MESSAGE "multimon_test - Win32 Debug" (based on "Win32 (x86) Application")
|
||||||
|
!MESSAGE
|
||||||
|
|
||||||
|
# Begin Project
|
||||||
|
# PROP AllowPerConfigDependencies 0
|
||||||
|
# PROP Scc_ProjName ""
|
||||||
|
# PROP Scc_LocalPath ""
|
||||||
|
CPP=cl.exe
|
||||||
|
MTL=midl.exe
|
||||||
|
RSC=rc.exe
|
||||||
|
|
||||||
|
!IF "$(CFG)" == "multimon_test - Win32 Release"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 0
|
||||||
|
# PROP BASE Output_Dir "Release"
|
||||||
|
# PROP BASE Intermediate_Dir "Release"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 0
|
||||||
|
# PROP Output_Dir "Release"
|
||||||
|
# PROP Intermediate_Dir "Release"
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||||
|
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||||
|
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
|
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||||
|
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "multimon_test - Win32 Debug"
|
||||||
|
|
||||||
|
# PROP BASE Use_MFC 0
|
||||||
|
# PROP BASE Use_Debug_Libraries 1
|
||||||
|
# PROP BASE Output_Dir "multimon_test___Win32_Debug"
|
||||||
|
# PROP BASE Intermediate_Dir "multimon_test___Win32_Debug"
|
||||||
|
# PROP BASE Target_Dir ""
|
||||||
|
# PROP Use_MFC 0
|
||||||
|
# PROP Use_Debug_Libraries 1
|
||||||
|
# PROP Output_Dir "Debug"
|
||||||
|
# PROP Intermediate_Dir "Debug"
|
||||||
|
# PROP Ignore_Export_Lib 0
|
||||||
|
# PROP Target_Dir ""
|
||||||
|
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||||
|
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_WIN32" /D "DEBUG" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "__WIN95__" /D "__WIN32__" /D "__WXMSW__" /D "__WINDOWS__" /D "__WXDEBUG__" /D WXUSINGDLL=1 /YX /FD /GZ /c
|
||||||
|
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||||
|
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||||
|
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||||
|
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||||
|
BSC32=bscmake.exe
|
||||||
|
# ADD BASE BSC32 /nologo
|
||||||
|
# ADD BSC32 /nologo
|
||||||
|
LINK32=link.exe
|
||||||
|
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
|
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wx22_9d.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||||
|
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
# Begin Target
|
||||||
|
|
||||||
|
# Name "multimon_test - Win32 Release"
|
||||||
|
# Name "multimon_test - Win32 Debug"
|
||||||
|
# Begin Group "Source Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\multimon_test.cpp
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Header Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\include\wx\display.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\include\wx\msw\display.h
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Resource Files"
|
||||||
|
|
||||||
|
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||||
|
# End Group
|
||||||
|
# End Target
|
||||||
|
# End Project
|
29
samples/multimon/multimon_test.dsw
Normal file
29
samples/multimon/multimon_test.dsw
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||||
|
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Project: "multimon_test"=.\multimon_test.dsp - Package Owner=<4>
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<4>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
Global:
|
||||||
|
|
||||||
|
Package=<5>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
Package=<3>
|
||||||
|
{{{
|
||||||
|
}}}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
135
src/mac/carbon/display.cpp
Normal file
135
src/mac/carbon/display.cpp
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: display.cpp
|
||||||
|
// Purpose: Mac implementation of wxDisplay class
|
||||||
|
// Author: Brian Victor
|
||||||
|
// Modified by: Royce Mitchell III
|
||||||
|
// Created: 06/21/02
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) wxWindows team
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "display.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_DISPLAY
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/dynarray.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __DARWIN__
|
||||||
|
#include <Carbon/Carbon.h>
|
||||||
|
#else
|
||||||
|
#include <Displays.h>
|
||||||
|
#include <Quickdraw.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/display.h"
|
||||||
|
#include "wx/gdicmn.h"
|
||||||
|
#include "wx/string.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxDisplayMacPriv
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GDHandle m_hndl;
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t wxDisplayBase::GetCount()
|
||||||
|
{
|
||||||
|
GDHandle hndl;
|
||||||
|
size_t num = 0;
|
||||||
|
hndl = DMGetFirstScreenDevice(true);
|
||||||
|
while(hndl)
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
hndl = DMGetNextScreenDevice(hndl, true);
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxDisplayBase::GetFromPoint(const wxPoint &p)
|
||||||
|
{
|
||||||
|
GDHandle hndl;
|
||||||
|
size_t num = 0;
|
||||||
|
hndl = DMGetFirstScreenDevice(true);
|
||||||
|
while(hndl)
|
||||||
|
{
|
||||||
|
Rect screenrect = (*hndl)->gdRect;
|
||||||
|
if (p.x >= screenrect.left &&
|
||||||
|
p.x <= screenrect.right &&
|
||||||
|
p.y >= screenrect.top &&
|
||||||
|
p.y <= screenrect.bottom)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
num++;
|
||||||
|
hndl = DMGetNextScreenDevice(hndl, true);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDisplay::wxDisplay(size_t index) : wxDisplayBase ( index ),
|
||||||
|
m_priv ( new wxDisplayMacPriv() )
|
||||||
|
{
|
||||||
|
GDHandle hndl;
|
||||||
|
hndl = DMGetFirstScreenDevice(true);
|
||||||
|
m_priv->m_hndl = NULL;
|
||||||
|
while(hndl)
|
||||||
|
{
|
||||||
|
if (index == 0)
|
||||||
|
{
|
||||||
|
m_priv->m_hndl = hndl;
|
||||||
|
}
|
||||||
|
index--;
|
||||||
|
hndl = DMGetNextScreenDevice(hndl, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRect wxDisplay::GetGeometry() const
|
||||||
|
{
|
||||||
|
if (!(m_priv)) return wxRect(0, 0, 0, 0);
|
||||||
|
if (!(m_priv->m_hndl)) return wxRect(0, 0, 0, 0);
|
||||||
|
Rect screenrect = (*(m_priv->m_hndl))->gdRect;
|
||||||
|
return wxRect( screenrect.left, screenrect.top,
|
||||||
|
screenrect.right - screenrect.left, screenrect.bottom - screenrect.top);
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxDisplay::GetDepth() const
|
||||||
|
{
|
||||||
|
if (!(m_priv)) return 0;
|
||||||
|
if (!(m_priv->m_hndl)) return 0;
|
||||||
|
|
||||||
|
// This cryptic looking code is based on Apple's sample code:
|
||||||
|
// http://developer.apple.com/samplecode/Sample_Code/Graphics_2D/GDevVideo/Gen.cp.htm
|
||||||
|
return ((*(*(m_priv->m_hndl))->gdPMap)->pixelSize) & 0x0000FFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxDisplay::GetName() const
|
||||||
|
{
|
||||||
|
// Macs don't name their displays...
|
||||||
|
return wxT("");
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDisplay::~wxDisplay()
|
||||||
|
{
|
||||||
|
if ( m_priv )
|
||||||
|
{
|
||||||
|
delete m_priv;
|
||||||
|
m_priv = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_DISPLAY
|
135
src/mac/display.cpp
Normal file
135
src/mac/display.cpp
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: display.cpp
|
||||||
|
// Purpose: Mac implementation of wxDisplay class
|
||||||
|
// Author: Brian Victor
|
||||||
|
// Modified by: Royce Mitchell III
|
||||||
|
// Created: 06/21/02
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) wxWindows team
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "display.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_DISPLAY
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/dynarray.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __DARWIN__
|
||||||
|
#include <Carbon/Carbon.h>
|
||||||
|
#else
|
||||||
|
#include <Displays.h>
|
||||||
|
#include <Quickdraw.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/display.h"
|
||||||
|
#include "wx/gdicmn.h"
|
||||||
|
#include "wx/string.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxDisplayMacPriv
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GDHandle m_hndl;
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t wxDisplayBase::GetCount()
|
||||||
|
{
|
||||||
|
GDHandle hndl;
|
||||||
|
size_t num = 0;
|
||||||
|
hndl = DMGetFirstScreenDevice(true);
|
||||||
|
while(hndl)
|
||||||
|
{
|
||||||
|
num++;
|
||||||
|
hndl = DMGetNextScreenDevice(hndl, true);
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxDisplayBase::GetFromPoint(const wxPoint &p)
|
||||||
|
{
|
||||||
|
GDHandle hndl;
|
||||||
|
size_t num = 0;
|
||||||
|
hndl = DMGetFirstScreenDevice(true);
|
||||||
|
while(hndl)
|
||||||
|
{
|
||||||
|
Rect screenrect = (*hndl)->gdRect;
|
||||||
|
if (p.x >= screenrect.left &&
|
||||||
|
p.x <= screenrect.right &&
|
||||||
|
p.y >= screenrect.top &&
|
||||||
|
p.y <= screenrect.bottom)
|
||||||
|
{
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
num++;
|
||||||
|
hndl = DMGetNextScreenDevice(hndl, true);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDisplay::wxDisplay(size_t index) : wxDisplayBase ( index ),
|
||||||
|
m_priv ( new wxDisplayMacPriv() )
|
||||||
|
{
|
||||||
|
GDHandle hndl;
|
||||||
|
hndl = DMGetFirstScreenDevice(true);
|
||||||
|
m_priv->m_hndl = NULL;
|
||||||
|
while(hndl)
|
||||||
|
{
|
||||||
|
if (index == 0)
|
||||||
|
{
|
||||||
|
m_priv->m_hndl = hndl;
|
||||||
|
}
|
||||||
|
index--;
|
||||||
|
hndl = DMGetNextScreenDevice(hndl, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRect wxDisplay::GetGeometry() const
|
||||||
|
{
|
||||||
|
if (!(m_priv)) return wxRect(0, 0, 0, 0);
|
||||||
|
if (!(m_priv->m_hndl)) return wxRect(0, 0, 0, 0);
|
||||||
|
Rect screenrect = (*(m_priv->m_hndl))->gdRect;
|
||||||
|
return wxRect( screenrect.left, screenrect.top,
|
||||||
|
screenrect.right - screenrect.left, screenrect.bottom - screenrect.top);
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxDisplay::GetDepth() const
|
||||||
|
{
|
||||||
|
if (!(m_priv)) return 0;
|
||||||
|
if (!(m_priv->m_hndl)) return 0;
|
||||||
|
|
||||||
|
// This cryptic looking code is based on Apple's sample code:
|
||||||
|
// http://developer.apple.com/samplecode/Sample_Code/Graphics_2D/GDevVideo/Gen.cp.htm
|
||||||
|
return ((*(*(m_priv->m_hndl))->gdPMap)->pixelSize) & 0x0000FFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxDisplay::GetName() const
|
||||||
|
{
|
||||||
|
// Macs don't name their displays...
|
||||||
|
return wxT("");
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDisplay::~wxDisplay()
|
||||||
|
{
|
||||||
|
if ( m_priv )
|
||||||
|
{
|
||||||
|
delete m_priv;
|
||||||
|
m_priv = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_DISPLAY
|
232
src/msw/display.cpp
Normal file
232
src/msw/display.cpp
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: display.cpp
|
||||||
|
// Purpose: MSW Implementation of wxDisplay class
|
||||||
|
// Author: Royce Mitchell III
|
||||||
|
// Modified by:
|
||||||
|
// Created: 06/21/02
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) wxWindows team
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
// declarations
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "display.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_DISPLAY
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/dynarray.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/display.h"
|
||||||
|
|
||||||
|
// the following define is necessary to access the multi-monitor function
|
||||||
|
// declarations in a manner safe to use w/ Windows 95
|
||||||
|
// JACS: not used for now until we're clear about the legality
|
||||||
|
// of distributing multimon.h. Meanwhile you can download the file
|
||||||
|
// yourself from:
|
||||||
|
// http://www.microsoft.com/msj/0697/monitor/monitortextfigs.htm#fig4
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define COMPILE_MULTIMON_STUBS
|
||||||
|
#include "wx/msw/multimon.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// private functions
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxmswInitDisplayRectArray();
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxmswDisplayInfo;
|
||||||
|
|
||||||
|
WX_DECLARE_OBJARRAY(wxmswDisplayInfo, wxmswDisplayInfoArray);
|
||||||
|
|
||||||
|
class wxmswDisplayInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HMONITOR m_hmon;
|
||||||
|
DISPLAY_DEVICE m_dd;
|
||||||
|
wxRect m_rect;
|
||||||
|
int m_depth;
|
||||||
|
};
|
||||||
|
|
||||||
|
wxmswDisplayInfoArray* g_wxmswDisplayInfoArray = 0;
|
||||||
|
|
||||||
|
#include <wx/arrimpl.cpp> // this is a magic incantation which must be done!
|
||||||
|
WX_DEFINE_OBJARRAY(wxmswDisplayInfoArray);
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
// implementation
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
BOOL CALLBACK wxmswMonitorEnumProc (
|
||||||
|
HMONITOR hMonitor, // handle to display monitor
|
||||||
|
HDC hdcMonitor, // handle to monitor-appropriate device context
|
||||||
|
LPRECT lprcMonitor, // pointer to monitor intersection rectangle
|
||||||
|
LPARAM dwData // data passed from EnumDisplayMonitors
|
||||||
|
)
|
||||||
|
{
|
||||||
|
wxmswDisplayInfo* info = new wxmswDisplayInfo();
|
||||||
|
info->m_hmon = hMonitor;
|
||||||
|
info->m_rect.SetX ( lprcMonitor->left );
|
||||||
|
info->m_rect.SetY ( lprcMonitor->top );
|
||||||
|
info->m_rect.SetWidth ( lprcMonitor->right - lprcMonitor->left );
|
||||||
|
info->m_rect.SetHeight ( lprcMonitor->bottom - lprcMonitor->top );
|
||||||
|
// now add this monitor to the array
|
||||||
|
g_wxmswDisplayInfoArray->Add ( info );
|
||||||
|
|
||||||
|
return TRUE; // continue the enumeration
|
||||||
|
}
|
||||||
|
|
||||||
|
class wxmswDisplayModule : public wxModule
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxmswDisplayModule)
|
||||||
|
public:
|
||||||
|
wxmswDisplayModule() {}
|
||||||
|
bool OnInit();
|
||||||
|
void OnExit();
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxmswDisplayModule, wxModule)
|
||||||
|
|
||||||
|
bool wxmswDisplayModule::OnInit()
|
||||||
|
{
|
||||||
|
g_wxmswDisplayInfoArray = new wxmswDisplayInfoArray();
|
||||||
|
if ( !g_wxmswDisplayInfoArray )
|
||||||
|
{
|
||||||
|
wxFAIL_MSG(wxT("Couldn't allocate array for display information"));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Royce3: I'm assuming that the monitor's are enumerated in the same
|
||||||
|
// order as the calls to EnumDisplayDevices below. We shall soon see
|
||||||
|
// if that assumption is correct.
|
||||||
|
if ( !EnumDisplayMonitors ( NULL, NULL, wxmswMonitorEnumProc, 0 ) )
|
||||||
|
wxLogLastError(wxT("EnumDisplayMonitors"));
|
||||||
|
|
||||||
|
size_t iDevNum = 0, count = g_wxmswDisplayInfoArray->Count();
|
||||||
|
while ( iDevNum < count )
|
||||||
|
{
|
||||||
|
wxmswDisplayInfo& info = (*g_wxmswDisplayInfoArray)[iDevNum];
|
||||||
|
|
||||||
|
// MSDN: Before calling EnumDisplayDevices, you must initialize the cb
|
||||||
|
// member of DISPLAY_DEVICE to the size, in bytes, of DISPLAY_DEVICE
|
||||||
|
info.m_dd.cb = sizeof(info.m_dd);
|
||||||
|
|
||||||
|
if ( !EnumDisplayDevices ( NULL, iDevNum, &info.m_dd, 0 ) )
|
||||||
|
wxLogLastError(wxT("EnumDisplayDevices"));
|
||||||
|
|
||||||
|
// get this display's Depth
|
||||||
|
DEVMODE devmode;
|
||||||
|
memset ( &devmode, 0, sizeof(devmode) );
|
||||||
|
|
||||||
|
// MSDN: Before calling EnumDisplaySettings, set the dmSize member to
|
||||||
|
// sizeof(DEVMODE), and set the dmDriverExtra member to indicate the size,
|
||||||
|
// in bytes, of the additional space available to receive private
|
||||||
|
// driver-data.
|
||||||
|
devmode.dmSize = sizeof(devmode);
|
||||||
|
devmode.dmDriverExtra = 0;
|
||||||
|
|
||||||
|
if ( !EnumDisplaySettings ( info.m_dd.DeviceName, ENUM_CURRENT_SETTINGS, &devmode ) )
|
||||||
|
{
|
||||||
|
wxLogLastError(wxT("EnumDisplaySettings"));
|
||||||
|
devmode.dmFields = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !(devmode.dmFields&DM_BITSPERPEL) )
|
||||||
|
info.m_depth = -1;
|
||||||
|
else
|
||||||
|
info.m_depth = devmode.dmBitsPerPel;
|
||||||
|
|
||||||
|
|
||||||
|
iDevNum++;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxmswDisplayModule::OnExit()
|
||||||
|
{
|
||||||
|
size_t count = g_wxmswDisplayInfoArray->Count();
|
||||||
|
while ( count-- )
|
||||||
|
{
|
||||||
|
wxmswDisplayInfo* info = g_wxmswDisplayInfoArray->Detach ( count );
|
||||||
|
delete info;
|
||||||
|
}
|
||||||
|
delete g_wxmswDisplayInfoArray;
|
||||||
|
g_wxmswDisplayInfoArray = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// wxDisplay
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
size_t wxDisplayBase::GetCount()
|
||||||
|
{
|
||||||
|
return GetSystemMetrics ( SM_CMONITORS );
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxDisplayBase::GetFromPoint ( const wxPoint& pt )
|
||||||
|
{
|
||||||
|
POINT pt2;
|
||||||
|
pt2.x = pt.x;
|
||||||
|
pt2.y = pt.y;
|
||||||
|
|
||||||
|
HMONITOR hmon = MonitorFromPoint ( pt2, 0 );
|
||||||
|
if ( !hmon )
|
||||||
|
return -1;
|
||||||
|
size_t count = wxDisplayBase::GetCount(), index;
|
||||||
|
|
||||||
|
for ( index = 0; index < count; index++ )
|
||||||
|
{
|
||||||
|
if ( hmon == (*g_wxmswDisplayInfoArray)[index].m_hmon )
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDisplay::wxDisplay ( size_t index ) : wxDisplayBase ( index )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRect wxDisplay::GetGeometry() const
|
||||||
|
{
|
||||||
|
return (*g_wxmswDisplayInfoArray)[m_index].m_rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxDisplay::GetDepth() const
|
||||||
|
{
|
||||||
|
return (*g_wxmswDisplayInfoArray)[m_index].m_depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxDisplay::GetName() const
|
||||||
|
{
|
||||||
|
return wxString ( (*g_wxmswDisplayInfoArray)[m_index].m_dd.DeviceName );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif//wxUSE_DISPLAY
|
Reference in New Issue
Block a user