00001 #include "gui_statusbar.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 status_bar::parse_block(xml::block* pBlock) 00011 { 00012 frame::parse_block(pBlock); 00013 00014 if (pBlock->is_provided("minValue") || !bInherits_) 00015 set_min_value(utils::string_to_float(pBlock->get_attribute("minValue"))); 00016 if (pBlock->is_provided("maxValue") || !bInherits_) 00017 set_max_value(utils::string_to_float(pBlock->get_attribute("maxValue"))); 00018 if (pBlock->is_provided("defaultValue") || !bInherits_) 00019 set_value(utils::string_to_float(pBlock->get_attribute("defaultValue"))); 00020 if (pBlock->is_provided("drawLayer") || !bInherits_) 00021 set_bar_draw_layer(pBlock->get_attribute("drawLayer")); 00022 00023 if (pBlock->is_provided("orientation") || !bInherits_) 00024 { 00025 std::string sOrientation = pBlock->get_attribute("orientation"); 00026 if (sOrientation == "HORIZONTAL") 00027 set_orientation(ORIENT_HORIZONTAL); 00028 else if (sOrientation == "VERTICAL") 00029 set_orientation(ORIENT_VERTICAL); 00030 else 00031 { 00032 gui::out << gui::warning << pBlock->get_location() << " : " 00033 "Unknown StatusBar orientation : \""+sOrientation+"\". Expecting either :\n" 00034 "\"HORIZONTAL\" or \"VERTICAL\". Attribute ignored." << std::endl; 00035 } 00036 } 00037 00038 if (pBlock->is_provided("reversed") || !bInherits_) 00039 set_reversed(utils::string_to_bool(pBlock->get_attribute("reversed"))); 00040 00041 xml::block* pBarBlock = pBlock->get_radio_block(); 00042 if (pBarBlock) 00043 { 00044 if (pBarBlock->get_name() == "BarTexture") 00045 { 00046 texture* pBarTexture = create_bar_texture_(); 00047 pBarTexture->parse_block(pBarBlock); 00048 set_bar_texture(pBarTexture); 00049 } 00050 else 00051 { 00052 set_bar_color(color( 00053 utils::string_to_float(pBarBlock->get_attribute("r")), 00054 utils::string_to_float(pBarBlock->get_attribute("g")), 00055 utils::string_to_float(pBarBlock->get_attribute("b")), 00056 utils::string_to_float(pBarBlock->get_attribute("a")) 00057 )); 00058 } 00059 } 00060 } 00061 }