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