A programmers editor widget for Atheos. More...
#include <codeview.h>
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... | |
Format * | GetFormat () |
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 *) |
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:
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.
r | Passed on to the os::View constructor. |
s | Passed on to the os::View constructor (only used to identify the view. Newer rendered anywhere). |
text | The initial content of the TextView. |
rm | Passed on to the os::View constructor. |
f | Passed on to the os::View constructor. |
void CodeView::Clear | ( | bool | sendNotify = true | ) |
Removes all text from the view.
sendNotify | Set to false if no event should be sent. |
void CodeView::ClearSelection | ( | bool | sendNotify = true | ) |
Unselects the current selection.
sendNotify | Set to false if no event should be sent. |
void CodeView::Cut | ( | bool | sendNotify = true | ) |
Cut selected text, and put it on the ClipBoard.
sendNotify | Set to false if no event should be sent. |
void CodeView::Delete | ( | bool | sendNotify = true | ) |
Delete the selected text, or current character.
sendNotify | Set to false if no event should be sent. |
void CodeView::Delete | ( | const os::IPoint & | start, |
const os::IPoint & | end, | ||
bool | sendNotify = true |
||
) |
Delete text.
start | Where to start the deletion. |
end | Where to end the deletion. |
sendNotify | Set to false if no event should be sent. |
size_t CodeView::GetCurrentLength | ( | ) | const |
Gets the length of the text in the view.
os::IPoint CodeView::GetCursor | ( | ) | const |
Gets the current cursor position.
uint32 CodeView::GetEventMask | ( | ) | const |
Gets the event mask.
Format * CodeView::GetFormat | ( | ) |
Gets the current format.
os::Color32_s CodeView::GetHighlightColor | ( | ) |
Gets the highlight color.
const os::String & CodeView::GetLine | ( | uint | i | ) | const |
Gets a line from the view.
i | The line to get |
int CodeView::GetMaxUndoSize | ( | ) | const |
Gets the maximum numer of undo steps kept.
bool CodeView::GetReadOnly | ( | ) | const |
Gets the readonly flag.
void CodeView::GetRegion | ( | os::String * | buffer | ) |
Gets the currently selected region.
buffer | The string to put the text into. |
uint CodeView::GetTabSize | ( | ) |
os::Color32_s CodeView::GetTextColor | ( | ) |
Gets the current text color.
bool CodeView::GetUseTab | ( | ) |
Gets the indent mode.
void CodeView::Insert | ( | const char * | text, |
bool | sendNotify = true |
||
) |
Inserts text into the view The text is inserted at the current cursor position.
text | The text to insert. |
sendNotify | Set 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.
pos | The position to insert the text at. |
text | The text to insert. |
sendNotify | Set to false if no event should be sent. |
void CodeView::Paint | ( | const os::Rect & | r | ) |
void CodeView::Paste | ( | bool | sendNotify = true | ) |
Paste the content of the ClipBoard into the view, replacing any selected text.
sendNotify | Set to false if no event should be sent. |
bool CodeView::Redo | ( | bool | sendNotify = true | ) |
Redoes an action previously undone - if possible.
sendNotify | Set to false if no event should be sent. |
bool CodeView::RedoAvailable | ( | ) | const |
void CodeView::Select | ( | const os::IPoint & | start, |
const os::IPoint & | end, | ||
bool | sendNotify = true |
||
) |
Selects text in the view.
start | Where to start the selection. |
end | Where to end the selection. |
sendNotify | Set to false if no event should be sent. |
void CodeView::SelectAll | ( | bool | sendNotify = true | ) |
Select all text in the view.
sendNotify | Set to false if no event should be sent. |
void CodeView::Set | ( | const char * | text, |
bool | sendNotify = true |
||
) |
Sets the text in the view.
text | The text to set. |
sendNotify | Set 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.
x | The character position to set to. |
y | The line to set to. |
select | Set to true if the move should select text. |
sendNotify | Set 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.
pos | The position to set |
select | Set to true if the move should select text. |
sendNotify | Set 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.
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.
void CodeView::SetHighlightColor | ( | os::Color32_s | c | ) |
Sets the highlight color.
void CodeView::SetLine | ( | const os::String & | text, |
uint | line | ||
) |
Sets a line.
text | The text to set |
line | Which 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
size | How many spaces a tab character should be shown as. |
void CodeView::SetTextColor | ( | os::Color32_s | c | ) |
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.
sendNotify | Set to false if no event should be sent. |
bool CodeView::UndoAvailable | ( | ) | const |