libyui-ncurses  2.44.1
 All Classes Functions Variables
NCTextPad.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: NCTextPad.h
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #ifndef NCTextPad_h
26 #define NCTextPad_h
27 
28 #include <iosfwd>
29 #include <list>
30 
31 #include "NCPad.h"
32 #include "NCtext.h"
33 
34 
35 class NCTextPad : public NCPad
36 {
37 
38  friend std::ostream & operator<<( std::ostream & STREAM, const NCTextPad & OBJ );
39 
40  NCTextPad & operator=( const NCTextPad & );
41  NCTextPad( const NCTextPad & );
42 
43 private:
44 
45  std::list<unsigned> lines;
46  std::list<unsigned>::iterator cline;
47 
48  wpos curs;
49  bool curson;
50 
51  void cursor( bool on );
52  void cursorOn() { cursor( true ); }
53 
54  void cursorOff() { cursor( false ); }
55 
56  bool insert( wint_t key );
57  bool delch( bool previous = false );
58  bool openLine();
59 
60  void assertSze( wsze minsze );
61  void assertWidth( unsigned minw );
62  void assertHeight( unsigned minh );
63 
64  // specifies how much characters can be inserted. -1 for unlimited input
65  int InputMaxLength;
66 
67 protected:
68 
69  virtual int setpos( const wpos & newpos );
70 
71 public:
72 
73  NCTextPad( int lines, int cols, const NCWidget & p );
74  virtual ~NCTextPad();
75 
76 public:
77 
78  virtual void resize( wsze nsze );
79  virtual int setpos();
80  virtual wpos CurPos() const;
81  virtual bool handleInput( wint_t key );
82 
83  void setText( const NCtext & ntext );
84  std::wstring getText() const;
85 
86  // limits the input to numberOfChars characters and truncates the text
87  // if appropriate
88  void setInputMaxLength( int nr );
89 };
90 
91 
92 #endif // NCTextPad_h
Definition: NCtext.h:37
static int lines()
Definition: ncursesw.h:1042
Definition: NCPad.h:93
static int cols()
Definition: ncursesw.h:1047
Definition: position.h:109
Definition: position.h:154