MQTreeListBox class

(new in Rev4.32)

MQTreeListBox class manages a list box. It inherits a MQWidgetBase class

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

Class
MQTreeListBox Constructor
~MQTreeListBox Destructor
Member functions
GetCurrentID Get a current id
SetCurrentID Set a current id
AddItem Add an item
DeleteItem Delete an item
ClearItems Clear all items
ReparentItem Change a parent item
GetItemCount Get a number of items
GetItemIDByIndex Get an item's ID from an index
GetItemParent Get a parent item
GetItemChildren Get child items
GetItem Get a text in an item
SetItem Set a text in an item
GetItemTag Get an arbitrary value in an item
SetItemTag Set an arbitrary value in an item
GetItemSelected Get a selection status of an item
SetItemSelected Set a selection status of an item
GetItemHint Get a hint string of an item
SetItemHint Set a hint string of an item
GetItemCollapsed Get a collapsed status of an item
SetItemCollapsed Set a collapsed status of an item
GetVisibleRow Get a number of visible rows
SetVisibleRow Set a number of visible rows
GetLineHeightRate Get a rate of a line height
SetLineHeightRate Set a rate of a line height
GetHorzScrollVisible Get a visibility of a horizontal scroll bar
SetHorzScrollVisible Set a visibility of a horizontal scroll bar
GetVertScrollVisible Get a visibility of a vertical scroll bar
SetVertScrollVisible Set a visibility of a vertical scroll bar
GetMultiSelect Get a multi selection
SetMultiSelect Set a multi selection
ClearSelection Clear all selections
MakeItemVisible Show an item in the visible area
HitTestItem Get an item at a apecified position
GetItemRect Get a position and a size of an item
Events
AddChangedEvent Add an event when a current index or a selection has been changed.
AddDrawItemEvent Add an event when an item is drawn.

MQTreeListBox::MQTreeListBox();

MQTreeListBox::MQTreeListBox(int id);

id
A widget ID created outside the plug-in

It is a constructor.


virtual MQTreeListBox::~MQTreeListBox();

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


int MQTreeListBox::GetCurrentID();

Return value
A current ID

It returns an ID of an active item.


void MQTreeListBox::SetCurrentID(int value);

value
A current ID

It specifies an ID of an active item.


int MQTreeListBox::AddItem(const std::wstring& text);

int MQTreeListBox::AddItem(const std::wstring& text, __int64 tag);

int MQTreeListBox::AddItem(int parent_id, const std::wstring& text);

int MQTreeListBox::AddItem(int parent_id, const std::wstring& text, __int64 tag);

parent_id
A parent item's ID
text
A string for an adding item
tag
An arbitrary value
Return value
An added item's ID

It adds a new item.

A new item will hang down from a parent item when parent_id is specified.

An item has a displayed string and an arbitrary value.


void MQTreeListBox::DeleteItem(int id);

id
A deleting item's ID

It deletes an item that has the specified ID.

When the item has child items, they are also deleted.


void MQTreeListBox::ClearItems();

It deletes all items.


void MQTreeListBox::ReparentItem(int id, int new_parent_id);

id
A child item's ID
new_parent_id
A new parent's ID

It changes a parent item to the specified one.


int MQTreeListBox::GetItemCount();

Return value
A number of items

It returns a number of items in the list.


int MQTreeListBox::GetItemIDFromIndex(int index);

index
An index of an item
Return value
An item's ID

It returns an ID of an item at the specified index.

index is equal or larger than 0 and equal or less than GetItemCount()-1. If the index is invalid, -1 will be returned.


int MQTreeListBox::GetItemParent();

Return value
A parent item's ID

It returns a parent item's ID. When the item does not have a parent item, -1 will be returned.


std::vector<int> MQTreeListBox::GetItemChildren();

Return value
ID array of child items

It returns an array of IDs of child items.


std::wstring MQTreeListBox::GetItem(int id);

id
An item's ID
Return value
A string

It returns a string of the specified item.


void MQTreeListBox::SetItem(int id, const std::wstring& text);

id
An item's ID
text
A string

It sets a string of the specified item.


__int64 MQTreeListBox::GetItemTag(int id);

id
An item's ID
Return value
An arbitrary value

It returns an arbitrary value assigned to the specified item.


void MQTreeListBox::SetItemTag(int id, __int64 tag);

id
An item's ID
tag
An arbitrary value

It assigns an arbitrary value to the specified item.


bool MQTreeListBox::GetItemSelected(int id);

id
An item's ID
Return value
A selection status

It returns a selection status of the specified item.

It is necessary to enable a multi selection mode by SetMultiSelection() to get a selection status of an item.


void MQTreeListBox::SetItemSelected(int id, bool selected);

id
An item's ID
selected
A selection status

It sets a selection status of the specified item.

It is necessary to enable a multi selection mode by SetMultiSelection() to get a selection status of an item.


std::wstring MQTreeListBox::GetItemHint(int id);

id
An item's ID
Return value
A hint string

It returns a hint string of the specified item.


void MQTreeListBox::SetItemHint(int id, const std::wstring& hint);

id
An item's ID
hint
A hint string

It sets a hint string of the specified item.


bool MQTreeListBox::GetItemCollapsed(int id);

id
An item's ID
Return value
A collapsed status

It returns whether the specifies item is collapsed or not.


void MQTreeListBox::SetItemCollapsed(int id, bool selected);

id
An item's ID
selected
A collapsed status

It specifies whether the specifies item is collapsed or not.


int MQTreeListBox::GetVisibleRow();

Return value
A number of visible rows

It returns a number of visible rows used for a size calculation.

The value does not necessarily match the number of rows that are actually displayed.


void MQTreeListBox::SetVisibleRow(int value);

value
A number of visible rows

It specifies a number of visible rows used for a size calculation.

The value does not necessarily match the number of rows that are actually displayed.


double MQTreeListBox::GetLineHeightRate();

Return value
A rate of a line height

It returns a line height as a rate for a default height.


void MQTreeListBox::SetLineHeightRate(double value);

value
A rate of a line height

It soecifies a line height as a rate for a default height.


bool MQTreeListBox::GetHorzScrollVisible();

Return value
A visibility of a horizontal scroll bar

It returns whether a horizontal scroll bar is displayed or not.


void MQTreeListBox::SetHorzScrollVisible(bool value);

value
A visibility of a horizontal scroll bar

It specifies whether a horizontal scroll bar is displayed or not.


bool MQTreeListBox::GetVertScrollVisible();

Return value
A visibility of a vertical scroll bar

It returns whether a vertical scroll bar is displayed or not.


void MQTreeListBox::SetVertScrollVisible(bool value);

value
A visibility of a vertical scroll bar

It specifies whether a vertical scroll bar is displayed or not.


bool MQTreeListBox::GetMultiSelect();

Return value
Multi selection mode

It returns whether to enable to select multiple items nor not.


void MQTreeListBox::SetMultiSelect(bool value);

value
Multi selection mode

It specifies whether to enable to select multiple items nor not.


void MQTreeListBox::ClearSelection();

It deselects all items for multi selections.


void MQTreeListBox::MakeItemVisible(int id);

id
An item's ID

It adjusts a scroll position to show the specified item in the visible area.


int MQTreeListBox::HitTestItem(int x, int y);

x
X in a client coordinate
y
Y in a client coordinate
Return value
An item's ID

(new in Rev4.40)

It returns an index of an item at the specified position. If there is no item at the position, -1 is returned.


void MQTreeListBox::GetItemRect(int id, int& x, int& y, int& w, int& h);

id
An item's ID
x
X coordinate of left top corner
y
Y coordinate of left top corner
w
Width
h
Height

(new in Rev4.40)

It returns a position an a size of the specified item.


template<typename T> void MQTreeListBox::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 an event notified when a current index has been changed by user's operation.


template<typename T> void MQTreeListBox::AddDrawItemEvent(T *p, BOOL (T::*f)(MQWidgetBase*, MQDocument, MQTreeListBoxDrawItemParam&), 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 an event notified when an item is drawn.

BOOL T::f(MQWidgetBase* sender, MQDocument doc, MQTreeListBoxDrawItemParam& 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] Finish without default drawing
[FALSE] Continue to default drawing

A position to draw a text and so on can be changed by changing X and Width in param and returning FALSE.

struct MQTreeListBoxDrawItemParam {
	MQCanvas *Canvas;
	int ItemIndex;
	int ItemID;
	int X;
	int Y;
	int Width;
	int Height;
};
Canvas
A drawing canvas
ItemIndex
An index of an item
ItemID
An ID of an item
X
X coordinate of a drawing area
Y
Y coordinate of a drawing area
Width
A width of a drawing area
Height
A height of a drawing area