wxPanel Children Update (wxMac)

Hiroshi ABE habe36 at gmail.com
Tue Dec 18 00:49:54 PST 2007


2007/12/15, ABE Hiroshi <habe36 at gmail.com>:
>
> I'm working with wxWidgets-2.6.4 on MacOSX 10.4 and Windows XP Sp2.
>
> My problem is that an initial value of wxTextCtrl is not displayed in
> certain situation on Mac.
>


I wrote a sample program to reproduce my problem.
Ii would be so appreciated if you would check the program.

Thank you.

#include "wx/wx.h"


#if !defined(__WXMSW__) && !defined(__WXPM__)

    #include "../sample.xpm"

#endif


class MyApp : public wxApp

{

public:

    virtual bool OnInit();

};


class MyFrame : public wxFrame

{

public:

    MyFrame(const wxString& title);


    void OnChoice(wxCommandEvent& event);


private:

    DECLARE_EVENT_TABLE()


 wxPanel* GenPanel( int n );

 wxChoice* m_choice;

wxPanel* m_panel;

wxBoxSizer* m_sizer;

};


enum {

ID_CHOICE =3D 2222

};


BEGIN_EVENT_TABLE(MyFrame, wxFrame)

EVT_CHOICE(ID_CHOICE, MyFrame::OnChoice)

END_EVENT_TABLE()


IMPLEMENT_APP(MyApp)



bool MyApp::OnInit()

{

    MyFrame *frame =3D new MyFrame(_T("Test App"));

    frame->Show(true);

    return true;

}


MyFrame::MyFrame(const wxString& title)

       : wxFrame(NULL, wxID_ANY, title)

{

    SetIcon(wxICON(sample));


 m_sizer =3D new wxBoxSizer(wxVERTICAL);


 wxString m_choice_list[] =3D {_T("A"),_T("B"),_T("C")};

int n =3D 3;

m_choice =3D new wxChoice( this, ID_CHOICE, wxDefaultPosition, wxDefaultSiz=
e,
n, m_choice_list, 0 );

m_sizer->Add( m_choice, 0, wxALL, 5 );

m_panel =3D GenPanel(0);

m_sizer->Add( m_panel, 0, wxEXPAND, 5 );

 SetSizer(m_sizer);

Layout();

}


wxPanel*

MyFrame::GenPanel( int n ) {

wxPanel* panel =3D new wxPanel( this, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxTAB_TRAVERSAL );

wxBoxSizer* _sizer =3D new wxBoxSizer(wxVERTICAL);

switch( n ) {

case 0:

_sizer->Add( new wxTextCtrl( panel, wxID_ANY, _T("AAA") ) );

break;

case 1:

_sizer->Add( new wxTextCtrl( panel, wxID_ANY, _T("BBB") ) );

break;

case 2:

_sizer->Add( new wxTextCtrl( panel, wxID_ANY, _T("CCC") ) );

break;

default:

exit(0);

}

panel->SetSizer( _sizer );

panel->Layout();

return panel;

}


// event handlers

void MyFrame::OnChoice(wxCommandEvent& event) {

int sel =3D m_choice->GetSelection();

 m_sizer->Detach( m_panel );

m_panel->Destroy();

m_panel =3D GenPanel( sel );

m_sizer->Add( m_panel, 0, wxALL|wxEXPAND, 5 );

m_sizer->Layout();


 Refresh();

Update();

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20071218/93a=
7a2a7/attachment.htm


More information about the wx-users mailing list