📄 utils.h
字号:
// Get the process id of the current process
WXDLLEXPORT unsigned long wxGetProcessId();
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
WXDLLEXPORT long wxGetFreeMemory();
// should wxApp::OnFatalException() be called?
WXDLLEXPORT bool wxHandleFatalExceptions(bool doit = TRUE);
// ----------------------------------------------------------------------------
// Environment variables
// ----------------------------------------------------------------------------
// returns TRUE if variable exists (value may be NULL if you just want to check
// for this)
WXDLLEXPORT bool wxGetEnv(const wxString& var, wxString *value);
// set the env var name to the given value, return TRUE on success
WXDLLEXPORT bool wxSetEnv(const wxString& var, const wxChar *value);
// remove the env var from environment
inline bool wxUnsetEnv(const wxString& var) { return wxSetEnv(var, NULL); }
// ----------------------------------------------------------------------------
// Network and username functions.
// ----------------------------------------------------------------------------
// NB: "char *" functions are deprecated, use wxString ones!
// Get eMail address
WXDLLEXPORT bool wxGetEmailAddress(wxChar *buf, int maxSize);
WXDLLEXPORT wxString wxGetEmailAddress();
// Get hostname.
WXDLLEXPORT bool wxGetHostName(wxChar *buf, int maxSize);
WXDLLEXPORT wxString wxGetHostName();
// Get FQDN
WXDLLEXPORT wxString wxGetFullHostName();
WXDLLEXPORT bool wxGetFullHostName(wxChar *buf, int maxSize);
// Get user ID e.g. jacs (this is known as login name under Unix)
WXDLLEXPORT bool wxGetUserId(wxChar *buf, int maxSize);
WXDLLEXPORT wxString wxGetUserId();
// Get user name e.g. Julian Smart
WXDLLEXPORT bool wxGetUserName(wxChar *buf, int maxSize);
WXDLLEXPORT wxString wxGetUserName();
// Get current Home dir and copy to dest (returns pstr->c_str())
WXDLLEXPORT wxString wxGetHomeDir();
WXDLLEXPORT const wxChar* wxGetHomeDir(wxString *pstr);
// Get the user's home dir (caller must copy --- volatile)
// returns NULL is no HOME dir is known
#if defined(__UNIX__) && wxUSE_UNICODE
WXDLLEXPORT const wxMB2WXbuf wxGetUserHome(const wxString& user = wxEmptyString);
#else
WXDLLEXPORT wxChar* wxGetUserHome(const wxString& user = wxEmptyString);
#endif
// get number of total/free bytes on the disk where path belongs
WXDLLEXPORT bool wxGetDiskSpace(const wxString& path,
wxLongLong *pTotal = NULL,
wxLongLong *pFree = NULL);
#if wxUSE_GUI // GUI only things from now on
// ----------------------------------------------------------------------------
// Menu accelerators related things
// ----------------------------------------------------------------------------
WXDLLEXPORT wxChar* wxStripMenuCodes(const wxChar *in, wxChar *out = (wxChar *) NULL);
WXDLLEXPORT wxString wxStripMenuCodes(const wxString& str);
#if wxUSE_ACCEL
class WXDLLEXPORT wxAcceleratorEntry;
WXDLLEXPORT wxAcceleratorEntry *wxGetAccelFromString(const wxString& label);
#endif // wxUSE_ACCEL
// ----------------------------------------------------------------------------
// Window search
// ----------------------------------------------------------------------------
// Returns menu item id or -1 if none.
WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString);
// Find the wxWindow at the given point. wxGenericFindWindowAtPoint
// is always present but may be less reliable than a native version.
WXDLLEXPORT wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
WXDLLEXPORT wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
// NB: this function is obsolete, use wxWindow::FindWindowByLabel() instead
//
// Find the window/widget with the given title or label.
// Pass a parent to begin the search from, or NULL to look through
// all windows.
WXDLLEXPORT wxWindow* wxFindWindowByLabel(const wxString& title, wxWindow *parent = (wxWindow *) NULL);
// NB: this function is obsolete, use wxWindow::FindWindowByName() instead
//
// Find window by name, and if that fails, by label.
WXDLLEXPORT wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent = (wxWindow *) NULL);
// ----------------------------------------------------------------------------
// Message/event queue helpers
// ----------------------------------------------------------------------------
// NB: these functions are obsolete, please use wxApp methods instead!
// Yield to other apps/messages
WXDLLEXPORT bool wxYield();
// Like wxYield, but fails silently if the yield is recursive.
WXDLLEXPORT bool wxYieldIfNeeded();
// Yield to other apps/messages and disable user input
WXDLLEXPORT bool wxSafeYield(wxWindow *win = NULL, bool onlyIfNeeded = FALSE);
// Enable or disable input to all top level windows
WXDLLEXPORT void wxEnableTopLevelWindows(bool enable = TRUE);
// Check whether this window wants to process messages, e.g. Stop button
// in long calculations.
WXDLLEXPORT bool wxCheckForInterrupt(wxWindow *wnd);
// Consume all events until no more left
WXDLLEXPORT void wxFlushEvents();
// a class which disables all windows (except, may be, thegiven one) in its
// ctor and enables them back in its dtor
class WXDLLEXPORT wxWindowDisabler
{
public:
wxWindowDisabler(wxWindow *winToSkip = (wxWindow *)NULL);
~wxWindowDisabler();
private:
wxWindowList *m_winDisabled;
DECLARE_NO_COPY_CLASS(wxWindowDisabler)
};
// ----------------------------------------------------------------------------
// Cursors
// ----------------------------------------------------------------------------
// Set the cursor to the busy cursor for all windows
class WXDLLEXPORT wxCursor;
WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR;
WXDLLEXPORT void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR);
// Restore cursor to normal
WXDLLEXPORT void wxEndBusyCursor();
// TRUE if we're between the above two calls
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(); }
// FIXME: These two methods are currently only implemented (and needed?)
// in wxGTK. BusyCursor handling should probably be moved to
// common code since the wxGTK and wxMSW implementations are very
// similar except for wxMSW using HCURSOR directly instead of
// wxCursor.. -- RL.
static const wxCursor &GetStoredCursor();
static const wxCursor GetBusyCursor();
};
// ----------------------------------------------------------------------------
// 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 = 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, wxChar **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
void WXDLLEXPORT wxGetMousePosition( int* x, int* y );
// MSW only: get user-defined resource from the .res file.
// Returns NULL or newly-allocated memory, so use delete[] to clean up.
#ifdef __WXMSW__
WXDLLEXPORT extern const wxChar* wxUserResourceStr;
WXDLLEXPORT wxChar* wxLoadUserResource(const wxString& resourceName, const wxString& resourceType = wxUserResourceStr);
#endif // MSW
// ----------------------------------------------------------------------------
// Display and colorss (X only)
// ----------------------------------------------------------------------------
#ifdef __WXGTK__
void *wxGetDisplay();
#endif
#ifdef __X__
WXDisplay *wxGetDisplay();
bool wxSetDisplay(const wxString& display_name);
wxString wxGetDisplayName();
#endif // X or GTK+
#ifdef __X__
#ifdef __VMS__ // Xlib.h for VMS is not (yet) compatible with C++
// The resulting warnings are switched off here
#pragma message disable nosimpint
#endif
// #include <X11/Xlib.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#endif //__X__
#endif // wxUSE_GUI
// ----------------------------------------------------------------------------
// Error message functions used by wxWindows (deprecated, use wxLog)
// ----------------------------------------------------------------------------
#if WXWIN_COMPATIBILITY_2_2
// Format a message on the standard error (UNIX) or the debugging
// stream (Windows)
WXDLLEXPORT void wxDebugMsg(const wxChar *fmt ...) ATTRIBUTE_PRINTF_1;
// Non-fatal error (continues)
WXDLLEXPORT_DATA(extern const wxChar*) wxInternalErrorStr;
WXDLLEXPORT void wxError(const wxString& msg, const wxString& title = wxInternalErrorStr);
// Fatal error (exits)
WXDLLEXPORT_DATA(extern const wxChar*) wxFatalErrorStr;
WXDLLEXPORT void wxFatalError(const wxString& msg, const wxString& title = wxFatalErrorStr);
#endif // WXWIN_COMPATIBILITY_2_2
#endif
// _WX_UTILSH__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -