// dynmenu.hpp -- manage dynamic menus // // Written by Frederic Bouvier, started February 2004. // // Copyright (C) 2004 Frederic Bouvier - fredb@users.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program 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 // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // // $Id: dynmenu.hpp,v 1.1 2004/02/14 14:17:38 fredb2 Exp $ #ifndef _dynmenu_hpp_ #define _dynmenu_hpp_ #include #include class FGSD_DynamicMenu { public: virtual ~FGSD_DynamicMenu() {} virtual void increment() = 0; virtual void decrement() = 0; }; class FGSD_DynamicSubMenu : public FGSD_DynamicMenu { public: FGSD_DynamicSubMenu(); void init( Fl_Menu_ *menu, const char *parentLabel, int position, FGSD_DynamicMenu *next ); void clear(); int add( const char *label, int shortcut, Fl_Callback *callback, void *user_data=0, int flags=0); int addNone(); int first() const { return _first; } void increment(); void decrement(); private: Fl_Menu_ *_menu; std::string _parentLabel; int _first; int _last; FGSD_DynamicMenu *_next; }; class FGSD_DynamicMenuItem : public FGSD_DynamicMenu { public: FGSD_DynamicMenuItem(); void init( Fl_Menu_ *menu, const char *parentLabel, int position, FGSD_DynamicMenu *next ); int position() const { return _pos; } void label( const char *); void activate(); void deactivate(); void increment(); void decrement(); private: Fl_Menu_ *_menu; std::string _parentLabel; std::string _label; int _pos; FGSD_DynamicMenu *_next; }; #endif