libyui-ncurses  2.44.1
/usr/src/RPM/BUILD/libyui-ncurses-2.44.1/src/NCTextPad.h
00001 /*
00002   Copyright (C) 2000-2012 Novell, Inc
00003   This library is free software; you can redistribute it and/or modify
00004   it under the terms of the GNU Lesser General Public License as
00005   published by the Free Software Foundation; either version 2.1 of the
00006   License, or (at your option) version 3.0 of the License. This library
00007   is distributed in the hope that it will be useful, but WITHOUT ANY
00008   WARRANTY; without even the implied warranty of MERCHANTABILITY or
00009   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00010   License for more details. You should have received a copy of the GNU
00011   Lesser General Public License along with this library; if not, write
00012   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
00013   Floor, Boston, MA 02110-1301 USA
00014 */
00015 
00016 
00017 /*-/
00018 
00019    File:       NCTextPad.h
00020 
00021    Author:     Michael Andres <ma@suse.de>
00022 
00023 /-*/
00024 
00025 #ifndef NCTextPad_h
00026 #define NCTextPad_h
00027 
00028 #include <iosfwd>
00029 #include <list>
00030 
00031 #include "NCPad.h"
00032 #include "NCtext.h"
00033 
00034 
00035 class NCTextPad : public NCPad
00036 {
00037 
00038     friend std::ostream & operator<<( std::ostream & STREAM, const NCTextPad & OBJ );
00039 
00040     NCTextPad & operator=( const NCTextPad & );
00041     NCTextPad( const NCTextPad & );
00042 
00043 private:
00044 
00045     std::list<unsigned>      lines;
00046     std::list<unsigned>::iterator cline;
00047 
00048     wpos curs;
00049     bool curson;
00050 
00051     void cursor( bool on );
00052     void cursorOn()  { cursor( true ); }
00053 
00054     void cursorOff() { cursor( false ); }
00055 
00056     bool insert( wint_t key );
00057     bool delch( bool previous = false );
00058     bool openLine();
00059 
00060     void assertSze( wsze minsze );
00061     void assertWidth( unsigned minw );
00062     void assertHeight( unsigned minh );
00063 
00064     // specifies how much characters can be inserted. -1 for unlimited input
00065     int InputMaxLength;
00066 
00067 protected:
00068 
00069     virtual int setpos( const wpos & newpos );
00070 
00071 public:
00072 
00073     NCTextPad( int lines, int cols, const NCWidget & p );
00074     virtual ~NCTextPad();
00075 
00076 public:
00077 
00078     virtual void resize( wsze nsze );
00079     virtual int setpos();
00080     virtual wpos CurPos() const;
00081     virtual bool handleInput( wint_t key );
00082 
00083     void setText( const NCtext & ntext );
00084     std::wstring getText() const;
00085 
00086     // limits  the input to numberOfChars characters and truncates the text
00087     // if appropriate
00088     void setInputMaxLength( int nr );
00089 };
00090 
00091 
00092 #endif // NCTextPad_h
 All Classes Functions Variables