bool wxWizardEx::Create(wxWindow *parent, int id, const wxString& title, const wxPoint& pos, long style) { bool result = wxDialog::Create(parent,id,title,pos,wxDefaultSize,style); m_posWizard = pos; DoCreateControls(); return result; }
bool wxTreeMultiXmlMapper::DoInitWizard(const wxString &start_tag) { bool allok = false; // clean up the control first m_ctrl->DeleteAllItems(); // reset the ID counter m_currentId = XMLMAP_BASE_ID; // obtain handle to document TiXmlHandle h(m_tiDoc); // find our first wizard declaration TiXmlHandle wizard = h.FirstChildElement(start_tag.c_str()); // we expect it to be an element, and we should go from there with // parsing categories and other stuff.. if(wizard.Element()) { // we skip all and look for the first category element TiXmlElement *cat = wizard.FirstChildElement(XMLMAP_TAG_CATEGORY).Element(); // go through the loop of creating all categories allok = (cat != 0); while(cat && allok) { // ok create a category root name, but only when we // have a name to give it if(cat->Attribute(XMLMAP_ATTR_CAPTION)) { wxTreeMultiItem item = AddCategory(cat, wxTreeMultiItem(0)); allok = DoCreateControls(cat, item, 0, 0); } // find a next one if(allok) cat = cat->NextSiblingElement(XMLMAP_TAG_CATEGORY); } } return allok; }
bool wxTreeMultiXmlMapper::DoCreateControls(TiXmlElement *cat, wxTreeMultiItem &pitem, wxWindow *pwnd, wxSizer *szr) { bool allOk = true; wxCHECK(cat, false); wxString value; wxWindow *wnd = 0; // go through all siblings of this TiXmlNode *node = cat->FirstChild(); while(node && allOk) { // cast to element. When it is an element, work this TiXmlElement *el = node->ToElement(); if(el) { value = el->Value(); // when we are dealing with a <row> element, we introduce a wxBoxSizer + panel // to add more on one row if(value.IsSameAs(XMLMAP_TAG_ROW, false)) { // we are in a row. All elements inside need to be parent // of this element, and we use a sizer to layout wxPanel *pnl = new wxPanel((pwnd != 0 ? pwnd : m_ctrl), -1); wxBoxSizer *bsz = new wxBoxSizer(wxHORIZONTAL); allOk = DoCreateControls(el, pitem, pnl, bsz); if(allOk) { // ok now we have all added elements, set the sizer and // add the item when we have no parent control nomore pnl->SetSizerAndFit(bsz); if(pwnd == 0) { // add the window m_ctrl->AppendWindow(pitem, pnl); } } else delete bsz; } else if(value.IsSameAs(XMLMAP_TAG_CATEGORY, false)) // is it an <category> element? { if(!pwnd) { // only allow when we have no parent window wxTreeMultiItem item = AddCategory(el, pitem); allOk = DoCreateControls(el, item, 0, 0); } else { // we do not allow a category inside another window! // so we report this as an error wxLogError(_("Cannot have a <" XMLMAP_TAG_CATEGORY "> inside <" XMLMAP_TAG_ROW "> tags!")); allOk = false; } } else if(value.IsSameAs(XMLMAP_TAG_CHECKBOX, false)) // is it a <checkbox> element? wnd = AddCheckBox(el, (pwnd != 0 ? pwnd : m_ctrl)); else if(value.IsSameAs(XMLMAP_TAG_BUTTON, false)) // is it a <button> element? wnd = AddButton(el, (pwnd != 0 ? pwnd : m_ctrl)); else // we encountered a strange element, just ignore allOk = true; // if we have a window to add, do this. if(wnd) { // add to sizer when there is one, else // do not add but trust the parent will be added if(szr) szr->Add(wnd, 0, wxALIGN_CENTER_VERTICAL); else m_ctrl->AppendWindow(pitem, wnd); allOk = (wnd != 0); wnd = 0; } } // get next sibling on this level if(allOk) node = node->NextSibling(); } return allOk; }