From b95db33f2cbd30213cadd4859f567e1dae32ef47 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 4 Jan 1999 19:25:40 +0000 Subject: Lots of changes: - Added #defines for Visual C++ to speed up compiles. - Added FLTK.DLL project to visualc directory. - Added editor project to visualc directory. - Added icon() method to Fl_Window class. - Implemented xclass() method for WIN32. - Fixed extern declaration of fl_send_extra_move in Fl_Menu_Window.cxx. - scandir_win32.c needed to include . - Added fix from Bill for fl_width() bug. - Updated fix for Fl_Input to default to FL_DOWN_BOX. - Added visible() check for children of Fl_Pack. - Added WinMain() function to library. - Now show console window in debug mode. - Fixed demo.menu and demo.cxx to work under WIN32. git-svn-id: file:///fltk/svn/fltk/trunk@180 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- test/demo.cxx | 568 +++++++++++++++++++++++++++++--------------------------- test/demo.menu | 105 +++++------ test/demod.menu | 80 ++++++++ 3 files changed, 425 insertions(+), 328 deletions(-) create mode 100644 test/demod.menu (limited to 'test') diff --git a/test/demo.cxx b/test/demo.cxx index ca337c921..d8263420e 100644 --- a/test/demo.cxx +++ b/test/demo.cxx @@ -1,276 +1,292 @@ -// -// "$Id: demo.cxx,v 1.4 1998/12/02 15:52:41 mike Exp $" -// -// Main demo program for the Fast Light Tool Kit (FLTK). -// -// Copyright 1998 by Bill Spitzak and others. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// -// Please report all bugs and problems to "fltk-bugs@easysw.com". -// - -#include -#include -#include -#if defined(WIN32) && !defined(CYGNUS) -# include -//# define chdir _chdir -#else -# include -#endif -#include -#include -#include -#include -#include - -/* The form description */ - -void doexit(Fl_Widget *, void *); -void doback(Fl_Widget *, void *); -void dobut(Fl_Widget *, long); - -Fl_Window *form; -Fl_Button *but[9]; - -void create_the_forms() { - Fl_Widget *obj; - form = new Fl_Window(370, 450); - obj = new Fl_Box(FL_FRAME_BOX,20,390,330,40,"Fltk Demonstration"); - obj->color(FL_GRAY-4); - obj->labelsize(24); - obj->labelfont(FL_BOLD); - obj->labeltype(FL_ENGRAVED_LABEL); - obj = new Fl_Box(FL_FRAME_BOX,20,50,330,330,0); - obj->color(FL_GRAY-8); - obj = new Fl_Button(130,10,110,30,"Exit"); - obj->callback(doexit); - obj = new Fl_Button(20,50,330,380); obj->type(FL_HIDDEN_BUTTON); - obj->callback(doback); - obj = but[0] = new Fl_Button(40,270,90,90); - obj = but[1] = new Fl_Button(140,270,90,90); - obj = but[2] = new Fl_Button(240,270,90,90); - obj = but[5] = new Fl_Button(240,170,90,90); - obj = but[4] = new Fl_Button(140,170,90,90); - obj = but[3] = new Fl_Button(40,170,90,90); - obj = but[6] = new Fl_Button(40,70,90,90); - obj = but[7] = new Fl_Button(140,70,90,90); - obj = but[8] = new Fl_Button(240,70,90,90); - for (int i=0; i<9; i++) { - but[i]->align(FL_ALIGN_WRAP); - but[i]->callback(dobut, i); - } - form->forms_end(); -} - -/* Maintaining and building up the menus. */ - -typedef struct { - char name[64]; - int numb; - char iname[9][64]; - char icommand[9][64]; -} MENU; - -#define MAXMENU 32 - -MENU menus[MAXMENU]; -int mennumb = 0; - -int find_menu(char nnn[]) -/* Returns the number of a given menu name. */ -{ - int i; - for (i=0; ihide(); - for (i=0; ishow(); - but[bn]->label(menus[men].iname[i]); -// if (menus[men].icommand[i][0] == '@') -// but[bn]->color(FL_GRAY-8); -// else -// but[bn]->color(FL_GRAY); - } - strcpy(stack[stsize],nnn); - stsize++; -} - -void pop_menu() -/* Pops a menu */ -{ - if (stsize<=1) return; - stsize -= 2; - push_menu(stack[stsize]); -} - -/* The callback Routines */ - -void dobut(Fl_Widget *, long arg) -/* handles a button push */ -{ - int men = find_menu(stack[stsize-1]); - int n = menus[men].numb; - int bn = but2numb( (int) arg, n-1); - if (menus[men].icommand[bn][0] == '@') - push_menu(menus[men].icommand[bn]); - else - system(menus[men].icommand[bn]); -} - -void doback(Fl_Widget *, void *) {pop_menu();} - -void doexit(Fl_Widget *, void *) {exit(0);} - -int load_the_menu(const char fname[]) -/* Loads the menu file. Returns whether successful. */ -{ - FILE *fin; - char line[256], mname[64],iname[64],cname[64]; - int i,j; - fin = fopen(fname,"r"); - if (fin == NULL) - { -// fl_show_message("ERROR","","Cannot read the menu description file."); - return 0; - } - for (;;) { - if (fgets(line,256,fin) == NULL) break; - j = 0; i = 0; - while (line[i] == ' ' || line[i] == '\t') i++; - if (line[i] == '\n') continue; - if (line[i] == '#') continue; - while (line[i] != ':' && line[i] != '\n') mname[j++] = line[i++]; - mname[j] = '\0'; - if (line[i] == ':') i++; - j = 0; - while (line[i] != ':' && line[i] != '\n') - { - if (line[i] == '\\') { - i++; - if (line[i] == 'n') iname[j++] = '\n'; - else iname[j++] = line[i]; - i++; - } else - iname[j++] = line[i++]; - } - iname[j] = '\0'; - if (line[i] == ':') i++; - j = 0; - while (line[i] != ':' && line[i] != '\n') cname[j++] = line[i++]; - cname[j] = '\0'; - addto_menu(mname,iname,cname); - } - fclose(fin); - return 1; -} - -int main(int argc, char **argv) { - create_the_forms(); - char buf[256]; - strcpy(buf, argv[0]); - filename_setext(buf,".menu"); - const char *fname = buf; - int i = 0; - if (!Fl::args(argc,argv,i) || i < argc-1) - Fl::fatal("Usage: %s \n%s",Fl::help); - if (i < argc) fname = argv[i]; - if (!load_the_menu(fname)) Fl::fatal("Can't open %s",fname); - strcpy(buf,fname); - const char *c = filename_name(buf); - if (c > buf) {buf[c-buf] = 0; chdir(buf);} - push_menu("@main"); - form->show(argc,argv); - Fl::run(); - return 0; -} - -// -// End of "$Id: demo.cxx,v 1.4 1998/12/02 15:52:41 mike Exp $". -// +// +// "$Id: demo.cxx,v 1.5 1999/01/04 19:25:06 mike Exp $" +// +// Main demo program for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998 by Bill Spitzak and others. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@easysw.com". +// + +#include +#include +#include +#if defined(WIN32) && !defined(CYGNUS) +# include +#else +# include +#endif +#include +#include +#include +#include +#include +#include + +/* The form description */ + +void doexit(Fl_Widget *, void *); +void doback(Fl_Widget *, void *); +void dobut(Fl_Widget *, long); + +Fl_Window *form; +Fl_Button *but[9]; + +void create_the_forms() { + Fl_Widget *obj; + form = new Fl_Window(370, 450); + obj = new Fl_Box(FL_FRAME_BOX,20,390,330,40,"FLTK Demonstration"); + obj->color(FL_GRAY-4); + obj->labelsize(24); + obj->labelfont(FL_BOLD); + obj->labeltype(FL_ENGRAVED_LABEL); + obj = new Fl_Box(FL_FRAME_BOX,20,50,330,330,0); + obj->color(FL_GRAY-8); + obj = new Fl_Button(130,10,110,30,"Exit"); + obj->callback(doexit); + obj = new Fl_Button(20,50,330,380); obj->type(FL_HIDDEN_BUTTON); + obj->callback(doback); + obj = but[0] = new Fl_Button(40,270,90,90); + obj = but[1] = new Fl_Button(140,270,90,90); + obj = but[2] = new Fl_Button(240,270,90,90); + obj = but[5] = new Fl_Button(240,170,90,90); + obj = but[4] = new Fl_Button(140,170,90,90); + obj = but[3] = new Fl_Button(40,170,90,90); + obj = but[6] = new Fl_Button(40,70,90,90); + obj = but[7] = new Fl_Button(140,70,90,90); + obj = but[8] = new Fl_Button(240,70,90,90); + for (int i=0; i<9; i++) { + but[i]->align(FL_ALIGN_WRAP); + but[i]->callback(dobut, i); + } + form->forms_end(); +} + +/* Maintaining and building up the menus. */ + +typedef struct { + char name[64]; + int numb; + char iname[9][64]; + char icommand[9][64]; +} MENU; + +#define MAXMENU 32 + +MENU menus[MAXMENU]; +int mennumb = 0; + +int find_menu(char nnn[]) +/* Returns the number of a given menu name. */ +{ + int i; + for (i=0; ihide(); + for (i=0; ishow(); + but[bn]->label(menus[men].iname[i]); + } + strcpy(stack[stsize],nnn); + stsize++; +} + +void pop_menu() +/* Pops a menu */ +{ + if (stsize<=1) return; + stsize -= 2; + push_menu(stack[stsize]); +} + +/* The callback Routines */ + +void dobut(Fl_Widget *, long arg) +/* handles a button push */ +{ + char command[255]; + int men = find_menu(stack[stsize-1]); + int n = menus[men].numb; + int bn = but2numb( (int) arg, n-1); + if (menus[men].icommand[bn][0] == '@') + push_menu(menus[men].icommand[bn]); + else { +#ifdef WIN32 + STARTUPINFO suInfo; // Process startup information + PROCESS_INFORMATION prInfo; // Process information + + memset(&suInfo, 0, sizeof(suInfo)); + suInfo.cb = sizeof(suInfo); + +# ifdef _DEBUG + sprintf(command, "%sd.exe", menus[men].icommand[bn]); +# else + sprintf(command, "%s.exe", menus[men].icommand[bn]); +# endif // _DEBUG + + CreateProcess(NULL, command, NULL, NULL, FALSE, + NORMAL_PRIORITY_CLASS, NULL, NULL, &suInfo, &prInfo); +#else + sprintf(command, "./%s &", menus[men].icommand[bn]); + system(command); +#endif // WIN32 + } +} + +void doback(Fl_Widget *, void *) {pop_menu();} + +void doexit(Fl_Widget *, void *) {exit(0);} + +int load_the_menu(const char fname[]) +/* Loads the menu file. Returns whether successful. */ +{ + FILE *fin; + char line[256], mname[64],iname[64],cname[64]; + int i,j; + fin = fopen(fname,"r"); + if (fin == NULL) + { +// fl_show_message("ERROR","","Cannot read the menu description file."); + return 0; + } + for (;;) { + if (fgets(line,256,fin) == NULL) break; + j = 0; i = 0; + while (line[i] == ' ' || line[i] == '\t') i++; + if (line[i] == '\n') continue; + if (line[i] == '#') continue; + while (line[i] != ':' && line[i] != '\n') mname[j++] = line[i++]; + mname[j] = '\0'; + if (line[i] == ':') i++; + j = 0; + while (line[i] != ':' && line[i] != '\n') + { + if (line[i] == '\\') { + i++; + if (line[i] == 'n') iname[j++] = '\n'; + else iname[j++] = line[i]; + i++; + } else + iname[j++] = line[i++]; + } + iname[j] = '\0'; + if (line[i] == ':') i++; + j = 0; + while (line[i] != ':' && line[i] != '\n') cname[j++] = line[i++]; + cname[j] = '\0'; + addto_menu(mname,iname,cname); + } + fclose(fin); + return 1; +} + +int main(int argc, char **argv) { + create_the_forms(); + char buf[256]; + strcpy(buf, argv[0]); + filename_setext(buf,".menu"); + const char *fname = buf; + int i = 0; + if (!Fl::args(argc,argv,i) || i < argc-1) + Fl::fatal("Usage: %s \n%s",Fl::help); + if (i < argc) fname = argv[i]; + if (!load_the_menu(fname)) Fl::fatal("Can't open %s",fname); + strcpy(buf,fname); + const char *c = filename_name(buf); + if (c > buf) {buf[c-buf] = 0; chdir(buf);} + push_menu("@main"); + form->show(argc,argv); + Fl::run(); + return 0; +} + +// +// End of "$Id: demo.cxx,v 1.5 1999/01/04 19:25:06 mike Exp $". +// diff --git a/test/demo.menu b/test/demo.menu index 8e01a97ae..8347c22d5 100644 --- a/test/demo.menu +++ b/test/demo.menu @@ -10,70 +10,71 @@ # @main:Widget\nTests:@x - @x:Fl_Browser:./browser& - @x:Fl_Input:./input& - @x:Fl_Output:./output& - @x:Fl_Button:./radio& - @x:Fl_Tabs:./tabs& - @x:Fl_Tile:./tile& - @x:Fl_Scroll:./scroll& - @x:Fl_Pack:./pack& - @x:Fl_Menu:./menubar& + @x:Fl_Browser:browser + @x:Fl_Input:input + @x:Fl_Output:output + @x:Fl_Button:radio + @x:Fl_Tabs:tabs + @x:Fl_Tile:tile + @x:Fl_Scroll:scroll + @x:Fl_Pack:pack + @x:Fl_Menu:menubar @main:Window\nTests:@w - @w:overlay:./overlay& - @w:subwindow:./subwindow& - @w:double\nbuffer:./doublebuffer& - @w:GL window:./cube& - @w:GL overlay:./gl_overlay& - @w:iconize:./iconize& - @w:fullscreen:./fullscreen& - @w:resizable:./resizebox& - @w:resize:./resize& + @w:overlay:overlay + @w:subwindow:subwindow + @w:double\nbuffer:doublebuffer + @w:GL window:cube + @w:GL overlay:gl_overlay + @w:iconize:iconize + @w:fullscreen:fullscreen + @w:resizable:resizebox + @w:resize:resize @main:Drawing\nTests:@d - @d:Fl_Bitmap:./bitmap& - @d:Fl_Pixmap:./pixmap& - @d:Fl_Image:./image& - @d:pixmap\nbrowser:./pixmap_browser& - @d:cursor:./cursor& - @d:labels:./label& - @d:fl_arc:./arc& - @d:fl_curve:./curve& - @d:fonts:./fonts& + @d:Fl_Bitmap:bitmap + @d:Fl_Pixmap:pixmap + @d:Fl_Image:image + @d:pixmap\nbrowser:pixmap_browser + @d:cursor:cursor + @d:labels:label + @d:fl_arc:arc + @d:fl_curve:curve + @d:fonts:fonts @main:Events:@u - @u:navigation:./navigation& - @u:minimum update:./minimum& - @u:keyboard:./keyboard& - @u:fast & slow widgets:./fast_slow& - @u:inactive:./inactive& + @u:navigation:navigation + @u:minimum update:minimum + @u:keyboard:keyboard + @u:fast & slow widgets:fast_slow + @u:inactive:inactive -@main:Fluid\n(UI design tool):../fluid/fluid valuators.fl& +@main:Fluid\n(UI design tool):../fluid/fluid valuators.fl @main:Cool\nDemos:@e - @e:X Color\nBrowser:./colbrowser& - @e:Mandelbrot:./mandelbrot& - @e:Fractals:./fractals& - @e:Puzzle:./glpuzzle& - @e:shiny\nOpenGL\nbuttons:./shiny& - @e:Checkers:./checkers& + @e:X Color\nBrowser:colbrowser + @e:Mandelbrot:mandelbrot + @e:Fractals:fractals + @e:Puzzle:glpuzzle + @e:shiny\nOpenGL\nbuttons:shiny + @e:Checkers:checkers @main:Other\nTests:@o - @o:color choosers:./color_chooser r& - @o:file chooser:./file_chooser& - @o:XForms Emulation:./forms& + @o:color choosers:color_chooser r + @o:file chooser:file_chooser + @o:XForms Emulation:forms @main:Tutorial\nfrom\nManual:@j - @j:hello:./hello& - @j:button:./button& - @j:ask\n(modified):./ask& - @j:shape:./shape& + @j:ask\n(modified):ask + @j:button:button + @j:editor:editor + @j:hello:hello + @j:shape:shape @main:Images\nfor\nManual:@i - @i:valuators:./valuators& - @i:symbols:./symbols& - @i:buttons:./buttons& - @i:clock:./clock& - @i:popups:./message& - @i:boxtypes:./boxtype& + @i:valuators:valuators + @i:symbols:symbols + @i:buttons:buttons + @i:clock:clock + @i:popups:message + @i:boxtypes:boxtype diff --git a/test/demod.menu b/test/demod.menu new file mode 100644 index 000000000..8347c22d5 --- /dev/null +++ b/test/demod.menu @@ -0,0 +1,80 @@ +# Menu description file for the generic demo program +# +# Each line consists of three fields, separated by : +# +# - menu name : To which the item belongs (starts with @) +# - item name : Placed on button. (use \n for newline) +# - command name: To be executed. Use a menu name to define a submenu. +# +# @main indicates the main menu. +# + +@main:Widget\nTests:@x + @x:Fl_Browser:browser + @x:Fl_Input:input + @x:Fl_Output:output + @x:Fl_Button:radio + @x:Fl_Tabs:tabs + @x:Fl_Tile:tile + @x:Fl_Scroll:scroll + @x:Fl_Pack:pack + @x:Fl_Menu:menubar + +@main:Window\nTests:@w + @w:overlay:overlay + @w:subwindow:subwindow + @w:double\nbuffer:doublebuffer + @w:GL window:cube + @w:GL overlay:gl_overlay + @w:iconize:iconize + @w:fullscreen:fullscreen + @w:resizable:resizebox + @w:resize:resize + +@main:Drawing\nTests:@d + @d:Fl_Bitmap:bitmap + @d:Fl_Pixmap:pixmap + @d:Fl_Image:image + @d:pixmap\nbrowser:pixmap_browser + @d:cursor:cursor + @d:labels:label + @d:fl_arc:arc + @d:fl_curve:curve + @d:fonts:fonts + +@main:Events:@u + @u:navigation:navigation + @u:minimum update:minimum + @u:keyboard:keyboard + @u:fast & slow widgets:fast_slow + @u:inactive:inactive + +@main:Fluid\n(UI design tool):../fluid/fluid valuators.fl + +@main:Cool\nDemos:@e + @e:X Color\nBrowser:colbrowser + @e:Mandelbrot:mandelbrot + @e:Fractals:fractals + @e:Puzzle:glpuzzle + @e:shiny\nOpenGL\nbuttons:shiny + @e:Checkers:checkers + +@main:Other\nTests:@o + @o:color choosers:color_chooser r + @o:file chooser:file_chooser + @o:XForms Emulation:forms + +@main:Tutorial\nfrom\nManual:@j + @j:ask\n(modified):ask + @j:button:button + @j:editor:editor + @j:hello:hello + @j:shape:shape + +@main:Images\nfor\nManual:@i + @i:valuators:valuators + @i:symbols:symbols + @i:buttons:buttons + @i:clock:clock + @i:popups:message + @i:boxtypes:boxtype -- cgit v1.2.3