예제 #1
0
	void Button::initialiseWidgetSkin(WidgetSkinInfoPtr _info)
	{
		// парсим свойства
		const MapString & properties = _info->getProperties();
		if (!properties.empty()) {
			MapString::const_iterator iter = properties.find("ButtonPressed");
			if (iter != properties.end()) setButtonPressed(utility::parseBool(iter->second));
			iter = properties.find("StateCheck");
			if (iter != properties.end()) setStateCheck(utility::parseBool(iter->second));
		}

		for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) {
			if (*(*iter)->_getInternalData<std::string>() == "Image") {
				MYGUI_DEBUG_ASSERT( ! mImage, "widget already assigned");
				mImage = (*iter)->castType<StaticImage>();
			}
		}
	}
예제 #2
0
	void ComboBox::initialiseWidgetSkin(WidgetSkinInfoPtr _info)
	{
		// парсим свойства
		const MapString & properties = _info->getProperties();
		MapString::const_iterator iter = properties.find("HeightList");
		if (iter != properties.end()) mMaxHeight = utility::parseSizeT(iter->second);

		iter = properties.find("ListSmoothShow");
		if (iter != properties.end()) setSmoothShow(utility::parseBool(iter->second));

		// парсим кнопку
		for (VectorWidgetPtr::iterator iter=mWidgetChildSkin.begin(); iter!=mWidgetChildSkin.end(); ++iter) {
			if (*(*iter)->_getInternalData<std::string>() == "Button") {
				MYGUI_DEBUG_ASSERT( ! mButton, "widget already assigned");
				mButton = (*iter)->castType<Button>();
				mButton->eventMouseButtonPressed = newDelegate(this, &ComboBox::notifyButtonPressed);
			}
			else if (*(*iter)->_getInternalData<std::string>() == "List") {
				MYGUI_DEBUG_ASSERT( ! mList, "widget already assigned");
				mList = (*iter)->castType<List>();
				mList->setVisible(false);
				mList->eventKeyLostFocus = newDelegate(this, &ComboBox::notifyListLostFocus);
				mList->eventListSelectAccept = newDelegate(this, &ComboBox::notifyListSelectAccept);
				mList->eventListMouseItemActivate = newDelegate(this, &ComboBox::notifyListMouseItemActivate);
				mList->eventListChangePosition = newDelegate(this, &ComboBox::notifyListChangePosition);
			}
		}

		//OBSOLETE
		MYGUI_ASSERT(nullptr != mButton, "Child Button not found in skin (combobox must have Button)");

		//MYGUI_ASSERT(nullptr != mList, "Child List not found in skin (combobox must have List)");
		mManualList = mList == nullptr;
		if (mList == nullptr)
		{
			std::string list_skin;
			iter = properties.find("ListSkin");
			if (iter != properties.end()) list_skin = iter->second;
			std::string list_layer;
			iter = properties.find("ListLayer");
			if (iter != properties.end()) list_layer = iter->second;
			mList = createWidget<MyGUI::List>(WidgetStyle::Popup, list_skin, IntCoord(), Align::Default, list_layer);
			mWidgetChild.pop_back();

			mList->setVisible(false);
			mList->eventKeyLostFocus = newDelegate(this, &ComboBox::notifyListLostFocus);
			mList->eventListSelectAccept = newDelegate(this, &ComboBox::notifyListSelectAccept);
			mList->eventListMouseItemActivate = newDelegate(this, &ComboBox::notifyListMouseItemActivate);
			mList->eventListChangePosition = newDelegate(this, &ComboBox::notifyListChangePosition);
		}

		// корректируем высоту списка
		//if (mMaxHeight < mList->getFontHeight()) mMaxHeight = mList->getFontHeight();

		// подписываем дочерние классы на скролл
		mWidgetClient->eventMouseWheel = newDelegate(this, &ComboBox::notifyMouseWheel);
		mWidgetClient->eventMouseButtonPressed = newDelegate(this, &ComboBox::notifyMousePressed);

		// подписываемся на изменения текста
		eventEditTextChange = newDelegate(this, &ComboBox::notifyEditTextChange);
	}