Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::TextControl Class Reference

The base class for presenting text to the user. More...

#include <vcf/ApplicationKit/TextControl.h>

Inheritance diagram for VCF::TextControl:

VCF::Control VCF::UIComponent VCF::AbstractView VCF::Component VCF::View VCF::ObjectWithCallbacks VCF::Object VCF::MultilineTextControl List of all members.

Public Member Functions

 TextControl (const bool &multiLineControl=false)
virtual ~TextControl ()
void init ()
virtual void paint (GraphicsContext *context)
 Paints the control.
void setTextModel (TextModel *model)
TextModelgetTextModel ()
String getText ()
void setText (const String &val)
uint32 getCaretPosition ()
void setCaretPosition (const uint32 &caretPos)
void setRightMargin (const double &rightMargin)
void setLeftMargin (const double &leftMargin)
uint32 getLineCount ()
uint32 getCurrentLinePosition ()
double getLeftMargin ()
double getRightMargin ()
PointgetPositionFromCharIndex (const uint32 &index)
uint32 getCharIndexFromPosition (Point *point)
uint32 getSelectionStart ()
 returns the zero based index that indicates where the current selection begins.
uint32 getSelectionCount ()
 gives the number of characters selected.
void setSelectionMark (const uint32 &start, const uint32 &count)
void selectAll ()
void getStyle (unsigned int start, unsigned int length, Dictionary &styles)
void setStyle (unsigned int start, unsigned int length, Dictionary &styles)
void setDefaultStyle (Dictionary &styles)
String getSelectedText ()
void replaceSelectedText (const String &text)
virtual double getPreferredHeight ()
 returns the preferred height for this control.
virtual void handleEvent (Event *event)
 This gets called by the ControlPeer for any windowing system mouse events, as well as for any windowing system keyboard events and for any windowing system events like size changes, position changes, etc.
bool getReadOnly ()
void setReadOnly (const bool &val)
virtual bool supportsMultiLinedText ()
void disableStandardAccelerators ()
 Call this function to disable the standard, built-in, accelerator's that make sure the platforms standard shortcut's for cut, copy, paste, undo, and redo get handled by the underlying platform.
void enableStandardAccelerators ()
 Call this function to enable the standard, built-in, accelerator's that make sure the platforms standard shortcut's for cut, copy, paste, undo, and redo get handled by the underlying platform.
void cut ()
 Cuts the selection and places it in the clipboard.
void copy ()
 Copies the selection and places it in the clipboard.
void paste ()
 Pastes the contents of the clipboard into the text control.
bool canUndo ()
 Returns a bool to indicate whether or not an undo operation can be performed.
bool canRedo ()
 Returns a bool to indicate whether or not a redo operation can be performed.
void undo ()
 Undoes the last operation.
void redo ()
 Redoes the last operation.
void setTextWrapping (const bool &val)
 This toggles word wrapping.
bool getTextWrapping ()
virtual bool generatePropertyValue (const String &fullPropertyName, Property *property, VariantData *value, String &strValue)

Public Attributes

VCF::Delegate TextModelDelegate
VCF::Delegate SelectionChanged

Protected Member Functions

void undoAccelerator (Event *e)
 handlers of some standard accelerator events.
void redoAccelerator (Event *e)
void cutAccelerator (Event *e)
void copyAccelerator (Event *e)
void pasteAccelerator (Event *e)
void selectAllAccelerator (Event *e)
virtual void gotFocus (FocusEvent *event)
 handler called when the control is getting the focus.

Protected Attributes

TextEditPeertextPeer_
bool readOnly_

Detailed Description

The base class for presenting text to the user.

The text can be plain text, or styled text, i.e. text with multiple styles.

The TextControl is only for editing or presenting a single line of text. For editing multiple lines of text, please see the MultilineTextControl.

All text controls contain a TextModel, that stores the actual text data.

See also:
MultilineTextControl

TextModel


Constructor & Destructor Documentation

VCF::TextControl::TextControl const bool &  multiLineControl = false  ) 
 

virtual VCF::TextControl::~TextControl  )  [virtual]
 


Member Function Documentation

bool VCF::TextControl::canRedo  ) 
 

Returns a bool to indicate whether or not a redo operation can be performed.

Returns:
bool true if an a redo operation can be performed. This indicates that a call to redo() will succeed. Returns false to indicate no redo is possible and any calls to redo() will be no-ops.

bool VCF::TextControl::canUndo  ) 
 

Returns a bool to indicate whether or not an undo operation can be performed.

Returns:
bool true if an an undo operation can be performed. This indicates that a call to undo() will succeed. Returns false to indicate no undo is possible and any calls to undo() will be no-ops.

void VCF::TextControl::copy  ) 
 

Copies the selection and places it in the clipboard.

This uses the standard copy implementation provided by the underlying windowing platform.

void VCF::TextControl::copyAccelerator Event e  )  [protected]
 

void VCF::TextControl::cut  ) 
 

Cuts the selection and places it in the clipboard.

This uses the standard cut implementation provided by the underlying windowing platform.

void VCF::TextControl::cutAccelerator Event e  )  [protected]
 

void VCF::TextControl::disableStandardAccelerators  ) 
 

Call this function to disable the standard, built-in, accelerator's that make sure the platforms standard shortcut's for cut, copy, paste, undo, and redo get handled by the underlying platform.

You may choose to turn these off if your use of a text control provides more advanced cut/copy/paste/undo/redo support. If you're using the DocView arcichtecture you'll almost certainly want to turn them off.

void VCF::TextControl::enableStandardAccelerators  ) 
 

Call this function to enable the standard, built-in, accelerator's that make sure the platforms standard shortcut's for cut, copy, paste, undo, and redo get handled by the underlying platform.

By default these are enabled for every text control.

virtual bool VCF::TextControl::generatePropertyValue const String fullPropertyName,
Property property,
VariantData value,
String strValue
[virtual]
 

Reimplemented from VCF::Control.

uint32 VCF::TextControl::getCaretPosition  ) 
 

uint32 VCF::TextControl::getCharIndexFromPosition Point point  ) 
 

uint32 VCF::TextControl::getCurrentLinePosition  ) 
 

double VCF::TextControl::getLeftMargin  ) 
 

uint32 VCF::TextControl::getLineCount  ) 
 

Point* VCF::TextControl::getPositionFromCharIndex const uint32 index  ) 
 

virtual double VCF::TextControl::getPreferredHeight  )  [virtual]
 

returns the preferred height for this control.

This is used when determing the height of the control when it is first created. Override it to provide a different value that is more acceptable for your control's initial display size.

Reimplemented from VCF::Control.

bool VCF::TextControl::getReadOnly  )  [inline]
 

double VCF::TextControl::getRightMargin  ) 
 

String VCF::TextControl::getSelectedText  ) 
 

uint32 VCF::TextControl::getSelectionCount  ) 
 

gives the number of characters selected.

Returns:
uint32, the number of characters selected, a return value of 0 indicates that no characters are currently selected.

uint32 VCF::TextControl::getSelectionStart  ) 
 

returns the zero based index that indicates where the current selection begins.

It may be the same index that getCaretPosition() returns

void VCF::TextControl::getStyle unsigned int  start,
unsigned int  length,
Dictionary styles
 

String VCF::TextControl::getText  )  [inline]
 

TextModel* VCF::TextControl::getTextModel  ) 
 

bool VCF::TextControl::getTextWrapping  ) 
 

virtual void VCF::TextControl::gotFocus FocusEvent event  )  [protected, virtual]
 

handler called when the control is getting the focus.

By default it is added only to a single line control, so we can select all the text whenever we get the focus.

Reimplemented from VCF::Control.

Reimplemented in VCF::MultilineTextControl.

virtual void VCF::TextControl::handleEvent Event event  )  [virtual]
 

This gets called by the ControlPeer for any windowing system mouse events, as well as for any windowing system keyboard events and for any windowing system events like size changes, position changes, etc.

Once inside the event the Control determines the type, and behaves accordingly, as well as notifying any appropriate listeners.

Reimplemented from VCF::Control.

void VCF::TextControl::init  ) 
 

virtual void VCF::TextControl::paint GraphicsContext context  )  [virtual]
 

Paints the control.

Called by the underlying windowing system whenever the control needs to be painted. Note that in some cases the GraphicsContext passed in to this method may not be the same pointer as the GraphicsContext that the control holds itself. During the paint() method you should only use the context value for all your drawing and not the one returned in getContext(). The value returned by getContext() should be used for drawing that takes place outside of the paint() method.

If the control allows paint notification, then the framework will fire an event to the BeforeControlPainted delegate prior to calling the control's paint() method. After the paint() method has returned, if the control allows paint notification, the framework will fire an event to the AfterControlPainted delegate. This allows outside observers to take part in the paint cycle, but beware that this does come at a bit of a cost, so use this feature sparingly.

Note: This should NEVER be called by programmers using the VCF, it will be called for you during the course of your applications native event loop, and is only here for providing custom drawing routines for controls. In other words: you implement it, you never call it yourself.

See also:
getAllowPaintNotification

Implements VCF::Control.

void VCF::TextControl::paste  ) 
 

Pastes the contents of the clipboard into the text control.

This uses the standard paste implementation provided by the underlying windowing platform.

void VCF::TextControl::pasteAccelerator Event e  )  [protected]
 

void VCF::TextControl::redo  ) 
 

Redoes the last operation.

This uses the standard redo implementation provided by the underlying windowing platform.

void VCF::TextControl::redoAccelerator Event e  )  [protected]
 

void VCF::TextControl::replaceSelectedText const String text  ) 
 

void VCF::TextControl::selectAll  ) 
 

void VCF::TextControl::selectAllAccelerator Event e  )  [protected]
 

void VCF::TextControl::setCaretPosition const uint32 caretPos  ) 
 

void VCF::TextControl::setDefaultStyle Dictionary styles  ) 
 

void VCF::TextControl::setLeftMargin const double &  leftMargin  ) 
 

void VCF::TextControl::setReadOnly const bool &  val  ) 
 

void VCF::TextControl::setRightMargin const double &  rightMargin  ) 
 

void VCF::TextControl::setSelectionMark const uint32 start,
const uint32 count
 

void VCF::TextControl::setStyle unsigned int  start,
unsigned int  length,
Dictionary styles
 

void VCF::TextControl::setText const String val  )  [inline]
 

void VCF::TextControl::setTextModel TextModel model  ) 
 

void VCF::TextControl::setTextWrapping const bool &  val  ) 
 

This toggles word wrapping.

If you turn off word wrapping the scroll bars will show up autmatically (if they are needed). If you turn on word wrapping the scroll bars will disapear.

virtual bool VCF::TextControl::supportsMultiLinedText  )  [inline, virtual]
 

Reimplemented in VCF::MultilineTextControl.

void VCF::TextControl::undo  ) 
 

Undoes the last operation.

This uses the standard undo implementation provided by the underlying windowing platform.

void VCF::TextControl::undoAccelerator Event e  )  [protected]
 

handlers of some standard accelerator events.


Member Data Documentation

bool VCF::TextControl::readOnly_ [protected]
 

VCF::Delegate VCF::TextControl::SelectionChanged
 

VCF::Delegate VCF::TextControl::TextModelDelegate
 

TextEditPeer* VCF::TextControl::textPeer_ [protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information