FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

Fl_Input_.H
1 //
2 // "$Id: Fl_Input_.H 9196 2011-12-06 16:55:51Z AlbrechtS $"
3 //
4 // Input base class header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2011 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18
19 /* \file
20 Fl_Input_ widget . */
21
22 #ifndef Fl_Input__H
23 #define Fl_Input__H
24
25 #ifndef Fl_Widget_H
26 #include "Fl_Widget.H"
27 #endif
28
29 #define FL_NORMAL_INPUT 0
30 #define FL_FLOAT_INPUT 1
31 #define FL_INT_INPUT 2
32 #define FL_HIDDEN_INPUT 3
33 #define FL_MULTILINE_INPUT 4
34 #define FL_SECRET_INPUT 5
35 #define FL_INPUT_TYPE 7
36 #define FL_INPUT_READONLY 8
37 #define FL_NORMAL_OUTPUT (FL_NORMAL_INPUT | FL_INPUT_READONLY)
38 #define FL_MULTILINE_OUTPUT (FL_MULTILINE_INPUT | FL_INPUT_READONLY)
39 #define FL_INPUT_WRAP 16
40 #define FL_MULTILINE_INPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_WRAP)
41 #define FL_MULTILINE_OUTPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_READONLY | FL_INPUT_WRAP)
42
94 class FL_EXPORT Fl_Input_ : public Fl_Widget {
95
97 const char* value_;
98
100 char* buffer;
101
103 int size_;
104
106 int bufsize;
107
109 int position_;
110
113 int mark_;
114
118 int tab_nav_;
119
121 int xscroll_, yscroll_;
122
125 int mu_p;
126
128 int maximum_size_;
129
131 int shortcut_;
132
134 uchar erase_cursor_only;
135
137 Fl_Font textfont_;
138
140 Fl_Fontsize textsize_;
141
143 Fl_Color textcolor_;
144
146 Fl_Color cursor_color_;
147
149 static double up_down_pos;
150
152 static int was_up_down;
153
154 /* Convert a given text segment into the text that will be rendered on screen. */
155 const char* expand(const char*, char*) const;
156
157 /* Calculates the width in pixels of part of a text buffer. */
158 double expandpos(const char*, const char*, const char*, int*) const;
159
160 /* Mark a range of characters for update. */
161 void minimal_update(int, int);
162
163 /* Mark a range of characters for update. */
164 void minimal_update(int p);
165
166 /* Copy the value from a possibly static entry into the internal buffer. */
167 void put_in_buffer(int newsize);
168
169 /* Set the current font and font size. */
170 void setfont() const;
171
172 protected:
173
174 /* Find the start of a word. */
175 int word_start(int i) const;
176
177 /* Find the end of a word. */
178 int word_end(int i) const;
179
180 /* Find the start of a line. */
181 int line_start(int i) const;
182
183 /* Find the end of a line. */
184 int line_end(int i) const;
185
186 /* Draw the text in the passed bounding box. */
187 void drawtext(int, int, int, int);
188
189 /* Move the cursor to the column given by up_down_pos. */
190 int up_down_position(int, int keepmark=0);
191
192 /* Handle mouse clicks and mouse moves. */
193 void handle_mouse(int, int, int, int, int keepmark=0);
194
195 /* Handle all kinds of text field related events. */
196 int handletext(int e, int, int, int, int);
197
198 /* Check the when() field and do a callback if indicated. */
199 void maybe_do_callback();
200
202 int xscroll() const {return xscroll_;}
203
205 int yscroll() const {return yscroll_;}
206 void yscroll(int yOffset) { yscroll_ = yOffset; damage(FL_DAMAGE_EXPOSE);}
207
208 /* Return the number of lines displayed on a single page. */
209 int linesPerPage();
210
211 public:
212
213 /* Change the size of the widget. */
214 void resize(int, int, int, int);
215
216 /* Constructor */
217 Fl_Input_(int, int, int, int, const char* = 0);
218
219 /* Destructor */
220 ~Fl_Input_();
221
222 /* Changes the widget text. */
223 int value(const char*);
224
225 /* Changes the widget text. */
226 int value(const char*, int);
227
228 /* Changes the widget text. */
229 int static_value(const char*);
230
231 /* Changes the widget text. */
232 int static_value(const char*, int);
233
244 const char* value() const {return value_;}
245
246 /* Returns the character at index \p i. */
247 Fl_Char index(int i) const;
248
257 int size() const {return size_;}
258
262 void size(int W, int H) { Fl_Widget::size(W, H); }
263
266 int maximum_size() const {return maximum_size_;}
267
275 void maximum_size(int m) {maximum_size_ = m;}
276
281 int position() const {return position_;}
282
285 int mark() const {return mark_;}
286
287 /* Sets the index for the cursor and mark. */
288 int position(int p, int m);
289
296 int position(int p) {return position(p, p);}
297
303 int mark(int m) {return position(position(), m);}
304
305 /* Deletes text from \p b to \p e and inserts the new string \p text. */
306 int replace(int b, int e, const char *text, int ilen=0);
307
318 int cut() {return replace(position(), mark(), 0);}
319
332 int cut(int n) {return replace(position(), position()+n, 0);}
333
345 int cut(int a, int b) {return replace(a, b, 0);}
346
358 int insert(const char* t, int l=0){return replace(position_, mark_, t, l);}
359
360 /* Put the current selection into the clipboard. */
361 int copy(int clipboard);
362
363 /* Undo previous changes to the text buffer. */
364 int undo();
365
366 /* Copy the yank buffer to the clipboard. */
367 int copy_cuts();
368
372 int shortcut() const {return shortcut_;}
373
380 void shortcut(int s) {shortcut_ = s;}
381
384 Fl_Font textfont() const {return textfont_;}
385
389 void textfont(Fl_Font s) {textfont_ = s;}
390
393 Fl_Fontsize textsize() const {return textsize_;}
394
398 void textsize(Fl_Fontsize s) {textsize_ = s;}
399
403 Fl_Color textcolor() const {return textcolor_;}
404
409 void textcolor(Fl_Color n) {textcolor_ = n;}
410
413 Fl_Color cursor_color() const {return cursor_color_;}
414
418 void cursor_color(Fl_Color n) {cursor_color_ = n;}
419
422 int input_type() const {return type() & FL_INPUT_TYPE; }
423
427 void input_type(int t) { type((uchar)(t | readonly())); }
428
431 int readonly() const { return type() & FL_INPUT_READONLY; }
432
435 void readonly(int b) { if (b) type((uchar)(type() | FL_INPUT_READONLY));
436 else type((uchar)(type() & ~FL_INPUT_READONLY)); }
437
442 int wrap() const { return type() & FL_INPUT_WRAP; }
443
448 void wrap(int b) { if (b) type((uchar)(type() | FL_INPUT_WRAP));
449 else type((uchar)(type() & ~FL_INPUT_WRAP)); }
450
472 void tab_nav(int val) {
473 tab_nav_ = val;
474 }
475
485 int tab_nav() const {
486 return tab_nav_;
487 }
488 };
489
490 #endif
491
492 //
493 // End of "$Id: Fl_Input_.H 9196 2011-12-06 16:55:51Z AlbrechtS $".
494 //
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:100
Fl_Input_::maximum_size
int maximum_size() const
Gets the maximum length of the input field in characters.
Definition: Fl_Input_.H:266
Fl_Input_::readonly
void readonly(int b)
Sets the read-only state of the input field.
Definition: Fl_Input_.H:435
Fl_Input_::input_type
void input_type(int t)
Sets the input field type.
Definition: Fl_Input_.H:427
Fl_Input_::position
int position() const
Gets the position of the text cursor.
Definition: Fl_Input_.H:281
Fl_Widget::size
void size(int W, int H)
Changes the size of the widget.
Definition: Fl_Widget.H:330
Fl_Input_::textcolor
Fl_Color textcolor() const
Gets the color of the text in the input field.
Definition: Fl_Input_.H:403
Fl_Input_::textsize
void textsize(Fl_Fontsize s)
Sets the size of the text in the input field.
Definition: Fl_Input_.H:398
Fl_Input_::textcolor
void textcolor(Fl_Color n)
Sets the color of the text in the input field.
Definition: Fl_Input_.H:409
Fl_Input_::tab_nav
int tab_nav() const
Gets whether the Tab key causes focus navigation in multiline input fields or not.
Definition: Fl_Input_.H:485
Fl_Input_::cut
int cut(int a, int b)
Deletes all characters between index a and b.
Definition: Fl_Input_.H:345
Fl_Widget::damage
uchar damage() const
Returns non-zero if draw() needs to be called.
Definition: Fl_Widget.H:913
Fl_Widget::resize
virtual void resize(int x, int y, int w, int h)
Changes the size or position of the widget.
Definition: Fl_Widget.cxx:131
Fl_Input_::tab_nav
void tab_nav(int val)
Sets whether the Tab key does focus navigation, or inserts tab characters into Fl_Multiline_Input.
Definition: Fl_Input_.H:472
Fl_Input_::cursor_color
Fl_Color cursor_color() const
Gets the color of the cursor.
Definition: Fl_Input_.H:413
Fl_Input_::mark
int mark(int m)
Sets the current selection mark.
Definition: Fl_Input_.H:303
Fl_Input_::value
const char * value() const
Returns the text displayed in the widget.
Definition: Fl_Input_.H:244
Fl_Input_::size
int size() const
Returns the number of bytes in value().
Definition: Fl_Input_.H:257
Fl_Input_::wrap
int wrap() const
Gets the word wrapping state of the input field.
Definition: Fl_Input_.H:442
Fl_Widget.H
Fl_Widget, Fl_Label classes .
Fl_Input_::mark
int mark() const
Gets the current selection mark.
Definition: Fl_Input_.H:285
Fl_Char
unsigned int Fl_Char
24-bit Unicode character - upper 8-bits are unused
Definition: fl_types.h:49
Fl_Fontsize
int Fl_Fontsize
Size of a font in pixels.
Definition: Enumerations.H:746
Fl_Input_::shortcut
int shortcut() const
Return the shortcut key associated with this widget.
Definition: Fl_Input_.H:372
Fl_Color
unsigned int Fl_Color
an FLTK color value
Definition: Enumerations.H:774
Fl_Input_
This class provides a low-overhead text input field.
Definition: Fl_Input_.H:94
Fl_Font
int Fl_Font
A font number is an index into the internal font table.
Definition: Enumerations.H:717
Fl_Input_::input_type
int input_type() const
Gets the input field type.
Definition: Fl_Input_.H:422
Fl_Input_::cut
int cut()
Deletes the current selection.
Definition: Fl_Input_.H:318
FL_DAMAGE_EXPOSE
The window was exposed.
Definition: Enumerations.H:945
Fl_Input_::cut
int cut(int n)
Deletes the next n bytes rounded to characters before or after the cursor.
Definition: Fl_Input_.H:332
Fl_Input_::insert
int insert(const char *t, int l=0)
Inserts text at the cursor position.
Definition: Fl_Input_.H:358
Fl_Input_::readonly
int readonly() const
Gets the read-only state of the input field.
Definition: Fl_Input_.H:431
Fl_Input_::position
int position(int p)
Sets the cursor position and mark.
Definition: Fl_Input_.H:296
Fl_Input_::textfont
void textfont(Fl_Font s)
Sets the font of the text in the input field.
Definition: Fl_Input_.H:389
Fl_Input_::size
void size(int W, int H)
Sets the width and height of this widget.
Definition: Fl_Input_.H:262
Fl_Widget::position
void position(int X, int Y)
Repositions the window or widget.
Definition: Fl_Widget.H:321
Fl_Input_::cursor_color
void cursor_color(Fl_Color n)
Sets the color of the cursor.
Definition: Fl_Input_.H:418
Fl_Input_::textsize
Fl_Fontsize textsize() const
Gets the size of the text in the input field.
Definition: Fl_Input_.H:393
Fl_Input_::maximum_size
void maximum_size(int m)
Sets the maximum length of the input field in characters.
Definition: Fl_Input_.H:275
Fl_Input_::shortcut
void shortcut(int s)
Sets the shortcut key associated with this widget.
Definition: Fl_Input_.H:380
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
Fl_Input_::textfont
Fl_Font textfont() const
Gets the font of the text in the input field.
Definition: Fl_Input_.H:384
Fl_Input_::wrap
void wrap(int b)
Sets the word wrapping state of the input field.
Definition: Fl_Input_.H:448
Fl_Widget::type
uchar type() const
Gets the widget type.
Definition: Fl_Widget.H:263
- © 1998-2012 by Bill Spitzak and others.