- *value = wxStrtol(s, NULL, 10);
- delete[] s;
- return TRUE;
- }
- else return FALSE;
-}
-
-bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
-{
- wxChar *s = NULL;
- bool succ = wxGetResource(section, entry, (wxChar **)&s, file);
- if (succ)
- {
- *value = (int)wxStrtol(s, NULL, 10);
- delete[] s;
- return TRUE;
- }
- else return FALSE;
-}
-#endif // wxUSE_RESOURCES
-
-// ---------------------------------------------------------------------------
-// helper functions for showing a "busy" cursor
-// ---------------------------------------------------------------------------
-
-static HCURSOR gs_wxBusyCursor = 0; // new, busy cursor
-static HCURSOR gs_wxBusyCursorOld = 0; // old cursor
-static int gs_wxBusyCursorCount = 0;
-
-extern HCURSOR wxGetCurrentBusyCursor()
-{
- return gs_wxBusyCursor;
-}
-
-// Set the cursor to the busy cursor for all windows
-void wxBeginBusyCursor(wxCursor *cursor)
-{
- if ( gs_wxBusyCursorCount++ == 0 )
- {
- gs_wxBusyCursor = (HCURSOR)cursor->GetHCURSOR();
-#ifndef __WXMICROWIN__
- gs_wxBusyCursorOld = ::SetCursor(gs_wxBusyCursor);
-#endif
- }
- //else: nothing to do, already set
-}
-
-// Restore cursor to normal
-void wxEndBusyCursor()
-{
- wxCHECK_RET( gs_wxBusyCursorCount > 0,
- wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
-
- if ( --gs_wxBusyCursorCount == 0 )
- {
-#ifndef __WXMICROWIN__
- ::SetCursor(gs_wxBusyCursorOld);
-#endif
- gs_wxBusyCursorOld = 0;
- }
-}
-
-// TRUE if we're between the above two calls
-bool wxIsBusy()
-{
- return gs_wxBusyCursorCount > 0;
-}
-
-// Check whether this window wants to process messages, e.g. Stop button
-// in long calculations.
-bool wxCheckForInterrupt(wxWindow *wnd)
-{
- wxCHECK( wnd, FALSE );
-
- MSG msg;
- while ( ::PeekMessage(&msg, GetHwndOf(wnd), 0, 0, PM_REMOVE) )
- {
- ::TranslateMessage(&msg);
- ::DispatchMessage(&msg);
- }
-
- return TRUE;
-}
-
-// MSW only: get user-defined resource from the .res file.
-// Returns NULL or newly-allocated memory, so use delete[] to clean up.
-
-#ifndef __WXMICROWIN__
-wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourceType)
-{
- HRSRC hResource = ::FindResource(wxGetInstance(), resourceName, resourceType);
- if ( hResource == 0 )
- return NULL;
-
- HGLOBAL hData = ::LoadResource(wxGetInstance(), hResource);
- if ( hData == 0 )
- return NULL;
-
- wxChar *theText = (wxChar *)::LockResource(hData);
- if ( !theText )
- return NULL;
-
- // Not all compilers put a zero at the end of the resource (e.g. BC++ doesn't).
- // so we need to find the length of the resource.
- int len = ::SizeofResource(wxGetInstance(), hResource);
- wxChar *s = new wxChar[len+1];
- wxStrncpy(s,theText,len);
- s[len]=0;
-
- // wxChar *s = copystring(theText);
-
- // Obsolete in WIN32
-#ifndef __WIN32__
- UnlockResource(hData);
-#endif
-
- // No need??
- // GlobalFree(hData);
-
- return s;
-}
-#endif // __WXMICROWIN__
-
-// ----------------------------------------------------------------------------
-// get display info
-// ----------------------------------------------------------------------------
-
-// See also the wxGetMousePosition in window.cpp
-// Deprecated: use wxPoint wxGetMousePosition() instead
-void wxGetMousePosition( int* x, int* y )
-{
- POINT pt;
- GetCursorPos( & pt );
- if ( x ) *x = pt.x;
- if ( y ) *y = pt.y;
-};
-
-// Return TRUE if we have a colour display
-bool wxColourDisplay()
-{
-#ifdef __WXMICROWIN__
- // MICROWIN_TODO
- return TRUE;
-#else
- // this function is called from wxDC ctor so it is called a *lot* of times
- // hence we optimize it a bit but doign 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);
- }