]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/function.tex
Very bad wxPrintData destructor... fixed typo.
[wxWidgets.git] / docs / latex / wx / function.tex
CommitLineData
a660d684
KB
1\chapter{Functions}\label{functions}
2\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
3\setfooter{\thepage}{}{}{}{}{\thepage}
4
5The functions defined in wxWindows are described here.
6
7\section{File functions}\label{filefunctions}
8
954b8ae6
JS
9\wxheading{Include files}
10
11<wx/utils.h>
12
13\wxheading{See also}
14
15\helpref{wxPathList}{wxpathlist}
a660d684
KB
16
17\membersection{::wxDirExists}
18
19\func{bool}{wxDirExists}{\param{const wxString\& }{dirname}}
20
21Returns TRUE if the directory exists.
22
23\membersection{::wxDos2UnixFilename}
24
25\func{void}{Dos2UnixFilename}{\param{const wxString\& }{s}}
26
e2a6f233 27Converts a DOS to a Unix filename by replacing backslashes with forward
a660d684
KB
28slashes.
29
30\membersection{::wxFileExists}
31
32\func{bool}{wxFileExists}{\param{const wxString\& }{filename}}
33
34Returns TRUE if the file exists.
35
36\membersection{::wxFileNameFromPath}
37
38\func{wxString}{wxFileNameFromPath}{\param{const wxString\& }{path}}
39
532372a3
JS
40\func{char*}{wxFileNameFromPath}{\param{char* }{path}}
41
42Returns the filename for a full path. The second form returns a pointer to
43temporary storage that should not be deallocated.
a660d684
KB
44
45\membersection{::wxFindFirstFile}\label{wxfindfirstfile}
46
532372a3 47\func{wxString}{wxFindFirstFile}{\param{const char*}{spec}, \param{int}{ flags = 0}}
a660d684
KB
48
49This function does directory searching; returns the first file
532372a3 50that matches the path {\it spec}, or the empty string. Use \helpref{wxFindNextFile}{wxfindnextfile} to
a660d684
KB
51get the next matching file.
52
53{\it spec} may contain wildcards.
54
55{\it flags} is reserved for future use.
56
a660d684
KB
57For example:
58
59\begin{verbatim}
60 wxString f = wxFindFirstFile("/home/project/*.*");
58503787 61 while ( !f.IsEmpty() )
a660d684
KB
62 {
63 ...
64 f = wxFindNextFile();
65 }
66\end{verbatim}
67
68\membersection{::wxFindNextFile}\label{wxfindnextfile}
69
70\func{wxString}{wxFindFirstFile}{\void}
71
72Returns the next file that matches the path passed to \helpref{wxFindFirstFile}{wxfindfirstfile}.
73
631f1bfe
JS
74\membersection{::wxGetOSDirectory}\label{wxgetosdirectory}
75
76\func{wxString}{wxGetOSDirectory}{\void}
77
78Returns the Windows directory under Windows; on other platforms returns the empty string.
79
a660d684
KB
80\membersection{::wxIsAbsolutePath}
81
82\func{bool}{wxIsAbsolutePath}{\param{const wxString\& }{filename}}
83
84Returns TRUE if the argument is an absolute filename, i.e. with a slash
85or drive name at the beginning.
86
87\membersection{::wxPathOnly}
88
89\func{wxString}{wxPathOnly}{\param{const wxString\& }{path}}
90
532372a3 91Returns the directory part of the filename.
a660d684
KB
92
93\membersection{::wxUnix2DosFilename}
94
95\func{void}{wxUnix2DosFilename}{\param{const wxString\& }{s}}
96
e2a6f233 97Converts a Unix to a DOS filename by replacing forward
a660d684
KB
98slashes with backslashes.
99
100\membersection{::wxConcatFiles}
101
102\func{bool}{wxConcatFiles}{\param{const wxString\& }{file1}, \param{const wxString\& }{file2},
103\param{const wxString\& }{file3}}
104
105Concatenates {\it file1} and {\it file2} to {\it file3}, returning
106TRUE if successful.
107
108\membersection{::wxCopyFile}
109
110\func{bool}{wxCopyFile}{\param{const wxString\& }{file1}, \param{const wxString\& }{file2}}
111
112Copies {\it file1} to {\it file2}, returning TRUE if successful.
113
7af89395
VZ
114\membersection{::wxGetCwd}\label{wxgetcwd}
115
116\func{wxString}{wxGetCwd}{\void}
117
118Returns a string containing the current (or working) directory.
119
a660d684
KB
120\membersection{::wxGetWorkingDirectory}
121
532372a3 122\func{wxString}{wxGetWorkingDirectory}{\param{char*}{buf=NULL}, \param{int }{sz=1000}}
a660d684 123
7af89395
VZ
124This function is obsolete: use \helpref{wxGetCwd}{wxgetcwd} instead.
125
a660d684
KB
126Copies the current working directory into the buffer if supplied, or
127copies the working directory into new storage (which you must delete yourself)
128if the buffer is NULL.
129
130{\it sz} is the size of the buffer if supplied.
131
132\membersection{::wxGetTempFileName}
133
532372a3 134\func{char*}{wxGetTempFileName}{\param{const wxString\& }{prefix}, \param{char* }{buf=NULL}}
a660d684
KB
135
136Makes a temporary filename based on {\it prefix}, opens and closes the file,
137and places the name in {\it buf}. If {\it buf} is NULL, new store
138is allocated for the temporary filename using {\it new}.
139
140Under Windows, the filename will include the drive and name of the
141directory allocated for temporary files (usually the contents of the
e2a6f233 142TEMP variable). Under Unix, the {\tt /tmp} directory is used.
a660d684
KB
143
144It is the application's responsibility to create and delete the file.
145
146\membersection{::wxIsWild}\label{wxiswild}
147
148\func{bool}{wxIsWild}{\param{const wxString\& }{pattern}}
149
150Returns TRUE if the pattern contains wildcards. See \helpref{wxMatchWild}{wxmatchwild}.
151
152\membersection{::wxMatchWild}\label{wxmatchwild}
153
154\func{bool}{wxMatchWild}{\param{const wxString\& }{pattern}, \param{const wxString\& }{text}, \param{bool}{ dot\_special}}
155
156Returns TRUE if the {\it pattern}\/ matches the {\it text}\/; if {\it
157dot\_special}\/ is TRUE, filenames beginning with a dot are not matched
158with wildcard characters. See \helpref{wxIsWild}{wxiswild}.
159
160\membersection{::wxMkdir}
161
162\func{bool}{wxMkdir}{\param{const wxString\& }{dir}}
163
164Makes the directory {\it dir}, returning TRUE if successful.
165
166\membersection{::wxRemoveFile}
167
168\func{bool}{wxRemoveFile}{\param{const wxString\& }{file}}
169
170Removes {\it file}, returning TRUE if successful.
171
172\membersection{::wxRenameFile}
173
174\func{bool}{wxRenameFile}{\param{const wxString\& }{file1}, \param{const wxString\& }{file2}}
175
176Renames {\it file1} to {\it file2}, returning TRUE if successful.
177
178\membersection{::wxRmdir}
179
180\func{bool}{wxRmdir}{\param{const wxString\& }{dir}, \param{int}{ flags=0}}
181
182Removes the directory {\it dir}, returning TRUE if successful. Does not work under VMS.
183
184The {\it flags} parameter is reserved for future use.
185
186\membersection{::wxSetWorkingDirectory}
187
188\func{bool}{wxSetWorkingDirectory}{\param{const wxString\& }{dir}}
189
190Sets the current working directory, returning TRUE if the operation succeeded.
191Under MS Windows, the current drive is also changed if {\it dir} contains a drive specification.
192
d37fd2fa
VZ
193\membersection{::wxSplitPath}\label{wxsplitfunction}
194
195\func{void}{wxSplitPath}{\param{const char *}{ fullname}, \param{const wxString *}{ path}, \param{const wxString *}{ name}, \param{const wxString *}{ ext}}
196
197This function splits a full file name into components: the path (including possible disk/drive
198specification under Windows), the base name and the extension. Any of the output parameters
199({\it path}, {\it name} or {\it ext}) may be NULL if you are not interested in the value of
200a particular component.
201
202wxSplitPath() will correctly handle filenames with both DOS and Unix path separators under
203Windows, however it will not consider backslashes as path separators under Unix (where backslash
204is a valid character in a filename).
205
206On entry, {\it fullname} should be non NULL (it may be empty though).
207
208On return, {\it path} contains the file path (without the trailing separator), {\it name}
209contains the file name and {\it ext} contains the file extension without leading dot. All
210three of them may be empty if the corresponding component is. The old contents of the
211strings pointed to by these parameters will be overwritten in any case (if the pointers
212are not NULL).
213
ed93168b
VZ
214\membersection{::wxTransferFileToStream}\label{wxtransferfiletostream}
215
216\func{bool}{wxTransferFileToStream}{\param{const wxString\& }{filename}, \param{ostream\& }{stream}}
217
218Copies the given file to {\it stream}. Useful when converting an old application to
219use streams (within the document/view framework, for example).
220
221Use of this function requires the file wx\_doc.h to be included.
222
223\membersection{::wxTransferStreamToFile}\label{wxtransferstreamtofile}
224
225\func{bool}{wxTransferStreamToFile}{\param{istream\& }{stream} \param{const wxString\& }{filename}}
226
227Copies the given stream to the file {\it filename}. Useful when converting an old application to
228use streams (within the document/view framework, for example).
229
230Use of this function requires the file wx\_doc.h to be included.
231
d524e22d
VZ
232\section{Network functions}\label{networkfunctions}
233
234\membersection{::wxGetFullHostName}\label{wxgetfullhostname}
235
236\func{wxString}{wxGetFullHostName}{\void}
237
238Returns the FQDN (fully qualified domain host name) or an empty string on
239error.
240
241See also: \helpref{wxGetHostName}{wxgethostname}
242
243\wxheading{Include files}
244
245<wx/utils.h>
246
247\membersection{::wxGetEmailAddress}\label{wxgetemailaddress}
248
249\func{bool}{wxGetEmailAddress}{\param{const wxString\& }{buf}, \param{int }{sz}}
250
251Copies the user's email address into the supplied buffer, by
252concatenating the values returned by \helpref{wxGetFullHostName}{wxgetfullhostname}\rtfsp
253and \helpref{wxGetUserId}{wxgetuserid}.
254
255Returns TRUE if successful, FALSE otherwise.
256
257\wxheading{Include files}
258
259<wx/utils.h>
260
261\membersection{::wxGetHostName}\label{wxgethostname}
262
263\func{wxString}{wxGetHostName}{\void}
264\func{bool}{wxGetHostName}{\param{char * }{buf}, \param{int }{sz}}
265
266Copies the current host machine's name into the supplied buffer. Please note
267that the returned name is {\it not} fully qualified, i.e. it does not include
268the domain name.
269
270Under Windows or NT, this function first looks in the environment
271variable SYSTEM\_NAME; if this is not found, the entry {\bf HostName}\rtfsp
272in the {\bf wxWindows} section of the WIN.INI file is tried.
273
274The first variant of this function returns the hostname if successful or an
275empty string otherwise. The second (deprecated) function returns TRUE
276if successful, FALSE otherwise.
277
278See also: \helpref{wxGetFullHostName}{wxgetfullhostname}
279
280\wxheading{Include files}
281
282<wx/utils.h>
283
284\section{User identification}\label{useridfunctions}
285
286\membersection{::wxGetUserId}\label{wxgetuserid}
287
288\func{wxString}{wxGetUserId}{\void}
289\func{bool}{wxGetUserId}{\param{char * }{buf}, \param{int }{sz}}
290
291This function returns the "user id" also known as "login name" under Unix i.e.
292something like "jsmith". It uniquely identifies the current user (on this system).
293
294Under Windows or NT, this function first looks in the environment
295variables USER and LOGNAME; if neither of these is found, the entry {\bf UserId}\rtfsp
296in the {\bf wxWindows} section of the WIN.INI file is tried.
297
298The first variant of this function returns the login name if successful or an
299empty string otherwise. The second (deprecated) function returns TRUE
300if successful, FALSE otherwise.
301
302See also: \helpref{wxGetUserName}{wxgetusername}
303
304\wxheading{Include files}
305
306<wx/utils.h>
307
308\membersection{::wxGetUserName}\label{wxgetusername}
309
310\func{wxString}{wxGetUserName}{\void}
311\func{bool}{wxGetUserName}{\param{char * }{buf}, \param{int }{sz}}
312
313This function returns the full user name (something like "Mr. John Smith").
314
315Under Windows or NT, this function looks for the entry {\bf UserName}\rtfsp
316in the {\bf wxWindows} section of the WIN.INI file. If PenWindows
317is running, the entry {\bf Current} in the section {\bf User} of
318the PENWIN.INI file is used.
319
320The first variant of this function returns the user name if successful or an
321empty string otherwise. The second (deprecated) function returns TRUE
322if successful, FALSE otherwise.
323
324See also: \helpref{wxGetUserId}{wxgetuserid}
325
326\wxheading{Include files}
327
328<wx/utils.h>
329
a660d684
KB
330\section{String functions}
331
332\membersection{::copystring}
333
334\func{char*}{copystring}{\param{const char* }{s}}
335
336Makes a copy of the string {\it s} using the C++ new operator, so it can be
337deleted with the {\it delete} operator.
338
339\membersection{::wxStringMatch}
340
341\func{bool}{wxStringMatch}{\param{const wxString\& }{s1}, \param{const wxString\& }{s2},\\
342 \param{bool}{ subString = TRUE}, \param{bool}{ exact = FALSE}}
343
344Returns TRUE if the substring {\it s1} is found within {\it s2},
345ignoring case if {\it exact} is FALSE. If {\it subString} is FALSE,
346no substring matching is done.
347
348\membersection{::wxStringEq}\label{wxstringeq}
349
350\func{bool}{wxStringEq}{\param{const wxString\& }{s1}, \param{const wxString\& }{s2}}
351
352A macro defined as:
353
354\begin{verbatim}
355#define wxStringEq(s1, s2) (s1 && s2 && (strcmp(s1, s2) == 0))
356\end{verbatim}
357
ed93168b 358\membersection{::IsEmpty}\label{isempty}
a660d684 359
ed93168b 360\func{bool}{IsEmpty}{\param{const char *}{ p}}
a660d684 361
ed93168b
VZ
362Returns TRUE if the string is empty, FALSE otherwise. It is safe to pass NULL
363pointer to this function and it will return TRUE for it.
a660d684 364
ed93168b 365\membersection{::Stricmp}\label{stricmp}
a660d684 366
ed93168b 367\func{int}{Stricmp}{\param{const char *}{p1}, \param{const char *}{p2}}
a660d684 368
ed93168b
VZ
369Returns a negative value, 0, or positive value if {\it p1} is less than, equal
370to or greater than {\it p2}. The comparison is case-insensitive.
a660d684 371
ed93168b
VZ
372This function complements the standard C function {\it strcmp()} which performs
373case-sensitive comparison.
a660d684 374
ed93168b
VZ
375\membersection{::Strlen}\label{strlen}
376
377\func{size\_t}{Strlen}{\param{const char *}{ p}}
378
379This is a safe version of standard function {\it strlen()}: it does exactly the
380same thing (i.e. returns the length of the string) except that it returns 0 if
381{\it p} is the NULL pointer.
382
383\membersection{::wxGetTranslation}\label{wxgettranslation}
384
385\func{const char *}{wxGetTranslation}{\param{const char * }{str}}
386
387This function returns the translation of string {\it str} in the current
388\helpref{locale}{wxlocale}. If the string is not found in any of the loaded
389message catalogs (see \helpref{i18n overview}{internationalization}), the
390original string is returned. In debug build, an error message is logged - this
391should help to find the strings which were not yet translated. As this function
392is used very often, an alternative syntax is provided: the \_() macro is
393defined as wxGetTranslation().
a660d684
KB
394
395\section{Dialog functions}\label{dialogfunctions}
396
397Below are a number of convenience functions for getting input from the
398user or displaying messages. Note that in these functions the last three
399parameters are optional. However, it is recommended to pass a parent frame
400parameter, or (in MS Windows or Motif) the wrong window frame may be brought to
401the front when the dialog box is popped up.
402
403\membersection{::wxFileSelector}\label{wxfileselector}
404
f5ee2e5f
JS
405\func{wxString}{wxFileSelector}{\param{const wxString\& }{message}, \param{const wxString\& }{default\_path = ""},\\
406 \param{const wxString\& }{default\_filename = ""}, \param{const wxString\& }{default\_extension = ""},\\
407 \param{const wxString\& }{wildcard = ``*.*''}, \param{int }{flags = 0}, \param{wxWindow *}{parent = ""},\\
a660d684
KB
408 \param{int}{ x = -1}, \param{int}{ y = -1}}
409
410Pops up a file selector box. In Windows, this is the common file selector
411dialog. In X, this is a file selector box with somewhat less functionality.
412The path and filename are distinct elements of a full file pathname.
706bb5f9 413If path is empty, the current directory will be used. If filename is empty,
a660d684
KB
414no default filename will be supplied. The wildcard determines what files
415are displayed in the file selector, and file extension supplies a type
416extension for the required filename. Flags may be a combination of wxOPEN,
417wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, or 0. They are only significant
418at present in Windows.
419
420Both the X and Windows versions implement a wildcard filter. Typing a
421filename containing wildcards (*, ?) in the filename text item, and
422clicking on Ok, will result in only those files matching the pattern being
423displayed. In the X version, supplying no default name will result in the
424wildcard filter being inserted in the filename text item; the filter is
425ignored if a default name is supplied.
426
427Under Windows (only), the wildcard may be a specification for multiple
428types of file with a description for each, such as:
429
430\begin{verbatim}
431 "BMP files (*.bmp) | *.bmp | GIF files (*.gif) | *.gif"
432\end{verbatim}
433
706bb5f9 434The application must check for an empty return value (the user pressed
a660d684
KB
435Cancel). For example:
436
437\begin{verbatim}
f5ee2e5f 438const wxString& s = wxFileSelector("Choose a file to open");
a660d684
KB
439if (s)
440{
441 ...
442}
443\end{verbatim}
444
954b8ae6
JS
445\wxheading{Include files}
446
447<wx/filedlg.h>
448
a660d684
KB
449\membersection{::wxGetTextFromUser}\label{wxgettextfromuser}
450
451\func{wxString}{wxGetTextFromUser}{\param{const wxString\& }{message}, \param{const wxString\& }{caption = ``Input text"},\\
452 \param{const wxString\& }{default\_value = ``"}, \param{wxWindow *}{parent = NULL},\\
453 \param{int}{ x = -1}, \param{int}{ y = -1}, \param{bool}{ centre = TRUE}}
454
455Pop up a dialog box with title set to {\it caption}, message {\it message}, and a
456\rtfsp{\it default\_value}. The user may type in text and press OK to return this text,
532372a3 457or press Cancel to return the empty string.
a660d684
KB
458
459If {\it centre} is TRUE, the message text (which may include new line characters)
460is centred; if FALSE, the message is left-justified.
461
954b8ae6
JS
462\wxheading{Include files}
463
464<wx/textdlg.h>
465
a660d684
KB
466\membersection{::wxGetMultipleChoice}\label{wxgetmultiplechoice}
467
468\func{int}{wxGetMultipleChoice}{\param{const wxString\& }{message}, \param{const wxString\& }{caption}, \param{int}{ n}, \param{const wxString\& }{choices[]},\\
469 \param{int }{nsel}, \param{int *}{selection},
470 \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1},\\
471 \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}}
472
473Pops up a dialog box containing a message, OK/Cancel buttons and a multiple-selection
474listbox. The user may choose one or more item(s) and press OK or Cancel.
475
476The number of initially selected choices, and array of the selected indices,
477are passed in; this array will contain the user selections on exit, with
478the function returning the number of selections. {\it selection} must be
479as big as the number of choices, in case all are selected.
480
481If Cancel is pressed, -1 is returned.
482
483{\it choices} is an array of {\it n} strings for the listbox.
484
485If {\it centre} is TRUE, the message text (which may include new line characters)
486is centred; if FALSE, the message is left-justified.
487
954b8ae6
JS
488\wxheading{Include files}
489
490<wx/choicdlg.h>
491
a660d684
KB
492\membersection{::wxGetSingleChoice}\label{wxgetsinglechoice}
493
494\func{wxString}{wxGetSingleChoice}{\param{const wxString\& }{message}, \param{const wxString\& }{caption}, \param{int}{ n}, \param{const wxString\& }{choices[]},\\
495 \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1},\\
496 \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}}
497
498Pops up a dialog box containing a message, OK/Cancel buttons and a single-selection
499listbox. The user may choose an item and press OK to return a string or
532372a3 500Cancel to return the empty string.
a660d684
KB
501
502{\it choices} is an array of {\it n} strings for the listbox.
503
504If {\it centre} is TRUE, the message text (which may include new line characters)
505is centred; if FALSE, the message is left-justified.
506
954b8ae6
JS
507\wxheading{Include files}
508
509<wx/choicdlg.h>
510
a660d684
KB
511\membersection{::wxGetSingleChoiceIndex}\label{wxgetsinglechoiceindex}
512
513\func{int}{wxGetSingleChoiceIndex}{\param{const wxString\& }{message}, \param{const wxString\& }{caption}, \param{int}{ n}, \param{const wxString\& }{choices[]},\\
514 \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1},\\
515 \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}}
516
517As {\bf wxGetSingleChoice} but returns the index representing the selected string.
518If the user pressed cancel, -1 is returned.
519
954b8ae6
JS
520\wxheading{Include files}
521
522<wx/choicdlg.h>
523
a660d684
KB
524\membersection{::wxGetSingleChoiceData}\label{wxgetsinglechoicedata}
525
526\func{wxString}{wxGetSingleChoiceData}{\param{const wxString\& }{message}, \param{const wxString\& }{caption}, \param{int}{ n}, \param{const wxString\& }{choices[]},\\
527 \param{const wxString\& }{client\_data[]}, \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1},\\
528 \param{int}{ y = -1}, \param{bool}{ centre = TRUE}, \param{int }{width=150}, \param{int }{height=200}}
529
530As {\bf wxGetSingleChoice} but takes an array of client data pointers
531corresponding to the strings, and returns one of these pointers.
532
954b8ae6
JS
533\wxheading{Include files}
534
535<wx/choicdlg.h>
536
a660d684
KB
537\membersection{::wxMessageBox}\label{wxmessagebox}
538
539\func{int}{wxMessageBox}{\param{const wxString\& }{message}, \param{const wxString\& }{caption = ``Message"}, \param{int}{ style = wxOK \pipe wxCENTRE},\\
540 \param{wxWindow *}{parent = NULL}, \param{int}{ x = -1}, \param{int}{ y = -1}}
541
542General purpose message dialog. {\it style} may be a bit list of the
543following identifiers:
544
545\begin{twocollist}\itemsep=0pt
546\twocolitem{wxYES\_NO}{Puts Yes and No buttons on the message box. May be combined with
547wxCANCEL.}
548\twocolitem{wxCANCEL}{Puts a Cancel button on the message box. May be combined with
549wxYES\_NO or wxOK.}
550\twocolitem{wxOK}{Puts an Ok button on the message box. May be combined with wxCANCEL.}
551\twocolitem{wxCENTRE}{Centres the text.}
552\twocolitem{wxICON\_EXCLAMATION}{Under Windows, displays an exclamation mark symbol.}
553\twocolitem{wxICON\_HAND}{Under Windows, displays a hand symbol.}
554\twocolitem{wxICON\_QUESTION}{Under Windows, displays a question mark symbol.}
555\twocolitem{wxICON\_INFORMATION}{Under Windows, displays an information symbol.}
556\end{twocollist}
557
558The return value is one of: wxYES, wxNO, wxCANCEL, wxOK.
559
560For example:
561
562\begin{verbatim}
563 ...
564 int answer = wxMessageBox("Quit program?", "Confirm",
565 wxYES_NO | wxCANCEL, main_frame);
566 if (answer == wxYES)
567 delete main_frame;
568 ...
569\end{verbatim}
570
571{\it message} may contain newline characters, in which case the
572message will be split into separate lines, to cater for large messages.
573
574Under Windows, the native MessageBox function is used unless wxCENTRE
575is specified in the style, in which case a generic function is used.
576This is because the native MessageBox function cannot centre text.
577The symbols are not shown when the generic function is used.
578
954b8ae6
JS
579\wxheading{Include files}
580
581<wx/msgdlg.h>
582
a660d684
KB
583\section{GDI functions}\label{gdifunctions}
584
585The following are relevant to the GDI (Graphics Device Interface).
586
954b8ae6
JS
587\wxheading{Include files}
588
589<wx/gdicmn.h>
590
a660d684
KB
591\membersection{::wxColourDisplay}
592
593\func{bool}{wxColourDisplay}{\void}
594
595Returns TRUE if the display is colour, FALSE otherwise.
596
597\membersection{::wxDisplayDepth}
598
599\func{int}{wxDisplayDepth}{\void}
600
601Returns the depth of the display (a value of 1 denotes a monochrome display).
602
e2a6f233 603\membersection{::wxMakeMetafilePlaceable}\label{wxmakemetafileplaceable}
a660d684 604
e2a6f233 605\func{bool}{wxMakeMetafilePlaceable}{\param{const wxString\& }{filename}, \param{int }{minX}, \param{int }{minY},
a660d684
KB
606 \param{int }{maxX}, \param{int }{maxY}, \param{float }{scale=1.0}}
607
e2a6f233 608Given a filename for an existing, valid metafile (as constructed using \helpref{wxMetafileDC}{wxmetafiledc})
a660d684
KB
609makes it into a placeable metafile by prepending a header containing the given
610bounding box. The bounding box may be obtained from a device context after drawing
611into it, using the functions wxDC::MinX, wxDC::MinY, wxDC::MaxX and wxDC::MaxY.
612
613In addition to adding the placeable metafile header, this function adds
614the equivalent of the following code to the start of the metafile data:
615
616\begin{verbatim}
617 SetMapMode(dc, MM_ANISOTROPIC);
618 SetWindowOrg(dc, minX, minY);
619 SetWindowExt(dc, maxX - minX, maxY - minY);
620\end{verbatim}
621
e3065973 622This simulates the wxMM\_TEXT mapping mode, which wxWindows assumes.
a660d684
KB
623
624Placeable metafiles may be imported by many Windows applications, and can be
625used in RTF (Rich Text Format) files.
626
627{\it scale} allows the specification of scale for the metafile.
628
629This function is only available under Windows.
630
631\membersection{::wxSetCursor}\label{wxsetcursor}
632
633\func{void}{wxSetCursor}{\param{wxCursor *}{cursor}}
634
635Globally sets the cursor; only has an effect in MS Windows.
636See also \helpref{wxCursor}{wxcursor}, \helpref{wxWindow::SetCursor}{wxwindowsetcursor}.
637
a660d684
KB
638\section{Printer settings}\label{printersettings}
639
640The following functions are used to control PostScript printing. Under
641Windows, PostScript output can only be sent to a file.
642
954b8ae6
JS
643\wxheading{Include files}
644
645<wx/dcps.h>
646
a660d684
KB
647\membersection{::wxGetPrinterCommand}
648
649\func{wxString}{wxGetPrinterCommand}{\void}
650
651Gets the printer command used to print a file. The default is {\tt lpr}.
652
653\membersection{::wxGetPrinterFile}
654
655\func{wxString}{wxGetPrinterFile}{\void}
656
657Gets the PostScript output filename.
658
659\membersection{::wxGetPrinterMode}
660
661\func{int}{wxGetPrinterMode}{\void}
662
663Gets the printing mode controlling where output is sent (PS\_PREVIEW, PS\_FILE or PS\_PRINTER).
664The default is PS\_PREVIEW.
665
666\membersection{::wxGetPrinterOptions}
667
668\func{wxString}{wxGetPrinterOptions}{\void}
669
670Gets the additional options for the print command (e.g. specific printer). The default is nothing.
671
672\membersection{::wxGetPrinterOrientation}
673
674\func{int}{wxGetPrinterOrientation}{\void}
675
676Gets the orientation (PS\_PORTRAIT or PS\_LANDSCAPE). The default is PS\_PORTRAIT.
677
678\membersection{::wxGetPrinterPreviewCommand}
679
680\func{wxString}{wxGetPrinterPreviewCommand}{\void}
681
682Gets the command used to view a PostScript file. The default depends on the platform.
683
684\membersection{::wxGetPrinterScaling}
685
686\func{void}{wxGetPrinterScaling}{\param{float *}{x}, \param{float *}{y}}
687
688Gets the scaling factor for PostScript output. The default is 1.0, 1.0.
689
690\membersection{::wxGetPrinterTranslation}
691
692\func{void}{wxGetPrinterTranslation}{\param{float *}{x}, \param{float *}{y}}
693
694Gets the translation (from the top left corner) for PostScript output. The default is 0.0, 0.0.
695
696\membersection{::wxSetPrinterCommand}
697
698\func{void}{wxSetPrinterCommand}{\param{const wxString\& }{command}}
699
700Sets the printer command used to print a file. The default is {\tt lpr}.
701
702\membersection{::wxSetPrinterFile}
703
704\func{void}{wxSetPrinterFile}{\param{const wxString\& }{filename}}
705
706Sets the PostScript output filename.
707
708\membersection{::wxSetPrinterMode}
709
710\func{void}{wxSetPrinterMode}{\param{int }{mode}}
711
712Sets the printing mode controlling where output is sent (PS\_PREVIEW, PS\_FILE or PS\_PRINTER).
713The default is PS\_PREVIEW.
714
715\membersection{::wxSetPrinterOptions}
716
717\func{void}{wxSetPrinterOptions}{\param{const wxString\& }{options}}
718
719Sets the additional options for the print command (e.g. specific printer). The default is nothing.
720
721\membersection{::wxSetPrinterOrientation}
722
723\func{void}{wxSetPrinterOrientation}{\param{int}{ orientation}}
724
725Sets the orientation (PS\_PORTRAIT or PS\_LANDSCAPE). The default is PS\_PORTRAIT.
726
727\membersection{::wxSetPrinterPreviewCommand}
728
729\func{void}{wxSetPrinterPreviewCommand}{\param{const wxString\& }{command}}
730
731Sets the command used to view a PostScript file. The default depends on the platform.
732
733\membersection{::wxSetPrinterScaling}
734
735\func{void}{wxSetPrinterScaling}{\param{float }{x}, \param{float }{y}}
736
737Sets the scaling factor for PostScript output. The default is 1.0, 1.0.
738
739\membersection{::wxSetPrinterTranslation}
740
741\func{void}{wxSetPrinterTranslation}{\param{float }{x}, \param{float }{y}}
742
743Sets the translation (from the top left corner) for PostScript output. The default is 0.0, 0.0.
744
745\section{Clipboard functions}\label{clipsboard}
746
747These clipboard functions are implemented for Windows only.
748
954b8ae6
JS
749\wxheading{Include files}
750
751<wx/clipbrd.h>
752
a660d684
KB
753\membersection{::wxClipboardOpen}
754
755\func{bool}{wxClipboardOpen}{\void}
756
757Returns TRUE if this application has already opened the clipboard.
758
759\membersection{::wxCloseClipboard}
760
761\func{bool}{wxCloseClipboard}{\void}
762
763Closes the clipboard to allow other applications to use it.
764
765\membersection{::wxEmptyClipboard}
766
767\func{bool}{wxEmptyClipboard}{\void}
768
769Empties the clipboard.
770
771\membersection{::wxEnumClipboardFormats}
772
773\func{int}{wxEnumClipboardFormats}{\param{int}{dataFormat}}
774
775Enumerates the formats found in a list of available formats that belong
776to the clipboard. Each call to this function specifies a known
777available format; the function returns the format that appears next in
778the list.
779
780{\it dataFormat} specifies a known format. If this parameter is zero,
781the function returns the first format in the list.
782
783The return value specifies the next known clipboard data format if the
784function is successful. It is zero if the {\it dataFormat} parameter specifies
785the last format in the list of available formats, or if the clipboard
786is not open.
787
788Before it enumerates the formats function, an application must open the clipboard by using the
789wxOpenClipboard function.
790
791\membersection{::wxGetClipboardData}
792
793\func{wxObject *}{wxGetClipboardData}{\param{int}{dataFormat}}
794
795Gets data from the clipboard.
796
797{\it dataFormat} may be one of:
798
799\begin{itemize}\itemsep=0pt
800\item wxCF\_TEXT or wxCF\_OEMTEXT: returns a pointer to new memory containing a null-terminated text string.
801\item wxCF\_BITMAP: returns a new wxBitmap.
802\end{itemize}
803
804The clipboard must have previously been opened for this call to succeed.
805
806\membersection{::wxGetClipboardFormatName}
807
808\func{bool}{wxGetClipboardFormatName}{\param{int}{dataFormat}, \param{const wxString\& }{formatName}, \param{int}{maxCount}}
809
810Gets the name of a registered clipboard format, and puts it into the buffer {\it formatName} which is of maximum
811length {\it maxCount}. {\it dataFormat} must not specify a predefined clipboard format.
812
813\membersection{::wxIsClipboardFormatAvailable}
814
815\func{bool}{wxIsClipboardFormatAvailable}{\param{int}{dataFormat}}
816
817Returns TRUE if the given data format is available on the clipboard.
818
819\membersection{::wxOpenClipboard}
820
821\func{bool}{wxOpenClipboard}{\void}
822
823Opens the clipboard for passing data to it or getting data from it.
824
825\membersection{::wxRegisterClipboardFormat}
826
827\func{int}{wxRegisterClipboardFormat}{\param{const wxString\& }{formatName}}
828
829Registers the clipboard data format name and returns an identifier.
830
831\membersection{::wxSetClipboardData}
832
833\func{bool}{wxSetClipboardData}{\param{int}{dataFormat}, \param{wxObject *}{data}, \param{int}{width}, \param{int}{height}}
834
835Passes data to the clipboard.
836
837{\it dataFormat} may be one of:
838
839\begin{itemize}\itemsep=0pt
840\item wxCF\_TEXT or wxCF\_OEMTEXT: {\it data} is a null-terminated text string.
841\item wxCF\_BITMAP: {\it data} is a wxBitmap.
842\item wxCF\_DIB: {\it data} is a wxBitmap. The bitmap is converted to a DIB (device independent bitmap).
e2a6f233 843\item wxCF\_METAFILE: {\it data} is a wxMetafile. {\it width} and {\it height} are used to give recommended dimensions.
a660d684
KB
844\end{itemize}
845
846The clipboard must have previously been opened for this call to succeed.
847
848\section{Miscellaneous functions}\label{miscellany}
849
954b8ae6 850\membersection{::wxNewId}
a660d684 851
954b8ae6 852\func{long}{wxNewId}{\void}
a660d684
KB
853
854Generates an integer identifier unique to this run of the program.
855
954b8ae6
JS
856\wxheading{Include files}
857
858<wx/utils.h>
a660d684 859
954b8ae6
JS
860\membersection{::wxRegisterId}
861
862\func{void}{wxRegisterId}{\param{long}{ id}}
a660d684
KB
863
864Ensures that ids subsequently generated by {\bf NewId} do not clash with
865the given {\bf id}.
866
954b8ae6
JS
867\wxheading{Include files}
868
869<wx/utils.h>
870
a660d684
KB
871\membersection{::wxBeginBusyCursor}\label{wxbeginbusycursor}
872
873\func{void}{wxBeginBusyCursor}{\param{wxCursor *}{cursor = wxHOURGLASS\_CURSOR}}
874
875Changes the cursor to the given cursor for all windows in the application.
876Use \helpref{wxEndBusyCursor}{wxendbusycursor} to revert the cursor back
877to its previous state. These two calls can be nested, and a counter
878ensures that only the outer calls take effect.
879
e2a6f233 880See also \helpref{wxIsBusy}{wxisbusy}, \helpref{wxBusyCursor}{wxbusycursor}.
a660d684 881
954b8ae6
JS
882\wxheading{Include files}
883
884<wx/utils.h>
885
a660d684
KB
886\membersection{::wxBell}
887
888\func{void}{wxBell}{\void}
889
890Ring the system bell.
891
954b8ae6 892\wxheading{Include files}
a660d684 893
954b8ae6 894<wx/utils.h>
a660d684
KB
895
896\membersection{::wxCreateDynamicObject}\label{wxcreatedynamicobject}
897
898\func{wxObject *}{wxCreateDynamicObject}{\param{const wxString\& }{className}}
899
900Creates and returns an object of the given class, if the class has been
901registered with the dynamic class system using DECLARE... and IMPLEMENT... macros.
902
e2a6f233
JS
903\membersection{::wxDDECleanUp}\label{wxddecleanup}
904
905\func{void}{wxDDECleanUp}{\void}
906
907Called when wxWindows exits, to clean up the DDE system. This no longer needs to be
908called by the application.
909
910See also helpref{wxDDEInitialize}{wxddeinitialize}.
911
954b8ae6
JS
912\wxheading{Include files}
913
914<wx/dde.h>
915
e2a6f233
JS
916\membersection{::wxDDEInitialize}\label{wxddeinitialize}
917
918\func{void}{wxDDEInitialize}{\void}
919
920Initializes the DDE system. May be called multiple times without harm.
921
922This no longer needs to be called by the application: it will be called
923by wxWindows if necessary.
924
925See also \helpref{wxDDEServer}{wxddeserver}, \helpref{wxDDEClient}{wxddeclient}, \helpref{wxDDEConnection}{wxddeconnection},
926\helpref{wxDDECleanUp}{wxddecleanup}.
927
954b8ae6
JS
928\wxheading{Include files}
929
930<wx/dde.h>
931
e2a6f233 932\membersection{::wxDebugMsg}\label{wxdebugmsg}
a660d684
KB
933
934\func{void}{wxDebugMsg}{\param{const wxString\& }{fmt}, \param{...}{}}
935
936Display a debugging message; under Windows, this will appear on the
e2a6f233 937debugger command window, and under Unix, it will be written to standard
a660d684
KB
938error.
939
940The syntax is identical to {\bf printf}: pass a format string and a
941variable list of arguments.
942
943Note that under Windows, you can see the debugging messages without a
944debugger if you have the DBWIN debug log application that comes with
945Microsoft C++.
946
947{\bf Tip:} under Windows, if your application crashes before the
948message appears in the debugging window, put a wxYield call after
949each wxDebugMsg call. wxDebugMsg seems to be broken under WIN32s
950(at least for Watcom C++): preformat your messages and use OutputDebugString
951instead.
952
6fb26ea3
JS
953This function is now obsolete, replaced by \helpref{Log functions}{logfunctions}.
954
954b8ae6
JS
955\wxheading{Include files}
956
957<wx/utils.h>
958
a660d684
KB
959\membersection{::wxDisplaySize}
960
961\func{void}{wxDisplaySize}{\param{int *}{width}, \param{int *}{height}}
962
963Gets the physical size of the display in pixels.
964
954b8ae6
JS
965\wxheading{Include files}
966
967<wx/gdicmn.h>
968
a660d684
KB
969\membersection{::wxEntry}\label{wxentry}
970
971This initializes wxWindows in a platform-dependent way. Use this if you
972are not using the default wxWindows entry code (e.g. main or WinMain). For example,
973you can initialize wxWindows from an Microsoft Foundation Classes application using
954b8ae6 974this function.
a660d684
KB
975
976\func{void}{wxEntry}{\param{HANDLE}{ hInstance}, \param{HANDLE}{ hPrevInstance},
977 \param{const wxString\& }{commandLine}, \param{int}{ cmdShow}, \param{bool}{ enterLoop = TRUE}}
978
979wxWindows initialization under Windows (non-DLL). If {\it enterLoop} is FALSE, the
980function will return immediately after calling wxApp::OnInit. Otherwise, the wxWindows
981message loop will be entered.
982
983\func{void}{wxEntry}{\param{HANDLE}{ hInstance}, \param{HANDLE}{ hPrevInstance},
984 \param{WORD}{ wDataSegment}, \param{WORD}{ wHeapSize}, \param{const wxString\& }{ commandLine}}
985
986wxWindows initialization under Windows (for applications constructed as a DLL).
987
988\func{int}{wxEntry}{\param{int}{ argc}, \param{const wxString\& *}{argv}}
989
e2a6f233 990wxWindows initialization under Unix.
a660d684 991
954b8ae6
JS
992\wxheading{Remarks}
993
994To clean up wxWindows, call wxApp::OnExit followed by the static function
995wxApp::CleanUp. For example, if exiting from an MFC application that also uses wxWindows:
996
997\begin{verbatim}
998int CTheApp::ExitInstance()
999{
1000 // OnExit isn't called by CleanUp so must be called explicitly.
1001 wxTheApp->OnExit();
1002 wxApp::CleanUp();
1003
1004 return CWinApp::ExitInstance();
1005}
1006\end{verbatim}
1007
1008\wxheading{Include files}
1009
1010<wx/app.h>
1011
a660d684
KB
1012\membersection{::wxError}\label{wxerror}
1013
1014\func{void}{wxError}{\param{const wxString\& }{msg}, \param{const wxString\& }{title = "wxWindows Internal Error"}}
1015
1016Displays {\it msg} and continues. This writes to standard error under
e2a6f233 1017Unix, and pops up a message box under Windows. Used for internal
a660d684
KB
1018wxWindows errors. See also \helpref{wxFatalError}{wxfatalerror}.
1019
954b8ae6
JS
1020\wxheading{Include files}
1021
1022<wx/utils.h>
1023
a660d684
KB
1024\membersection{::wxEndBusyCursor}\label{wxendbusycursor}
1025
1026\func{void}{wxEndBusyCursor}{\void}
1027
1028Changes the cursor back to the original cursor, for all windows in the application.
1029Use with \helpref{wxBeginBusyCursor}{wxbeginbusycursor}.
1030
e2a6f233 1031See also \helpref{wxIsBusy}{wxisbusy}, \helpref{wxBusyCursor}{wxbusycursor}.
a660d684 1032
954b8ae6
JS
1033\wxheading{Include files}
1034
1035<wx/utils.h>
1036
a660d684
KB
1037\membersection{::wxExecute}\label{wxexecute}
1038
eafc087e 1039\func{long}{wxExecute}{\param{const wxString\& }{command}, \param{bool }{sync = FALSE}, \param{wxProcess *}{callback = NULL}}
a660d684 1040
e2a6f233 1041\func{long}{wxExecute}{\param{char **}{argv}, \param{bool }{sync = FALSE}, \param{wxProcess *}{callback = NULL}}
a660d684 1042
e2a6f233 1043Executes another program in Unix or Windows.
a660d684
KB
1044
1045The first form takes a command string, such as {\tt "emacs file.txt"}.
1046
1047The second form takes an array of values: a command, any number of
1048arguments, terminated by NULL.
1049
1050If {\it sync} is FALSE (the default), flow of control immediately returns.
1051If TRUE, the current application waits until the other program has terminated.
1052
43bb3699 1053In the case of synchronous execution, the return value is the exit code of
e6045e08
VZ
1054the process (which terminates by the moment the function returns) and will be
1055$-1$ if the process couldn't be started and typically 0 if the process
1056terminated successfully.
1057
1058For asynchronous execution, however, the return value is the process id and
1059zero value indicates that the command could not be executed.
a660d684 1060
7e84f02d
VZ
1061If callback isn't NULL and if execution is asynchronous (note that callback
1062parameter can not be non NULL for synchronous execution),
eafc087e
GL
1063\helpref{wxProcess::OnTerminate}{wxprocessonterminate} will be called when
1064the process finishes.
1065
1066See also \helpref{wxShell}{wxshell}, \helpref{wxProcess}{wxprocess}.
a660d684 1067
954b8ae6
JS
1068\wxheading{Include files}
1069
1070<wx/utils.h>
1071
a660d684
KB
1072\membersection{::wxExit}\label{wxexit}
1073
1074\func{void}{wxExit}{\void}
1075
1076Exits application after calling \helpref{wxApp::OnExit}{wxapponexit}.
1077Should only be used in an emergency: normally the top-level frame
1078should be deleted (after deleting all other frames) to terminate the
1079application. See \helpref{wxWindow::OnCloseWindow}{wxwindowonclosewindow} and \helpref{wxApp}{wxapp}.
1080
954b8ae6
JS
1081\wxheading{Include files}
1082
1083<wx/app.h>
1084
a660d684
KB
1085\membersection{::wxFatalError}\label{wxfatalerror}
1086
1087\func{void}{wxFatalError}{\param{const wxString\& }{msg}, \param{const wxString\& }{title = "wxWindows Fatal Error"}}
1088
e2a6f233 1089Displays {\it msg} and exits. This writes to standard error under Unix,
a660d684
KB
1090and pops up a message box under Windows. Used for fatal internal
1091wxWindows errors. See also \helpref{wxError}{wxerror}.
1092
954b8ae6
JS
1093\wxheading{Include files}
1094
1095<wx/utils.h>
1096
a660d684
KB
1097\membersection{::wxFindMenuItemId}
1098
1099\func{int}{wxFindMenuItemId}{\param{wxFrame *}{frame}, \param{const wxString\& }{menuString}, \param{const wxString\& }{itemString}}
1100
1101Find a menu item identifier associated with the given frame's menu bar.
1102
954b8ae6
JS
1103\wxheading{Include files}
1104
1105<wx/utils.h>
1106
a660d684
KB
1107\membersection{::wxFindWindowByLabel}
1108
1109\func{wxWindow *}{wxFindWindowByLabel}{\param{const wxString\& }{label}, \param{wxWindow *}{parent=NULL}}
1110
1111Find a window by its label. Depending on the type of window, the label may be a window title
1112or panel item label. If {\it parent} is NULL, the search will start from all top-level
1113frames and dialog boxes; if non-NULL, the search will be limited to the given window hierarchy.
1114The search is recursive in both cases.
1115
954b8ae6
JS
1116\wxheading{Include files}
1117
1118<wx/utils.h>
1119
a660d684
KB
1120\membersection{::wxFindWindowByName}\label{wxfindwindowbyname}
1121
1122\func{wxWindow *}{wxFindWindowByName}{\param{const wxString\& }{name}, \param{wxWindow *}{parent=NULL}}
1123
1124Find a window by its name (as given in a window constructor or {\bf Create} function call).
1125If {\it parent} is NULL, the search will start from all top-level
1126frames and dialog boxes; if non-NULL, the search will be limited to the given window hierarchy.
1127The search is recursive in both cases.
1128
1129If no such named window is found, {\bf wxFindWindowByLabel} is called.
1130
954b8ae6
JS
1131\wxheading{Include files}
1132
1133<wx/utils.h>
1134
a660d684
KB
1135\membersection{::wxGetActiveWindow}\label{wxgetactivewindow}
1136
1137\func{wxWindow *}{wxGetActiveWindow}{\void}
1138
1139Gets the currently active window (Windows only).
1140
954b8ae6
JS
1141\wxheading{Include files}
1142
1143<wx/windows.h>
1144
a660d684
KB
1145\membersection{::wxGetDisplayName}\label{wxgetdisplayname}
1146
1147\func{wxString}{wxGetDisplayName}{\void}
1148
1149Under X only, returns the current display name. See also \helpref{wxSetDisplayName}{wxsetdisplayname}.
1150
954b8ae6
JS
1151\wxheading{Include files}
1152
1153<wx/utils.h>
1154
a660d684
KB
1155\membersection{::wxGetHomeDir}
1156
1157\func{wxString}{wxGetHomeDir}{\param{const wxString\& }{buf}}
1158
e2a6f233 1159Fills the buffer with a string representing the user's home directory (Unix only).
a660d684 1160
954b8ae6
JS
1161\wxheading{Include files}
1162
1163<wx/utils.h>
1164
a660d684
KB
1165\membersection{::wxGetHostName}
1166
1167\func{bool}{wxGetHostName}{\param{const wxString\& }{buf}, \param{int}{ bufSize}}
1168
1169Copies the host name of the machine the program is running on into the
1170buffer {\it buf}, of maximum size {\it bufSize}, returning TRUE if
e2a6f233 1171successful. Under Unix, this will return a machine name. Under Windows,
a660d684
KB
1172this returns ``windows''.
1173
954b8ae6
JS
1174\wxheading{Include files}
1175
1176<wx/utils.h>
1177
a660d684
KB
1178\membersection{::wxGetElapsedTime}\label{wxgetelapsedtime}
1179
1180\func{long}{wxGetElapsedTime}{\param{bool}{ resetTimer = TRUE}}
1181
1182Gets the time in milliseconds since the last \helpref{::wxStartTimer}{wxstarttimer}.
1183
1184If {\it resetTimer} is TRUE (the default), the timer is reset to zero
1185by this call.
1186
1187See also \helpref{wxTimer}{wxtimer}.
1188
954b8ae6
JS
1189\wxheading{Include files}
1190
1191<wx/timer.h>
1192
e2a6f233 1193\membersection{::wxGetFreeMemory}\label{wxgetfreememory}
a660d684
KB
1194
1195\func{long}{wxGetFreeMemory}{\void}
1196
1197Returns the amount of free memory in Kbytes under environments which
1198support it, and -1 if not supported. Currently, returns a positive value
e2a6f233 1199under Windows, and -1 under Unix.
a660d684 1200
954b8ae6
JS
1201\wxheading{Include files}
1202
1203<wx/utils.h>
1204
a660d684
KB
1205\membersection{::wxGetMousePosition}
1206
1207\func{void}{wxGetMousePosition}{\param{int* }{x}, \param{int* }{y}}
1208
1209Returns the mouse position in screen coordinates.
1210
954b8ae6
JS
1211\wxheading{Include files}
1212
1213<wx/utils.h>
1214
a660d684
KB
1215\membersection{::wxGetOsVersion}
1216
1217\func{int}{wxGetOsVersion}{\param{int *}{major = NULL}, \param{int *}{minor = NULL}}
1218
1219Gets operating system version information.
1220
1221\begin{twocollist}\itemsep=0pt
1222\twocolitemruled{Platform}{Return tyes}
1223\twocolitem{Macintosh}{Return value is wxMACINTOSH.}
12a44087 1224\twocolitem{GTK}{Return value is wxGTK, {\it major} is 1, {\it minor} is 0. (for GTK 1.0.X) }
a660d684
KB
1225\twocolitem{Motif}{Return value is wxMOTIF\_X, {\it major} is X version, {\it minor} is X revision.}
1226\twocolitem{OS/2}{Return value is wxOS2\_PM.}
1227\twocolitem{Windows 3.1}{Return value is wxWINDOWS, {\it major} is 3, {\it minor} is 1.}
1228\twocolitem{Windows NT}{Return value is wxWINDOWS\_NT, {\it major} is 3, {\it minor} is 1.}
1229\twocolitem{Windows 95}{Return value is wxWIN95, {\it major} is 3, {\it minor} is 1.}
1230\twocolitem{Win32s (Windows 3.1)}{Return value is wxWIN32S, {\it major} is 3, {\it minor} is 1.}
1231\twocolitem{Watcom C++ 386 supervisor mode (Windows 3.1)}{Return value is wxWIN386, {\it major} is 3, {\it minor} is 1.}
1232\end{twocollist}
1233
954b8ae6
JS
1234\wxheading{Include files}
1235
1236<wx/utils.h>
1237
a660d684
KB
1238\membersection{::wxGetResource}\label{wxgetresource}
1239
1240\func{bool}{wxGetResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},
1241 \param{const wxString\& *}{value}, \param{const wxString\& }{file = NULL}}
1242
1243\func{bool}{wxGetResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},
1244 \param{float *}{value}, \param{const wxString\& }{file = NULL}}
1245
1246\func{bool}{wxGetResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},
1247 \param{long *}{value}, \param{const wxString\& }{file = NULL}}
1248
1249\func{bool}{wxGetResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},
1250 \param{int *}{value}, \param{const wxString\& }{file = NULL}}
1251
1252Gets a resource value from the resource database (for example, WIN.INI, or
1253.Xdefaults). If {\it file} is NULL, WIN.INI or .Xdefaults is used,
1254otherwise the specified file is used.
1255
e2a6f233 1256Under X, if an application class (wxApp::GetClassName) has been defined,
a660d684
KB
1257it is appended to the string /usr/lib/X11/app-defaults/ to try to find
1258an applications default file when merging all resource databases.
1259
1260The reason for passing the result in an argument is that it
1261can be convenient to define a default value, which gets overridden
1262if the value exists in the resource file. It saves a separate
1263test for that resource's existence, and it also allows
1264the overloading of the function for different types.
1265
e2a6f233 1266See also \helpref{wxWriteResource}{wxwriteresource}, \helpref{wxConfigBase}{wxconfigbase}.
a660d684 1267
954b8ae6
JS
1268\wxheading{Include files}
1269
1270<wx/utils.h>
1271
a660d684
KB
1272\membersection{::wxGetUserId}
1273
1274\func{bool}{wxGetUserId}{\param{const wxString\& }{buf}, \param{int}{ bufSize}}
1275
1276Copies the user's login identity (such as ``jacs'') into the buffer {\it
1277buf}, of maximum size {\it bufSize}, returning TRUE if successful.
1278Under Windows, this returns ``user''.
1279
954b8ae6
JS
1280\wxheading{Include files}
1281
1282<wx/utils.h>
1283
a660d684
KB
1284\membersection{::wxGetUserName}
1285
1286\func{bool}{wxGetUserName}{\param{const wxString\& }{buf}, \param{int}{ bufSize}}
1287
1288Copies the user's name (such as ``Julian Smart'') into the buffer {\it
1289buf}, of maximum size {\it bufSize}, returning TRUE if successful.
1290Under Windows, this returns ``unknown''.
1291
954b8ae6
JS
1292\wxheading{Include files}
1293
1294<wx/utils.h>
1295
a660d684
KB
1296\membersection{::wxKill}\label{wxkill}
1297
1298\func{int}{wxKill}{\param{long}{ pid}, \param{int}{ sig}}
1299
e2a6f233 1300Under Unix (the only supported platform), equivalent to the Unix kill function.
a660d684
KB
1301Returns 0 on success, -1 on failure.
1302
1303Tip: sending a signal of 0 to a process returns -1 if the process does not exist.
1304It does not raise a signal in the receiving process.
1305
954b8ae6 1306\wxheading{Include files}
a660d684 1307
954b8ae6 1308<wx/utils.h>
a660d684 1309
a660d684
KB
1310\membersection{::wxIsBusy}\label{wxisbusy}
1311
1312\func{bool}{wxIsBusy}{\void}
1313
1314Returns TRUE if between two \helpref{wxBeginBusyCursor}{wxbeginbusycursor} and\rtfsp
1315\helpref{wxEndBusyCursor}{wxendbusycursor} calls.
1316
e2a6f233
JS
1317See also \helpref{wxBusyCursor}{wxbusycursor}.
1318
954b8ae6
JS
1319\wxheading{Include files}
1320
1321<wx/utils.h>
1322
a660d684
KB
1323\membersection{::wxLoadUserResource}\label{wxloaduserresource}
1324
1325\func{wxString}{wxLoadUserResource}{\param{const wxString\& }{resourceName}, \param{const wxString\& }{resourceType=``TEXT"}}
1326
1327Loads a user-defined Windows resource as a string. If the resource is found, the function creates
1328a new character array and copies the data into it. A pointer to this data is returned. If unsuccessful, NULL is returned.
1329
1330The resource must be defined in the {\tt .rc} file using the following syntax:
1331
1332\begin{verbatim}
1333myResource TEXT file.ext
1334\end{verbatim}
1335
1336where {\tt file.ext} is a file that the resource compiler can find.
1337
1338One use of this is to store {\tt .wxr} files instead of including the data in the C++ file; some compilers
1339cannot cope with the long strings in a {\tt .wxr} file. The resource data can then be parsed
1340using \helpref{wxResourceParseString}{wxresourceparsestring}.
1341
1342This function is available under Windows only.
1343
954b8ae6
JS
1344\wxheading{Include files}
1345
1346<wx/utils.h>
1347
a660d684
KB
1348\membersection{::wxNow}\label{wxnow}
1349
1350\func{wxString}{wxNow}{\void}
1351
1352Returns a string representing the current date and time.
1353
954b8ae6
JS
1354\wxheading{Include files}
1355
1356<wx/utils.h>
1357
a660d684
KB
1358\membersection{::wxPostDelete}\label{wxpostdelete}
1359
1360\func{void}{wxPostDelete}{\param{wxObject *}{object}}
1361
954b8ae6 1362Tells the system to delete the specified object when
a660d684
KB
1363all other events have been processed. In some environments, it is
1364necessary to use this instead of deleting a frame directly with the
954b8ae6 1365delete operator, because some GUIs will still send events to a deleted window.
a660d684
KB
1366
1367Now obsolete: use \helpref{wxWindow::Close}{wxwindowclose} instead.
1368
954b8ae6
JS
1369\wxheading{Include files}
1370
1371<wx/utils.h>
1372
43bb3699
VZ
1373\membersection{::wxSafeYield}{wxsafeyield}
1374
1375\func{bool}{wxSafeYield}{\param{wxWindow*}{ win = NULL}}
1376
1377This function is similar to wxYield, except that it disables the user input to
a818ccea
KB
1378all program windows before calling wxYield and re-enables it again
1379afterwards. If {\it win} is not NULL, this window will remain enabled,
1380allowing the implementation of some limited user interaction.
43bb3699
VZ
1381
1382Returns the result of the call to \helpref{::wxYield}{wxyield}.
1383
1384\wxheading{Include files}
1385
1386<wx/utils.h>
1387
a660d684
KB
1388\membersection{::wxSetDisplayName}\label{wxsetdisplayname}
1389
1390\func{void}{wxSetDisplayName}{\param{const wxString\& }{displayName}}
1391
1392Under X only, sets the current display name. This is the X host and display name such
1393as ``colonsay:0.0", and the function indicates which display should be used for creating
1394windows from this point on. Setting the display within an application allows multiple
1395displays to be used.
1396
1397See also \helpref{wxGetDisplayName}{wxgetdisplayname}.
1398
954b8ae6
JS
1399\wxheading{Include files}
1400
1401<wx/utils.h>
1402
a660d684
KB
1403\membersection{::wxShell}\label{wxshell}
1404
1405\func{bool}{wxShell}{\param{const wxString\& }{command = NULL}}
1406
1407Executes a command in an interactive shell window. If no command is
1408specified, then just the shell is spawned.
1409
1410See also \helpref{wxExecute}{wxexecute}.
1411
954b8ae6
JS
1412\wxheading{Include files}
1413
1414<wx/utils.h>
1415
e2a6f233 1416\membersection{::wxSleep}\label{wxsleep}
a660d684
KB
1417
1418\func{void}{wxSleep}{\param{int}{ secs}}
1419
e2a6f233 1420Sleeps for the specified number of seconds.
a660d684 1421
954b8ae6
JS
1422\wxheading{Include files}
1423
1424<wx/utils.h>
1425
a660d684
KB
1426\membersection{::wxStripMenuCodes}
1427
8a2c6ef8
JS
1428\func{wxString}{wxStripMenuCodes}{\param{const wxString\& }{in}}
1429
1430\func{void}{wxStripMenuCodes}{\param{char* }{in}, \param{char* }{out}}
a660d684
KB
1431
1432Strips any menu codes from {\it in} and places the result
8a2c6ef8
JS
1433in {\it out} (or returns the new string, in the first form).
1434
1435Menu codes include \& (mark the next character with an underline
a660d684
KB
1436as a keyboard shortkey in Windows and Motif) and $\backslash$t (tab in Windows).
1437
954b8ae6
JS
1438\wxheading{Include files}
1439
1440<wx/utils.h>
1441
a660d684
KB
1442\membersection{::wxStartTimer}\label{wxstarttimer}
1443
1444\func{void}{wxStartTimer}{\void}
1445
1446Starts a stopwatch; use \helpref{::wxGetElapsedTime}{wxgetelapsedtime} to get the elapsed time.
1447
1448See also \helpref{wxTimer}{wxtimer}.
1449
954b8ae6
JS
1450\wxheading{Include files}
1451
1452<wx/timer.h>
1453
a660d684
KB
1454\membersection{::wxToLower}\label{wxtolower}
1455
1456\func{char}{wxToLower}{\param{char }{ch}}
1457
1458Converts the character to lower case. This is implemented as a macro for efficiency.
1459
954b8ae6
JS
1460\wxheading{Include files}
1461
1462<wx/utils.h>
1463
a660d684
KB
1464\membersection{::wxToUpper}\label{wxtoupper}
1465
1466\func{char}{wxToUpper}{\param{char }{ch}}
1467
1468Converts the character to upper case. This is implemented as a macro for efficiency.
1469
954b8ae6
JS
1470\wxheading{Include files}
1471
1472<wx/utils.h>
1473
a660d684
KB
1474\membersection{::wxTrace}\label{wxtrace}
1475
1476\func{void}{wxTrace}{\param{const wxString\& }{fmt}, \param{...}{}}
1477
1478Takes printf-style variable argument syntax. Output
1479is directed to the current output stream (see \helpref{wxDebugContext}{wxdebugcontextoverview}).
1480
6fb26ea3
JS
1481This function is now obsolete, replaced by \helpref{Log functions}{logfunctions}.
1482
954b8ae6
JS
1483\wxheading{Include files}
1484
1485<wx/memory.h>
1486
a660d684
KB
1487\membersection{::wxTraceLevel}\label{wxtracelevel}
1488
1489\func{void}{wxTraceLevel}{\param{int}{ level}, \param{const wxString\& }{fmt}, \param{...}{}}
1490
1491Takes printf-style variable argument syntax. Output
1492is directed to the current output stream (see \helpref{wxDebugContext}{wxdebugcontextoverview}).
1493The first argument should be the level at which this information is appropriate.
1494It will only be output if the level returned by wxDebugContext::GetLevel is equal to or greater than
1495this value.
1496
6fb26ea3
JS
1497This function is now obsolete, replaced by \helpref{Log functions}{logfunctions}.
1498
954b8ae6
JS
1499\wxheading{Include files}
1500
1501<wx/memory.h>
1502
afb74891
VZ
1503\membersection{::wxUsleep}\label{wxusleep}
1504
1505\func{void}{wxUsleep}{\param{unsigned long}{ milliseconds}}
1506
1507Sleeps for the specified number of milliseconds. Notice that usage of this
1508function is encouraged instead of calling usleep(3) directly because the
1509standard usleep() function is not MT safe.
1510
1511\wxheading{Include files}
1512
1513<wx/utils.h>
1514
a660d684
KB
1515\membersection{::wxWriteResource}\label{wxwriteresource}
1516
1517\func{bool}{wxWriteResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},
1518 \param{const wxString\& }{value}, \param{const wxString\& }{file = NULL}}
1519
1520\func{bool}{wxWriteResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},
1521 \param{float }{value}, \param{const wxString\& }{file = NULL}}
1522
1523\func{bool}{wxWriteResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},
1524 \param{long }{value}, \param{const wxString\& }{file = NULL}}
1525
1526\func{bool}{wxWriteResource}{\param{const wxString\& }{section}, \param{const wxString\& }{entry},
1527 \param{int }{value}, \param{const wxString\& }{file = NULL}}
1528
1529Writes a resource value into the resource database (for example, WIN.INI, or
1530.Xdefaults). If {\it file} is NULL, WIN.INI or .Xdefaults is used,
1531otherwise the specified file is used.
1532
1533Under X, the resource databases are cached until the internal function
1534\rtfsp{\bf wxFlushResources} is called automatically on exit, when
1535all updated resource databases are written to their files.
1536
1537Note that it is considered bad manners to write to the .Xdefaults
e2a6f233 1538file under Unix, although the WIN.INI file is fair game under Windows.
a660d684 1539
e2a6f233 1540See also \helpref{wxGetResource}{wxgetresource}, \helpref{wxConfigBase}{wxconfigbase}.
a660d684 1541
954b8ae6
JS
1542\wxheading{Include files}
1543
1544<wx/utils.h>
1545
fd34e3a5 1546\membersection{::wxYield}\label{wxyield}
a660d684
KB
1547
1548\func{bool}{wxYield}{\void}
1549
1550Yields control to pending messages in the windowing system. This can be useful, for example, when a
1551time-consuming process writes to a text window. Without an occasional
1552yield, the text window will not be updated properly, and (since Windows
1553multitasking is cooperative) other processes will not respond.
1554
1555Caution should be exercised, however, since yielding may allow the
1556user to perform actions which are not compatible with the current task.
1557Disabling menu items or whole menus during processing can avoid unwanted
43bb3699
VZ
1558reentrance of code: see \helpref{::wxSafeYield}{wxsafeyield} for a better
1559function.
a660d684 1560
954b8ae6
JS
1561\wxheading{Include files}
1562
1563<wx/utils.h>
1564
a660d684
KB
1565\section{Macros}\label{macros}
1566
1567These macros are defined in wxWindows.
1568
1569\membersection{CLASSINFO}\label{classinfo}
1570
1571\func{wxClassInfo *}{CLASSINFO}{className}
1572
1573Returns a pointer to the wxClassInfo object associated with this class.
1574
954b8ae6
JS
1575\wxheading{Include files}
1576
1577<wx/object.h>
1578
a660d684
KB
1579\membersection{WXDEBUG\_NEW}\label{debugnew}
1580
1581\func{}{WXDEBUG\_NEW}{arg}
1582
1583This is defined in debug mode to be call the redefined new operator
1584with filename and line number arguments. The definition is:
1585
1586\begin{verbatim}
1587#define WXDEBUG_NEW new(__FILE__,__LINE__)
1588\end{verbatim}
1589
1590In non-debug mode, this is defined as the normal new operator.
1591
954b8ae6
JS
1592\wxheading{Include files}
1593
1594<wx/object.h>
1595
a660d684
KB
1596\membersection{DECLARE\_ABSTRACT\_CLASS}
1597
1598\func{}{DECLARE\_ABSTRACT\_CLASS}{className}
1599
1600Used inside a class declaration to declare that the class should be
1601made known to the class hierarchy, but objects of this class cannot be created
1602dynamically. The same as DECLARE\_CLASS.
1603
1604Example:
1605
1606\begin{verbatim}
1607class wxCommand: public wxObject
1608{
1609 DECLARE_ABSTRACT_CLASS(wxCommand)
1610
1611 private:
1612 ...
1613 public:
1614 ...
1615};
1616\end{verbatim}
1617
954b8ae6
JS
1618\wxheading{Include files}
1619
1620<wx/object.h>
1621
a660d684
KB
1622\membersection{DECLARE\_APP}\label{declareapp}
1623
1624\func{}{DECLARE\_APP}{className}
1625
1626This is used in headers to create a forward declaration of the wxGetApp function implemented
1627by IMPLEMENT\_APP. It creates the declaration {\tt className\& wxGetApp(void)}.
1628
1629Example:
1630
1631\begin{verbatim}
1632 DECLARE_APP(MyApp)
1633\end{verbatim}
1634
954b8ae6
JS
1635\wxheading{Include files}
1636
1637<wx/app.h>
1638
a660d684
KB
1639\membersection{DECLARE\_CLASS}
1640
1641\func{}{DECLARE\_CLASS}{className}
1642
1643Used inside a class declaration to declare that the class should be
1644made known to the class hierarchy, but objects of this class cannot be created
1645dynamically. The same as DECLARE\_ABSTRACT\_CLASS.
1646
954b8ae6
JS
1647\wxheading{Include files}
1648
1649<wx/object.h>
1650
a660d684
KB
1651\membersection{DECLARE\_DYNAMIC\_CLASS}
1652
1653\func{}{DECLARE\_DYNAMIC\_CLASS}{className}
1654
1655Used inside a class declaration to declare that the objects of this class should be dynamically
1656createable from run-time type information.
1657
1658Example:
1659
1660\begin{verbatim}
1661class wxFrame: public wxWindow
1662{
1663 DECLARE_DYNAMIC_CLASS(wxFrame)
1664
1665 private:
1666 const wxString\& frameTitle;
1667 public:
1668 ...
1669};
1670\end{verbatim}
1671
954b8ae6
JS
1672\wxheading{Include files}
1673
1674<wx/object.h>
1675
a660d684
KB
1676\membersection{IMPLEMENT\_ABSTRACT\_CLASS}
1677
1678\func{}{IMPLEMENT\_ABSTRACT\_CLASS}{className, baseClassName}
1679
1680Used in a C++ implementation file to complete the declaration of
1681a class that has run-time type information. The same as IMPLEMENT\_CLASS.
1682
1683Example:
1684
1685\begin{verbatim}
1686IMPLEMENT_ABSTRACT_CLASS(wxCommand, wxObject)
1687
1688wxCommand::wxCommand(void)
1689{
1690...
1691}
1692\end{verbatim}
1693
954b8ae6
JS
1694\wxheading{Include files}
1695
1696<wx/object.h>
1697
a660d684
KB
1698\membersection{IMPLEMENT\_ABSTRACT\_CLASS2}
1699
1700\func{}{IMPLEMENT\_ABSTRACT\_CLASS2}{className, baseClassName1, baseClassName2}
1701
1702Used in a C++ implementation file to complete the declaration of
1703a class that has run-time type information and two base classes. The same as IMPLEMENT\_CLASS2.
1704
954b8ae6
JS
1705\wxheading{Include files}
1706
1707<wx/object.h>
1708
a660d684
KB
1709\membersection{IMPLEMENT\_APP}\label{implementapp}
1710
1711\func{}{IMPLEMENT\_APP}{className}
1712
1713This is used in the application class implementation file to make the application class known to
1714wxWindows for dynamic construction. You use this instead of
1715
1716Old form:
1717
1718\begin{verbatim}
1719 MyApp myApp;
1720\end{verbatim}
1721
1722New form:
1723
1724\begin{verbatim}
1725 IMPLEMENT_APP(MyApp)
1726\end{verbatim}
1727
1728See also \helpref{DECLARE\_APP}{declareapp}.
1729
954b8ae6
JS
1730\wxheading{Include files}
1731
1732<wx/app.h>
1733
a660d684
KB
1734\membersection{IMPLEMENT\_CLASS}
1735
1736\func{}{IMPLEMENT\_CLASS}{className, baseClassName}
1737
1738Used in a C++ implementation file to complete the declaration of
1739a class that has run-time type information. The same as IMPLEMENT\_ABSTRACT\_CLASS.
1740
954b8ae6
JS
1741\wxheading{Include files}
1742
1743<wx/object.h>
1744
a660d684
KB
1745\membersection{IMPLEMENT\_CLASS2}
1746
1747\func{}{IMPLEMENT\_CLASS2}{className, baseClassName1, baseClassName2}
1748
1749Used in a C++ implementation file to complete the declaration of a
1750class that has run-time type information and two base classes. The
1751same as IMPLEMENT\_ABSTRACT\_CLASS2.
1752
954b8ae6
JS
1753\wxheading{Include files}
1754
1755<wx/object.h>
1756
a660d684
KB
1757\membersection{IMPLEMENT\_DYNAMIC\_CLASS}
1758
1759\func{}{IMPLEMENT\_DYNAMIC\_CLASS}{className, baseClassName}
1760
1761Used in a C++ implementation file to complete the declaration of
1762a class that has run-time type information, and whose instances
1763can be created dynamically.
1764
1765Example:
1766
1767\begin{verbatim}
1768IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
1769
1770wxFrame::wxFrame(void)
1771{
1772...
1773}
1774\end{verbatim}
1775
954b8ae6
JS
1776\wxheading{Include files}
1777
1778<wx/object.h>
1779
a660d684
KB
1780\membersection{IMPLEMENT\_DYNAMIC\_CLASS2}
1781
1782\func{}{IMPLEMENT\_DYNAMIC\_CLASS2}{className, baseClassName1, baseClassName2}
1783
1784Used in a C++ implementation file to complete the declaration of
1785a class that has run-time type information, and whose instances
1786can be created dynamically. Use this for classes derived from two
1787base classes.
1788
954b8ae6
JS
1789\wxheading{Include files}
1790
1791<wx/object.h>
1792
a660d684
KB
1793\membersection{WXTRACE}\label{trace}
1794
1795\func{}{WXTRACE}{formatString, ...}
1796
1797Calls wxTrace with printf-style variable argument syntax. Output
1798is directed to the current output stream (see \helpref{wxDebugContext}{wxdebugcontextoverview}).
1799
6fb26ea3
JS
1800This macro is now obsolete, replaced by \helpref{Log functions}{logfunctions}.
1801
954b8ae6
JS
1802\wxheading{Include files}
1803
1804<wx/memory.h>
1805
a660d684
KB
1806\membersection{WXTRACELEVEL}\label{tracelevel}
1807
1808\func{}{WXTRACELEVEL}{level, formatString, ...}
1809
1810Calls wxTraceLevel with printf-style variable argument syntax. Output
1811is directed to the current output stream (see \helpref{wxDebugContext}{wxdebugcontextoverview}).
1812The first argument should be the level at which this information is appropriate.
1813It will only be output if the level returned by wxDebugContext::GetLevel is equal to or greater than
1814this value.
1815
6fb26ea3
JS
1816This function is now obsolete, replaced by \helpref{Log functions}{logfunctions}.
1817
954b8ae6
JS
1818\wxheading{Include files}
1819
1820<wx/memory.h>
1821
a660d684
KB
1822\section{wxWindows resource functions}\label{resourcefuncs}
1823
1824\overview{wxWindows resource system}{resourceformats}
1825
1826This section details functions for manipulating wxWindows (.WXR) resource
1827files and loading user interface elements from resources.
1828
1829\normalbox{Please note that this use of the word `resource' is different from that used when talking
1830about initialisation file resource reading and writing, using such functions
1831as wxWriteResource and wxGetResource. It's just an unfortunate clash of terminology.}
1832
1833\helponly{For an overview of the wxWindows resource mechanism, see \helpref{the wxWindows resource system}{resourceformats}.}
1834
1835See also \helpref{wxWindow::LoadFromResource}{wxwindowloadfromresource} for
1836loading from resource data.
1837
954b8ae6
JS
1838{\bf Warning:} this needs updating for wxWindows 2.
1839
a660d684
KB
1840\membersection{::wxResourceAddIdentifier}\label{wxresourceaddidentifier}
1841
1842\func{bool}{wxResourceAddIdentifier}{\param{const wxString\& }{name}, \param{int }{value}}
1843
1844Used for associating a name with an integer identifier (equivalent to dynamically\rtfsp
1845\verb$#$defining a name to an integer). Unlikely to be used by an application except
1846perhaps for implementing resource functionality for interpreted languages.
1847
1848\membersection{::wxResourceClear}
1849
1850\func{void}{wxResourceClear}{\void}
1851
1852Clears the wxWindows resource table.
1853
1854\membersection{::wxResourceCreateBitmap}
1855
1856\func{wxBitmap *}{wxResourceCreateBitmap}{\param{const wxString\& }{resource}}
1857
1858Creates a new bitmap from a file, static data, or Windows resource, given a valid
1859wxWindows bitmap resource identifier. For example, if the .WXR file contains
1860the following:
1861
1862\begin{verbatim}
1863static const wxString\& aiai_resource = "bitmap(name = 'aiai_resource',\
1864 bitmap = ['aiai', wxBITMAP_TYPE_BMP_RESOURCE, 'WINDOWS'],\
1865 bitmap = ['aiai.xpm', wxBITMAP_TYPE_XPM, 'X']).";
1866\end{verbatim}
1867
1868then this function can be called as follows:
1869
1870\begin{verbatim}
1871 wxBitmap *bitmap = wxResourceCreateBitmap("aiai_resource");
1872\end{verbatim}
1873
1874\membersection{::wxResourceCreateIcon}
1875
1876\func{wxIcon *}{wxResourceCreateIcon}{\param{const wxString\& }{resource}}
1877
1878Creates a new icon from a file, static data, or Windows resource, given a valid
1879wxWindows icon resource identifier. For example, if the .WXR file contains
1880the following:
1881
1882\begin{verbatim}
1883static const wxString\& aiai_resource = "icon(name = 'aiai_resource',\
1884 icon = ['aiai', wxBITMAP_TYPE_ICO_RESOURCE, 'WINDOWS'],\
1885 icon = ['aiai', wxBITMAP_TYPE_XBM_DATA, 'X']).";
1886\end{verbatim}
1887
1888then this function can be called as follows:
1889
1890\begin{verbatim}
1891 wxIcon *icon = wxResourceCreateIcon("aiai_resource");
1892\end{verbatim}
1893
1894\membersection{::wxResourceCreateMenuBar}
1895
1896\func{wxMenuBar *}{wxResourceCreateMenuBar}{\param{const wxString\& }{resource}}
1897
1898Creates a new menu bar given a valid wxWindows menubar resource
1899identifier. For example, if the .WXR file contains the following:
1900
1901\begin{verbatim}
1902static const wxString\& menuBar11 = "menu(name = 'menuBar11',\
1903 menu = \
1904 [\
1905 ['&File', 1, '', \
1906 ['&Open File', 2, 'Open a file'],\
1907 ['&Save File', 3, 'Save a file'],\
1908 [],\
1909 ['E&xit', 4, 'Exit program']\
1910 ],\
1911 ['&Help', 5, '', \
1912 ['&About', 6, 'About this program']\
1913 ]\
1914 ]).";
1915\end{verbatim}
1916
1917then this function can be called as follows:
1918
1919\begin{verbatim}
1920 wxMenuBar *menuBar = wxResourceCreateMenuBar("menuBar11");
1921\end{verbatim}
1922
1923
1924\membersection{::wxResourceGetIdentifier}
1925
1926\func{int}{wxResourceGetIdentifier}{\param{const wxString\& }{name}}
1927
1928Used for retrieving the integer value associated with an identifier.
1929A zero value indicates that the identifier was not found.
1930
1931See \helpref{wxResourceAddIdentifier}{wxresourceaddidentifier}.
1932
1933\membersection{::wxResourceParseData}\label{wxresourcedata}
1934
1935\func{bool}{wxResourceParseData}{\param{const wxString\& }{resource}, \param{wxResourceTable *}{table = NULL}}
1936
1937Parses a string containing one or more wxWindows resource objects. If
1938the resource objects are global static data that are included into the
1939C++ program, then this function must be called for each variable
1940containing the resource data, to make it known to wxWindows.
1941
1942{\it resource} should contain data in the following form:
1943
1944\begin{verbatim}
1945dialog(name = 'dialog1',
1946 style = 'wxCAPTION | wxDEFAULT_DIALOG_STYLE',
1947 title = 'Test dialog box',
1948 x = 312, y = 234, width = 400, height = 300,
1949 modal = 0,
1950 control = [wxGroupBox, 'Groupbox', '0', 'group6', 5, 4, 380, 262,
1951 [11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0]],
1952 control = [wxMultiText, 'Multitext', 'wxVERTICAL_LABEL', 'multitext3',
1953 156, 126, 200, 70, 'wxWindows is a multi-platform, GUI toolkit.',
1954 [11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0],
1955 [11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0]]).
1956\end{verbatim}
1957
1958This function will typically be used after including a {\tt .wxr} file into
1959a C++ program as follows:
1960
1961\begin{verbatim}
1962#include "dialog1.wxr"
1963\end{verbatim}
1964
1965Each of the contained resources will declare a new C++ variable, and each
1966of these variables should be passed to wxResourceParseData.
1967
1968\membersection{::wxResourceParseFile}
1969
1970\func{bool}{wxResourceParseFile}{\param{const wxString\& }{filename}, \param{wxResourceTable *}{table = NULL}}
1971
1972Parses a file containing one or more wxWindows resource objects
1973in C++-compatible syntax. Use this function to dynamically load
1974wxWindows resource data.
1975
1976\membersection{::wxResourceParseString}\label{wxresourceparsestring}
1977
1978\func{bool}{wxResourceParseString}{\param{const wxString\& }{resource}, \param{wxResourceTable *}{table = NULL}}
1979
1980Parses a string containing one or more wxWindows resource objects. If
1981the resource objects are global static data that are included into the
1982C++ program, then this function must be called for each variable
1983containing the resource data, to make it known to wxWindows.
1984
1985{\it resource} should contain data with the following form:
1986
1987\begin{verbatim}
1988static const wxString\& dialog1 = "dialog(name = 'dialog1',\
1989 style = 'wxCAPTION | wxDEFAULT_DIALOG_STYLE',\
1990 title = 'Test dialog box',\
1991 x = 312, y = 234, width = 400, height = 300,\
1992 modal = 0,\
1993 control = [wxGroupBox, 'Groupbox', '0', 'group6', 5, 4, 380, 262,\
1994 [11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0]],\
1995 control = [wxMultiText, 'Multitext', 'wxVERTICAL_LABEL', 'multitext3',\
1996 156, 126, 200, 70, 'wxWindows is a multi-platform, GUI toolkit.',\
1997 [11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0],\
1998 [11, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0]]).";
1999\end{verbatim}
2000
2001This function will typically be used after calling \helpref{wxLoadUserResource}{wxloaduserresource} to
2002load an entire {\tt .wxr file} into a string.
2003
2004\membersection{::wxResourceRegisterBitmapData}\label{registerbitmapdata}
2005
2006\func{bool}{wxResourceRegisterBitmapData}{\param{const wxString\& }{name}, \param{const wxString\& }{xbm\_data}, \param{int }{width},
2007\param{int }{height}, \param{wxResourceTable *}{table = NULL}}
2008
2009\func{bool}{wxResourceRegisterBitmapData}{\param{const wxString\& }{name}, \param{const wxString\& *}{xpm\_data}}
2010
2011Makes \verb$#$included XBM or XPM bitmap data known to the wxWindows resource system.
2012This is required if other resources will use the bitmap data, since otherwise there
2013is no connection between names used in resources, and the global bitmap data.
2014
2015\membersection{::wxResourceRegisterIconData}
2016
2017Another name for \helpref{wxResourceRegisterBitmapData}{registerbitmapdata}.
2018
6fb26ea3
JS
2019\section{Log functions}\label{logfunctions}
2020
2021These functions provide a variety of logging functions: see \helpref{Log classes overview}{wxlogoverview} for
2022further information.
2023
954b8ae6
JS
2024\wxheading{Include files}
2025
2026<wx/log.h>
2027
6fb26ea3
JS
2028\membersection{::wxLogError}\label{wxlogerror}
2029
2030\func{void}{wxLogError}{\param{const char*}{ formatString}, \param{...}{}}
2031
2032The function to use for error messages, i.e. the
2033messages that must be shown to the user. The default processing is to pop up a
2034message box to inform the user about it.
2035
2036\membersection{::wxLogFatalError}\label{wxlogfatalerror}
2037
2038\func{void}{wxLogFatalError}{\param{const char*}{ formatString}, \param{...}{}}
2039
2040Like \helpref{wxLogError}{wxlogerror}, but also
2041terminates the program with the exit code 3. Using {\it abort()} standard
2042function also terminates the program with this exit code.
2043
2044\membersection{::wxLogWarning}\label{wxlogwarning}
2045
2046\func{void}{wxLogWarning}{\param{const char*}{ formatString}, \param{...}{}}
2047
2048For warnings - they are also normally shown to the
2049user, but don't interrupt the program work.
2050
2051\membersection{::wxLogMessage}\label{wxlogmessage}
2052
2053\func{void}{wxLogMessage}{\param{const char*}{ formatString}, \param{...}{}}
2054
2055for all normal, informational messages. They also
2056appear in a message box by default (but it can be changed). Notice
2057that the standard behaviour is to not show informational messages if there are
2058any errors later - the logic being that the later error messages make the
2059informational messages preceding them meaningless.
2060
2061\membersection{::wxLogVerbose}\label{wxlogverbose}
2062
2063\func{void}{wxLogVerbose}{\param{const char*}{ formatString}, \param{...}{}}
2064
2065For verbose output. Normally, it's suppressed, but
2066might be activated if the user wishes to know more details about the program
2067progress (another, but possibly confusing name for the same function is {\bf wxLogInfo}).
2068
2069\membersection{::wxLogStatus}\label{wxlogstatus}
2070
2071\func{void}{wxLogStatus}{\param{const char*}{ formatString}, \param{...}{}}
2072
2073For status messages - they will go into the status
2074bar of the active or specified (as the first argument) \helpref{wxFrame}{wxframe} if it has one.
2075
2076\membersection{::wxLogSysError}\label{wxlogsyserror}
2077
2078\func{void}{wxLogSysError}{\param{const char*}{ formatString}, \param{...}{}}
2079
2080Mostly used by wxWindows itself, but might be
2081handy for logging errors after system call (API function) failure. It logs the
2082specified message text as well as the last system error code ({\it errno} or {\it ::GetLastError()} depending
2083on the platform) and the corresponding error
2084message. The second form of this function takes the error code explitly as the
2085first argument.
2086
2087\membersection{::wxLogDebug}\label{wxlogdebug}
2088
2089\func{void}{wxLogDebug}{\param{const char*}{ formatString}, \param{...}{}}
2090
2091The right function for debug output. It only
2092does anything at all in the debug mode (when the preprocessor symbol \_\_WXDEBUG\_\_ is defined)
2093and expands to nothing in release mode (otherwise).
2094
2095\membersection{::wxLogTrace}\label{wxlogtrace}
2096
2097\func{void}{wxLogTrace}{\param{const char*}{ formatString}, \param{...}{}}
2098
2099\func{void}{wxLogTrace}{\param{wxTraceMask}{ mask}, \param{const char*}{ formatString}, \param{...}{}}
2100
2101As {\bf wxLogDebug}, only does something in debug
2102build. The reason for making it a separate function from it is that usually
2103there are a lot of trace messages, so it might make sense to separate them
2104from other debug messages which would be flooded in them. Moreover, the second
2105version of this function takes a trace mask as the first argument which allows
2106to further restrict the amount of messages generated. The value of {\it mask} can be:
2107
2108\begin{itemize}\itemsep=0pt
2109\item wxTraceMemAlloc: trace memory allocation (new/delete)
2110\item wxTraceMessages: trace window messages/X callbacks
2111\item wxTraceResAlloc: trace GDI resource allocation
2112\item wxTraceRefCount: trace various ref counting operations
2113\end{itemize}
2114
2115\section{Debugging macros and functions}\label{debugmacros}
2116
2117Useful macros and functins for error checking and defensive programming. ASSERTs are only
2118compiled if \_\_WXDEBUG\_\_ is defined, whereas CHECK macros stay in release
2119builds.
2120
954b8ae6
JS
2121\wxheading{Include files}
2122
2123<wx/debug.h>
2124
6fb26ea3
JS
2125\membersection{::wxOnAssert}\label{wxonassert}
2126
2127\func{void}{wxOnAssert}{\param{const char*}{ fileName}, \param{int}{ lineNumber}, \param{const char*}{ msg = NULL}}
2128
2129This function may be redefined to do something non trivial and is called
2130whenever one of debugging macros fails (i.e. condition is false in an
5b6aa0ff
JS
2131assertion).
2132% TODO: this should probably be an overridable in wxApp.
6fb26ea3
JS
2133
2134\membersection{wxASSERT}\label{wxassert}
2135
2136\func{}{wxASSERT}{\param{}{condition}}
2137
b207457c
VZ
2138Assert macro. An error message will be generated if the condition is FALSE in
2139debug mode, but nothing will be done in the release build.
2140
2141Please note that the condition in wxASSERT() should have no side effects
2142because it will not be executed in release mode at all.
2143
2144See also: \helpref{wxASSERT\_MSG}{wxassertmsg}
6fb26ea3
JS
2145
2146\membersection{wxASSERT\_MSG}\label{wxassertmsg}
2147
2148\func{}{wxASSERT\_MSG}{\param{}{condition}, \param{}{msg}}
2149
2150Assert macro with message. An error message will be generated if the condition is FALSE.
2151
b207457c
VZ
2152See also: \helpref{wxASSERT}{wxassert}
2153
6fb26ea3
JS
2154\membersection{wxFAIL}\label{wxfail}
2155
b207457c 2156\func{}{wxFAIL}{\void}
6fb26ea3
JS
2157
2158Will always generate an assert error if this code is reached (in debug mode).
2159
b207457c
VZ
2160See also: \helpref{wxFAIL\_MSG}{wxfailmsg}
2161
6fb26ea3
JS
2162\membersection{wxFAIL\_MSG}\label{wxfailmsg}
2163
b207457c 2164\func{}{wxFAIL\_MSG}{\param{}{msg}}
6fb26ea3
JS
2165
2166Will always generate an assert error with specified message if this code is reached (in debug mode).
2167
b207457c
VZ
2168This macro is useful for marking unreachable" code areas, for example
2169it may be used in the "default:" branch of a switch statement if all possible
2170cases are processed above.
2171
2172See also: \helpref{wxFAIL}{wxfail}
2173
6fb26ea3
JS
2174\membersection{wxCHECK}\label{wxcheck}
2175
2176\func{}{wxCHECK}{\param{}{condition}, \param{}{retValue}}
2177
2178Checks that the condition is true, returns with the given return value if not (FAILs in debug mode).
2179This check is done even in release mode.
2180
2181\membersection{wxCHECK\_MSG}\label{wxcheckmsg}
2182
2183\func{}{wxCHECK\_MSG}{\param{}{condition}, \param{}{retValue}, \param{}{msg}}
2184
2185Checks that the condition is true, returns with the given return value if not (FAILs in debug mode).
2186This check is done even in release mode.
2187
b207457c
VZ
2188This macro may be only used in non void functions, see also
2189\helpref{wxCHECK\_RET}{wxcheckret}.
2190
2191\membersection{wxCHECK\_RET}\label{wxcheckret}
2192
2193\func{}{wxCHECK\_RET}{\param{}{condition}, \param{}{msg}}
2194
2195Checks that the condition is true, and returns if not (FAILs with given error
2196message in debug mode). This check is done even in release mode.
2197
2198This macro should be used in void functions instead of
2199\helpref{wxCHECK\_MSG}{wxcheckmsg}.
2200
2201\membersection{wxCHECK2}\label{wxcheck2}
2202
2203\func{}{wxCHECK2}{\param{}{condition}, \param{}{operation}}
2204
2205Checks that the condition is true and \helpref{wxFAIL}{wxfail} and execute
2206{\it operation} if it is not. This is a generalisation of
2207\helpref{wxCHECK}{wxcheck} and may be used when something else than just
2208returning from the function must be done when the {\it condition} is false.
2209
2210This check is done even in release mode.
2211
2212\membersection{wxCHECK2\_MSG}\label{wxcheck2msg}
2213
2214\func{}{wxCHECK2}{\param{}{condition}, \param{}{operation}, \param{}{msg}}
2215
2216This is the same as \helpref{wxCHECK2}{wxcheck2}, but
2217\helpref{wxFAIL\_MSG}{wxfailmsg} with the specified {\it msg} is called
2218instead of wxFAIL() if the {\it condition} is false.
2219