diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-01 18:03:10 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2020-07-06 20:28:20 +0200 |
| commit | f09e17c3c564e8310125a10c03397cbf473ff643 (patch) | |
| tree | 8d0fd4a28e3686c33aaa140d07ddba26ab28bdc2 /examples/menubar-add.cxx | |
| parent | b0e0c355edaa2e23148cb0260ada907aec930f05 (diff) | |
Remove $Id$ tags, update URL's, and more
- remove obsolete svn '$Id$' tags from all source files
- update .fl files and generated files accordingly
- replace 'http://www.fltk.org' URL's with 'https://...'
- replace bug report URL 'str.php' with 'bugs.php'
- remove trailing whitespace
- fix other whitespace errors flagged by Git
- add and/or fix missing or wrong standard headers
- convert tabs to spaces in all source files
The only relevant code changes are in the fluid/ folder where
some .fl files and other source files were used to generate
the '$Id' headers and footers.
Diffstat (limited to 'examples/menubar-add.cxx')
| -rw-r--r-- | examples/menubar-add.cxx | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/examples/menubar-add.cxx b/examples/menubar-add.cxx index 2284b2bc4..6326d4865 100644 --- a/examples/menubar-add.cxx +++ b/examples/menubar-add.cxx @@ -1,16 +1,14 @@ // -// "$Id$" +// An example of using Fl_Menu_Bar's add() to dynamically create menubars // -// An example of using Fl_Menu_Bar's add() to dynamically create menubars +// Menu bars can be created several ways. Using add() allows +// dynamically creating a menubar using a 'pathname' syntax. +// Use if you're creating items dynamically, or if you're making +// menubars by hand (as opposed to using fluid), as it's easier +// to type and read. // -// Menu bars can be created several ways. Using add() allows -// dynamically creating a menubar using a 'pathname' syntax. -// Use if you're creating items dynamically, or if you're making -// menubars by hand (as opposed to using fluid), as it's easier -// to type and read. -// -// In this case we're using one callback for all items, -// but you can make unique callbacks for each item if needed. +// In this case we're using one callback for all items, +// but you can make unique callbacks for each item if needed. // // Copyright 2010 Greg Ercolano. // Copyright 1998-2010 by Bill Spitzak and others. @@ -19,32 +17,32 @@ // the file "COPYING" which should have been included with this file. If this // file is missing or damaged, see the license at: // -// http://www.fltk.org/COPYING.php +// https://www.fltk.org/COPYING.php // -// Please report all bugs and problems on the following page: +// Please see the following page on how to report bugs and issues: // -// http://www.fltk.org/str.php +// https://www.fltk.org/bugs.php // -#include <stdio.h> // fprintf() -#include <stdlib.h> // exit() -#include <string.h> // strcmp() +#include <stdio.h> // fprintf() +#include <stdlib.h> // exit() +#include <string.h> // strcmp() #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Menu_Bar.H> -#include <FL/filename.H> // fl_open_uri() +#include <FL/filename.H> // fl_open_uri() // This callback is invoked whenever the user clicks an item in the menu bar static void MyMenuCallback(Fl_Widget *w, void *) { - Fl_Menu_Bar *bar = (Fl_Menu_Bar*)w; // Get the menubar widget - const Fl_Menu_Item *item = bar->mvalue(); // Get the menu item that was picked + Fl_Menu_Bar *bar = (Fl_Menu_Bar*)w; // Get the menubar widget + const Fl_Menu_Item *item = bar->mvalue(); // Get the menu item that was picked - char ipath[256]; bar->item_pathname(ipath, sizeof(ipath)); // Get full pathname of picked item + char ipath[256]; bar->item_pathname(ipath, sizeof(ipath)); // Get full pathname of picked item - fprintf(stderr, "callback: You picked '%s'", item->label()); // Print item picked - fprintf(stderr, ", item_pathname() is '%s'", ipath); // ..and full pathname + fprintf(stderr, "callback: You picked '%s'", item->label()); // Print item picked + fprintf(stderr, ", item_pathname() is '%s'", ipath); // ..and full pathname - if ( item->flags & (FL_MENU_RADIO|FL_MENU_TOGGLE) ) { // Toggle or radio item? - fprintf(stderr, ", value is %s", item->value()?"on":"off"); // Print item's value + if ( item->flags & (FL_MENU_RADIO|FL_MENU_TOGGLE) ) { // Toggle or radio item? + fprintf(stderr, ", value is %s", item->value()?"on":"off"); // Print item's value } fprintf(stderr, "\n"); if ( strcmp(item->label(), "Google") == 0 ) { fl_open_uri("http://google.com/"); } @@ -53,8 +51,8 @@ static void MyMenuCallback(Fl_Widget *w, void *) { int main() { Fl::scheme("gtk+"); - Fl_Window *win = new Fl_Window(400,200, "menubar-simple"); // Create window - Fl_Menu_Bar *menu = new Fl_Menu_Bar(0,0,400,25); // Create menubar, items.. + Fl_Window *win = new Fl_Window(400,200, "menubar-simple"); // Create window + Fl_Menu_Bar *menu = new Fl_Menu_Bar(0,0,400,25); // Create menubar, items.. menu->add("&File/&Open", "^o", MyMenuCallback); menu->add("&File/&Save", "^s", MyMenuCallback, 0, FL_MENU_DIVIDER); menu->add("&File/&Quit", "^q", MyMenuCallback); @@ -62,23 +60,19 @@ int main() { menu->add("&Edit/&Paste", "^v", MyMenuCallback, 0, FL_MENU_DIVIDER); menu->add("&Edit/Radio 1", 0, MyMenuCallback, 0, FL_MENU_RADIO); menu->add("&Edit/Radio 2", 0, MyMenuCallback, 0, FL_MENU_RADIO|FL_MENU_DIVIDER); - menu->add("&Edit/Toggle 1", 0, MyMenuCallback, 0, FL_MENU_TOGGLE); // Default: off - menu->add("&Edit/Toggle 2", 0, MyMenuCallback, 0, FL_MENU_TOGGLE); // Default: off - menu->add("&Edit/Toggle 3", 0, MyMenuCallback, 0, FL_MENU_TOGGLE|FL_MENU_VALUE); // Default: on + menu->add("&Edit/Toggle 1", 0, MyMenuCallback, 0, FL_MENU_TOGGLE); // Default: off + menu->add("&Edit/Toggle 2", 0, MyMenuCallback, 0, FL_MENU_TOGGLE); // Default: off + menu->add("&Edit/Toggle 3", 0, MyMenuCallback, 0, FL_MENU_TOGGLE|FL_MENU_VALUE); // Default: on menu->add("&Help/Google", 0, MyMenuCallback); // Example: show how we can dynamically change the state of item Toggle #2 (turn it 'on') { - Fl_Menu_Item *item = (Fl_Menu_Item*)menu->find_item("&Edit/Toggle 2"); // Find item - if ( item ) item->set(); // Turn it on - else fprintf(stderr, "'Toggle 2' item not found?!\n"); // (optional) Not found? complain! + Fl_Menu_Item *item = (Fl_Menu_Item*)menu->find_item("&Edit/Toggle 2"); // Find item + if ( item ) item->set(); // Turn it on + else fprintf(stderr, "'Toggle 2' item not found?!\n"); // (optional) Not found? complain! } win->end(); win->show(); return(Fl::run()); } - -// -// End of "$Id$". -// |
