CodeView  Version0.4
 All Classes Functions Variables
Public Types | Public Member Functions | List of all members
cv::CodeView Class Reference

A programmers editor widget for Atheos. More...

#include <codeview.h>

Inheritance diagram for cv::CodeView:

Public Types

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
}
 

Public Member Functions

 CodeView (const os::Rect &, const os::String &name, const os::String &buffer, uint32 resizeMask=os::CF_FOLLOW_LEFT||os::CF_FOLLOW_TOP, uint32 flags=os::WID_WILL_DRAW||os::WID_FULL_UPDATE_ON_RESIZE)
 Constructor. More...
 
void Paint (const os::Rect &)
 Paints the CodeView. More...
 
void EnableStatusChanged (bool enable)
 Overridden from os::Control.
 
void FontChanged (os::Font *f)
 Overridden from os::View.
 
virtual void MakeFocus (bool=true)
 Overridden from os::View.
 
virtual bool HasFocus ()
 Overridden from os::View.
 
bool Invoked (os::Message *)
 Overridden from os::Control.
 
void SetReadOnly (bool flag=true)
 Sets the readonly flag. More...
 
bool GetReadOnly () const
 Gets the readonly flag. More...
 
int GetMaxUndoSize () const
 Gets the maximum numer of undo steps kept. More...
 
void SetMaxUndoSize (int size)
 Sets the maximum number of undo steps to keep. More...
 
uint32 GetEventMask () const
 Gets the event mask. More...
 
void SetEventMask (uint32 mask)
 Sets the event mask. More...
 
void GetRegion (os::String *buffer)
 Gets the currently selected region. More...
 
void MakeCsrVisible ()
 Ensure the cursor is visible in the view.
 
void Clear (bool sendNotify=true)
 Removes all text from the view. More...
 
void Set (const char *text, bool sendNotify=true)
 Sets the text in the view. More...
 
void Insert (const char *text, bool sendNotify=true)
 Inserts text into the view The text is inserted at the current cursor position. More...
 
void Insert (const os::IPoint &pos, const char *text, bool sendNotify=true)
 Inserts text into the view. More...
 
void Select (const os::IPoint &start, const os::IPoint &end, bool sendNotify=true)
 Selects text in the view. More...
 
void SelectAll (bool sendNotify=true)
 Select all text in the view. More...
 
void ClearSelection (bool sendNotify=true)
 Unselects the current selection. More...
 
void SetCursor (int x, int y, bool select=false, bool sendNotify=true)
 Sets the cursor position. More...
 
void SetCursor (const os::IPoint &pos, bool select=false, bool sendNotify=true)
 Sets the cursor position. More...
 
os::IPoint GetCursor () const
 Gets the current cursor position. More...
 
size_t GetCurrentLength () const
 Gets the length of the text in the view. More...
 
void Cut (bool sendNotify=true)
 Cut selected text, and put it on the ClipBoard. More...
 
void Copy ()
 Copy the selected text and put it on the ClipBoard.
 
void Paste (bool sendNotify=true)
 Paste the content of the ClipBoard into the view, replacing any selected text. More...
 
void Delete (bool sendNotify=true)
 Delete the selected text, or current character. More...
 
void Delete (const os::IPoint &start, const os::IPoint &end, bool sendNotify=true)
 Delete text. More...
 
void SetTabOrder (int order)
 Overridden from os::View or os::Control .
 
void SetFormat (Format *f)
 Sets the current format. More...
 
FormatGetFormat ()
 Gets the current format. More...
 
void SetTextColor (os::Color32_s)
 Sets the color of the text. More...
 
os::Color32_s GetTextColor ()
 Gets the current text color. More...
 
void SetBackground (os::Color32_s)
 Sets the text background color. More...
 
os::Color32_s GetBackground ()
 Gets the current text background color.
 
void SetShowLineNumbers (bool bShowLN)
 
bool GetShowLineNumbers ()
 
uint GetLineCount () const
 Gets the number of lines in the view.
 
const os::String & GetLine (uint i) const
 Gets a line from the view. More...
 
void SetLine (const os::String &text, uint i)
 Sets a line. More...
 
bool Undo (bool sendNotify=true)
 Undoes a previous action - if possible. More...
 
bool Redo (bool sendNotify=true)
 Redoes an action previously undone - if possible. More...
 
bool UndoAvailable () const
 Is it possible to undo an action? More...
 
bool RedoAvailable () const
 Is it possible to redo an action? More...
 
void SetTabSize (uint size)
 Sets the tab size. More...
 
uint GetTabSize ()
 Gets the tab size. More...
 
void SetUseTab (bool)
 Sets if indenting uses tabs or spaces. More...
 
bool GetUseTab ()
 Gets the indent mode. More...
 
void ClearEvents ()
 Clears any buffered events - no notifies will be sent.
 
void SetHighlightColor (os::Color32_s)
 Sets the highlight color. More...
 
os::Color32_s GetHighlightColor ()
 Gets the highlight color. More...
 
void SetLineNumberFgColor (os::Color32_s)
 
os::Color32_s GetLineNumberFgColor ()
 
void SetLineNumberBgColor (os::Color32_s)
 
os::Color32_s GetLineNumberBgColor ()
 
void SetLineBackColor (os::Color32_s)
 
os::Color32_s GetLineBackColor ()
 
os::Font * GetEditorFont () const
 
void SetContextMenu (os::Menu *pcMenu)
 
void FoldAll ()
 
virtual void MouseUp (const os::Point &, uint32, os::Message *)
 

Detailed Description

A programmers editor widget for Atheos.

The widget is written to be so similar to the native os::TextView widget in Atheos that switching to it should require few changes. The differences are in three groups:

See Also
GetLine() SetLine() GetLineCount()
SetFormat()
Undo() Redo() UndoAvailable() RedoAvailable()
SetTabSize() GetTabSize()
Author
Andreas Engh-Halstvedt (aeh@o.nosp@m.pera.nosp@m.mail..nosp@m.com)

Constructor & Destructor Documentation

CodeView::CodeView ( const os::Rect &  r,
const os::String &  s,
const os::String &  text,
uint32  rm = os::CF_FOLLOW_LEFT||os::CF_FOLLOW_TOP,
uint32  f = os::WID_WILL_DRAW || os::WID_FULL_UPDATE_ON_RESIZE 
)

Constructor.

Description:
The constructor will initialize the CodeView and set all properties to default values. See the documentaition of each Setxxx() members to see what the various default values might be.
Parameters
rPassed on to the os::View constructor.
sPassed on to the os::View constructor (only used to identify the view. Newer rendered anywhere).
textThe initial content of the TextView.
rmPassed on to the os::View constructor.
fPassed on to the os::View constructor.

Member Function Documentation

void CodeView::Clear ( bool  sendNotify = true)

Removes all text from the view.

Parameters
sendNotifySet to false if no event should be sent.
void CodeView::ClearSelection ( bool  sendNotify = true)

Unselects the current selection.

Parameters
sendNotifySet to false if no event should be sent.
void CodeView::Cut ( bool  sendNotify = true)

Cut selected text, and put it on the ClipBoard.

Parameters
sendNotifySet to false if no event should be sent.
void CodeView::Delete ( bool  sendNotify = true)

Delete the selected text, or current character.

Parameters
sendNotifySet to false if no event should be sent.
void CodeView::Delete ( const os::IPoint &  start,
const os::IPoint &  end,
bool  sendNotify = true 
)

Delete text.

Parameters
startWhere to start the deletion.
endWhere to end the deletion.
sendNotifySet to false if no event should be sent.
size_t CodeView::GetCurrentLength ( ) const

Gets the length of the text in the view.

Returns
The sum of all line lengths plus line shifts.
os::IPoint CodeView::GetCursor ( ) const

Gets the current cursor position.

Returns
The current cursor position.
uint32 CodeView::GetEventMask ( ) const

Gets the event mask.

See Also
SetEventMask()
Format * CodeView::GetFormat ( )

Gets the current format.

See Also
SetFormat()
os::Color32_s CodeView::GetHighlightColor ( )

Gets the highlight color.

See Also
SetHighlightColor()
const os::String & CodeView::GetLine ( uint  i) const

Gets a line from the view.

Parameters
iThe line to get
Returns
Const reference to the given line.
int CodeView::GetMaxUndoSize ( ) const

Gets the maximum numer of undo steps kept.

See Also
SetMaxUndoSize()
bool CodeView::GetReadOnly ( ) const

Gets the readonly flag.

See Also
SetReadOnly()
void CodeView::GetRegion ( os::String *  buffer)

Gets the currently selected region.

Parameters
bufferThe string to put the text into.
uint CodeView::GetTabSize ( )

Gets the tab size.

Returns
How many spaces a tab character is shown as.
See Also
SetTabSize()
os::Color32_s CodeView::GetTextColor ( )

Gets the current text color.

See Also
SetTextColor()
bool CodeView::GetUseTab ( )

Gets the indent mode.

See Also
SetUseTab()
void CodeView::Insert ( const char *  text,
bool  sendNotify = true 
)

Inserts text into the view The text is inserted at the current cursor position.

Parameters
textThe text to insert.
sendNotifySet to false if no event should be sent.
void CodeView::Insert ( const os::IPoint &  pos,
const char *  text,
bool  sendNotify = true 
)

Inserts text into the view.

Parameters
posThe position to insert the text at.
textThe text to insert.
sendNotifySet to false if no event should be sent.
void CodeView::Paint ( const os::Rect &  r)

Paints the CodeView.

Only the scrollbars and the frame is painted by the CodeView. The text is painted by a child view.

void CodeView::Paste ( bool  sendNotify = true)

Paste the content of the ClipBoard into the view, replacing any selected text.

Parameters
sendNotifySet to false if no event should be sent.
bool CodeView::Redo ( bool  sendNotify = true)

Redoes an action previously undone - if possible.

Parameters
sendNotifySet to false if no event should be sent.
Returns
true if succesfull.
See Also
RedoAvailable() Undo()
bool CodeView::RedoAvailable ( ) const

Is it possible to redo an action?

Returns
true if possible.
See Also
Redo() Undo()
void CodeView::Select ( const os::IPoint &  start,
const os::IPoint &  end,
bool  sendNotify = true 
)

Selects text in the view.

Parameters
startWhere to start the selection.
endWhere to end the selection.
sendNotifySet to false if no event should be sent.
void CodeView::SelectAll ( bool  sendNotify = true)

Select all text in the view.

Parameters
sendNotifySet to false if no event should be sent.
void CodeView::Set ( const char *  text,
bool  sendNotify = true 
)

Sets the text in the view.

Parameters
textThe text to set.
sendNotifySet to false if no event should be sent.
void CodeView::SetBackground ( os::Color32_s  c)

Sets the text background color.

SetBgColor() will set the color of the parts of the view that is not covered by editor or scroll bar (i.e. lower right corner).

void CodeView::SetCursor ( int  x,
int  y,
bool  select = false,
bool  sendNotify = true 
)

Sets the cursor position.

Parameters
xThe character position to set to.
yThe line to set to.
selectSet to true if the move should select text.
sendNotifySet to false if no event should be sent.
void CodeView::SetCursor ( const os::IPoint &  pos,
bool  select = false,
bool  sendNotify = true 
)

Sets the cursor position.

Parameters
posThe position to set
selectSet to true if the move should select text.
sendNotifySet to false if no event should be sent.
void CodeView::SetEventMask ( uint32  mask)

Sets the event mask.

Default: 0

The event mask determines what events causes the CodeView to invoke itself and send out a message.

See Also
os::TextView
void CodeView::SetFormat ( Format f)

Sets the current format.

Default: NULL

The format is not deleted when the view is deleted, so the same Format can be used by several views.

See Also
Format
void CodeView::SetHighlightColor ( os::Color32_s  c)

Sets the highlight color.

See Also
GetHighlightColor()
void CodeView::SetLine ( const os::String &  text,
uint  line 
)

Sets a line.

Parameters
textThe text to set
lineWhich line to set.
void CodeView::SetMaxUndoSize ( int  size)

Sets the maximum number of undo steps to keep.

Default: 100

Each undo step requires some memory. With a large number of large edit operations this may add up to quite a lot!

void CodeView::SetReadOnly ( bool  flag = true)

Sets the readonly flag.

Default: false

void CodeView::SetTabSize ( uint  size)

Sets the tab size.

Default: 4

Parameters
sizeHow many spaces a tab character should be shown as.
void CodeView::SetTextColor ( os::Color32_s  c)

Sets the color of the text.

If a format is set, it will override this.

See Also
SetFormat()
void CodeView::SetUseTab ( bool  b)

Sets if indenting uses tabs or spaces.

Default: true

bool CodeView::Undo ( bool  sendNotify = true)

Undoes a previous action - if possible.

Parameters
sendNotifySet to false if no event should be sent.
Returns
true if succesfull.
See Also
UndoAvailable() Redo()
bool CodeView::UndoAvailable ( ) const

Is it possible to undo an action?

Returns
true if possible.
See Also
Undo()

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