Fl_Widget | +----Fl_Input_ | +----Fl_Input
#include <FL/Fl_Input_.H>
This is a virtual base class below Fl_Input. It has all the same interfaces, but lacks the handle() and draw() method. You may want to subclass it if you are one of those people who likes to change how the editing keys work.
This can act like any of the subclasses of Fl_Input, by setting type() to one of the following values:
#define FL_NORMAL_INPUT 0 #define FL_FLOAT_INPUT 1 #define FL_INT_INPUT 2 #define FL_MULTILINE_INPUT 4 #define FL_SECRET_INPUT 5 #define FL_INPUT_TYPE 7 #define FL_INPUT_READONLY 8 #define FL_NORMAL_OUTPUT (FL_NORMAL_INPUT | FL_INPUT_READONLY) #define FL_MULTILINE_OUTPUT (FL_MULTILINE_INPUT | FL_INPUT_READONLY) #define FL_INPUT_WRAP 16 #define FL_MULTILINE_INPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_WRAP) #define FL_MULTILINE_OUTPUT_WRAP (FL_MULTILINE_INPUT | FL_INPUT_READONLY | FL_INPUT_WRAP)
Creates a new Fl_Input_ widget using the given position, size, and label string. The default boxtype is FL_DOWN_BOX.
The destructor removes the widget and any value associated with it.
Returns true if position i is at the start or end of a word.
Returns true if position i is at the start or end of a line.
Draw the text in the passed bounding box. If damage() & FL_DAMAGE_ALL is true, this assumes the area has already been erased to color(). Otherwise it does minimal update and erases the area itself.
Default handler for all event types. Your handle() method should call this for all events that it does not handle completely. You must pass it the same bounding box as you do when calling drawtext() from your draw() method. Handles FL_PUSH, FL_DRAG, FL_RELEASE to select text, handles FL_FOCUS and FL_UNFOCUS to show and hide the cursor.
Do the correct thing for arrow keys. Sets the position (and mark if keepmark is zero) to somewhere in the same line as i, such that pressing the arrows repeatedly will cause the point to move up and down.
Does the callback if changed() is true or if when() & FL_WHEN_NOT_CHANGED is non-zero. You should call this at any point you think you should generate a callback.
Sets or returns the maximum length of the input field.
The input widget maintains two pointers into the string. The "position" is where the cursor is. The "mark" is the other end of the selected text. If they are equal then there is no selection. Changing this does not affect the clipboard (use copy() to do that).
Changing these values causes a redraw(). The new values are bounds checked. The return value is non-zero if the new position is different than the old one. position(n) is the same as position(n,n). mark(n) is the same as position(position(),n).
Gets or sets the current selection mark. mark(n) is the same as position(position(),n).
This call does all editing of the text. It deletes the region between a and b (either one may be less or equal to the other), and then inserts the string insert at that point and leaves the mark() and position() after the insertion. Does the callback if when() & FL_WHEN_CHANGED and there is a change.
Set start and end equal to not delete anything. Set insert to NULL to not insert anything.
length must be zero or strlen(insert), this saves a tiny bit of time if you happen to already know the length of the insertion, or can be used to insert a portion of a string or a string containing nul's.
a and b are clamped to the 0..size() range, so it is safe to pass any values.
cut() and insert() are just inline functions that call replace().
Fl_Input_::cut() deletes the current selection. cut(n) deletes n characters after the position(). cut(-n) deletes n characters before the position(). cut(a,b) deletes the characters between offsets a and b. A, b, and n are all clamped to the size of the string. The mark and point are left where the deleted text was.
If you want the data to go into the clipboard, do Fl_Input_::copy() before calling Fl_Input_::cut(), or do Fl_Input_::copy_cuts() afterwards.
Insert the string t at the current position, and leave the mark and position after it. If l is not zero then it is assumed to be strlen(t).
Put the current selection between mark() and position() into the specified clipboard. Does not replace the old clipboard contents if position() and mark() are equal. Clipboard 0 maps to the current text selection and clipboard 1 maps to the cut/paste clipboard.
Does undo of several previous calls to replace(). Returns non-zero if any change was made.
Copy all the previous contiguous cuts from the undo information to the clipboard. This is used to make ^K work.
Gets or sets the input field type.
Gets or sets the read-only state of the input field.
The second form sets the shortcut key to key. Setting this
overrides the use of '&' in the label(). The value is a bitwise
OR of a key and a set of shift flags, for example FL_ALT | 'a'
, FL_ALT | (FL_F + 10)
, or just 'a'
. A value
of 0 disables the shortcut.
The key can be any value returned by Fl::event_key(), but will usually be an ASCII letter. Use a lower-case letter unless you require the shift key to be held down.
The shift flags can be any set of values accepted by Fl::event_state(). If the bit is on that shift key must be pushed. Meta, Alt, Ctrl, and Shift must be off if they are not in the shift flags (zero for the other bits indicates a "don't care" setting).
Gets or sets the word wrapping state of the input field. Word wrap is only functional with multi-line input fields.