controls sizing, but not displaying in sizer

Eric Eric.Medlin at gmail.com
Mon Dec 4 10:37:00 PST 2006


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();
}







More information about the wx-users mailing list