MQTreeListBoxクラス

(new in Rev4.32)

MQTreeListBox クラスはリストを表示するウィジェットを管理します。MQWidgetBaseクラスを継承しています。

継承元クラスで定義されるメンバ関数はそのクラスの記述を参照してください。

クラス
MQTreeListBox コンストラクタ
~MQTreeListBox デストラクタ
メンバ関数
GetCurrentID カレントインデックスの取得
SetCurrentID カレントインデックスの設定
AddItem 項目の追加
DeleteItem 項目の削除
ClearItems 項目の全消去
ReparentItem 親項目の変更
GetItemCount 項目数の取得
GetItemIDByIndex インデックスからの項目の取得
GetItemParent 親項目の取得
GetItemChildren 子項目の取得
GetItem 項目の取得
SetItem 項目の設定
GetItemTag 項目の任意値の取得
SetItemTag 項目の任意値の設定
GetItemSelected 項目の選択状態の取得
SetItemSelected 項目の選択状態の設定
GetItemHint 項目のヒント文字列の取得
SetItemHint 項目のヒント文字列の設定
GetItemCollapsed 項目の折り畳み状態の取得
SetItemCollapsed 項目の折り畳み状態の設定
GetVisibleRow 表示行数の取得
SetVisibleRow 表示行数の取得
GetLineHeightRate 一行の高さの割合取得
SetLineHeightRate 一行の高さの割合設定
GetHorzScrollVisible 横スクロールバーの表示取得
SetHorzScrollVisible 横スクロールバーの表示設定
GetVertScrollVisible 縦スクロールバーの表示取得
SetVertScrollVisible 縦スクロールバーの表示設定
GetMultiSelect 複数選択の可否取得
SetMultiSelect 複数選択の可否設定
ClearSelection 全選択解除
MakeItemVisible 指定項目を可視領域内に表示
HitTestItem 指定した位置にある項目を取得
GetItemRect 項目の位置・サイズを取得
イベント
AddChangedEvent 状態が変更された時のイベントを追加
AddDrawItemEvent 項目の描画時のイベントを追加

MQTreeListBox::MQTreeListBox();

MQTreeListBox::MQTreeListBox(int id);

id
プラグイン外で生成されたウィジェットのID

コンストラクタです。


virtual MQTreeListBox::~MQTreeListBox();

デストラクタです。仮想関数として定義されます。


int MQTreeListBox::GetCurrentID();

戻り値
カレントID

現在選択されている項目のIDを取得します。


void MQTreeListBox::SetCurrentID(int value);

value
カレントID

現在選択されている項目のIDを設定します。


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
親項目のID
text
追加する項目の文字列
tag
任意の数値
戻り値
追加された項目のID

項目を追加します。

parent_idを指定すると親項目にぶら下げることができます。

項目には表示される文字列とは別に任意の値を割り当てることができます。


void MQTreeListBox::DeleteItem(int id);

id
削除する項目のID

指定したIDの項目を削除します。

子項目がある場合、子項目も削除されます。


void MQTreeListBox::ClearItems();

すべての項目を削除します。


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

id
子項目のID
new_parent_id
新しい親項目のID

指定したIDの項目の親項目を別のものに変更します。


int MQTreeListBox::GetItemCount();

戻り値
項目数

項目の数を取得します。


int MQTreeListBox::GetItemIDFromIndex(int index);

index
項目のインデックス
戻り値
項目のID

インデックスから項目のIDを取得します。

インデックスは0からGetItemCount()-1までの範囲の値となります。インデックスが不正な場合、-1が返されます。


int MQTreeListBox::GetItemParent();

戻り値
親項目のID

親項目のIDを取得します。親項目がない場合、-1が返されます。


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

戻り値
子項目のID配列

子項目のIDを配列として取得します。


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

id
項目のID
戻り値
文字列

指定した項目の文字列を取得します。


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

id
項目のID
text
文字列

指定した項目の文字列を設定します。


__int64 MQTreeListBox::GetItemTag(int id);

id
項目のID
戻り値
任意の値

指定した項目に割り当てられた任意の値を取得します。


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

id
項目のID
tag
任意の値

指定した項目に任意の値を割り当てます。


bool MQTreeListBox::GetItemSelected(int id);

id
項目のID
戻り値
選択状態

指定した項目の選択状態を取得します。

複数選択の状態を取得するにはSetMultiSelection()で複数選択できるようにしておく必要があります。


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

id
項目のID
selected
選択状態

指定した項目に選択状態を設定します。

複数選択の状態を取得するにはSetMultiSelection()で複数選択できるようにしておく必要があります。


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

id
項目のID
戻り値
ヒント文字列

指定した項目のヒント文字列を取得します。


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

id
項目のID
hint
ヒント文字列

指定した項目のヒント文字列を設定します。


bool MQTreeListBox::GetItemCollapsed(int id);

id
項目のID
戻り値
折り畳み状態

指定した項目の折り畳み状態を取得します。


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

id
項目のID
selected
折り畳み状態

指定した項目に折り畳み状態を設定します。


int MQTreeListBox::GetVisibleRow();

戻り値
表示する行数

高さの計算時に用いる表示行数を取得します。

実際に表示される行数とは必ずしも一致しません。


void MQTreeListBox::SetVisibleRow(int value);

value
表示する行数

高さの計算時に用いる表示行数を設定します。

実際に表示される行数とは必ずしも一致しません。


double MQTreeListBox::GetLineHeightRate();

戻り値
標準の高さに対する割合

一行の高さを標準の高さに対する割合で取得します。


void MQTreeListBox::SetLineHeightRate(double value);

value
標準の高さに対する割合

一行の高さを標準の高さに対する割合で設定します。


bool MQTreeListBox::GetHorzScrollVisible();

戻り値
横スクロールバーの表示

横スクロールバーを表示するかどうか取得します。


void MQTreeListBox::SetHorzScrollVisible(bool value);

value
横スクロールバーの表示

横スクロールバーを表示するかを設定します。


bool MQTreeListBox::GetVertScrollVisible();

戻り値
縦スクロールバーの表示

縦スクロールバーを表示するかどうか取得します。


void MQTreeListBox::SetVertScrollVisible(bool value);

value
縦スクロールバーの表示

縦スクロールバーを表示するかを設定します。


bool MQTreeListBox::GetMultiSelect();

戻り値
複数選択の可否

複数選択をできるかどうか取得します。


void MQTreeListBox::SetMultiSelect(bool value);

value
複数選択の可否

複数選択をできるかどうかを設定します。


void MQTreeListBox::ClearSelection();

複数選択用の選択状態をすべて解除します。


void MQTreeListBox::MakeItemVisible(int id);

id
項目のID

指定したIDの項目が画面のリスト領域内に表示されるようスクロール位置を調整します。


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

x
X座標(クライアント座標系)
y
Y座標(クライアント座標系)
戻り値
項目のID

(new in Rev4.40)

指定した位置にある項目のIDを取得します。指定した位置に項目がない場合は-1が返ります。


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

id
項目のID
x
左上のX座標
y
左上のY座標
w
横幅
h
縦幅

(new in Rev4.40)

指定した項目の位置・サイズを取得します。


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

p
イベント通知先のウィジェット
f
イベント通知先のメンバ関数
prior
イベントの通知順序
[true] 最初に通知されるよう指定
[false] 最後に通知されるよう指定

ユーザーの操作により状態が変更されたときに発生されるイベントを追加します。


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

p
イベント通知先のウィジェット
f
イベント通知先のメンバ関数
prior
イベントの通知順序
[true] 最初に通知されるよう指定
[false] 最後に通知されるよう指定

個々の項目が描画されるときに発生されるイベントを追加します。

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

sender
イベント通知元のウィジェット
doc
ドキュメント
param
イベント発生時のパラメータ(下記参照)
戻り値
[TRUE] 通常の描画を行わずに終了する
[FALSE] 文字などの通常描画を行う

param内のXとWidthを変更してFALSEを返すことで、文字などの描画位置を変更することができます。

struct MQTreeListBoxDrawItemParam {
	MQCanvas *Canvas;
	int ItemIndex;
	int ItemID;
	int X;
	int Y;
	int Width;
	int Height;
};
Canvas
描画キャンバス
ItemIndex
項目のインデックス
ItemID
項目のID
X
描画範囲のX座標
Y
描画範囲のY座標
Width
描画範囲の横幅
Height
描画範囲の縦幅