From de6f468b5121df32566bbaa3b250d35eae8e1178 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sun, 14 Sep 2008 21:58:12 +0000 Subject: Edited basic chapters to be more doxygen-friendly, added \image html statements. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6245 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- documentation/basics.dox | 201 ++++++++++++++++++++++------------------------- 1 file changed, 94 insertions(+), 107 deletions(-) (limited to 'documentation/basics.dox') diff --git a/documentation/basics.dox b/documentation/basics.dox index 3c330f907..ed5c3812d 100644 --- a/documentation/basics.dox +++ b/documentation/basics.dox @@ -7,84 +7,82 @@ that use FLTK.

Writing Your First FLTK Program

-

All programs must include the file <FL/Fl.H>. +

All programs must include the file . In addition the program must include a header file for each -FLTK class it uses. Listing 1 shows a simple "Hello, -World!" program that uses FLTK to display the window.

+FLTK class it uses. Listing 1 shows a simple "Hello, +World!" program that uses FLTK to display the window.

- +\endcode

After including the required header files, the program then creates a window. All following widgets will automatically be children of this window.

- +\code +Fl_Window *window = new Fl_Window(300,180); +\endcode -

Then we create a box with the "Hello, World!" string in it. FLTK automatically adds +

Then we create a box with the "Hello, World!" string in it. FLTK automatically adds the new box to window, the current grouping widget.

- +\code +Fl_Box *box = new Fl_Box(20,40,260,100,"Hello, World!"); +\endcode

Next, we set the type of box and the size, font, and style of the label:

- +\code +box->box(FL_UP_BOX); +box->labelsize(36); +box->labelfont(FL_BOLD+FL_ITALIC); +box->labeltype(FL_SHADOW_LABEL); +\endcode

We tell FLTK that we will not add any more widgets to window.

- +\code +window->end(); +\endcode

Finally, we show the window and enter the FLTK event loop:

- +\code +window->show(argc, argv); +return Fl::run(); +\endcode

The resulting program will display the window in Figure 2-1. -You can quit the program by closing the window or pressing the +You can quit the program by closing the window or pressing the ESCape key.

-

Hello, World! Window
-Figure 2-1: The Hello, World! Window

+\image html hello.C.gif "Figure 2-1: The Hello, World! Window"

Creating the Widgets

The widgets are created using the C++ new operator. For most widgets the arguments to the constructor are:

- +\endcode

The x and y parameters determine where the widget or window is placed on the screen. In FLTK the top left @@ -107,8 +105,8 @@ copy of it - it just uses the pointer.

Widgets are commonly ordered into functional groups, which in turn may be grouped again, creating a hierarchy of widgets. FLTK makes it easy to fill groups by automatically adding all widgets -that are created between a myGroup->begin() and -myGroup->end(). In this example, myGroup +that are created between a myGroup->begin() and +myGroup->end(). In this example, myGroup would be the current group.

Newly created groups and their derived widgets implicitly call @@ -122,19 +120,19 @@ hierarchies. New widgets can now be added manually using

Get/Set Methods

-

box->box(FL_UP_BOX) sets the type of box the +

box->box(FL_UP_BOX) sets the type of box the Fl_Box draws, changing it from the default of FL_NO_BOX, which means that no box is drawn. In our -"Hello, World!" example we use FL_UP_BOX, +"Hello, World!" example we use FL_UP_BOX, which means that a raised button border will be drawn around the widget. You can learn more about boxtypes in Chapter 3.

You could examine the boxtype in by doing -box->box(). FLTK uses method name overloading to make +box->box(). FLTK uses method name overloading to make short names for get/set methods. A "set" method is always of -the form "void name(type)", and a "get" method is always -of the form "type name() const".

+the form "void name(type)", and a "get" method is always +of the form "type name() const".

Redrawing After Changing Attributes

@@ -148,6 +146,11 @@ only common exceptions are value() which calls

Labels

+

All widgets support labels. In the case of window widgets, +the label is used for the label in the title bar. Our example +program calls the labelfont(), labelsize, +and labeltype() methods.

+

All widgets support labels. In the case of window widgets, the label is used for the label in the title bar. Our example program calls the @@ -203,17 +206,16 @@ write, or when an error condition occurs on a file. They are most often used to monitor network connections (sockets) for data-driven displays.

-

FLTK applications must periodically check -(Fl::check()) or wait (Fl::wait()) for events -or use the Fl::run() +

FLTK applications must periodically check (Fl::check()) +or wait (Fl::wait()) for events or use the Fl::run() method to enter a standard event processing loop. Calling -Fl::run() is equivalent to the following code:

+Fl::run() is equivalent to the following code:

- +\endcode -

Fl::run() does not return until all of the windows +

Fl::run() does not return until all of the windows under FLTK control are closed by the user or your program.

Compiling Programs with Standard Compilers

@@ -222,71 +224,64 @@ under FLTK control are closed by the user or your program.

tools) you will probably need to tell the compiler where to find the header files. This is usually done using the -I option:

- +\endcode

The fltk-config script included with FLTK can be used to get the options that are required by your compiler:

- +\endcode

Similarly, when linking your application you will need to tell the compiler to use the FLTK library:

- +\endcode

Aside from the "fltk" library, there is also a "fltk_forms" library for the XForms compatibility classes, "fltk_gl" for the OpenGL and GLUT classes, and "fltk_images" for the image file -classes, Fl_Help_Dialog -widget, and system icon support. - -

- - - -
Note: -

The libraries are named "fltk.lib", "fltkgl.lib", "fltkforms.lib", +classes, Fl_Help_Dialog widget, and system icon support. + +\note + The libraries are named "fltk.lib", "fltkgl.lib", "fltkforms.lib", and "fltkimages.lib", respectively under Windows. -

As before, the fltk-config script included with FLTK can be used to get the options that are required by your linker:

- +\endcode

The forms, GL, and images libraries are included with the "--use-foo" options, as follows: -

+\endcode

Finally, you can use the fltk-config script to compile a single source file as a FLTK program: -

+\endcode

Any of these will create an executable named filename. @@ -294,11 +289,10 @@ fltk-config --use-forms --use-gl --use-images --compile filename.cpp

In Visual C++ you will need to tell the compiler where to find the FLTK header files. This can be done by selecting -"Settings" from the "Project" menu and then -changing the "Preprocessor" settings under the -"C/C++" tab. You will also need to add the FLTK and -WinSock (WSOCK32.LIB) libraries to the "Link" -settings.

+"Settings" from the "Project" menu and then changing the +"Preprocessor" settings under the "C/C++" tab. You will also +need to add the FLTK and WinSock2 (WS2_32.LIB) libraries to +the "Link" settings.

You can build your Microsoft Windows applications as Console or WIN32 applications. If you want to use the standard C main() @@ -306,7 +300,7 @@ function as the entry point, FLTK includes a WinMain() function that will call your main() function for you.

Note: The Visual C++ 5.0 optimizer is known to cause problems with -many programs. We only recommend using the "Favor Small Code" +many programs. We only recommend using the "Favor Small Code" optimization setting. The Visual C++ 6.0 optimizer seems to be much better and can be used with the "optimized for speed" setting.

@@ -325,7 +319,7 @@ better and can be used with the "optimized for speed" setting.

  • Constants and enumerations are uppercase: FL_FOO.
  • -
  • All header files start with <FL/...>. +
  • All header files start with .
  • @@ -336,27 +330,20 @@ better and can be used with the "optimized for speed" setting.

    The proper way to include FLTK header files is:

    - - -
    - - - -
    Note: +\code +#include +\endcode -

    Case is significant on many operating systems, +\note + Case is significant on many operating systems, and the C standard uses the forward slash (/) to separate directories. Do not use any of the following - include lines:

    - -
      -	#include <FL\Fl_xyz.H>
      -	#include <fl/fl_xyz.h>
      -	#include <Fl/fl_xyz.h>
      -	
    + include lines: -
    + \code + #include + #include + #include + \endcode */ -- cgit v1.2.3