ツリーコントロールは、情報を階層化して表現します。ツリーの各項目 (Item) を展開して、さらに項目を表示することができます。ツリーの項目は、wxTreeItemId というハンドラによって参照されます。wxTreeItemId::IsOk を呼び出すことで、有効な項目ハンドラであるかどうかを確認できます。
A tree control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree control are referenced by wxTreeItemId handles, which may be tested for validity by calling wxTreeItemId::IsOk.
ツリーコントロールからのイベントを割り込み処理するために、wxTreeEvent の項目で説明しているイベントテーブルマクロを使います。
wxControl
wxWindow
wxEvtHandler
wxObject
Include files
<wx/treectrl.h>
Window styles
wxTR_EDIT_LABELS |
ツリーコントロールのラベルの編集を可能にしたいときには、このスタイルを用いる。
Use this style
if you wish the user to be able to edit labels in the tree control.
|
wxTR_NO_BUTTONS |
便宜的。ボタンが描かれないことを記載するため。
For convenience
to document that no buttons are to be drawn.
|
wxTR_HAS_BUTTONS |
親となる項目の左側に + や - のボタンを表示するときにこのスタイルを用いる。
Use this style
to show + and - buttons to the left of parent items.
|
wxTR_TWIST_BUTTONS |
親となる項目の左側に Mac 風のツイスターボタンを表示するときにこのスタイルを
用いる。
wxTR_HAS_BUTTONS と wxTR_TWIST_BUTTONS の両方が渡されると、ツイスターボタンが
生成される。ジェネリック版のみ。
Use this style
to show Mac-style twister buttons to the left of parent items.
If both wxTR_HAS_BUTTONS and wxTR_TWIST_BUTTONS are given,
twister buttons are generated. Generic only.
|
wxTR_NO_LINES |
垂直なレベル線を隠すときに、このスタイルを用いる。
Use this style
to hide vertical level connectors.
|
wxTR_FULL_ROW_HIGHLIGHT |
背景の色と選択字のハイライトを、ツリーコントロールのウインドウの横幅いっぱいに
広げるときに、このスタイルを使う。(このフラグは、Windows の下では xTR_NO_LINES とあわせて指定しなければ無視される。)
Use this style to have the background
colour and the selection highlight extend over the entire horizontal
row of the tree control window. (This flag is ignored under Windows unless you
specify wxTR_NO_LINES as well.)
|
wxTR_LINES_AT_ROOT |
ルートノード間に線を引きたいときにこのスタイルを用いる。
wxTR_HIDE_ROOT がセットされ、かつ wxTR_NO_LINES がセットされていないときにだけ、効果がある。
Use this style
to show lines between root nodes.
Only applicable if wxTR_HIDE_ROOT is set and wxTR_NO_LINES is not set.
|
wxTR_HIDE_ROOT |
ルートノードを表示させないときに、このスタイルを用いる。
実質的には、第 1 レベルのノードが一連のルートノードのように見えることになる。
Use this style
to suppress the display of the root node,
effectively causing the first-level nodes
to appear as a series of root nodes.
|
wxTR_ROW_LINES |
行の間に境界線を表示したいときにこのスタイルを使う。
Use this style
to draw a contrasting border between displayed rows.
|
wxTR_HAS_VARIABLE_ROW_HEIGHT |
行の高さを内容にあわせて変化させるときに、このスタイルを用いる。
指定されなければ、すべての行は一番大きな行の高さを使う。
デフォルトでは、このフラグは指定されない。ジェネリック版のみ。
Use this style
to cause row heights to be just big enough to fit the content.
If not set, all rows use the largest row height.
The default is that this flag is unset.
Generic only.
|
wxTR_SINGLE |
一度に一項目だけを選択できることを明示するための便宜的なフラグ。
別の項目を選ぶと、現在選ばれていたものがあっても、選択解除される。
これがデフォルトの振る舞いである。
For convenience
to document that only one item may be selected at a time.
Selecting another item causes the current selection, if any,
to be deselected. This is the default.
|
wxTR_MULTIPLE |
一連の項目範囲を選択可能にするために、このスタイルを用いる。
別の項目範囲を選ぶと、現在選ばれていた範囲があっても、選択解除される。
Use this style
to allow a range of items to be selected.
If a second range is selected, the current range, if any, is deselected.
|
wxTR_EXTENDED |
隣接しない項目の選択を可能にする場合にこのスタイルを使用する。
(部分的にしか実装されていないので、すべての場合に動作するとは限らない。)
Use this style
to allow disjoint items to be selected. (Only partially implemented; may not work in all cases.)
|
wxTR_DEFAULT_STYLE |
(各プラットフォームに) 固有のツールキットの各コントロールの
デフォルトに近いようなフラグの組み合わせとする。
The set of flags that are
closest to the defaults for the native control for a particular toolkit.
|
See also window styles overview.
Event handling
EVT_TREE_BEGIN_DRAG(id, func) |
左マウスボタンによるドラッグ開始。
Begin dragging with the left mouse button.
|
EVT_TREE_BEGIN_RDRAG(id, func) |
右マウスボタンによるドラッグ開始。
Begin dragging with the right mouse button.
|
EVT_TREE_BEGIN_LABEL_EDIT(id, func) |
ラベルの編集を開始する。 Veto() を
呼び出すと、編集を始めさせない。
Begin editing a label. This can be prevented by calling Veto().
|
EVT_TREE_END_LABEL_EDIT(id, func) |
ラベルの編集を終わる。Veto() を
呼び出すと、編集を終了させない。
注: 編集結果を反映させないで、編集を終了する。?
Finish editing a label. This can be prevented by calling Veto().
|
EVT_TREE_DELETE_ITEM(id, func) |
項目の削除
Delete an item.
|
EVT_TREE_GET_INFO(id, func) |
アプリケーションから情報を要求する。?
Request information from the application.
|
EVT_TREE_SET_INFO(id, func) |
情報が与えられた。?
Information is being supplied.
|
EVT_TREE_ITEM_ACTIVATED(id, func) |
項目がアクティベイトされた。つまり、ダブル・クリックで選ばれたか、キーボードから選択された。
The item has been activated, i.e. chosen by double clicking it with mouse or from keyboard
|
EVT_TREE_ITEM_COLLAPSED(id, func) |
項目が折りたたまれた。
The item has been collapsed.
|
EVT_TREE_ITEM_COLLAPSING(id, func) |
項目が折りたたまれようとしている。Veto() を呼び出して、これを拒否できる。
The item is being collapsed. This can be prevented by calling Veto().
|
EVT_TREE_ITEM_EXPANDED(id, func) |
項目が展開された。
The item has been expanded.
|
EVT_TREE_ITEM_EXPANDING(id, func) |
項目を展開しようとしている。Veto() を呼び出して、これを拒否できる。
The item is being expanded. This can be prevented by calling Veto().
|
EVT_TREE_SEL_CHANGED(id, func) |
別の項目が選択された。
Selection has changed.
|
EVT_TREE_SEL_CHANGING(id, func) |
別の項目を選択しようとしている。Veto() を呼び出して、これを拒否できる。
Selection is changing. This can be prevented by calling Veto().
|
EVT_TREE_KEY_DOWN(id, func) |
キーが押された。
A key has been pressed.
|
See also
wxTreeItemData, wxTreeCtrl overview, wxListBox, wxListCtrl, wxImageList, wxTreeEvent
Win32 notes
wxTreeCtrl::wxTreeCtrl
wxTreeCtrl::~wxTreeCtrl
wxTreeCtrl::AddRoot
wxTreeCtrl::AppendItem
wxTreeCtrl::AssignButtonsImageList
wxTreeCtrl::AssignImageList
wxTreeCtrl::AssignStateImageList
wxTreeCtrl::Collapse
wxTreeCtrl::CollapseAndReset
wxTreeCtrl::Create
wxTreeCtrl::Delete
wxTreeCtrl::DeleteAllItems
wxTreeCtrl::DeleteChildren
wxTreeCtrl::EditLabel
wxTreeCtrl::EndEditLabel
wxTreeCtrl::EnsureVisible
wxTreeCtrl::Expand
wxTreeCtrl::GetBoundingRect
wxTreeCtrl::GetButtonsImageList
wxTreeCtrl::GetChildrenCount
wxTreeCtrl::GetCount
wxTreeCtrl::GetEditControl
wxTreeCtrl::GetFirstChild
wxTreeCtrl::GetFirstVisibleItem
wxTreeCtrl::GetImageList
wxTreeCtrl::GetIndent
wxTreeCtrl::GetItemBackgroundColour
wxTreeCtrl::GetItemData
wxTreeCtrl::GetItemFont
wxTreeCtrl::GetItemImage
wxTreeCtrl::GetItemText
wxTreeCtrl::GetItemTextColour
wxTreeCtrl::GetLastChild
wxTreeCtrl::GetNextChild
wxTreeCtrl::GetNextSibling
wxTreeCtrl::GetNextVisible
wxTreeCtrl::GetItemParent
wxTreeCtrl::GetParent
wxTreeCtrl::GetPrevSibling
wxTreeCtrl::GetPrevVisible
wxTreeCtrl::GetRootItem
wxTreeCtrl::GetItemSelectedImage
wxTreeCtrl::GetSelection
wxTreeCtrl::GetSelections
wxTreeCtrl::GetStateImageList
wxTreeCtrl::HitTest
wxTreeCtrl::InsertItem
wxTreeCtrl::IsBold
wxTreeCtrl::IsExpanded
wxTreeCtrl::IsSelected
wxTreeCtrl::IsVisible
wxTreeCtrl::ItemHasChildren
wxTreeCtrl::OnCompareItems
wxTreeCtrl::PrependItem
wxTreeCtrl::ScrollTo
wxTreeCtrl::SelectItem
wxTreeCtrl::SetButtonsImageList
wxTreeCtrl::SetIndent
wxTreeCtrl::SetImageList
wxTreeCtrl::SetItemBackgroundColour
wxTreeCtrl::SetItemBold
wxTreeCtrl::SetItemData
wxTreeCtrl::SetItemFont
wxTreeCtrl::SetItemHasChildren
wxTreeCtrl::SetItemImage
wxTreeCtrl::SetItemSelectedImage
wxTreeCtrl::SetItemText
wxTreeCtrl::SetItemTextColour
wxTreeCtrl::SetStateImageList
wxTreeCtrl::SortChildren
wxTreeCtrl::Toggle
wxTreeCtrl::Unselect
wxTreeCtrl::UnselectAll
wxTreeCtrl()
parent
id
pos
size
style
validator
name
See also
wxTreeCtrl::Create, wxValidator
void ~wxTreeCtrl()
wxTreeItemId AddRoot(const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL)
The image and selImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If image > -1 and selImage is -1, the same image is used for both selected and unselected items.
wxTreeItemId AppendItem(const wxTreeItemId& parent, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL)
パラメータ image および selImage は、 非選択時および選択時に用いるイメージをノーマル・イメージ・リスト (normal image list) の中から指定する添え字である。 image > -1 かつ selImage が -1 なら、同じイメージが、選択時と非選択時の両方に用いられる。
The image and selImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If image > -1 and selImage is -1, the same image is used for both selected and unselected items.
void AssignButtonsImageList(wxImageList* imageList)
ボタンイメージリストが、セットないしアサインされると イメージボタンの表示が指定される。 一度指定したあとに、ボタンイメージの表示を止めるには、 ボタンメージリストを NULL にセットすること。
この関数は、ジェネリック版でのみ、使用可能。
SetButtonsImageList を参照。
Setting or assigning the button image list enables the display of image buttons. Once enabled, the only way to disable the display of button images is to set the button image list to NULL.
This function is only available in the generic version.
See also SetButtonsImageList.
void AssignImageList(wxImageList* imageList)
SetImageList を参照。
See also SetImageList.
void AssignStateImageList(wxImageList* imageList)
SetStateImageList を参照。
See also SetStateImageList.
void Collapse(const wxTreeItemId& item)
void CollapseAndReset(const wxTreeItemId& item)
bool wxTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
void Delete(const wxTreeItemId& item)
void DeleteAllItems()
void DeleteChildren(const wxTreeItemId& item)
void EditLabel(const wxTreeItemId& item)
If the user changed the label (i.e. s/he does not press ESC or leave the text control without changes, a EVT_TREE_END_LABEL_EDIT event will be sent which can be vetoed as well.
wxTreeCtrl::EndEditLabel, wxTreeEvent
void EndEditLabel(bool cancelEdit)
現時点では、Windows 下でのみサポートされている。
This function is currently supported under Windows only.
void EnsureVisible(const wxTreeItemId& item)
void Expand(const wxTreeItemId& item)
bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, bool textOnly = FALSE) const
矩形領域が取得できれば TRUE を返し、例えば指定した項目が現在不可視の場合には失敗して FALSE となる。(この場合、rect は変化しない。)
The return value is TRUE if the rectangle was successfully retrieved or FALSE if it was not (in this case rect is not changed) - for example, if the item is currently invisible.
wxImageList* GetButtonsImageList() const
この関数は、ジェネリック版でのみ利用できる。。
This function is only available in the generic version.
size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE) const
int GetCount() const
wxTextCtrl& GetEditControl() const
wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& cookie) const
これらの列挙する関数には、「クッキー」パラメータを渡さなければならない。 「クッキー」パラメータは、アプリケーションには透過 (意味をもたない) が、ライブラリがこれらの関数の繰り返しの呼び出しをできるようにするために必要である。 (すなわち、ひとつの同じオブジェクトにたいして、 同時に複数の列挙関数呼び出しが可能になる。) 関数 GetFirstChild と GetNextChild に渡されるクッキーは、同じ変数でなければならない。
それ以上子供がいないときには、無効なツリー項目を返す。
For this enumeration function you must pass in a 'cookie' parameter which is opaque for the application but is necessary for the library to make these functions reentrant (i.e. allow more than one enumeration on one and the same object simultaneously). The cookie passed to GetFirstChild and GetNextChild should be the same variable.
Returns an invalid tree item if there are no further children.
wxTreeCtrl::GetNextChild, wxTreeCtrl::GetNextSibling
wxPython note:
wxTreeItemId GetFirstVisibleItem() const
wxImageList* GetImageList() const
int GetIndent() const
wxColour GetItemBackgroundColour(const wxTreeItemId& item) const
wxTreeItemData* GetItemData(const wxTreeItemId& item) const
wxPython note:
GetPyData(item) |
指定した項目 Id に関連付けられた Python オブジェクト wxTreeItemData を返す。
Returns the Python Object
associated with the wxTreeItemData for the given item Id.
|
wxPerl note:
GetPlData( item ) |
Wx::TreeItemData (これは、tree->GetItemData( item )->GetData();
と同じこと) に関連付けられた Perl データを返す。
Returns the Perl data
associated with the Wx::TreeItemData ( it is just the same as
tree->GetItemData( item )->GetData(); ).
|
wxFont GetItemFont(const wxTreeItemId& item) const
int GetItemImage(const wxTreeItemId& item, wxTreeItemIcon which = wxTreeItemIcon_Normal) const
wxString GetItemText(const wxTreeItemId& item) const
wxColour GetItemTextColour(const wxTreeItemId& item) const
wxTreeItemId GetLastChild(const wxTreeItemId& item) const
GetFirstChild, wxTreeCtrl::GetNextSibling, GetLastChild
wxTreeItemId GetNextChild(const wxTreeItemId& item, long& cookie) const
この列挙する関数には、「クッキー」パラメータを渡さなければならない。 「クッキー」パラメータは、アプリケーションには透過 (意味をもたない) が、ライブラリがこれらの関数の繰り返しの呼び出しをできるようにするために必要である。 (すなわち、ひとつの同じオブジェクトにたいして、 同時に複数の列挙関数呼び出しが可能になる。)
関数 GetFirstChild と GetNextChild に渡されるクッキーは、同じ変数でなければならない。
それ以上子供がいないときには、無効なツリー項目を返す。
For this enumeration function you must pass in a 'cookie' parameter which is opaque for the application but is necessary for the library to make these functions reentrant (i.e. allow more than one enumeration on one and the same object simultaneously). The cookie passed to GetFirstChild and GetNextChild should be the same.
Returns an invalid tree item if there are no further children.
wxPython note:
wxTreeItemId GetNextSibling(const wxTreeItemId& item) const
Returns an invalid tree item if there are no further siblings.
wxTreeItemId GetNextVisible(const wxTreeItemId& item) const
wxTreeItemId GetItemParent(const wxTreeItemId& item) const
wxTreeItemId GetParent(const wxTreeItemId& item) const
Returns the item's parent.
wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const
Returns an invalid tree item if there are no further children.
wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const
wxTreeItemId GetRootItem() const
int GetItemSelectedImage(const wxTreeItemId& item) const
wxTreeItemId GetSelection() const
size_t GetSelections(wxArrayTreeItemIds& selection) const
選択されている項目の数を返す。
Returns the number of selected items.
wxImageList* GetStateImageList() const
wxTreeItemId HitTest(const wxPoint& point, int& flags)
wxTREE_HITTEST_ABOVE |
クライアント領域より上
Above the client area.
|
wxTREE_HITTEST_BELOW |
クライアント領域より下
Below the client area.
|
wxTREE_HITTEST_NOWHERE |
クライアントエリア内ではあるが、最後の項目よりも下
In the client area but below the last item.
|
wxTREE_HITTEST_ONITEMBUTTON |
項目と関係付けられているボタン上
On the button associated with an item.
|
wxTREE_HITTEST_ONITEMICON |
項目と関係付けられているビットマップ上
On the bitmap associated with an item.
|
wxTREE_HITTEST_ONITEMINDENT |
項目と関係付けられている字下げ領域
In the indentation associated with an item.
|
wxTREE_HITTEST_ONITEMLABEL |
項目と関係付けられているラベル(文字列)
On the label (string) associated with an item.
|
wxTREE_HITTEST_ONITEMRIGHT |
項目の右側の場所
In the area to the right of an item.
|
wxTREE_HITTEST_ONITEMSTATEICON |
ツリービューの中で、ユーザー定義されたステートアイコン
On the state icon for a tree view item that is in a user-defined state.
|
wxTREE_HITTEST_TOLEFT |
クライアント領域の右側
To the right of the client area.
|
wxTREE_HITTEST_TORIGHT |
クライアント領域の左側
To the left of the client area.
|
wxPython note:
wxTreeItemId InsertItem(const wxTreeItemId& parent, const wxTreeItemId& previous, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL)
wxTreeItemId InsertItem(const wxTreeItemId& parent, size_t before, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL)
パラメータ image および selImage は、インデックスであり、 ノーマルイメージリストの中から、非選択時と選択時に用いるイメージを指定する。 image > -1 かつ selImage が -1 のときには、非選択時と選択時の両方に同じイメージが用いられる。
The image and selImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If image > -1 and selImage is -1, the same image is used for both selected and unselected items.
bool IsBold(const wxTreeItemId& item) const
bool IsExpanded(const wxTreeItemId& item) const
bool IsSelected(const wxTreeItemId& item) const
bool IsVisible(const wxTreeItemId& item) const
bool ItemHasChildren(const wxTreeItemId& item) const
int OnCompareItems(const wxTreeItemId& item1, const wxTreeItemId& item2)
The base class version compares items alphabetically.
wxTreeItemId PrependItem(const wxTreeItemId& parent, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL)
パラメータ image および selImage は、インデックスであり、 非選択時と選択時に用いるイメージを、ノーマルイメージリストの中から指定する。 image > -1 かつ selImage が -1 のときには、非選択時と選択時の両方に同じイメージが用いられる。
The image and selImage parameters are an index within the normal image list specifying the image to use for unselected and selected items, respectively. If image > -1 and selImage is -1, the same image is used for both selected and unselected items.
void ScrollTo(const wxTreeItemId& item)
bool SelectItem(const wxTreeItemId& item)
void SetButtonsImageList(wxImageList* imageList)
ボタンイメージリストをセットあるいはアサインすることで、イメージボタンの 表示が指定される。一度、指定したあとに、ボタンイメージの表示を止めるには、 ボタンメージリストを NULL に指定すること。
この関数は、ジェネリック版のみ。
Setting or assigning the button image list enables the display of image buttons. Once enabled, the only way to disable the display of button images is to set the button image list to NULL.
This function is only available in the generic version.
void SetIndent(int indent)
void SetImageList(wxImageList* imageList)
See also AssignImageList.
void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col)
void SetItemBold(const wxTreeItemId& item, bool bold = TRUE)
void SetItemData(const wxTreeItemId& item, wxTreeItemData* data)
SetPyData(item, obj) |
指定された Python オブジェクトを与えられた項目 Id の wxTreeItemData とする。
Associate the given Python
Object with the wxTreeItemData for the given item Id.
|
wxPerl note:
SetPlData( item, data ) |
Perl データを Wx::TreeItemData (これは tree->GetItemData( item )->SetData( data ); と同じこと) にセットする。
Sets the Perl data
associated with the Wx::TreeItemData ( it is just the same as
tree->GetItemData( item )->SetData( data ); ).
|
void SetItemFont(const wxTreeItemId& item, const wxFont& font)
void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = TRUE)
void SetItemImage(const wxTreeItemId& item, int image, wxTreeItemIcon which = wxTreeItemIcon_Normal)
void SetItemSelectedImage(const wxTreeItemId& item, int selImage)
void SetItemText(const wxTreeItemId& item, const wxString& text)
void SetItemTextColour(const wxTreeItemId& item, const wxColour& col)
void SetStateImageList(wxImageList* imageList)
void SetWindowStyle(longstyles)
void SortChildren(const wxTreeItemId& item)
wxTreeItemData, OnCompareItems
void Toggle(const wxTreeItemId& item)
void Unselect()
void UnselectAll()