source: NonGTP/FLTK/include/fltk/Input.h @ 773

Revision 773, 3.3 KB checked in by gumbau, 19 years ago (diff)

FLTK imported to SVN repository to be linked agains the GeoTool? application

Line 
1//
2// "$Id: Input.h 4245 2005-04-08 06:27:43Z spitzak $"
3//
4// One-line text input field.
5//
6// Copyright 1998-2003 by Bill Spitzak and others.
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Library General Public
10// License as published by the Free Software Foundation; either
11// version 2 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16// Library General Public License for more details.
17//
18// You should have received a copy of the GNU Library General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21// USA.
22//
23// Please report all bugs and problems to "fltk-bugs@fltk.org".
24//
25
26#ifndef fltk_Input_h
27#define fltk_Input_h
28
29#ifndef fltk_Widget_h
30#include "Widget.h"
31#endif
32
33namespace fltk {
34
35class FL_API Input : public Widget {
36public:
37  enum { // values for type()
38    NORMAL = 0,
39    // this hole was used by float & int types
40    SECRET = 3,
41    MULTILINE = 4,
42    WORDWRAP = 5
43  };
44
45  Input(int, int, int, int, const char* = 0);
46  ~Input();
47  static NamedStyle* default_style;
48
49  void draw();
50  void draw(const Rectangle&);
51  int handle(int);
52  int handle(int event, const Rectangle&);
53  bool handle_key();
54
55  bool value(const char*);
56  bool value(const char*, int);
57  bool static_value(const char*);
58  bool static_value(const char*, int);
59  const char* value() const {return value_;}
60  char at(int i) const {return value_[i];}
61#ifdef FLTK_1_WIDGET  // back-compatability section:
62  char index(int i) const {return value_[i];}
63#endif
64  int size() const {return size_;}
65  void reserve(int newsize);
66
67  int position() const {return position_;}
68  int mark() const {return mark_;}
69  void position(int p, int m);
70  void position(int p) {position(p, p);}
71  void up_down_position(int position, bool extend);
72  void mark(int m) { position(position(), m);}
73
74  virtual bool replace(int, int, const char*, int);
75  bool cut() {return replace(position(), mark(), 0, 0);}
76  bool cut(int n) {return replace(position(), position()+n, 0, 0);}
77  bool cut(int a, int b) {return replace(a, b, 0, 0);}
78  bool insert(const char* t);
79  bool insert(const char* t, int l){return replace(position_, mark_, t, l);}
80  bool replace(int a, int b, char c) {return replace(a,b,&c,1);}
81  bool copy(bool clipboard = true);
82  bool undo();
83  void maybe_do_callback();
84
85  int word_start(int i) const;
86  int word_end(int i) const;
87  int line_start(int i) const;
88  int line_end(int i) const;
89  int mouse_position(const Rectangle&) const;
90  int xscroll() const {return xscroll_;}
91  int yscroll() const {return yscroll_;}
92
93private:
94
95  const char* value_;
96  char* buffer;
97
98  int size_;
99  int bufsize;
100  int position_;
101  int mark_;
102  int xscroll_, yscroll_;
103  int mu_p;
104  int label_width;
105
106  const char* expand(const char*, char*, int) const;
107  float expandpos(const char*, const char*, const char*, int*) const;
108  void minimal_update(int, int);
109  void minimal_update(int p);
110  void erase_cursor_at(int p);
111
112  void setfont() const;
113
114  void shift_position(int p);
115  void shift_up_down_position(int p);
116
117};
118
119}
120
121#endif
122
123//
124// End of "$Id: Input.h 4245 2005-04-08 06:27:43Z spitzak $".
125//
Note: See TracBrowser for help on using the repository browser.