MQMemo class

(new in Rev4.00)

MQMemo class manages a memo to input multi-line text. It inherits MQWidgetBase class.

Please refer the inherited class about member functions declared in the inherited class.

Class
MQMemo Constructor
~MQMemo Destructor
Member functions
GetText Get a displayed text
GetTextLength Get a length of a displayed text
SetText Set a displayed text
GetFontName Get a font name
SetFontName Set a font name
GetFontBold Get a bold font
SetFontBold Set a bold font
GetFontScale Get a font scaling
SetFontScale Set a font scaling
GetReadOnly Get a read-only mode
SetReadOnly Set a read-only mode
GetPriorMenuShortcut Get a priority to menu shortcut
SetPriorMenuShortcut Set a priority to menu shortcut
GetHorzBarStatus Get a status of horizontal bar
SetHorzBarStatus Set a status of horizontal bar
GetVertBarStatus Get a status of vertical bar
SetVertBarStatus Set a status of vertical bar
GetFocus Get a focus
SetFocus Set a focus
GetCaretPos Get a caret position
SetCaretPos Set a caret position
GetTabColumn Get a tab width
SetTabColumn Set a tab width
GetAutoIndent Get an auto indent
SetAutoIndent Set an auto indent
GetShowTabMark Get a visibility of tab marks
SetShowTabMark Set a visibility of tab marks
GetShowReturnMark Get a visibility of return marks
SetShowReturnMark Set a visibility of return marks
GetShowLineNumber Get a visibility of line numbers
SetShowLineNumber Set a visibility of line numbers
GetChanged Get a modified flag
SetChanged Set a modified flag
Member functions - Syntax highlight
GetSyntaxHighlight Get a syntax highlight
SetSyntaxHighlight Set a syntax highlight
GetMarkCharacters Get mark characters
SetMarkCharacters Set mark characters
AddSyntaxKeyword Add a keyword for syntax highlight
ClearSyntaxKeyword Clear keywords for syntax highlight
AddRadixPrefix Add a prefix string for radix
ClearRadixPrefix Clear prefix strings for radix
GetSyntaxComment Get a string for a comment
SetSyntaxComment Set a string for a comment
AddSyntaxMultiLineComment Add a string for multi-line comment
ClearSyntaxMultiLineComment Clear strings for multi-line comment
AddSyntaxString Add a string for syntax highlight
ClearSyntaxString Clear strings for syntax highlight
Member functions - Select, Position
SelectAll Select all text
SelectRange Select text in specified range
GetSelectedRange Get a selected range of text
CutSelection Cut a selected text
CopySelection Copy a selected text
PasteFromClipboard Paste a text
ReplaceSelectedText Replace a selected text
FindString Find a string
FindStringFromCaretPos Find a string from a caret position
FindNextWordBreak Find a next word break
GetLineColumnByCaretPos Get line and column number by caret position
GetCaretPosByLineColumn Get caret position by line and column number
Member functions - Undo
CanUndo Get undoable
CanRedo Get redoable
Undo Execute an undo
Redo Execute a redo
Events
AddChangedEvent Add an event after finishing to change a text
AddChangingEvent Add an event while changing a text
AddDrawItemEvent Add an event for drawing an item

MQMemo::MQMemo();

MQMemo::MQMemo(int id);

id
A widget ID created outside the plug-in

It is a constructor.


virtual MQMemo::~MQMemo();

This method is a destructor. It is defined as a virtual function.


std::wstring MQMemo::GetText();

Return value
A displayed string

It returns a text displayed in the input area.


size_t MQMemo::GetTextLength();

Return value
A length of a text

(new in Rev4.64)

It returns a length of a text.

This function is faster than GetText() if you want a length only.


void MQMemo::SetText(const std::wstring& text);

text
A displayed string

It specifies a text displayed in the input area.


std::wstring MQMemo::GetFontName();

Return value
Font name

It returns a font name for displaying a text.


void MQMemo::SetFontName(const std::wstring& value);

value
Font name

It specifies a font name for displaying a text.


bool MQMemo::GetFontBold();

Return value
Bold font

It returns whether a displayed font is bold or not.


void MQMemo::SetFontBold(bool value);

value
Bold font

It specifies whether a displayed font is bold or not.


double MQMemo::GetFontScale();

Return value
Font scaling

It returns a font scaling ratio for a default font size.

A default value is 1.0.


void MQMemo::SetFontScale(double value);

value
Font scaling

It specifies a font scaling ratio for a default font size.


bool MQMemo::GetReadOnly();

Return value
Read-only mode

It returns whether to input characters by keys (false) or reject key inputs (true).


void MQMemo::SetReadOnly(bool value);

value
Read-only mode

It returns whether to input characters by keys (false) or reject key inputs (true).


bool MQMemo::GetPriorMenuShortcut();

Return value
A priolity of menu

It returns whether to prior a shortcut key for a menu or not when a key is pressed.


void MQMemo::SetPriorMenuShortcut(bool value);

value
A priolity of menu

It specifies whether to prior a shortcut key for a menu or not when a key is pressed.


MQBarStatus MQMemo::GetHorzBarStatus();

Return value
A status of a horizontal scroll bar
[SCROLLBAR_AUTO] Auto by a length of each line
[SCROLLBAR_OFF] Always on
[SCROLLBAR_ON] Always off

(new in Rev4.64)

It returns a status of a horizontal scroll bar.


void MQMemo::SetHorzBarStatus(MQBarStatus value);

value
A status of a horizontal scroll bar
[SCROLLBAR_AUTO] Auto by a length of each line
[SCROLLBAR_OFF] Always on
[SCROLLBAR_ON] Always off

(new in Rev4.64)

It specifies a status of a horizontal scroll bar.


MQBarStatus MQMemo::GetVertBarStatus();

Return value
A status of a vertical scroll bar
[SCROLLBAR_AUTO] Auto by a length of each line
[SCROLLBAR_OFF] Always on
[SCROLLBAR_ON] Always off

(new in Rev4.64)

It returns a status of a horizontal scroll bar.


void MQMemo::SetVertBarStatus(MQBarStatus value);

value
A status of a vertical scroll bar
[SCROLLBAR_AUTO] Auto by a length of each line
[SCROLLBAR_OFF] Always on
[SCROLLBAR_ON] Always off

(new in Rev4.64)

It specifies a status of a vertical scroll bar.


bool MQMemo::GetFocus();

Return value
A focus status

(new in Rev4.64)

It returns whether this widget is focused or not now.


void MQMemo::SetFocus(bool value);

value
A focus status

It focuses this widget.

When this widget is focused, keyboard messages are notified to this widget.

When other widget has a focus and 'true' is specified, the focus will move from the widget to this.


size_t MQMemo::GetCaretPos();

Return value
A position of a caret

(new in Rev4.64)

It returns a position of a caret


void MQMemo::SetCaretPos(size_t value);

value
A position of caret

(new in Rev4.64)

It specifies a position of a caret


int MQMemo::GetTabColumn();

Return value
A width of a tab

(new in Rev4.64)

It returns a width of a tab.


void MQMemo::SetTabColumn(int value);

value
A width of a tab

(new in Rev4.64)

It specifies a width of a tab.


bool MQMemo::GetAutoIndent();

Return value
Auto indent

(new in Rev4.64)

It returns whether an indent is automatically inserted or not when a new line starts.


void MQMemo::SetAutoIndent(bool value);

value
Auto indent

(new in Rev4.64)

It specifies whether an indent is automatically inserted or not when a new line starts.


bool MQMemo::GetShowTabMark();

Return value
Show tab marks

(new in Rev4.64)

It returns whether to show tab marks or not.


void MQMemo::SetShowTabMark(bool value);

value
Show tab marks

(new in Rev4.64)

It specifies whether to show tab marks or not.


bool MQMemo::GetShowReturnMark();

Return value
Show return marks

(new in Rev4.64)

It returns whether to show return marks or not.


void MQMemo::SetShowReturnMark(bool value);

value
Show return marks

(new in Rev4.64)

It specifies whether to show return marks or not.


bool MQMemo::GetShowLineNumber();

Return value
Show line numbers

(new in Rev4.64)

It returns whether to show line numbers or not.


void MQMemo::SetShowLineNumber(bool value);

value
Show line numbers

(new in Rev4.64)

It specifies whether to show line numbers or not.


bool MQMemo::GetSyntaxHighlight();

Return value
Enabled or disable syntax highlight

(new in Rev4.64)

It returns whether syntax highlight is enabled or disable.


void MQMemo::SetSyntaxHighlight(bool value);

value
Enable or disable syntax highlight

(new in Rev4.64)

It specifies whether to enable or disable syntax highlight.


bool MQMemo::GetChanged();

Return value
A modified flag

(new in Rev4.64)

It return whether a text has been modified or not.


void MQMemo::SetChanged(bool value);

value
A modified flag

(new in Rev4.64)

It specifies whether a text has been modified or not.


std::wstring MQMemo::GetMarkCharacters();

Return value
Mark characters

(new in Rev4.64)

It returns characters used as marks for syntax highlight and finding a word


void MQMemo::SetMarkCharacters(const std::wstring& text);

text
Mark characters

(new in Rev4.64)

It specifies characters used as marks for syntax highlight and finding a word


void MQMemo::AddSyntaxKeyword(const std::wstring& text);

text
A keyword

(new in Rev4.64)

It adds a keyword for syntax highlight.

Example: 'for', 'break' and so on in C and Python


void MQMemo::ClearSyntaxKeyword();

(new in Rev4.64)

It clears all keywords for syntax highlight.


void MQMemo::AddRadixPrefix(const std::wstring& text);

text
A prefix

(new in Rev4.64)

It adds a prefix string for radix.

Example: 0x in C and Python


void MQMemo::ClearRadixPrefix();

(new in Rev4.64)

It clears all prefix strings for radix.


std::wstring MQMemo::GetSyntaxComment();

Return value
A comment string

(new in Rev4.64)

It returns a string for a single line comment.

Example: // in C++, # in Python


void MQMemo::SetSyntaxComment(const std::wstring& text);

text
A comment string

(new in Rev4.64)

It specifies a string for a single line comment.


void MQMemo::AddSyntaxMultiLineComment(const std::wstring& start, const std::wstring& end);

start
Start string for a comment
end
End string for a comment

(new in Rev4.64)

It adds a pair of start and end string used as a multi-line comment in syntax highlight.

Example: /* and */ in C, and """ and """ in Python


void MQMemo::ClearSyntaxMultiLineComment();

(new in Rev4.64)

It clears all pair of start and end strings used as a multi-line comment in syntax highlight.


void MQMemo::AddSyntaxString(const std::wstring& start, const std::wstring& end);

start
Start string for a text
end
End string for a text

(new in Rev4.64)

It adds a pair of start and end strings used as a text in syntax highlight.

Example: " and " in C and Python.


void MQMemo::ClearSyntaxString();

(new in Rev4.64)

It clears all strings used as a text.


void MQMemo::SelectAll();

(new in Rev4.64)

It selects all text.


void MQMemo::SelectRange(size_t start, size_t end);

start
Start position
end
End position

(new in Rev4.64)

It selects a text in the specified range.


bool MQMemo::GetSelectedRange(size_t& start, size_t& end);

start
Start position (output)
end
End position (output)
Return value
Selected or not

(new in Rev4.64)

It returns a selected range of a text.


void MQMemo::CutSelection();

(new in Rev4.64)

It cuts a text in the selected range, and send to clipboard.


void MQMemo::CopySelection();

(new in Rev4.64)

It copies a text in the selected range to clipboard.


void MQMemo::PasteFromClipboard();

(new in Rev4.64)

It pastes a text from clipboard.


void MQMemo::ReplaceSelectedText(const std::wstring& text);

text
A replacing text

(new in Rev4.64)

It replaces a selected range with a specified text.


size_t MQMemo::FindString(const std::wstring& text, size_t start_pos, bool forward, bool matchcase, bool word);

text
String to find
start_pos
Start position
forward
Search forward
matchcase
Case sensitive
word
Find a word
Return value
Position (MQMemo::INVALID_POS means 'not found')

(new in Rev4.64)

It searches a first position matched with the text under the specified condition.


size_t MQMemo::FindStringFromCaretPos(const std::wstring& text, bool forward, bool matchcase, bool word);

text
String to find
forward
Find forward
matchcase
Case sensitive
word
Find a word
Return value
Position (MQMemo::INVALID_POS means 'not found')

(new in Rev4.64)

It searches a first position matched with the text from a current caret position under the specified condition.


size_t MQMemo::FindNextWordBreak(size_t pos, bool forward);

pos
Start position
forward
Find forward
Return value
Position (MQMemo::INVALID_POS means 'not found')

(new in Rev4.64)

It searches a position of next word wrap from the specified position.


bool MQMemo::GetLineColumnByCaretPos(size_t pos, int& line, int& column);

pos
Position
line
Line number (output)
column
Column number (output)
Return value
Succeeded or not

(new in Rev4.64)

It returns line and column number at the specified position.


bool MQMemo::GetCaretPosByLineColumn(int line, int column, size_t& pos);

line
Line number
column
Column number
pos
Position (output)
Return value
Succeeded or not

(new in Rev4.64)

It returns a position from line and column number.


bool MQMemo::CanUndo();

Return value
Can undo or not

(new in Rev4.64)

It returns whether to be able to execute an undo or not.


bool MQMemo::CanRedo();

Return value
Can redo or not

(new in Rev4.64)

It returns whether to be able to execute a redo or not.


void MQMemo::Undo();

(new in Rev4.64)

It executes an undo operation.


void MQMemo::Redo();

(new in Rev4.64)

It executes a redo operation.


template<typename T> void MQMemo::AddChangedEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument), bool prior = false)

p
A widget to notify events
f
A member function to notify events
prior
An order to notify events
[true] Notify first
[false] Notify last

It adds events notified when a text has been changed by user's operation.

An event by AddChangingEvent() is invoked when characters are modified by key input, and an event by AddChangedEvent() is invoked when Enter key is pressed or a focus removed by Tab key or a mouse operation.


template<typename T> void MQMemo::AddChangingEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument), bool prior = false)

p
A widget to notify events
f
A member function to notify events
prior
An order to notify events
[true] Notify first
[false] Notify last

It adds events notified when a text is changing by user's operation.

An event by AddChangingEvent() is invoked when characters are modified by key input, and an event by AddChangedEvent() is invoked when Enter key is pressed or a focus removed by Tab key or a mouse operation.


template<typename T> void MQMemo::AddDrawItemEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQMemoDrawItemParam&), bool prior = false)

p
A widget to notify events
f
A member function to notify events
prior
An order to notify events
[true] Notify first
[false] Notify last

(new in Rev4.64)

It add an event for drawing each line.

A member function 'f' must have the following options and return value.

 

BOOL T::f(MQWidgetBase* sender, MQDocument doc, MQMemoDrawItemParam& param);

sender
A source widget that notifies an event
doc
A document
param
Parameters when an event is occurred (See the following description)
Return value
[TRUE] Modified the document
[FALSE] Nothing is modified in the document

struct MQMemoDrawItemParam {
	MQCanvas *Canvas;
	int Line;
	size_t StartPos;
	size_t EndPos;
	int X;
	int Y;
	int Width;
	int Height;
};
Canvas
A drawing canvas
Line
Line number
StartPos
Position of line start
EndPos
Position of line end
X
left top X coordinate
Y
left top Y coordinate
Width
A width of drawing rect
Height
A height of drawing rect