The same TreeCtrl on 2 different notebook tabs
The same TreeCtrl on 2 different notebook tabs
My app has a sash window with a tree Ctrl in the left sash and a note book on the right with several tabs.
I would like to make the notebook the higher level ctrl with the same instantiation of the tree ctrl on two different notebook tabs with different sash windows on each tab but not on all the tabs. I want the same instantiation of the tree ctrl in two places so the tree id and node user data would be the same; that’s important to the rest of the app. For the creation can I make its parent the same as the notebook or notebook parent? That would take care of events, I think. But I see no way to add it two to different sizers on two different tabs.
Is this easily doable? It works like it is but would feel better if I could change it.
Thanks,
Eddie
I would like to make the notebook the higher level ctrl with the same instantiation of the tree ctrl on two different notebook tabs with different sash windows on each tab but not on all the tabs. I want the same instantiation of the tree ctrl in two places so the tree id and node user data would be the same; that’s important to the rest of the app. For the creation can I make its parent the same as the notebook or notebook parent? That would take care of events, I think. But I see no way to add it two to different sizers on two different tabs.
Is this easily doable? It works like it is but would feel better if I could change it.
Thanks,
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
~e.e. cummings.
Re: The same TreeCtrl on 2 different notebook tabs
Hi,
I don't think you can.
Can you put some sketch of what you are trying to achieve?
Thank you.
I don't think you can.
Can you put some sketch of what you are trying to achieve?
Thank you.
Re: The same TreeCtrl on 2 different notebook tabs
yes, give me a little bit.
The most wasted of all days is one without laughter.
~e.e. cummings.
~e.e. cummings.
Re: The same TreeCtrl on 2 different notebook tabs
well... Maybe I don't know how to include pics.
can you follow the link to my github proj and see them. it is supposed to be public.
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
~e.e. cummings.
Re: The same TreeCtrl on 2 different notebook tabs
Hi,
It really easy.
Under the post there is a little notebook. Click on the Attachments tab.
Click "Add Files" button.
Select the file and click "Open"
You can then click "Place inline" if you want to.
Thank you.
It really easy.
Under the post there is a little notebook. Click on the Attachments tab.
Click "Add Files" button.
Select the file and click "Open"
You can then click "Place inline" if you want to.
Thank you.
Re: The same TreeCtrl on 2 different notebook tabs
Currently treectrl and notebook are panels of splitterwindow.
After I need the treectrl in 2 separate notebook pages. The important point is they would e the same ctrl in 2 different pages so that all the tree ids and user data is the same in the tree o either page.
But still even if i can do it it may not be a good thing to do. I'm worried about events getting handled right and the sizers working correctly.The most wasted of all days is one without laughter.
~e.e. cummings.
~e.e. cummings.
Re: The same TreeCtrl on 2 different notebook tabs
Hi,
The easiest and probably the simplest solution would be to create a child of wxTreeCtrl, handle all the events in it and then create 2 different objects out of this class.
Thank you.
The easiest and probably the simplest solution would be to create a child of wxTreeCtrl, handle all the events in it and then create 2 different objects out of this class.
Thank you.
Re: The same TreeCtrl on 2 different notebook tabs
I built this skeleton app. I had to mod the above structure some. Instead of making the treectrl a child of the splitterwindow I had to add a panel and make the treectrl a child of this for the splitter in both tabs.
I instantiated the treectrl once with parent as notebook and added it to the sizer for the splitter window panel. it compiles but barfs in startup. It wants the treectrl to have the panel as a parent.
There may be a way to do this but I'm not sure its worth the effort it will cost.
Thanks for looking,
Eddie
I instantiated the treectrl once with parent as notebook and added it to the sizer for the splitter window panel. it compiles but barfs in startup. It wants the treectrl to have the panel as a parent.
There may be a way to do this but I'm not sure its worth the effort it will cost.
Thanks for looking,
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
~e.e. cummings.
Re: The same TreeCtrl on 2 different notebook tabs
Hi,
The wxPanel gives yo a benefit of handling the {Shift+}TAB for free.
But besides that - can you show the code and the error you got?
Thank you.
The wxPanel gives yo a benefit of handling the {Shift+}TAB for free.
But besides that - can you show the code and the error you got?
Thank you.
Re: The same TreeCtrl on 2 different notebook tabs
Code: Select all
void ProjectFrame::CreateControls()
{
ProjectFrame* itemFrame1 = this;
ProjectFrameVertSizer = new wxBoxSizer(wxVERTICAL);
itemFrame1->SetSizer(ProjectFrameVertSizer);
ProjectFrameHorzSizer = new wxBoxSizer(wxHORIZONTAL);
ProjectFrameVertSizer->Add(ProjectFrameHorzSizer, 1, wxGROW|wxALL, 5);
wxNotebook* itemNotebook1 = new wxNotebook( itemFrame1, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize, wxBK_DEFAULT );
wxSplitterWindow* itemSplitterWindow2 = new wxSplitterWindow( itemNotebook1, ID_SPLITTERWINDOW1, wxDefaultPosition, wxSize(100, 100), wxSP_3DBORDER|wxSP_3DSASH|wxNO_BORDER );
itemSplitterWindow2->SetMinimumPaneSize(0);
wxPanel* itemPanel1 = new wxPanel( itemSplitterWindow2, ID_PANEL4, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
itemPanel1->SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
itemPanel1->SetSizer(itemBoxSizer3);
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
// one instance of tree ctrl
itemTreeCtrl5 = new wxTreeCtrl( itemFrame1, ID_TREECTRL1, wxDefaultPosition, wxSize(100, 100), wxTR_SINGLE );
//in first sized
itemBoxSizer4->Add(itemTreeCtrl5, 1, wxGROW|wxALL, 5);
wxPanel* itemPanel6 = new wxPanel( itemSplitterWindow2, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
itemPanel6->SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
wxButton* itemButton7 = new wxButton( itemPanel6, ID_BUTTON, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
itemSplitterWindow2->SplitVertically(itemPanel1, itemPanel6, 200);
itemNotebook1->AddPage(itemSplitterWindow2, _("Tab"));
wxSplitterWindow* itemSplitterWindow6 = new wxSplitterWindow( itemNotebook1, ID_SPLITTERWINDOW2, wxDefaultPosition, wxSize(100, 100), wxSP_3DBORDER|wxSP_3DSASH|wxNO_BORDER );
itemSplitterWindow6->SetMinimumPaneSize(0);
wxPanel* itemPanel8 = new wxPanel( itemSplitterWindow6, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
itemPanel8->SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL);
itemPanel8->SetSizer(itemBoxSizer9);
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer9->Add(itemBoxSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
//wxTreeCtrl* itemTreeCtrl11 = new wxTreeCtrl( itemPanel8, ID_TREECTRL2, wxDefaultPosition, wxSize(100, 100), wxTR_SINGLE );
//in second sizer
itemBoxSizer10->Add(itemTreeCtrl5, 1, wxGROW|wxALL, 5);
wxPanel* itemPanel12 = new wxPanel( itemSplitterWindow6, ID_PANEL3, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
itemPanel12->SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
wxArrayString itemChoice13Strings;
wxChoice* itemChoice13 = new wxChoice( itemPanel12, ID_CHOICE, wxDefaultPosition, wxDefaultSize, itemChoice13Strings, 0 );
itemSplitterWindow6->SplitVertically(itemPanel8, itemPanel12, 200);
itemNotebook1->AddPage(itemSplitterWindow6, _("Tab"));
wxPanel* itemPanel10 = new wxPanel( itemNotebook1, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
itemPanel10->SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
wxTextCtrl* itemTextCtrl11 = new wxTextCtrl( itemPanel10, ID_TEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
itemNotebook1->AddPage(itemPanel10, _("Tab2"));
ProjectFrameHorzSizer->Add(itemNotebook1, 1, wxGROW|wxALL, 5);
}
Code: Select all
../src/common/sizer.cpp(850): assert "CheckExpectedParentIs(w, m_containingWindow)" failed in DoInsert():
Windows managed by the sizer associated with the given window must have this window as
parent, otherwise they will not be repositioned correctly.
Please use the window wxPanel@0x5555558e9150 ("panel") with which this sizer is associated,
as the parent when creating the window wxTreeCtrl@0x555555933400 ("treeCtrl") managed by it.
Rather than trying to make the widgets sizers do stuff they are not planning for, I think it would be better to bite the bullet and separate all the data from the tree into another non-gui class then populate a separate tree with updated data each time a page of the notebook is selected. It was just easier to use the tree item id to select the data.
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
~e.e. cummings.