libyui-ncurses  2.44.1
 All Classes Functions Variables
NCMultiLineEdit.cc
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: NCMultiLineEdit.cc
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #define YUILogComponent "ncurses"
26 #include <yui/YUILog.h>
27 #include "NCMultiLineEdit.h"
28 
29 
30 NCMultiLineEdit::NCMultiLineEdit( YWidget * parent, const std::string & nlabel )
31  : YMultiLineEdit( parent, nlabel )
32  , NCPadWidget( parent )
33 {
34  yuiDebug() << std::endl;
35  defsze = wsze( 5, 5 ) + wsze( 0, 2 );
36  setLabel( nlabel );
37 }
38 
39 
40 NCMultiLineEdit::~NCMultiLineEdit()
41 {
42  yuiDebug() << std::endl;
43 }
44 
45 
46 int NCMultiLineEdit::preferredWidth()
47 {
48  defsze.W = ( 5 > labelWidth() ? 5 : labelWidth() ) + 2;
49  return wGetDefsze().W;
50 }
51 
52 
53 int NCMultiLineEdit::preferredHeight()
54 {
55  return wGetDefsze().H;
56  //return YMultiLineEdit::defaultVisibleLines();
57 }
58 
59 
60 void NCMultiLineEdit::setEnabled( bool do_bv )
61 {
62  NCWidget::setEnabled( do_bv );
63  YMultiLineEdit::setEnabled( do_bv );
64 }
65 
66 
67 void NCMultiLineEdit::setSize( int newwidth, int newheight )
68 {
69  wRelocate( wpos( 0 ), wsze( newheight, newwidth ) );
70 }
71 
72 
73 void NCMultiLineEdit::setLabel( const std::string & nlabel )
74 {
75  YMultiLineEdit::setLabel( nlabel );
76  NCPadWidget::setLabel( NCstring( nlabel ) );
77 }
78 
79 
80 void NCMultiLineEdit::setValue( const std::string & ntext )
81 {
82  DelPad();
83  ctext = NCstring( ntext );
84  Redraw();
85 }
86 
87 
88 std::string NCMultiLineEdit::value()
89 {
90  if ( myPad() )
91  {
92  ctext = NCstring( myPad()->getText() );
93  }
94 
95  return ctext.Str();
96 }
97 
98 
99 void NCMultiLineEdit::wRedraw()
100 {
101  if ( !win )
102  return;
103 
104  NCPadWidget::wRedraw();
105 }
106 
107 
108 NCursesEvent NCMultiLineEdit::wHandleInput( wint_t key )
109 {
110  NCursesEvent ret;
111  handleInput( key );
112 
113  if ( notify() )
114  ret = NCursesEvent::ValueChanged;
115 
116  return ret;
117 }
118 
119 
120 NCPad * NCMultiLineEdit::CreatePad()
121 {
122  wsze psze( defPadSze() );
123  NCPad * npad = new NCTextPad( psze.H, psze.W, *this );
124  npad->bkgd( listStyle().item.plain );
125 
126  return npad;
127 }
128 
129 
130 void NCMultiLineEdit::DrawPad()
131 {
132  myPad()->setText( ctext );
133 }
134 
135 
136 void NCMultiLineEdit::setInputMaxLength( int numberOfChars )
137 {
138  myPad()->setInputMaxLength( numberOfChars );
139  YMultiLineEdit::setInputMaxLength( numberOfChars );
140 }
int bkgd(const chtype ch)
Definition: ncursesw.h:1443
Definition: NCPad.h:93
Definition: position.h:109
virtual NCTextPad * myPad() const
virtual void setEnabled(bool do_bv)=0
Definition: NCWidget.cc:391
virtual void setEnabled(bool do_bv)
Definition: position.h:154