Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | Related Pages

multilineedit.h

00001 /* 00002 libwftk - Worldforge Toolkit - a widget library 00003 Copyright (C) 2002 Malcolm Walker <malcolm@worldforge.org> 00004 Based on code copyright (C) 1999-2002 Karsten Laux 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the 00018 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, SA. 00020 */ 00021 00022 #ifndef _MULTILINEDIT_H 00023 #define _MULTILINEDIT_H 00024 00025 #include <vector> 00026 00027 #include <wftk/font.h> 00028 #include <wftk/lineedit.h> 00029 00030 namespace wftk { 00031 00033 class MultiLineEdit : public LineEdit 00034 { 00035 public: 00044 explicit MultiLineEdit(const std::string& text = "", const Font &font=Font(), 00045 bool readonly = true, bool fill = false); 00047 virtual ~MultiLineEdit(); 00048 00050 void setWrapping(bool flag); 00052 void setMaxLinesToStore(unsigned n) 00053 {maxLinesToStore_ = n; textUpdate();} 00054 00056 virtual void addText(const std::string&); 00058 void newline() {addText("\n");} 00060 unsigned visibleLines() const; 00062 void setMarkupColor(unsigned index, const Color& fontCol); 00064 void setMarkupFont(unsigned index, const Font& font); 00066 void setImage(unsigned index, Surface::Resource* surface); 00068 void setImage(unsigned index, const Surface& surface); 00070 void setImage(unsigned index, const std::string&); 00071 00076 enum tag_t { 00077 START_TAG=127, 00078 END_TAG=126, 00079 FONT_TAG=124, 00080 IMAGE_TAG=123, 00081 LINK_TAG=122 00082 }; 00083 00085 SigC::Signal1<void, unsigned> linkActivated; 00086 00088 virtual bool buttonEvent(Mouse::Button, bool, const Point&); 00089 00090 protected: 00092 virtual void setPackingInfo(); 00094 virtual void handleResize(Uint16 w, Uint16 h); 00096 void breakText(std::string&, std::vector<std::string>&, unsigned); 00098 void renderTextLines(const std::vector<std::string>&); 00100 unsigned maxLinesToStore_; 00101 private: 00103 void preprocessLines(std::vector<std::string>& lines); 00105 virtual Point drawText(Surface&, const Point&, const Region&); 00107 virtual void updateText(); 00109 unsigned maxLines(); 00111 bool wordWrap_; 00113 bool readOnly_; 00115 bool fill_; 00117 std::vector<Font> fonts_; 00119 std::vector<Surface::Resource*> images_; 00121 typedef struct 00122 { 00123 unsigned link; // 0 means no link 00124 unsigned image; // 0 means no images 00125 unsigned font; // 0 means the default font 00126 std::string text; 00127 } TextChunk; 00129 typedef std::vector<TextChunk> TextLine; 00131 std::vector<TextLine> textLines_; 00133 unsigned displayLines_; 00135 typedef struct 00136 { 00137 unsigned id; 00138 Rect rect; 00139 } LinkArea; 00141 std::vector<LinkArea> linkAreas_; 00142 }; 00143 00144 } // namespace wftk 00145 00146 #endif // _MULTILINEDIT_H

Generated Mon Sep 6 21:58:16 2004.
Copyright © 1998-2003 by the respective authors.

This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.