//----------------------------------------------------------------------------- CView* UIViewFactory::createViewByName (const std::string* className, const UIAttributes& attributes, IUIDescription* description) { ViewCreatorRegistry& registry = getCreatorRegistry (); ViewCreatorRegistry::const_iterator iter = registry.find (className->c_str ()); if (iter != registry.end ()) { CView* view = (*iter).second->create (attributes, description); if (view) { IdStringPtr viewName = (*iter).second->getViewName (); view->setAttribute ('cvcr', sizeof (IdStringPtr), &viewName); while (iter != registry.end () && (*iter).second->apply (view, attributes, description)) { if ((*iter).second->getBaseViewName () == 0) break; iter = registry.find ((*iter).second->getBaseViewName ()); } return view; } } else { #if DEBUG DebugPrint ("UIViewFactory::createView(..): Could not find view of class: %s\n", className->c_str ()); #endif } return 0; }
//---------------------------------------------------------------------------------------------------- CView* UIDialogController::verifyView (CView* view, const UIAttributes& attributes, IUIDescription* description) { CControl* control = dynamic_cast<CControl*>(view); if (control) { if (control->getTag () == kButton1Tag) { CTextButton* button = dynamic_cast<CTextButton*>(control); if (button) { button1 = button; button->setTitle (dialogButton1.c_str ()); layoutButtons (); } } else if (control->getTag () == kButton2Tag) { CTextButton* button = dynamic_cast<CTextButton*>(control); if (button) { button2 = button; if (dialogButton2.empty ()) { button->setVisible (false); } else { button->setTitle (dialogButton2.c_str ()); } layoutButtons (); } } else if (control->getTag () == kTitleTag) { CTextLabel* label = dynamic_cast<CTextLabel*>(control); if (label) { label->setText (dialogTitle.c_str ()); } } } const std::string* name = attributes.getAttributeValue ("custom-view-name"); if (name) { if (*name == "view") { IController* controller = dialogController.cast<IController> (); CView* subView = dialogDescription->createView (templateName.c_str (), controller); if (subView) { subView->setAttribute (kCViewControllerAttribute, sizeof (IController*), &controller); sizeDiff.x = subView->getWidth () - view->getWidth (); sizeDiff.y = subView->getHeight () - view->getHeight (); CRect size = view->getViewSize (); size.setWidth (subView->getWidth ()); size.setHeight (subView->getHeight ()); view->setViewSize (size); view->setMouseableArea (size); CViewContainer* container = dynamic_cast<CViewContainer*> (view); if (container) container->addView (subView); } } } return view; }