Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

controls sizing, but not displaying in sizer

16 views
Skip to first unread message

Eric

unread,
Nov 16, 2006, 1:41:16 PM11/16/06
to
I have the following gui structure. The frame contains a box sizer
with two panels in it. The right panel contains a box size. That box
sizer contains only another box sizer. This box sizer contains a
static box sizer, box sizer, and grid sizer. The static box sizer
contains only a flexgrid sizer that contains three static text items.
Now the problem is when I add some more controls to this flexgrid
sizer. They appear on the left panel and not on the right panel inside
the flexgrid sizer. They are laidout correctly though after calling
Layout on the flexgrid sizer. Also the flexgrid sizer doesn't grow
when they are added until I change the size of the frame. Then the
sizers become large enough to hold the controls but they are still
displayed on the other side of the frame. I have called Layout on the
frames sizer and flexgrid sizer. I have also called refresh(true and
false) followed by update on the frame. What am I doing wrong?

Eric

unread,
Nov 16, 2006, 1:43:27 PM11/16/06
to
Forgot to mention I using 2.8.0 rc1 on windows 2000. But I have had
similar problems on OSX with 2.6.0 and 2.7.1. I never did find a fix.

Eric

unread,
Nov 16, 2006, 3:31:58 PM11/16/06
to
If I call Layout on the right panel or the box sizer on the right panel
it will arrange the controls correctly and the flexgrid sizer they are
in will grow large enough to hold them. However they are still being
drawn on the left panel. Also the controls don't work, ie my check
boxes cannot be checked or unchecked.

Eric

unread,
Nov 20, 2006, 9:49:31 AM11/20/06
to
Does anyone know what I am doing wrong? Are you suppose to call layout
on every sizer from the top frame till where you add widgets?

Eric

unread,
Nov 30, 2006, 10:06:06 AM11/30/06
to
Still no luck. Any suggestions? I really would like to have these
controls dynamic, so I can add and delete as many as I want. If anyone
needs more details about the problem just let me know.

Eric

unread,
Dec 4, 2006, 1:37:00 PM12/4/06
to
Here is the code I am using to add controls to the sizer with lots of
stuff commented out for testing. The following code draws the check
boxes on the left hand side instead of the right, but the static sizer
on the right hand side does change size like they are inside it, but
they are not. Also the check boxes I am adding for testing do not
work. You can not toggle them. They are always checked. It is like
they do not get the mouse event or something.


void MainFrame::loadTiff(const wxString& filename){
// read tiff
wxString name = wxFileName(filename).GetName();
tiffManager.addTiff(filename.c_str(), name.c_str());
// display tiff
unsigned int tiffPos = tiffManager.size()-1;
// find and set color
int start = name.First('_');
int end = name.Find('.', true);
wxString pantone = name.Mid(start+1, (end-start)-1);
Colors::Color color = colors[pantone.c_str()];
tiffManager.setColor(tiffPos, reinterpret_cast<unsigned
char*>(&color));
// display tiff in viewer
//viewer->loadTexture(tiffPos);
// create checkbox, textctrl, color selector button
TiffControls* tiffControl = new TiffControls;
tiffControl->activeCheckBox = new wxCheckBox(this, -1, "");
tiffControl->activeCheckBox->SetValue(true);
Connect(tiffControl->activeCheckBox->GetId(),
wxEVT_COMMAND_CHECKBOX_CLICKED,
reinterpret_cast<wxObjectEventFunction>(&MainFrame::onViewClick));
wxSizer *sizer = XRCCTRL(*this, "view",
wxStaticText)->GetContainingSizer();
sizer->Add(tiffControl->activeCheckBox, 0, wxALIGN_CENTER);
//tiffControl->tiffNameTextCtrl = new wxTextCtrl(this, -1 , name,
wxDefaultPosition, wxSize(190, -1), wxTE_READONLY);
//sizer->Add(tiffControl->tiffNameTextCtrl, 0, wxALIGN_CENTER);
//tiffControl->colorSizer = new wxBoxSizer(wxHORIZONTAL);
//tiffControl->colorSwatch = new wxPanel(this, -1, wxDefaultPosition,
wxSize(25,25));
//tiffControl->colorSwatch->SetBackgroundColour(wxColour(color.r,
color.g, color.b));
//tiffControl->colorSwatch->SetWindowStyle(wxSUNKEN_BORDER);
//tiffControl->colorButton = new wxButton(this, -1, "",
wxDefaultPosition, wxSize(60,-1));
//Connect(tiffControl->colorButton->GetId(),
wxEVT_COMMAND_BUTTON_CLICKED,
// reinterpret_cast<wxObjectEventFunction>(&MainFrame::onColorClick));
//tiffControl->colorSizer->Add(tiffControl->colorSwatch, 0,
wxALIGN_CENTER);
//tiffControl->colorSizer->Add(tiffControl->colorButton, 0,
wxALIGN_CENTER);
//sizer->Add(tiffControl->colorSizer, 0, wxALIGN_CENTER);
tiffControls.push_back(tiffControl);
// update gui
//GetSizer()->Layout();
XRCCTRL(*this, "controls", wxPanel)->GetSizer()->Layout(); //
works bettter than the line above, but not much better
Update();
}

Eric

unread,
Dec 6, 2006, 11:03:21 AM12/6/06
to
Just for refrence the problem was the parent of the controls should
have been the controls panel and not the main frame.

0 new messages