Thanks,
I'm going to try this as it seems easier
But I have one more question. What about if I'm using a GridSizer and inside
it an StaticBoxSizer? What should I do to show/hide these controls?
* wxStaticBoxSizer* sizer_2 = new wxStaticBoxSizer(sizer_2_staticbox,
wxHORIZONTAL);
wxGridSizer* grid_sizer_2 = new wxGridSizer(2, 2, 0, 0);
*
* grid_sizer_2->Add(label_1, 0, 0, 0);
grid_sizer_2->Add(label_3, 0, 0, 0);
grid_sizer_2->Add(label_2, 0, 0, 0);
grid_sizer_2->Add(label_4, 0, 0, 0);
sizer_2->Add(grid_sizer_2, 1, wxEXPAND, 0);
m_sizer2->Add(sizer_2, 1, wxEXPAND, 0);*
Thank you very much
Aida
2011/10/25 Xavier Planes <[email protected]>
> Hi Aida,
>
> When using show/hide functions in wxWidgets, you need to call
> show/hide on the sizers also to avoid grey empty space.
>
> For example when using a wxStaticBoxSizer:
> sizer_2_staticbox = new wxStaticBox(this, -1, wxT("Scalars"));
> wxStaticBoxSizer* sizer_2 = new wxStaticBoxSizer(sizer_2_staticbox,
> wxVERTICAL);
> sizer_2->Add(m_ComboBoxSelection, 0, wxBOTTOM|wxEXPAND, 2);
>
> You need to call these functions to hide them all:
> m_ComboBoxSelection->Show( false );
> m_ComboBoxSelection->GetContainingSizer()->Show( false );
> sizer_2_staticbox->Show( false );
>
> If you use a wxBoxSizer:
> wxBoxSizer* sizer_3 = new wxBoxSizer(wxHORIZONTAL);
> sizer_3->Add(m_chkSynchronize, 0, wxTOP, 2);
> sizer_3->Add(m_btnExport, 0, 0, 0);
>
> To hide all this controls you need to call:
> m_chkSynchronize->Show( false );
> m_btnExport->Show( false );
> m_btnExport->GetContainingSizer()->Show( false );
>
> This is the way we use to show/hide controls in wxWidgets. However,
> if you want to create/destroy the controls, we need to take a look at the
> source code to see where's the problem.
>
> Best,
> Xavi
>
> From: Aida Ninyerola [mailto:[email protected]]
> Sent: martes, 25 de octubre de 2011 0:17
> To: Xavier Planes
> Cc: [email protected]
> Subject: Re: [Gimias-developers] panel widget
>
> Hi,
>
> I needed to change some of the structure I had in the panel widget and now
> I
> am not able to achieve the result I previously had.
>
> I didn't want to use the show/hide functions because using this it is going
> to appear a grey empty place where is hidden what I want to show later.
> Using the same code now all the new controls appear in a wrong place
> ("result.jpg") but I want what appears in "final.jpg".
>
> I know is something difficult and maybe I'm not giving all the required
> information, but I would like to know what I'm possibly doing wrong or
> missing.
>
> Thank you very much!
> Aida
> 2011/10/14 Aida Ninyerola <[email protected]>
> Hi,
>
> I followed all your comments about the code and it worked without using
> show/hide functions.
>
> Thank you very much!
> Aida
>
> 2011/10/11 Xavier Planes <[email protected]>
> Hi Aida,
>
> You need to be carefully when using a sizer and the functions
> Detach() or Remove().Remove() will remove the child from the sizer and
> destroys it if it’s a sizer or spacer.
> http://docs.wxwidgets.org/2.8.10/wx_wxsizer.html#wxsizerremove
> http://docs.wxwidgets.org/2.8.10/wx_wxsizer.html#wxsizerdetach
>
> In your example, these lines will destroy the "SUR" labels but not
> the "Standard SUR" labels (m_label5 and m_label6):
> m_grid_sizer2->Detach(m_label3);
> m_grid_sizer2->Detach(m_label4);
> m_label3->Destroy();
> m_label4->Destroy();
> In the next piece of code m_grid_sizer2 will be detached from
> m_sizer3 but it will not be destroyed because when calling Remove() the
> sizer m_grid_sizer2 is not a child of m_sizer3:
> m_sizer3->Detach(m_grid_sizer2);
> m_sizer3->Remove(m_grid_sizer2);
>
> Finally m_sizer3 will be detached:
> m_sizer2->Detach(m_sizer3);
> m_sizer2->Remove(m_sizer3);
>
> At the end, the labels m_label5 and m_label6 are not destroyed and
> will be floating in the parent window because the sizer where they were
> inserted (m_grid_sizer2) has been detached from the main sizer (m_sizer2).
>
> I recommend you to better use show/hide functions instead of
> destroying the labels/sizers. This will simplify the code. Sometimes we add
> a checkbox called "Advanced" to show/hide some advanced controls on the
> window.
>
> Best,
> Xavi
>
>
> From: Aida Ninyerola [mailto:[email protected]]
> Sent: lunes, 10 de octubre de 2011 15:11
> To: [email protected]
> Subject: [Gimias-developers] panel widget
>
> Hi,
>
> During our process we create some controls in order to show the achieved
> results.
>
> wxStaticBox* m_sizer3_staticbox = new wxStaticBox(this, -1,
> wxT("Results of Quantificaction:"));
> m_sizer3 = new wxStaticBoxSizer(m_sizer3_staticbox, wxVERTICAL);
> m_grid_sizer2 = new wxFlexGridSizer(2, 2, 0, 0);
> m_label3 = new wxStaticText(this, wxID_ANY, wxT("SUR " + nameResult
> + ":\t"),wxDefaultPosition, wxDefaultSize,
> wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
> m_label3->SetFont(wxFont(8, wxDEFAULT, wxNORMAL, wxBOLD));
> m_label4 = new wxStaticText(this, wxID_ANY,
> wxT(wxString::Format("%.5f", numResult )),wxDefaultPosition, wxDefaultSize,
> wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
> m_label5 = new wxStaticText(this, wxID_ANY, wxT("Standard SUR
> :\t"),wxDefaultPosition, wxDefaultSize,
> wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
> m_label5->SetFont(wxFont(8, wxDEFAULT, wxNORMAL, wxBOLD));
> m_label6 = new wxStaticText(this, wxID_ANY,
> wxT(wxString::Format("%.5f", StandardResult )),wxDefaultPosition,
> wxDefaultSize, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL);
> m_grid_sizer2->Add(m_label3, 0,wxEXPAND|wxALL,5);
> m_grid_sizer2->Add(m_label4, 0,wxEXPAND|wxALL,5);
> m_grid_sizer2->Add(m_label5, 0,wxEXPAND|wxALL,5);
> m_grid_sizer2->Add(m_label6, 0,wxEXPAND|wxALL,5);
> m_sizer3->Add(m_grid_sizer2, 0, wxALL|wxEXPAND, 5);
> m_sizer2->Add(m_sizer3, 0, wxALL|wxEXPAND, 5);
>
> // Resize this
> // Cast a resize event
> wxSizeEvent resEvent(this->GetBestSize(), this->GetId());
> resEvent.SetEventObject(this);
> this->GetEventHandler()->ProcessEvent(resEvent);
> this->Refresh();
>
> At some point we need to destroy this controls. We have this code in order
> to achieve this
>
> //Remove static texts
> m_grid_sizer2->Detach(m_label3);
> m_grid_sizer2->Detach(m_label4);
> m_label3->Destroy();
> m_label4->Destroy();
>
> //Remove grid sizer
> m_sizer3->Detach(m_grid_sizer2);
> m_sizer3->Remove(m_grid_sizer2);
>
> //Remove sizer 3
> m_sizer3->Show(false);
> m_sizer2->Detach(m_sizer3);
> m_sizer2->Remove(m_sizer3);
> GetSizer()->Layout();
> GetSizer()->Fit(this);
>
> // Resize this
> // Cast a resize event
> wxSizeEvent resEvent(this->GetBestSize(), this->GetId());
> resEvent.SetEventObject(this);
> this->GetEventHandler()->ProcessEvent(resEvent);
>
> Although the creation works correctly, when we later try to destroy those
> controls, they are not destroyed and other parts of the panel widget are
> eliminated and all the panel widget of the processor stops working
> correctly.
>
> What is being done uncorrectly?
>
> Thank you very much,
> Aida
>
>
>
>
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Gimias-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gimias-developers