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