00001 #ifndef GSGL_FRAMEWORK_TEXTBOX_H 00002 #define GSGL_FRAMEWORK_TEXTBOX_H 00003 00004 // 00005 // $Id: textbox.hpp 2 2008-03-01 20:58:50Z kulibali $ 00006 // 00007 // Copyright (c) 2008, The Periapsis Project. All rights reserved. 00008 // 00009 // Redistribution and use in source and binary forms, with or without 00010 // modification, are permitted provided that the following conditions are 00011 // met: 00012 // 00013 // * Redistributions of source code must retain the above copyright notice, 00014 // this list of conditions and the following disclaimer. 00015 // 00016 // * Redistributions in binary form must reproduce the above copyright 00017 // notice, this list of conditions and the following disclaimer in the 00018 // documentation and/or other materials provided with the distribution. 00019 // 00020 // * Neither the name of the The Periapsis Project nor the names of its 00021 // contributors may be used to endorse or promote products derived from 00022 // this software without specific prior written permission. 00023 // 00024 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00025 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00026 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00027 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 00028 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00029 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00030 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 // 00036 00037 #include "framework/framework.hpp" 00038 #include "framework/widget.hpp" 00039 00040 namespace gsgl 00041 { 00042 00043 namespace platform 00044 { 00045 class font; 00046 } // namespace platform 00047 00048 00049 namespace framework 00050 { 00051 00052 class FRAMEWORK_API textbox 00053 : public widget 00054 { 00055 platform::font *text_font; 00056 gsgl::string text; 00057 00058 public: 00059 00060 enum text_align 00061 { 00062 ALIGN_LEFT, 00063 ALIGN_RIGHT, 00064 ALIGN_CENTER, 00065 ALIGN_JUSTIFY 00066 }; 00067 00068 enum textbox_flags 00069 { 00070 NO_FLAGS = 0, 00071 TEXT_WRAP = (1 << 0), 00072 TEXT_SCROLL = (1 << 1) 00073 }; 00074 00075 textbox(widget *parent, 00076 const int x, const int y, const int w, const int h, 00077 const platform::color & fg, const platform::color & bg, 00078 const gsgl::string & font_face, const int font_size, 00079 text_align align = ALIGN_LEFT, gsgl::flags_t text_flags = NO_FLAGS); 00080 virtual ~textbox(); 00081 00082 text_align & get_align() { return align; } 00083 gsgl::flags_t & get_text_flags() { return text_flags; } 00084 gsgl::string & get_text() { return text; } 00085 00086 virtual void draw(); 00087 00088 private: 00089 text_align align; 00090 gsgl::flags_t text_flags; 00091 }; // class textbox 00092 00093 } // namespace framework 00094 00095 } // namespace gsgl 00096 00097 #endif