Implement wxColourDisplay() in terms of wxDisplay::GetDepth()

Get rid of another global display-related function, even though this one
only had non-trivial implementation under MSW.
This commit is contained in:
Vadim Zeitlin
2018-10-06 16:14:45 +02:00
parent 382404f0a7
commit e3e883bbd2
10 changed files with 11 additions and 62 deletions

View File

@@ -1183,6 +1183,10 @@ const wxSize wxDefaultSize;
/**
Returns @true if the display is colour, @false otherwise.
@note Use of this function is not recommended in the new code as it only
works for the primary display. Use wxDisplay::GetDepth() to retrieve
the depth of the appropriate display and compare it with 1 instead.
@header{wx/gdicmn.h}
*/
bool wxColourDisplay();

View File

@@ -850,6 +850,13 @@ int wxDisplayDepth()
return wxDisplay().GetDepth();
}
bool wxColourDisplay()
{
// If GetDepth() returns 0, meaning unknown, we assume it's a colour
// display, hence the use of "!=" rather than ">" here.
return wxDisplay().GetDepth() != 1;
}
void wxDisplaySize(int *width, int *height)
{
const wxSize size = wxGetDisplaySize();

View File

@@ -89,12 +89,6 @@ wxDisplayFactory* wxDisplay::CreateFactory()
return new wxDisplayFactorySingleDFB;
}
bool wxColourDisplay()
{
#warning "FIXME: wxColourDisplay"
return true;
}
void wxDisplaySizeMM(int *width, int *height)
{
// FIXME: there's no way to get physical resolution using the DirectDB

View File

@@ -90,11 +90,6 @@ void wxDisplaySizeMM( int *width, int *height )
#endif
}
bool wxColourDisplay()
{
return true;
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
return wxGenericFindWindowAtPoint(pt);

View File

@@ -97,11 +97,6 @@ void wxGetMousePosition( int* x, int* y )
gdk_window_get_pointer( NULL, x, y, NULL );
}
bool wxColourDisplay()
{
return true;
}
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
{
return wxGenericFindWindowAtPoint(pt);

View File

@@ -225,12 +225,6 @@ void wxGetMousePosition( int* x, int* y )
#endif
}
// Return true if we have a colour display
bool wxColourDisplay()
{
return wxDisplayDepth() > 1;
}
void wxDisplaySizeMM(int *width, int *height)
{
Display *dpy = wxGlobalDisplay();

View File

@@ -117,27 +117,6 @@ void wxGetMousePosition( int* x, int* y )
if ( y ) *y = pt.y;
}
// Return true if we have a colour display
bool wxColourDisplay()
{
// this function is called from wxDC ctor so it is called a *lot* of times
// hence we optimize it a bit but doing the check only once
//
// this should be MT safe as only the GUI thread (holding the GUI mutex)
// can call us
static int s_isColour = -1;
if ( s_isColour == -1 )
{
ScreenHDC dc;
int noCols = ::GetDeviceCaps(dc, NUMCOLORS);
s_isColour = (noCols == -1) || (noCols > 2);
}
return s_isColour != 0;
}
void wxDisplaySizeMM(int *width, int *height)
{
ScreenHDC dc;

View File

@@ -53,14 +53,6 @@ bool wxCheckForInterrupt(wxWindow *WXUNUSED(wnd))
return false;
}
// Return true if we have a colour display
bool wxColourDisplay()
{
// always the case on OS X
return true;
}
#if wxOSX_USE_COCOA_OR_CARBON
#if wxUSE_GUI

View File

@@ -140,11 +140,6 @@ wxWindow *wxGetActiveWindow()
return NULL;
}
bool wxColourDisplay()
{
return QApplication::desktop()->depth() > 1;
}
bool wxLaunchDefaultApplication(const wxString& path, int WXUNUSED( flags ) )
{
return QDesktopServices::openUrl( QUrl::fromLocalFile( wxQtConvertString( path ) ) );

View File

@@ -148,12 +148,6 @@ void wxGetMousePosition( int* x, int* y )
#endif
};
// Return true if we have a colour display
bool wxColourDisplay()
{
return wxDisplayDepth() > 1;
}
void wxDisplaySizeMM(int *width, int *height)
{
Display *dpy = (Display*) wxGetDisplay();