- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

utextwidget.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/widgets/utextwidget.hpp 00008 begin : Sa Apr 2 2005 00009 $Id: utextwidget.hpp,v 1.2 2005/08/17 09:09:46 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 00029 #ifndef UTEXTWIDGET_HPP 00030 #define UTEXTWIDGET_HPP 00031 00032 #include "uscrollablewidget.hpp" 00033 00034 namespace ufo { 00035 00036 class UDocument; 00037 class UTextModel; 00038 class UCaret; 00039 class UTextLayout; 00040 00047 class UFO_EXPORT UTextWidget : public UScrollableWidget, public std::streambuf { 00048 UFO_DECLARE_DYNAMIC_CLASS(UTextWidget) 00049 UFO_STYLE_TYPE(UStyle::CE_TextWidget) 00050 public: 00052 UTextWidget(); 00056 UTextWidget(const std::string & text); 00057 virtual ~UTextWidget(); 00058 00059 public: // Public methods 00063 void setContentType(const std::string & type); 00064 std::string getContentType() const; 00065 00072 void setDocument(UDocument * documentA); 00073 UDocument * getDocument() const; 00074 00075 UTextLayout * getTextLayout() const; 00076 00077 // methods which change the document content 00078 00080 virtual void cut(); 00083 virtual void copy(); 00085 virtual void paste(); 00086 00089 virtual void setText(const std::string & textA); 00090 00093 virtual std::string getText() const; 00094 00095 // 00096 // caret methods 00097 // 00100 void setCaretPosition(unsigned int positionA); 00104 void moveCaretPosition(unsigned int positionA); 00105 00106 //void setCaret(UCaret * caretA); 00107 UCaret * getCaret() const; 00108 00109 // 00110 // size hints 00111 // 00115 void setColumns(unsigned int columnsA); 00116 unsigned int getColumns() const; 00117 00121 void setRows(unsigned int rowsA); 00122 unsigned int getRows() const; 00123 00124 public: // Overrides UWidget 00125 virtual void validateSelf(); 00126 virtual void processMouseEvent(UMouseEvent * e); 00127 virtual UDimension getContentsSize(const UDimension & maxSize) const; 00128 00129 public: // Public streaming methods 00131 virtual std::streambuf * rdbuf(); 00132 00133 int overflow(int c); 00134 00135 // stream-like insertion operators 00136 UTextWidget & operator<<(const std::string & str); 00137 UTextWidget & operator<<(int i); 00138 UTextWidget & operator<<(long i); 00139 UTextWidget & operator<<(float f); 00140 UTextWidget & operator<<(double d); 00141 UTextWidget & operator<<(const char * cstr); 00142 00143 protected: 00144 UTextModel * getTextModel() const; 00145 void docChanged(UDocument*, unsigned int, 00146 unsigned int, unsigned int); 00147 protected: // Protected attributes 00149 static std::string m_textBuffer; 00150 00151 private: // Private attributes 00152 UDocument * m_doc; 00153 UTextLayout * m_textLayout; 00154 00158 std::string m_type; 00159 00160 unsigned int m_columns; 00161 unsigned int m_rows; 00162 }; 00163 00164 } // namespace ufo 00165 00166 #endif // UTEXTWIDGET_HPP

The libUFO Project - written by Johannes Schmidt