summaryrefslogtreecommitdiff
path: root/FL/Fl_Menu_.H
blob: aaab94d6dc11316e8957bbffcaadfdd9636877a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//
// "$Id"
//
// Menu base class header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998 by Bill Spitzak and others.
//
// 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.
//
// Please report all bugs and problems to "fltk-bugs@easysw.com".
//

#ifndef Fl_Menu__H
#define Fl_Menu__H

#ifndef Fl_Widget_H
#include "Fl_Widget.H"
#endif
#include "Fl_Menu_Item.H"

class Fl_Menu_ : public Fl_Widget {

  Fl_Menu_Item *menu_;
  const Fl_Menu_Item *value_;
  static Fl_Font default_font_;
  static int default_size_;

protected:

  const Fl_Menu_Item* picked(const Fl_Menu_Item*);
  uchar down_box_;
  uchar textfont_;
  uchar textsize_;
  uchar textcolor_;
  uchar alloc;

public:

  Fl_Menu_(int,int,int,int,const char * =0);
  ~Fl_Menu_();

  const Fl_Menu_Item* test_shortcut() {return picked(menu()->test_shortcut());}
  void global();

  const Fl_Menu_Item *menu() const {return menu_;}
  void menu(const Fl_Menu_Item *m);
  int  add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 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  size() const ;
  void clear();
  int  add(const char *);
  void replace(int,const char *);
  void remove(int);
  void shortcut(int i, int s) {menu_[i].shortcut(s);}
  void mode(int i,int x) {menu_[i].flags = x;}
  int  mode(int i) const {return menu_[i].flags;}

  const Fl_Menu_Item *mvalue() const {return value_;}
  int value() const {return value_-menu_;}
  int value(const Fl_Menu_Item*);
  int value(int i) {return value(menu_+i);}
  const char *text() const {return value_ ? value_->text : 0;}
  const char *text(int i) const {return menu_[i].text;}

  Fl_Font textfont() const {return (Fl_Font)textfont_;}
  void textfont(uchar c) {textfont_=c;}
  uchar textsize() const {return textsize_;}
  void textsize(uchar c) {textsize_=c;}
  Fl_Color textcolor() const {return (Fl_Color)textcolor_;}
  void textcolor(uchar c) {textcolor_=c;}

  static void default_font(Fl_Font b) {default_font_ = b;}
  static Fl_Font default_font() {return default_font_;}
  static void default_size(int b) {default_size_ = b;}
  static int default_size() {return default_size_;}

  Fl_Boxtype down_box() const {return (Fl_Boxtype)down_box_;}
  void down_box(Fl_Boxtype b) {down_box_ = b;}

  // back compatability:
  Fl_Color down_color() const {return selection_color();}
  void down_color(uchar c) {selection_color(c);}
};

#endif

//
// End of "$Id: Fl_Menu_.H,v 1.2 1998/10/19 21:38:49 mike Exp $".
//