]>
git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/mainpages/utilities.h
adb8d53c01ba53cac86d72f0232b63651a7975b2
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Utilities page of the Doxygen manual
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @page page_utils Utilities and samples supplied with wxWidgets
13 @li @ref page_utils_utils
14 @li @ref page_utils_samples
20 @section page_utils_utils Utilities
22 In addition to the @ref page_libs, 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.
29 @subsection page_utils_utils_helpview Helpview
31 Helpview is a program for displaying wxWidgets HTML
32 Help files. In many cases, you may wish to use the wxWidgets HTML
33 Help classes from within your application, but this provides a
34 handy stand-alone viewer. See @ref overview_html for more details.
35 You can find it in @c samples/html/helpview.
37 @subsection page_utils_utils_tex2rtf Tex2RTF
39 Supplied with wxWidgets is a utility called Tex2RTF for
40 converting @e LaTeX manuals HTML, MS HTML Help, wxHTML Help, RTF, and Windows
41 Help RTF formats. Tex2RTF was used for the wxWidgets manuals and can be used
42 independently by authors wishing to create on-line and printed manuals from the
43 same @e LaTeX source. Please see the separate documentation for Tex2RTF.
44 You can find it under @c utils/tex2rtf.
46 @subsection page_utils_utils_helpgen Helpgen
48 Helpgen takes C++ header files and generates a Tex2RTF-compatible
49 documentation file for each class it finds, using comments as appropriate.
50 This is a good way to start a reference for a set of classes.
51 Helpgen can be found in @c utils/HelpGen.
53 @subsection page_utils_utils_emulator Emulator
55 Xnest-based display emulator for X11-based PDA applications.
56 On some systems, the Xnest window does not synchronise with the
57 'skin' window. This program can be found in @c utils/emulator.
62 @section page_utils_samples Samples
64 Probably the best way to learn wxWidgets is by reading the source of some 50+
65 samples provided with it. Many aspects of wxWidgets programming can be learnt
66 from them, but sometimes it is not simple to just choose the right sample to
67 look at. This overview aims at describing what each sample does/demonstrates to
68 make it easier to find the relevant one if a simple grep through all sources
69 didn't help. They also provide some notes about using the samples and what
70 features of wxWidgets are they supposed to test.
72 There are currently more than 50 different samples as part of wxWidgets and
73 this list is not complete. You should start your tour of wxWidgets with the
74 minimal sample which is the wxWidgets version of
75 "Hello, world!". It shows the basic structure of wxWidgets program and is the
76 most commented sample of all - looking at its source code is recommended.
78 The next most useful samples are probably widgets
79 and controls which show many of wxWidgets native and
80 generic controls, such as buttons, listboxes, checkboxes, comboboxes etc.
82 Other, more complicated controls, have their own samples. In this category you
83 may find the following samples showing the corresponding controls:
85 @li wxCalendarCtrl: @ref page_utils_samples_calendar
86 @li wxListCtrl: @ref page_utils_samples_listctrl
87 @li wxTreeCtrl: @ref page_utils_samples_treectrl
88 @li wxGrid: @ref page_utils_samples_grid
90 Finally, it might be helpful to do a search in the entire sample directory if
91 you can't find the sample showing the control you are interested in by
92 name. Most classes contained in wxWidgets occur in at least one of the samples.
95 @subsection page_utils_samples_minimal Minimal sample
97 The minimal sample is what most people will know under the term Hello World,
98 i.e. a minimal program that doesn't demonstrate anything apart from what is
99 needed to write a program that will display a "hello" dialog. This is usually
100 a good starting point for learning how to use wxWidgets.
103 @subsection page_utils_samples_animate Animate sample
105 The @c animate sample shows how you can use wxAnimationCtrl
106 control and shows concept of a platform-dependent animation encapsulated
110 @subsection page_utils_samples_artprovider Art provider sample
112 The @c artprov sample shows how you can customize the look of standard
113 wxWidgets dialogs by replacing default bitmaps/icons with your own versions.
114 It also shows how you can use wxArtProvider to
115 get stock bitmaps for use in your application.
118 @subsection page_utils_samples_calendar Calendar sample
120 This font shows the calendar control in action. It
121 shows how to configure the control (see the different options in the calendar
122 menu) and also how to process the notifications from it.
125 @subsection page_utils_samples_config Config sample
127 This sample demonstrates the wxConfig classes in a platform
128 independent way, i.e. it uses text based files to store a given configuration under
129 Unix and uses the Registry under Windows.
131 See @ref overview_config for the descriptions of all features of this class.
134 @subsection page_utils_samples_controls Controls sample
136 The controls sample is the main test program for most simple controls used in
137 wxWidgets. The sample tests their basic functionality, events, placement,
138 modification in terms of colour and font as well as the possibility to change
139 the controls programmatically, such as adding an item to a list box etc. Apart
140 from that, the sample uses a wxNotebook and tests most
141 features of this special control (using bitmap in the tabs, using
142 wxSizer instances and wxLayoutConstraints within notebook pages, advancing pages
143 programmatically and vetoing a page change by intercepting the wxNotebookEvent.
145 The various controls tested are listed here:
164 @subsection page_utils_samples_debugrpt DebugRpt sample
166 This sample shows how to use wxDebugReport class to
167 generate a debug report in case of a program crash or otherwise. On start up,
168 it proposes to either crash itself (by dereferencing a NULL pointer) or
169 generate debug report without doing it. Next it initializes the debug report
170 with standard information adding a custom file to it (just a timestamp) and
171 allows to view the information gathered using
172 wxDebugReportPreview.
174 For the report processing part of the sample to work you should make available
175 a Web server accepting form uploads, otherwise
176 wxDebugReportUpload will report an error.
179 @subsection page_utils_samples_dialogs Dialogs sample
181 This sample shows how to use the common dialogs available from wxWidgets. These
182 dialogs are described in detail in the @ref overview_cmndlg.
185 @subsection page_utils_samples_dialup Dialup sample
187 This sample shows the wxDialUpManager
188 class. In the status bar, it displays the information gathered through its
189 interface: in particular, the current connection status (online or offline) and
190 whether the connection is permanent (in which case a string `LAN' appears in
191 the third status bar field - but note that you may be on a LAN not
192 connected to the Internet, in which case you will not see this) or not.
194 Using the menu entries, you may also dial or hang up the line if you have a
195 modem attached and (this only makes sense for Windows) list the available
199 @subsection page_utils_samples_dnd DnD sample
201 This sample shows both clipboard and drag and drop in action. It is quite non
202 trivial and may be safely used as a basis for implementing the clipboard and
203 drag and drop operations in a real-life program.
205 When you run the sample, its screen is split in several parts. On the top,
206 there are two listboxes which show the standard derivations of
211 The middle of the sample window is taken by the log window which shows what is
212 going on (of course, this only works in debug builds) and may be helpful to see
213 the sequence of steps of data transfer.
215 Finally, the last part is used for dragging text from it to either one of the
216 listboxes (only one will accept it) or another application. The last
217 functionality available from the main frame is to paste a bitmap from the
218 clipboard (or, in the case of the Windows version, also a metafile) - it will be
219 shown in a new frame.
221 So far, everything we mentioned was implemented with minimal amount of code
222 using standard wxWidgets classes. The more advanced features are demonstrated
223 if you create a shape frame from the main frame menu. A shape is a geometric
224 object which has a position, size and color. It models some
225 application-specific data in this sample. A shape object supports its own
226 private wxDataFormat which means that you may cut and
227 paste it or drag and drop (between one and the same or different shapes) from
228 one sample instance to another (or the same). However, chances are that no
229 other program supports this format and so shapes can also be rendered as
230 bitmaps which allows them to be pasted/dropped in many other applications
231 (and, under Windows, also as metafiles which are supported by most of Windows
232 programs as well - try Write/Wordpad, for example).
234 Take a look at DnDShapeDataObject class to see how you may use
235 wxDataObject to achieve this.
238 @subsection page_utils_samples_event Event sample
240 The event sample demonstrates various features of the wxWidgets events. It
241 shows using dynamic events and connecting/disconnecting the event handlers
242 during run time and also using
243 PushEventHandler() and
247 @subsection page_utils_samples_except Except(ions) sample
249 This very simple sample shows how to use C++ exceptions in wxWidgets programs,
250 i.e. where to catch the exception which may be thrown by the program code. It
251 doesn't do anything very exciting by itself, you need to study its code to
252 understand what goes on.
254 You need to build the library with @c wxUSE_EXCEPTIONS being set to @c 1
255 and compile your code with C++ exceptions support to be able to build this
259 @subsection page_utils_samples_exec Exec sample
261 The exec sample demonstrates the wxExecute and
262 wxShell functions. Both of them are used to execute the
263 external programs and the sample shows how to do this synchronously (waiting
264 until the program terminates) or asynchronously (notification will come later).
266 It also shows how to capture the output of the child process in both
267 synchronous and asynchronous cases and how to kill the processes with
268 wxProcess::Kill and test for their existence with
272 @subsection page_utils_samples_font Font sample
274 The font sample demonstrates wxFont,
276 wxFontMapper classes. It allows you to see the fonts
277 available (to wxWidgets) on the computer and shows all characters of the
281 @subsection page_utils_samples_grid Grid sample
286 @subsection page_utils_samples_html HTML samples
288 Eight HTML samples (you can find them in directory @c samples/html)
289 cover all features of the HTML sub-library.
291 @li @b Test demonstrates how to create wxHtmlWindow
292 and also shows most supported HTML tags.
294 @li @b Widget shows how you can embed ordinary controls or windows within an
295 HTML page. It also nicely explains how to write new tag handlers and extend
296 the library to work with unsupported tags.
298 @li @b About may give you an idea how to write good-looking About boxes.
300 @li @b Zip demonstrates use of virtual file systems in wxHTML. The zip archives
301 handler (ships with wxWidgets) allows you to access HTML pages stored
302 in a compressed archive as if they were ordinary files.
304 @li @b Virtual is yet another virtual file systems demo. This one generates pages at run-time.
305 You may find it useful if you need to display some reports in your application.
307 @li @b Printing explains use of wxHtmlEasyPrinting
308 class which serves as as-simple-as-possible interface for printing HTML
309 documents without much work. In fact, only few function calls are sufficient.
311 @li @b Help and @b Helpview are variations on displaying HTML help
312 (compatible with MS HTML Help Workshop). @e Help shows how to embed
313 wxHtmlHelpController in your application
314 while @e Helpview is a simple tool that only pops up the help window and
315 displays help books given at command line.
318 @subsection page_utils_samples_image Image sample
320 The image sample demonstrates use of the wxImage class
321 and shows how to download images in a variety of formats, currently PNG, GIF,
322 TIFF, JPEG, BMP, PNM and PCX. The top of the sample shows two rectangles, one
323 of which is drawn directly in the window, the other one is drawn into a
324 wxBitmap, converted to a wxImage, saved as a PNG image
325 and then reloaded from the PNG file again so that conversions between wxImage
326 and wxBitmap as well as loading and saving PNG files are tested.
328 At the bottom of the main frame there is a test for using a monochrome bitmap by
329 drawing into a wxMemoryDC. The bitmap is then drawn
330 specifying the foreground and background colours with
331 wxDC::SetTextForeground and
332 wxDC::SetTextBackground (on the left). The
333 bitmap is then converted to a wxImage and the foreground colour (black) is
334 replaced with red using wxImage::Replace.
336 This sample also contains the code for testing the image rotation and resizing
337 and using raw bitmap access, see the corresponding menu commands.
340 @subsection page_utils_samples_internat Internat(ionalization) sample
342 The not very clearly named internat sample demonstrates the wxWidgets
343 internationalization (i18n for short from now on) features. To be more
344 precise, it only shows localization support, i.e. support for translating the
345 program messages into another language while true i18n would also involve
346 changing the other aspects of the programs behaviour.
348 More information about this sample can be found in the @c readme.txt file in
349 its directory. Please also see the @ref overview_i18n.
352 @subsection page_utils_samples_layout Layout sample
354 The layout sample demonstrates the two different layout systems offered
355 by wxWidgets. When starting the program, you will see a frame with some
356 controls and some graphics. The controls will change their size whenever
357 you resize the entire frame and the exact behaviour of the size changes
358 is determined using the wxLayoutConstraints
359 class. See also the overview and the
360 wxIndividualLayoutConstraint
361 class for further information.
363 The menu in this sample offers two more tests, one showing how to use
364 a wxBoxSizer in a simple dialog and the other one
365 showing how to use sizers in connection with a wxNotebook
366 class. See also wxSizer.
369 @subsection page_utils_samples_listctrl Listctrl sample
371 This sample shows the wxListCtrl control. Different modes
372 supported by the control (list, icons, small icons, report) may be chosen from
375 The sample also provides some timings for adding/deleting/sorting a lot of
376 (several thousands) items into the control.
379 @subsection page_utils_samples_mediaplayer Mediaplayer sample
381 This sample demonstrates how to use all the features of
382 wxMediaCtrl and play various types of sound, video,
385 It replaces the old dynamic sample.
388 @subsection page_utils_samples_notebook Notebook sample
390 This samples shows wxBookCtrl family of controls.
391 Although initially it was written to demonstrate wxNotebook
392 only, it can now be also used to see wxListbook,
393 wxChoicebook and wxTreebook in action.
394 Test each of the controls, their orientation, images and pages using
395 commands through menu.
398 @subsection page_utils_samples_render Render sample
400 This sample shows how to replace the default wxWidgets
401 renderer and also how to write a shared library
402 (DLL) implementing a renderer and load and unload it during the run-time.
405 @subsection page_utils_samples_scrollsub Scroll subwindow sample
407 This sample demonstrates use of the wxScrolledWindow
408 class including placing subwindows into it and drawing simple graphics. It uses the
409 SetTargetWindow method and thus the effect
410 of scrolling does not show in the scrolled window itself, but in one of its subwindows.
412 Additionally, this samples demonstrates how to optimize drawing operations in wxWidgets,
413 in particular using the wxWindow::IsExposed method with
414 the aim to prevent unnecessary drawing in the window and thus reducing or removing
418 @subsection page_utils_samples_sockets Sockets sample
420 The sockets sample demonstrates how to use the communication facilities
421 provided by wxSocket. There are two different
422 applications in this sample: a server, which is implemented using a
423 wxSocketServer object, and a client, which
424 is implemented as a wxSocketClient.
426 The server binds to the local address, using TCP port number 3000,
427 sets up an event handler to be notified of incoming connection requests
428 (@b wxSOCKET_CONNECTION events), and sits there, waiting for clients
429 (@e listening, in socket parlance). For each accepted connection,
430 a new wxSocketBase object is created. These
431 socket objects are independent from the server that created them, so
432 they set up their own event handler, and then request to be notified
433 of @b wxSOCKET_INPUT (incoming data) or @b wxSOCKET_LOST
434 (connection closed at the remote end) events. In the sample, the event
435 handler is the same for all connections; to find out which socket the
436 event is addressed to, the GetSocket function
439 Although it might take some time to get used to the event-oriented
440 system upon which wxSocket is built, the benefits are many. See, for
441 example, that the server application, while being single-threaded
442 (and of course without using fork() or ugly select() loops) can handle
443 an arbitrary number of connections.
445 The client starts up unconnected, so you can use the Connect... option
446 to specify the address of the server you are going to connect to (the
447 TCP port number is hard-coded as 3000). Once connected, a number of
448 tests are possible. Currently, three tests are implemented. They show
449 how to use the basic IO calls in wxSocketBase,
450 such as wxSocketBase::Read, wxSocketBase::Write,
451 wxSocketBase::ReadMsg and wxSocketBase::WriteMsg,
452 and how to set up the correct IO flags depending on what you are going to
453 do. See the comments in the code for more information. Note that because
454 both clients and connection objects in the server set up an event handler
455 to catch @b wxSOCKET_LOST events, each one is immediately notified
456 if the other end closes the connection.
458 There is also a URL test which shows how to use
459 the wxURL class to fetch data from a given URL.
461 The sockets sample is work in progress. Some things to do:
463 @li More tests for basic socket functionality.
464 @li More tests for protocol classes (wxProtocol and its descendants).
465 @li Tests for the recently added (and still in alpha stage) datagram sockets.
466 @li New samples which actually do something useful (suggestions accepted).
469 @subsection page_utils_samples_sound Sound sample
471 The @c sound sample shows how to use wxSound for simple
472 audio output (e.g. notifications).
475 @subsection page_utils_samples_statbar Statbar sample
477 This sample shows how to create and use wxStatusBar. Although most of the
478 samples have a statusbar, they usually only create a default one and only
481 Here you can see how to recreate the statusbar (with possibly different number
482 of fields) and how to use it to show icons/bitmaps and/or put arbitrary
486 @subsection page_utils_samples_taborder Tab order sample
488 This sample allows to test keyboard navigation (mostly done using the
489 @c TAB key, hence the sample name) between different controls.
490 It shows the use of wxWindow::MoveBeforeInTabOrder() and
491 MoveAfterInTabOrder() methods to change
492 the default order of the windows in the navigation chain and of
493 wxWindow::Navigate() for moving focus along this
497 @subsection page_utils_samples_text Text sample
499 This sample demonstrates four features: firstly the use and many variants of
500 the wxTextCtrl class (single line, multi line, read only,
501 password, ignoring TAB, ignoring ENTER).
503 Secondly it shows how to intercept a wxKeyEvent in both
504 the raw form using the @c EVT_KEY_UP and @c EVT_KEY_DOWN macros and the
505 higher level from using the @c EVT_CHAR macro. All characters will be logged
506 in a log window at the bottom of the main window. By pressing some of the function
507 keys, you can test some actions in the text ctrl as well as get statistics on the
508 text ctrls, which is useful for testing if these statistics actually are correct.
510 Thirdly, on platforms which support it, the sample will offer to copy text to the
511 wxClipboard and to paste text from it. The GTK version will
512 use the so called PRIMARY SELECTION, which is the pseudo clipboard under X and
513 best known from pasting text to the XTerm program.
515 Last not least: some of the text controls have tooltips and the sample also shows
516 how tooltips can be centrally disabled and their latency controlled.
519 @subsection page_utils_samples_thread Thread sample
521 This sample demonstrates use of threads in connection with GUI programs.
522 There are two fundamentally different ways to use threads in GUI programs and
523 either way has to take care of the fact that the GUI library itself usually
524 is not multi-threading safe, i.e. that it might crash if two threads try to
525 access the GUI class simultaneously. One way to prevent that is have a normal
526 GUI program in the main thread and some worker threads which work in the
527 background. In order to make communication between the main thread and the
528 worker threads possible, wxWidgets offers the wxPostEvent
529 function and this sample makes use of this function.
531 The other way to use a so called Mutex (such as those offered in the wxMutex
532 class) that prevent threads from accessing the GUI classes as long as any other
533 thread accesses them. For this, wxWidgets has the wxMutexGuiEnter
534 and wxMutexGuiLeave functions, both of which are
535 used and tested in the sample as well.
537 See also @ref overview_thread and wxThread.
540 @subsection page_utils_samples_toolbar Toolbar sample
542 The toolbar sample shows the wxToolBar class in action.
544 The following things are demonstrated:
546 @li Creating the toolbar using wxToolBar::AddTool and wxToolBar::AddControl: see
547 MyApp::InitToolbar in the sample.
548 @li Using @c EVT_UPDATE_UI handler for automatically enabling/disabling
549 toolbar buttons without having to explicitly call EnableTool. This is done
550 in MyFrame::OnUpdateCopyAndCut.
551 @li Using wxToolBar::DeleteTool and wxToolBar::InsertTool to dynamically update the
554 Some buttons in the main toolbar are check buttons, i.e. they stay checked when
555 pressed. On the platforms which support it, the sample also adds a combobox
556 to the toolbar showing how you can use arbitrary controls and not only buttons
559 If you toggle another toolbar in the sample (using @c Ctrl-A) you will also
560 see the radio toolbar buttons in action: the first three buttons form a radio
561 group, i.e. checking any of them automatically unchecks the previously
565 @subsection page_utils_samples_treectrl Treectrl sample
567 This sample demonstrates using the wxTreeCtrl class. Here
568 you may see how to process various notification messages sent by this control
569 and also when they occur (by looking at the messages in the text control in
570 the bottom part of the frame).
572 Adding, inserting and deleting items and branches from the tree as well as
573 sorting (in default alphabetical order as well as in custom one) is
574 demonstrated here as well - try the corresponding menu entries.
577 @subsection page_utils_samples_widgets Widgets sample
579 The widgets sample is the main presentation program for most simple and advanced
580 native controls and complex generic widgets provided by wxWidgets.
581 The sample tests their basic functionality, events, placement, modification
582 in terms of colour and font as well as the possibility to change
583 the controls programmatically, such as adding an item to a list box etc.
584 All widgets are categorized for easy browsing.
587 @subsection page_utils_samples_wizard Wizard sample
589 This sample shows the so-called wizard dialog (implemented using
590 wxWizard and related classes). It shows almost all
593 @li Using bitmaps with the wizard and changing them depending on the page
594 shown (notice that wxValidationPage in the sample has a different image from
596 @li Using TransferDataFromWindow
597 to verify that the data entered is correct before passing to the next page
598 (done in wxValidationPage which forces the user to check a checkbox before
600 @li Using more elaborated techniques to allow returning to the previous
601 page, but not continuing to the next one or vice versa (in wxRadioboxPage)
602 @li This (wxRadioboxPage) page also shows how the page may process the
603 @e Cancel button itself instead of relying on the wizard parent to do it.
604 @li Normally, the order of the pages in the wizard is known at compile-time,
605 but sometimes it depends on the user choices: wxCheckboxPage shows how to
606 dynamically decide which page to display next (see also