//---------------------------------------------------------------------------------------------------- CView* UITemplateSettingsController::verifyView (CView* view, const UIAttributes& attributes, IUIDescription* description) { CTextEdit* control = dynamic_cast<CTextEdit*>(view); if (control) { switch (control->getTag ()) { case kNameTag: { controls[kNameTag] = control; control->setText (templateName.c_str ()); break; } case kMinWidthTag: { controls[kMinWidthTag] = control; control->setStringToValueProc (stringToValue); control->setValueToStringProc (valueToString); control->setValue ((float)minSize.x); break; } case kMinHeightTag: { controls[kMinHeightTag] = control; control->setStringToValueProc (stringToValue); control->setValueToStringProc (valueToString); control->setValue ((float)minSize.y); break; } case kMaxWidthTag: { controls[kMaxWidthTag] = control; control->setStringToValueProc (stringToValue); control->setValueToStringProc (valueToString); control->setValue ((float)maxSize.x); break; } case kMaxHeightTag: { controls[kMaxHeightTag] = control; control->setStringToValueProc (stringToValue); control->setValueToStringProc (valueToString); control->setValue ((float)maxSize.y); break; } } } return view; }
//---------------------------------------------------------------------------------------------------- void UITemplateSettingsController::valueChanged (CControl* control) { switch (control->getTag ()) { case kNameTag: { CTextEdit* edit = dynamic_cast<CTextEdit*>(control); if (edit) { if (edit->getText ()) newTemplateName = edit->getText (); else edit->setText (newTemplateName.c_str ()); } break; } case kMinWidthTag: { minSize.x = control->getValue (); break; } case kMinHeightTag: { minSize.y = control->getValue (); break; } case kMaxWidthTag: { maxSize.x = control->getValue (); break; } case kMaxHeightTag: { maxSize.y = control->getValue (); break; } case kMinUseCurrentTag: case kMaxUseCurrentTag: { if (control->getValue() == control->getMax()) { const UIAttributes* attr = description->getViewAttributes (templateName.c_str()); if (attr) { CPoint currentSize; if (attr->getPointAttribute ("size", currentSize)) { if (control->getTag () == kMinUseCurrentTag) { minSize = currentSize; if (controls[kMinWidthTag]) { controls[kMinWidthTag]->setValue ((float)minSize.x); controls[kMinWidthTag]->invalid (); } if (controls[kMinHeightTag]) { controls[kMinHeightTag]->setValue ((float)minSize.y); controls[kMinHeightTag]->invalid (); } } else { maxSize = currentSize; if (controls[kMaxWidthTag]) { controls[kMaxWidthTag]->setValue ((float)maxSize.x); controls[kMaxWidthTag]->invalid (); } if (controls[kMaxHeightTag]) { controls[kMaxHeightTag]->setValue ((float)maxSize.y); controls[kMaxHeightTag]->invalid (); } } } } } break; } } }