Fixed wxScrolledWindow references to properly link (and appropriately changed others...
[wxWidgets.git] / docs / doxygen / mainpages / samples.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: samples.h
3 // Purpose: Samples page of the Doxygen manual
4 // Author: wxWidgets team
5 // RCS-ID: $Id: utilities.h 52634 2008-03-20 13:45:17Z VS $
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10
11 @page page_samples Included Samples
12
13 Probably the best way to learn wxWidgets is by reading the source of some 70+
14 samples provided with it. Many aspects of wxWidgets programming can be learnt
15 from them, but sometimes it is not simple to just choose the right sample to
16 look at. This overview aims at describing what each sample does/demonstrates to
17 make it easier to find the relevant one if a simple grep through all sources
18 didn't help. They also provide some notes about using the samples and what
19 features of wxWidgets are they supposed to test.
20
21 There are currently more than 70 different samples as part of wxWidgets:
22 the list in this page is not complete!
23 You should start your tour of wxWidgets with the @ref page_samples_minimal
24 which is the wxWidgets version of "Hello, world!".
25 It shows the basic structure of wxWidgets program and is the most commented
26 sample of all - looking at its source code is recommended.
27
28 The next most useful samples are probably @ref page_samples_widgets and
29 @ref page_samples_controls which show many of wxWidgets native and
30 generic controls, such as buttons, listboxes, checkboxes, comboboxes etc.
31
32 Other, more complicated controls, have their own samples. In this category you
33 may find the following samples showing the corresponding controls:
34
35 @li wxCalendarCtrl: @ref page_samples_calendar
36 @li wxListCtrl: @ref page_samples_listctrl
37 @li wxTreeCtrl: @ref page_samples_treectrl
38 @li wxGrid: @ref page_samples_grid
39
40 Finally, it might be helpful to do a search in the entire sample directory if
41 you can't find the sample showing the control you are interested in by
42 name. Most classes contained in wxWidgets occur in at least one of the samples.
43
44 @beginInvisibleTable
45 <tr><td>
46 @li @ref page_samples_access
47 @li @ref page_samples_animate
48 @li @ref page_samples_artprovider
49 @li @ref page_samples_aui
50 @li @ref page_samples_calendar
51 @li @ref page_samples_config
52 @li @ref page_samples_controls
53 @li @ref page_samples_debugrpt
54 @li @ref page_samples_dialogs
55 @li @ref page_samples_dialup
56 @li @ref page_samples_dnd
57 @li @ref page_samples_event
58 </td><td>
59 @li @ref page_samples_except
60 @li @ref page_samples_exec
61 @li @ref page_samples_font
62 @li @ref page_samples_grid
63 @li @ref page_samples_html
64 @li @ref page_samples_image
65 @li @ref page_samples_internat
66 @li @ref page_samples_layout
67 @li @ref page_samples_listctrl
68 @li @ref page_samples_mediaplayer
69 @li @ref page_samples_minimal
70 @li @ref page_samples_notebook
71 @li @ref page_samples_render
72 </td><td>
73 @li @ref page_samples_scrollsub
74 @li @ref page_samples_sockets
75 @li @ref page_samples_sound
76 @li @ref page_samples_statbar
77 @li @ref page_samples_taborder
78 @li @ref page_samples_text
79 @li @ref page_samples_thread
80 @li @ref page_samples_toolbar
81 @li @ref page_samples_treectrl
82 @li @ref page_samples_widgets
83 @li @ref page_samples_wizard
84 </td></tr>
85 @endTable
86
87
88 <!--
89
90 TODO: write descriptions for the samples:
91
92 aui
93 caret
94 collpane
95 combo
96 console
97 dataview
98 display
99 docview
100 docvwmdi
101 dragimag
102 drawing
103 editlbox
104 erase
105 event
106 except
107 help
108 htlbox
109 ipc
110 joytest
111 keyboard
112 mdi
113 memcheck
114 menu
115 mfc
116 mobile
117 nativdlg
118 oleauto
119 opengl
120 ownerdrw
121 popup
122 power
123 printing
124 regtest
125 richtext
126 sashtest
127 scroll
128 shaped
129 splash
130 splitter
131 stc
132 svg
133 taskbar
134 typetest
135 validate
136 vscroll
137 xrc
138
139 -->
140
141
142
143
144 <hr>
145
146
147 @section page_samples_access Accessibility sample
148
149 The @c access sample shows how you can use the wxAccessible classes in a
150 simple GUI program.
151
152
153 @section page_samples_animate Animate sample
154
155 The @c animate sample shows how you can use wxAnimationCtrl
156 control and shows concept of a platform-dependent animation encapsulated
157 in wxAnimation.
158
159
160 @section page_samples_artprovider Art provider sample
161
162 The @c artprov sample shows how you can customize the look of standard
163 wxWidgets dialogs by replacing default bitmaps/icons with your own versions.
164 It also shows how you can use wxArtProvider to
165 get stock bitmaps for use in your application.
166
167
168 @section page_samples_calendar Calendar sample
169
170 This font shows the calendar control in action. It
171 shows how to configure the control (see the different options in the calendar
172 menu) and also how to process the notifications from it.
173
174
175 @section page_samples_config Config sample
176
177 This sample demonstrates the wxConfig classes in a platform
178 independent way, i.e. it uses text based files to store a given configuration under
179 Unix and uses the Registry under Windows.
180
181 See @ref overview_config for the descriptions of all features of this class.
182
183
184 @section page_samples_controls Controls sample
185
186 The controls sample is the main test program for most simple controls used in
187 wxWidgets. The sample tests their basic functionality, events, placement,
188 modification in terms of colour and font as well as the possibility to change
189 the controls programmatically, such as adding an item to a list box etc. Apart
190 from that, the sample uses a wxNotebook and tests most
191 features of this special control (using bitmap in the tabs, using
192 wxSizer instances and wxLayoutConstraints within notebook pages, advancing pages
193 programmatically and vetoing a page change by intercepting the wxNotebookEvent.
194
195 The various controls tested are listed here:
196
197 @li wxButton
198 @li wxBitmapButton
199 @li wxCheckBox
200 @li wxChoice
201 @li wxComboBox
202 @li wxGauge
203 @li wxStaticBox
204 @li wxListBox
205 @li wxSpinCtrl
206 @li wxSpinButton
207 @li wxStaticText
208 @li wxStaticBitmap
209 @li wxRadioBox
210 @li wxRadioButton
211 @li wxSlider
212
213
214 @section page_samples_debugrpt DebugRpt sample
215
216 This sample shows how to use wxDebugReport class to
217 generate a debug report in case of a program crash or otherwise. On start up,
218 it proposes to either crash itself (by dereferencing a NULL pointer) or
219 generate debug report without doing it. Next it initializes the debug report
220 with standard information adding a custom file to it (just a timestamp) and
221 allows to view the information gathered using
222 wxDebugReportPreview.
223
224 For the report processing part of the sample to work you should make available
225 a Web server accepting form uploads, otherwise
226 wxDebugReportUpload will report an error.
227
228
229 @section page_samples_dialogs Dialogs sample
230
231 This sample shows how to use the common dialogs available from wxWidgets. These
232 dialogs are described in detail in the @ref overview_cmndlg.
233
234
235 @section page_samples_dialup Dialup sample
236
237 This sample shows the wxDialUpManager
238 class. In the status bar, it displays the information gathered through its
239 interface: in particular, the current connection status (online or offline) and
240 whether the connection is permanent (in which case a string `LAN' appears in
241 the third status bar field - but note that you may be on a LAN not
242 connected to the Internet, in which case you will not see this) or not.
243
244 Using the menu entries, you may also dial or hang up the line if you have a
245 modem attached and (this only makes sense for Windows) list the available
246 connections.
247
248
249 @section page_samples_dnd DnD sample
250
251 This sample shows both clipboard and drag and drop in action. It is quite non
252 trivial and may be safely used as a basis for implementing the clipboard and
253 drag and drop operations in a real-life program.
254
255 When you run the sample, its screen is split in several parts. On the top,
256 there are two listboxes which show the standard derivations of
257 wxDropTarget:
258 wxTextDropTarget and
259 wxFileDropTarget.
260
261 The middle of the sample window is taken by the log window which shows what is
262 going on (of course, this only works in debug builds) and may be helpful to see
263 the sequence of steps of data transfer.
264
265 Finally, the last part is used for dragging text from it to either one of the
266 listboxes (only one will accept it) or another application. The last
267 functionality available from the main frame is to paste a bitmap from the
268 clipboard (or, in the case of the Windows version, also a metafile) - it will be
269 shown in a new frame.
270
271 So far, everything we mentioned was implemented with minimal amount of code
272 using standard wxWidgets classes. The more advanced features are demonstrated
273 if you create a shape frame from the main frame menu. A shape is a geometric
274 object which has a position, size and color. It models some
275 application-specific data in this sample. A shape object supports its own
276 private wxDataFormat which means that you may cut and
277 paste it or drag and drop (between one and the same or different shapes) from
278 one sample instance to another (or the same). However, chances are that no
279 other program supports this format and so shapes can also be rendered as
280 bitmaps which allows them to be pasted/dropped in many other applications
281 (and, under Windows, also as metafiles which are supported by most of Windows
282 programs as well - try Write/Wordpad, for example).
283
284 Take a look at DnDShapeDataObject class to see how you may use
285 wxDataObject to achieve this.
286
287
288 @section page_samples_event Event sample
289
290 The event sample demonstrates various features of the wxWidgets events. It
291 shows using dynamic events and connecting/disconnecting the event handlers
292 during run time and also using
293 PushEventHandler() and
294 PopEventHandler().
295
296
297 @section page_samples_except Except(ions) sample
298
299 This very simple sample shows how to use C++ exceptions in wxWidgets programs,
300 i.e. where to catch the exception which may be thrown by the program code. It
301 doesn't do anything very exciting by itself, you need to study its code to
302 understand what goes on.
303
304 You need to build the library with @c wxUSE_EXCEPTIONS being set to @c 1
305 and compile your code with C++ exceptions support to be able to build this
306 sample.
307
308
309 @section page_samples_exec Exec sample
310
311 The exec sample demonstrates the wxExecute and
312 wxShell functions. Both of them are used to execute the
313 external programs and the sample shows how to do this synchronously (waiting
314 until the program terminates) or asynchronously (notification will come later).
315
316 It also shows how to capture the output of the child process in both
317 synchronous and asynchronous cases and how to kill the processes with
318 wxProcess::Kill and test for their existence with
319 wxProcess::Exists.
320
321
322 @section page_samples_font Font sample
323
324 The font sample demonstrates wxFont,
325 wxFontEnumerator and
326 wxFontMapper classes. It allows you to see the fonts
327 available (to wxWidgets) on the computer and shows all characters of the
328 chosen font as well.
329
330
331 @section page_samples_grid Grid sample
332
333 @todo WRITE THIS DESCRIPTION.
334
335
336 @section page_samples_html HTML samples
337
338 Eight HTML samples (you can find them in directory @c samples/html)
339 cover all features of the HTML sub-library.
340
341 @li @b Test demonstrates how to create wxHtmlWindow
342 and also shows most supported HTML tags.
343
344 @li @b Widget shows how you can embed ordinary controls or windows within an
345 HTML page. It also nicely explains how to write new tag handlers and extend
346 the library to work with unsupported tags.
347
348 @li @b About may give you an idea how to write good-looking About boxes.
349
350 @li @b Zip demonstrates use of virtual file systems in wxHTML. The zip archives
351 handler (ships with wxWidgets) allows you to access HTML pages stored
352 in a compressed archive as if they were ordinary files.
353
354 @li @b Virtual is yet another virtual file systems demo. This one generates pages at run-time.
355 You may find it useful if you need to display some reports in your application.
356
357 @li @b Printing explains use of wxHtmlEasyPrinting
358 class which serves as as-simple-as-possible interface for printing HTML
359 documents without much work. In fact, only few function calls are sufficient.
360
361 @li @b Help and @b Helpview are variations on displaying HTML help
362 (compatible with MS HTML Help Workshop). @e Help shows how to embed
363 wxHtmlHelpController in your application
364 while @e Helpview is a simple tool that only pops up the help window and
365 displays help books given at command line.
366
367
368 @section page_samples_image Image sample
369
370 The image sample demonstrates use of the wxImage class
371 and shows how to download images in a variety of formats, currently PNG, GIF,
372 TIFF, JPEG, BMP, PNM and PCX. The top of the sample shows two rectangles, one
373 of which is drawn directly in the window, the other one is drawn into a
374 wxBitmap, converted to a wxImage, saved as a PNG image
375 and then reloaded from the PNG file again so that conversions between wxImage
376 and wxBitmap as well as loading and saving PNG files are tested.
377
378 At the bottom of the main frame there is a test for using a monochrome bitmap by
379 drawing into a wxMemoryDC. The bitmap is then drawn
380 specifying the foreground and background colours with
381 wxDC::SetTextForeground and
382 wxDC::SetTextBackground (on the left). The
383 bitmap is then converted to a wxImage and the foreground colour (black) is
384 replaced with red using wxImage::Replace.
385
386 This sample also contains the code for testing the image rotation and resizing
387 and using raw bitmap access, see the corresponding menu commands.
388
389
390 @section page_samples_internat Internat(ionalization) sample
391
392 The not very clearly named internat sample demonstrates the wxWidgets
393 internationalization (i18n for short from now on) features. To be more
394 precise, it only shows localization support, i.e. support for translating the
395 program messages into another language while true i18n would also involve
396 changing the other aspects of the programs behaviour.
397
398 More information about this sample can be found in the @c readme.txt file in
399 its directory. Please also see the @ref overview_i18n.
400
401
402 @section page_samples_layout Layout sample
403
404 The layout sample demonstrates the two different layout systems offered
405 by wxWidgets. When starting the program, you will see a frame with some
406 controls and some graphics. The controls will change their size whenever
407 you resize the entire frame and the exact behaviour of the size changes
408 is determined using the wxLayoutConstraints
409 class. See also the overview and the
410 wxIndividualLayoutConstraint
411 class for further information.
412
413 The menu in this sample offers two more tests, one showing how to use
414 a wxBoxSizer in a simple dialog and the other one
415 showing how to use sizers in connection with a wxNotebook
416 class. See also wxSizer.
417
418
419 @section page_samples_listctrl Listctrl sample
420
421 This sample shows the wxListCtrl control. Different modes
422 supported by the control (list, icons, small icons, report) may be chosen from
423 the menu.
424
425 The sample also provides some timings for adding/deleting/sorting a lot of
426 (several thousands) items into the control.
427
428
429 @section page_samples_mediaplayer Mediaplayer sample
430
431 This sample demonstrates how to use all the features of
432 wxMediaCtrl and play various types of sound, video,
433 and other files.
434
435 It replaces the old dynamic sample.
436
437
438 @section page_samples_minimal Minimal sample
439
440 The minimal sample is what most people will know under the term Hello World,
441 i.e. a minimal program that doesn't demonstrate anything apart from what is
442 needed to write a program that will display a "hello" dialog. This is usually
443 a good starting point for learning how to use wxWidgets.
444
445
446 @section page_samples_notebook Notebook sample
447
448 This samples shows wxBookCtrl family of controls.
449 Although initially it was written to demonstrate wxNotebook
450 only, it can now be also used to see wxListbook,
451 wxChoicebook and wxTreebook in action.
452 Test each of the controls, their orientation, images and pages using
453 commands through menu.
454
455
456 @section page_samples_render Render sample
457
458 This sample shows how to replace the default wxWidgets
459 renderer and also how to write a shared library
460 (DLL) implementing a renderer and load and unload it during the run-time.
461
462
463 @section page_samples_scrollsub Scroll subwindow sample
464
465 This sample demonstrates use of the ::wxScrolledWindow
466 class including placing subwindows into it and drawing simple graphics. It uses the
467 SetTargetWindow method and thus the effect
468 of scrolling does not show in the scrolled window itself, but in one of its subwindows.
469
470 Additionally, this samples demonstrates how to optimize drawing operations in wxWidgets,
471 in particular using the wxWindow::IsExposed method with
472 the aim to prevent unnecessary drawing in the window and thus reducing or removing
473 flicker on screen.
474
475
476 @section page_samples_sockets Sockets sample
477
478 The sockets sample demonstrates how to use the communication facilities
479 provided by wxSocket. There are two different
480 applications in this sample: a server, which is implemented using a
481 wxSocketServer object, and a client, which
482 is implemented as a wxSocketClient.
483
484 The server binds to the local address, using TCP port number 3000,
485 sets up an event handler to be notified of incoming connection requests
486 (@b wxSOCKET_CONNECTION events), and sits there, waiting for clients
487 (@e listening, in socket parlance). For each accepted connection,
488 a new wxSocketBase object is created. These
489 socket objects are independent from the server that created them, so
490 they set up their own event handler, and then request to be notified
491 of @b wxSOCKET_INPUT (incoming data) or @b wxSOCKET_LOST
492 (connection closed at the remote end) events. In the sample, the event
493 handler is the same for all connections; to find out which socket the
494 event is addressed to, the GetSocket function
495 is used.
496
497 Although it might take some time to get used to the event-oriented
498 system upon which wxSocket is built, the benefits are many. See, for
499 example, that the server application, while being single-threaded
500 (and of course without using fork() or ugly select() loops) can handle
501 an arbitrary number of connections.
502
503 The client starts up unconnected, so you can use the Connect... option
504 to specify the address of the server you are going to connect to (the
505 TCP port number is hard-coded as 3000). Once connected, a number of
506 tests are possible. Currently, three tests are implemented. They show
507 how to use the basic IO calls in wxSocketBase,
508 such as wxSocketBase::Read, wxSocketBase::Write,
509 wxSocketBase::ReadMsg and wxSocketBase::WriteMsg,
510 and how to set up the correct IO flags depending on what you are going to
511 do. See the comments in the code for more information. Note that because
512 both clients and connection objects in the server set up an event handler
513 to catch @b wxSOCKET_LOST events, each one is immediately notified
514 if the other end closes the connection.
515
516 There is also a URL test which shows how to use
517 the wxURL class to fetch data from a given URL.
518
519 The sockets sample is work in progress. Some things to do:
520
521 @li More tests for basic socket functionality.
522 @li More tests for protocol classes (wxProtocol and its descendants).
523 @li Tests for the recently added (and still in alpha stage) datagram sockets.
524 @li New samples which actually do something useful (suggestions accepted).
525
526
527 @section page_samples_sound Sound sample
528
529 The @c sound sample shows how to use wxSound for simple
530 audio output (e.g. notifications).
531
532
533 @section page_samples_statbar Statbar sample
534
535 This sample shows how to create and use wxStatusBar. Although most of the
536 samples have a statusbar, they usually only create a default one and only
537 do it once.
538
539 Here you can see how to recreate the statusbar (with possibly different number
540 of fields) and how to use it to show icons/bitmaps and/or put arbitrary
541 controls into it.
542
543
544 @section page_samples_taborder Tab order sample
545
546 This sample allows to test keyboard navigation (mostly done using the
547 @c TAB key, hence the sample name) between different controls.
548 It shows the use of wxWindow::MoveBeforeInTabOrder() and
549 MoveAfterInTabOrder() methods to change
550 the default order of the windows in the navigation chain and of
551 wxWindow::Navigate() for moving focus along this
552 chain.
553
554
555 @section page_samples_text Text sample
556
557 This sample demonstrates four features: firstly the use and many variants of
558 the wxTextCtrl class (single line, multi line, read only,
559 password, ignoring TAB, ignoring ENTER).
560
561 Secondly it shows how to intercept a wxKeyEvent in both
562 the raw form using the @c EVT_KEY_UP and @c EVT_KEY_DOWN macros and the
563 higher level from using the @c EVT_CHAR macro. All characters will be logged
564 in a log window at the bottom of the main window. By pressing some of the function
565 keys, you can test some actions in the text ctrl as well as get statistics on the
566 text ctrls, which is useful for testing if these statistics actually are correct.
567
568 Thirdly, on platforms which support it, the sample will offer to copy text to the
569 wxClipboard and to paste text from it. The GTK version will
570 use the so called PRIMARY SELECTION, which is the pseudo clipboard under X and
571 best known from pasting text to the XTerm program.
572
573 Last not least: some of the text controls have tooltips and the sample also shows
574 how tooltips can be centrally disabled and their latency controlled.
575
576
577 @section page_samples_thread Thread sample
578
579 This sample demonstrates use of threads in connection with GUI programs.
580 There are two fundamentally different ways to use threads in GUI programs and
581 either way has to take care of the fact that the GUI library itself usually
582 is not multi-threading safe, i.e. that it might crash if two threads try to
583 access the GUI class simultaneously. One way to prevent that is have a normal
584 GUI program in the main thread and some worker threads which work in the
585 background. In order to make communication between the main thread and the
586 worker threads possible, wxWidgets offers the wxPostEvent
587 function and this sample makes use of this function.
588
589 The other way to use a so called Mutex (such as those offered in the wxMutex
590 class) that prevent threads from accessing the GUI classes as long as any other
591 thread accesses them. For this, wxWidgets has the wxMutexGuiEnter
592 and wxMutexGuiLeave functions, both of which are
593 used and tested in the sample as well.
594
595 See also @ref overview_thread and wxThread.
596
597
598 @section page_samples_toolbar Toolbar sample
599
600 The toolbar sample shows the wxToolBar class in action.
601
602 The following things are demonstrated:
603
604 @li Creating the toolbar using wxToolBar::AddTool and wxToolBar::AddControl: see
605 MyApp::InitToolbar in the sample.
606 @li Using @c EVT_UPDATE_UI handler for automatically enabling/disabling
607 toolbar buttons without having to explicitly call EnableTool. This is done
608 in MyFrame::OnUpdateCopyAndCut.
609 @li Using wxToolBar::DeleteTool and wxToolBar::InsertTool to dynamically update the
610 toolbar.
611
612 Some buttons in the main toolbar are check buttons, i.e. they stay checked when
613 pressed. On the platforms which support it, the sample also adds a combobox
614 to the toolbar showing how you can use arbitrary controls and not only buttons
615 in it.
616
617 If you toggle another toolbar in the sample (using @c Ctrl-A) you will also
618 see the radio toolbar buttons in action: the first three buttons form a radio
619 group, i.e. checking any of them automatically unchecks the previously
620 checked one.
621
622
623 @section page_samples_treectrl Treectrl sample
624
625 This sample demonstrates using the wxTreeCtrl class. Here
626 you may see how to process various notification messages sent by this control
627 and also when they occur (by looking at the messages in the text control in
628 the bottom part of the frame).
629
630 Adding, inserting and deleting items and branches from the tree as well as
631 sorting (in default alphabetical order as well as in custom one) is
632 demonstrated here as well - try the corresponding menu entries.
633
634
635 @section page_samples_widgets Widgets sample
636
637 The widgets sample is the main presentation program for most simple and advanced
638 native controls and complex generic widgets provided by wxWidgets.
639 The sample tests their basic functionality, events, placement, modification
640 in terms of colour and font as well as the possibility to change
641 the controls programmatically, such as adding an item to a list box etc.
642 All widgets are categorized for easy browsing.
643
644
645 @section page_samples_wizard Wizard sample
646
647 This sample shows the so-called wizard dialog (implemented using
648 wxWizard and related classes). It shows almost all
649 features supported:
650
651 @li Using bitmaps with the wizard and changing them depending on the page
652 shown (notice that wxValidationPage in the sample has a different image from
653 the other ones)
654 @li Using TransferDataFromWindow
655 to verify that the data entered is correct before passing to the next page
656 (done in wxValidationPage which forces the user to check a checkbox before
657 continuing).
658 @li Using more elaborated techniques to allow returning to the previous
659 page, but not continuing to the next one or vice versa (in wxRadioboxPage)
660 @li This (wxRadioboxPage) page also shows how the page may process the
661 @e Cancel button itself instead of relying on the wizard parent to do it.
662 @li Normally, the order of the pages in the wizard is known at compile-time,
663 but sometimes it depends on the user choices: wxCheckboxPage shows how to
664 dynamically decide which page to display next (see also
665 wxWizardPage)
666
667 */
668