00001 #include "gui_button.hpp"
00002 #include "gui_texture.hpp"
00003 #include "gui_fontstring.hpp"
00004 #include "gui_out.hpp"
00005
00006 #include <xml_document.hpp>
00007 #include <utils_string.hpp>
00008
00009 namespace gui
00010 {
00011 void button::parse_block(xml::block* pBlock)
00012 {
00013 frame::parse_block(pBlock);
00014
00015 xml::block* pSpecialBlock;
00016 pSpecialBlock = pBlock->get_block("NormalTexture");
00017 if (pSpecialBlock)
00018 {
00019 texture* pTexture = create_normal_texture_();
00020 pTexture->parse_block(pSpecialBlock);
00021 if (pSpecialBlock->is_provided("layer"))
00022 pTexture->set_draw_layer(pSpecialBlock->get_attribute("layer"));
00023 }
00024
00025 pSpecialBlock = pBlock->get_block("PushedTexture");
00026 if (pSpecialBlock)
00027 {
00028 texture* pTexture = create_pushed_texture_();
00029 pTexture->parse_block(pSpecialBlock);
00030 if (pSpecialBlock->is_provided("layer"))
00031 pTexture->set_draw_layer(pSpecialBlock->get_attribute("layer"));
00032 }
00033
00034 pSpecialBlock = pBlock->get_block("DisabledTexture");
00035 if (pSpecialBlock)
00036 {
00037 texture* pTexture = create_disabled_texture_();
00038 pTexture->parse_block(pSpecialBlock);
00039 if (pSpecialBlock->is_provided("layer"))
00040 pTexture->set_draw_layer(pSpecialBlock->get_attribute("layer"));
00041 }
00042
00043 pSpecialBlock = pBlock->get_block("HighlightTexture");
00044 if (pSpecialBlock)
00045 {
00046 texture* pTexture = create_highlight_texture_();
00047 pTexture->parse_block(pSpecialBlock);
00048 if (pSpecialBlock->is_provided("layer"))
00049 pTexture->set_draw_layer(pSpecialBlock->get_attribute("layer"));
00050 }
00051
00052
00053 pSpecialBlock = pBlock->get_block("NormalText");
00054 if (pSpecialBlock)
00055 {
00056 font_string* pFontString = create_normal_text_();
00057 pFontString->parse_block(pSpecialBlock);
00058 if (pSpecialBlock->is_provided("layer"))
00059 pFontString->set_draw_layer(pSpecialBlock->get_attribute("layer"));
00060 }
00061
00062 pSpecialBlock = pBlock->get_block("HighlightText");
00063 if (pSpecialBlock)
00064 {
00065 font_string* pFontString = create_highlight_text_();
00066 pFontString->parse_block(pSpecialBlock);
00067 if (pSpecialBlock->is_provided("layer"))
00068 pFontString->set_draw_layer(pSpecialBlock->get_attribute("layer"));
00069 }
00070
00071 pSpecialBlock = pBlock->get_block("DisabledText");
00072 if (pSpecialBlock)
00073 {
00074 font_string* pFontString = create_disabled_text_();
00075 pFontString->parse_block(pSpecialBlock);
00076 if (pSpecialBlock->is_provided("layer"))
00077 pFontString->set_draw_layer(pSpecialBlock->get_attribute("layer"));
00078 }
00079
00080 xml::block* pOffsetBlock = pBlock->get_block("PushedTextOffset");
00081 if (pOffsetBlock)
00082 {
00083 xml::block* pDimBlock = pOffsetBlock->get_radio_block();
00084 if (pDimBlock->get_name() == "AbsDimension")
00085 {
00086 set_pushed_text_offset({{
00087 (int)utils::string_to_int(pDimBlock->get_attribute("x")),
00088 (int)utils::string_to_int(pDimBlock->get_attribute("y"))
00089 }});
00090 }
00091 else if (pDimBlock->get_name() == "RelDimension")
00092 {
00093 gui::out << gui::warning << pDimBlock->get_location() << " : "
00094 << "RelDimension for button:PushedTextOffset is not yet supported ("+sName_+")." << std::endl;
00095 }
00096 }
00097
00098 if ((pBlock->is_provided("text") || !pBlock->is_provided("inherits")))
00099 set_text(pBlock->get_attribute("text"));
00100 }
00101 }