X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c030b70fc6270c2e44a81f83e69fcc91d2b3c768..58a8ab88685a72ac030d5e2ade62b4d796f11bed:/include/wx/utils.h?ds=sidebyside diff --git a/include/wx/utils.h b/include/wx/utils.h index 1be20a24b7..222e822c5b 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -6,7 +6,7 @@ // Created: 29/01/98 // RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_UTILSH__ @@ -21,16 +21,10 @@ #include "wx/list.h" #include "wx/window.h" #include "wx/filefn.h" -#include "wx/process.h" - -#if wxUSE_IOSTREAMH -#include -#else -#include -# ifdef _MSC_VER - using namespace std; -# endif -#endif + +#include "wx/ioswrap.h" + +class WXDLLEXPORT wxProcess; #ifdef __X__ #ifndef __VMS__ @@ -55,13 +49,13 @@ class WXDLLEXPORT wxFrame; #define wxToLower(C) (((C) >= 'A' && (C) <= 'Z')? (C) - 'A' + 'a': (C)) // Return a string with the current date/time -WXDLLEXPORT wxString wxNow(void); +WXDLLEXPORT wxString wxNow(); // Make a copy of this string using 'new' WXDLLEXPORT char* copystring(const char *s); // Generate a unique ID -WXDLLEXPORT long wxNewId(void); +WXDLLEXPORT long wxNewId(); #define NewId wxNewId // Ensure subsequent IDs don't clash with this one @@ -69,7 +63,7 @@ WXDLLEXPORT void wxRegisterId(long id); #define RegisterId wxRegisterId // Return the current ID -WXDLLEXPORT long wxGetCurrentId(void); +WXDLLEXPORT long wxGetCurrentId(); // Useful buffer WXDLLEXPORT_DATA(extern char*) wxBuffer; @@ -112,16 +106,19 @@ WXDLLEXPORT int wxKill(long pid, int sig=wxSIGTERM); // Execute a command in an interactive shell window // If no command then just the shell -WXDLLEXPORT bool wxShell(const wxString& command = ""); +WXDLLEXPORT bool wxShell(const wxString& command = wxEmptyString); // Sleep for nSecs seconds under UNIX, do nothing under Windows WXDLLEXPORT void wxSleep(int nSecs); +// Sleep for a given amount of milliseconds +WXDLLEXPORT void wxUsleep(unsigned long milliseconds); + // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) -WXDLLEXPORT long wxGetFreeMemory(void); +WXDLLEXPORT long wxGetFreeMemory(); // Consume all events until no more left -WXDLLEXPORT void wxFlushEvents(void); +WXDLLEXPORT void wxFlushEvents(); /* * Network and username functions. @@ -133,12 +130,15 @@ WXDLLEXPORT bool wxGetEmailAddress(char *buf, int maxSize); // Get hostname. WXDLLEXPORT bool wxGetHostName(char *buf, int maxSize); +WXDLLEXPORT bool wxGetHostName(wxString& buf); // Get user ID e.g. jacs WXDLLEXPORT bool wxGetUserId(char *buf, int maxSize); +WXDLLEXPORT bool wxGetUserId(wxString& buf); // Get user name e.g. Julian Smart WXDLLEXPORT bool wxGetUserName(char *buf, int maxSize); +WXDLLEXPORT bool wxGetUserName(wxString& buf); /* * Strip out any menu codes @@ -157,46 +157,6 @@ WXDLLEXPORT wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent // Returns menu item id or -1 if none. WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString); -// A debugging stream buffer. -// Under Windows, this writes to the Windows debug output. -// Under other platforms, it writes to cerr. - -// ALl this horrible gubbins required for Borland, because the calling -// convention needs to be the same as for streambuf. -// Thanks to Gerhard.Vogt@embl-heidelberg.de for this solution. - -#if defined(__BORLANDC__) && defined(__BCOPT__) && !defined(_RTL_ALLOW_po) && !defined(__FLAT__) -#pragma option -po- -#endif - -// Can't export a class derived from a non-export class -#if !defined(_WINDLL) && !defined(WXUSINGDLL) - -// #ifdef new -// #undef new -// #endif - -class WXDLLEXPORT wxDebugStreamBuf: public streambuf -{ - public: - wxDebugStreamBuf(void); - ~wxDebugStreamBuf(void) {} - - int overflow(int i); - inline int underflow(void) { return EOF; } - int sync(void); -}; - -// #if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS -// #define new WXDEBUG_NEW -// #endif - -#endif - -#if defined(__BORLANDC__) && defined(__BCOPT__) && !defined(_RTL_ALLOW_po) && !defined(__FLAT__) -#pragma option -po. -#endif - /* #if (!defined(__MINMAX_DEFINED) && !defined(max)) #define max(a,b) (((a) > (b)) ? (a) : (b)) @@ -204,11 +164,12 @@ class WXDLLEXPORT wxDebugStreamBuf: public streambuf #define __MINMAX_DEFINED 1 #endif */ + #define wxMax(a,b) (((a) > (b)) ? (a) : (b)) #define wxMin(a,b) (((a) < (b)) ? (a) : (b)) // Yield to other apps/messages -WXDLLEXPORT bool wxYield(void); +WXDLLEXPORT bool wxYield(); // Format a message on the standard error (UNIX) or the debugging // stream (Windows) @@ -224,14 +185,24 @@ WXDLLEXPORT int wxGetOsVersion(int *majorVsn= (int *) NULL,int *minorVsn= (int * class WXDLLEXPORT wxCursor; WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR; WXDLLEXPORT void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); - + // Restore cursor to normal -WXDLLEXPORT void wxEndBusyCursor(void); +WXDLLEXPORT void wxEndBusyCursor(); // TRUE if we're between the above two calls -WXDLLEXPORT bool wxIsBusy(void); +WXDLLEXPORT bool wxIsBusy(); + +// Convenience class so we can just create a wxBusyCursor object on the stack +class WXDLLEXPORT wxBusyCursor +{ +public: + wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR) + { wxBeginBusyCursor(cursor); } + ~wxBusyCursor() + { wxEndBusyCursor(); } +}; -/* Error message functions used by wxWindows */ +// Error message functions used by wxWindows // Non-fatal error (continues) WXDLLEXPORT_DATA(extern const char*) wxInternalErrorStr; @@ -243,15 +214,15 @@ WXDLLEXPORT void wxFatalError(const wxString& msg, const wxString& title = wxFat // Reading and writing resources (eg WIN.INI, .Xdefaults) #if wxUSE_RESOURCES -WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file = ""); -WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file = ""); -WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file = ""); -WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file = ""); - -WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file = ""); -WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file = ""); -WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file = ""); -WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file = ""); +WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file = wxEmptyString); + +WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file = wxEmptyString); +WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file = wxEmptyString); #endif // wxUSE_RESOURCES // Get current Home dir and copy to dest (returns pstr->c_str()) @@ -259,7 +230,7 @@ WXDLLEXPORT const char* wxGetHomeDir(wxString *pstr); // Get the user's home dir (caller must copy--- volatile) // returns NULL is no HOME dir is known -WXDLLEXPORT char* wxGetUserHome(const wxString& user = ""); +WXDLLEXPORT char* wxGetUserHome(const wxString& user = wxEmptyString); // Check whether this window wants to process messages, e.g. Stop button // in long calculations.