X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/954b8ae60391d18b87a604e7919c87c0c6ae208b..5824f314a3ac14fb4f4c8c2db7823076fedbbee8:/docs/latex/wx/function.tex?ds=inline diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex index 655af485a7..13e2bbb853 100644 --- a/docs/latex/wx/function.tex +++ b/docs/latex/wx/function.tex @@ -4,6 +4,58 @@ The functions defined in wxWindows are described here. +\section{Thread functions}\label{threadfunctions} + +\wxheading{Include files} + + + +\wxheading{See also} + +\helpref{wxThread}{wxthread}, \helpref{wxMutex}{wxmutex}, \helpref{Multithreading overview}{wxthreadoverview} + +\membersection{::wxMutexGuiEnter}\label{wxmutexguienter} + +\func{void}{wxMutexGuiEnter}{\void} + +This function must be called when any thread other than the main GUI thread +wants to get access to the GUI library. This function will block the execution +of the calling thread until the main thread (or any other thread holding the +main GUI lock) leaves the GUI library and no other other thread will enter +the GUI library until the calling thread calls \helpref{::wxMutexGuiLeave()}{wxmutexguileave}. + +Typically, these functions are used like this: + +\begin{verbatim} +void MyThread::Foo(void) +{ + // before doing any GUI calls we must ensure that this thread is the only + // one doing it! + + wxMutexGuiEnter(); + + // Call GUI here: + my_window->DrawSomething(); + + wxMutexGuiLeave(); +} +\end{verbatim} + +Note that under GTK, no creation of top-level windows is allowed in any +thread but the main one. + +This function is only defined on platforms which support preemptive +threads. + +\membersection{::wxMutexGuiLeave}\label{wxmutexguileave} + +\func{void}{wxMutexGuiLeave}{\void} + +See \helpref{::wxMutexGuiEnter()}{wxmutexguienter}. + +This function is only defined on platforms which support preemptive +threads. + \section{File functions}\label{filefunctions} \wxheading{Include files} @@ -12,7 +64,7 @@ The functions defined in wxWindows are described here. \wxheading{See also} -\helpref{wxPathList}{wxpathlist} +\helpref{wxPathList}{wxpathlist}, \helpref{wxDir}{wxdir}, \helpref{wxFile}{wxfile} \membersection{::wxDirExists} @@ -31,35 +83,43 @@ slashes. \func{bool}{wxFileExists}{\param{const wxString\& }{filename}} -Returns TRUE if the file exists. +Returns TRUE if the file exists. It also returns TRUE if the file is +a directory. + +\membersection{::wxFileModificationTime} + +\func{time\_t}{wxFileModificationTime}{\param{const wxString\& }{filename}} + +Returns time of last modification of given file. + \membersection{::wxFileNameFromPath} \func{wxString}{wxFileNameFromPath}{\param{const wxString\& }{path}} -Returns a temporary pointer to the filename for a full path. -Copy this pointer for long-term use. +\func{char*}{wxFileNameFromPath}{\param{char* }{path}} + +Returns the filename for a full path. The second form returns a pointer to +temporary storage that should not be deallocated. \membersection{::wxFindFirstFile}\label{wxfindfirstfile} -\func{wxString}{wxFindFirstFile}{\param{const wxString\& }{spec}, \param{int}{ flags = 0}} +\func{wxString}{wxFindFirstFile}{\param{const char*}{spec}, \param{int}{ flags = 0}} This function does directory searching; returns the first file -that matches the path {\it spec}, or NULL. Use \helpref{wxFindNextFile}{wxfindnextfile} to -get the next matching file. +that matches the path {\it spec}, or the empty string. Use \helpref{wxFindNextFile}{wxfindnextfile} to +get the next matching file. Neither will report the current directory "." or the +parent directory "..". {\it spec} may contain wildcards. -{\it flags} is reserved for future use. - -The returned filename is a pointer to static memory so should -not be freed. +{\it flags} may be wxDIR for restricting the query to directories, wxFILE for files or zero for either. For example: \begin{verbatim} wxString f = wxFindFirstFile("/home/project/*.*"); - while (f) + while ( !f.IsEmpty() ) { ... f = wxFindNextFile(); @@ -68,10 +128,12 @@ For example: \membersection{::wxFindNextFile}\label{wxfindnextfile} -\func{wxString}{wxFindFirstFile}{\void} +\func{wxString}{wxFindNextFile}{\void} Returns the next file that matches the path passed to \helpref{wxFindFirstFile}{wxfindfirstfile}. +See \helpref{wxFindFirstFile}{wxfindfirstfile} for an example. + \membersection{::wxGetOSDirectory}\label{wxgetosdirectory} \func{wxString}{wxGetOSDirectory}{\void} @@ -89,8 +151,7 @@ or drive name at the beginning. \func{wxString}{wxPathOnly}{\param{const wxString\& }{path}} -Returns a temporary pointer to the directory part of the filename. Copy this -pointer for long-term use. +Returns the directory part of the filename. \membersection{::wxUnix2DosFilename} @@ -119,56 +180,9 @@ Copies {\it file1} to {\it file2}, returning TRUE if successful. Returns a string containing the current (or working) directory. -\membersection{::wxGetHostName}\label{wxgethostname} - -\func{bool}{wxGetHostName}{\param{const wxString\& }{buf}, \param{int }{sz}} - -Copies the current host machine's name into the supplied buffer. - -Under Windows or NT, this function first looks in the environment -variable SYSTEM\_NAME; if this is not found, the entry {\bf HostName}\rtfsp -in the {\bf wxWindows} section of the WIN.INI file is tried. - -Returns TRUE if successful, FALSE otherwise. - -\membersection{::wxGetEmailAddress}\label{wxgetemailaddress} - -\func{bool}{wxGetEmailAddress}{\param{const wxString\& }{buf}, \param{int }{sz}} - -Copies the user's email address into the supplied buffer, by -concatenating the values returned by \helpref{wxGetHostName}{wxgethostname}\rtfsp -and \helpref{wxGetUserId}{wxgetuserid}. - -Returns TRUE if successful, FALSE otherwise. - -\membersection{::wxGetUserId}\label{wxgetuserid} - -\func{bool}{wxGetUserId}{\param{const wxString\& }{buf}, \param{int }{sz}} - -Copies the current user id into the supplied buffer. - -Under Windows or NT, this function first looks in the environment -variables USER and LOGNAME; if neither of these is found, the entry {\bf UserId}\rtfsp -in the {\bf wxWindows} section of the WIN.INI file is tried. - -Returns TRUE if successful, FALSE otherwise. - -\membersection{::wxGetUserName}\label{wxgetusername} - -\func{bool}{wxGetUserName}{\param{const wxString\& }{buf}, \param{int }{sz}} - -Copies the current user name into the supplied buffer. - -Under Windows or NT, this function looks for the entry {\bf UserName}\rtfsp -in the {\bf wxWindows} section of the WIN.INI file. If PenWindows -is running, the entry {\bf Current} in the section {\bf User} of -the PENWIN.INI file is used. - -Returns TRUE if successful, FALSE otherwise. - \membersection{::wxGetWorkingDirectory} -\func{wxString}{wxGetWorkingDirectory}{\param{const wxString\& }{buf=NULL}, \param{int }{sz=1000}} +\func{wxString}{wxGetWorkingDirectory}{\param{char*}{buf=NULL}, \param{int }{sz=1000}} This function is obsolete: use \helpref{wxGetCwd}{wxgetcwd} instead. @@ -180,7 +194,9 @@ if the buffer is NULL. \membersection{::wxGetTempFileName} -\func{wxString}{wxGetTempFileName}{\param{const wxString\& }{prefix}, \param{const wxString\& }{buf=NULL}} +\func{char*}{wxGetTempFileName}{\param{const wxString\& }{prefix}, \param{char* }{buf=NULL}} + +\func{bool}{wxGetTempFileName}{\param{const wxString\& }{prefix}, \param{wxString\& }{buf}} Makes a temporary filename based on {\it prefix}, opens and closes the file, and places the name in {\it buf}. If {\it buf} is NULL, new store @@ -208,10 +224,13 @@ with wildcard characters. See \helpref{wxIsWild}{wxiswild}. \membersection{::wxMkdir} -\func{bool}{wxMkdir}{\param{const wxString\& }{dir}} +\func{bool}{wxMkdir}{\param{const wxString\& }{dir}, \param{int }{perm = 0777}} Makes the directory {\it dir}, returning TRUE if successful. +{\it perm} is the access mask for the directory for the systems on which it is +supported (Unix) and doesn't have effect for the other ones. + \membersection{::wxRemoveFile} \func{bool}{wxRemoveFile}{\param{const wxString\& }{file}} @@ -239,6 +258,154 @@ The {\it flags} parameter is reserved for future use. Sets the current working directory, returning TRUE if the operation succeeded. Under MS Windows, the current drive is also changed if {\it dir} contains a drive specification. +\membersection{::wxSplitPath}\label{wxsplitfunction} + +\func{void}{wxSplitPath}{\param{const char *}{ fullname}, \param{wxString *}{ path}, \param{wxString *}{ name}, \param{wxString *}{ ext}} + +This function splits a full file name into components: the path (including possible disk/drive +specification under Windows), the base name and the extension. Any of the output parameters +({\it path}, {\it name} or {\it ext}) may be NULL if you are not interested in the value of +a particular component. + +wxSplitPath() will correctly handle filenames with both DOS and Unix path separators under +Windows, however it will not consider backslashes as path separators under Unix (where backslash +is a valid character in a filename). + +On entry, {\it fullname} should be non NULL (it may be empty though). + +On return, {\it path} contains the file path (without the trailing separator), {\it name} +contains the file name and {\it ext} contains the file extension without leading dot. All +three of them may be empty if the corresponding component is. The old contents of the +strings pointed to by these parameters will be overwritten in any case (if the pointers +are not NULL). + +\membersection{::wxTransferFileToStream}\label{wxtransferfiletostream} + +\func{bool}{wxTransferFileToStream}{\param{const wxString\& }{filename}, \param{ostream\& }{stream}} + +Copies the given file to {\it stream}. Useful when converting an old application to +use streams (within the document/view framework, for example). + +Use of this function requires the file wx\_doc.h to be included. + +\membersection{::wxTransferStreamToFile}\label{wxtransferstreamtofile} + +\func{bool}{wxTransferStreamToFile}{\param{istream\& }{stream} \param{const wxString\& }{filename}} + +Copies the given stream to the file {\it filename}. Useful when converting an old application to +use streams (within the document/view framework, for example). + +Use of this function requires the file wx\_doc.h to be included. + +\section{Network functions}\label{networkfunctions} + +\membersection{::wxGetFullHostName}\label{wxgetfullhostname} + +\func{wxString}{wxGetFullHostName}{\void} + +Returns the FQDN (fully qualified domain host name) or an empty string on +error. + +\wxheading{See also} + +\helpref{wxGetHostName}{wxgethostname} + +\wxheading{Include files} + + + +\membersection{::wxGetEmailAddress}\label{wxgetemailaddress} + +\func{bool}{wxGetEmailAddress}{\param{const wxString\& }{buf}, \param{int }{sz}} + +Copies the user's email address into the supplied buffer, by +concatenating the values returned by \helpref{wxGetFullHostName}{wxgetfullhostname}\rtfsp +and \helpref{wxGetUserId}{wxgetuserid}. + +Returns TRUE if successful, FALSE otherwise. + +\wxheading{Include files} + + + +\membersection{::wxGetHostName}\label{wxgethostname} + +\func{wxString}{wxGetHostName}{\void} + +\func{bool}{wxGetHostName}{\param{char * }{buf}, \param{int }{sz}} + +Copies the current host machine's name into the supplied buffer. Please note +that the returned name is {\it not} fully qualified, i.e. it does not include +the domain name. + +Under Windows or NT, this function first looks in the environment +variable SYSTEM\_NAME; if this is not found, the entry {\bf HostName}\rtfsp +in the {\bf wxWindows} section of the WIN.INI file is tried. + +The first variant of this function returns the hostname if successful or an +empty string otherwise. The second (deprecated) function returns TRUE +if successful, FALSE otherwise. + +\wxheading{See also} + +\helpref{wxGetFullHostName}{wxgetfullhostname} + +\wxheading{Include files} + + + +\section{User identification}\label{useridfunctions} + +\membersection{::wxGetUserId}\label{wxgetuserid} + +\func{wxString}{wxGetUserId}{\void} + +\func{bool}{wxGetUserId}{\param{char * }{buf}, \param{int }{sz}} + +This function returns the "user id" also known as "login name" under Unix i.e. +something like "jsmith". It uniquely identifies the current user (on this system). + +Under Windows or NT, this function first looks in the environment +variables USER and LOGNAME; if neither of these is found, the entry {\bf UserId}\rtfsp +in the {\bf wxWindows} section of the WIN.INI file is tried. + +The first variant of this function returns the login name if successful or an +empty string otherwise. The second (deprecated) function returns TRUE +if successful, FALSE otherwise. + +\wxheading{See also} + +\helpref{wxGetUserName}{wxgetusername} + +\wxheading{Include files} + + + +\membersection{::wxGetUserName}\label{wxgetusername} + +\func{wxString}{wxGetUserName}{\void} + +\func{bool}{wxGetUserName}{\param{char * }{buf}, \param{int }{sz}} + +This function returns the full user name (something like "Mr. John Smith"). + +Under Windows or NT, this function looks for the entry {\bf UserName}\rtfsp +in the {\bf wxWindows} section of the WIN.INI file. If PenWindows +is running, the entry {\bf Current} in the section {\bf User} of +the PENWIN.INI file is used. + +The first variant of this function returns the user name if successful or an +empty string otherwise. The second (deprecated) function returns TRUE +if successful, FALSE otherwise. + +\wxheading{See also} + +\helpref{wxGetUserId}{wxgetuserid} + +\wxheading{Include files} + + + \section{String functions} \membersection{::copystring} @@ -267,23 +434,69 @@ A macro defined as: #define wxStringEq(s1, s2) (s1 && s2 && (strcmp(s1, s2) == 0)) \end{verbatim} -\membersection{::wxTransferFileToStream}\label{wxtransferfiletostream} +\membersection{::IsEmpty}\label{isempty} -\func{bool}{wxTransferFileToStream}{\param{const wxString\& }{filename}, \param{ostream\& }{stream}} +\func{bool}{IsEmpty}{\param{const char *}{ p}} -Copies the given file to {\it stream}. Useful when converting an old application to -use streams (within the document/view framework, for example). +Returns TRUE if the string is empty, FALSE otherwise. It is safe to pass NULL +pointer to this function and it will return TRUE for it. -Use of this function requires the file wx\_doc.h to be included. +\membersection{::Stricmp}\label{stricmp} -\membersection{::wxTransferStreamToFile}\label{wxtransferstreamtofile} +\func{int}{Stricmp}{\param{const char *}{p1}, \param{const char *}{p2}} -\func{bool}{wxTransferStreamToFile}{\param{istream\& }{stream} \param{const wxString\& }{filename}} +Returns a negative value, 0, or positive value if {\it p1} is less than, equal +to or greater than {\it p2}. The comparison is case-insensitive. -Copies the given stream to the file {\it filename}. Useful when converting an old application to -use streams (within the document/view framework, for example). +This function complements the standard C function {\it strcmp()} which performs +case-sensitive comparison. -Use of this function requires the file wx\_doc.h to be included. +\membersection{::Strlen}\label{strlen} + +\func{size\_t}{Strlen}{\param{const char *}{ p}} + +This is a safe version of standard function {\it strlen()}: it does exactly the +same thing (i.e. returns the length of the string) except that it returns 0 if +{\it p} is the NULL pointer. + +\membersection{::wxGetTranslation}\label{wxgettranslation} + +\func{const char *}{wxGetTranslation}{\param{const char * }{str}} + +This function returns the translation of string {\it str} in the current +\helpref{locale}{wxlocale}. If the string is not found in any of the loaded +message catalogs (see \helpref{i18n overview}{internationalization}), the +original string is returned. In debug build, an error message is logged - this +should help to find the strings which were not yet translated. As this function +is used very often, an alternative syntax is provided: the \_() macro is +defined as wxGetTranslation(). + +\membersection{::wxSnprintf}\label{wxsnprintf} + +\func{int}{wxSnprintf}{\param{wxChar *}{buf}, \param{size\_t }{len}, \param{const wxChar *}{format}, \param{}{...}} + +This function replaces the dangerous standard function {\tt sprintf()} and is +like {\tt snprintf()} available on some platforms. The only difference with +sprintf() is that an additional argument - buffer size - is taken and the +buffer is never overflowed. + +Returns the number of characters copied to the buffer or -1 if there is not +enough space. + +\wxheading{See also} + +\helpref{wxVsnprintf}{wxvsnprintf}, \helpref{wxString::Printf}{wxstringprintf} + +\membersection{::wxVsnprintf}\label{wxvsnprintf} + +\func{int}{wxVsnprintf}{\param{wxChar *}{buf}, \param{size\_t }{len}, \param{const wxChar *}{format}, \param{va\_list }{argptr}} + +The same as \helpref{wxSnprintf}{wxsnprintf} but takes a {\tt va\_list} +argument instead of arbitrary number of parameters. + +\wxheading{See also} + +\helpref{wxSnprintf}{wxsnprintf}, \helpref{wxString::PrintfV}{wxstringprintfv} \section{Dialog functions}\label{dialogfunctions} @@ -293,64 +506,136 @@ parameters are optional. However, it is recommended to pass a parent frame parameter, or (in MS Windows or Motif) the wrong window frame may be brought to the front when the dialog box is popped up. +\membersection{::wxCreateFileTipProvider}\label{wxcreatefiletipprovider} + +\func{wxTipProvider *}{wxCreateFileTipProvider}{\param{const wxString\& }{filename}, + \param{size\_t }{currentTip}} + +This function creates a \helpref{wxTipProvider}{wxtipprovider} which may be +used with \helpref{wxShowTip}{wxshowtip}. + +\docparam{filename}{The name of the file containing the tips, one per line} +\docparam{currentTip}{The index of the first tip to show - normally this index +is remembered between the 2 program runs.} + +\wxheading{See also} + +\helpref{Tips overview}{tipsoverview} + +\wxheading{Include files} + + + \membersection{::wxFileSelector}\label{wxfileselector} -\func{wxString}{wxFileSelector}{\param{const wxString\& }{message}, \param{const wxString\& }{default\_path = NULL},\\ - \param{const wxString\& }{default\_filename = NULL}, \param{const wxString\& }{default\_extension = NULL},\\ - \param{const wxString\& }{wildcard = ``*.*''}, \param{int }{flags = 0}, \param{wxWindow *}{parent = NULL},\\ - \param{int}{ x = -1}, \param{int}{ y = -1}} +\func{wxString}{wxFileSelector}{\param{const wxString\& }{message}, \param{const wxString\& }{default\_path = ""},\\ + \param{const wxString\& }{default\_filename = ""}, \param{const wxString\& }{default\_extension = ""},\\ + \param{const wxString\& }{wildcard = ``*.*''}, \param{int }{flags = 0}, \param{wxWindow *}{parent = ""},\\ + \param{int}{ x = -1}, \param{int}{ y = -1}} Pops up a file selector box. In Windows, this is the common file selector -dialog. In X, this is a file selector box with somewhat less functionality. +dialog. In X, this is a file selector box with the same functionality. The path and filename are distinct elements of a full file pathname. -If path is NULL, the current directory will be used. If filename is NULL, +If path is empty, the current directory will be used. If filename is empty, no default filename will be supplied. The wildcard determines what files are displayed in the file selector, and file extension supplies a type extension for the required filename. Flags may be a combination of wxOPEN, -wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, or 0. They are only significant -at present in Windows. +wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, wxFILE\_MUST\_EXIST, wxMULTIPLE or 0. -Both the X and Windows versions implement a wildcard filter. Typing a +Both the Unix and Windows versions implement a wildcard filter. Typing a filename containing wildcards (*, ?) in the filename text item, and clicking on Ok, will result in only those files matching the pattern being -displayed. In the X version, supplying no default name will result in the -wildcard filter being inserted in the filename text item; the filter is -ignored if a default name is supplied. +displayed. -Under Windows (only), the wildcard may be a specification for multiple -types of file with a description for each, such as: +The wildcard may be a specification for multiple types of file +with a description for each, such as: \begin{verbatim} - "BMP files (*.bmp) | *.bmp | GIF files (*.gif) | *.gif" + "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif" \end{verbatim} -The application must check for a NULL return value (the user pressed +The application must check for an empty return value (the user pressed Cancel). For example: \begin{verbatim} -const wxString\& s = wxFileSelector("Choose a file to open"); +const wxString& s = wxFileSelector("Choose a file to open"); if (s) { ... } \end{verbatim} -Remember that the returned pointer is temporary and should be copied -if other wxWindows calls will be made before the value is to be used. - \wxheading{Include files} +\membersection{::wxGetColourFromUser}\label{wxgetcolourfromuser} + +\func{wxColour}{wxGetColourFromUser}{\param{wxWindow *}{parent}, \param{const wxColour\& }{colInit}} + +Shows the colour selection dialog and returns the colour selected by user or +invalid colour (use \helpref{wxColour::Ok}{wxcolourok} to test whether a colour +is valid) if the dialog was cancelled. + +\wxheading{Parameters} + +\docparam{parent}{The parent window for the colour selection dialog} + +\docparam{colInit}{If given, this will be the colour initially selected in the dialog.} + +\wxheading{Include files} + + + +\membersection{::wxGetNumberFromUser}\label{wxgetnumberfromuser} + +\func{long}{wxGetNumberFromUser}{ + \param{const wxString\& }{message}, + \param{const wxString\& }{prompt}, + \param{const wxString\& }{caption}, + \param{long }{value}, + \param{long }{min = 0}, + \param{long }{max = 100}, + \param{wxWindow *}{parent = NULL}, + \param{const wxPoint\& }{pos = wxDefaultPosition}} + +Shows a dialog asking the user for numeric input. The dialogs title is set to +{\it caption}, it contains a (possibly) multiline {\it message} above the +single line {\it prompt} and the zone for entering the number. + +The number entered must be in the range {\it min}..{\it max} (both of which +should be positive) and {\it value} is the initial value of it. If the user +enters an invalid value or cancels the dialog, the function will return -1. + +Dialog is centered on its {\it parent} unless an explicit position is given in +{\it pos}. + +\wxheading{Include files} + + + +\membersection{::wxGetPasswordFromUser}\label{wxgetpasswordfromuser} + +\func{wxString}{wxGetTextFromUser}{\param{const wxString\& }{message}, \param{const wxString\& }{caption = ``Input text"},\\ + \param{const wxString\& }{default\_value = ``"}, \param{wxWindow *}{parent = NULL}} + +Similar to \helpref{wxGetTextFromUser}{wxgettextfromuser} but the text entered +in the dialog is not shown on screen but replaced with stars. This is intended +to be used for entering passwords as the function name implies. + +\wxheading{Include files} + + + \membersection{::wxGetTextFromUser}\label{wxgettextfromuser} \func{wxString}{wxGetTextFromUser}{\param{const wxString\& }{message}, \param{const wxString\& }{caption = ``Input text"},\\ - \param{const wxString\& }{default\_value = ``"}, \param{wxWindow *}{parent = NULL},\\ - \param{int}{ x = -1}, \param{int}{ y = -1}, \param{bool}{ centre = TRUE}} + \param{const wxString\& }{default\_value = ``"}, \param{wxWindow *}{parent = NULL},\\ + \param{int}{ x = -1}, \param{int}{ y = -1}, \param{bool}{ centre = TRUE}} Pop up a dialog box with title set to {\it caption}, message {\it message}, and a \rtfsp{\it default\_value}. The user may type in text and press OK to return this text, -or press Cancel to return NULL. +or press Cancel to return the empty string. If {\it centre} is TRUE, the message text (which may include new line characters) is centred; if FALSE, the message is left-justified. @@ -362,9 +647,9 @@ is centred; if FALSE, the message is left-justified. \membersection{::wxGetMultipleChoice}\label{wxgetmultiplechoice} \func{int}{wxGetMultipleChoice}{\param{const wxString\& }{message}, \param{const wxString\& }{caption}, \param{int}{ n}, \param{const wxString\& }{choices[]},\\ - \param{int }{nsel}, \param{int *}{selection}, - \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1},\\ - \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}} + \param{int }{nsel}, \param{int *}{selection}, + \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1},\\ + \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}} Pops up a dialog box containing a message, OK/Cancel buttons and a multiple-selection listbox. The user may choose one or more item(s) and press OK or Cancel. @@ -388,12 +673,12 @@ is centred; if FALSE, the message is left-justified. \membersection{::wxGetSingleChoice}\label{wxgetsinglechoice} \func{wxString}{wxGetSingleChoice}{\param{const wxString\& }{message}, \param{const wxString\& }{caption}, \param{int}{ n}, \param{const wxString\& }{choices[]},\\ - \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1},\\ - \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}} + \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1},\\ + \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}} Pops up a dialog box containing a message, OK/Cancel buttons and a single-selection listbox. The user may choose an item and press OK to return a string or -Cancel to return NULL. +Cancel to return the empty string. {\it choices} is an array of {\it n} strings for the listbox. @@ -407,8 +692,8 @@ is centred; if FALSE, the message is left-justified. \membersection{::wxGetSingleChoiceIndex}\label{wxgetsinglechoiceindex} \func{int}{wxGetSingleChoiceIndex}{\param{const wxString\& }{message}, \param{const wxString\& }{caption}, \param{int}{ n}, \param{const wxString\& }{choices[]},\\ - \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1},\\ - \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}} + \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1},\\ + \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}} As {\bf wxGetSingleChoice} but returns the index representing the selected string. If the user pressed cancel, -1 is returned. @@ -420,8 +705,8 @@ If the user pressed cancel, -1 is returned. \membersection{::wxGetSingleChoiceData}\label{wxgetsinglechoicedata} \func{wxString}{wxGetSingleChoiceData}{\param{const wxString\& }{message}, \param{const wxString\& }{caption}, \param{int}{ n}, \param{const wxString\& }{choices[]},\\ - \param{const wxString\& }{client\_data[]}, \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1},\\ - \param{int}{ y = -1}, \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}} + \param{const wxString\& }{client\_data[]}, \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1},\\ + \param{int}{ y = -1}, \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}} As {\bf wxGetSingleChoice} but takes an array of client data pointers corresponding to the strings, and returns one of these pointers. @@ -433,7 +718,7 @@ corresponding to the strings, and returns one of these pointers. \membersection{::wxMessageBox}\label{wxmessagebox} \func{int}{wxMessageBox}{\param{const wxString\& }{message}, \param{const wxString\& }{caption = ``Message"}, \param{int}{ style = wxOK \pipe wxCENTRE},\\ - \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1}} + \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1}} General purpose message dialog. {\it style} may be a bit list of the following identifiers: @@ -476,6 +761,31 @@ The symbols are not shown when the generic function is used. +\membersection{::wxShowTip}\label{wxshowtip} + +\func{bool}{wxShowTip}{\param{wxWindow *}{parent}, + \param{wxTipProvider *}{tipProvider}, + \param{bool }{showAtStartup = TRUE}} + +This function shows a "startup tip" to the user. + +\docparam{parent}{The parent window for the modal dialog} + +\docparam{tipProvider}{An object which is used to get the text of the tips. +It may be created with the \helpref{wxCreateFileTipProvider}{wxcreatefiletipprovider} function.} + +\docparam{showAtStartup}{Should be TRUE if startup tips are shown, FALSE +otherwise. This is used as the initial value for "Show tips at startup" +checkbox which is shown in the tips dialog.} + +\wxheading{See also} + +\helpref{Tips overview}{tipsoverview} + +\wxheading{Include files} + + + \section{GDI functions}\label{gdifunctions} The following are relevant to the GDI (Graphics Device Interface). @@ -528,11 +838,13 @@ This function is only available under Windows. \func{void}{wxSetCursor}{\param{wxCursor *}{cursor}} -Globally sets the cursor; only has an effect in MS Windows. +Globally sets the cursor; only has an effect in Windows and GTK. See also \helpref{wxCursor}{wxcursor}, \helpref{wxWindow::SetCursor}{wxwindowsetcursor}. \section{Printer settings}\label{printersettings} +These routines are obsolete and should no longer be used! + The following functions are used to control PostScript printing. Under Windows, PostScript output can only be sent to a file. @@ -640,7 +952,9 @@ Sets the translation (from the top left corner) for PostScript output. The defau \section{Clipboard functions}\label{clipsboard} -These clipboard functions are implemented for Windows only. +These clipboard functions are implemented for Windows only. The use of these functions +is deprecated and the code is no longer maintained. Use the \helpref{wxClipboard}{wxclipboard} +class instead. \wxheading{Include files} @@ -803,7 +1117,7 @@ registered with the dynamic class system using DECLARE... and IMPLEMENT... macro Called when wxWindows exits, to clean up the DDE system. This no longer needs to be called by the application. -See also helpref{wxDDEInitialize}{wxddeinitialize}. +See also \helpref{wxDDEInitialize}{wxddeinitialize}. \wxheading{Include files} @@ -829,6 +1143,8 @@ See also \helpref{wxDDEServer}{wxddeserver}, \helpref{wxDDEClient}{wxddeclient}, \func{void}{wxDebugMsg}{\param{const wxString\& }{fmt}, \param{...}{}} +{\bf This function is deprecated, use \helpref{wxLogDebug}{wxlogdebug} instead!} + Display a debugging message; under Windows, this will appear on the debugger command window, and under Unix, it will be written to standard error. @@ -836,10 +1152,6 @@ error. The syntax is identical to {\bf printf}: pass a format string and a variable list of arguments. -Note that under Windows, you can see the debugging messages without a -debugger if you have the DBWIN debug log application that comes with -Microsoft C++. - {\bf Tip:} under Windows, if your application crashes before the message appears in the debugging window, put a wxYield call after each wxDebugMsg call. wxDebugMsg seems to be broken under WIN32s @@ -862,6 +1174,17 @@ Gets the physical size of the display in pixels. +\membersection{::wxEnableTopLevelWindows}\label{wxenabletoplevelwindows} + +\func{void}{wxEnableTopLevelWindow}{\param{bool}{ enable = TRUE}} + +This function enables or disables all top level windows. It is used by +\helpref{::wxSafeYield}{wxsafeyield}. + +\wxheading{Include files} + + + \membersection{::wxEntry}\label{wxentry} This initializes wxWindows in a platform-dependent way. Use this if you @@ -905,26 +1228,26 @@ int CTheApp::ExitInstance() -\membersection{::wxError}\label{wxerror} +\membersection{::wxEndBusyCursor}\label{wxendbusycursor} -\func{void}{wxError}{\param{const wxString\& }{msg}, \param{const wxString\& }{title = "wxWindows Internal Error"}} +\func{void}{wxEndBusyCursor}{\void} -Displays {\it msg} and continues. This writes to standard error under -Unix, and pops up a message box under Windows. Used for internal -wxWindows errors. See also \helpref{wxFatalError}{wxfatalerror}. +Changes the cursor back to the original cursor, for all windows in the application. +Use with \helpref{wxBeginBusyCursor}{wxbeginbusycursor}. + +See also \helpref{wxIsBusy}{wxisbusy}, \helpref{wxBusyCursor}{wxbusycursor}. \wxheading{Include files} -\membersection{::wxEndBusyCursor}\label{wxendbusycursor} - -\func{void}{wxEndBusyCursor}{\void} +\membersection{::wxError}\label{wxerror} -Changes the cursor back to the original cursor, for all windows in the application. -Use with \helpref{wxBeginBusyCursor}{wxbeginbusycursor}. +\func{void}{wxError}{\param{const wxString\& }{msg}, \param{const wxString\& }{title = "wxWindows Internal Error"}} -See also \helpref{wxIsBusy}{wxisbusy}, \helpref{wxBusyCursor}{wxbusycursor}. +Displays {\it msg} and continues. This writes to standard error under +Unix, and pops up a message box under Windows. Used for internal +wxWindows errors. See also \helpref{wxFatalError}{wxfatalerror}. \wxheading{Include files} @@ -936,6 +1259,8 @@ See also \helpref{wxIsBusy}{wxisbusy}, \helpref{wxBusyCursor}{wxbusycursor}. \func{long}{wxExecute}{\param{char **}{argv}, \param{bool }{sync = FALSE}, \param{wxProcess *}{callback = NULL}} +\func{long}{wxExecute}{\param{const wxString\& }{command}, \param{wxArrayString\& }{output}} + Executes another program in Unix or Windows. The first form takes a command string, such as {\tt "emacs file.txt"}. @@ -943,18 +1268,34 @@ The first form takes a command string, such as {\tt "emacs file.txt"}. The second form takes an array of values: a command, any number of arguments, terminated by NULL. +The semantics of the third version is different from the first two and is +described in more details below. + If {\it sync} is FALSE (the default), flow of control immediately returns. If TRUE, the current application waits until the other program has terminated. -If execution is asynchronous, the return value is the process id, -otherwise it is a status value. A zero value indicates that the command could not -be executed. +In the case of synchronous execution, the return value is the exit code of +the process (which terminates by the moment the function returns) and will be +$-1$ if the process couldn't be started and typically 0 if the process +terminated successfully. Also, while waiting for the process to +terminate, wxExecute will call \helpref{wxYield}{wxyield}. The caller +should ensure that this can cause no recursion, in the simplest case by +calling \helpref{wxEnableTopLevelWindows(FALSE)}{wxenabletoplevelwindows}. -If callback isn't NULL and if execution is asynchronous, +For asynchronous execution, however, the return value is the process id and +zero value indicates that the command could not be executed. + +If callback isn't NULL and if execution is asynchronous (note that callback +parameter can not be non NULL for synchronous execution), \helpref{wxProcess::OnTerminate}{wxprocessonterminate} will be called when the process finishes. -See also \helpref{wxShell}{wxshell}, \helpref{wxProcess}{wxprocess}. +Finally, you may use the third overloaded version of this function to execute +a process (always synchronously) and capture its output in the array +{\it output}. + +See also \helpref{wxShell}{wxshell}, \helpref{wxProcess}{wxprocess}, +\helpref{Exec sample}{sampleexec}. \wxheading{Include files} @@ -1043,24 +1384,15 @@ Under X only, returns the current display name. See also \helpref{wxSetDisplayNa -\membersection{::wxGetHomeDir} +\membersection{::wxGetHomeDir}\label{wxgethomedir} -\func{wxString}{wxGetHomeDir}{\param{const wxString\& }{buf}} +\func{wxString}{wxGetHomeDir}{\void} -Fills the buffer with a string representing the user's home directory (Unix only). - -\wxheading{Include files} - - +Return the (current) user's home directory. -\membersection{::wxGetHostName} - -\func{bool}{wxGetHostName}{\param{const wxString\& }{buf}, \param{int}{ bufSize}} +\wxheading{See also} -Copies the host name of the machine the program is running on into the -buffer {\it buf}, of maximum size {\it bufSize}, returning TRUE if -successful. Under Unix, this will return a machine name. Under Windows, -this returns ``windows''. +\helpref{wxGetUserHome}{wxgetuserhome} \wxheading{Include files} @@ -1103,7 +1435,23 @@ Returns the mouse position in screen coordinates. -\membersection{::wxGetOsVersion} +\membersection{::wxGetOsDescription}\label{wxgetosdescription} + +\func{wxString}{wxGetOsDescription}{\void} + +Returns the string containing the description of the current platform in a +user-readable form. For example, this function may return strings like +{\tt Windows NT Version 4.0} or {\tt Linux 2.2.2 i386}. + +\wxheading{See also} + +\helpref{::wxGetOsVersion}{wxgetosversion} + +\wxheading{Include files} + + + +\membersection{::wxGetOsVersion}\label{wxgetosversion} \func{int}{wxGetOsVersion}{\param{int *}{major = NULL}, \param{int *}{minor = NULL}} @@ -1112,16 +1460,21 @@ Gets operating system version information. \begin{twocollist}\itemsep=0pt \twocolitemruled{Platform}{Return tyes} \twocolitem{Macintosh}{Return value is wxMACINTOSH.} -\twocolitem{GTK}{Return value is wxGTK, {\it major} is 1, {\it minor} is 0. (for GTK 1.0.X) } +\twocolitem{GTK}{Return value is wxGTK, For GTK 1.0, {\it major} is 1, {\it minor} is 0. } \twocolitem{Motif}{Return value is wxMOTIF\_X, {\it major} is X version, {\it minor} is X revision.} \twocolitem{OS/2}{Return value is wxOS2\_PM.} \twocolitem{Windows 3.1}{Return value is wxWINDOWS, {\it major} is 3, {\it minor} is 1.} -\twocolitem{Windows NT}{Return value is wxWINDOWS\_NT, {\it major} is 3, {\it minor} is 1.} -\twocolitem{Windows 95}{Return value is wxWIN95, {\it major} is 3, {\it minor} is 1.} +\twocolitem{Windows NT/2000}{Return value is wxWINDOWS\_NT, version is returned in {\it major} and {\it minor}} +\twocolitem{Windows 98}{Return value is wxWIN95, {\it major} is 4, {\it minor} is 1 or greater.} +\twocolitem{Windows 95}{Return value is wxWIN95, {\it major} is 4, {\it minor} is 0.} \twocolitem{Win32s (Windows 3.1)}{Return value is wxWIN32S, {\it major} is 3, {\it minor} is 1.} \twocolitem{Watcom C++ 386 supervisor mode (Windows 3.1)}{Return value is wxWIN386, {\it major} is 3, {\it minor} is 1.} \end{twocollist} +\wxheading{See also} + +\helpref{::wxGetOsDescription}{wxgetosdescription} + \wxheading{Include files} @@ -1172,6 +1525,18 @@ Under Windows, this returns ``user''. +\membersection{::wxGetUserHome}\label{wxgetuserhome} + +\func{const wxChar *}{wxGetUserHome}{\param{const wxString\& }{user = ""}} + +Returns the home directory for the given user. If the username is empty +(default value), this function behaves like +\helpref{wxGetHomeDir}{wxgethomedir}. + +\wxheading{Include files} + + + \membersection{::wxGetUserName} \func{bool}{wxGetUserName}{\param{const wxString\& }{buf}, \param{int}{ bufSize}} @@ -1198,6 +1563,17 @@ It does not raise a signal in the receiving process. +\membersection{::wxInitAllImageHandlers}\label{wxinitallimagehandlers} + +\func{void}{wxInitAllImageHandlers}{\void} + +Initializes all available image handlers. For a list of available handlers, +see \helpref{wxImage}{wximage}. + +\wxheading{See also} + +\helpref{wxImage}{wximage}, \helpref{wxImageHandler}{wximagehandler} + \membersection{::wxIsBusy}\label{wxisbusy} \func{bool}{wxIsBusy}{\void} @@ -1261,6 +1637,45 @@ Now obsolete: use \helpref{wxWindow::Close}{wxwindowclose} instead. +\membersection{::wxPostEvent}\label{wxpostevent} + +\func{void}{wxPostEvent}{\param{wxEvtHandler *}{dest}, \param{wxEvent\& }{event}} + +This function posts the event to the specified {\it dest} object. The +difference between sending an event and posting it is that in the first case +the event is processed before the function returns (in wxWindows, event sending +is done with \helpref{ProcessEvent}{wxevthandlerprocessevent} function), but in +the second, the function returns immediately and the event will be processed +sometime later - usually during the next even loop iteration. + +Note that a copy of the {\it event} is made by the function, so the original +copy can be deleted as soon as function returns. This function can also be used +to send events between different threads safely. As this function makes a +copy of the event, the event needs to have a fully implemented Clone() method, +which may not be the case for all event in wxWindows. + +See also \helpref{AddPendingEvent}{wxevthandleraddpendingevent} (which this function +uses internally). + +\wxheading{Include files} + + + +\membersection{::wxSafeYield}\label{wxsafeyield} + +\func{bool}{wxSafeYield}{\param{wxWindow*}{ win = NULL}} + +This function is similar to wxYield, except that it disables the user input to +all program windows before calling wxYield and re-enables it again +afterwards. If {\it win} is not NULL, this window will remain enabled, +allowing the implementation of some limited user interaction. + +Returns the result of the call to \helpref{::wxYield}{wxyield}. + +\wxheading{Include files} + + + \membersection{::wxSetDisplayName}\label{wxsetdisplayname} \func{void}{wxSetDisplayName}{\param{const wxString\& }{displayName}} @@ -1283,7 +1698,7 @@ See also \helpref{wxGetDisplayName}{wxgetdisplayname}. Executes a command in an interactive shell window. If no command is specified, then just the shell is spawned. -See also \helpref{wxExecute}{wxexecute}. +See also \helpref{wxExecute}{wxexecute}, \helpref{Exec sample}{sampleexec}. \wxheading{Include files} @@ -1376,6 +1791,18 @@ This function is now obsolete, replaced by \helpref{Log functions}{logfunctions} +\membersection{::wxUsleep}\label{wxusleep} + +\func{void}{wxUsleep}{\param{unsigned long}{ milliseconds}} + +Sleeps for the specified number of milliseconds. Notice that usage of this +function is encouraged instead of calling usleep(3) directly because the +standard usleep() function is not MT safe. + +\wxheading{Include files} + + + \membersection{::wxWriteResource}\label{wxwriteresource} \func{bool}{wxWriteResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry}, @@ -1407,50 +1834,104 @@ See also \helpref{wxGetResource}{wxgetresource}, \helpref{wxConfigBase}{wxconfig -\membersection{::wxYield} +\membersection{::wxYield}\label{wxyield} \func{bool}{wxYield}{\void} Yields control to pending messages in the windowing system. This can be useful, for example, when a time-consuming process writes to a text window. Without an occasional -yield, the text window will not be updated properly, and (since Windows -multitasking is cooperative) other processes will not respond. +yield, the text window will not be updated properly, and on systems with +cooperative multitasking, such as Windows 3.1 other processes will not respond. Caution should be exercised, however, since yielding may allow the user to perform actions which are not compatible with the current task. Disabling menu items or whole menus during processing can avoid unwanted -reentrance of code. +reentrance of code: see \helpref{::wxSafeYield}{wxsafeyield} for a better +function. + +Note that wxYield will not flush the message logs. This is intentional as +calling wxYield is usually done to quickly update the screen and popping up a +message box dialog may be undesirable. If you do with to flush the log +messages immediately (otherwise it will be done during the next idle loop +iteration), call \helpref{wxLog::FlushActive}{wxlogflushactive}. \wxheading{Include files} - + or + +\membersection{::wxWakeUpIdle}\label{wxwakeupidle} + +\func{void}{wxWakeUpIdle}{\void} + +This functions wakes up the (internal and platform dependent) idle system, i.e. it +will force the system to send an idle event even if the system currently {\it is} +idle and thus would not send any idle event until after some other event would get +sent. This is also useful for sending events between two threads and is used by +the corresponding functions \helpref{::wxPostEvent}{wxpostevent} and +\helpref{wxEvtHandler::AddPendingEvent}{wxevthandleraddpendingevent}. + +\wxheading{Include files} + + \section{Macros}\label{macros} These macros are defined in wxWindows. -\membersection{CLASSINFO}\label{classinfo} +\membersection{wxINTXX\_SWAP\_ALWAYS}\label{intswapalways} -\func{wxClassInfo *}{CLASSINFO}{className} +\func{wxInt32}{wxINT32\_SWAP\_ALWAYS}{\param{wxInt32 }{value}} -Returns a pointer to the wxClassInfo object associated with this class. +\func{wxUint32}{wxUINT32\_SWAP\_ALWAYS}{\param{wxUint32 }{value}} -\wxheading{Include files} +\func{wxInt16}{wxINT16\_SWAP\_ALWAYS}{\param{wxInt16 }{value}} - +\func{wxUint16}{wxUINT16\_SWAP\_ALWAYS}{\param{wxUint16 }{value}} -\membersection{WXDEBUG\_NEW}\label{debugnew} +This macro will swap the bytes of the {\it value} variable from little +endian to big endian or vice versa. -\func{}{WXDEBUG\_NEW}{arg} +\membersection{wxINTXX\_SWAP\_ON\_BE}\label{intswaponbe} -This is defined in debug mode to be call the redefined new operator -with filename and line number arguments. The definition is: +\func{wxInt32}{wxINT32\_SWAP\_ON\_BE}{\param{wxInt32 }{value}} -\begin{verbatim} -#define WXDEBUG_NEW new(__FILE__,__LINE__) -\end{verbatim} +\func{wxUint32}{wxUINT32\_SWAP\_ON\_BE}{\param{wxUint32 }{value}} -In non-debug mode, this is defined as the normal new operator. +\func{wxInt16}{wxINT16\_SWAP\_ON\_BE}{\param{wxInt16 }{value}} + +\func{wxUint16}{wxUINT16\_SWAP\_ON\_BE}{\param{wxUint16 }{value}} + +This macro will swap the bytes of the {\it value} variable from little +endian to big endian or vice versa if the program is compiled on a +big-endian architecture (such as Sun work stations). If the program has +been compiled on a little-endian architecture, the value will be unchanged. + +Use these macros to read data from and write data to a file that stores +data in little endian (Intel i386) format. + +\membersection{wxINTXX\_SWAP\_ON\_LE}\label{intswaponle} + +\func{wxInt32}{wxINT32\_SWAP\_ON\_LE}{\param{wxInt32 }{value}} + +\func{wxUint32}{wxUINT32\_SWAP\_ON\_LE}{\param{wxUint32 }{value}} + +\func{wxInt16}{wxINT16\_SWAP\_ON\_LE}{\param{wxInt16 }{value}} + +\func{wxUint16}{wxUINT16\_SWAP\_ON\_LE}{\param{wxUint16 }{value}} + +This macro will swap the bytes of the {\it value} variable from little +endian to big endian or vice versa if the program is compiled on a +little-endian architecture (such as Intel PCs). If the program has +been compiled on a big-endian architecture, the value will be unchanged. + +Use these macros to read data from and write data to a file that stores +data in big endian format. + +\membersection{CLASSINFO}\label{classinfo} + +\func{wxClassInfo *}{CLASSINFO}{className} + +Returns a pointer to the wxClassInfo object associated with this class. \wxheading{Include files} @@ -1653,8 +2134,93 @@ base classes. +\membersection{wxBITMAP}\label{wxbitmapmacro} + +\func{}{wxBITMAP}{bitmapName} + +This macro loads a bitmap from either application resources (on the platforms +for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to +avoid using {\tt \#ifdef}s when creating bitmaps. + +\wxheading{See also} + +\helpref{Bitmaps and icons overview}{wxbitmapoverview}, +\helpref{wxICON}{wxiconmacro} + +\wxheading{Include files} + + + +\membersection{WXDEBUG\_NEW}\label{debugnew} + +\func{}{WXDEBUG\_NEW}{arg} + +This is defined in debug mode to be call the redefined new operator +with filename and line number arguments. The definition is: + +\begin{verbatim} +#define WXDEBUG_NEW new(__FILE__,__LINE__) +\end{verbatim} + +In non-debug mode, this is defined as the normal new operator. + +\wxheading{Include files} + + + +\membersection{wxDynamicCast}\label{wxdynamiccast} + +\func{}{wxDynamicCast}{ptr, classname} + +This macro returns the pointer {\it ptr} cast to the type {\it classname *} if +the pointer is of this type (the check is done during the run-time) or NULL +otherwise. Usage of this macro is prefered over obsoleted wxObject::IsKindOf() +function. + +The {\it ptr} argument may be NULL, in which case NULL will be returned. + +Example: + +\begin{verbatim} + wxWindow *win = wxWindow::FindFocus(); + wxTextCtrl *text = wxDynamicCast(win, wxTextCtrl); + if ( text ) + { + // a text control has the focus... + } + else + { + // no window has the focus or it's not a text control + } +\end{verbatim} + +\wxheading{See also} + +\helpref{RTTI overview}{runtimeclassoverview} + +\membersection{wxICON}\label{wxiconmacro} + +\func{}{wxICON}{iconName} + +This macro loads an icon from either application resources (on the platforms +for which they exist, i.e. Windows and OS2) or from an XPM file. It allows to +avoid using {\tt \#ifdef}s when creating icons. + +\wxheading{See also} + +\helpref{Bitmaps and icons overview}{wxbitmapoverview}, +\helpref{wxBITMAP}{wxbitmapmacro} + +\wxheading{Include files} + + + \membersection{WXTRACE}\label{trace} +\wxheading{Include files} + + + \func{}{WXTRACE}{formatString, ...} Calls wxTrace with printf-style variable argument syntax. Output @@ -1882,7 +2448,9 @@ Another name for \helpref{wxResourceRegisterBitmapData}{registerbitmapdata}. \section{Log functions}\label{logfunctions} These functions provide a variety of logging functions: see \helpref{Log classes overview}{wxlogoverview} for -further information. +further information. The functions use (implicitly) the currently active log +target, so their descriptions here may not apply if the log target is not the +standard one (installed by wxWindows in the beginning of the program). \wxheading{Include files} @@ -1892,9 +2460,9 @@ further information. \func{void}{wxLogError}{\param{const char*}{ formatString}, \param{...}{}} -The function to use for error messages, i.e. the -messages that must be shown to the user. The default processing is to pop up a -message box to inform the user about it. +The function to use for error messages, i.e. the messages that must be shown +to the user. The default processing is to pop up a message box to inform the +user about it. \membersection{::wxLogFatalError}\label{wxlogfatalerror} @@ -1908,18 +2476,18 @@ function also terminates the program with this exit code. \func{void}{wxLogWarning}{\param{const char*}{ formatString}, \param{...}{}} -For warnings - they are also normally shown to the -user, but don't interrupt the program work. +For warnings - they are also normally shown to the user, but don't interrupt +the program work. \membersection{::wxLogMessage}\label{wxlogmessage} \func{void}{wxLogMessage}{\param{const char*}{ formatString}, \param{...}{}} -for all normal, informational messages. They also -appear in a message box by default (but it can be changed). Notice -that the standard behaviour is to not show informational messages if there are -any errors later - the logic being that the later error messages make the -informational messages preceding them meaningless. +for all normal, informational messages. They also appear in a message box by +default (but it can be changed). Notice that the standard behaviour is to not +show informational messages if there are any errors later - the logic being +that the later error messages make the informational messages preceding them +meaningless. \membersection{::wxLogVerbose}\label{wxlogverbose} @@ -1931,50 +2499,111 @@ progress (another, but possibly confusing name for the same function is {\bf wxL \membersection{::wxLogStatus}\label{wxlogstatus} +\func{void}{wxLogStatus}{\param{wxFrame *}{frame}, \param{const char*}{ formatString}, \param{...}{}} + \func{void}{wxLogStatus}{\param{const char*}{ formatString}, \param{...}{}} -For status messages - they will go into the status -bar of the active or specified (as the first argument) \helpref{wxFrame}{wxframe} if it has one. +Messages logged by this function will appear in the statusbar of the {\it +frame} or of the top level application window by default (i.e. when using +the second version of the function). + +If the target frame doesn't have a statusbar, the message will be lost. \membersection{::wxLogSysError}\label{wxlogsyserror} \func{void}{wxLogSysError}{\param{const char*}{ formatString}, \param{...}{}} -Mostly used by wxWindows itself, but might be -handy for logging errors after system call (API function) failure. It logs the -specified message text as well as the last system error code ({\it errno} or {\it ::GetLastError()} depending -on the platform) and the corresponding error -message. The second form of this function takes the error code explitly as the -first argument. +Mostly used by wxWindows itself, but might be handy for logging errors after +system call (API function) failure. It logs the specified message text as well +as the last system error code ({\it errno} or {\it ::GetLastError()} depending +on the platform) and the corresponding error message. The second form +of this function takes the error code explitly as the first argument. + +\wxheading{See also} + +\helpref{wxSysErrorCode}{wxsyserrorcode}, +\helpref{wxSysErrorMsg}{wxsyserrormsg} \membersection{::wxLogDebug}\label{wxlogdebug} \func{void}{wxLogDebug}{\param{const char*}{ formatString}, \param{...}{}} -The right function for debug output. It only -does anything at all in the debug mode (when the preprocessor symbol \_\_WXDEBUG\_\_ is defined) -and expands to nothing in release mode (otherwise). +The right function for debug output. It only does anything at all in the debug +mode (when the preprocessor symbol \_\_WXDEBUG\_\_ is defined) and expands to +nothing in release mode (otherwise). \membersection{::wxLogTrace}\label{wxlogtrace} \func{void}{wxLogTrace}{\param{const char*}{ formatString}, \param{...}{}} -\func{void}{wxLogTrace}{\param{wxTraceMask}{ mask}, \param{const char*}{ formatString}, \param{...}{}} +\func{void}{wxLogTrace}{\param{const char *}{mask}, \param{const char *}{formatString}, \param{...}{}} + +\func{void}{wxLogTrace}{\param{wxTraceMask}{ mask}, \param{const char *}{formatString}, \param{...}{}} + +As {\bf wxLogDebug}, trace functions only do something in debug build and +expand to nothing in the release one. The reason for making +it a separate function from it is that usually there are a lot of trace +messages, so it might make sense to separate them from other debug messages. -As {\bf wxLogDebug}, only does something in debug -build. The reason for making it a separate function from it is that usually -there are a lot of trace messages, so it might make sense to separate them -from other debug messages which would be flooded in them. Moreover, the second -version of this function takes a trace mask as the first argument which allows -to further restrict the amount of messages generated. The value of {\it mask} can be: +The trace messages also usually can be separated into different categories and +the second and third versions of this function only log the message if the +{\it mask} which it has is currently enabled in \helpref{wxLog}{wxlog}. This +allows to selectively trace only some operations and not others by changing +the value of the trace mask (possible during the run-time). + +For the second function (taking a string mask), the message is logged only if +the mask has been previously enabled by the call to +\helpref{AddTraceMask}{wxlogaddtracemask}. The predefined string trace masks +used by wxWindows are: + +\begin{itemize}\itemsep=0pt +\item wxTRACE\_MemAlloc: trace memory allocation (new/delete) +\item wxTRACE\_Messages: trace window messages/X callbacks +\item wxTRACE\_ResAlloc: trace GDI resource allocation +\item wxTRACE\_RefCount: trace various ref counting operations +\item wxTRACE\_OleCalls: trace OLE method calls (Win32 only) +\end{itemize} + +The third version of the function only logs the message if all the bit +corresponding to the {\it mask} are set in the wxLog trace mask which can be +set by \helpref{SetTraceMask}{wxlogsettracemask}. This version is less +flexible than the previous one because it doesn't allow defining the user +trace masks easily - this is why it is deprecated in favour of using string +trace masks. \begin{itemize}\itemsep=0pt \item wxTraceMemAlloc: trace memory allocation (new/delete) \item wxTraceMessages: trace window messages/X callbacks \item wxTraceResAlloc: trace GDI resource allocation \item wxTraceRefCount: trace various ref counting operations +\item wxTraceOleCalls: trace OLE method calls (Win32 only) \end{itemize} +\membersection{::wxSysErrorCode}\label{wxsyserrorcode} + +\func{unsigned long}{wxSysErrorCode}{\void} + +Returns the error code from the last system call. This function uses +{\tt errno} on Unix platforms and {\tt GetLastError} under Win32. + +\wxheading{See also} + +\helpref{wxSysErrorMsg}{wxsyserrormsg}, +\helpref{wxLogSysError}{wxlogsyserror} + +\membersection{::wxSysErrorMsg}\label{wxsyserrormsg} + +\func{const wxChar *}{wxSysErrorMsg}{\param{unsigned long }{errCode = 0}} + +Returns the error message corresponding to the given system error code. If +{\it errCode} is $0$ (default), the last error code (as returned by +\helpref{wxSysErrorCode}{wxsyserrorcode}) is used. + +\wxheading{See also} + +\helpref{wxSysErrorCode}{wxsyserrorcode}, +\helpref{wxLogSysError}{wxlogsyserror} + \section{Debugging macros and functions}\label{debugmacros} Useful macros and functins for error checking and defensive programming. ASSERTs are only @@ -1998,7 +2627,13 @@ assertion). \func{}{wxASSERT}{\param{}{condition}} -Assert macro. An error message will be generated if the condition is FALSE. +Assert macro. An error message will be generated if the condition is FALSE in +debug mode, but nothing will be done in the release build. + +Please note that the condition in wxASSERT() should have no side effects +because it will not be executed in release mode at all. + +See also: \helpref{wxASSERT\_MSG}{wxassertmsg} \membersection{wxASSERT\_MSG}\label{wxassertmsg} @@ -2006,18 +2641,28 @@ Assert macro. An error message will be generated if the condition is FALSE. Assert macro with message. An error message will be generated if the condition is FALSE. +See also: \helpref{wxASSERT}{wxassert} + \membersection{wxFAIL}\label{wxfail} -\func{}{wxFAIL}{\param{}{condition}} +\func{}{wxFAIL}{\void} Will always generate an assert error if this code is reached (in debug mode). +See also: \helpref{wxFAIL\_MSG}{wxfailmsg} + \membersection{wxFAIL\_MSG}\label{wxfailmsg} -\func{}{wxFAIL\_MSG}{\param{}{condition}, \param{}{msg}} +\func{}{wxFAIL\_MSG}{\param{}{msg}} Will always generate an assert error with specified message if this code is reached (in debug mode). +This macro is useful for marking unreachable" code areas, for example +it may be used in the "default:" branch of a switch statement if all possible +cases are processed above. + +See also: \helpref{wxFAIL}{wxfail} + \membersection{wxCHECK}\label{wxcheck} \func{}{wxCHECK}{\param{}{condition}, \param{}{retValue}} @@ -2032,3 +2677,35 @@ This check is done even in release mode. Checks that the condition is true, returns with the given return value if not (FAILs in debug mode). This check is done even in release mode. +This macro may be only used in non void functions, see also +\helpref{wxCHECK\_RET}{wxcheckret}. + +\membersection{wxCHECK\_RET}\label{wxcheckret} + +\func{}{wxCHECK\_RET}{\param{}{condition}, \param{}{msg}} + +Checks that the condition is true, and returns if not (FAILs with given error +message in debug mode). This check is done even in release mode. + +This macro should be used in void functions instead of +\helpref{wxCHECK\_MSG}{wxcheckmsg}. + +\membersection{wxCHECK2}\label{wxcheck2} + +\func{}{wxCHECK2}{\param{}{condition}, \param{}{operation}} + +Checks that the condition is true and \helpref{wxFAIL}{wxfail} and execute +{\it operation} if it is not. This is a generalisation of +\helpref{wxCHECK}{wxcheck} and may be used when something else than just +returning from the function must be done when the {\it condition} is false. + +This check is done even in release mode. + +\membersection{wxCHECK2\_MSG}\label{wxcheck2msg} + +\func{}{wxCHECK2}{\param{}{condition}, \param{}{operation}, \param{}{msg}} + +This is the same as \helpref{wxCHECK2}{wxcheck2}, but +\helpref{wxFAIL\_MSG}{wxfailmsg} with the specified {\it msg} is called +instead of wxFAIL() if the {\it condition} is false. +