GG
|
00001 // -*- C++ -*- 00002 /* GG is a GUI for SDL and OpenGL. 00003 Copyright (C) 2003-2008 T. Zachary Laine 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public License 00007 as published by the Free Software Foundation; either version 2.1 00008 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00018 02111-1307 USA 00019 00020 If you do not wish to comply with the terms of the LGPL please 00021 contact the author as other terms are available for a fee. 00022 00023 Zach Laine 00024 whatwasthataddress@gmail.com */ 00025 00029 #ifndef _GG_ThreeButtonDlg_h_ 00030 #define _GG_ThreeButtonDlg_h_ 00031 00032 #include <GG/Wnd.h> 00033 00034 00035 namespace GG { 00036 00037 class Button; 00038 class Font; 00039 00057 class GG_API ThreeButtonDlg : public Wnd 00058 { 00059 public: 00061 00062 ThreeButtonDlg(X x, Y y, X w, Y h, const std::string& msg, const boost::shared_ptr<Font>& font, Clr color, 00063 Clr border_color, Clr button_color, Clr text_color, std::size_t buttons, const std::string& zero = "", 00064 const std::string& one = "", const std::string& two = ""); 00065 00067 ThreeButtonDlg(X w, Y h, const std::string& msg, const boost::shared_ptr<Font>& font, Clr color, 00068 Clr border_color, Clr button_color, Clr text_color, std::size_t buttons, const std::string& zero = "", 00069 const std::string& one = "", const std::string& two = ""); 00071 00073 Clr ButtonColor() const; 00074 std::size_t Result() const; 00075 std::size_t DefaultButton() const; 00076 std::size_t EscapeButton() const; 00077 00078 00080 virtual void Render(); 00081 virtual void KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys); 00082 00083 void SetButtonColor(Clr color); 00084 void SetDefaultButton(std::size_t i); 00085 void SetEscapeButton(std::size_t i); 00086 00087 00088 static const std::size_t NO_BUTTON; 00089 00090 protected: 00092 ThreeButtonDlg(); 00093 00094 00095 private: 00096 std::size_t NumButtons() const; 00097 void Init(const std::string& msg, const boost::shared_ptr<Font>& font, std::size_t buttons, 00098 const std::string& zero = "", const std::string& one = "", const std::string& two = ""); 00099 void ConnectSignals(); 00100 void Button0Clicked(); 00101 void Button1Clicked(); 00102 void Button2Clicked(); 00103 00104 Clr m_color; 00105 Clr m_border_color; 00106 Clr m_text_color; 00107 Clr m_button_color; 00108 std::size_t m_default; 00109 std::size_t m_escape; 00110 std::size_t m_result; 00111 Button* m_button_0; 00112 Button* m_button_1; 00113 Button* m_button_2; 00114 00115 friend class boost::serialization::access; 00116 template <class Archive> 00117 void serialize(Archive& ar, const unsigned int version); 00118 }; 00119 00120 } // namespace GG 00121 00122 // template implementations 00123 template <class Archive> 00124 void GG::ThreeButtonDlg::serialize(Archive& ar, const unsigned int version) 00125 { 00126 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Wnd) 00127 & BOOST_SERIALIZATION_NVP(m_color) 00128 & BOOST_SERIALIZATION_NVP(m_border_color) 00129 & BOOST_SERIALIZATION_NVP(m_text_color) 00130 & BOOST_SERIALIZATION_NVP(m_button_color) 00131 & BOOST_SERIALIZATION_NVP(m_default) 00132 & BOOST_SERIALIZATION_NVP(m_escape) 00133 & BOOST_SERIALIZATION_NVP(m_result) 00134 & BOOST_SERIALIZATION_NVP(m_button_0) 00135 & BOOST_SERIALIZATION_NVP(m_button_1) 00136 & BOOST_SERIALIZATION_NVP(m_button_2); 00137 00138 if (Archive::is_loading::value) 00139 ConnectSignals(); 00140 } 00141 00142 #endif // _GG_ThreeButtonDlg_h_