00001 #include "gui_slider.hpp" 00002 #include "gui_texture.hpp" 00003 #include "gui_out.hpp" 00004 00005 #include <xml_document.hpp> 00006 #include <utils_string.hpp> 00007 00008 namespace gui 00009 { 00010 void slider::parse_block(xml::block* pBlock) 00011 { 00012 frame::parse_block(pBlock); 00013 00014 if (pBlock->is_provided("valueStep") || !bInherits_) 00015 set_value_step(utils::string_to_float(pBlock->get_attribute("valueStep"))); 00016 if (pBlock->is_provided("minValue") || !bInherits_) 00017 set_min_value(utils::string_to_float(pBlock->get_attribute("minValue"))); 00018 if (pBlock->is_provided("maxValue") || !bInherits_) 00019 set_max_value(utils::string_to_float(pBlock->get_attribute("maxValue"))); 00020 if (pBlock->is_provided("defaultValue") || !bInherits_) 00021 set_value(utils::string_to_float(pBlock->get_attribute("defaultValue"))); 00022 if (pBlock->is_provided("drawLayer") || !bInherits_) 00023 set_thumb_draw_layer(pBlock->get_attribute("drawLayer")); 00024 00025 if (pBlock->is_provided("orientation") || !bInherits_) 00026 { 00027 std::string sOrientation = pBlock->get_attribute("orientation"); 00028 if (sOrientation == "HORIZONTAL") 00029 set_orientation(ORIENT_HORIZONTAL); 00030 else if (sOrientation == "VERTICAL") 00031 set_orientation(ORIENT_VERTICAL); 00032 else 00033 { 00034 gui::out << gui::warning << pBlock->get_location() << " : " 00035 "Unknown Slider orientation : \""+sOrientation+"\". Expecting either :\n" 00036 "\"HORIZONTAL\" or \"VERTICAL\". Attribute ignored." << std::endl; 00037 } 00038 } 00039 00040 xml::block* pThumbBlock = pBlock->get_block("ThumbTexture"); 00041 if (pThumbBlock) 00042 { 00043 create_thumb_texture_(); 00044 00045 pThumbTexture_->parse_block(pThumbBlock); 00046 pThumbTexture_->clear_all_points(); 00047 pThumbTexture_->set_point(anchor( 00048 pThumbTexture_, ANCHOR_CENTER, "$parent", 00049 get_orientation() == ORIENT_HORIZONTAL ? ANCHOR_LEFT : ANCHOR_TOP 00050 )); 00051 } 00052 } 00053 }