FL_PUSH_MENU FL_PULLDOWN_MENU FL_TOUCH_MENU Menu appears when mouse inside it
FL_PUP_NONE Normal FL_PUP_GRAY Entry is grayed out and disabled FL_PUP_BOX Entry has empty box to the left FL_PUP_CHECK Entry has a check box to the left
#include <iostream.h> #include <string.h> #include "forms.h" void menuSelected( FL_OBJECT* theMenu, long NotUsed) { cout << "The user selected " << fl_get_menu( theMenu ) << endl; }; int main( int argc, char *argv[] ) { FL_FORM *form; FL_OBJECT *button, *menu; fl_initialize( argv[0], "FormDemo", 0, 0 , &argc, argv ); form = fl_bgn_form( FL_UP_BOX, 440, 380 ); menu = fl_add_menu( FL_PUSH_MENU, 10, 350, 110, 30, "Which Game" ); fl_set_object_callback( menu , menuSelected, 0 ); button = fl_add_button( FL_NORMAL_BUTTON, 310, 20, 110, 30, "Exit" ); fl_end_form( ); fl_set_menu( menu, "English | Italian | Polish | Turkish " ); fl_set_menu_item_mode( menu, 2, FL_PUP_NONE ); fl_show_form( form, FL_PLACE_CENTER, FL_FULLBORDER, NULL ); fl_do_forms( ); return 0; }
OBJECT *fl_add_free( type, MouseXCoordinate, MouseYCoordinate, width, height, label, (*handle)() );
FL_NORMAL_FREE
FL_INACTIVE_FREE
FL_INPUT_FREE
FL_CONTINUOUS_FREE
FL_ALL_FREE
int handle( *object, event, mouseX, MouseY, int KeyPressed, void* Xevent );
object->x object coordinate and size object->y object->w object->h
object->belowmouse object is below the mouse object->pushed object is being pushed by mouse object->focus object has input focus
fl_rectf filled rectangle fl_rectbound filled rectangle with black border fl_rect outline of rectangle
void fl_rectf( x, y, width, height, color ) void fl_rectbound( x, y, width, height, color ) void fl_rect( x, y, width, height, color ) void fl_roundrectf( x, y, width, height, color ) void fl_roundrect( x, y, width, height, color ) void fl_line( x, y, deltaX, deltaY, color ) /* line attributes */ void fl_linewidth( int ); void fl_linestyle( int ); void fl_ovalf( x, y, width, height, color ) void fl_ovalbound( x, y, width, height, color ) void fl_ovall( x, y, width, height, color ) void fl_circf( x, y, radius, color ) void fl_circ( x, y, radius, color )
#include <iostream.h> #include <string.h> #include "forms.h" int freeObjectHandler( FL_OBJECT* freeObject, int event, FL_Coord mouseX, FL_Coord mouseY, int key, void* xEvent) { switch ( event ) { case FL_MOTION: cout << " Mouse X " << mouseX << " Y " << mouseY << endl; }; return 0; }; int main( int argc, char *argv[] ) { FL_FORM *form; FL_OBJECT *button, *free; fl_initialize( argv[0], "FormDemo", 0, 0 , &argc, argv ); form = fl_bgn_form( FL_UP_BOX, 400, 300 ); free= fl_add_free( FL_NORMAL_FREE, 20, 20, 360, 180, "The Board", freeObjectHandler ); button = fl_add_button( FL_NORMAL_BUTTON, 200, 20, 60, 30, "Exit" ); fl_end_form( ); fl_show_form( form, FL_PLACE_CENTER, FL_FULLBORDER, NULL ); fl_do_forms( ); return 0;}
#include <iostream.h> #include <string.h> #include "forms.h" int freeObjectHandler( FL_OBJECT* freeObject, int event, FL_Coord mouseX, FL_Coord mouseY, int key, void* xEvent) { switch ( event ) { case FL_DRAW: fl_rectf( 100, 150, 30, 30, FL_RED ); }; return 0; }; int main( int argc, char *argv[] ) { FL_FORM *form; FL_OBJECT *button, *free; fl_initialize( argv[0], "FormDemo", 0, 0 , &argc, argv ); form = fl_bgn_form( FL_UP_BOX, 400, 300 ); fl_add_frame(FL_DOWN_FRAME, 20, 20, 360, 180, ""); free= fl_add_free( FL_NORMAL_FREE, 20, 20, 360, 180, "The Board", freeObjectHandler ); fl_set_object_boxtype( free, FL_FLAT_BOX ); button = fl_add_button( FL_NORMAL_BUTTON, 200, 20, 60, 30, "Exit" ); fl_end_form( ); fl_show_form( form, FL_PLACE_CENTER, FL_FULLBORDER, NULL ); fl_do_forms( ); return 0;}
#include <iostream.h> #include <string.h> #include "forms.h"
class LCircle { public: LCircle( int x = 0, int y = 0, int initalRadius = 1, int initialColor = 1 ); void setCenter( int x, int y ); void setY( int y); void setColor( int newColor ); int getY(); void draw( int xOffSet, int yOffSet ); private: int xCoordinate; int yCoordinate; int radius; int color; }; LCircle :: LCircle(int x, int y, int initalRadius , int initialColor ) { xCoordinate = x; yCoordinate = y; radius = initalRadius; color = initialColor; } void LCircle :: setY( int y) { yCoordinate = y; }; void LCircle :: setColor( int newColor ) { color = newColor ; }; int LCircle :: getY( ) { return yCoordinate; }; void LCircle :: setCenter( int x, int y ) { xCoordinate = x; yCoordinate = y; }; void LCircle :: draw( int xOffSet, int yOffSet ) { fl_circf( xCoordinate + xOffSet, yCoordinate + yOffSet , radius, color ); }
LCircle followMouse(20, 20, 20, FL_RED );
int freeObjectHandler( FL_OBJECT* freeObject, int event, FL_Coord mouseX, FL_Coord mouseY, int key, void* xEvent) { switch ( event ) { case FL_DRAW: followMouse.draw( 0, 0 ); break; case FL_PUSH: cout << " Mouse Pressed, Start Drawing " << endl; break; case FL_RELEASE: cout << " Mouse Released, Stop Drawing " << endl; break; case FL_MOUSE: followMouse.setCenter( mouseX, mouseY ); fl_redraw_object( freeObject ); break; }; return 0; };
int main( int argc, char *argv[] ) { FL_FORM *form; FL_OBJECT *button, *free; fl_initialize( argv[0], "FormDemo", 0, 0 , &argc, argv ); form = fl_bgn_form( FL_UP_BOX, 400, 300 ); fl_add_frame(FL_DOWN_FRAME, 20, 20, 360, 180, ""); free= fl_add_free( FL_NORMAL_FREE, 20, 20, 360, 180, "The Board", freeObjectHandler ); fl_set_object_boxtype( free, FL_FLAT_BOX ); button = fl_add_button( FL_NORMAL_BUTTON, 200, 20, 60, 30, "Exit" ); fl_end_form( ); fl_show_form( form, FL_PLACE_CENTER, FL_FULLBORDER, NULL ); fl_do_forms( ); return 0;}
#include <iostream.h> #include <string.h> #include "forms.h"
class LCircle { // Not Shown }; LCircle followMouse(20, 20, 20, FL_RED );
int freeObjectHandler( FL_OBJECT* freeObject, int event, FL_Coord mouseX, FL_Coord mouseY, int key, void* xEvent) { switch ( event ) { case FL_DRAW: followMouse.draw( 0, 0 ); break; case FL_PUSH: followMouse.setCenter( mouseX, mouseY ); fl_redraw_object( freeObject ); break; case FL_STEP: followMouse.setY( followMouse.getY() + 1 ); fl_redraw_object( freeObject ); break; }; return 0; };
int main( int argc, char *argv[] ) { FL_FORM *form; FL_OBJECT *button, *free; fl_initialize( argv[0], "FormDemo", 0, 0 , &argc, argv ); form = fl_bgn_form( FL_UP_BOX, 400, 300 ); fl_add_frame(FL_DOWN_FRAME, 20, 20, 360, 180, ""); free= fl_add_free( FL_CONTINUOUS_FREE, 20, 20, 360, 180, "The Board", freeObjectHandler ); fl_set_object_boxtype( free, FL_FLAT_BOX ); button = fl_add_button( FL_NORMAL_BUTTON, 200, 20, 60, 30, "Exit" ); fl_end_form( ); fl_show_form( form, FL_PLACE_CENTER, FL_FULLBORDER, NULL ); fl_do_forms( ); return 0;}
#ifndef FD_buttonTest_h_ #define FD_buttonTest_h_ /* Header file generated with fdesign. */ /**** Callback routines ****/ extern void buttonPushed( FL_OBJECT *, long ); /**** Forms and Objects ****/ typedef struct { FL_FORM *buttonTest; FL_OBJECT *PushButton; void *vdata; long ldata; } FD_buttonTest; extern FD_buttonTest * create_form_buttonTest( void ); #endif /* FD_buttonTest_h_ */
/* Form definition file generated with fdesign. */ #include "forms.h" #include "button.h" FD_buttonTest *create_form_buttonTest( void ) { FL_OBJECT *obj; FD_buttonTest *fdui = ( FD_buttonTest * ) fl_calloc( 1, sizeof( FD_buttonTest ) ); fdui->buttonTest = fl_bgn_form( FL_NO_BOX, 320, 250 ); obj = fl_add_box( FL_UP_BOX, 0, 0, 320, 250, "" ); fdui->PushButton = obj = fl_add_button( FL_NORMAL_BUTTON, 80, 80, 160, 100, "Push Me" ); fl_set_button_shortcut( obj, "x", 1 ); fl_set_object_callback( obj, buttonPushed, notUsed ); fl_end_form( ); return fdui; } /*---------------------------------------*/
#include "forms.h" #include "button.h" /* callbacks for form buttonTest */ void buttonPushed( FL_OBJECT *ob, long data ) { /* fill-in code for callback */ }
#include "forms.h" #include "button.h" int main( int argc, char *argv[] ) { FD_buttonTest *fd_buttonTest; fl_initialize( argv[0], 0, 0, 0, &argc, argv ); fd_buttonTest = create_form_buttonTest( ); /* fill-in form initialization code */ /* show the first form */ fl_show_form( fd_buttonTest->buttonTest, FL_PLACE_CENTER, FL_FULLBORDER, "buttonTest" ); fl_do_forms( ); return 0; }
Magic: 12322 Internal Form Definition File (do not change) Number of forms: 1 Unit of measure: FL_COORD_PIXEL =============== FORM =============== Name: buttonTest Width: 320 Height: 250 Number of Objects: 2 -------------------- class: FL_BOX type: UP_BOX box: 0 0 320 250 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_DEFAULT_SIZE lcol: FL_BLACK label: shortcut: resize: FL_RESIZE_ALL gravity: ForgetGravity ForgetGravity name: callback: argument: -------------------- class: FL_BUTTON type: NORMAL_BUTTON box: 80 80 160 100 boxtype: FL_UP_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_DEFAULT_SIZE lcol: FL_BLACK label: Push Me shortcut: x resize: FL_RESIZE_ALL gravity: ForgetGravity ForgetGravity name: PushButton callback: buttonPushed argument: notUsed ============================== create_the_forms