From b5f85fd9d681a5cbbbc022bf0b2b23ba7eeeb41b Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Wed, 10 Mar 1999 20:18:38 +0000 Subject: Changed PostScript output to Level 1 for maximum compatibility. Fixed some more typos and formatting problems. git-svn-id: file:///fltk/svn/fltk/trunk@415 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- documentation/fluid.html | 170 ++++++++++++++++++++++++++++------------------- 1 file changed, 100 insertions(+), 70 deletions(-) (limited to 'documentation/fluid.html') diff --git a/documentation/fluid.html b/documentation/fluid.html index e2dfcbd7d..680598c3a 100644 --- a/documentation/fluid.html +++ b/documentation/fluid.html @@ -94,17 +94,16 @@ files found to be compiled:

A Short Tutorial

-FLUID is an amazingly powerful little program. However, -this power comes at a price, it is not always obvious how -to accomplish seemingly simple tasks with it. This -tutorial will show you how to generate a complete user -interface class with FLUID. -

- - - - - -
-The program shown to the right is called CubeView. The window you see -is of class CubeViewUI, and is completely generated by FLUID, including + +FLUID is an amazingly powerful little program. However, this power +comes at a price, as it is not always obvious how to accomplish seemingly +simple tasks with it. This tutorial will show you how to generate a +complete user interface class with FLUID that is used for the CubeView +program below. + +

+ +

The window is of class CubeViewUI, and is completely generated by FLUID, including class member functions. The central display of the cube is a separate subclass of Fl_Gl_Window called CubeView. CubeViewUI manages CubeView using callbacks from the various sliders and rollers to manipulate the @@ -120,10 +119,7 @@ classes. href="Fl_Gl_Window.html#Fl_Gl_Window">Fl_Gl_Window to suit your purposes. -

+

The CubeView Class

The CubeView class is a subclass of Fl_Gl_Window. It has methods for setting the zoom, the x and y pan, and the rotation angle @@ -216,42 +212,85 @@ CubeView::CubeView(int x,int y,int w,int h,const char *l) void CubeView::drawCube() { /* Draw a colored cube */ - glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv0); - v3f(boxv1); v3f(boxv2); v3f(boxv3); glEnd(); - - glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv5); - v3f(boxv4); v3f(boxv7); v3f(boxv6); glEnd(); +#define ALPHA 0.5 + glShadeModel(GL_FLAT); + + glBegin(GL_QUADS); + glColor4f(0.0, 0.0, 1.0, ALPHA); + glVertex3fv(boxv0); + glVertex3fv(boxv1); + glVertex3fv(boxv2); + glVertex3fv(boxv3); + + glColor4f(1.0, 1.0, 0.0, ALPHA); + glVertex3fv(boxv0); + glVertex3fv(boxv4); + glVertex3fv(boxv5); + glVertex3fv(boxv1); + + glColor4f(0.0, 1.0, 1.0, ALPHA); + glVertex3fv(boxv2); + glVertex3fv(boxv6); + glVertex3fv(boxv7); + glVertex3fv(boxv3); + + glColor4f(1.0, 0.0, 0.0, ALPHA); + glVertex3fv(boxv4); + glVertex3fv(boxv5); + glVertex3fv(boxv6); + glVertex3fv(boxv7); + + glColor4f(1.0, 0.0, 1.0, ALPHA); + glVertex3fv(boxv0); + glVertex3fv(boxv3); + glVertex3fv(boxv7); + glVertex3fv(boxv4); + + glColor4f(0.0, 1.0, 0.0, ALPHA); + glVertex3fv(boxv1); + glVertex3fv(boxv5); + glVertex3fv(boxv6); + glVertex3fv(boxv2); + glEnd(); + + glColor3f(1.0, 1.0, 1.0); + glBegin(GL_LINES); + glVertex3fv(boxv0); + glVertex3fv(boxv1); - glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv0); - v3f(boxv4); v3f(boxv5); v3f(boxv1); glEnd(); + glVertex3fv(boxv1); + glVertex3fv(boxv2); - glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv2); - v3f(boxv6); v3f(boxv7); v3f(boxv3); glEnd(); + glVertex3fv(boxv2); + glVertex3fv(boxv3); - glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv0); - v3f(boxv3); v3f(boxv7); v3f(boxv4); glEnd(); + glVertex3fv(boxv3); + glVertex3fv(boxv0); - glBegin(GL_LINE_LOOP); glColor4ub(CUBECOLOR); v3f(boxv1); - v3f(boxv5); v3f(boxv6); v3f(boxv2); glEnd(); + glVertex3fv(boxv4); + glVertex3fv(boxv5); -#define ALPHA 128 - glBegin(GL_QUADS); glColor4ub( 0, 0, 255, ALPHA); v3f(boxv0); - v3f(boxv1); v3f(boxv2); v3f(boxv3); glEnd(); + glVertex3fv(boxv5); + glVertex3fv(boxv6); - glBegin(GL_QUADS); glColor4ub(255, 255, 0, ALPHA); v3f(boxv0); - v3f(boxv4); v3f(boxv5); v3f(boxv1); glEnd(); + glVertex3fv(boxv6); + glVertex3fv(boxv7); - glBegin(GL_QUADS); glColor4ub( 0, 255, 255, ALPHA); v3f(boxv2); - v3f(boxv6); v3f(boxv7); v3f(boxv3); glEnd(); + glVertex3fv(boxv7); + glVertex3fv(boxv4); - glBegin(GL_QUADS); glColor4ub(255, 0, 0, ALPHA); v3f(boxv4); - v3f(boxv5); v3f(boxv6); v3f(boxv7); glEnd(); + glVertex3fv(boxv0); + glVertex3fv(boxv4); - glBegin(GL_QUADS); glColor4ub(255, 0, 255, ALPHA); v3f(boxv0); - v3f(boxv3); v3f(boxv7); v3f(boxv4); glEnd(); + glVertex3fv(boxv1); + glVertex3fv(boxv5); - glBegin(GL_QUADS); glColor4ub( 0, 255, 0, ALPHA); v3f(boxv1); - v3f(boxv5); v3f(boxv6); v3f(boxv2); glEnd(); + glVertex3fv(boxv2); + glVertex3fv(boxv6); + + glVertex3fv(boxv3); + glVertex3fv(boxv7); + glEnd(); };//drawCube void CubeView::draw() { @@ -305,9 +344,7 @@ CubeViewUI.

We will talk about the show() method that is highlighted shortly.

Adding the CubeView Widget

- - - - - -
+ What we have is nice, but does little to show our cube. We have already defined the CubeView class and we would like to show it within the CubeViewUI. @@ -323,10 +360,9 @@ Code:" field enter #include "CubeView.h"

This #include is important, as we have just included CubeView as a member of CubeViewUI, so any public CubeView methods are now available to CubeViewUI. -

+ +

+

Defining the Callbacks

Each of the widgets we defined before adding CubeView can have callbacks that call CubeView methods. You can call an external @@ -345,9 +381,6 @@ more than one view change only redrawing once saves a lot of time. enter these callbacks. FLUID assumes you are smart enough not to refer to members or functions that don't exist.

Adding a Class Method

- - - - - -
You can add class methods within FLUID that have nothing to do with the GUI. An an example add a show function so that CubeViewUI can actually appear on the screen. @@ -356,12 +389,9 @@ appear on the screen. show(). We don't need a return value here, and since we will not be adding any widgets to this method FLUID will assign it a return type of void. +

Once the new method has been added, highlight its name and select New->Code->Code. Enter the method's code in the code window. -

Adding Constructor Initialization Code

If you need to add code to initialize class, for example setting @@ -488,9 +518,13 @@ to reorder functions, classes, and windows within functions.

Edit/Later (F3)

Moves all of the selected widgets one later in order among the children of their parent (if possible). +

+ + + +

Edit/Group (F7)

Creates a new Fl_Group and make all the currently selected widgets -children of it. +children of it.

Edit/Ungroup (F8)

Deletes the parent group if all the children of a group are selected.

Edit/Overlays on/off (Alt+Shift+O)

@@ -499,21 +533,17 @@ selection. This makes it easier to see box borders and how the layout looks. The overlays will be forced back on if you change the selection.

Edit/Preferences (Alt+p)

- - -
Displays the preferences panel. The alignment preferences control the grid that all widgets snap to when you move and resize them, and for the "snap" which is how far a widget has to be dragged from its original position to actually change. - -

The output filenames control the extensions or names of the files the are -generated by FLUID. If you check the "Include .h from .cxx" button the code -file will include the header file automatically.

+The output filenames control the extensions or names of the files the are +generated by FLUID. If you check the "Include .h from .cxx" button the code +file will include the header file automatically.

New/Code/Function

Creates a new C function. You will be asked for a name for the @@ -550,28 +580,28 @@ which is described later in this chapter.

Help/About FLUID

Pops up a panel showing the version of FLUID.

The Widget Panel

- +
-
When you double-click on a widget or a set of widgets you will get the "widget attribute panel".

When you change attributes using this panel, the changes are reflected immediately in the window. It is useful to hit the "no overlay" button (or type Alt+Shift+O) to hide the red overlay so you can see -the widgets more accurately, especially when setting the box type.

+the widgets more accurately, especially when setting the box type.

If you have several widgets selected, they may have different values for the fields. In this case the value for one of the widgets is shown. But if you change this value, all of the selected -widgets are changed to the new value.

+widgets are changed to the new value.

Hitting "OK" makes the changes permanent. Selecting a different widget also makes the changes permanent. FLUID checks for simple syntax errors such as mismatched parenthesis in any code before -saving any text.

-
-"Revert" or "Cancel" put everything back to when you last brought up +saving any text. +

"Revert" or "Cancel" put everything back to when you last brought up the panel or hit OK. However in the current version of FLUID, changes to "visible" attributes (such as the color, label, box) are not undone by revert or cancel. Changes to code like the callbacks are undone, however. +

Widget Attributes

Name (text field)

Name of a variable to declare, and to store a pointer to this -- cgit v1.2.3