X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/44353523d85ba44f62bad4ab7b27a14001d4b1ae..83cda8eb0a329674400977aafb8772dcda39a68e:/docs/latex/wx/function.tex

diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex
index 42069bf337..b96a451336 100644
--- a/docs/latex/wx/function.tex
+++ b/docs/latex/wx/function.tex
@@ -1,3 +1,14 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Name:        function.tex
+%% Purpose:     Functions and macros
+%% Author:      wxWidgets Team
+%% Modified by:
+%% Created:
+%% RCS-ID:      $Id$
+%% Copyright:   (c) wxWidgets Team
+%% License:     wxWindows license
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 \chapter{Functions}\label{functions}
 \setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
 \setfooter{\thepage}{}{}{}{}{\thepage}
@@ -164,6 +175,7 @@ the corresponding topic.
 \helpref{wxIsNaN}{wxisnan}\\
 \helpref{wxIsWild}{wxiswild}\\
 \helpref{wxKill}{wxkill}\\
+\helpref{wxLaunchDefaultBrowser}{wxlaunchdefaultbrowser}\\
 \helpref{wxLEAVE\_CRIT\_SECT}{wxleavecritsect}\\
 \helpref{wxLoadUserResource}{wxloaduserresource}\\
 \helpref{wxLogDebug}{wxlogdebug}\\
@@ -188,9 +200,11 @@ the corresponding topic.
 \helpref{wxNewId}{wxnewid}\\
 \helpref{wxNow}{wxnow}\\
 \helpref{wxOnAssert}{wxonassert}\\
+\helpref{wxON\_BLOCK\_EXIT}{wxonblockexit}\\
+\helpref{wxON\_BLOCK\_EXIT\_OBJ}{wxonblockexitobj}\\
 \helpref{wxOpenClipboard}{wxopenclipboard}\\
 \helpref{wxParseCommonDialogsFilter}{wxparsecommondialogsfilter}\\
-\helpref{wxPathExists}{functionwxpathexists}\\
+\helpref{wxDirExists}{functionwxdirexists}\\
 \helpref{wxPathOnly}{wxpathonly}\\
 \helpref{wxPostDelete}{wxpostdelete}\\
 \helpref{wxPostEvent}{wxpostevent}\\
@@ -226,6 +240,7 @@ the corresponding topic.
 \helpref{wxStricmp}{wxstricmp}\\
 \helpref{wxStringEq}{wxstringeq}\\
 \helpref{wxStringMatch}{wxstringmatch}\\
+\helpref{wxStringTokenize}{wxstringtokenize}\\
 \helpref{wxStripMenuCodes}{wxstripmenucodes}\\
 \helpref{wxStrlen}{wxstrlen}\\
 \helpref{wxSysErrorCode}{wxsyserrorcode}\\
@@ -249,7 +264,9 @@ the corresponding topic.
 \helpref{wx\_const\_cast}{wxconstcastraw}\\
 \helpref{wx\_reinterpret\_cast}{wxreinterpretcastraw}\\
 \helpref{wx\_static\_cast}{wxstaticcastraw}\\
+\helpref{wx\_truncate\_cast}{wxtruncatecast}\\
 \helpref{\_}{underscore}\\
+\helpref{wxPLURAL}{wxplural}\\
 \helpref{\_T}{underscoret}
 
 
@@ -435,7 +452,7 @@ This function is used in wxBase only and only if you don't create
 \helpref{wxApp}{wxapp} object at all. In this case you must call it from your
 {\tt main()} function before calling any other wxWidgets functions.
 
-If the function returns {\tt false} the initialization could not be performed,
+If the function returns \false the initialization could not be performed,
 in this case the library cannot be used and
 \helpref{wxUninitialize}{wxuninitialize} shouldn't be called neither.
 
@@ -584,7 +601,7 @@ happening, i.e. with this flag the child process window will be shown normally.
 Under Unix the flag {\tt wxEXEC\_MAKE\_GROUP\_LEADER} may be used to ensure
 that the new process is a group leader (this will create a new session if
 needed). Calling \helpref{wxKill}{wxkill} passing wxKILL\_CHILDREN will
-will kill this process as well as all of its children (except those which have
+kill this process as well as all of its children (except those which have
 started their own session).
 
 Finally, you may use the third overloaded version of this function to execute
@@ -740,7 +757,7 @@ and that this function is only implemented under Unix and Win32.
 
 \wxheading{Returns}
 
-{\tt true} on success, {\tt false} if an error occured.
+\true on success, \false if an error occurred.
 
 \wxheading{Include files}
 
@@ -841,7 +858,7 @@ This macro is equivalent to \helpref{cs.Enter()}{wxcriticalsectionenter} if
 
 \func{bool}{wxIsMainThread}{\void}
 
-Returns {\tt true} if this thread is the main one. Always returns {\tt true} if
+Returns \true if this thread is the main one. Always returns \true if
 {\tt wxUSE\_THREADS} is $0$.
 
 
@@ -935,6 +952,8 @@ Returns true if the file exists and is a plain file.
 
 Returns time of last modification of given file.
 
+The return value is $0$ if an error occured (e.g. file not found).
+
 
 \membersection{::wxFileNameFromPath}\label{wxfilenamefrompath}
 
@@ -960,7 +979,7 @@ parent directory "..".
 
 \wxheading{Warning}
 
-As of wx 2.5.2, these functions are not thread-safe! (use static variables)
+As of wx 2.5.2, these functions are not thread-safe! (they use static variables). You probably want to use \helpref{wxDir::GetFirst}{wxdirgetfirst} or \helpref{wxDirTraverser}{wxdirtraverser} instead.
 
 {\it spec} may contain wildcards.
 
@@ -998,7 +1017,7 @@ information is not needed.
 
 \wxheading{Returns}
 
-{\tt true} on success, {\tt false} if an error occured (for example, the
+\true on success, \false if an error occurred (for example, the
 directory doesn't exist).
 
 \wxheading{Portability}
@@ -1048,9 +1067,9 @@ Returns true if the argument is an absolute filename, i.e. with a slash
 or drive name at the beginning.
 
 
-\membersection{::wxPathExists}\label{functionwxpathexists}
+\membersection{::wxDirExists}\label{functionwxdirexists}
 
-\func{bool}{wxPathExists}{\param{const wxString\& }{dirname}}
+\func{bool}{wxDirExists}{\param{const wxString\& }{dirname}}
 
 Returns true if the path exists.
 
@@ -1064,7 +1083,9 @@ Returns the directory part of the filename.
 
 \membersection{::wxUnix2DosFilename}\label{wxunix2dosfilename}
 
-\func{void}{wxUnix2DosFilename}{\param{const wxString\& }{s}}
+\func{void}{wxUnix2DosFilename}{\param{wxChar *}{s}}
+
+This function is deprecated, use \helpref{wxFileName}{wxfilename} instead.
 
 Converts a Unix to a DOS filename by replacing forward
 slashes with backslashes.
@@ -1112,7 +1133,7 @@ Returns a string containing the current (or working) directory.
 
 \func{wxString}{wxGetWorkingDirectory}{\param{char *}{buf=NULL}, \param{int }{sz=1000}}
 
-{\bf NB:} This function is obsolete: use \helpref{wxGetCwd}{wxgetcwd} instead.
+{\bf NB:} This function is deprecated: use \helpref{wxGetCwd}{wxgetcwd} instead.
 
 Copies the current working directory into the buffer if supplied, or
 copies the working directory into new storage (which you {\emph must} delete
@@ -1322,7 +1343,8 @@ Return the (current) user's home directory.
 
 \wxheading{See also}
 
-\helpref{wxGetUserHome}{wxgetuserhome}
+\helpref{wxGetUserHome}{wxgetuserhome}\\
+\helpref{wxStandardPaths}{wxstandardpaths}
 
 \wxheading{Include files}
 
@@ -1460,8 +1482,8 @@ 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 {\tt true}
-if successful, {\tt false} otherwise.
+empty string otherwise. The second (deprecated) function returns \true
+if successful, \false otherwise.
 
 \wxheading{See also}
 
@@ -1503,23 +1525,33 @@ as wxGetTranslation.
 
 The second form is used when retrieving translation of string that has
 different singular and plural form in English or different plural forms in some
-other language. It takes two extra arguments: \arg{str}
-parameter must contain the singular form of the string to be converted.
-It is also used as the key for the search in the catalog.
-The \arg{strPlural} parameter is the plural form (in English).
-The parameter \arg{n} is used to determine the plural form.  If no
-message catalog is found \arg{str} is returned if `n == 1',
+other language. It takes two extra arguments: as above, \arg{str}
+parameter must contain the singular form of the string to be converted and
+is used as the key for the search in the catalog. The \arg{strPlural} parameter
+is the plural form (in English). The parameter \arg{n} is used to determine the
+plural form.  If no message catalog is found \arg{str} is returned if `n == 1',
 otherwise \arg{strPlural}.
-See \urlref{GNU gettext manual}{http://www.gnu.org/manual/gettext/html\_chapter/gettext\_10.html\#SEC150} for additional information on plural forms handling.
+
+See \urlref{GNU gettext manual}{http://www.gnu.org/manual/gettext/html\_chapter/gettext\_10.html\#SEC150}
+for additional information on plural forms handling. For a shorter alternative
+see the \helpref{wxPLURAL()}{wxplural} macro.
 
 Both versions call \helpref{wxLocale::GetString}{wxlocalegetstring}.
 
+Note that this function is not suitable for literal strings in Unicode
+builds, since the literal strings must be enclosed into
+\helpref{\_T()}{underscoret} or \helpref{wxT}{wxt} macro which makes them
+unrecognised by \texttt{xgettext}, and so they are not extracted to the message
+catalog. Instead, use the \helpref{\_()}{underscore} and
+\helpref{wxPLURAL}{wxplural} macro for all literal strings.
+
+
 \membersection{::wxIsEmpty}\label{wxisempty}
 
 \func{bool}{wxIsEmpty}{\param{const char *}{ p}}
 
-Returns {\tt true} if the pointer is either {\tt NULL} or points to an empty
-string, {\tt false} otherwise.
+Returns \true if the pointer is either {\tt NULL} or points to an empty
+string, \false otherwise.
 
 
 \membersection{::wxStrcmp}\label{wxstrcmp}
@@ -1544,6 +1576,19 @@ This function complements the standard C function {\it strcmp()} which performs
 case-sensitive comparison.
 
 
+\membersection{::wxStringEq}\label{wxstringeq}
+
+\func{bool}{wxStringEq}{\param{const wxString\& }{s1}, \param{const wxString\& }{s2}}
+
+{\bf NB:} This function is obsolete, use \helpref{wxString}{wxstring} instead.
+
+A macro defined as:
+
+\begin{verbatim}
+#define wxStringEq(s1, s2) (s1 && s2 && (strcmp(s1, s2) == 0))
+\end{verbatim}
+
+
 \membersection{::wxStringMatch}\label{wxstringmatch}
 
 \func{bool}{wxStringMatch}{\param{const wxString\& }{s1}, \param{const wxString\& }{s2},\\
@@ -1551,22 +1596,24 @@ case-sensitive comparison.
 
 {\bf NB:} This function is obsolete, use \helpref{wxString::Find}{wxstringfind} instead.
 
-Returns {\tt true} if the substring {\it s1} is found within {\it s2},
-ignoring case if {\it exact} is false. If {\it subString} is {\tt false},
+Returns \true if the substring {\it s1} is found within {\it s2},
+ignoring case if {\it exact} is false. If {\it subString} is \false,
 no substring matching is done.
 
 
-\membersection{::wxStringEq}\label{wxstringeq}
+\membersection{::wxStringTokenize}\label{wxstringtokenize}
 
-\func{bool}{wxStringEq}{\param{const wxString\& }{s1}, \param{const wxString\& }{s2}}
+\func{wxArrayString}{wxStringTokenize}{\param{const wxString\& }{str},\\
+  \param{const wxString\& }{delims = wxDEFAULT\_DELIMITERS},\\
+  \param{wxStringTokenizerMode }{mode = wxTOKEN\_DEFAULT}}
 
-{\bf NB:} This function is obsolete, use \helpref{wxString}{wxstring} instead.
+This is a convenience function wrapping
+\helpref{wxStringTokenizer}{wxstringtokenizer} which simply returns all tokens
+found in the given \arg{str} in an array.
 
-A macro defined as:
-
-\begin{verbatim}
-#define wxStringEq(s1, s2) (s1 && s2 && (strcmp(s1, s2) == 0))
-\end{verbatim}
+Please see
+\helpref{wxStringTokenizer::wxStringTokenizer}{wxstringtokenizerwxstringtokenizer}
+for the description of the other parameters.
 
 
 \membersection{::wxStrlen}\label{wxstrlen}
@@ -1687,6 +1734,14 @@ the string for the current locale during execution.
 Don't confuse this macro with \helpref{\_T()}{underscoret}!
 
 
+\membersection{wxPLURAL}\label{wxplural}
+
+\func{const wxChar *}{wxPLURAL}{\param{const char *}{sing}, \param{const char *}{plur}, \param{size\_t}{n}}
+
+This macro is identical to \helpref{\_()}{underscore} but for the plural variant
+of \helpref{wxGetTranslation}{wxgettranslation}.
+
+
 \membersection{\_T}\label{underscoret}
 
 \func{wxChar}{\_T}{\param{char }{ch}}
@@ -2528,7 +2583,7 @@ Empties the clipboard.
 
 \membersection{::wxEnumClipboardFormats}\label{wxenumclipboardformats}
 
-\func{int}{wxEnumClipboardFormats}{\param{int}{dataFormat}}
+\func{int}{wxEnumClipboardFormats}{\param{int}{ dataFormat}}
 
 Enumerates the formats found in a list of available formats that belong
 to the clipboard. Each call to this  function specifies a known
@@ -2549,7 +2604,7 @@ wxOpenClipboard function.
 
 \membersection{::wxGetClipboardData}\label{wxgetclipboarddata}
 
-\func{wxObject *}{wxGetClipboardData}{\param{int}{dataFormat}}
+\func{wxObject *}{wxGetClipboardData}{\param{int}{ dataFormat}}
 
 Gets data from the clipboard.
 
@@ -2565,7 +2620,7 @@ The clipboard must have previously been opened for this call to succeed.
 
 \membersection{::wxGetClipboardFormatName}\label{wxgetclipboardformatname}
 
-\func{bool}{wxGetClipboardFormatName}{\param{int}{dataFormat}, \param{const wxString\& }{formatName}, \param{int}{maxCount}}
+\func{bool}{wxGetClipboardFormatName}{\param{int}{ dataFormat}, \param{const wxString\& }{formatName}, \param{int}{ maxCount}}
 
 Gets the name of a registered clipboard format, and puts it into the buffer {\it formatName} which is of maximum
 length {\it maxCount}. {\it dataFormat} must not specify a predefined clipboard format.
@@ -2573,7 +2628,7 @@ length {\it maxCount}. {\it dataFormat} must not specify a predefined clipboard
 
 \membersection{::wxIsClipboardFormatAvailable}\label{wxisclipboardformatavailable}
 
-\func{bool}{wxIsClipboardFormatAvailable}{\param{int}{dataFormat}}
+\func{bool}{wxIsClipboardFormatAvailable}{\param{int}{ dataFormat}}
 
 Returns true if the given data format is available on the clipboard.
 
@@ -2594,7 +2649,7 @@ Registers the clipboard data format name and returns an identifier.
 
 \membersection{::wxSetClipboardData}\label{wxsetclipboarddata}
 
-\func{bool}{wxSetClipboardData}{\param{int}{dataFormat}, \param{wxObject *}{data}, \param{int}{width}, \param{int}{height}}
+\func{bool}{wxSetClipboardData}{\param{int}{ dataFormat}, \param{wxObject*}{ data}, \param{int}{ width}, \param{int}{ height}}
 
 Passes data to the clipboard.
 
@@ -2610,8 +2665,6 @@ Passes data to the clipboard.
 The clipboard must have previously been opened for this call to succeed.
 
 
-
-
 \section{Miscellaneous functions}\label{miscellany}
 
 
@@ -2729,6 +2782,48 @@ Generates an integer identifier unique to this run of the program.
 <wx/utils.h>
 
 
+\membersection{wxON\_BLOCK\_EXIT}\label{wxonblockexit}
+
+\func{}{wxON\_BLOCK\_EXIT0}{\param{}{func}}
+\func{}{wxON\_BLOCK\_EXIT1}{\param{}{func}, \param{}{p1}}
+\func{}{wxON\_BLOCK\_EXIT2}{\param{}{func}, \param{}{p1}, \param{}{p2}}
+
+This family of macros allows to ensure that the global function \arg{func}
+with 0, 1, 2 or more parameters (up to some implementaton-defined limit) is
+executed on scope exit, whether due to a normal function return or because an
+exception has been thrown. A typical example of its usage:
+\begin{verbatim}
+    void *buf = malloc(size);
+    wxON_BLOCK_EXIT1(free, buf);
+\end{verbatim}
+
+Please see the original article by Andrei Alexandrescu and Petru Marginean
+published in December 2000 issue of \emph{C/C++ Users Journal} for more
+details.
+
+\wxheading{Include files}
+
+<wx/scopeguard.h>
+
+\wxheading{See also}
+
+\helpref{wxON\_BLOCK\_EXIT\_OBJ}{wxonblockexitobj}
+
+
+\membersection{wxON\_BLOCK\_EXIT\_OBJ}\label{wxonblockexitobj}
+
+\func{}{wxON\_BLOCK\_EXIT\_OBJ0}{\param{}{obj}, \param{}{method}}
+\func{}{wxON\_BLOCK\_EXIT\_OBJ1}{\param{}{obj}, \param{}{method}, \param{}{p1}}
+\func{}{wxON\_BLOCK\_EXIT\_OBJ2}{\param{}{obj}, \param{}{method}, \param{}{p1}, \param{}{p2}}
+
+This family of macros is similar to \helpref{wxON\_BLOCK\_EXIT}{wxonblockexit}
+but calls a method of the given object instead of a free function.
+
+\wxheading{Include files}
+
+<wx/scopeguard.h>
+
+
 \membersection{::wxRegisterId}\label{wxregisterid}
 
 \func{void}{wxRegisterId}{\param{long}{ id}}
@@ -2774,7 +2869,7 @@ See also \helpref{wxDDEServer}{wxddeserver}, \helpref{wxDDEClient}{wxddeclient},
 
 \membersection{::wxEnableTopLevelWindows}\label{wxenabletoplevelwindows}
 
-\func{void}{wxEnableTopLevelWindow}{\param{bool}{ enable = true}}
+\func{void}{wxEnableTopLevelWindows}{\param{bool}{ enable = true}}
 
 This function enables or disables all top level windows. It is used by
 \helpref{::wxSafeYield}{wxsafeyield}.
@@ -2946,7 +3041,7 @@ See also \helpref{wxWriteResource}{wxwriteresource}, \helpref{wxConfigBase}{wxco
 
 \membersection{::wxGetStockLabel}\label{wxgetstocklabel}
 
-\func{wxString}{wxGetStockLabel}{\param{wxWindowID }{id}, \param{bool }{withCodes = true}, \param{wxString }{accelerator = wxEmptyString}}
+\func{wxString}{wxGetStockLabel}{\param{wxWindowID }{id}, \param{bool }{withCodes = true}, \param{const wxString\& }{accelerator = wxEmptyString}}
 
 Returns label that should be used for given {\it id} element.
 
@@ -2978,6 +3073,21 @@ frame or dialog containing it, or {\tt NULL}.
 <wx/window.h>
 
 
+\membersection{::wxLaunchDefaultBrowser}\label{wxlaunchdefaultbrowser}
+
+\func{bool}{wxLaunchDefaultBrowser}{\param{const wxString\& }{url}, \param{int }{flags = $0$}}
+
+Open the \arg{url} in user's default browser. If \arg{flags} parameter contains
+\texttt{wxBROWSER\_NEW\_WINDOW} flag, a new window is opened for the URL
+(currently this is only supported under Windows).
+
+Returns \true if the application was successfully launched.
+
+\wxheading{Include files}
+
+<wx/utils.h>
+
+
 \membersection{::wxLoadUserResource}\label{wxloaduserresource}
 
 \func{wxString}{wxLoadUserResource}{\param{const wxString\& }{resourceName}, \param{const wxString\& }{resourceType=``TEXT"}}
@@ -3091,7 +3201,7 @@ allows to define unsigned 64 bit compile time constants:
 
 \membersection{wxVaCopy}\label{wxvacopy}
 
-\func{void}{wxVaCopy}{\param{va\_list }{argptrDst}, \param{va\_list}{argptrSrc}}
+\func{void}{wxVaCopy}{\param{va\_list }{argptrDst}, \param{va\_list}{ argptrSrc}}
 
 This macro is the same as the standard C99 \texttt{va\_copy} for the compilers
 which support it or its replacement for those that don't. It must be used to
@@ -3290,8 +3400,11 @@ dynamically. The same as DECLARE\_ABSTRACT\_CLASS.
 
 \func{}{DECLARE\_DYNAMIC\_CLASS}{className}
 
-Used inside a class declaration to declare that the objects of this class should be dynamically
-creatable from run-time type information.
+Used inside a class declaration to make the class known to wxWidgets RTTI
+system and also declare that the objects of this class should be dynamically
+creatable from run-time type information. Notice that this implies that the
+class should have a default constructor, if this is not the case consider using
+\helpref{DECLARE\_CLASS}{declareclass}.
 
 Example:
 
@@ -3581,8 +3694,20 @@ star is not appended to it.
 \wxheading{See also}
 
 \helpref{wx\_const\_cast}{wxconstcastraw},\\
-\helpref{wx\_reinterpret\_cast}{wxreinterpretcastraw}
+\helpref{wx\_reinterpret\_cast}{wxreinterpretcastraw},\\
+\helpref{wx\_truncate\_cast}{wxtruncatecast}
+
+
+\membersection{wx\_truncate\_cast}\label{wxtruncatecast}
 
+\func{T}{wx\_truncate\_cast}{T, x}
+
+This case doesn't correspond to any standard cast but exists solely to make
+casts which possibly result in a truncation of an integer value more readable.
+
+\wxheading{See also}
+
+\helpref{wx\_static\_cast}{wxstaticcastraw}
 
 
 \section{Log functions}\label{logfunctions}
@@ -4336,7 +4461,7 @@ Returns the current value of the environment variable {\it var} in {\it value}.
 {\it value} may be {\tt NULL} if you just want to know if the variable exists
 and are not interested in its value.
 
-Returns {\tt true} if the variable exists, {\tt false} otherwise.
+Returns \true if the variable exists, \false otherwise.
 
 
 \membersection{wxSetEnv}\label{wxsetenv}
@@ -4346,7 +4471,7 @@ Returns {\tt true} if the variable exists, {\tt false} otherwise.
 Sets the value of the environment variable {\it var} (adding it if necessary)
 to {\it value}.
 
-Returns {\tt true} on success.
+Returns \true on success.
 
 
 \membersection{wxUnsetEnv}\label{wxunsetenv}
@@ -4357,5 +4482,4 @@ Removes the variable {\it var} from the environment.
 \helpref{wxGetEnv}{wxgetenv} will return {\tt NULL} after the call to this
 function.
 
-Returns {\tt true} on success.
-
+Returns \true on success.
