1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Menu base class header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2009-01-01 19:11:32 +03:00
|
|
|
// Copyright 1998-2009 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-15 17:46:06 +04:00
|
|
|
/* \file
|
2008-09-16 11:26:22 +04:00
|
|
|
Fl_Menu_ widget . */
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
#ifndef Fl_Menu__H
|
|
|
|
#define Fl_Menu__H
|
|
|
|
|
|
|
|
#ifndef Fl_Widget_H
|
|
|
|
#include "Fl_Widget.H"
|
|
|
|
#endif
|
|
|
|
#include "Fl_Menu_Item.H"
|
|
|
|
|
2008-09-15 04:27:28 +04:00
|
|
|
/**
|
|
|
|
Base class of all widgets that have a menu in FLTK.
|
|
|
|
Currently FLTK provides you with
|
|
|
|
Fl_Menu_Button, Fl_Menu_Bar, and Fl_Choice.
|
|
|
|
|
|
|
|
<P>The class contains a pointer to an array of structures of type Fl_Menu_Item. The
|
|
|
|
array may either be supplied directly by the user program, or it may
|
|
|
|
be "private": a dynamically allocated array managed by the Fl_Menu_.
|
|
|
|
*/
|
2002-08-14 20:49:38 +04:00
|
|
|
class FL_EXPORT Fl_Menu_ : public Fl_Widget {
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
Fl_Menu_Item *menu_;
|
|
|
|
const Fl_Menu_Item *value_;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2010-04-08 09:22:13 +04:00
|
|
|
uchar alloc; // flag indicates if menu_ is a dynamic copy (=1) or not (=0)
|
1998-10-06 22:21:25 +04:00
|
|
|
uchar down_box_;
|
2008-04-23 23:09:28 +04:00
|
|
|
Fl_Font textfont_;
|
2008-08-16 01:11:21 +04:00
|
|
|
Fl_Fontsize textsize_;
|
2009-09-27 15:06:56 +04:00
|
|
|
Fl_Color textcolor_;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
public:
|
2002-08-14 20:49:38 +04:00
|
|
|
Fl_Menu_(int,int,int,int,const char * =0);
|
|
|
|
~Fl_Menu_();
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2004-04-06 23:19:41 +04:00
|
|
|
int item_pathname(char *name, int namelen, const Fl_Menu_Item *finditem=0) const;
|
|
|
|
const Fl_Menu_Item* picked(const Fl_Menu_Item*);
|
|
|
|
const Fl_Menu_Item* find_item(const char *name);
|
2010-02-26 16:03:21 +03:00
|
|
|
const Fl_Menu_Item* find_item(Fl_Callback*);
|
2004-04-06 23:19:41 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
const Fl_Menu_Item* test_shortcut() {return picked(menu()->test_shortcut());}
|
2002-08-14 20:49:38 +04:00
|
|
|
void global();
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-09-15 04:27:28 +04:00
|
|
|
/**
|
|
|
|
Returns a pointer to the array of Fl_Menu_Items. This will either be
|
|
|
|
the value passed to menu(value) or the private copy.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
const Fl_Menu_Item *menu() const {return menu_;}
|
2002-08-14 20:49:38 +04:00
|
|
|
void menu(const Fl_Menu_Item *m);
|
|
|
|
void copy(const Fl_Menu_Item *m, void* user_data = 0);
|
|
|
|
int add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0);
|
2008-09-15 04:27:28 +04:00
|
|
|
/** See int Fl_Menu_::add(const char* label, int shortcut, Fl_Callback*, void *user_data=0, int flags=0)*/
|
|
|
|
int add(const char* a, const char* b, Fl_Callback* c, void* d = 0, int e = 0) {
|
|
|
|
return add(a,fl_old_shortcut(b),c,d,e);}
|
|
|
|
int add(const char *);
|
2002-08-14 20:49:38 +04:00
|
|
|
int size() const ;
|
2003-06-15 08:47:28 +04:00
|
|
|
void size(int W, int H) { Fl_Widget::size(W, H); }
|
2002-08-14 20:49:38 +04:00
|
|
|
void clear();
|
|
|
|
void replace(int,const char *);
|
|
|
|
void remove(int);
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Changes the shortcut of item i to n. */
|
1998-10-06 22:21:25 +04:00
|
|
|
void shortcut(int i, int s) {menu_[i].shortcut(s);}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Sets the flags of item i. For a list of the flags, see Fl_Menu_Item. */
|
2002-08-09 05:09:49 +04:00
|
|
|
void mode(int i,int fl) {menu_[i].flags = fl;}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Gets the flags of item i. For a list of the flags, see Fl_Menu_Item. */
|
1998-10-06 22:21:25 +04:00
|
|
|
int mode(int i) const {return menu_[i].flags;}
|
|
|
|
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Returns a pointer to the last menu item that was picked. */
|
1998-10-06 22:21:25 +04:00
|
|
|
const Fl_Menu_Item *mvalue() const {return value_;}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Returns the index into menu() of the last item chosen by the user. It is zero initially. */
|
2004-12-03 05:48:22 +03:00
|
|
|
int value() const {return value_ ? (int)(value_-menu_) : -1;}
|
2002-08-14 20:49:38 +04:00
|
|
|
int value(const Fl_Menu_Item*);
|
2008-09-15 04:27:28 +04:00
|
|
|
/**
|
|
|
|
The value is the index into menu() of the last item chosen by
|
|
|
|
the user. It is zero initially. You can set it as an integer, or set
|
|
|
|
it with a pointer to a menu item. The set routines return non-zero if
|
|
|
|
the new value is different than the old one.
|
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int value(int i) {return value(menu_+i);}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Returns the title of the last item chosen, or of item i. */
|
1998-10-06 22:21:25 +04:00
|
|
|
const char *text() const {return value_ ? value_->text : 0;}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Returns the title of the last item chosen, or of item i. */
|
1998-10-06 22:21:25 +04:00
|
|
|
const char *text(int i) const {return menu_[i].text;}
|
|
|
|
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Gets the current font of menu item labels. */
|
2008-04-23 23:09:28 +04:00
|
|
|
Fl_Font textfont() const {return textfont_;}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Sets the current font of menu item labels. */
|
2008-04-23 23:09:28 +04:00
|
|
|
void textfont(Fl_Font c) {textfont_=c;}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Gets the font size of menu item labels. */
|
2008-08-16 01:11:21 +04:00
|
|
|
Fl_Fontsize textsize() const {return textsize_;}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Sets the font size of menu item labels. */
|
2008-08-16 01:11:21 +04:00
|
|
|
void textsize(Fl_Fontsize c) {textsize_=c;}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Get the current color of menu item labels. */
|
2009-09-27 15:06:56 +04:00
|
|
|
Fl_Color textcolor() const {return textcolor_;}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** Sets the current color of menu item labels. */
|
2009-09-27 15:06:56 +04:00
|
|
|
void textcolor(Fl_Color c) {textcolor_=c;}
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-09-15 04:27:28 +04:00
|
|
|
/**
|
|
|
|
This box type is used to surround the currently-selected items in the
|
|
|
|
menus. If this is FL_NO_BOX then it acts like
|
|
|
|
FL_THIN_UP_BOX and selection_color() acts like
|
2008-09-15 21:46:42 +04:00
|
|
|
FL_WHITE, for back compatibility.
|
2008-09-15 04:27:28 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
|
2008-09-15 04:27:28 +04:00
|
|
|
/** See Fl_Boxtype Fl_Menu_::down_box() const */
|
1998-10-06 22:21:25 +04:00
|
|
|
void down_box(Fl_Boxtype b) {down_box_ = b;}
|
|
|
|
|
2008-09-15 21:46:42 +04:00
|
|
|
/** For back compatibility, same as selection_color() */
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Color down_color() const {return selection_color();}
|
2008-09-15 21:46:42 +04:00
|
|
|
/** For back compatibility, same as selection_color() */
|
2001-10-29 06:44:33 +03:00
|
|
|
void down_color(unsigned c) {selection_color(c);}
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-10-20 01:39:29 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|