1998-10-20 01:39:29 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Input base class header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2009-01-01 19:11:32 +03:00
|
|
|
// Copyright 1998-2009 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-10-15 17:46:06 +04:00
|
|
|
/* \file
|
2008-09-16 11:26:22 +04:00
|
|
|
Fl_Input_ widget . */
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
#ifndef Fl_Input__H
|
|
|
|
#define Fl_Input__H
|
|
|
|
|
|
|
|
#ifndef Fl_Widget_H
|
|
|
|
#include "Fl_Widget.H"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FL_NORMAL_INPUT 0
|
|
|
|
#define FL_FLOAT_INPUT 1
|
|
|
|
#define FL_INT_INPUT 2
|
|
|
|
#define FL_HIDDEN_INPUT 3
|
|
|
|
#define FL_MULTILINE_INPUT 4
|
|
|
|
#define FL_SECRET_INPUT 5
|
2002-04-11 15:52:43 +04:00
|
|
|
#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)
|
2002-07-23 20:28:19 +04:00
|
|
|
#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)
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2008-09-15 15:10:51 +04:00
|
|
|
/**
|
2009-04-18 22:52:59 +04:00
|
|
|
This class provides a low-overhead text input field.
|
|
|
|
|
2009-04-19 16:47:36 +04:00
|
|
|
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
|
2008-09-15 15:10:51 +04:00
|
|
|
one of those people who likes to change how the editing keys
|
2009-04-18 22:52:59 +04:00
|
|
|
work. It may also be useful for adding scrollbars
|
|
|
|
to the input field.
|
2008-09-15 15:10:51 +04:00
|
|
|
|
2009-04-19 16:47:36 +04:00
|
|
|
This can act like any of the subclasses of Fl_Input, by
|
|
|
|
setting type() to one of the following values:
|
2008-09-15 15:10:51 +04:00
|
|
|
|
|
|
|
\code
|
|
|
|
#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)
|
|
|
|
\endcode
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2009-04-23 19:32:19 +04:00
|
|
|
All variables that represent an index into a text buffer are byte-oriented,
|
|
|
|
not character oriented. Since utf8 characters can be up to six bytes long,
|
|
|
|
simply incrementing such an index will not reliably advance to the next character
|
|
|
|
in the text buffer.
|
|
|
|
|
2009-07-18 15:03:44 +04:00
|
|
|
Indices and pointers into the text buffer should always point at a 7 bit ASCII
|
2009-04-23 19:32:19 +04:00
|
|
|
character or the beginning of a utf8 character sequence. Behavior for false
|
|
|
|
utf8 sequences and pointers into the middle of a seqeunce are undefined.
|
|
|
|
|
2009-04-19 16:47:36 +04:00
|
|
|
\see Fl_Text_Display, Fl_Text_Editor for more powerful text handling widgets
|
2009-04-23 19:32:19 +04:00
|
|
|
|
|
|
|
\internal
|
|
|
|
When porting this widget from ASCII to UTF8, previously legal pointers into
|
|
|
|
the text of this widget can become illegal by pointing into the middle of
|
|
|
|
a UTF8 seuence. This is not a big problem for Fl_Input_ because all code
|
|
|
|
in this module is quite tolerant. It could be problematic though when deriving
|
|
|
|
from this class because no feedback for illegal pointers is given. Additionaly,
|
|
|
|
a careless "copy" call can put partial UTF8 sequnces into the clipboard.
|
|
|
|
|
|
|
|
None of these issues should be desasterous. Nevertheless, we should
|
|
|
|
discuss how FLTK should handle false UTF8 suequences and pointers.
|
2008-09-15 15:10:51 +04:00
|
|
|
*/
|
2002-08-14 20:49:38 +04:00
|
|
|
class FL_EXPORT Fl_Input_ : public Fl_Widget {
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
/** \internal Storage for the text field. */
|
1998-10-06 22:21:25 +04:00
|
|
|
const char* value_;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** \internal Buffer memory for expanded text. \see expand() */
|
1998-10-06 22:21:25 +04:00
|
|
|
char* buffer;
|
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
/** \internal Size of text in bytes in the \p value_ field. */
|
1998-10-06 22:21:25 +04:00
|
|
|
int size_;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2009-04-23 19:32:19 +04:00
|
|
|
/** \internal \todo Please document me! */
|
1998-10-06 22:21:25 +04:00
|
|
|
int bufsize;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** \internal Positin of the cursor in the document */
|
1998-10-06 22:21:25 +04:00
|
|
|
int position_;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2009-07-18 15:03:44 +04:00
|
|
|
/** \internal Position of the other end of the selected text. If \p position_ equals
|
2009-04-18 22:52:59 +04:00
|
|
|
\p mark_, no text is selected */
|
1998-10-06 22:21:25 +04:00
|
|
|
int mark_;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2009-09-20 01:16:21 +04:00
|
|
|
/** \internal Offset to text origin within widget bounds */
|
1998-10-06 22:21:25 +04:00
|
|
|
int xscroll_, yscroll_;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** \internal Minimal update pointer. Display requirs redraw from here to the end
|
|
|
|
of the buffer. */
|
1998-10-06 22:21:25 +04:00
|
|
|
int mu_p;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** \internal Maximum size of buffer. \todo Is this really needed? */
|
1998-10-06 22:21:25 +04:00
|
|
|
int maximum_size_;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2009-07-18 15:03:44 +04:00
|
|
|
/** \internal Shortcut key that will fetch focus for this widget. */
|
2008-04-23 03:33:17 +04:00
|
|
|
int shortcut_;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
/** \internal This is set if no text but only the cursor needs updating. */
|
2001-10-29 06:44:33 +03:00
|
|
|
uchar erase_cursor_only;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** \internal The font used for the entire text. */
|
2008-04-23 23:09:28 +04:00
|
|
|
Fl_Font textfont_;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** \internal Height of the font used for the entire text. */
|
2008-08-16 01:11:21 +04:00
|
|
|
Fl_Fontsize textsize_;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** \internal color of the entire text */
|
2009-09-27 15:06:56 +04:00
|
|
|
Fl_Color textcolor_;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** \internal color of the text cursor */
|
2009-09-27 15:06:56 +04:00
|
|
|
Fl_Color cursor_color_;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
/** \internal Horizontal cursor position in pixels while movin up or down. */
|
|
|
|
static double up_down_pos;
|
|
|
|
|
|
|
|
/** \internal Flag to remeber last cursor move. */
|
|
|
|
static int was_up_down;
|
|
|
|
|
|
|
|
/* Convert a given text segment into the text that will be rendered on screen. */
|
2002-08-14 20:49:38 +04:00
|
|
|
const char* expand(const char*, char*) const;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Calculates the width in pixels of part of a text buffer. */
|
2002-08-14 20:49:38 +04:00
|
|
|
double expandpos(const char*, const char*, const char*, int*) const;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Mark a range of characters for update. */
|
2002-08-14 20:49:38 +04:00
|
|
|
void minimal_update(int, int);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Mark a range of characters for update. */
|
2002-08-14 20:49:38 +04:00
|
|
|
void minimal_update(int p);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Copy the value from a possibly static entry into the internal buffer. */
|
2002-08-14 20:49:38 +04:00
|
|
|
void put_in_buffer(int newsize);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
/* Set the current font and font size. */
|
2002-08-14 20:49:38 +04:00
|
|
|
void setfont() const;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2009-07-18 15:03:44 +04:00
|
|
|
/* Find the start of a word. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int word_start(int i) const;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2009-07-18 15:03:44 +04:00
|
|
|
/* Find the end of a word. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int word_end(int i) const;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2009-07-18 15:03:44 +04:00
|
|
|
/* Find the start of a line. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int line_start(int i) const;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2009-07-18 15:03:44 +04:00
|
|
|
/* Find the end of a line. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int line_end(int i) const;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Draw the text in the passed bounding box. */
|
2002-08-14 20:49:38 +04:00
|
|
|
void drawtext(int, int, int, int);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Move the cursor to the column given by up_down_pos. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int up_down_position(int, int keepmark=0);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Handle mouse clicks and mose moves. */
|
2002-08-14 20:49:38 +04:00
|
|
|
void handle_mouse(int, int, int, int, int keepmark=0);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Handle all kinds of text field related events. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int handletext(int e, int, int, int, int);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Check the when() field and do a callback if indicated. */
|
2002-08-14 20:49:38 +04:00
|
|
|
void maybe_do_callback();
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** \internal Horizontal offset of text to left edge of widget. */
|
1998-10-06 22:21:25 +04:00
|
|
|
int xscroll() const {return xscroll_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** \internal Vertical offset of text to top edge of widget. */
|
1998-10-06 22:21:25 +04:00
|
|
|
int yscroll() const {return yscroll_;}
|
2009-09-20 01:16:21 +04:00
|
|
|
void yscroll(int y) { yscroll_ = y; damage(FL_DAMAGE_EXPOSE);}
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
/* Return the number of lines displayed on a single page. */
|
|
|
|
int linesPerPage();
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
public:
|
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
/* Change the size of the widget. */
|
2002-08-14 20:49:38 +04:00
|
|
|
void resize(int, int, int, int);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-07-18 15:03:44 +04:00
|
|
|
/* Constructor */
|
2002-08-14 20:49:38 +04:00
|
|
|
Fl_Input_(int, int, int, int, const char* = 0);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Destructor */
|
2002-08-14 20:49:38 +04:00
|
|
|
~Fl_Input_();
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
/* Changes the widget text. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int value(const char*);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Changes the widget text. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int value(const char*, int);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Changes the widget text. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int static_value(const char*);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Changes the widget text. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int static_value(const char*, int);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2008-09-15 15:10:51 +04:00
|
|
|
/**
|
2009-04-18 22:52:59 +04:00
|
|
|
Returns the text displayed in the widget.
|
|
|
|
|
|
|
|
This function returns the current value, which is a pointer
|
2008-09-15 15:10:51 +04:00
|
|
|
to the internal buffer and is valid only until the next event is
|
|
|
|
handled.
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2009-04-19 16:47:36 +04:00
|
|
|
\return pointer to an internal buffer - do not free() this
|
|
|
|
\see Fl_Input_::value(const char*)
|
2008-09-15 15:10:51 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
const char* value() const {return value_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2009-04-23 19:32:19 +04:00
|
|
|
/* Returns the character at index \p i. */
|
|
|
|
Fl_Char index(int i) const;
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2008-09-15 15:10:51 +04:00
|
|
|
/**
|
2009-04-19 16:47:36 +04:00
|
|
|
Returns the number of bytes in value().
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
This may be greater than <tt>strlen(value())</tt> if there are
|
|
|
|
\c nul characters in the text.
|
|
|
|
|
|
|
|
\return number of bytes in the text
|
2008-09-15 15:10:51 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int size() const {return size_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Sets the width and height of this widget.
|
|
|
|
\param [in] W, H new width and height
|
2009-04-19 16:47:36 +04:00
|
|
|
\see Fl_Widget::size(int, int) */
|
2003-06-15 08:47:28 +04:00
|
|
|
void size(int W, int H) { Fl_Widget::size(W, H); }
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Gets the maximum length of the input field.
|
|
|
|
\todo It is not clear if this function is actually required */
|
1998-10-06 22:21:25 +04:00
|
|
|
int maximum_size() const {return maximum_size_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Sets the maximum length of the input field.
|
|
|
|
\todo It is not clear if this function is actually required */
|
1998-10-06 22:21:25 +04:00
|
|
|
void maximum_size(int m) {maximum_size_ = m;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Gets the position of the text cursor.
|
|
|
|
\return the cursor position as an index
|
2009-04-19 16:47:36 +04:00
|
|
|
\see position(int, int)
|
2008-09-15 15:10:51 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int position() const {return position_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Gets the current selection mark.
|
|
|
|
\return index into the text */
|
1998-10-06 22:21:25 +04:00
|
|
|
int mark() const {return mark_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Sets the index for the cursor and mark. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int position(int p, int m);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Set the cursor position and mark.
|
2009-04-19 16:47:36 +04:00
|
|
|
position(n) is the same as <tt>position(n, n)</tt>.
|
2009-04-18 22:52:59 +04:00
|
|
|
\param p new index for cursor and mark
|
2009-04-19 16:47:36 +04:00
|
|
|
\return 0 if no positions changed
|
|
|
|
\see position(int, int), position(), mark(int)
|
2009-04-18 22:52:59 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int position(int p) {return position(p, p);}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Sets the current selection mark.
|
2009-04-19 16:47:36 +04:00
|
|
|
mark(n) is the same as <tt>position(position(),n)</tt>.
|
2009-04-18 22:52:59 +04:00
|
|
|
\param m new index of the mark
|
2009-04-19 16:47:36 +04:00
|
|
|
\return 0 if the mark did not change
|
|
|
|
\see position(), position(int, int) */
|
1998-10-06 22:21:25 +04:00
|
|
|
int mark(int m) {return position(position(), m);}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Deletes text from b to e and inserts the new string text. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int replace(int, int, const char*, int=0);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2008-09-15 15:10:51 +04:00
|
|
|
/**
|
|
|
|
Deletes the current selection.
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
This function deletes the currently selected text
|
|
|
|
\e without storing it in the clipboard. To use the clipboard,
|
2009-04-19 16:47:36 +04:00
|
|
|
you may call copy() first or copy_cuts() after
|
2009-04-18 22:52:59 +04:00
|
|
|
this call.
|
|
|
|
|
2009-04-19 16:47:36 +04:00
|
|
|
\return 0 if no data was copied
|
2008-09-15 15:10:51 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int cut() {return replace(position(), mark(), 0);}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Deletes the next \p n bytes rounded to characters before or after the cursor.
|
|
|
|
|
|
|
|
This function deletes the currently selected text
|
|
|
|
\e without storing it in the clipboard. To use the clipboard,
|
2009-04-19 16:47:36 +04:00
|
|
|
you may call copy() first or copy_cuts() after
|
2009-04-18 22:52:59 +04:00
|
|
|
this call.
|
|
|
|
|
|
|
|
\param n number of bytes rounded to full characters and clamped to the buffer.
|
|
|
|
A negative number will cut characters to the left of the cursor.
|
2009-04-19 16:47:36 +04:00
|
|
|
\return 0 if no data was copied
|
2009-04-18 22:52:59 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int cut(int n) {return replace(position(), position()+n, 0);}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Deletes all characters between index \p a and \p b.
|
|
|
|
|
|
|
|
This function deletes the currently selected text
|
|
|
|
\e without storing it in the clipboard. To use the clipboard,
|
2009-04-19 16:47:36 +04:00
|
|
|
you may call copy() first or copy_cuts() after
|
2009-04-18 22:52:59 +04:00
|
|
|
this call.
|
|
|
|
|
|
|
|
\param a, b range of bytes rounded to full characters and clamped to the buffer
|
2009-04-19 16:47:36 +04:00
|
|
|
\return 0 if no data was copied
|
2009-04-18 22:52:59 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int cut(int a, int b) {return replace(a, b, 0);}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2008-09-15 15:10:51 +04:00
|
|
|
/**
|
2009-04-18 22:52:59 +04:00
|
|
|
Inserts text at the cursor position.
|
|
|
|
|
|
|
|
This function inserts the string in \p t at the cursor
|
2009-04-19 16:47:36 +04:00
|
|
|
position() and moves the new position and mark to
|
2009-04-18 22:52:59 +04:00
|
|
|
the end of the inserted text.
|
|
|
|
|
|
|
|
\param [in] t text that will be inserted
|
2009-04-19 16:47:36 +04:00
|
|
|
\param [in] l length of text, or 0 if the string is terminated by \c nul.
|
|
|
|
\return 0 if no text was inserted
|
2008-09-15 15:10:51 +04:00
|
|
|
*/
|
1998-10-06 22:21:25 +04:00
|
|
|
int insert(const char* t, int l=0){return replace(position_, mark_, t, l);}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Put the current selection into the clipboard. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int copy(int clipboard);
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Undo previous changes to the text buffer. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int undo();
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/* Copy the yank buffer to the clipboard. */
|
2002-08-14 20:49:38 +04:00
|
|
|
int copy_cuts();
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
/** Return the shortcut key associtaed with this widget.
|
|
|
|
\return shortcut keystroke
|
|
|
|
\see Fl_Button::shortcut() */
|
2008-04-23 03:33:17 +04:00
|
|
|
int shortcut() const {return shortcut_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the shortcut key associtaed with this widget.
|
|
|
|
Pressing the shortcut key gives text editing focus to this widget.
|
|
|
|
\param [in] s new shortcut keystroke
|
|
|
|
\see Fl_Button::shortcut()
|
|
|
|
*/
|
2008-04-23 03:33:17 +04:00
|
|
|
void shortcut(int s) {shortcut_ = s;}
|
|
|
|
|
2009-04-18 22:52:59 +04:00
|
|
|
/** Gets the font of the text in the input field.
|
2009-04-19 16:47:36 +04:00
|
|
|
\return the current Fl_Font index */
|
2008-04-23 23:09:28 +04:00
|
|
|
Fl_Font textfont() const {return textfont_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Sets the font of the text in the input field.
|
|
|
|
The text font defaults to \c FL_HELVETICA.
|
|
|
|
\param [in] s the new text font */
|
2008-04-23 23:09:28 +04:00
|
|
|
void textfont(Fl_Font s) {textfont_ = s;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Gets the size of the text in the input field.
|
|
|
|
\return the text height in pixels */
|
2008-08-16 01:11:21 +04:00
|
|
|
Fl_Fontsize textsize() const {return textsize_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Sets the size of the text in the input field.
|
|
|
|
The text height defaults to \c FL_NORMAL_SIZE.
|
|
|
|
\param [in] s the new font height in pixel units */
|
2008-08-16 01:11:21 +04:00
|
|
|
void textsize(Fl_Fontsize s) {textsize_ = s;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Gets the color of the text in the input field.
|
|
|
|
\return the text color
|
2009-09-27 15:06:56 +04:00
|
|
|
\see textcolor(Fl_Color) */
|
|
|
|
Fl_Color textcolor() const {return textcolor_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Sets the color of the text in the input field.
|
|
|
|
The text color defaults to \c FL_FOREGROUND_COLOR.
|
|
|
|
\param [in] n new text color
|
2009-04-19 16:47:36 +04:00
|
|
|
\see textcolor() */
|
2009-09-27 15:06:56 +04:00
|
|
|
void textcolor(Fl_Color n) {textcolor_ = n;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Gets the color of the cursor.
|
|
|
|
\return the current cursor color */
|
2009-09-27 15:06:56 +04:00
|
|
|
Fl_Color cursor_color() const {return cursor_color_;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Sets the color of the cursor.
|
|
|
|
The default color for the cursor is \c FL_BLACK.
|
|
|
|
\param [in] n the new cursor color */
|
2009-09-27 15:06:56 +04:00
|
|
|
void cursor_color(Fl_Color n) {cursor_color_ = n;}
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Gets the input field type.
|
|
|
|
\return the current input type */
|
2002-04-11 15:52:43 +04:00
|
|
|
int input_type() const {return type() & FL_INPUT_TYPE; }
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Sets the input field type.
|
2009-04-19 16:47:36 +04:00
|
|
|
A redraw() is required to reformat the input field.
|
2009-04-18 22:52:59 +04:00
|
|
|
\param [in] t new input type */
|
2002-11-19 19:37:36 +03:00
|
|
|
void input_type(int t) { type((uchar)(t | readonly())); }
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Gets the read-only state of the input field.
|
|
|
|
\return non-zero if this widget is read-only */
|
2002-04-11 15:52:43 +04:00
|
|
|
int readonly() const { return type() & FL_INPUT_READONLY; }
|
2009-04-18 22:52:59 +04:00
|
|
|
|
|
|
|
/** Sets the read-only state of the input field.
|
2009-04-19 16:47:36 +04:00
|
|
|
\param [in] b if \p b is 0, the text in this widget can be edited by the user */
|
2002-11-19 19:37:36 +03:00
|
|
|
void readonly(int b) { if (b) type((uchar)(type() | FL_INPUT_READONLY));
|
|
|
|
else type((uchar)(type() & ~FL_INPUT_READONLY)); }
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2008-09-15 15:10:51 +04:00
|
|
|
/**
|
2009-04-18 22:52:59 +04:00
|
|
|
Gets the word wrapping state of the input field.
|
|
|
|
Word wrap is only functional with multi-line input fields.
|
2008-09-15 15:10:51 +04:00
|
|
|
*/
|
2002-07-23 20:28:19 +04:00
|
|
|
int wrap() const { return type() & FL_INPUT_WRAP; }
|
2009-04-18 22:52:59 +04:00
|
|
|
|
2008-09-15 15:10:51 +04:00
|
|
|
/**
|
2009-04-18 22:52:59 +04:00
|
|
|
Sets the word wrapping state of the input field.
|
|
|
|
Word wrap is only functional with multi-line input fields.
|
2008-09-15 15:10:51 +04:00
|
|
|
*/
|
2002-11-19 19:37:36 +03:00
|
|
|
void wrap(int b) { if (b) type((uchar)(type() | FL_INPUT_WRAP));
|
|
|
|
else type((uchar)(type() & ~FL_INPUT_WRAP)); }
|
2009-04-18 22:52:59 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-10-20 01:39:29 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|