class Fl_Input_ : public Fl_Widget
This is a virtual base class below Fl_Input.
It has all the same interfaces, but lacks a 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
Besides all the methods documented in Fl_Input, the methods are provided so a
subclass can edit the text:
int Fl_Input_::wordboundary(int i) const;
int Fl_Input_::lineboundary(int i) const;
Returns true if position i is at the start or end of a word/line.
void Fl_Input_::drawtext(int,int,int,int);
Draw the text in the passed bounding box. If
damage()&128
is true, this assummes the area has already
been erased to color(). Otherwise it does minimal update and erases
the area itself.
void Fl_Input_::handletext(int e,int,int,int,int);
Default handler for all event types. Your handle() should call this
for all events that it does not handle completely. You must pass it
the same bounding box as passed to draw(). Handles FL_PUSH, FL_DRAG,
FL_RELEASE to select text, handles FL_FOCUS and FL_UNFOCUS to show and
hide the cursor.
int Fl_Input_::up_down_position(int i, int keepmark=0);
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.
void Fl_Input_::maybe_do_callback();
Does the callback if changed() is true or if
when()&FL_WHEN_NOT_CHANGED. You should call this at any point you
think you should generate a callback.
int Fl_Input_::position() const;
int Fl_Input_::mark() const;
int Fl_Input_::position(int new_position, int new_mark);
int Fl_Input_::position(int new_position_and_new_mark);
int Fl_Input_::mark(int new_mark);
The input 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 X selection (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)
.
int Fl_Input_::replace(int a, int b, const char *insert, int length=0);
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 null-terminated 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.
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().
int Fl_Input_::cut();
int Fl_Input_::cut(int n);
int Fl_Input_::cut(int a, int b);
Fl_Input_::cut() deletes the region. 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.
int Fl_Input_::insert(const char *t,int l=0);
Insert the string t at the postion, and leave the mark and position
after it. If l is not zero then it is assummed to be strlen(t).
int Fl_Input_::copy();
Put the region between mark() and position() into the X
clipboard. Does nothing (that is it does not clear the old X
selection) if mark()==position().
int Fl_Input_::undo();
Does undo of several previous calls to replace(). Returns non-zero if
any change was made.
int Fl_Input_::copy_cuts();
Copy all the previous contiguous cuts from the undo information to the
X clipboard. This is used to make ^K work.
(back to contents)