1 // Copyright 2008, Google Inc. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are met: 5 // 6 // 1. Redistributions of source code must retain the above copyright notice, 7 // this list of conditions and the following disclaimer. 8 // 2. Redistributions in binary form must reproduce the above copyright notice, 9 // this list of conditions and the following disclaimer in the documentation 10 // and/or other materials provided with the distribution. 11 // 3. Neither the name of Google Inc. nor the names of its contributors may be 12 // used to endorse or promote products derived from this software without 13 // specific prior written permission. 14 // 15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 26 // This file contains the declaration of the BalloonStyle element. 27 28 #ifndef KML_DOM_BALLOONSTYLE_H__ 29 #define KML_DOM_BALLOONSTYLE_H__ 30 31 #include "kml/base/color32.h" 32 #include "kml/dom/substyle.h" 33 #include "kml/dom/kml22.h" 34 35 namespace kmldom { 36 37 class Visitor; 38 39 class BalloonStyle : public SubStyle { 40 public: 41 virtual ~BalloonStyle(); Type()42 virtual KmlDomType Type() const { return Type_BalloonStyle; } IsA(KmlDomType type)43 virtual bool IsA(KmlDomType type) const { 44 return type == Type_BalloonStyle || SubStyle::IsA(type); 45 } 46 47 // <bgColor> get_bgcolor()48 const kmlbase::Color32& get_bgcolor() const { 49 return bgcolor_; 50 } has_bgcolor()51 bool has_bgcolor() const { 52 return has_bgcolor_; 53 } set_bgcolor(const kmlbase::Color32 & bgcolor)54 void set_bgcolor(const kmlbase::Color32& bgcolor) { 55 bgcolor_ = bgcolor; 56 has_bgcolor_ = true; 57 } clear_bgcolor()58 void clear_bgcolor() { 59 bgcolor_ = kmlbase::Color32(0xffffffff); 60 has_bgcolor_ = false; 61 } 62 63 // <textColor> get_textcolor()64 const kmlbase::Color32& get_textcolor() const { 65 return textcolor_; 66 } has_textcolor()67 bool has_textcolor() const { 68 return has_textcolor_; 69 } set_textcolor(const kmlbase::Color32 & textcolor)70 void set_textcolor(const kmlbase::Color32& textcolor) { 71 textcolor_ = textcolor; 72 has_textcolor_ = true; 73 } clear_textcolor()74 void clear_textcolor() { 75 textcolor_ = kmlbase::Color32(0xff000000); 76 has_textcolor_ = false; 77 } 78 79 // <text> get_text()80 const string& get_text() const { 81 return text_; 82 } has_text()83 bool has_text() const { 84 return has_text_; 85 } set_text(const string & text)86 void set_text(const string& text) { 87 text_ = text; 88 has_text_ = true; 89 } clear_text()90 void clear_text() { 91 text_.clear(); 92 has_text_ = false; 93 } 94 95 // <displayMode> get_displaymode()96 int get_displaymode() const { 97 return displaymode_; 98 } has_displaymode()99 bool has_displaymode() const { 100 return has_displaymode_; 101 } set_displaymode(int displaymode)102 void set_displaymode(int displaymode) { 103 displaymode_ = displaymode; 104 has_displaymode_ = true; 105 } clear_displaymode()106 void clear_displaymode() { 107 displaymode_ = DISPLAYMODE_DEFAULT; 108 has_displaymode_ = false; 109 } 110 111 // Visitor API methods, see visitor.h. 112 virtual void Accept(Visitor* visitor); 113 114 private: 115 friend class KmlFactory; 116 BalloonStyle(); 117 friend class KmlHandler; 118 virtual void AddElement(const ElementPtr& element); 119 friend class Serializer; 120 virtual void Serialize(Serializer& serialize) const; 121 kmlbase::Color32 bgcolor_; 122 bool has_bgcolor_; 123 kmlbase::Color32 textcolor_; 124 bool has_textcolor_; 125 string text_; 126 bool has_text_; 127 int displaymode_; 128 bool has_displaymode_; 129 LIBKML_DISALLOW_EVIL_CONSTRUCTORS(BalloonStyle); 130 }; 131 132 } // end namespace kmldom 133 134 #endif // KML_DOM_BALLOONSTYLE_H__ 135