Fl_Input_ Class Reference

This class provides a low-overhead text input field. More...

`#include <Fl_Input_.H>`

Inheritance diagram for Fl_Input_:

## Public Member Functions

int | copy (int clipboard)
| Put the current selection into the clipboard. More...
int | copy_cuts ()
| Copies the yank buffer to the clipboard. More...
Fl_Color | cursor_color () const
| Gets the color of the cursor. More...
void | cursor_color (Fl_Color n)
| Sets the color of the cursor. More...
int | cut ()
| Deletes the current selection. More...
int | cut (int n)
| Deletes the next `n` bytes rounded to characters before or after the cursor. More...
int | cut (int a, int b)
| Deletes all characters between index `a` and `b`. More...
| Fl_Input_ (int, int, int, int, const char *=0)
| Creates a new Fl_Input_ widget. More...
Fl_Char | index (int i) const
| Returns the character at index `i`. More...
int | input_type () const
| Gets the input field type. More...
void | input_type (int t)
| Sets the input field type. More...
int | insert (const char *t, int l=0)
| Inserts text at the cursor position. More...
int | mark () const
| Gets the current selection mark. More...
int | mark (int m)
| Sets the current selection mark. More...
int | maximum_size () const
| Gets the maximum length of the input field in characters. More...
void | maximum_size (int m)
| Sets the maximum length of the input field in characters. More...
int | position () const
| Gets the position of the text cursor. More...
int | position (int p, int m)
| Sets the index for the cursor and mark. More...
int | position (int p)
| Sets the cursor position and mark. More...
int | readonly () const
| Gets the read-only state of the input field. More...
void | readonly (int b)
| Sets the read-only state of the input field. More...
int | replace (int b, int e, const char *text, int ilen=0)
| Deletes text from `b` to `e` and inserts the new string `text`. More...
void | resize (int, int, int, int)
| Changes the size of the widget. More...
int | shortcut () const
| Return the shortcut key associated with this widget. More...
void | shortcut (int s)
| Sets the shortcut key associated with this widget. More...
int | size () const
| Returns the number of bytes in value(). More...
void | size (int W, int H)
| Sets the width and height of this widget. More...
int | static_value (const char *)
| Changes the widget text. More...
int | static_value (const char *, int)
| Changes the widget text. More...
void | tab_nav (int val)
| Sets whether the Tab key does focus navigation, or inserts tab characters into Fl_Multiline_Input. More...
int | tab_nav () const
| Gets whether the Tab key causes focus navigation in multiline input fields or not. More...
Fl_Color | textcolor () const
| Gets the color of the text in the input field. More...
void | textcolor (Fl_Color n)
| Sets the color of the text in the input field. More...
Fl_Font | textfont () const
| Gets the font of the text in the input field. More...
void | textfont (Fl_Font s)
| Sets the font of the text in the input field. More...
Fl_Fontsize | textsize () const
| Gets the size of the text in the input field. More...
void | textsize (Fl_Fontsize s)
| Sets the size of the text in the input field. More...
int | undo ()
| Undoes previous changes to the text buffer. More...
int | value (const char *)
| Changes the widget text. More...
int | value (const char *, int)
| Changes the widget text. More...
const char * | value () const
| Returns the text displayed in the widget. More...
int | wrap () const
| Gets the word wrapping state of the input field. More...
void | wrap (int b)
| Sets the word wrapping state of the input field. More...
| ~Fl_Input_ ()
| Destroys the widget. More...
Public Member Functions inherited from Fl_Widget
void | _clear_fullscreen ()
void | _set_fullscreen ()
void | activate ()
| Activates the widget. More...
unsigned int | active () const
| Returns whether the widget is active. More...
int | active_r () const
| Returns whether the widget and all of its parents are active. More...
Fl_Align | align () const
| Gets the label alignment. More...
void | align (Fl_Align alignment)
| Sets the label alignment. More...
long | argument () const
| Gets the current user data (long) argument that is passed to the callback function.
void | argument (long v)
| Sets the current user data (long) argument that is passed to the callback function. More...
virtual class Fl_Gl_Window * | as_gl_window ()
| Returns an Fl_Gl_Window pointer if this widget is an Fl_Gl_Window. More...
virtual Fl_Group * | as_group ()
| Returns an Fl_Group pointer if this widget is an Fl_Group. More...
virtual Fl_Window * | as_window ()
| Returns an Fl_Window pointer if this widget is an Fl_Window. More...
Fl_Boxtype | box () const
| Gets the box type of the widget. More...
void | box (Fl_Boxtype new_box)
| Sets the box type for the widget. More...
Fl_Callback_p | callback () const
| Gets the current callback function for the widget. More...
void | callback (Fl_Callback *cb, void *p)
| Sets the current callback function for the widget. More...
void | callback (Fl_Callback *cb)
| Sets the current callback function for the widget. More...
void | callback (Fl_Callback0 *cb)
| Sets the current callback function for the widget. More...
void | callback (Fl_Callback1 *cb, long p=0)
| Sets the current callback function for the widget. More...
unsigned int | changed () const
| Checks if the widget value changed since the last callback. More...
void | clear_changed ()
| Marks the value of the widget as unchanged. More...
void | clear_damage (uchar c=0)
| Clears or sets the damage flags. More...
void | clear_output ()
| Sets a widget to accept input. More...
void | clear_visible ()
| Hides the widget. More...
void | clear_visible_focus ()
| Disables keyboard focus navigation with this widget. More...
Fl_Color | color () const
| Gets the background color of the widget. More...
void | color (Fl_Color bg)
| Sets the background color of the widget. More...
void | color (Fl_Color bg, Fl_Color sel)
| Sets the background and selection color of the widget. More...
Fl_Color | color2 () const
| For back compatibility only. More...
void | color2 (unsigned a)
| For back compatibility only. More...
int | contains (const Fl_Widget *w) const
| Checks if w is a child of this widget. More...
void | copy_label (const char *new_label)
| Sets the current label. More...
void | copy_tooltip (const char *text)
| Sets the current tooltip text. More...
uchar | damage () const
| Returns non-zero if draw() needs to be called. More...
void | damage (uchar c)
| Sets the damage bits for the widget. More...
void | damage (uchar c, int x, int y, int w, int h)
| Sets the damage bits for an area inside the widget. More...
int | damage_resize (int, int, int, int)
| Internal use only. More...
void | deactivate ()
| Deactivates the widget. More...
Fl_Image * | deimage ()
| Gets the image that is used as part of the widget label. More...
const Fl_Image * | deimage () const
void | deimage (Fl_Image *img)
| Sets the image to use as part of the widget label. More...
void | deimage (Fl_Image &img)
| Sets the image to use as part of the widget label. More...
void | do_callback ()
| Calls the widget callback. More...
void | do_callback (Fl_Widget *o, long arg)
| Calls the widget callback. More...
void | do_callback (Fl_Widget *o, void *arg=0)
| Calls the widget callback. More...
virtual void | draw ()=0
| Draws the widget. More...
void | draw_label (int, int, int, int, Fl_Align) const
| Draws the label in an arbitrary bounding box with an arbitrary alignment. More...
int | h () const
| Gets the widget height. More...
virtual int | handle (int event)
| Handles the specified event. More...
virtual void | hide ()
| Makes a widget invisible. More...
Fl_Image * | image ()
| Gets the image that is used as part of the widget label. More...
const Fl_Image * | image () const
void | image (Fl_Image *img)
| Sets the image to use as part of the widget label. More...
void | image (Fl_Image &img)
| Sets the image to use as part of the widget label. More...
int | inside (const Fl_Widget *wgt) const
| Checks if this widget is a child of `wgt`. More...
const char * | label () const
| Gets the current label text. More...
void | label (const char *text)
| Sets the current label pointer. More...
void | label (Fl_Labeltype a, const char *b)
| Shortcut to set the label text and type in one call. More...
Fl_Color | labelcolor () const
| Gets the label color. More...
void | labelcolor (Fl_Color c)
| Sets the label color. More...
Fl_Font | labelfont () const
| Gets the font to use. More...
void | labelfont (Fl_Font f)
| Sets the font to use. More...
Fl_Fontsize | labelsize () const
| Gets the font size in pixels. More...
void | labelsize (Fl_Fontsize pix)
| Sets the font size in pixels. More...
Fl_Labeltype | labeltype () const
| Gets the label type. More...
void | labeltype (Fl_Labeltype a)
| Sets the label type. More...
void | measure_label (int &ww, int &hh) const
| Sets width ww and height hh accordingly with the label size. More...
unsigned int | output () const
| Returns if a widget is used for output only. More...
Fl_Group * | parent () const
| Returns a pointer to the parent widget. More...
void | parent (Fl_Group *p)
| Internal use only - "for hacks only". More...
void | position (int X, int Y)
| Repositions the window or widget. More...
void | redraw ()
| Schedules the drawing of the widget. More...
void | redraw_label ()
| Schedules the drawing of the label. More...
Fl_Color | selection_color () const
| Gets the selection color. More...
void | selection_color (Fl_Color a)
| Sets the selection color. More...
void | set_changed ()
| Marks the value of the widget as changed. More...
void | set_output ()
| Sets a widget to output only. More...
void | set_visible ()
| Makes the widget visible. More...
void | set_visible_focus ()
| Enables keyboard focus navigation with this widget. More...
virtual void | show ()
| Makes a widget visible. More...
void | size (int W, int H)
| Changes the size of the widget. More...
int | take_focus ()
| Gives the widget the keyboard focus. More...
unsigned int | takesevents () const
| Returns if the widget is able to take events. More...
int | test_shortcut ()
| Returns true if the widget's label contains the entered '&x' shortcut. More...
const char * | tooltip () const
| Gets the current tooltip text. More...
void | tooltip (const char *text)
| Sets the current tooltip text. More...
uchar | type () const
| Gets the widget type. More...
void | type (uchar t)
| Sets the widget type. More...
int | use_accents_menu ()
| Returns non zero if MAC_USE_ACCENTS_MENU flag is set, 0 otherwise.
void * | user_data () const
| Gets the user data for this widget. More...
void | user_data (void *v)
| Sets the user data for this widget. More...
unsigned int | visible () const
| Returns whether a widget is visible. More...
void | visible_focus (int v)
| Modifies keyboard focus navigation. More...
unsigned int | visible_focus ()
| Checks whether this widget has a visible focus. More...
int | visible_r () const
| Returns whether a widget and all its parents are visible. More...
int | w () const
| Gets the widget width. More...
Fl_When | when () const
| Returns the conditions under which the callback is called. More...
void | when (uchar i)
| Sets the flags used to decide when a callback is called. More...
Fl_Window * | window () const
| Returns a pointer to the primary Fl_Window widget. More...
int | x () const
| Gets the widget position in its window. More...
int | y () const
| Gets the widget position in its window. More...
virtual | ~Fl_Widget ()
| Destroys the widget. More...

## Protected Member Functions

void | drawtext (int, int, int, int)
| Draws the text in the passed bounding box. More...
void | handle_mouse (int, int, int, int, int keepmark=0)
| Handles mouse clicks and mouse moves. More...
int | handletext (int e, int, int, int, int)
| Handles all kinds of text field related events. More...
int | line_end (int i) const
| Finds the end of a line. More...
int | line_start (int i) const
| Finds the start of a line. More...
int | linesPerPage ()
void | maybe_do_callback ()
int | up_down_position (int, int keepmark=0)
| Moves the cursor to the column given by `up_down_pos`. More...
int | word_end (int i) const
| Finds the end of a word. More...
int | word_start (int i) const
| Finds the start of a word. More...
int | xscroll () const
int | yscroll () const
void | yscroll (int yOffset)
Protected Member Functions inherited from Fl_Widget
void | clear_flag (unsigned int c)
| Clears a flag in the flags mask.
void | draw_backdrop () const
| If FL_ALIGN_IMAGE_BACKDROP is set, the image or deimage will be drawn.
void | draw_box () const
| Draws the widget box according its box style.
void | draw_box (Fl_Boxtype t, Fl_Color c) const
| Draws a box of type t, of color c at the widget's position and size. More...
void | draw_box (Fl_Boxtype t, int x, int y, int w, int h, Fl_Color c) const
| Draws a box of type t, of color c at the position X,Y and size W,H. More...
void | draw_focus ()
| draws a focus rectangle around the widget
void | draw_focus (Fl_Boxtype t, int x, int y, int w, int h) const
| Draws a focus box for the widget at the given position and size.
void | draw_label () const
| Draws the widget's label at the defined label position. More...
void | draw_label (int, int, int, int) const
| Draws the label in an arbitrary bounding box. More...
| Fl_Widget (int x, int y, int w, int h, const char *label=0L)
| Creates a widget at the given position and size. More...
unsigned int | flags () const
| Gets the widget flags mask.
void | h (int v)
| Internal use only. More...
void | set_flag (unsigned int c)
| Sets a flag in the flags mask.
void | w (int v)
| Internal use only. More...
void | x (int v)
| Internal use only. More...
void | y (int v)
| Internal use only. More...

## Additional Inherited Members

Static Public Member Functions inherited from Fl_Widget
static void | default_callback (Fl_Widget *cb, void *d)
| Sets the default callback for all widgets. More...
static unsigned int | label_shortcut (const char *t)
| Returns the Unicode value of the '&x' shortcut in a given text. More...
static int | test_shortcut (const char *, const bool require_alt=false)
| Returns true if the given text `t` contains the entered '&x' shortcut. More...
Protected Types inherited from Fl_Widget

enum

{
INACTIVE = 1<<0, INVISIBLE = 1<<1, OUTPUT = 1<<2, NOBORDER = 1<<3,
FORCE_POSITION = 1<<4, NON_MODAL = 1<<5, SHORTCUT_LABEL = 1<<6, CHANGED = 1<<7,
OVERRIDE = 1<<8, VISIBLE_FOCUS = 1<<9, COPIED_LABEL = 1<<10, CLIP_CHILDREN = 1<<11,
MENU_WINDOW = 1<<12, TOOLTIP_WINDOW = 1<<13, MODAL = 1<<14, NO_OVERLAY = 1<<15,
GROUP_RELATIVE = 1<<16, COPIED_TOOLTIP = 1<<17, FULLSCREEN = 1<<18, MAC_USE_ACCENTS_MENU = 1<<19,
USERFLAG3 = 1<<29, USERFLAG2 = 1<<30, USERFLAG1 = 1<<31
}

| flags possible values enumeration. More...

## Detailed Description

This class provides a low-overhead text input field.

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. It may also be useful for adding scrollbars to the input field.

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)

All variables that represent an index into a text buffer are byte-oriented, not character oriented, counting from 0 (at or before the first character) to size() (at the end of the buffer, after the last byte). Since UTF-8 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.

Indices and pointers into the text buffer should always point at a 7 bit ASCII character or the beginning of a UTF-8 character sequence. Behavior for false UTF-8 sequences and pointers into the middle of a sequence are undefined.

See Also
  Fl_Text_Display, Fl_Text_Editor for more powerful text handling widgets

## Constructor & Destructor Documentation

Fl_Input_::Fl_Input_ | ( | int | X,
|  | int | Y,
|  | int | W,
|  | int | H,
|  | const char * | l = `0`
| ) |  |

Creates a new Fl_Input_ widget.

This function creates a new Fl_Input_ widget and adds it to the current Fl_Group. The value() is set to `NULL`. The default boxtype is `FL_DOWN_BOX`.

Parameters

  X,Y,W,H | the dimensions of the new widget
  l | an optional label text

Fl_Input_::~Fl_Input_ | ( |  | ) |

Destroys the widget.

The destructor clears all allocated buffers and removes the widget from the parent Fl_Group.

## Member Function Documentation

int Fl_Input_::copy | ( | int | clipboard | ) |

Put the current selection into the clipboard.

This function copies the current selection between mark() and position() into the specified `clipboard`. This 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.

Parameters

  clipboard | the clipboard destination 0 or 1

Returns
  0 if no text is selected, 1 if the selection was copied

See Also
  Fl::copy(const char *, int, int)

int Fl_Input_::copy_cuts | ( |  | ) |

Copies the yank buffer to the clipboard.

This method copies all the previous contiguous cuts from the undo information to the clipboard. This function implements the `^K` shortcut key.

Returns
  0 if the operation did not change the clipboard

See Also
  copy(int), cut()

Fl_Color Fl_Input_::cursor_color | ( |  | ) | const

inline

Gets the color of the cursor.

Returns
  the current cursor color

void Fl_Input_::cursor_color | ( | Fl_Color | n | ) |

inline

Sets the color of the cursor.

The default color for the cursor is `FL_BLACK`.

Parameters

  [in] | n | the new cursor color

int Fl_Input_::cut | ( |  | ) |

inline

Deletes the current selection.

This function deletes the currently selected text without storing it in the clipboard. To use the clipboard, you may call copy() first or copy_cuts() after this call.

Returns
  0 if no data was copied

int Fl_Input_::cut | ( | int | n | ) |

inline

Deletes the next `n` bytes rounded to characters before or after the cursor.

This function deletes the currently selected text without storing it in the clipboard. To use the clipboard, you may call copy() first or copy_cuts() after this call.

Parameters

  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.

Returns
  0 if no data was copied

int Fl_Input_::cut | ( | int | a,
|  | int | b
| ) |  |

inline

Deletes all characters between index `a` and `b`.

This function deletes the currently selected text without storing it in the clipboard. To use the clipboard, you may call copy() first or copy_cuts() after this call.

Parameters

  a,b | range of bytes rounded to full characters and clamped to the buffer

Returns
  0 if no data was copied

void Fl_Input_::drawtext | ( | int | X,
|  | int | Y,
|  | int | W,
|  | int | H
| ) |  |

protected

Draws 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.

Parameters

  X,Y,W,H | area that must be redrawn

void Fl_Input_::handle_mouse | ( | int | X,
|  | int | Y,
|  | int | ,
|  | int | ,
|  | int | drag = `0`
| ) |  |

protected

Handles mouse clicks and mouse moves.

Todo:
  Add comment and parameters

int Fl_Input_::handletext | ( | int | event,
|  | int | X,
|  | int | Y,
|  | int | W,
|  | int | H
| ) |  |

protected

Handles all kinds of text field related events.

This is called by derived classes.

Todo:
  Add comment and parameters

unsigned int Fl_Input_::index | ( | int | i | ) | const

Returns the character at index `i`.

This function returns the UTF-8 character at `i` as a ucs4 character code.

Parameters

  [in] | i | index into the value field

Returns
  the character at index `i`

int Fl_Input_::input_type | ( |  | ) | const

inline

Gets the input field type.

Returns
  the current input type

void Fl_Input_::input_type | ( | int | t | ) |

inline

Sets the input field type.

A redraw() is required to reformat the input field.

Parameters

  [in] | t | new input type

int Fl_Input_::insert | ( | const char * | t,
|  | int | l = `0`
| ) |  |

inline

Inserts text at the cursor position.

This function inserts the string in `t` at the cursor position() and moves the new position and mark to the end of the inserted text.

Parameters

  [in] | t | text that will be inserted
  [in] | l | length of text, or 0 if the string is terminated by `nul`.

Returns
  0 if no text was inserted

int Fl_Input_::line_end | ( | int | i | ) | const

protected

Finds the end of a line.

This call calculates the end of a line based on the given index `i`.

Parameters

  [in] | i | starting index for the search

Returns
  end of the line

int Fl_Input_::line_start | ( | int | i | ) | const

protected

Finds the start of a line.

This call calculates the start of a line based on the given index `i`.

Parameters

  [in] | i | starting index for the search

Returns
  start of the line

int Fl_Input_::mark | ( |  | ) | const

inline

Gets the current selection mark.

Returns
  index into the text

int Fl_Input_::mark | ( | int | m | ) |

inline

Sets the current selection mark.

mark(n) is the same as `position(position(),n)`.

Parameters

  m | new index of the mark

Returns
  0 if the mark did not change

See Also
  position(), position(int, int)

int Fl_Input_::maximum_size | ( |  | ) | const

inline

Gets the maximum length of the input field in characters.

See Also
  maximum_size(int).

void Fl_Input_::maximum_size | ( | int | m | ) |

inline

Sets the maximum length of the input field in characters.

This limits the number of characters that can be inserted in the widget.

Since
  FLTK 1.3 this is different than the buffer size, since one character can be more than one byte in UTF-8 encoding. In FLTK 1.1 this was the same (one byte = one character).

int Fl_Input_::position | ( |  | ) | const

inline

Gets the position of the text cursor.

Returns
  the cursor position as an index in the range 0..size()

See Also
  position(int, int)

int Fl_Input_::position | ( | int | p,
|  | int | m
| ) |  |

Sets the index for the cursor and mark.

The input widget maintains two pointers into the string. The position (`p`) is where the cursor is. The mark (`m`) 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.

Parameters

  p | index for the cursor position
  m | index for the mark

Returns
  0 if no positions changed

See Also
  position(int), position(), mark(int)

int Fl_Input_::position | ( | int | p | ) |

inline

Sets the cursor position and mark.

position(n) is the same as `position(n, n)`.

Parameters

  p | new index for cursor and mark

Returns
  0 if no positions changed

See Also
  position(int, int), position(), mark(int)

int Fl_Input_::readonly | ( |  | ) | const

inline

Gets the read-only state of the input field.

Returns
  non-zero if this widget is read-only

void Fl_Input_::readonly | ( | int | b | ) |

inline

Sets the read-only state of the input field.

Parameters

  [in] | b | if `b` is 0, the text in this widget can be edited by the user

int Fl_Input_::replace | ( | int | b,
|  | int | e,
|  | const char * | text,
|  | int | ilen = `0`
| ) |  |

Deletes text from `b` to `e` and inserts the new string `text`.

All changes to the text buffer go through this function. It deletes the region between `b` and `e` (either one may be less or equal to the other), and then inserts the string `text` at that point and moves the mark() and position() to the end of the insertion. Does the callback if `when() & FL_WHEN_CHANGED` and there is a change.

Set `b` and `e` equal to not delete anything. Set `text` to `NULL` to not insert anything.

`ilen` can be zero or `strlen(text)`, which 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. If `ilen` is zero, `strlen(text)` is used instead.

`b` and `e` are clamped to the `0..size()` range, so it is safe to pass any values. `b`, `e`, and `ilen` are used as numbers of bytes (not characters), where `b` and `e` count from 0 to size() (end of buffer).

If `b` and/or `e` don't point to a valid UTF-8 character boundary, they are adjusted to the previous (`b`) or the next (`e`) valid UTF-8 character boundary, resp..

If the current number of characters in the buffer minus deleted characters plus inserted characters in `text` would overflow the number of allowed characters (maximum_size()), then only the first characters of the string are inserted, so that maximum_size() is not exceeded.

cut() and insert() are just inline functions that call replace().

Parameters

  [in] | b | beginning index of text to be deleted
  [in] | e | ending index of text to be deleted and insertion position
  [in] | text | string that will be inserted
  [in] | ilen | length of `text` or 0 for `nul` terminated strings

Returns
  0 if nothing changed

Note
  If `text` does not point to a valid UTF-8 character or includes invalid UTF-8 sequences, the text is inserted nevertheless (counting invalid UTF-8 bytes as one character each).

void Fl_Input_::resize | ( | int | X,
|  | int | Y,
|  | int | W,
|  | int | H
| ) |  |

virtual

Changes the size of the widget.

This call updates the text layout so that the cursor is visible.

Parameters

  [in] | X,Y,W,H | new size of the widget

See Also
  Fl_Widget::resize(int, int, int, int)

Reimplemented from Fl_Widget.

int Fl_Input_::shortcut | ( |  | ) | const

inline

Return the shortcut key associated with this widget.

Returns
  shortcut keystroke

See Also
  Fl_Button::shortcut()

void Fl_Input_::shortcut | ( | int | s | ) |

inline

Sets the shortcut key associated with this widget.

Pressing the shortcut key gives text editing focus to this widget.

Parameters

  [in] | s | new shortcut keystroke

See Also
  Fl_Button::shortcut()

int Fl_Input_::size | ( |  | ) | const

inline

Returns the number of bytes in value().

This may be greater than `strlen(value())` if there are `nul` characters in the text.

Returns
  number of bytes in the text

void Fl_Input_::size | ( | int | W,
|  | int | H
| ) |  |

inline

Sets the width and height of this widget.

Parameters

  [in] | W,H | new width and height

See Also
  Fl_Widget::size(int, int)

int Fl_Input_::static_value | ( | const char * | str | ) |

Changes the widget text.

This function changes the text and sets the mark and the point to the end of it. The string is not copied. If the user edits the string it is copied to the internal buffer then. This can save a great deal of time and memory if your program is rapidly changing the values of text fields, but this will only work if the passed string remains unchanged until either the Fl_Input is destroyed or value() is called again.

Parameters

  [in] | str | the new text

Returns
  non-zero if the new value is different than the current one

int Fl_Input_::static_value | ( | const char * | str,
|  | int | len
| ) |  |

Changes the widget text.

This function changes the text and sets the mark and the point to the end of it. The string is not copied. If the user edits the string it is copied to the internal buffer then. This can save a great deal of time and memory if your program is rapidly changing the values of text fields, but this will only work if the passed string remains unchanged until either the Fl_Input is destroyed or value() is called again.

You can use the `len` parameter to directly set the length if you know it already or want to put `nul` characters in the text.

Parameters

  [in] | str | the new text
  [in] | len | the length of the new text

Returns
  non-zero if the new value is different than the current one

void Fl_Input_::tab_nav | ( | int | val | ) |

inline

Sets whether the Tab key does focus navigation, or inserts tab characters into Fl_Multiline_Input.

By default this flag is enabled to provide the 'normal' behavior most users expect; Tab navigates focus to the next widget. To inserting an actual Tab character, users can use Ctrl-I or copy/paste.

Disabling this flag gives the old FLTK behavior where Tab inserts a tab character into the text field, in which case only the mouse can be used to navigate to the next field.

History: This flag was provided for backwards support of FLTK's old 1.1.x behavior where Tab inserts a tab character instead of navigating focus to the next widget. This behavior was unique to Fl_Multiline_Input. With the advent of Fl_Text_Editor, this old behavior has been deprecated.

Parameters

  [in] | val | If `val` is 1, Tab advances focus (default). If `val` is 0, Tab inserts a tab character (old FLTK behavior).

int Fl_Input_::tab_nav | ( |  | ) | const

inline

Gets whether the Tab key causes focus navigation in multiline input fields or not.

If enabled (default), hitting Tab causes focus navigation to the next widget.

If disabled, hitting Tab inserts a tab character into the text field.

Returns
  1 if Tab advances focus (default), 0 if Tab inserts tab characters.

See Also
  tab_nav(int)

Fl_Color Fl_Input_::textcolor | ( |  | ) | const

inline

Gets the color of the text in the input field.

Returns
  the text color

See Also
  textcolor(Fl_Color)

void Fl_Input_::textcolor | ( | Fl_Color | n | ) |

inline

Sets the color of the text in the input field.

The text color defaults to `FL_FOREGROUND_COLOR`.

Parameters

  [in] | n | new text color

See Also
  textcolor()

Fl_Font Fl_Input_::textfont | ( |  | ) | const

inline

Gets the font of the text in the input field.

Returns
  the current Fl_Font index

void Fl_Input_::textfont | ( | Fl_Font | s | ) |

inline

Sets the font of the text in the input field.

The text font defaults to `FL_HELVETICA`.

Parameters

  [in] | s | the new text font

Fl_Fontsize Fl_Input_::textsize | ( |  | ) | const

inline

Gets the size of the text in the input field.

Returns
  the text height in pixels

void Fl_Input_::textsize | ( | Fl_Fontsize | s | ) |

inline

Sets the size of the text in the input field.

The text height defaults to `FL_NORMAL_SIZE`.

Parameters

  [in] | s | the new font height in pixel units

int Fl_Input_::undo | ( |  | ) |

Undoes previous changes to the text buffer.

This call undoes a number of previous calls to replace().

Returns
  non-zero if any change was made.

int Fl_Input_::up_down_position | ( | int | i,
|  | int | keepmark = `0`
| ) |  |

protected

Moves the cursor to the column given by `up_down_pos`.

This function is helpful when implementing up and down cursor movement. It moves the cursor from the beginning of a line to the column indicated by the global variable `up_down_pos` in pixel units.

Parameters

  [in] | i | index into the beginning of a line of text
  [in] | keepmark | if set, move only the cursor, but not the mark

Returns
  index to new cursor position

int Fl_Input_::value | ( | const char * | str | ) |

Changes the widget text.

This function changes the text and sets the mark and the point to the end of it. The string is copied to the internal buffer. Passing `NULL` is the same as `""`.

Parameters

  [in] | str | the new text

Returns
  non-zero if the new value is different than the current one

See Also
  Fl_Input_::value(const char* str, int len), Fl_Input_::value()

int Fl_Input_::value | ( | const char * | str,
|  | int | len
| ) |  |

Changes the widget text.

This function changes the text and sets the mark and the point to the end of it. The string is copied to the internal buffer. Passing `NULL` is the same as "".

You can use the `length` parameter to directly set the length if you know it already or want to put `nul` characters in the text.

Parameters

  [in] | str | the new text
  [in] | len | the length of the new text

Returns
  non-zero if the new value is different than the current one

See Also
  Fl_Input_::value(const char* str), Fl_Input_::value()

const char* Fl_Input_::value | ( |  | ) | const

inline

Returns the text displayed in the widget.

This function returns the current value, which is a pointer to the internal buffer and is valid only until the next event is handled.

Returns
  pointer to an internal buffer - do not free() this

See Also
  Fl_Input_::value(const char*)

int Fl_Input_::word_end | ( | int | i | ) | const

protected

Finds the end of a word.

This call calculates the end of a word based on the given index `i`. Calling this function repeatedly will move forwards to the end of the text.

Parameters

  [in] | i | starting index for the search

Returns
  end of the word

int Fl_Input_::word_start | ( | int | i | ) | const

protected

Finds the start of a word.

This call calculates the start of a word based on the given index `i`. Calling this function repeatedly will move backwards to the beginning of the text.

Parameters

  [in] | i | starting index for the search

Returns
  start of the word

int Fl_Input_::wrap | ( |  | ) | const

inline

Gets the word wrapping state of the input field.

Word wrap is only functional with multi-line input fields.

void Fl_Input_::wrap | ( | int | b | ) |

inline

Sets the word wrapping state of the input field.

Word wrap is only functional with multi-line input fields.

The documentation for this class was generated from the following files:

- Fl_Input_.H
- Fl_Input_.cxx

- © 1998-2012 by Bill Spitzak and others.