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