You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

611 lines
18KB

  1. /**
  2. \page examples Example Source Code
  3. The FLTK distribution contains over 60 sample applications written
  4. in, or ported to, FLTK. If the FLTK archive you received does not
  5. contain a 'test' directory, you can download the complete FLTK
  6. distribution from \b http://fltk.org/software.php .
  7. Most of the example programs were created while testing a group of widgets.
  8. They are not meant to be great achievements in clean C++ programming, but
  9. merely a test platform to verify the functionality of the FLTK library.
  10. Note that extra example programs are also available in an additional
  11. 'examples' directory, but these are \b NOT built automatically when
  12. you build FLTK, unlike those in the 'test' directory shown below.
  13. \section example_applications Example Applications
  14. <table width=100% border=0>
  15. <tr>
  16. <td> \ref examples_adjuster </td>
  17. <td> \ref examples_arc </td>
  18. <td> \ref examples_ask </td>
  19. <td> \ref examples_bitmap </td>
  20. <td> \ref examples_blocks </td>
  21. <td> \ref examples_boxtype </td>
  22. </tr>
  23. <tr>
  24. <td> \ref examples_browser </td>
  25. <td> \ref examples_button </td>
  26. <td> \ref examples_buttons </td>
  27. <td> \ref examples_checkers </td>
  28. <td> \ref examples_clock </td>
  29. <td> \ref examples_colbrowser </td>
  30. </tr>
  31. <tr>
  32. <td> \ref examples_color_chooser </td>
  33. <td> \ref examples_cube </td>
  34. <td> \ref examples_CubeView </td>
  35. <td> \ref examples_cursor </td>
  36. <td> \ref examples_curve </td>
  37. <td> \ref examples_demo </td>
  38. </tr>
  39. <tr>
  40. <td> \ref examples_doublebuffer </td>
  41. <td> \ref examples_editor </td>
  42. <td> \ref examples_fast_slow </td>
  43. <td> \ref examples_file_chooser </td>
  44. <td> \ref examples_fluid </td>
  45. <td> \ref examples_fonts </td>
  46. </tr>
  47. <tr>
  48. <td> \ref examples_forms </td>
  49. <td> \ref examples_fractals </td>
  50. <td> \ref examples_fullscreen </td>
  51. <td> \ref examples_gl_overlay </td>
  52. <td> \ref examples_glpuzzle </td>
  53. <td> \ref examples_hello </td>
  54. </tr>
  55. <tr>
  56. <td> \ref examples_help </td>
  57. <td> \ref examples_iconize </td>
  58. <td> \ref examples_image </td>
  59. <td> \ref examples_inactive </td>
  60. <td> \ref examples_input </td>
  61. <td> \ref examples_input_choice </td>
  62. </tr>
  63. <tr>
  64. <td> \ref examples_keyboard </td>
  65. <td> \ref examples_label </td>
  66. <td> \ref examples_line_style </td>
  67. <td> \ref examples_list_visuals </td>
  68. <td> \ref examples_mandelbrot </td>
  69. <td> \ref examples_menubar </td>
  70. </tr>
  71. <tr>
  72. <td> \ref examples_message </td>
  73. <td> \ref examples_minimum </td>
  74. <td> \ref examples_navigation </td>
  75. <td> \ref examples_output </td>
  76. <td> \ref examples_overlay </td>
  77. <td> \ref examples_pack </td>
  78. </tr>
  79. <tr>
  80. <td> \ref examples_pixmap_browser </td>
  81. <td> \ref examples_pixmap </td>
  82. <td> \ref examples_preferences </td>
  83. <td> \ref examples_radio </td>
  84. <td> \ref examples_resizebox </td>
  85. <td> \ref examples_resize </td>
  86. </tr>
  87. <tr>
  88. <td> \ref examples_scroll </td>
  89. <td> \ref examples_shape </td>
  90. <td> \ref examples_subwindow </td>
  91. <td> \ref examples_sudoku </td>
  92. <td> \ref examples_symbols </td>
  93. <td> \ref examples_tabs </td>
  94. </tr>
  95. <tr>
  96. <td> \ref examples_threads </td>
  97. <td> \ref examples_tile </td>
  98. <td> \ref examples_tiled_image </td>
  99. <td> \ref examples_valuators </td>
  100. <td> \ref examples_device </td>
  101. <td> &nbsp; </td>
  102. <td> &nbsp; </td>
  103. </tr>
  104. </table>
  105. \subsection examples_adjuster adjuster
  106. \par
  107. \c adjuster shows a nifty little widget for quickly
  108. setting values in a great range.
  109. \subsection examples_arc arc
  110. \par
  111. The \c arc demo explains how to derive your own widget to
  112. generate some custom drawings. The sample drawings use the matrix
  113. based arc drawing for some fun effects.
  114. \subsection examples_ask ask
  115. \par
  116. \c ask shows some of FLTK's standard dialog boxes. Click
  117. the correct answers or you may end up in a loop, or you may end
  118. up in a loop, or you... .
  119. \subsection examples_bitmap bitmap
  120. \par
  121. This simple test shows the use of a single color bitmap as a
  122. label for a box widget. Bitmaps are stored in the X11 '.bmp'
  123. file format and can be part of the source code.
  124. \subsection examples_blocks blocks
  125. \par
  126. A wonderful and addictive game that shows the usage of FLTK
  127. timers, graphics, and how to implement sound on all platforms.
  128. \c blocks is also a good example for the Mac OS X specific
  129. bundle format.
  130. \subsection examples_boxtype boxtype
  131. \par
  132. \c boxtype gives an overview of readily available boxes and
  133. frames in FLTK. More types can be added by the application programmer.
  134. When using themes, FLTK shuffles boxtypes around to give your program
  135. a new look.
  136. \subsection examples_browser browser
  137. \par
  138. \c browser shows the capabilities of the Fl_Browser widget.
  139. Important features tested are loading of files, line formatting, and
  140. correct positioning of the browser data window.
  141. \subsection examples_button button
  142. \par
  143. The \c button test is a simple demo of push-buttons and callbacks.
  144. \subsection examples_buttons buttons
  145. \par
  146. \c buttons shows a sample of FLTK button types.
  147. \subsection examples_checkers checkers
  148. \par
  149. Written by Steve Poulsen in early 1979, \c checkers shows
  150. how to convert a VT100 text-terminal based program into a neat
  151. application with a graphical UI. Check out the code that drags the
  152. pieces, and how the pieces are drawn by layering. Then tell me
  153. how to beat the computer at Checkers.
  154. \subsection examples_clock clock
  155. \par
  156. The \c clock demo shows two analog clocks. The innards of
  157. the Fl_Clock widget are pretty interesting, explaining
  158. the use of timeouts and matrix based drawing.
  159. \subsection examples_colbrowser colbrowser
  160. \par
  161. \c colbrowser runs only on X11 systems. It reads
  162. <i>/usr/lib/X11/rgb.txt</i> to show the color representation
  163. of every text entry in the file. This is beautiful, but
  164. only moderately useful unless your UI is written in <i>Motif</i>.
  165. \subsection examples_color_chooser color_chooser
  166. \par
  167. The \c color_chooser gives a short demo of FLTK's palette based
  168. color chooser and of the RGB based color wheel.
  169. \subsection examples_cube cube
  170. \par
  171. The \c cube demo shows the speed of OpenGL. It also tests
  172. the ability to render two OpenGL buffers into a single window,
  173. and shows OpenGL text.
  174. \subsection examples_CubeView CubeView
  175. \par
  176. \c CubeView shows how to create a UI containing OpenGL with Fluid.
  177. \subsection examples_cursor cursor
  178. \par
  179. The \c cursor demo shows all mouse cursor shapes that come standard
  180. with FLTK. The <i>fgcolor</i> and <i>bgcolor</i> sliders work only
  181. on few systems (some version of Irix for example).
  182. \subsection examples_curve curve
  183. \par
  184. \c curve draws a nice Bezier curve into a custom widget. The
  185. <i>points</i> option for splines is not supported on all platforms.
  186. \subsection examples_demo demo
  187. \par
  188. This tool allows quick access to all programs in the \c test directory.
  189. \c demo is based on the visuals of the IrixGL demo program. The menu
  190. tree can be changed by editing <tt>test/demo.menu</tt>.
  191. \subsection examples_device device
  192. \par
  193. Shows how a wide variety of graphics requests can be printed using the Fl_Printer class.
  194. \subsection examples_doublebuffer doublebuffer
  195. \par
  196. The \c doublebuffer demo shows the difference between a single
  197. buffered window, which may flicker during a slow redraw, and a
  198. double buffered window, which never flickers, but uses twice the
  199. amount of RAM. Some modern OS's double buffer all windows automatically
  200. to allow transparency and shadows on the desktop. FLTK is smart enough
  201. to not tripple buffer a window in that case.
  202. \subsection examples_editor editor
  203. \par
  204. FLTK has two very different text input widgets. Fl_Input
  205. and derived classes are rather light weight, however
  206. Fl_Text_Editor is a complete port of <i>nedit</i> (with permission).
  207. The \c editor test is almost a full application, showing custom
  208. syntax highlighting and dialog creation.
  209. \subsection examples_fast_slow fast_slow
  210. \par
  211. \c fast_slow shows how an application can use the Fl_Widget::when()
  212. setting to receive different kinds of callbacks.
  213. \subsection examples_file_chooser file_chooser
  214. \par
  215. The standard FLTK \c file_chooser is the result of many
  216. iterations, trying to find a middle ground between a complex
  217. browser and a fast light implementation.
  218. \subsection examples_fonts fonts
  219. \par
  220. \c fonts shows all available text fonts on the host system.
  221. If your machine still has some pixmap based fonts, the supported
  222. sizes will be shown in bold face. Only the first 256 fonts will
  223. be listed.
  224. \subsection examples_forms forms
  225. \par
  226. \c forms is an XForms program with very few changes.
  227. Search for "fltk" to find all changes necessary to port to fltk.
  228. This demo shows the different boxtypes. Note that some
  229. boxtypes are not appropriate for some objects.
  230. \subsection examples_fractals fractals
  231. \par
  232. \c fractals shows how to mix OpenGL, Glut and FLTK code.
  233. FLTK supports a rather large subset of Glut, so that many Glut
  234. applications compile just fine.
  235. \subsection examples_fullscreen fullscreen
  236. \par
  237. This demo shows how to do many of the window manipulations that
  238. are popular for games.
  239. You can toggle the border on/off, switch between single-
  240. and double-buffered rendering, and take over the entire
  241. screen. More information in the source code.
  242. \subsection examples_gl_overlay gl_overlay
  243. \par
  244. \c gl_overlay shows OpenGL overlay plane rendering. If no
  245. hardware overlay plane is available, FLTK will simulate it
  246. for you.
  247. \subsection examples_glpuzzle glpuzzle
  248. \par
  249. The \c glpuzzle test shows how most Glut source code compiles
  250. easily under FLTK.
  251. \subsection examples_hello hello
  252. \par
  253. \c hello: Hello, World. Need I say more? Well, maybe. This
  254. tiny demo shows how little is needed to get a functioning application
  255. running with FLTK. Quite impressive, I'd say.
  256. \subsection examples_help help
  257. \par
  258. \c help displays the built-in FLTK help browser. The
  259. Fl_Help_Dialog understands a subset of html and renders
  260. various image formats. This widget makes it easy to provide help
  261. pages to the user without depending on the operating system's
  262. html browser.
  263. \subsection examples_iconize iconize
  264. \par
  265. \c iconize demonstrates the effect of the window functions
  266. hide(), iconize(), and show().
  267. \subsection examples_image image
  268. \par
  269. The \c image demo shows how an image can be created on the fly.
  270. This generated image contains an alpha (transparency) channel which
  271. lets previous renderings 'shine through', either via true
  272. transparency or by using screen door transparency (pixelation).
  273. \subsection examples_inactive inactive
  274. \par
  275. \c inactive tests the correct rendering of inactive widgets.
  276. To see the inactive version of images, you can check out the pixmap
  277. or image test.
  278. \subsection examples_input input
  279. \par
  280. This tool shows and tests different types of text input fields based on
  281. Fl_Input_. The \c input program also tests various
  282. settings of Fl_Input::when().
  283. \subsection examples_input_choice input_choice
  284. \par
  285. \c input_choice tests the latest addition to FLTK1, a text input
  286. field with an attached pulldown menu. Windows users will recognize
  287. similarities to the 'ComboBox'. \c input_choice starts up in
  288. 'plastic' scheme, but the traditional scheme is also supported.
  289. \subsection examples_keyboard keyboard
  290. \par
  291. FLTK unifies keyboard events for all platforms. The \c keyboard
  292. test can be used to check the return values of Fl::event_key()
  293. and Fl::event_text(). It is also great to see the modifier
  294. buttons and the scroll wheel at work. Quit this application by closing
  295. the window. The ESC key will not work.
  296. \subsection examples_label label
  297. \par
  298. Every FLTK widget can have a label attached to it. The \c label
  299. demo shows alignment, clipping, and wrapping of text labels. Labels
  300. can contain symbols at the start and end of the text, like <i>\@FLTK</i>
  301. or <i>\@circle uh-huh \@square</i>.
  302. \subsection examples_line_style line_style
  303. \par
  304. Advanced line drawing can be tested with \c line_style.
  305. Not all platforms support all line styles.
  306. \subsection examples_list_visuals list_visuals
  307. \par
  308. This little app finds all available pixel formats for the current X11
  309. screen. But since you are now an FLTK user, you don't have to worry
  310. about any of this.
  311. \subsection examples_mandelbrot mandelbrot
  312. \par
  313. \c mandelbrot shows two advanced topics in one test. It creates
  314. grayscale images on the fly, updating them via the <i>idle</i> callback
  315. system. This is one of the few occasions where the <i>idle</i> callback
  316. is very useful by giving all available processor time to the application
  317. without blocking the UI or other apps.
  318. \subsection examples_menubar menubar
  319. \par
  320. The \c menubar tests many aspects of FLTK's popup menu system.
  321. Among the features are radio buttons, menus taller than the screen,
  322. arbitrary sub menu depth, and global shortcuts.
  323. \subsection examples_message message
  324. \par
  325. \c message pops up a few of FLTK's standard message boxes.
  326. \subsection examples_minimum minimum
  327. \par
  328. The \c minimum test program verifies that the update regions
  329. are set correctly. In a real life application, the trail would
  330. be avoided by choosing a smaller label or by setting label clipping
  331. differently.
  332. \subsection examples_navigation navigation
  333. \par
  334. \c navigation demonstrates how the text cursor moves from
  335. text field to text field when using the arrow keys, tab, and shift-tab.
  336. \subsection examples_output output
  337. \par
  338. \c output shows the difference between the single line and
  339. multi line mode of the Fl_Output widget. Fonts can be
  340. selected from the FLTK standard list of fonts.
  341. \subsection examples_overlay overlay
  342. \par
  343. The \c overlay test app shows how easy an FLTK window can
  344. be layered to display cursor and manipulator style elements. This
  345. example derives a new class from Fl_Overlay_Window and
  346. provides a new function to draw custom overlays.
  347. \subsection examples_pack pack
  348. \par
  349. The \c pack test program demonstrates the resizing
  350. and repositioning of children of the Fl_Pack group.
  351. Putting an Fl_Pack into an Fl_Scroll is
  352. a useful way to create a browser for large sets of data.
  353. \subsection examples_pixmap_browser pixmap_browser
  354. \par
  355. \c pixmap_browser tests the shared-image interface. When using
  356. the same image multiple times, Fl_Shared_Image will keep it
  357. only once in memory.
  358. \subsection examples_pixmap pixmap
  359. \par
  360. This simple test shows the use of a LUT based pixmap as a
  361. label for a box widget. Pixmaps are stored in the X11 '.xpm'
  362. file format and can be part of the source code. Pixmaps support
  363. one transparent color.
  364. \subsection examples_preferences preferences
  365. \par
  366. I do have my \c preferences in the morning, but sometimes I
  367. just can't remember a thing. This is where the Fl_Preferences
  368. come in handy. They remember any kind of data between program launches.
  369. \subsection examples_radio radio
  370. \par
  371. The \c radio tool was created entirely with <i>fluid</i>. It
  372. shows some of the available button types and tests radio
  373. button behavior.
  374. \subsection examples_resizebox resizebox
  375. \par
  376. \c resizebox shows some possible ways of FLTK's automatic
  377. resize behavior.
  378. \subsection examples_resize resize
  379. \par
  380. The \c resize demo tests size and position functions with
  381. the given window manager.
  382. \subsection examples_scroll scroll
  383. \par
  384. \c scroll shows how to scroll an area of widgets, one of
  385. them being a slow custom drawing. Fl_Scroll uses
  386. clipping and smart window area copying to improve redraw speed.
  387. The buttons at the bottom of the window control decoration rendering
  388. and updates.
  389. \subsection examples_shape shape
  390. \par
  391. \c shape is a very minimal demo that shows how to create
  392. your own OpenGL rendering widget. Now that you know that, go ahead
  393. and write that flight simulator you always dreamt of.
  394. \subsection examples_subwindow subwindow
  395. \par
  396. The \c subwindow demo tests messaging and drawing between
  397. the main window and 'true' sub windows. A sub window is different
  398. to a group by resetting the FLTK coordinate system to 0, 0 in the
  399. top left corner. On Win32 and X11, subwindows have their own
  400. operating system specific handle.
  401. \subsection examples_sudoku sudoku
  402. \par
  403. Another highly addictive game - don't play it, I warned you.
  404. The implementation shows how to create application icons,
  405. how to deal with OS specifics, and how to generate sound.
  406. \subsection examples_symbols symbols
  407. \par
  408. \c symbols are a speciality of FLTK. These little vector
  409. drawings can be integrated into labels. They scale and rotate,
  410. and with a little patience, you can define your own. The rotation
  411. number refers to 45 degree rotations if you were looking at a
  412. numeric keypad (2 is down, 6 is right, etc.).
  413. \subsection examples_tabs tabs
  414. \par
  415. The \c tabs tool was created with <i>fluid</i>. It tests
  416. correct hiding and redisplaying of tabs, navigation across tabs,
  417. resize behavior, and no unneeded redrawing of invisible widgets.
  418. \par
  419. The \c tabs application shows the Fl_Tabs widget
  420. on the left and the Fl_Wizard widget on the right side
  421. for direct comparison of these two panel management widgets.
  422. \subsection examples_threads threads
  423. \par
  424. FLTK can be used in a multithreading environment. There are some
  425. limitations, mostly due to the underlying operating system.
  426. \c threads shows how to use Fl::lock(),
  427. Fl::unlock(), and Fl::awake() in secondary threads
  428. to keep FLTK happy. Although locking works on all platforms,
  429. this demo is not available on every machine.
  430. \subsection examples_tile tile
  431. \par
  432. The \c tile tool shows a nice way of using Fl_Tile.
  433. To test correct resizing of subwindows, the widget for region
  434. 1 is created from an Fl_Window class.
  435. \subsection examples_tiled_image tiled_image
  436. \par
  437. The \c tiled_image demo uses an image as the background
  438. for a window by repeating it over the full size of the widget.
  439. The window is resizable and shows how the image gets repeated.
  440. \subsection examples_valuators valuators
  441. \par
  442. \c valuators shows all of FLTK's nifty widgets to change
  443. numeric values.
  444. \subsection examples_fluid fluid
  445. \par
  446. \c fluid is not only a big test program, but also a very
  447. useful visual UI designer. Many parts of \c fluid were
  448. created using \c fluid. See the \link fluid Fluid Tutorial \endlink
  449. for more details.
  450. \htmlonly
  451. <hr>
  452. <table summary="navigation bar" width="100%" border="0">
  453. <tr>
  454. <td width="45%" align="LEFT">
  455. <a class="el" href="license.html">
  456. [Prev]
  457. Software License
  458. </a>
  459. </td>
  460. <td width="10%" align="CENTER">
  461. <a class="el" href="index.html">[Index]</a>
  462. </td>
  463. <td width="45%" align="RIGHT">
  464. &nbsp;
  465. </a>
  466. </td>
  467. </tr>
  468. </table>
  469. \endhtmlonly
  470. */