/*********************************************************************** filename: CEGUIWindowProperties.cpp created: 5/7/2004 author: Paul D Turner purpose: Implementation of available window base class properties *************************************************************************/ /*************************************************************************** * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************/ #include "CEGUIWindowProperties.h" #include "CEGUIWindow.h" #include "CEGUIFont.h" #include "CEGUIPropertyHelper.h" #include "CEGUIExceptions.h" #include "CEGUIWindowFactoryManager.h" #include #include // Start of CEGUI namespace section namespace CEGUI { // Start of WindowProperties namespace section namespace WindowProperties { String ID::get(const PropertyReceiver* receiver) const { return PropertyHelper::uintToString(static_cast(receiver)->getID()); } void ID::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setID(PropertyHelper::stringToUint(value)); } String Alpha::get(const PropertyReceiver* receiver) const { return PropertyHelper::floatToString(static_cast(receiver)->getAlpha()); } void Alpha::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setAlpha(PropertyHelper::stringToFloat(value)); } String Font::get(const PropertyReceiver* receiver) const { const CEGUI::Font* fnt = static_cast(receiver)->getFont(); if (fnt) { return fnt->getProperty ("Name"); } else { return String(); } } void Font::set(PropertyReceiver* receiver, const String& value) { try { if (value.empty()) { static_cast(receiver)->setFont(0); } else { static_cast(receiver)->setFont(value); } } catch (UnknownObjectException&) { } } bool Font::isDefault(const PropertyReceiver* receiver) const { return static_cast(receiver)->getFont(false) == 0; } String Text::get(const PropertyReceiver* receiver) const { return static_cast(receiver)->getText(); } void Text::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setText(value); } String MouseCursorImage::get(const PropertyReceiver* receiver) const { const Image* img = static_cast(receiver)->getMouseCursor(); if (img) { return PropertyHelper::imageToString(img); } else { return String(); } } void MouseCursorImage::set(PropertyReceiver* receiver, const String& value) { if (!value.empty()) { static_cast(receiver)->setMouseCursor(PropertyHelper::stringToImage(value)); } } bool MouseCursorImage::isDefault(const PropertyReceiver* receiver) const { return static_cast(receiver)->getMouseCursor(false) == 0; } String ClippedByParent::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->isClippedByParent()); } void ClippedByParent::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setClippedByParent(PropertyHelper::stringToBool(value)); } String InheritsAlpha::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->inheritsAlpha()); } void InheritsAlpha::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setInheritsAlpha(PropertyHelper::stringToBool(value)); } String AlwaysOnTop::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->isAlwaysOnTop()); } void AlwaysOnTop::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setAlwaysOnTop(PropertyHelper::stringToBool(value)); } String Disabled::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->isDisabled()); } void Disabled::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setEnabled(!PropertyHelper::stringToBool(value)); } bool Disabled::isDefault(const PropertyReceiver* receiver) const { return !static_cast(receiver)->isDisabled(true); } String Visible::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->isVisible()); } void Visible::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setVisible(PropertyHelper::stringToBool(value)); } bool Visible::isDefault(const PropertyReceiver* receiver) const { return static_cast(receiver)->isVisible(true); } String RestoreOldCapture::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->restoresOldCapture()); } void RestoreOldCapture::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setRestoreCapture(PropertyHelper::stringToBool(value)); } String DestroyedByParent::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->isDestroyedByParent()); } void DestroyedByParent::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setDestroyedByParent(PropertyHelper::stringToBool(value)); } String ZOrderChangeEnabled::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->isZOrderingEnabled()); } void ZOrderChangeEnabled::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setZOrderingEnabled(PropertyHelper::stringToBool(value)); } String WantsMultiClickEvents::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->wantsMultiClickEvents()); } void WantsMultiClickEvents::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setWantsMultiClickEvents(PropertyHelper::stringToBool(value)); } String MouseButtonDownAutoRepeat::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->isMouseAutoRepeatEnabled()); } void MouseButtonDownAutoRepeat::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setMouseAutoRepeatEnabled(PropertyHelper::stringToBool(value)); } String AutoRepeatDelay::get(const PropertyReceiver* receiver) const { return PropertyHelper::floatToString(static_cast(receiver)->getAutoRepeatDelay()); } void AutoRepeatDelay::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setAutoRepeatDelay(PropertyHelper::stringToFloat(value)); } String AutoRepeatRate::get(const PropertyReceiver* receiver) const { return PropertyHelper::floatToString(static_cast(receiver)->getAutoRepeatRate()); } void AutoRepeatRate::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setAutoRepeatRate(PropertyHelper::stringToFloat(value)); } String DistributeCapturedInputs::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->distributesCapturedInputs()); } void DistributeCapturedInputs::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setDistributesCapturedInputs(PropertyHelper::stringToBool(value)); } String CustomTooltipType::get(const PropertyReceiver* receiver) const { return static_cast(receiver)->getTooltipType(); } void CustomTooltipType::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setTooltipType(value); } String Tooltip::get(const PropertyReceiver* receiver) const { const Window* wnd = static_cast(receiver); if (!wnd->getParent() || !wnd->inheritsTooltipText() || (wnd->getTooltipText() != wnd->getParent()->getTooltipText())) { return wnd->getTooltipText(); } else { return String(""); } } void Tooltip::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setTooltipText(value); } String InheritsTooltipText::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->inheritsTooltipText()); } void InheritsTooltipText::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setInheritsTooltipText(PropertyHelper::stringToBool(value)); } String RiseOnClick::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->isRiseOnClickEnabled()); } void RiseOnClick::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setRiseOnClickEnabled(PropertyHelper::stringToBool(value)); } String VerticalAlignment::get(const PropertyReceiver* receiver) const { switch(static_cast(receiver)->getVerticalAlignment()) { case VA_CENTRE: return String("Centre"); break; case VA_BOTTOM: return String("Bottom"); break; default: return String("Top"); } } void VerticalAlignment::set(PropertyReceiver* receiver, const String& value) { CEGUI::VerticalAlignment align; if (value == "Centre") { align = VA_CENTRE; } else if (value == "Bottom") { align = VA_BOTTOM; } else { align = VA_TOP; } static_cast(receiver)->setVerticalAlignment(align); } String HorizontalAlignment::get(const PropertyReceiver* receiver) const { switch(static_cast(receiver)->getHorizontalAlignment()) { case HA_CENTRE: return String("Centre"); break; case HA_RIGHT: return String("Right"); break; default: return String("Left"); } } void HorizontalAlignment::set(PropertyReceiver* receiver, const String& value) { CEGUI::HorizontalAlignment align; if (value == "Centre") { align = HA_CENTRE; } else if (value == "Right") { align = HA_RIGHT; } else { align = HA_LEFT; } static_cast(receiver)->setHorizontalAlignment(align); } String UnifiedAreaRect::get(const PropertyReceiver* receiver) const { return PropertyHelper::urectToString(static_cast(receiver)->getArea()); } void UnifiedAreaRect::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setArea(PropertyHelper::stringToURect(value)); } String UnifiedPosition::get(const PropertyReceiver* receiver) const { return PropertyHelper::uvector2ToString(static_cast(receiver)->getPosition()); } void UnifiedPosition::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setPosition(PropertyHelper::stringToUVector2(value)); } String UnifiedXPosition::get(const PropertyReceiver* receiver) const { return PropertyHelper::udimToString(static_cast(receiver)->getXPosition()); } void UnifiedXPosition::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setXPosition(PropertyHelper::stringToUDim(value)); } String UnifiedYPosition::get(const PropertyReceiver* receiver) const { return PropertyHelper::udimToString(static_cast(receiver)->getYPosition()); } void UnifiedYPosition::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setYPosition(PropertyHelper::stringToUDim(value)); } String UnifiedSize::get(const PropertyReceiver* receiver) const { return PropertyHelper::uvector2ToString(static_cast(receiver)->getSize()); } void UnifiedSize::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setSize(PropertyHelper::stringToUVector2(value)); } String UnifiedWidth::get(const PropertyReceiver* receiver) const { return PropertyHelper::udimToString(static_cast(receiver)->getWidth()); } void UnifiedWidth::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setWidth(PropertyHelper::stringToUDim(value)); } String UnifiedHeight::get(const PropertyReceiver* receiver) const { return PropertyHelper::udimToString(static_cast(receiver)->getHeight()); } void UnifiedHeight::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setHeight(PropertyHelper::stringToUDim(value)); } String UnifiedMinSize::get(const PropertyReceiver* receiver) const { return PropertyHelper::uvector2ToString(static_cast(receiver)->getMinSize()); } void UnifiedMinSize::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setMinSize(PropertyHelper::stringToUVector2(value)); } String UnifiedMaxSize::get(const PropertyReceiver* receiver) const { return PropertyHelper::uvector2ToString(static_cast(receiver)->getMaxSize()); } void UnifiedMaxSize::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setMaxSize(PropertyHelper::stringToUVector2(value)); } String MousePassThroughEnabled::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->isMousePassThroughEnabled()); } void MousePassThroughEnabled::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setMousePassThroughEnabled(PropertyHelper::stringToBool(value)); } String WindowRenderer::get(const PropertyReceiver* receiver) const { CEGUI::WindowRenderer* wr = static_cast(receiver)->getWindowRenderer(); return wr ? wr->getName() : ""; } void WindowRenderer::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setWindowRenderer(value); } void WindowRenderer::writeXMLToStream(const PropertyReceiver* receiver, XMLSerializer& xml_stream) const { const Window* wnd = static_cast(receiver); if (!WindowFactoryManager::getSingleton().isFalagardMappedType(wnd->getType())) { Property::writeXMLToStream(receiver, xml_stream); } } String LookNFeel::get(const PropertyReceiver* receiver) const { return static_cast(receiver)->getLookNFeel(); } void LookNFeel::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setLookNFeel(value); } void LookNFeel::writeXMLToStream(const PropertyReceiver* receiver, XMLSerializer& xml_stream) const { const Window* wnd = static_cast(receiver); if (!WindowFactoryManager::getSingleton().isFalagardMappedType(wnd->getType())) { Property::writeXMLToStream(receiver, xml_stream); } } String DragDropTarget::get(const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast(receiver)->isDragDropTarget()); } void DragDropTarget::set(PropertyReceiver* receiver, const String& value) { static_cast(receiver)->setDragDropTarget(PropertyHelper::stringToBool(value)); } } // End of WindowProperties namespace section } // End of CEGUI namespace section