From 4f26bc4784443a530d322c7d04f9b294942d3c14 Mon Sep 17 00:00:00 2001 From: Gilles Depeyrot Date: Wed, 28 May 2003 20:08:24 +0000 Subject: [PATCH] allow wxDisplaySize to be called with NULL parameters implement GetMetric for wxSYS_SCREEN_X & wxSYS_SCREEN_X using wxDisplaySize git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20753 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/settings.cpp | 15 +++++++----- src/mac/carbon/utils.cpp | 49 +++++++++++++++++++++++++------------ src/mac/settings.cpp | 15 +++++++----- src/mac/utils.cpp | 49 +++++++++++++++++++++++++------------ 4 files changed, 84 insertions(+), 44 deletions(-) diff --git a/src/mac/carbon/settings.cpp b/src/mac/carbon/settings.cpp index 5c3cc0990b..dcfab47793 100644 --- a/src/mac/carbon/settings.cpp +++ b/src/mac/carbon/settings.cpp @@ -151,13 +151,16 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) // Get a system metric, e.g. scrollbar size int wxSystemSettingsNative::GetMetric(wxSystemMetric index) { + int value; + switch ( index) { case wxSYS_MOUSE_BUTTONS: - return 2; // we emulate a two button mouse (ctrl + click = right button ) + // we emulate a two button mouse (ctrl + click = right button ) + return 2; case wxSYS_BORDER_X: // TODO - return 0; + return 0; case wxSYS_BORDER_Y: // TODO return 0; @@ -210,11 +213,11 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index) // TODO return 0; case wxSYS_SCREEN_X: - // TODO - return 0; + wxDisplaySize(&value, NULL); + return value; case wxSYS_SCREEN_Y: - // TODO - return 0; + wxDisplaySize(NULL, &value); + return value; case wxSYS_FRAMESIZE_X: // TODO return 0; diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index ad685519dd..4e31d12476 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -450,11 +450,15 @@ int wxDisplayDepth() // Get size of display void wxDisplaySize(int *width, int *height) { - BitMap screenBits; - GetQDGlobalsScreenBits( &screenBits ); + BitMap screenBits; + GetQDGlobalsScreenBits( &screenBits ); - *width = screenBits.bounds.right - screenBits.bounds.left ; - *height = screenBits.bounds.bottom - screenBits.bounds.top ; + if (width != NULL) { + *width = screenBits.bounds.right - screenBits.bounds.left ; + } + if (height != NULL) { + *height = screenBits.bounds.bottom - screenBits.bounds.top ; + } } void wxDisplaySizeMM(int *width, int *height) @@ -462,29 +466,42 @@ void wxDisplaySizeMM(int *width, int *height) wxDisplaySize(width, height); // on mac 72 is fixed (at least now ;-) float cvPt2Mm = 25.4 / 72; - *width = int( *width * cvPt2Mm ); - *height = int( *height * cvPt2Mm ); + + if (width != NULL) { + *width = int( *width * cvPt2Mm ); + } + if (height != NULL) { + *height = int( *height * cvPt2Mm ); + } } void wxClientDisplayRect(int *x, int *y, int *width, int *height) { - BitMap screenBits; - GetQDGlobalsScreenBits( &screenBits ); + BitMap screenBits; + GetQDGlobalsScreenBits( &screenBits ); - if (x) *x = 0; - if (y) *y = 0; + if (x) + *x = 0; + if (y) + *y = 0; - *width = screenBits.bounds.right - screenBits.bounds.left ; - *height = screenBits.bounds.bottom - screenBits.bounds.top ; + if (width != NULL) { + *width = screenBits.bounds.right - screenBits.bounds.left ; + } + if (height != NULL) { + *height = screenBits.bounds.bottom - screenBits.bounds.top ; + } - SInt16 mheight ; + SInt16 mheight ; #if TARGET_CARBON - GetThemeMenuBarHeight( &mheight ) ; + GetThemeMenuBarHeight( &mheight ) ; #else mheight = LMGetMBarHeight() ; #endif - *height -= mheight ; - if ( y ) + if (height != NULL) { + *height -= mheight ; + } + if (y) *y = mheight ; } diff --git a/src/mac/settings.cpp b/src/mac/settings.cpp index 5c3cc0990b..dcfab47793 100644 --- a/src/mac/settings.cpp +++ b/src/mac/settings.cpp @@ -151,13 +151,16 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) // Get a system metric, e.g. scrollbar size int wxSystemSettingsNative::GetMetric(wxSystemMetric index) { + int value; + switch ( index) { case wxSYS_MOUSE_BUTTONS: - return 2; // we emulate a two button mouse (ctrl + click = right button ) + // we emulate a two button mouse (ctrl + click = right button ) + return 2; case wxSYS_BORDER_X: // TODO - return 0; + return 0; case wxSYS_BORDER_Y: // TODO return 0; @@ -210,11 +213,11 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index) // TODO return 0; case wxSYS_SCREEN_X: - // TODO - return 0; + wxDisplaySize(&value, NULL); + return value; case wxSYS_SCREEN_Y: - // TODO - return 0; + wxDisplaySize(NULL, &value); + return value; case wxSYS_FRAMESIZE_X: // TODO return 0; diff --git a/src/mac/utils.cpp b/src/mac/utils.cpp index ad685519dd..4e31d12476 100644 --- a/src/mac/utils.cpp +++ b/src/mac/utils.cpp @@ -450,11 +450,15 @@ int wxDisplayDepth() // Get size of display void wxDisplaySize(int *width, int *height) { - BitMap screenBits; - GetQDGlobalsScreenBits( &screenBits ); + BitMap screenBits; + GetQDGlobalsScreenBits( &screenBits ); - *width = screenBits.bounds.right - screenBits.bounds.left ; - *height = screenBits.bounds.bottom - screenBits.bounds.top ; + if (width != NULL) { + *width = screenBits.bounds.right - screenBits.bounds.left ; + } + if (height != NULL) { + *height = screenBits.bounds.bottom - screenBits.bounds.top ; + } } void wxDisplaySizeMM(int *width, int *height) @@ -462,29 +466,42 @@ void wxDisplaySizeMM(int *width, int *height) wxDisplaySize(width, height); // on mac 72 is fixed (at least now ;-) float cvPt2Mm = 25.4 / 72; - *width = int( *width * cvPt2Mm ); - *height = int( *height * cvPt2Mm ); + + if (width != NULL) { + *width = int( *width * cvPt2Mm ); + } + if (height != NULL) { + *height = int( *height * cvPt2Mm ); + } } void wxClientDisplayRect(int *x, int *y, int *width, int *height) { - BitMap screenBits; - GetQDGlobalsScreenBits( &screenBits ); + BitMap screenBits; + GetQDGlobalsScreenBits( &screenBits ); - if (x) *x = 0; - if (y) *y = 0; + if (x) + *x = 0; + if (y) + *y = 0; - *width = screenBits.bounds.right - screenBits.bounds.left ; - *height = screenBits.bounds.bottom - screenBits.bounds.top ; + if (width != NULL) { + *width = screenBits.bounds.right - screenBits.bounds.left ; + } + if (height != NULL) { + *height = screenBits.bounds.bottom - screenBits.bounds.top ; + } - SInt16 mheight ; + SInt16 mheight ; #if TARGET_CARBON - GetThemeMenuBarHeight( &mheight ) ; + GetThemeMenuBarHeight( &mheight ) ; #else mheight = LMGetMBarHeight() ; #endif - *height -= mheight ; - if ( y ) + if (height != NULL) { + *height -= mheight ; + } + if (y) *y = mheight ; }