// ----------------------------------------------------------------------------- // CSIPParamContainerBase::ParseL // ----------------------------------------------------------------------------- // void CSIPParamContainerBase::ParseL (const TDesC8& aValue) { CSIPTokenizer* tokenizer = CSIPTokenizer::NewLC (aValue,iParamSeparator); for (TInt i=0; i < tokenizer->Tokens().Count(); i++) { TPtrC8 pname; TPtrC8 pvalue(KNullDesC8); TBool hasValue = CSIPParam::ParseL(tokenizer->Tokens()[i],pname,pvalue); CSIPParam* param = CSIPParam::NewLC(pname); RStringF pnameStr = param->Name(); if (HasParam(pnameStr)) { User::Leave(KErrSipCodecDuplicateParam); } CheckAndUpdateParamL(pnameStr,hasValue,pvalue); if (hasValue) { param->SetValueL(pvalue,AddQuotesWhenEncoding(pnameStr)); } User::LeaveIfError(iParams.Append(param)); CleanupStack::Pop(param); } CleanupStack::PopAndDestroy(tokenizer); }
wxObject *wxToolBarXmlHandler::DoCreateResource() { if (m_class == wxT("tool")) { wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: tool not within a toolbar!")); if (GetPosition() != wxDefaultPosition) { m_toolbar->AddTool(GetID(), GetBitmap(wxT("bitmap"), wxART_TOOLBAR), GetBitmap(wxT("bitmap2"), wxART_TOOLBAR), GetBool(wxT("toggle")), GetPosition().x, GetPosition().y, NULL, GetText(wxT("tooltip")), GetText(wxT("longhelp"))); } else { wxItemKind kind = wxITEM_NORMAL; if (GetBool(wxT("radio"))) kind = wxITEM_RADIO; if (GetBool(wxT("toggle"))) { wxASSERT_MSG( kind == wxITEM_NORMAL, _T("can't have both toggleable and radion button at once") ); kind = wxITEM_CHECK; } m_toolbar->AddTool(GetID(), GetText(wxT("label")), GetBitmap(wxT("bitmap"), wxART_TOOLBAR), GetBitmap(wxT("bitmap2"), wxART_TOOLBAR), kind, GetText(wxT("tooltip")), GetText(wxT("longhelp"))); if ( GetBool(wxT("disabled")) ) m_toolbar->EnableTool(GetID(), false); } return m_toolbar; // must return non-NULL } else if (m_class == wxT("separator")) { wxCHECK_MSG(m_toolbar, NULL, wxT("Incorrect syntax of XRC resource: separator not within a toolbar!")); m_toolbar->AddSeparator(); return m_toolbar; // must return non-NULL } else /*<object class="wxToolBar">*/ { int style = GetStyle(wxT("style"), wxNO_BORDER | wxTB_HORIZONTAL); #ifdef __WXMSW__ if (!(style & wxNO_BORDER)) style |= wxNO_BORDER; #endif XRC_MAKE_INSTANCE(toolbar, wxToolBar) toolbar->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), style, GetName()); wxSize bmpsize = GetSize(wxT("bitmapsize")); if (!(bmpsize == wxDefaultSize)) toolbar->SetToolBitmapSize(bmpsize); wxSize margins = GetSize(wxT("margins")); if (!(margins == wxDefaultSize)) toolbar->SetMargins(margins.x, margins.y); long packing = GetLong(wxT("packing"), -1); if (packing != -1) toolbar->SetToolPacking(packing); long separation = GetLong(wxT("separation"), -1); if (separation != -1) toolbar->SetToolSeparation(separation); if (HasParam(wxT("bg"))) toolbar->SetBackgroundColour(GetColour(wxT("bg"))); wxXmlNode *children_node = GetParamNode(wxT("object")); if (!children_node) children_node = GetParamNode(wxT("object_ref")); if (children_node == NULL) return toolbar; m_isInside = true; m_toolbar = toolbar; wxXmlNode *n = children_node; while (n) { if ((n->GetType() == wxXML_ELEMENT_NODE) && (n->GetName() == wxT("object") || n->GetName() == wxT("object_ref"))) { wxObject *created = CreateResFromNode(n, toolbar, NULL); wxControl *control = wxDynamicCast(created, wxControl); if (!IsOfClass(n, wxT("tool")) && !IsOfClass(n, wxT("separator")) && control != NULL) toolbar->AddControl(control); } n = n->GetNext(); } m_isInside = false; m_toolbar = NULL; toolbar->Realize(); if (m_parentAsWindow && !GetBool(wxT("dontattachtoframe"))) { wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame); if (parentFrame) parentFrame->SetToolBar(toolbar); } return toolbar; } }
wxObject* MYwxTreebookXmlHandler::DoCreateResource() { if(m_class == wxT("wxTreebook")) { XRC_MAKE_INSTANCE(tbk, wxTreebook) tbk->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style")), GetName()); wxTreebook* old_par = m_tbk; m_tbk = tbk; bool old_ins = m_isInside; m_isInside = true; wxArrayTbkPageIndexes old_treeContext = m_treeContext; m_treeContext.Clear(); CreateChildren(m_tbk, true /*only this handler*/); wxXmlNode* node = GetParamNode(wxT("object")); int pageIndex = 0; for(unsigned int i = 0; i < m_tbk->GetPageCount(); i++) { if(m_tbk->GetPage(i)) { wxXmlNode* child = node->GetChildren(); while(child) { if(child->GetName() == wxT("expanded") && child->GetNodeContent() == wxT("1")) m_tbk->ExpandNode(pageIndex, true); child = child->GetNext(); } pageIndex++; } } m_treeContext = old_treeContext; m_isInside = old_ins; m_tbk = old_par; return tbk; } // else ( m_class == wxT("treebookpage") ) wxXmlNode* n = GetParamNode(wxT("object")); wxWindow* wnd = NULL; if(!n) n = GetParamNode(wxT("object_ref")); if(n) { bool old_ins = m_isInside; m_isInside = false; wxObject* item = CreateResFromNode(n, m_tbk, NULL); m_isInside = old_ins; wnd = wxDynamicCast(item, wxWindow); } size_t depth = GetLong(wxT("depth")); if(depth <= m_treeContext.GetCount()) { // first prepare the icon int imgIndex = wxNOT_FOUND; if(HasParam(wxT("bitmap"))) { wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); wxImageList* imgList = m_tbk->GetImageList(); if(imgList == NULL) { imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight()); m_tbk->AssignImageList(imgList); } imgIndex = imgList->Add(bmp); } else if(HasParam(wxT("image"))) { if(m_tbk->GetImageList()) { imgIndex = GetLong(wxT("image")); } else // image without image list? { } } // then add the page to the corresponding parent if(depth < m_treeContext.GetCount()) m_treeContext.RemoveAt(depth, m_treeContext.GetCount() - depth); if(depth == 0) { m_tbk->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")), imgIndex); } else { m_tbk->InsertSubPage(m_treeContext.Item(depth - 1), wnd, GetText(wxT("label")), GetBool(wxT("selected")), imgIndex); } m_treeContext.Add(m_tbk->GetPageCount() - 1); } else { // ReportParamError("depth", "invalid depth"); } return wnd; }
wxHtmlTag::wxHtmlTag(wxHtmlTag *parent, const wxString *source, const wxString::const_iterator& pos, const wxString::const_iterator& end_pos, wxHtmlTagsCache *cache, wxHtmlEntitiesParser *entParser) { /* Setup DOM relations */ m_Next = NULL; m_FirstChild = m_LastChild = NULL; m_Parent = parent; if (parent) { m_Prev = m_Parent->m_LastChild; if (m_Prev == NULL) m_Parent->m_FirstChild = this; else m_Prev->m_Next = this; m_Parent->m_LastChild = this; } else m_Prev = NULL; /* Find parameters and their values: */ wxChar c wxDUMMY_INITIALIZE(0); // fill-in name, params and begin pos: wxString::const_iterator i(pos+1); // find tag's name and convert it to uppercase: while ((i < end_pos) && ((c = *(i++)) != wxT(' ') && c != wxT('\r') && c != wxT('\n') && c != wxT('\t') && c != wxT('>') && c != wxT('/'))) { if ((c >= wxT('a')) && (c <= wxT('z'))) c -= (wxT('a') - wxT('A')); m_Name << c; } // if the tag has parameters, read them and "normalize" them, // i.e. convert to uppercase, replace whitespaces by spaces and // remove whitespaces around '=': if (*(i-1) != wxT('>')) { #define IS_WHITE(c) (c == wxT(' ') || c == wxT('\r') || \ c == wxT('\n') || c == wxT('\t')) wxString pname, pvalue; wxChar quote; enum { ST_BEFORE_NAME = 1, ST_NAME, ST_BEFORE_EQ, ST_BEFORE_VALUE, ST_VALUE } state; quote = 0; state = ST_BEFORE_NAME; while (i < end_pos) { c = *(i++); if (c == wxT('>') && !(state == ST_VALUE && quote != 0)) { if (state == ST_BEFORE_EQ || state == ST_NAME) { m_ParamNames.Add(pname); m_ParamValues.Add(wxGetEmptyString()); } else if (state == ST_VALUE && quote == 0) { m_ParamNames.Add(pname); if (entParser) m_ParamValues.Add(entParser->Parse(pvalue)); else m_ParamValues.Add(pvalue); } break; } switch (state) { case ST_BEFORE_NAME: if (!IS_WHITE(c)) { pname = c; state = ST_NAME; } break; case ST_NAME: if (IS_WHITE(c)) state = ST_BEFORE_EQ; else if (c == wxT('=')) state = ST_BEFORE_VALUE; else pname << c; break; case ST_BEFORE_EQ: if (c == wxT('=')) state = ST_BEFORE_VALUE; else if (!IS_WHITE(c)) { m_ParamNames.Add(pname); m_ParamValues.Add(wxGetEmptyString()); pname = c; state = ST_NAME; } break; case ST_BEFORE_VALUE: if (!IS_WHITE(c)) { if (c == wxT('"') || c == wxT('\'')) quote = c, pvalue = wxGetEmptyString(); else quote = 0, pvalue = c; state = ST_VALUE; } break; case ST_VALUE: if ((quote != 0 && c == quote) || (quote == 0 && IS_WHITE(c))) { m_ParamNames.Add(pname); if (quote == 0) { // VS: backward compatibility, no real reason, // but wxHTML code relies on this... :( pvalue.MakeUpper(); } if (entParser) m_ParamValues.Add(entParser->Parse(pvalue)); else m_ParamValues.Add(pvalue); state = ST_BEFORE_NAME; } else pvalue << c; break; } } #undef IS_WHITE } m_Begin = i; cache->QueryTag(pos, source->end(), &m_End1, &m_End2, &m_hasEnding); if (m_End1 > end_pos) m_End1 = end_pos; if (m_End2 > end_pos) m_End2 = end_pos; #if WXWIN_COMPATIBILITY_2_8 m_sourceStart = source->begin(); #endif // Try to parse any style parameters that can be handled simply by // converting them to the equivalent HTML 3 attributes: this is a far cry // from perfect but better than nothing. static const struct EquivAttr { const char *style; const char *attr; } equivAttrs[] = { { "text-align", "ALIGN" }, { "width", "WIDTH" }, { "vertical-align", "VALIGN" }, { "background", "BGCOLOR" }, }; wxHtmlStyleParams styleParams(*this); for ( unsigned n = 0; n < WXSIZEOF(equivAttrs); n++ ) { const EquivAttr& ea = equivAttrs[n]; if ( styleParams.HasParam(ea.style) && !HasParam(ea.attr) ) { m_ParamNames.Add(ea.attr); m_ParamValues.Add(styleParams.GetParam(ea.style)); } } }
wxObject *wxNotebookXmlHandler::DoCreateResource() { if (m_class == wxT("notebookpage")) { wxXmlNode *n = GetParamNode(wxT("object")); if ( !n ) n = GetParamNode(wxT("object_ref")); if (n) { bool old_ins = m_isInside; m_isInside = false; wxObject *item = CreateResFromNode(n, m_notebook, NULL); m_isInside = old_ins; wxWindow *wnd = wxDynamicCast(item, wxWindow); if (wnd) { m_notebook->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected"))); if ( HasParam(wxT("bitmap")) ) { wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); wxImageList *imgList = m_notebook->GetImageList(); if ( imgList == NULL ) { imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() ); m_notebook->AssignImageList( imgList ); } int imgIndex = imgList->Add(bmp); m_notebook->SetPageImage(m_notebook->GetPageCount()-1, imgIndex ); } } else wxLogError(wxT("Error in resource.")); return wnd; } else { wxLogError(wxT("Error in resource: no control within notebook's <page> tag.")); return NULL; } } else { XRC_MAKE_INSTANCE(nb, wxNotebook) nb->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style")), GetName()); SetupWindow(nb); wxNotebook *old_par = m_notebook; m_notebook = nb; bool old_ins = m_isInside; m_isInside = true; CreateChildren(m_notebook, true/*only this handler*/); m_isInside = old_ins; m_notebook = old_par; return nb; } }
wxObject *wxTreebookXmlHandler::DoCreateResource() { if (m_class == wxT("wxTreebook")) { XRC_MAKE_INSTANCE(tbk, wxTreebook) tbk->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style")), GetName()); wxTreebook * old_par = m_tbk; m_tbk = tbk; bool old_ins = m_isInside; m_isInside = true; wxArrayTbkPageIndexes old_treeContext = m_treeContext; m_treeContext.Clear(); CreateChildren(m_tbk, true/*only this handler*/); m_treeContext = old_treeContext; m_isInside = old_ins; m_tbk = old_par; return tbk; } // else ( m_class == wxT("treebookpage") ) wxXmlNode *n = GetParamNode(wxT("object")); wxWindow *wnd = NULL; if ( !n ) n = GetParamNode(wxT("object_ref")); if (n) { bool old_ins = m_isInside; m_isInside = false; wxObject *item = CreateResFromNode(n, m_tbk, NULL); m_isInside = old_ins; wnd = wxDynamicCast(item, wxWindow); if (wnd == NULL && item != NULL) wxLogError(wxT("Error in resource: control within treebook's <page> tag is not a window.")); } size_t depth = GetLong( wxT("depth") ); if( depth <= m_treeContext.Count() ) { // first prepare the icon int imgIndex = wxNOT_FOUND; if ( HasParam(wxT("bitmap")) ) { wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); wxImageList *imgList = m_tbk->GetImageList(); if ( imgList == NULL ) { imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() ); m_tbk->AssignImageList( imgList ); } imgIndex = imgList->Add(bmp); } // then add the page to the corresponding parent if( depth < m_treeContext.Count() ) m_treeContext.RemoveAt(depth, m_treeContext.Count() - depth ); if( depth == 0) { m_tbk->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")), imgIndex); } else { m_tbk->InsertSubPage(m_treeContext.Item(depth - 1), wnd, GetText(wxT("label")), GetBool(wxT("selected")), imgIndex); } m_treeContext.Add( m_tbk->GetPageCount() - 1); } else wxLogError(wxT("Error in resource. wxTreebookPage has an invalid depth.")); return wnd; }
wxObject *wxMenuXmlHandler::DoCreateResource() { if (m_class == wxT("wxMenu")) { wxMenu *menu = m_instance ? wxStaticCast(m_instance, wxMenu) : new wxMenu(GetStyle()); wxString title = GetText(wxT("label")); wxString help = GetText(wxT("help")); bool oldins = m_insideMenu; m_insideMenu = true; CreateChildren(menu, true/*only this handler*/); m_insideMenu = oldins; wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar); if (p_bar) { p_bar->Append(menu, title); } else { wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu); if (p_menu) { p_menu->Append(GetID(), title, menu, help); if (HasParam(wxT("enabled"))) p_menu->Enable(GetID(), GetBool(wxT("enabled"))); } } return menu; } else { wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu); if (m_class == wxT("separator")) p_menu->AppendSeparator(); else if (m_class == wxT("break")) p_menu->Break(); else /*wxMenuItem*/ { int id = GetID(); wxString label = GetText(wxT("label")); wxString accel = GetText(wxT("accel"), false); wxString fullLabel = label; if (!accel.empty()) fullLabel << wxT("\t") << accel; wxItemKind kind = wxITEM_NORMAL; if (GetBool(wxT("radio"))) kind = wxITEM_RADIO; if (GetBool(wxT("checkable"))) { if ( kind != wxITEM_NORMAL ) { ReportParamError ( "checkable", "menu item can't have both <radio> and <checkable> properties" ); } kind = wxITEM_CHECK; } wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel, GetText(wxT("help")), kind); #if (!defined(__WXMSW__) && !defined(__WXPM__)) || wxUSE_OWNER_DRAWN if (HasParam(wxT("bitmap"))) { // currently only wxMSW has support for using different checked // and unchecked bitmaps for menu items #ifdef __WXMSW__ if (HasParam(wxT("bitmap2"))) mitem->SetBitmaps(GetBitmap(wxT("bitmap2"), wxART_MENU), GetBitmap(wxT("bitmap"), wxART_MENU)); else #endif // __WXMSW__ mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU)); } #endif p_menu->Append(mitem); mitem->Enable(GetBool(wxT("enabled"), true)); if (kind == wxITEM_CHECK) mitem->Check(GetBool(wxT("checked"))); } return NULL; } }
wxObject *wxChoicebookXmlHandler::DoCreateResource() { if (m_class == wxT("choicebookpage")) { wxXmlNode *n = GetParamNode(wxT("object")); if ( !n ) n = GetParamNode(wxT("object_ref")); if (n) { bool old_ins = m_isInside; m_isInside = false; wxObject *item = CreateResFromNode(n, m_choicebook, NULL); m_isInside = old_ins; wxWindow *wnd = wxDynamicCast(item, wxWindow); if (wnd) { m_choicebook->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected"))); if ( HasParam(wxT("bitmap")) ) { wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); wxImageList *imgList = m_choicebook->GetImageList(); if ( imgList == NULL ) { imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() ); m_choicebook->AssignImageList( imgList ); } int imgIndex = imgList->Add(bmp); m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1, imgIndex ); } else if ( HasParam(wxT("image")) ) { if ( m_choicebook->GetImageList() ) { m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1, GetLong(wxT("image")) ); } else // image without image list? { ReportError(n, "image can only be used in conjunction " "with imagelist"); } } } else { ReportError(n, "choicebookpage child must be a window"); } return wnd; } else { ReportError("choicebookpage must have a window child"); return NULL; } } else { XRC_MAKE_INSTANCE(nb, wxChoicebook) nb->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style")), GetName()); wxImageList *imagelist = GetImageList(); if ( imagelist ) nb->AssignImageList(imagelist); wxChoicebook *old_par = m_choicebook; m_choicebook = nb; bool old_ins = m_isInside; m_isInside = true; CreateChildren(m_choicebook, true/*only this handler*/); m_isInside = old_ins; m_choicebook = old_par; return nb; } }
wxObject *wxPropertySheetDialogXmlHandler::DoCreateResource() { if (m_class == wxT("propertysheetpage")) { wxXmlNode *n = GetParamNode(wxT("object")); if (!n) n = GetParamNode(wxT("object_ref")); if (n) { wxBookCtrlBase *bookctrl = m_dialog->GetBookCtrl(); bool old_ins = m_isInside; m_isInside = false; wxObject *item = CreateResFromNode(n, bookctrl, NULL); m_isInside = old_ins; wxWindow *wnd = wxDynamicCast(item, wxWindow); if (wnd) { bookctrl->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected"))); if (HasParam(wxT("bitmap"))) { wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); wxImageList *imgList = bookctrl->GetImageList(); if (imgList == NULL) { imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight()); bookctrl->AssignImageList(imgList); } int imgIndex = imgList->Add(bmp); bookctrl->SetPageImage(bookctrl->GetPageCount()-1, imgIndex); } } else { ReportError(n, "propertysheetpage child must be a window"); } return wnd; } else { ReportError("propertysheetpage must have a window child"); return NULL; } } else { XRC_MAKE_INSTANCE(dlg, wxPropertySheetDialog) dlg->Create(m_parentAsWindow, GetID(), GetText(wxT("title")), GetPosition(), GetSize(), GetStyle(), GetName()); if (HasParam(wxT("icon"))) dlg->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON)); SetupWindow(dlg); wxPropertySheetDialog *old_par = m_dialog; m_dialog = dlg; bool old_ins = m_isInside; m_isInside = true; CreateChildren(m_dialog, true/*only this handler*/); m_isInside = old_ins; m_dialog = old_par; if (GetBool(wxT("centered"), false)) dlg->Centre(); wxString buttons = GetText(wxT("buttons")); if (!buttons.IsEmpty()) { int flags = 0; if (buttons.Find(wxT("wxOK")) != wxNOT_FOUND) flags |= wxOK; if (buttons.Find(wxT("wxCANCEL")) != wxNOT_FOUND) flags |= wxCANCEL; if (buttons.Find(wxT("wxYES")) != wxNOT_FOUND) flags |= wxYES; if (buttons.Find(wxT("wxNO")) != wxNOT_FOUND) flags |= wxNO; if (buttons.Find(wxT("wxHELP")) != wxNOT_FOUND) flags |= wxHELP; if (buttons.Find(wxT("wxNO_DEFAULT")) != wxNOT_FOUND) flags |= wxNO_DEFAULT; dlg->CreateButtons(flags); } return dlg; } }
//----------------------------------------------------------------------------- bool GoCommandHandle::Parse(const char* params) { static const std::string argBinc = "binc"; static const std::string argBtime = "btime"; static const std::string argDepth = "depth"; static const std::string argInfinite = "infinite"; static const std::string argMovestogo = "movestogo"; static const std::string argMovetime = "movetime"; static const std::string argNodes = "nodes"; static const std::string argPonder = "ponder"; static const std::string argSearchmoves = "searchmoves"; static const std::string argWinc = "winc"; static const std::string argWtime = "wtime"; infinite = false; ponder = false; depth = 0; movestogo = 0; binc = 0; btime = 0; movetime = 0; nodes = 0; winc = 0; wtime = 0; bool invalid = false; while (!invalid && params && *NextWord(params)) { if (ParamMatch(argSearchmoves, params)) { Output() << "searchmoves not implemented!"; // TODO break; } if (HasParam(argInfinite, infinite, params) || HasParam(argPonder, ponder, params) || NumberParam(argDepth, depth, params, invalid) || NumberParam(argMovestogo, movestogo, params, invalid) || NumberParam(argBinc, binc, params, invalid) || NumberParam(argBtime, btime, params, invalid) || NumberParam(argMovetime, movetime, params, invalid) || NumberParam(argNodes, nodes, params, invalid) || NumberParam(argWinc, winc, params, invalid) || NumberParam(argWtime, wtime, params, invalid)) { continue; } Output() << "Unexpected token: " << params; return false; } if (invalid) { Output() << "usage: " << Usage(); return false; } if (infinite || ponder) { depth = 0; movestogo = 0; binc = 0; btime = 0; movetime = 0; nodes = 0; winc = 0; wtime = 0; } return true; }
wxObject *wxAuiToolBarXmlHandler::DoCreateResource() { if (m_class == wxS("tool")) { if ( !m_toolbar ) { ReportError("tool only allowed inside a wxAuiToolBar"); return NULL; } wxItemKind kind = wxITEM_NORMAL; if (GetBool(wxS("radio"))) kind = wxITEM_RADIO; if (GetBool(wxS("toggle"))) { if ( kind != wxITEM_NORMAL ) { ReportParamError ( "toggle", "tool can't have both <radio> and <toggle> properties" ); } kind = wxITEM_CHECK; } #if wxUSE_MENUS // check whether we have dropdown tag inside wxMenu *menu = NULL; // menu for drop down items wxXmlNode * const nodeDropdown = GetParamNode("dropdown"); if ( nodeDropdown ) { // also check for the menu specified inside dropdown (it is // optional and may be absent for e.g. dynamically-created // menus) wxXmlNode * const nodeMenu = GetNodeChildren(nodeDropdown); if ( nodeMenu ) { wxObject *res = CreateResFromNode(nodeMenu, NULL); menu = wxDynamicCast(res, wxMenu); if ( !menu ) { ReportError ( nodeMenu, "drop-down tool contents can only be a wxMenu" ); } if ( GetNodeNext(nodeMenu) ) { ReportError ( GetNodeNext(nodeMenu), "unexpected extra contents under drop-down tool" ); } } } #endif wxAuiToolBarItem * const tool = m_toolbar->AddTool ( GetID(), GetText(wxS("label")), GetBitmap(wxS("bitmap"), wxART_TOOLBAR, m_toolSize), GetBitmap(wxS("bitmap2"), wxART_TOOLBAR, m_toolSize), kind, GetText(wxS("tooltip")), GetText(wxS("longhelp")), NULL ); if ( GetBool(wxS("disabled")) ) m_toolbar->EnableTool(GetID(), false); #if wxUSE_MENUS if (menu) { tool->SetHasDropDown(true); tool->SetUserData(m_menuHandler.RegisterMenu(m_toolbar, GetID(), menu)); } #endif return m_toolbar; // must return non-NULL } else if (m_class == wxS("separator") || m_class == wxS("space") || m_class == wxS("label")) { if ( !m_toolbar ) { ReportError("separators only allowed inside wxAuiToolBar"); return NULL; } if ( m_class == wxS("separator") ) m_toolbar->AddSeparator(); else if (m_class == wxS("space")) { // This may be a stretch spacer (the default) or a non-stretch one bool hasProportion = HasParam(wxS("proportion")); bool hasWidth = HasParam(wxS("width")); if (hasProportion && hasWidth) { ReportError("A space can't both stretch and have width"); return NULL; } if (hasWidth) { m_toolbar->AddSpacer ( GetLong(wxS("width")) ); } else { m_toolbar->AddStretchSpacer ( GetLong(wxS("proportion"), 1l) ); } } else if (m_class == wxS("label")) { m_toolbar->AddLabel ( GetID(), GetText(wxS("label")), GetLong(wxS("width"), -1l) ); } return m_toolbar; // must return non-NULL } else /*<object class="wxAuiToolBar">*/ { int style = GetStyle(wxS("style"), wxNO_BORDER | wxTB_HORIZONTAL); #ifdef __WXMSW__ if (!(style & wxNO_BORDER)) style |= wxNO_BORDER; #endif XRC_MAKE_INSTANCE(toolbar, wxAuiToolBar) toolbar->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), style); toolbar->SetName(GetName()); SetupWindow(toolbar); m_toolSize = GetSize(wxS("bitmapsize")); if (!(m_toolSize == wxDefaultSize)) toolbar->SetToolBitmapSize(m_toolSize); wxSize margins = GetSize(wxS("margins")); if (!(margins == wxDefaultSize)) toolbar->SetMargins(margins.x, margins.y); long packing = GetLong(wxS("packing"), -1); if (packing != -1) toolbar->SetToolPacking(packing); long separation = GetLong(wxS("separation"), -1); if (separation != -1) toolbar->SetToolSeparation(separation); wxXmlNode *children_node = GetParamNode(wxS("object")); if (!children_node) children_node = GetParamNode(wxS("object_ref")); if (children_node == NULL) return toolbar; m_isInside = true; m_toolbar = toolbar; wxXmlNode *n = children_node; while (n) { if (IsObjectNode(n)) { wxObject *created = CreateResFromNode(n, toolbar, NULL); wxControl *control = wxDynamicCast(created, wxControl); if (!IsOfClass(n, wxS("tool")) && !IsOfClass(n, wxS("separator")) && !IsOfClass(n, wxS("label")) && !IsOfClass(n, wxS("space")) && control != NULL) toolbar->AddControl(control); } n = GetNodeNext(n); } m_isInside = false; m_toolbar = NULL; toolbar->Realize(); return toolbar; } }
wxObject *wxAuiNotebookXmlHandler::DoCreateResource() { if (m_class == wxT("notebookpage")) { wxXmlNode *anb = GetParamNode(wxT("object")); if (!anb) anb = GetParamNode(wxT("object_ref")); if (anb) { bool old_ins = m_isInside; m_isInside = false; wxObject *item = CreateResFromNode(anb, m_notebook, NULL); m_isInside = old_ins; wxWindow *wnd = wxDynamicCast(item, wxWindow); if (wnd) { if ( HasParam(wxT("bitmap")) ) { m_notebook->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")), GetBitmap(wxT("bitmap"), wxART_OTHER)); } else { m_notebook->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected"))); } } else { ReportError(anb, "notebookpage child must be a window"); } return wnd; } else { ReportError("notebookpage must have a window child"); return NULL; } } else { XRC_MAKE_INSTANCE(anb, wxAuiNotebook) anb->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style"))); SetupWindow(anb); wxAuiNotebook *old_par = m_notebook; m_notebook = anb; bool old_ins = m_isInside; m_isInside = true; CreateChildren(m_notebook, true/*only this handler*/); m_isInside = old_ins; m_notebook = old_par; return anb; } }