Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

os::TextView Class Reference

#include <textview.h>

Inheritance diagram for os::TextView::

os::Control os::View os::Invoker os::Handler List of all members.

Public Types

typedef std::vector< Stringbuffer_type
enum  {
  EI_CONTENT_CHANGED = 0x0001,
  EI_ENTER_PRESSED = 0x0002,
  EI_ESC_PRESSED = 0x0004,
  EI_FOCUS_LOST = 0x0008,
  EI_CURSOR_MOVED = 0x0010,
  EI_SELECTION_CHANGED = 0x0020,
  EI_MAX_SIZE_REACHED = 0x0040,
  EI_MAX_SIZE_LEFT = 0x0080
}

Public Methods

 TextView (const Rect &cFrame, const char *pzTitle, const char *pzBuffer, uint32 nResizeMask=CF_FOLLOW_LEFT|CF_FOLLOW_TOP, uint32 nFlags=WID_WILL_DRAW|WID_FULL_UPDATE_ON_RESIZE)
 os::TextView constructor. More...

 ~TextView ()
virtual void MouseMove (const Point &cNewPos, int nCode, uint32 nButtons, Message *pcData)
 Hook called by the system when the mouse is moved. More...

virtual void MouseDown (const Point &cPosition, uint32 nButtons)
 Hook called by the system when a mouse button is pressed. More...

virtual void MouseUp (const Point &cPosition, uint32 nButtons, Message *pcData)
 Hook called by the system when a mouse button is release. More...

virtual void WheelMoved (const Point &cDelta)
 Hook called by the system when the scroll-wheel is rotated. More...

virtual void KeyDown (const char *pzString, const char *pzRawString, uint32 nQualifiers)
 Hook called by the system when a key is pressed while the view has focus. More...

virtual void LabelChanged (const std::string &cNewLabel)
virtual void EnableStatusChanged (bool bIsEnabled)
virtual bool Invoked (Message *pcMessage)
 Intercept outgoing messages. More...

virtual void Activated (bool bIsActive)
 Hook called when the view gain or loose focus. More...

virtual void SetValue (Variant cValue, bool bInvoke=true)
virtual Variant GetValue () const
const ViewGetEditor () const
 Get a pointer to the editor view. More...

void SetMultiLine (bool bMultiLine=true)
 Enable/disable multiline mode. More...

bool GetMultiLine ()
 Get the current editor mode. More...

void SetPasswordMode (bool bPassword=true)
 Disable/enable password mode. More...

bool GetPasswordMode () const
 Get the current echo mode. More...

void SetNumeric (bool bNumeric)
 Set the view in "numeric" mode. More...

bool GetNumeric () const
 Check if the view is in numeric mode. More...

void SetReadOnly (bool bFlag=true)
bool GetReadOnly () const
int GetMaxUndoSize () const
void SetMaxUndoSize (int nSize)
uint32 GetEventMask () const
void SetEventMask (uint32 nMask)
void GetRegion (std::string *pcBuffer)
void SetMinPreferredSize (int nWidthChars, int nHeightChars)
IPoint GetMinPreferredSize () const
void SetMaxPreferredSize (int nWidthChars, int nHeightChars)
IPoint GetMaxPreferredSize () const
void MakeCsrVisible ()
void Clear (bool bSendNotify=true)
void Set (const char *pzBuffer, bool bSendNotify=true)
void Insert (const char *pzBuffer, bool bSendNotify=true)
void Select (const IPoint &cStart, const IPoint &cEnd, bool bSendNotify=true)
void SelectAll (bool bSendNotify=true)
void ClearSelection (bool bSendNotify=true)
bool GetSelection (IPoint *pcStart=NULL, IPoint *pcEnd=NULL)
void SetCursor (int x, int y, bool bSelect=false, bool bSendNotify=true)
void SetCursor (const IPoint &cPos, bool bSelect=false, bool bSendNotify=true)
void GetCursor (int *x, int *y) const
IPoint GetCursor () const
void SetMaxLength (size_t nMaxLength)
size_t GetMaxLength () const
size_t GetCurrentLength () const
void Cut (bool bSendNotify=true)
void Copy ()
void Paste (bool bSendNotify=true)
void Delete (bool bSendNotify=true)
const buffer_typeGetBuffer () const
virtual void SetTabOrder (int nOrder)
 Set the keyboard manouvering sorting order. More...

virtual Point GetPreferredSize (bool bLargest) const
virtual bool FilterKeyStroke (const std::string *pcString)
virtual void FontChanged (Font *pcNewFont)
 Called to notify the view that the font has changed. More...

virtual void FrameSized (const Point &cDelta)
 Virtual hook called by the system when the view is resized. More...

virtual void Paint (const Rect &cUpdateRect)
 Called by the system update "damaged" areas of the view. More...

virtual void __TV_reserved1__ ()
virtual void __TV_reserved2__ ()
virtual void __TV_reserved3__ ()
virtual void __TV_reserved4__ ()

Friends

class TextEdit

Detailed Description

Description:
See also:
Author:
Kurt Skauen (kurt@atheos.cx)


Member Typedef Documentation

typedef std::vector<String> os::TextView::buffer_type
 


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
EI_CONTENT_CHANGED  
EI_ENTER_PRESSED  
EI_ESC_PRESSED  
EI_FOCUS_LOST  
EI_CURSOR_MOVED  
EI_SELECTION_CHANGED  
EI_MAX_SIZE_REACHED  
EI_MAX_SIZE_LEFT  


Constructor & Destructor Documentation

TextView::TextView const Rect & cFrame,
const char * pzTitle,
const char * pzText,
uint32 nResizeMask = CF_FOLLOW_LEFT | CF_FOLLOW_TOP,
uint32 nFlags = WID_WILL_DRAW | WID_FULL_UPDATE_ON_RESIZE
 

Description:
The contructor will initialize the text view and set all properties to default values. See the documentaition of each Setxxx() members to see what the verious default values might be.
Parameters:
cFrame   Passed on to the os::View constructor.
pzTitle   Passed on to the os::View constructor (only used to identify the view. Newer rendered anywhere).
pzText   The initial content of the TextView or NULL if the TextView should be empty.
nResizeMask   Passed on to the os::View constructor.
nFlags   Passed on to the os::View constructor.
See also:
os::View::View()
Author:
Kurt Skauen (kurt@atheos.cx)

TextView::~TextView
 


Member Function Documentation

void TextView::Activated bool bIsActive [virtual]
 

Description:
This is a callback member that can be overloaded by derived classes to learn when the view is activated and when it is deactivated. The bIsActive parameter tell whether the focus was lost or gained.

The view has focus when it is the active view in the active window.

Note:
This is a hook function that is called by the system to notify about an event. You should never call this member yourself.

The window is locked when this member is called.
Parameters:
bIsActive   - true if the view gain and false if it loose focus.
See also:
MakeFocus(), WindowActivated()
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::View.

void TextView::Clear bool bSendNotify = true
 

void TextView::ClearSelection bool bSendNotify = true
 

void TextView::Copy
 

void TextView::Cut bool bSendNotify = true
 

void TextView::Delete bool bSendNotify = true
 

void TextView::EnableStatusChanged bool bIsEnabled [virtual]
 

Reimplemented from os::Control.

bool TextView::FilterKeyStroke const std::string * pcString [virtual]
 

void TextView::FontChanged Font * pcNewFont [virtual]
 

Description:
FontChanged() is a virtual hook function that can be overloaded by inheriting classes to track changes to the view's font.

This hook function is called whenver the font is replaced through the View::SetFont() member or if the currently assigned font is modified in a way that whould alter the graphical appearance of the font.

Note:
View::SetFont() will call FontChanged() syncronously and will cause FontChanged() to be called even if the view is not yet added to a window. Changes done to the font-object cause a message to be sendt to the window thread and FontChanged() will then be called asyncronously from the window thread when the message arrive. For this reason it is only possible to track changes done to the font object itself when the view is added to a window.
Parameters:
pcNewFont   Pointer to the affected font (same as returned by GetFont()).

See also:
SetFont(), os::Font
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::View.

void TextView::FrameSized const Point & cDelta [virtual]
 

Description:
Overload this member if you need to know when the view is resized.
Note:
This member is called after the view is resized. If you need the old size you can subtract the cDelta calue from the current size.
Parameters:
cDelta   The distance the bottom/right corner was moved relative to the upper/left corner.
See also:
FrameMoved(), SetFrame, ResizeBy(), ResizeTo()
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::View.

const TextView::buffer_type & TextView::GetBuffer const
 

size_t TextView::GetCurrentLength const
 

IPoint TextView::GetCursor const
 

void TextView::GetCursor int * x,
int * y
const
 

const View * TextView::GetEditor const
 

Description:
The os::TextView class is only responsible for rendering the borders and controlling the scroll-bars. Everything else is handled by a child view crated by the constructor. The os::TextView class provide an interface to all the functionality of the internal editor but in some rare cases it might be useful to have a pointer to this child view.
Note:
In erlier version (before V0.3.3) the only way to change the font used by the text editor was to retrieve the editor and then set it's font manually. This is not neccessarry (and not possible) any longer. Setting the font on the os::TextView class itself will automatically be relected by the internal editor.

Returns:
A const pointer to the internal editor.
Author:
Kurt Skauen (kurt@atheos.cx)

uint32 TextView::GetEventMask const
 

size_t TextView::GetMaxLength const
 

IPoint TextView::GetMaxPreferredSize const
 

int TextView::GetMaxUndoSize const
 

IPoint TextView::GetMinPreferredSize const
 

bool TextView::GetMultiLine
 

Returns:
True if the view is in multiline mode, false if it is in singleline mode.

See also:
SetMultiLine()
Author:
Kurt Skauen (kurt@atheos.cx)

bool TextView::GetNumeric const
 

Returns:
True if numeric mode is enabled, false if it is disabled.
See also:
SetNumeric()
Author:
Kurt Skauen (kurt@atheos.cx)

bool TextView::GetPasswordMode const
 

Returns:
True if the view is in password mode, false if not.
See also:
SetPasswordMode()
Author:
Kurt Skauen (kurt@atheos.cx)

Point TextView::GetPreferredSize bool bLargest const [virtual]
 

Reimplemented from os::View.

bool TextView::GetReadOnly const
 

void TextView::GetRegion std::string * pcBuffer
 

bool TextView::GetSelection IPoint * pcStart = NULL,
IPoint * pcEnd = NULL
 

Variant TextView::GetValue void const [virtual]
 

Reimplemented from os::Control.

void TextView::Insert const char * pzBuffer,
bool bSendNotify = true
 

bool TextView::Invoked Message * pcMessage [virtual]
 

Description:
This member is called from Invoke() just before a message is sendt to the target.

This allow classes that inherits from os::Invoker to add data to or otherwhice modify the message before it is sendt. The message can also be canceled entirely by returning false from this member.

The message passed to Invoked() is a copy of the internal message or the message passed to Invoke() (if any) so any changes made here will not affect the internal message or the message passed to Invoke(). When this method returns the message will imidiatly be sendt to the target and then discarded (unless false is returned in which case the message is simply discarded).

The default implementation of this member does nothing and return true.

Parameters:
pcMessage   Pointer to the message that is about to be sendt. You can do any modification you like to this message (but never delete it).
Returns:
Normally you should return true to indicate that the message should be sendt. You can however return false if you for some reason want to cancel the invokation.
See also:
Invoke(), SetMessage(), SetTarget()
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::Control.

void TextView::KeyDown const char * pzString,
const char * pzRawString,
uint32 nQualifiers
[virtual]
 

Description:
Overload this member if your view need to handle keyboard input. This member is called to allow the view to handle M_KEY_DOWN messages. The most common members are exctracted from the message and passed as parameters but you might need to obtain the raw message with os::Looper::GetCurrentMessage() and find some members yourself if you the data you needed are not passed in.

For example if you need the raw key-code for the pressed key you will have to lookup the "_raw_key" member from the message.

Parameters:
pzString   String containing a single UTF-8 encoded character. This is the character generated by the pressed key according to the current keymap accounting for any qualifiers that might be pressed.
pzRawString   Same as pzString except that the key is converted without accounting for qualifiers. Ie. if 'A' is pressed while pressing <SHIFT> pzString will contain 'A' and pzRawString will contain 'a'.
nQualifiers   Bitmask describing which qualifiers that was active when the key was pressed.

See also:
KeyUp(), os::Looper::GetCurrentMessage()
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::View.

void TextView::LabelChanged const std::string & cNewLabel [virtual]
 

Reimplemented from os::Control.

void TextView::MakeCsrVisible
 

void TextView::MouseDown const Point & cPosition,
uint32 nButtons
[virtual]
 

Description:
This member is called from the window thread whenever a mouse button is clicked above the view. You can overload this member if your view need to know about mouse-down events.

A view will not automatically take focus when clicked so if you want that behaviour you must call MakeFocus() from an overloaded version of this member.

The default implementation of this member will call MouseDown() on it's parent view if one exists.

Parameters:
cPosition   Mouse position in the views coordinate system at the time the mouse was pressed.
nButtons   Index of the pressed button. Buttons start at 1 for the left button, 2 for the right button, 3 for the middle button. Additional buttons might be supported by the mouse driver and will then be assigned numbers from 4 and up.

See also:
MouseUp(), MouseMove(), WheelMoved()
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::View.

void TextView::MouseMove const Point & cNewPos,
int nCode,
uint32 nButtons,
Message * pcData
[virtual]
 

Description:
This member is called from the window thread whenever the mouse is moved above the view or if the view have focus.

Oveload this member if your view need to handle mouse-move events.

The default implementation of this member will call MouseMove() on it's parent view if one exists.

Parameters:
cNewPos   New mouse position given in the views coordinate system.
nCode   Enter/exit code. This is MOUSE_ENTERED when the mouse first enter the view, MOUSE_EXITED when the mouse leaves the view, MOUSE_INSIDE whenever the mouse move withing the boundary of the view and MOUSE_OUTSIDE when the mouse move outside the view (will only happen if the view have focus).
nButtons   Bitmask telling which buttons that are currently pressed. Bit 0 is button 1 (left), bit 1 is button 2 (right), and bit 2 is button 3 (middle), and so on.
pcData   Pointer to a Message object containing the dragged data if the user is in the middle of a drag and drop operation. Otherwise this pointer is NULL. Look at BeginDrag() for a more detailed description of the drag and drop system.

See also:
MouseDown(), MouseUp(), WheelMoved(), BeginDrag()
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::View.

void TextView::MouseUp const Point & cPosition,
uint32 nButtons,
Message * pcData
[virtual]
 

Description:
This member is called from the window thread whenever a mouse button is released above the view. You can overload this member if your view need to know about mouse-up events or if your view support drag and drop.

If mouse-up was the result of ending a drag and drop operation the pcData member will point to a Message containing the dragged data. Look at BeginDrag() for a more detailed description of the drag and drop system.

The default implementation of this member will call MouseDown() on it's parent view if one exists.

Parameters:
cPosition   Mouse position in the views coordinate system at the time the mouse was pressed.
nButtons   Index of the pressed button. Buttons start at 1 for the left button, 2 for the right button, 3 for the middle button. Additional buttons might be supported by the mouse driver and will then be assigned numbers from 4 and up.
pcData   Pointer to a Message object containing the dragged data if this mouse-up was the end of a drag and drop operation. If no data was dragged it will be NULL.

See also:
MouseDown(), MouseMove(), WheelMoved()
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::View.

void TextView::Paint const Rect & cUpdateRect [virtual]
 

Description:
Note:
Warning:
Parameters:
cUpdateRect   A rectangle enclosing all damaged areas. This is just a rough "worst-case", further fine-grained clipping will be performed by the Application Server to avoid updating non-damaged pixels and make the update as fast and flicker-free as possible.

See also:
Invalidate(), Flush()
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::View.

void TextView::Paste bool bSendNotify = true
 

void TextView::Select const IPoint & cStart,
const IPoint & cEnd,
bool bSendNotify = true
 

void TextView::SelectAll bool bSendNotify = true
 

void TextView::Set const char * pzBuffer,
bool bSendNotify = true
 

void TextView::SetCursor const IPoint & cPos,
bool bSelect = false,
bool bSendNotify = true
 

void TextView::SetCursor int x,
int y,
bool bSelect = false,
bool bSendNotify = true
 

void TextView::SetEventMask uint32 nMask
 

void TextView::SetMaxLength size_t nMaxLength
 

void TextView::SetMaxPreferredSize int nWidthChars,
int nHeightChars
 

void TextView::SetMaxUndoSize int nSize
 

void TextView::SetMinPreferredSize int nWidthChars,
int nHeightChars
 

void TextView::SetMultiLine bool bMultiLine = true
 

Description:
The TextView have two quite different modes. Multiline and single line.

In singleline mode it will only allow a single line of text and it will send the EI_ENTER_PRESSED event (if not masked out) when the user press <ENTER> or <RETURN>. It will also always center the single line vertically inside the views boundary and it will never display scroll bars.

In multiline mode it will allow multiple lines of text and <ENTER> and <RETURN> will insert a new line instead of trigging the EI_ENTER_PRESSED event. The view will automatically add and remove vertical and horizontal scroll-bars as needed.

Parameters:
bMultiLine   True to set the view in multiline mode or false to set it in singleline mode.

See also:
GetMultiLine(), SetEventMask(), SetPasswordMode()
Author:
Kurt Skauen (kurt@atheos.cx)

void TextView::SetNumeric bool bNumeric
 

Description:
When numeric mode is enabled the TextView will only accept valid numbers to be typed.

Digits are always accepted. Punctuation (.) is accepted once. "E" is accepted once. Plus and minus (+/-) is accepted as the first character of the line or as the first character after an "E".

If you have other restrictions on what should be accepted as input (for example hexadecimal numbers) you can overload the FilterKeyStroke() hook and filter the user input yourself.

Parameters:
bNumeric   True to enable numeric mode, false to disable it.
See also:
GetNumeric(), FilterKeyStroke()
Author:
Kurt Skauen (kurt@atheos.cx)

void TextView::SetPasswordMode bool bPassword = true
 

Description:
When setting the view in password mode it will render all characters as asterics (*) to hide it's content and it will not allow the user to copy the content to the clipboard.
Note:
Only single-line TextView's should be set in password mode.
Parameters:
bPassword   True to enable password mode, false to disable it.
See also:
GetPasswordMode(), SetMultiLine()
Author:
Kurt Skauen (kurt@atheos.cx)

void TextView::SetReadOnly bool bFlag = true
 

void TextView::SetTabOrder int nOrder [virtual]
 

Description:
Set the value that will be returned by GetTabOrder().
Parameters:
nOrder   - The sorting order.
See also:
GetTabOrder()
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::View.

void TextView::SetValue Variant cValue,
bool bInvoke = true
[virtual]
 

Reimplemented from os::Control.

void TextView::WheelMoved const Point & cDelta [virtual]
 

Description:
This member is called from the window thread whenever the user rotates the scroll wheel with the mouse pointer above this view.

The default implementation of this member will call WheelMoved() on it's parent view if one exists.

Since:
V0.3.7
Parameters:
cDelta   Delta movement. Normally only the y value is used but it is possible for the mouse driver to also support horizontal scroll wheel functionality. The delta value is normally +/- 1.0 for each "click" on the wheel.
See also:
MouseMove(), MouseDown(), MouseUp()
Author:
Kurt Skauen (kurt@atheos.cx)

Reimplemented from os::View.

void TextView::__TV_reserved1__ [virtual]
 

For internal use only.

void TextView::__TV_reserved2__ [virtual]
 

For internal use only.

void TextView::__TV_reserved3__ [virtual]
 

For internal use only.

void TextView::__TV_reserved4__ [virtual]
 

For internal use only.


Friends And Related Function Documentation

friend class TextEdit [friend]
 


Generated at Tue Sep 11 15:27:56 2001 for AtheOS higlevel API by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001