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 item header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// Copyright 1998-2005 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.
|
|
|
|
//
|
2000-06-06 01:21:24 +04:00
|
|
|
// Please report all bugs and problems to "fltk-bugs@fltk.org".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
#ifndef Fl_Menu_Item_H
|
|
|
|
#define Fl_Menu_Item_H
|
|
|
|
|
2002-08-01 06:02:03 +04:00
|
|
|
# include "Fl_Widget.H"
|
|
|
|
# include "Fl_Image.H"
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2005-03-21 14:38:52 +03:00
|
|
|
# if defined(__APPLE__) && defined(check)
|
2002-08-01 06:02:03 +04:00
|
|
|
# undef check
|
|
|
|
# endif
|
2002-07-17 10:09:26 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
enum { // values for flags:
|
|
|
|
FL_MENU_INACTIVE = 1,
|
|
|
|
FL_MENU_TOGGLE= 2,
|
|
|
|
FL_MENU_VALUE = 4,
|
|
|
|
FL_MENU_RADIO = 8,
|
|
|
|
FL_MENU_INVISIBLE = 0x10,
|
|
|
|
FL_SUBMENU_POINTER = 0x20,
|
|
|
|
FL_SUBMENU = 0x40,
|
|
|
|
FL_MENU_DIVIDER = 0x80,
|
|
|
|
FL_MENU_HORIZONTAL = 0x100
|
|
|
|
};
|
|
|
|
|
1999-02-17 01:00:04 +03:00
|
|
|
extern FL_EXPORT int fl_old_shortcut(const char*);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
class Fl_Menu_;
|
|
|
|
|
2002-08-14 20:49:38 +04:00
|
|
|
struct FL_EXPORT Fl_Menu_Item {
|
1998-10-06 22:21:25 +04:00
|
|
|
const char *text; // label()
|
|
|
|
int shortcut_;
|
|
|
|
Fl_Callback *callback_;
|
|
|
|
void *user_data_;
|
|
|
|
int flags;
|
|
|
|
uchar labeltype_;
|
|
|
|
uchar labelfont_;
|
|
|
|
uchar labelsize_;
|
2001-10-29 06:44:33 +03:00
|
|
|
unsigned labelcolor_;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// advance N items, skipping submenus:
|
2002-08-14 20:49:38 +04:00
|
|
|
const Fl_Menu_Item *next(int=1) const;
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Menu_Item *next(int i=1) {
|
|
|
|
return (Fl_Menu_Item*)(((const Fl_Menu_Item*)this)->next(i));}
|
2004-06-07 23:23:12 +04:00
|
|
|
const Fl_Menu_Item *first() const { return next(0); }
|
|
|
|
Fl_Menu_Item *first() { return next(0); }
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// methods on menu items:
|
|
|
|
const char* label() const {return text;}
|
|
|
|
void label(const char* a) {text=a;}
|
|
|
|
void label(Fl_Labeltype a,const char* b) {labeltype_ = a; text = b;}
|
|
|
|
Fl_Labeltype labeltype() const {return (Fl_Labeltype)labeltype_;}
|
|
|
|
void labeltype(Fl_Labeltype a) {labeltype_ = a;}
|
|
|
|
Fl_Color labelcolor() const {return (Fl_Color)labelcolor_;}
|
2001-10-29 06:44:33 +03:00
|
|
|
void labelcolor(unsigned a) {labelcolor_ = a;}
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Font labelfont() const {return (Fl_Font)labelfont_;}
|
|
|
|
void labelfont(uchar a) {labelfont_ = a;}
|
|
|
|
uchar labelsize() const {return labelsize_;}
|
|
|
|
void labelsize(uchar a) {labelsize_ = a;}
|
1999-03-18 23:04:13 +03:00
|
|
|
Fl_Callback_p callback() const {return callback_;}
|
1998-10-06 22:21:25 +04:00
|
|
|
void callback(Fl_Callback* c, void* p) {callback_=c; user_data_=p;}
|
|
|
|
void callback(Fl_Callback* c) {callback_=c;}
|
|
|
|
void callback(Fl_Callback0*c) {callback_=(Fl_Callback*)c;}
|
|
|
|
void callback(Fl_Callback1*c, long p=0) {callback_=(Fl_Callback*)c; user_data_=(void*)p;}
|
|
|
|
void* user_data() const {return user_data_;}
|
|
|
|
void user_data(void* v) {user_data_ = v;}
|
|
|
|
long argument() const {return (long)user_data_;}
|
|
|
|
void argument(long v) {user_data_ = (void*)v;}
|
|
|
|
int shortcut() const {return shortcut_;}
|
|
|
|
void shortcut(int s) {shortcut_ = s;}
|
|
|
|
int submenu() const {return flags&(FL_SUBMENU|FL_SUBMENU_POINTER);}
|
|
|
|
int checkbox() const {return flags&FL_MENU_TOGGLE;}
|
|
|
|
int radio() const {return flags&FL_MENU_RADIO;}
|
|
|
|
int value() const {return flags&FL_MENU_VALUE;}
|
|
|
|
void set() {flags |= FL_MENU_VALUE;}
|
|
|
|
void clear() {flags &= ~FL_MENU_VALUE;}
|
2002-08-14 20:49:38 +04:00
|
|
|
void setonly();
|
1998-10-06 22:21:25 +04:00
|
|
|
int visible() const {return !(flags&FL_MENU_INVISIBLE);}
|
|
|
|
void show() {flags &= ~FL_MENU_INVISIBLE;}
|
|
|
|
void hide() {flags |= FL_MENU_INVISIBLE;}
|
|
|
|
int active() const {return !(flags&FL_MENU_INACTIVE);}
|
|
|
|
void activate() {flags &= ~FL_MENU_INACTIVE;}
|
|
|
|
void deactivate() {flags |= FL_MENU_INACTIVE;}
|
|
|
|
int activevisible() const {return !(flags&0x11);}
|
|
|
|
|
2002-08-01 06:02:03 +04:00
|
|
|
// compatibility for FLUID so it can set the image of a menu item...
|
|
|
|
void image(Fl_Image* a) {a->label(this);}
|
|
|
|
void image(Fl_Image& a) {a.label(this);}
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
// used by menubar:
|
2002-08-14 20:49:38 +04:00
|
|
|
int measure(int* h, const Fl_Menu_*) const;
|
|
|
|
void draw(int x, int y, int w, int h, const Fl_Menu_*, int t=0) const;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
// popup menus without using an Fl_Menu_ widget:
|
2002-08-14 20:49:38 +04:00
|
|
|
const Fl_Menu_Item* popup(
|
1998-10-06 22:21:25 +04:00
|
|
|
int X, int Y,
|
|
|
|
const char *title = 0,
|
|
|
|
const Fl_Menu_Item* picked=0,
|
|
|
|
const Fl_Menu_* = 0) const;
|
2002-08-14 20:49:38 +04:00
|
|
|
const Fl_Menu_Item* pulldown(
|
1998-10-06 22:21:25 +04:00
|
|
|
int X, int Y, int W, int H,
|
|
|
|
const Fl_Menu_Item* picked = 0,
|
|
|
|
const Fl_Menu_* = 0,
|
|
|
|
const Fl_Menu_Item* title = 0,
|
|
|
|
int menubar=0) const;
|
2002-08-14 20:49:38 +04:00
|
|
|
const Fl_Menu_Item* test_shortcut() const;
|
|
|
|
const Fl_Menu_Item* find_shortcut(int *ip=0) const;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
void do_callback(Fl_Widget* o) const {callback_(o, user_data_);}
|
|
|
|
void do_callback(Fl_Widget* o,void* arg) const {callback_(o, arg);}
|
|
|
|
void do_callback(Fl_Widget* o,long arg) const {callback_(o, (void*)arg);}
|
|
|
|
|
|
|
|
// back-compatability, do not use:
|
|
|
|
int checked() const {return flags&FL_MENU_VALUE;}
|
|
|
|
void check() {flags |= FL_MENU_VALUE;}
|
|
|
|
void uncheck() {flags &= ~FL_MENU_VALUE;}
|
2002-08-14 20:49:38 +04:00
|
|
|
int add(const char*, int shortcut, Fl_Callback*, void* =0, int = 0);
|
1998-10-06 22:21:25 +04:00
|
|
|
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);}
|
2002-08-14 20:49:38 +04:00
|
|
|
int size() const ;
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef Fl_Menu_Item Fl_Menu; // back compatability
|
|
|
|
|
|
|
|
enum { // back-compatability enum:
|
|
|
|
FL_PUP_NONE = 0,
|
|
|
|
FL_PUP_GREY = FL_MENU_INACTIVE,
|
|
|
|
FL_PUP_GRAY = FL_MENU_INACTIVE,
|
|
|
|
FL_MENU_BOX = FL_MENU_TOGGLE,
|
|
|
|
FL_PUP_BOX = FL_MENU_TOGGLE,
|
|
|
|
FL_MENU_CHECK = FL_MENU_VALUE,
|
|
|
|
FL_PUP_CHECK = FL_MENU_VALUE,
|
|
|
|
FL_PUP_RADIO = FL_MENU_RADIO,
|
|
|
|
FL_PUP_INVISIBLE = FL_MENU_INVISIBLE,
|
|
|
|
FL_PUP_SUBMENU = FL_SUBMENU_POINTER
|
|
|
|
};
|
|
|
|
|
|
|
|
#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
|
|
|
//
|