Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

TInputLine Class Reference

Provides a basic input line string editor. More...

#include <dialogs.h>

Inheritance diagram for TInputLine::

TView TObject TStreamable TFileInputLine List of all members.

Public Methods

 TInputLine (const TRect &bounds, int aMaxLen, TValidator *aValid=0)
 ~TInputLine ()
virtual ushort dataSize ()
virtual void draw ()
virtual void getData (void *rec)
virtual TPalettegetPalette () const
virtual void handleEvent (TEvent &event)
void selectAll (Boolean enable)
virtual void setData (void *rec)
virtual void setState (ushort aState, Boolean enable)
virtual Boolean valid (ushort cmd)
void setValidator (TValidator *aValid)

Static Public Methods

TStreamablebuild ()

Public Attributes

char* data
int maxLen
int curPos
int firstPos
int selStart
int selEnd

Static Public Attributes

const char* const name

Protected Methods

 TInputLine (StreamableInit)
virtual void write (opstream &os)
virtual void* read (ipstream &is)

Detailed Description

A TInputLine object provides a basic input line string editor. It handles keyboard input and mouse clicks and drags for block marking and a variety of line editing functions.

Definition at line 261 of file dialogs.h.


Constructor & Destructor Documentation

TInputLine::TInputLine ( const TRect & bounds,
int aMaxLen,
TValidator * aValid = 0 )
 

Creates an input box control with the given values by calling TView::TView(bounds).

See also:
TView::TView

Variable state is then set to sfCursorVis, options is set to (ofSelectable | ofFirstClick), and maxLen is set to `aMaxLen'.

Memory is allocated and cleared for `aMaxlen' + 1 bytes and the data data member set to point at this allocation.

An input line is sometimes used with a validator. Data validators are objects that detect when the user has entered valid or invalid information. In case of invalid data, the validator will provide appropriate feedback to the user.

See also:
TValidator

TInputLine::~TInputLine ( )
 

Deletes the data memory allocation, then calls TView destructor to destroy the TInputLine object.

See also:
TView::~TView

TInputLine::TInputLine ( StreamableInit ) [protected]
 

Each streamable class needs a "builder" to allocate the correct memory for its objects together with the initialized virtual table pointers.

This is achieved by calling this constructor with an argument of type StreamableInit.


Member Function Documentation

TStreamable * TInputLine::build ( ) [static]
 

Called to create an object in certain stream-reading situations.

Reimplemented from TView.

Reimplemented in TFileInputLine.

ushort TInputLine::dataSize ( ) [virtual]
 

Returns the size of the record for getData() and setData() calls. By default, it returns maxLen + 1.

Override this member function if you define descendants to handle other data types.

Reimplemented from TView.

void TInputLine::draw ( ) [virtual]
 

Draws the input box and its data.

The box is drawn with the appropriate colors depending on whether the box is sfFocused (that is, whether the box view owns the cursor), and arrows are drawn if the input string exceeds the size of the view (in either or both directions).

See also:
TView::state

Any selected (block-marked) characters are drawn with the appropriate palette.

Reimplemented from TView.

void TInputLine::getData ( void * rec ) [virtual]
 

Writes the number of bytes (obtained from a call to dataSize()) from the data string to the array given by `rec'. Used with setData() for a variety of applications; for example, temporary storage, or passing on the input string to other views.

Override getData() if you define TInputLine descendants to handle non-string data types. You can also use getData() to convert from a string to other data types after editing by TInputLine.

Reimplemented from TView.

TPalette & TInputLine::getPalette ( ) const [virtual]
 

Returns the default palette string.

Reimplemented from TView.

void TInputLine::handleEvent ( TEvent & event ) [virtual]
 

Calls TView::handleEvent(), then handles all mouse and keyboard events if the input box is selected.

This member function implements the standard editing capability of the input box. Editing features include:

  1. block marking with mouse click and drag
  2. block deletion
  3. insert or overwrite control with automatic cursor shape change
  4. automatic and manual scrolling as required (depending on relative sizes of the data string and size.x); see size
  5. manual horizontal scrolling via mouse clicks on the arrow icons
  6. manual cursor movement by arrow, Home, and End keys (and their standard control-key equivalents)
  7. character and block deletion with Del and Ctrl-G
The view is redrawn as required and the TInputLine data members are adjusted appropriately.

Reimplemented from TView.

Reimplemented in TFileInputLine.

void * TInputLine::read ( ipstream & is ) [protected, virtual]
 

Reads from the input stream `is'.

Reimplemented from TView.

void TInputLine::selectAll ( Boolean enable )
 

Sets curPos, firstPos and selStart data members to 0.

If `enable' is set to True, selEnd is set to the length of the data string, thereby selecting the whole input line; if `enable' is set to False, selEnd is set to 0, thereby deselecting the whole line.

Finally, the view is redrawn by calling TView::drawView().

void TInputLine::setData ( void * rec ) [virtual]
 

By default, copies the number of bytes (as returned by dataSize()) from the `rec' array to the data string, and then calls selectAll(True). This zeros curPos, firstPos and selStart.

See also:
TInputLine::selectAll

Finally, TView::drawView() is called to redraw the input box.

Override setData() if you define descendants to handle non-string data types. You also use setData() to convert other data types to a string for editing by TInputLine.

Reimplemented from TView.

void TInputLine::setState ( ushort aState,
Boolean enable ) [virtual]
 

Called when the input box needs redrawing (for example, if the palette is changed) following a change of state.

Calls TView::setState() to set or clear the view's state with the given `aState' bit(s).

Then if `aState' is sfSelected (or sfActive and the input box is sfSelected), selectAll(enable) is called (which, in turn, calls TView::drawView()).

See also:
TInputLine::selectAll

Reimplemented from TView.

void TInputLine::setValidator ( TValidator * aValid )
 

Undocumented.

Boolean TInputLine::valid ( ushort cmd ) [virtual]
 

Undocumented.

Reimplemented from TView.

void TInputLine::write ( opstream & os ) [protected, virtual]
 

Writes to the output stream `os'.

Reimplemented from TView.


Member Data Documentation

int TInputLine::curPos
 

Index to insertion point (that is, to the current cursor position).

Definition at line 404 of file dialogs.h.

char * TInputLine::data
 

The string containing the edited information.

Definition at line 396 of file dialogs.h.

int TInputLine::firstPos
 

Index to the first displayed character.

Definition at line 408 of file dialogs.h.

int TInputLine::maxLen
 

Maximum length allowed for string to grow (excluding the final 0).

Definition at line 400 of file dialogs.h.

const char *const TInputLine::name [static]
 

Undocumented.

Reimplemented from TView.

Reimplemented in TFileInputLine.

Definition at line 463 of file dialogs.h.

int TInputLine::selEnd
 

Index to the end of the selection area (that is, to the last character block marked).

Definition at line 418 of file dialogs.h.

int TInputLine::selStart
 

Index to the beginning of the selection area (that is, to the first character block marked).

Definition at line 413 of file dialogs.h.


The documentation for this class was generated from the following file:
Generated at Sat Sep 22 20:19:27 2001 for TVision by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001