Allow marking wxTreeBook nodes to expand initially in XRC.

Add new "expanded" attribute for XRC nodes of treebookpage class.

Also update the sample and the XRC format documentation.

Closes #13355.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68318 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2011-07-21 13:50:03 +00:00
parent fb4faeb5de
commit 2b232decc5
4 changed files with 35 additions and 0 deletions

View File

@ -446,6 +446,7 @@ All (GUI):
- Support float, double and file name values in wxGenericValidator (troelsk).
- Fix keyboard navigation in wxGrid with hidden columns (ivan_14_32).
- Add wxDataViewEvent::IsEditCancelled() (Allonii).
- Allow marking wxTreeBook nodes to expand initially in XRC (RedTide).
OSX:

View File

@ -1730,6 +1730,9 @@ pseudo-class (similarly to @ref xrc_wxnotebook "wxNotebook" and its
into the image list.}
@row3col{selected, @ref overview_xrcformat_type_bool,
Is the page selected initially (only one page can be selected; default: 0)?}
@row3col{expanded, @ref overview_xrcformat_type_bool,
If set to 1, the page is initially expanded. By default all pages are
initially collapsed.}
@endTable
Each @c treebookpage has exactly one non-toplevel window as its child.

View File

@ -1147,9 +1147,18 @@ lay them out using wxSizers, absolute positioning, everything you like!
<object class="wxTreebook" name="controls_treebook">
<size>350,280</size>
<style>wxSUNKEN_BORDER</style>
<imagelist>
<size>16,16</size>
<bitmap stock_id="wxART_HELP_BOOK"/>
<bitmap stock_id="wxART_QUESTION"/>
<bitmap stock_id="wxART_INFORMATION"/>
<bitmap stock_id="wxART_GO_HOME"/>
</imagelist>
<object class="treebookpage">
<label>Page 1</label>
<depth>0</depth>
<image>0</image>
<expanded>1</expanded>
<object class="wxButton" name="controls_treebook_button1">
<size>200,180</size>
<label>Button N1</label>
@ -1158,10 +1167,13 @@ lay them out using wxSizers, absolute positioning, everything you like!
<object class="treebookpage">
<label>Empty Page 2</label>
<depth>1</depth>
<image>1</image>
<expanded>1</expanded>
</object>
<object class="treebookpage">
<label>Page 3</label>
<depth>2</depth>
<image>2</image>
<object class="wxButton" name="controls_treebook_button3">
<size>200,180</size>
<label>Button N3</label>
@ -1170,6 +1182,7 @@ lay them out using wxSizers, absolute positioning, everything you like!
<object class="treebookpage">
<label>Page 4</label>
<depth>1</depth>
<image>3</image>
<object class="wxButton" name="controls_treebook_button4">
<size>200,180</size>
<label>Button N4</label>

View File

@ -76,6 +76,24 @@ wxObject *wxTreebookXmlHandler::DoCreateResource()
CreateChildren(m_tbk, true/*only this handler*/);
wxXmlNode *node = GetParamNode("object");
int pageIndex = 0;
for (unsigned int i = 0; i < m_tbk->GetPageCount(); i++)
{
if ( m_tbk->GetPage(i) )
{
wxXmlNode *child = node->GetChildren();
while (child)
{
if (child->GetName() == "expanded" && child->GetNodeContent() == "1")
m_tbk->ExpandNode(pageIndex, true);
child = child->GetNext();
}
pageIndex++;
}
}
m_treeContext = old_treeContext;
m_isInside = old_ins;
m_tbk = old_par;