]>
git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/utilities.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Utilities page of the Doxygen manual
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @page utilities_page Utilities and samples supplied with wxWidgets
20 @section utils Utilities
22 In addition to the @ref libraries_page, some
23 additional utilities are supplied in the @c utils hierarchy.
25 For other user-contributed packages, please see the Contributions page
26 on the wxWidgets Web site http://www.wxwidgets.org.
28 @li @b Helpview: Helpview is a program for displaying wxWidgets HTML
29 Help files. In many cases, you may wish to use the wxWidgets HTML
30 Help classes from within your application, but this provides a
31 handy stand-alone viewer. See @ref html_overview for more details.
32 You can find it in @c samples/html/helpview.
34 @li @b Tex2RTF; Supplied with wxWidgets is a utility called Tex2RTF for
35 converting @e LaTeX manuals HTML, MS HTML Help, wxHTML Help, RTF, and Windows
36 Help RTF formats. Tex2RTF was used for the wxWidgets manuals and can be used
37 independently by authors wishing to create on-line and printed manuals from the
38 same @e LaTeX source. Please see the separate documentation for Tex2RTF.
39 You can find it under @c utils/tex2rtf.
41 @li @b Helpgen: Helpgen takes C++ header files and generates a Tex2RTF-compatible
42 documentation file for each class it finds, using comments as appropriate.
43 This is a good way to start a reference for a set of classes.
44 Helpgen can be found in @c utils/HelpGen.
46 @li @b Emulator: Xnest-based display emulator for X11-based PDA applications.
47 On some systems, the Xnest window does not synchronise with the
48 'skin' window. This program can be found in @c utils/emulator.
53 @section samples wxWidgets samples
55 Probably the best way to learn wxWidgets is by reading the source of some 50+
56 samples provided with it. Many aspects of wxWidgets programming can be learnt
57 from them, but sometimes it is not simple to just choose the right sample to
58 look at. This overview aims at describing what each sample does/demonstrates to
59 make it easier to find the relevant one if a simple grep through all sources
60 didn't help. They also provide some notes about using the samples and what
61 features of wxWidgets are they supposed to test.
63 There are currently more than 50 different samples as part of wxWidgets and
64 this list is not complete. You should start your tour of wxWidgets with the
65 minimal sample which is the wxWidgets version of
66 "Hello, world!". It shows the basic structure of wxWidgets program and is the
67 most commented sample of all - looking at its source code is recommended.
69 The next most useful samples are probably widgets
70 and controls which show many of wxWidgets native and
71 generic controls, such as buttons, listboxes, checkboxes, comboboxes etc.
73 Other, more complicated controls, have their own samples. In this category you
74 may find the following samples showing the corresponding controls:
76 \begin{twocollist}\itemsep=0pt
77 \twocolitem{wxCalendarCtrl}{samplecalendar}
78 \twocolitem{wxListCtrl}{samplelistctrl}
79 \twocolitem{wxTreeCtrl}{sampletreectrl}
80 \twocolitem{wxGrid}{samplegrid}
83 Finally, it might be helpful to do a search in the entire sample directory if
84 you can't find the sample showing the control you are interested in by
85 name. Most classes contained in wxWidgets occur in at least one of the samples.
88 @subsection sampleminimal Minimal sample
90 The minimal sample is what most people will know under the term Hello World,
91 i.e. a minimal program that doesn't demonstrate anything apart from what is
92 needed to write a program that will display a "hello" dialog. This is usually
93 a good starting point for learning how to use wxWidgets.
96 @subsection sampleanimate Animate sample
98 The @c animate sample shows how you can use wxAnimationCtrl
99 control and shows concept of a platform-dependent animation encapsulated
103 @subsection sampleartprovider Art provider sample
105 The @c artprov sample shows how you can customize the look of standard
106 wxWidgets dialogs by replacing default bitmaps/icons with your own versions.
107 It also shows how you can use wxArtProvider to
108 get stock bitmaps for use in your application.
111 @subsection samplecalendar Calendar sample
113 This font shows the calendar control in action. It
114 shows how to configure the control (see the different options in the calendar
115 menu) and also how to process the notifications from it.
118 @subsection sampleconfig Config sample
120 This sample demonstrates the wxConfig classes in a platform
121 independent way, i.e. it uses text based files to store a given configuration under
122 Unix and uses the Registry under Windows.
124 See wxConfig overview for the descriptions of all
125 features of this class.
128 @subsection samplecontrols Controls sample
130 The controls sample is the main test program for most simple controls used in
131 wxWidgets. The sample tests their basic functionality, events, placement,
132 modification in terms of colour and font as well as the possibility to change
133 the controls programmatically, such as adding an item to a list box etc. Apart
134 from that, the sample uses a wxNotebook and tests most
135 features of this special control (using bitmap in the tabs, using
136 wxSizer instances and wxLayoutConstraints within notebook pages, advancing pages
137 programmatically and vetoing a page change by intercepting the wxNotebookEvent.
139 The various controls tested are listed here:
141 \begin{twocollist}\itemsep=0pt
142 \twocolitem{wxButton}{wxbutton}
143 \twocolitem{wxBitmapButton}{wxbitmapbutton}
144 \twocolitem{wxCheckBox}{wxcheckbox}
145 \twocolitem{wxChoice}{wxchoice}
146 \twocolitem{wxComboBox}{wxcombobox}
147 \twocolitem{wxGauge}{wxgauge}
148 \twocolitem{wxStaticBox}{wxstaticbox}
149 \twocolitem{wxListBox}{wxlistbox}
150 \twocolitem{wxSpinCtrl}{A spin ctrl with a text field and a `up-down' control}
151 \twocolitem{wxSpinButton}{wxspinbutton}
152 \twocolitem{wxStaticText}{wxstatictext}
153 \twocolitem{wxStaticBitmap}{wxstaticbitmap}
154 \twocolitem{wxRadioBox}{wxradiobox}
155 \twocolitem{wxRadioButton}{wxradiobutton}
156 \twocolitem{wxSlider}{wxslider}
160 @subsection sampledebugrpt DebugRpt sample
162 This sample shows how to use wxDebugReport class to
163 generate a debug report in case of a program crash or otherwise. On start up,
164 it proposes to either crash itself (by dereferencing a NULL pointer) or
165 generate debug report without doing it. Next it initializes the debug report
166 with standard information adding a custom file to it (just a timestamp) and
167 allows to view the information gathered using
168 wxDebugReportPreview.
170 For the report processing part of the sample to work you should make available
171 a Web server accepting form uploads, otherwise
172 wxDebugReportUpload will report an error.
175 @subsection sampledialogs Dialogs sample
177 This sample shows how to use the common dialogs available from wxWidgets. These
178 dialogs are described in detail in the Common dialogs overview.
181 @subsection sampledialup Dialup sample
183 This sample shows the wxDialUpManager
184 class. In the status bar, it displays the information gathered through its
185 interface: in particular, the current connection status (online or offline) and
186 whether the connection is permanent (in which case a string `LAN' appears in
187 the third status bar field - but note that you may be on a LAN not
188 connected to the Internet, in which case you will not see this) or not.
190 Using the menu entries, you may also dial or hang up the line if you have a
191 modem attached and (this only makes sense for Windows) list the available
195 @subsection samplednd DnD sample
197 This sample shows both clipboard and drag and drop in action. It is quite non
198 trivial and may be safely used as a basis for implementing the clipboard and
199 drag and drop operations in a real-life program.
201 When you run the sample, its screen is split in several parts. On the top,
202 there are two listboxes which show the standard derivations of
207 The middle of the sample window is taken by the log window which shows what is
208 going on (of course, this only works in debug builds) and may be helpful to see
209 the sequence of steps of data transfer.
211 Finally, the last part is used for dragging text from it to either one of the
212 listboxes (only one will accept it) or another application. The last
213 functionality available from the main frame is to paste a bitmap from the
214 clipboard (or, in the case of the Windows version, also a metafile) - it will be
215 shown in a new frame.
217 So far, everything we mentioned was implemented with minimal amount of code
218 using standard wxWidgets classes. The more advanced features are demonstrated
219 if you create a shape frame from the main frame menu. A shape is a geometric
220 object which has a position, size and color. It models some
221 application-specific data in this sample. A shape object supports its own
222 private wxDataFormat which means that you may cut and
223 paste it or drag and drop (between one and the same or different shapes) from
224 one sample instance to another (or the same). However, chances are that no
225 other program supports this format and so shapes can also be rendered as
226 bitmaps which allows them to be pasted/dropped in many other applications
227 (and, under Windows, also as metafiles which are supported by most of Windows
228 programs as well - try Write/Wordpad, for example).
230 Take a look at DnDShapeDataObject class to see how you may use
231 wxDataObject to achieve this.
234 @subsection sampleevent Event sample
236 The event sample demonstrates various features of the wxWidgets events. It
237 shows using dynamic events and connecting/disconnecting the event handlers
238 during run time and also using
239 PushEventHandler() and
243 @subsection sampleexcept Except(ions) sample
245 This very simple sample shows how to use C++ exceptions in wxWidgets programs,
246 i.e. where to catch the exception which may be thrown by the program code. It
247 doesn't do anything very exciting by itself, you need to study its code to
248 understand what goes on.
250 You need to build the library with @c wxUSE_EXCEPTIONS being set to @c 1
251 and compile your code with C++ exceptions support to be able to build this
255 @subsection sampleexec Exec sample
257 The exec sample demonstrates the wxExecute and
258 wxShell functions. Both of them are used to execute the
259 external programs and the sample shows how to do this synchronously (waiting
260 until the program terminates) or asynchronously (notification will come later).
262 It also shows how to capture the output of the child process in both
263 synchronous and asynchronous cases and how to kill the processes with
264 wxProcess::Kill and test for their existence with
268 @subsection samplefont Font sample
270 The font sample demonstrates wxFont,
272 wxFontMapper classes. It allows you to see the fonts
273 available (to wxWidgets) on the computer and shows all characters of the
277 @subsection samplegrid Grid sample
282 @subsection samplehtml HTML samples
284 Eight HTML samples (you can find them in directory @c samples/html)
285 cover all features of the HTML sub-library.
287 @li @b Test demonstrates how to create wxHtmlWindow
288 and also shows most supported HTML tags.
290 @li @b Widget shows how you can embed ordinary controls or windows within an
291 HTML page. It also nicely explains how to write new tag handlers and extend
292 the library to work with unsupported tags.
294 @li @b About may give you an idea how to write good-looking About boxes.
296 @li @b Zip demonstrates use of virtual file systems in wxHTML. The zip archives
297 handler (ships with wxWidgets) allows you to access HTML pages stored
298 in a compressed archive as if they were ordinary files.
300 @li @b Virtual is yet another virtual file systems demo. This one generates pages at run-time.
301 You may find it useful if you need to display some reports in your application.
303 @li @b Printing explains use of wxHtmlEasyPrinting
304 class which serves as as-simple-as-possible interface for printing HTML
305 documents without much work. In fact, only few function calls are sufficient.
307 @li @b Help and @b Helpview are variations on displaying HTML help
308 (compatible with MS HTML Help Workshop). @e Help shows how to embed
309 wxHtmlHelpController in your application
310 while @e Helpview is a simple tool that only pops up the help window and
311 displays help books given at command line.
314 @subsection sampleimage Image sample
316 The image sample demonstrates use of the wxImage class
317 and shows how to download images in a variety of formats, currently PNG, GIF,
318 TIFF, JPEG, BMP, PNM and PCX. The top of the sample shows two rectangles, one
319 of which is drawn directly in the window, the other one is drawn into a
320 wxBitmap, converted to a wxImage, saved as a PNG image
321 and then reloaded from the PNG file again so that conversions between wxImage
322 and wxBitmap as well as loading and saving PNG files are tested.
324 At the bottom of the main frame there is a test for using a monochrome bitmap by
325 drawing into a wxMemoryDC. The bitmap is then drawn
326 specifying the foreground and background colours with
327 wxDC::SetTextForeground and
328 wxDC::SetTextBackground (on the left). The
329 bitmap is then converted to a wxImage and the foreground colour (black) is
330 replaced with red using wxImage::Replace.
332 This sample also contains the code for testing the image rotation and resizing
333 and using raw bitmap access, see the corresponding menu commands.
336 @subsection sampleinternat Internat(ionalization) sample
338 The not very clearly named internat sample demonstrates the wxWidgets
339 internationalization (i18n for short from now on) features. To be more
340 precise, it only shows localization support, i.e. support for translating the
341 program messages into another language while true i18n would also involve
342 changing the other aspects of the programs behaviour.
344 More information about this sample can be found in the @c readme.txt file in
345 its directory. Please see also i18n overview.
348 @subsection samplelayout Layout sample
350 The layout sample demonstrates the two different layout systems offered
351 by wxWidgets. When starting the program, you will see a frame with some
352 controls and some graphics. The controls will change their size whenever
353 you resize the entire frame and the exact behaviour of the size changes
354 is determined using the wxLayoutConstraints
355 class. See also the overview and the
356 wxIndividualLayoutConstraint
357 class for further information.
359 The menu in this sample offers two more tests, one showing how to use
360 a wxBoxSizer in a simple dialog and the other one
361 showing how to use sizers in connection with a wxNotebook
362 class. See also wxSizer.
365 @subsection samplelistctrl Listctrl sample
367 This sample shows the wxListCtrl control. Different modes
368 supported by the control (list, icons, small icons, report) may be chosen from
371 The sample also provides some timings for adding/deleting/sorting a lot of
372 (several thousands) items into the control.
375 @subsection samplemediaplayer Mediaplayer sample
377 This sample demonstrates how to use all the features of
378 wxMediaCtrl and play various types of sound, video,
381 It replaces the old dynamic sample.
384 @subsection samplenotebook Notebook sample
386 This samples shows wxBookCtrl family of controls.
387 Although initially it was written to demonstrate wxNotebook
388 only, it can now be also used to see wxListbook,
389 wxChoicebook and wxTreebook in action.
390 Test each of the controls, their orientation, images and pages using
391 commands through menu.
394 @subsection samplerender Render sample
396 This sample shows how to replace the default wxWidgets
397 renderer and also how to write a shared library
398 (DLL) implementing a renderer and load and unload it during the run-time.
401 @subsection samplescrollsub Scroll subwindow sample
403 This sample demonstrates use of the wxScrolledWindow
404 class including placing subwindows into it and drawing simple graphics. It uses the
405 SetTargetWindow method and thus the effect
406 of scrolling does not show in the scrolled window itself, but in one of its subwindows.
408 Additionally, this samples demonstrates how to optimize drawing operations in wxWidgets,
409 in particular using the wxWindow::IsExposed method with
410 the aim to prevent unnecessary drawing in the window and thus reducing or removing
414 @subsection samplesockets Sockets sample
416 The sockets sample demonstrates how to use the communication facilities
417 provided by wxSocket. There are two different
418 applications in this sample: a server, which is implemented using a
419 wxSocketServer object, and a client, which
420 is implemented as a wxSocketClient.
422 The server binds to the local address, using TCP port number 3000,
423 sets up an event handler to be notified of incoming connection requests
424 (@b wxSOCKET_CONNECTION events), and sits there, waiting for clients
425 (@e listening, in socket parlance). For each accepted connection,
426 a new wxSocketBase object is created. These
427 socket objects are independent from the server that created them, so
428 they set up their own event handler, and then request to be notified
429 of @b wxSOCKET_INPUT (incoming data) or @b wxSOCKET_LOST
430 (connection closed at the remote end) events. In the sample, the event
431 handler is the same for all connections; to find out which socket the
432 event is addressed to, the GetSocket function
435 Although it might take some time to get used to the event-oriented
436 system upon which wxSocket is built, the benefits are many. See, for
437 example, that the server application, while being single-threaded
438 (and of course without using fork() or ugly select() loops) can handle
439 an arbitrary number of connections.
441 The client starts up unconnected, so you can use the Connect... option
442 to specify the address of the server you are going to connect to (the
443 TCP port number is hard-coded as 3000). Once connected, a number of
444 tests are possible. Currently, three tests are implemented. They show
445 how to use the basic IO calls in wxSocketBase,
446 such as wxSocketBase::Read, wxSocketBase::Write,
447 wxSocketBase::ReadMsg and wxSocketBase::WriteMsg,
448 and how to set up the correct IO flags depending on what you are going to
449 do. See the comments in the code for more information. Note that because
450 both clients and connection objects in the server set up an event handler
451 to catch @b wxSOCKET_LOST events, each one is immediately notified
452 if the other end closes the connection.
454 There is also a URL test which shows how to use
455 the wxURL class to fetch data from a given URL.
457 The sockets sample is work in progress. Some things to do:
459 @li More tests for basic socket functionality.
460 @li More tests for protocol classes (wxProtocol and its descendants).
461 @li Tests for the recently added (and still in alpha stage) datagram sockets.
462 @li New samples which actually do something useful (suggestions accepted).
465 @subsection samplesound Sound sample
467 The @c sound sample shows how to use wxSound for simple
468 audio output (e.g. notifications).
471 @subsection samplestatbar Statbar sample
473 This sample shows how to create and use wxStatusBar. Although most of the
474 samples have a statusbar, they usually only create a default one and only
477 Here you can see how to recreate the statusbar (with possibly different number
478 of fields) and how to use it to show icons/bitmaps and/or put arbitrary
482 @subsection sampletaborder Tab order sample
484 This sample allows to test keyboard navigation (mostly done using the
485 @c TAB key, hence the sample name) between different controls.
486 It shows the use of wxWindow::MoveBeforeInTabOrder() and
487 MoveAfterInTabOrder() methods to change
488 the default order of the windows in the navigation chain and of
489 wxWindow::Navigate() for moving focus along this
493 @subsection sampletext Text sample
495 This sample demonstrates four features: firstly the use and many variants of
496 the wxTextCtrl class (single line, multi line, read only,
497 password, ignoring TAB, ignoring ENTER).
499 Secondly it shows how to intercept a wxKeyEvent in both
500 the raw form using the @c EVT_KEY_UP and @c EVT_KEY_DOWN macros and the
501 higher level from using the @c EVT_CHAR macro. All characters will be logged
502 in a log window at the bottom of the main window. By pressing some of the function
503 keys, you can test some actions in the text ctrl as well as get statistics on the
504 text ctrls, which is useful for testing if these statistics actually are correct.
506 Thirdly, on platforms which support it, the sample will offer to copy text to the
507 wxClipboard and to paste text from it. The GTK version will
508 use the so called PRIMARY SELECTION, which is the pseudo clipboard under X and
509 best known from pasting text to the XTerm program.
511 Last not least: some of the text controls have tooltips and the sample also shows
512 how tooltips can be centrally disabled and their latency controlled.
515 @subsection samplethread Thread sample
517 This sample demonstrates use of threads in connection with GUI programs.
518 There are two fundamentally different ways to use threads in GUI programs and
519 either way has to take care of the fact that the GUI library itself usually
520 is not multi-threading safe, i.e. that it might crash if two threads try to
521 access the GUI class simultaneously. One way to prevent that is have a normal
522 GUI program in the main thread and some worker threads which work in the
523 background. In order to make communication between the main thread and the
524 worker threads possible, wxWidgets offers the wxPostEvent
525 function and this sample makes use of this function.
527 The other way to use a so called Mutex (such as those offered in the wxMutex
528 class) that prevent threads from accessing the GUI classes as long as any other
529 thread accesses them. For this, wxWidgets has the wxMutexGuiEnter
530 and wxMutexGuiLeave functions, both of which are
531 used and tested in the sample as well.
533 See also @ref thread_overview and wxThread.
536 @subsection sampletoolbar Toolbar sample
538 The toolbar sample shows the wxToolBar class in action.
540 The following things are demonstrated:
542 @li Creating the toolbar using wxToolBar::AddTool and wxToolBar::AddControl: see
543 MyApp::InitToolbar in the sample.
544 @li Using @c EVT_UPDATE_UI handler for automatically enabling/disabling
545 toolbar buttons without having to explicitly call EnableTool. This is done
546 in MyFrame::OnUpdateCopyAndCut.
547 @li Using wxToolBar::DeleteTool and wxToolBar::InsertTool to dynamically update the
550 Some buttons in the main toolbar are check buttons, i.e. they stay checked when
551 pressed. On the platforms which support it, the sample also adds a combobox
552 to the toolbar showing how you can use arbitrary controls and not only buttons
555 If you toggle another toolbar in the sample (using @c Ctrl-A) you will also
556 see the radio toolbar buttons in action: the first three buttons form a radio
557 group, i.e. checking any of them automatically unchecks the previously
561 @subsection sampletreectrl Treectrl sample
563 This sample demonstrates using the wxTreeCtrl class. Here
564 you may see how to process various notification messages sent by this control
565 and also when they occur (by looking at the messages in the text control in
566 the bottom part of the frame).
568 Adding, inserting and deleting items and branches from the tree as well as
569 sorting (in default alphabetical order as well as in custom one) is
570 demonstrated here as well - try the corresponding menu entries.
573 @subsection samplewidgets Widgets sample
575 The widgets sample is the main presentation program for most simple and advanced
576 native controls and complex generic widgets provided by wxWidgets.
577 The sample tests their basic functionality, events, placement, modification
578 in terms of colour and font as well as the possibility to change
579 the controls programmatically, such as adding an item to a list box etc.
580 All widgets are categorized for easy browsing.
583 @subsection samplewizard Wizard sample
585 This sample shows the so-called wizard dialog (implemented using
586 wxWizard and related classes). It shows almost all
589 @li Using bitmaps with the wizard and changing them depending on the page
590 shown (notice that wxValidationPage in the sample has a different image from
592 @li Using TransferDataFromWindow
593 to verify that the data entered is correct before passing to the next page
594 (done in wxValidationPage which forces the user to check a checkbox before
596 @li Using more elaborated techniques to allow returning to the previous
597 page, but not continuing to the next one or vice versa (in wxRadioboxPage)
598 @li This (wxRadioboxPage) page also shows how the page may process the
599 @e Cancel button itself instead of relying on the wizard parent to do it.
600 @li Normally, the order of the pages in the wizard is known at compile-time,
601 but sometimes it depends on the user choices: wxCheckboxPage shows how to
602 dynamically decide which page to display next (see also