[wxMSW 2.4.2] How to derive correctly from wxPanel

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
nihil84
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Jan 10, 2005 11:17 am

[wxMSW 2.4.2] How to derive correctly from wxPanel

Post by nihil84 » Mon Jan 10, 2005 11:43 am

Hi to all, I hope this is the right place to post my question. If not can you suggest where it is?

I have some problems with sizers when I try to write my own widgets (i.e.: derived from wxPanel).

Obviously I create end setup all needed sizer inside it and I add itself in a sizer also in the parent window but... nothing works

Where can I find some examples about?
Any help is welcome.

Tanks
/\/ / /-/ / /_ Copyleft (L) 1984. All Rights Reversed

wxNewbi
Knows some wx things
Knows some wx things
Posts: 26
Joined: Mon Nov 15, 2004 11:27 pm
Location: London UK
Contact:

Post by wxNewbi » Mon Jan 10, 2005 11:57 am

What error are you getting or have you got a code snippet. this could make it easier to understand the problem :D
Keep it real, Keep it free, Keep it GPL

nihil84
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Jan 10, 2005 11:17 am

Post by nihil84 » Mon Jan 10, 2005 2:04 pm

Sorry. Here some code.

This is the constructor of the class derived from wxPanel:

Code: Select all

MyPanel::MyPanel(wxWindow* parent,wxWindowID id) {
	this->Create(parent,id,wxDefaultPosition,wxSize(300,200));
	
    topsizer = new wxBoxSizer(wxVERTICAL);  // declared as class-member
   SetBackgroundColour(wxColour(254,241,12)); // YELLOW for test

    topsizer->Add(
	new wxTextCtrl( this, -1, "My text.", wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE),
	1,            // make vertically stretchable
	wxEXPAND |    // make horizontally stretchable
	wxALL,        //   and make border all around
	10 );         // set border width to 10


    this->SetSizer(topsizer);
    topsizer->SetSizeHints(this);
}
here how I add the panel in the main frame:

Code: Select all

	mainsizer->Add(new EstimateCtrl(this,-1),1,wxEXPAND,0);

	this->SetSizer(mainsizer);
	mainsizer->SetSizeHints(this);
But if I use the class in this way the panel is resized correcly (I can see the yellow spot became bigger or smaller) but the text control inside not and the border arount it is not displayed. why?

please, help me.
/\/ / /-/ / /_ Copyleft (L) 1984. All Rights Reversed

nihil84
In need of some credit
In need of some credit
Posts: 3
Joined: Mon Jan 10, 2005 11:17 am

Post by nihil84 » Mon Jan 10, 2005 2:16 pm

nihil84 wrote: here how I add the panel in the main frame:

Code: Select all

	mainsizer->Add(new EstimateCtrl(this,-1),1,wxEXPAND,0);

	this->SetSizer(mainsizer);
	mainsizer->SetSizeHints(this);
OPS.I make a mistake while reporting. Correct is:

Code: Select all

	mainsizer->Add(new MyPanel(this,-1),1,wxEXPAND,0);
/\/ / /-/ / /_ Copyleft (L) 1984. All Rights Reversed

Post Reply