X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/621ccd8a82647e094bdf539501b648df5de7efab..93489fc8f15eef3bb618682c0a32f648550ddc56:/src/os2/utilsgui.cpp?ds=sidebyside diff --git a/src/os2/utilsgui.cpp b/src/os2/utilsgui.cpp index f77d16db2c..66647fcd2e 100644 --- a/src/os2/utilsgui.cpp +++ b/src/os2/utilsgui.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: os2/utilsgui.cpp +// Name: src/os2/utilsgui.cpp // Purpose: Various utility functions only available in GUI // Author: David Webster // Modified by: @@ -25,12 +25,14 @@ #endif #ifndef WX_PRECOMP - #include "wx/setup.h" #include "wx/utils.h" #include "wx/app.h" #include "wx/cursor.h" #endif //WX_PRECOMP +#include "wx/apptrait.h" +#include "wx/timer.h" + #include "wx/os2/private.h" // includes // ============================================================================ @@ -54,8 +56,6 @@ public: } }; -static wxTimer* wxTheSleepTimer = NULL; - // Reading and writing resources (eg WIN.INI, .Xdefaults) #if wxUSE_RESOURCES bool wxWriteResource( @@ -68,7 +68,7 @@ bool wxWriteResource( HAB hab = 0; HINI hIni = 0; - if (rFile != "") + if (!rFile.empty()) { hIni = ::PrfOpenProfile(hab, (PSZ)WXSTRINGCAST rFile); if (hIni != 0L) @@ -152,7 +152,7 @@ bool wxGetResource( wxChar zDefunkt[] = _T("$$default"); char zBuf[1000]; - if (rFile != "") + if (!rFile.empty()) { hIni = ::PrfOpenProfile(hab, (PSZ)WXSTRINGCAST rFile); if (hIni != 0L) @@ -332,7 +332,6 @@ bool wxCheckForInterrupt( QMSG vMsg; HAB hab = 0; HWND hwndFilter = NULLHANDLE; - HWND hwndWin= (HWND) pWnd->GetHWND(); while(::WinPeekMsg(hab, &vMsg, hwndFilter, 0, 0, PM_REMOVE)) { @@ -428,8 +427,10 @@ void wxDisplaySize( ::DevCloseDC(hdcScreen); ::WinReleasePS(hpsScreen); } - *pWidth = (int)lWidth; - *pHeight = (int)lHeight; + if (pWidth) + *pWidth = (int)lWidth; + if (pHeight) + *pHeight = (int)lHeight; } void wxDisplaySizeMM( @@ -470,9 +471,19 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height) wxDisplaySize(width, height); } +void wxGUIAppTraits::InitializeGui(unsigned long &ulHab) +{ + ulHab = ::WinInitialize(0); +} + +void wxGUIAppTraits::TerminateGui(unsigned long ulHab) +{ + ::WinTerminate(ulHab); +} + wxToolkitInfo & wxGUIAppTraits::GetToolkitInfo() { - static wxToolkitInfo vInfo; + static wxToolkitInfo vInfo; ULONG ulSysInfo[QSV_MAX] = {0}; APIRET ulrc; @@ -500,31 +511,30 @@ wxToolkitInfo & wxGUIAppTraits::GetToolkitInfo() // window information functions // --------------------------------------------------------------------------- -wxString WXDLLEXPORT wxGetWindowText( - WXHWND hWnd -) +wxString WXDLLEXPORT wxGetWindowText( WXHWND hWnd ) { - wxString vStr; - long lLen = ::WinQueryWindowTextLength((HWND)hWnd) + 1; + wxString vStr; - ::WinQueryWindowText((HWND)hWnd, lLen, vStr.GetWriteBuf((int)lLen)); - vStr.UngetWriteBuf(); + if ( hWnd ) + { + long lLen = ::WinQueryWindowTextLength((HWND)hWnd) + 1; + ::WinQueryWindowText((HWND)hWnd, lLen, (PSZ)(wxChar*)wxStringBuffer(vStr, lLen)); + } return vStr; } -wxString WXDLLEXPORT wxGetWindowClass( - WXHWND hWnd -) +wxString WXDLLEXPORT wxGetWindowClass( WXHWND hWnd ) { - wxString vStr; - int nLen = 256; // some starting value + wxString vStr; + if ( hWnd ) + { + int nLen = 256; // some starting value for ( ;; ) { - int nCount = ::WinQueryClassName((HWND)hWnd, nLen, vStr.GetWriteBuf(nLen)); + int nCount = ::WinQueryClassName((HWND)hWnd, nLen, (PSZ)(wxChar*)wxStringBuffer(vStr, nLen)); - vStr.UngetWriteBuf(); if (nCount == nLen ) { // the class name might have been truncated, retry with larger @@ -535,6 +545,7 @@ wxString WXDLLEXPORT wxGetWindowClass( { break; } + } } return vStr; } @@ -925,7 +936,7 @@ wxBitmap wxDisableBitmap( int j; // - // Bitmap must be ina double-word alligned address so we may + // Bitmap must be in a double-word aligned address so we may // have some padding to worry about // if (nLineBoundary > 0)