diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2011-01-02 03:50:54 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2011-01-02 03:50:54 +0000 |
| commit | e203237eb3406ce7d4639b33a3ea2b05d8b7e9c5 (patch) | |
| tree | be246b76f09f0439bf37c5fe34b06abb12ee5f6e /test/demo.cxx | |
| parent | 5f2aa6ca9c0f3054a0dfa061d9e0662f421f8862 (diff) | |
Integrated menu into demo resource branch for OS X. Indicating items that open more choices with ...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8167 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test/demo.cxx')
| -rw-r--r-- | test/demo.cxx | 125 |
1 files changed, 9 insertions, 116 deletions
diff --git a/test/demo.cxx b/test/demo.cxx index f52951b2b..66e34ba0c 100644 --- a/test/demo.cxx +++ b/test/demo.cxx @@ -25,106 +25,6 @@ // http://www.fltk.org/str.php // -const char *default_menu[] = { - "# Menu description file for the generic demo program\n", - "#\n", - "# Each line consists of three fields, separated by :\n", - "#\n", - "# - menu name : To which the item belongs (starts with @)\n", - "# - item name : Placed on button. (use \\n for newline)\n", - "# - command name: To be executed. Use a menu name to define a submenu.\n", - "#\n", - "# @main indicates the main menu.\n", - "#\n", - "\n", - "@main:Widget\\nTests:@x\n", - "@x:Fl_Browser:browser browser.cxx\n", - "@x:Fl_Input:input\n", - "@x:Fl_Output:output\n", - "@x:Fl_Button:radio\n", - "@x:Fl_Tabs:tabs\n", - "@x:Fl_Tile:tile\n", - "@x:Fl_Scroll:scroll\n", - "@x:Fl_Pack:pack\n", - "@x:more...:@xm\n", - "@xm:Fl_Menu:menubar\n", - "@xm:Fl_Table:table\n", - "@xm:Fl_Tree:tree\n", - "\n", - "@main:Window\\nTests:@w\n", - "@w:overlay:overlay\n", - "@w:subwindow:subwindow\n", - "@w:double\\nbuffer:doublebuffer\n", - "@w:GL window:cube\n", - "@w:GL overlay:gl_overlay\n", - "@w:iconize:iconize\n", - "@w:fullscreen:fullscreen\n", - "@w:resizable:resizebox\n", - "@w:resize:resize\n", - "\n", - "@main:Drawing\\nTests:@d\n", - "@d:Images:@di\n", - "@di:Fl_Bitmap:bitmap\n", - "@di:Fl_Pixmap:pixmap\n", - "@di:Fl_RGB\\n_Image:image\n", - "@di:Fl_Shared\\n_Image:pixmap_browser\n", - "@di:Fl_Tiled\\n_Image:tiled_image\n", - "@d:cursor:cursor\n", - "@d:labels:label\n", - "@d:rotated text:rotated_text\n", - "@d:fl_arc:arc\n", - "@d:fl_curve:curve\n", - "@d:fl_line_style:line_style\n", - "\n", - "@main:Events:@u\n", - "@u:navigation:navigation\n", - "@u:minimum update:minimum\n", - "@u:keyboard:keyboard\n", - "@u:fast && slow widgets:fast_slow\n", - "@u:inactive:inactive\n", - "\n", - "@main:Fluid\\n(UI design tool):../fluid/fluid valuators.fl\n", - "\n", - "@main:Cool\\nDemos:@e\n", - "@e:X Color\\nBrowser:colbrowser\n", - "@e:Mandelbrot:mandelbrot\n", - "@e:Fractals:fractals\n", - "@e:Puzzle:glpuzzle\n", - "@e:Block\\nAttack!:blocks\n", - "@e:Checkers:checkers\n", - "@e:Sudoku:sudoku\n", - "@e:Print\\nsupport:device\n", - "\n", - "@main:Other\\nTests:@o\n", - "@o:Color Choosers:color_chooser\n", - "@o:File Chooser:file_chooser\n", - "@o:Native File Chooser:native-filechooser\n", - "@o:Font Tests:@of\n", - "@of:Fonts:fonts\n", - "@of:UTF-8:utf8\n", - "@o:HelpDialog:help\n", - "@o:Input Choice:input_choice\n", - "@o:Preferences:preferences\n", - "@o:Threading:threads\n", - "@o:XForms Emulation:forms\n", - "\n", - "@main:Tutorial\\nfrom\\nManual:@j\n", - "@j:ask\\n(modified):ask\n", - "@j:button:button\n", - "@j:CubeView:CubeView\n", - "@j:editor:editor editor.cxx\n", - "@j:hello:hello\n", - "@j:shape:shape\n", - "\n", - "@main:Images\\nfor\\nManual:@i\n", - "@i:valuators:valuators\n", - "@i:symbols:symbols\n", - "@i:buttons:buttons\n", - "@i:clock:clock\n", - "@i:popups:message\n", - "@i:boxtypes:boxtype\n", - 0 }; - #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -383,7 +283,7 @@ void dobut(Fl_Widget *, long arg) char command[2048], path[2048], app_path[2048]; - // this neat litle block of cose ensures that the current directory is set + // this neat litle block of code ensures that the current directory is set // to the location of the Demo application. CFBundleRef app = CFBundleGetMainBundle(); CFURLRef url = CFBundleCopyBundleURL(app); @@ -435,11 +335,10 @@ int load_the_menu(const char* fname) { FILE *fin = 0; char line[256], mname[64],iname[64],cname[64]; - int i,j, mi = 0; + int i, j; fin = fl_fopen(fname,"r"); - if (fin == NULL) - { -#if defined ( __APPLE__ ) +#if defined ( USING_XCODE ) + if (fin == NULL) { // mac os bundle menu detection: char* pos = strrchr(fname,'/'); if (!pos) return 0; @@ -448,18 +347,13 @@ int load_the_menu(const char* fname) if (!pos) return 0; strcpy(pos,"/Resources/demo.menu"); fin = fl_fopen(fname,"r"); + } #endif + if (fin == NULL) { + return 0; } - // if "fin" is still NULL, we will read the menu from the string array in the - // beginning of the file. for (;;) { - if (fin) { - if (fgets(line,256,fin) == NULL) break; - } else { - const char *m = default_menu[mi++]; - if (!m) break; - strcpy(line, m); - } + if (fgets(line,256,fin) == NULL) break; // remove all carriage returns that Cygwin may have inserted char *s = line, *d = line; for (;;++d) { @@ -493,8 +387,7 @@ int load_the_menu(const char* fname) cname[j] = '\0'; addto_menu(mname,iname,cname); } - if (fin) - fclose(fin); + fclose(fin); return 1; } |
