#include <ctype.h>
-#if !defined(__GNUWIN32__) && !defined(__SALFORDC__)
+#if !defined(__GNUWIN32__) && !defined(__WXWINE__) && !defined(__SALFORDC__)
#include <direct.h>
#ifndef __MWERKS__
#include <dir.h>
#endif
-#ifdef __WIN32__
+#if defined(__WIN32__) && !defined(__WXWINE__)
#include <io.h>
#ifndef __GNUWIN32__
#include <stdarg.h>
//// BEGIN for console support: VC++ only
+#ifdef __VISUALC__
#include "wx/msw/msvcrt.h"
# define new new(__FILE__,__LINE__)
# endif
+#endif
+ // __VISUALC__
/// END for console support
// In the WIN.INI file
}
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
-long wxGetFreeMemory(void)
+long wxGetFreeMemory()
{
#if defined(__WIN32__) && !defined(__BORLANDC__) && !defined(__TWIN32__)
MEMORYSTATUS memStatus;
class wxSleepTimer: public wxTimer
{
public:
- inline void Notify(void)
+ inline void Notify()
{
inTimer = FALSE;
Stop();
static wxTimer *wxTheSleepTimer = NULL;
+void wxUsleep(unsigned long milliseconds)
+{
+#ifdef __WIN32__
+ ::Sleep(milliseconds);
+#else
+ if (inTimer)
+ return;
+
+ wxTheSleepTimer = new wxSleepTimer;
+ inTimer = TRUE;
+ wxTheSleepTimer->Start(milliseconds);
+ while (inTimer)
+ {
+ if (wxTheApp->Pending())
+ wxTheApp->Dispatch();
+ }
+ delete wxTheSleepTimer;
+ wxTheSleepTimer = NULL;
+#endif
+}
+
void wxSleep(int nSecs)
{
#if 0 // WIN32 hangs app
}
// Consume all events until no more left
-void wxFlushEvents(void)
+void wxFlushEvents()
{
// wxYield();
}
}
// Emit a beeeeeep
-void wxBell(void)
+void wxBell()
{
// Removed by RD because IHMO syncronous sound is a Bad Thing. MessageBeep
// will do a similar thing anyway if there is no sound card...
}
#endif // wxUSE_RESOURCES
-// Old cursor
-static HCURSOR wxBusyCursorOld = 0;
-static int wxBusyCursorCount = 0;
+// ---------------------------------------------------------------------------
+// helper functions for showing a "busy" cursor
+// ---------------------------------------------------------------------------
+
+HCURSOR gs_wxBusyCursor = 0; // new, busy cursor
+HCURSOR gs_wxBusyCursorOld = 0; // old cursor
+static int gs_wxBusyCursorCount = 0;
// Set the cursor to the busy cursor for all windows
void wxBeginBusyCursor(wxCursor *cursor)
{
- wxBusyCursorCount ++;
- if (wxBusyCursorCount == 1)
- {
- wxBusyCursorOld = ::SetCursor((HCURSOR) cursor->GetHCURSOR());
- }
- else
- {
- (void)::SetCursor((HCURSOR) cursor->GetHCURSOR());
- }
+ if ( gs_wxBusyCursorCount++ == 0 )
+ {
+ gs_wxBusyCursor = (HCURSOR)cursor->GetHCURSOR();
+ gs_wxBusyCursorOld = ::SetCursor(gs_wxBusyCursor);
+ }
+ //else: nothing to do, already set
}
// Restore cursor to normal
-void wxEndBusyCursor(void)
+void wxEndBusyCursor()
{
- if (wxBusyCursorCount == 0)
- return;
+ wxCHECK_RET( gs_wxBusyCursorCount > 0,
+ "no matching wxBeginBusyCursor() for wxEndBusyCursor()" );
- wxBusyCursorCount --;
- if (wxBusyCursorCount == 0)
- {
- ::SetCursor(wxBusyCursorOld);
- wxBusyCursorOld = 0;
- }
+ if ( --gs_wxBusyCursorCount == 0 )
+ {
+ ::SetCursor(gs_wxBusyCursorOld);
+
+ gs_wxBusyCursorOld = 0;
+ }
}
// TRUE if we're between the above two calls
-bool wxIsBusy(void)
+bool wxIsBusy()
{
- return (wxBusyCursorCount > 0);
+ return (gs_wxBusyCursorCount > 0);
}
+// ---------------------------------------------------------------------------
const char* wxGetHomeDir(wxString *pstr)
{
wxString& strDir = *pstr;
if ((home = getenv("TMP")) != NULL ||
(home = getenv("TMPDIR")) != NULL ||
(home = getenv("TEMP")) != NULL)
- return *home ? home : "\\";
+ return *home ? home : (char*)"\\";
}
if (Stricmp(tmp, WXSTRINGCAST user1) == 0)
user1 = "";
return TRUE;//*** temporary?
}
else{
- wxError("wnd==NULL !!!");
+ wxFAIL_MSG("wnd==NULL !!!");
+
return FALSE;//*** temporary?
}
}
};
// Return TRUE if we have a colour display
-bool wxColourDisplay(void)
+bool wxColourDisplay()
{
HDC dc = ::GetDC((HWND) NULL);
bool flag;
}
// Returns depth of screen
-int wxDisplayDepth(void)
+int wxDisplayDepth()
{
HDC dc = ::GetDC((HWND) NULL);
int planes = GetDeviceCaps(dc, PLANES);
#endif
}
+// ---------------------------------------------------------------------------
+// window information functions
+// ---------------------------------------------------------------------------
+
wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
{
wxString str;
return str;
}
+wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd)
+{
+ wxString str;
+
+ int len = 256; // some starting value
+
+ for ( ;; )
+ {
+ // as we've #undefined GetClassName we must now manually choose the
+ // right function to call
+ int count =
+
+ #ifndef __WIN32__
+ GetClassName
+ #else // Win32
+ #ifdef UNICODE
+ GetClassNameW
+ #else // !Unicode
+ #ifdef __TWIN32__
+ GetClassName
+ #else // !Twin32
+ GetClassNameA
+ #endif // Twin32/!Twin32
+ #endif // Unicode/ANSI
+ #endif // Win16/32
+ ((HWND)hWnd, str.GetWriteBuf(len), len);
+
+ str.UngetWriteBuf();
+ if ( count == len )
+ {
+ // the class name might have been truncated, retry with larger
+ // buffer
+ len *= 2;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return str;
+}
+
+WXWORD WXDLLEXPORT wxGetWindowId(WXHWND hWnd)
+{
+#ifndef __WIN32__
+ return GetWindowWord((HWND)hWnd, GWW_ID);
+#else // Win32
+ return GetWindowLong((HWND)hWnd, GWL_ID);
+#endif // Win16/32
+}
+
#if 0
//------------------------------------------------------------------------
// wild character routines
#endif
-#ifdef 0
+#if 0
// maximum mumber of lines the output console should have
static const WORD MAX_CONSOLE_LINES = 500;