libyui-ncurses  2.44.1
/usr/src/RPM/BUILD/libyui-ncurses-2.44.1/src/NCMultiLineEdit.cc
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:       NCMultiLineEdit.cc
00020 
00021    Author:     Michael Andres <ma@suse.de>
00022 
00023 /-*/
00024 
00025 #define  YUILogComponent "ncurses"
00026 #include <yui/YUILog.h>
00027 #include "NCMultiLineEdit.h"
00028 
00029 
00030 NCMultiLineEdit::NCMultiLineEdit( YWidget * parent, const std::string & nlabel )
00031         : YMultiLineEdit( parent, nlabel )
00032         , NCPadWidget( parent )
00033 {
00034     yuiDebug() << std::endl;
00035     defsze = wsze( 5, 5 ) + wsze( 0, 2 );
00036     setLabel( nlabel );
00037 }
00038 
00039 
00040 NCMultiLineEdit::~NCMultiLineEdit()
00041 {
00042     yuiDebug() << std::endl;
00043 }
00044 
00045 
00046 int NCMultiLineEdit::preferredWidth()
00047 {
00048     defsze.W = ( 5 > labelWidth() ? 5 : labelWidth() ) + 2;
00049     return wGetDefsze().W;
00050 }
00051 
00052 
00053 int NCMultiLineEdit::preferredHeight()
00054 {
00055     return wGetDefsze().H;
00056     //return YMultiLineEdit::defaultVisibleLines();
00057 }
00058 
00059 
00060 void NCMultiLineEdit::setEnabled( bool do_bv )
00061 {
00062     NCWidget::setEnabled( do_bv );
00063     YMultiLineEdit::setEnabled( do_bv );
00064 }
00065 
00066 
00067 void NCMultiLineEdit::setSize( int newwidth, int newheight )
00068 {
00069     wRelocate( wpos( 0 ), wsze( newheight, newwidth ) );
00070 }
00071 
00072 
00073 void NCMultiLineEdit::setLabel( const std::string & nlabel )
00074 {
00075     YMultiLineEdit::setLabel( nlabel );
00076     NCPadWidget::setLabel( NCstring( nlabel ) );
00077 }
00078 
00079 
00080 void NCMultiLineEdit::setValue( const std::string & ntext )
00081 {
00082     DelPad();
00083     ctext = NCstring( ntext );
00084     Redraw();
00085 }
00086 
00087 
00088 std::string NCMultiLineEdit::value()
00089 {
00090     if ( myPad() )
00091     {
00092         ctext = NCstring( myPad()->getText() );
00093     }
00094 
00095     return ctext.Str();
00096 }
00097 
00098 
00099 void NCMultiLineEdit::wRedraw()
00100 {
00101     if ( !win )
00102         return;
00103 
00104     NCPadWidget::wRedraw();
00105 }
00106 
00107 
00108 NCursesEvent NCMultiLineEdit::wHandleInput( wint_t key )
00109 {
00110     NCursesEvent ret;
00111     handleInput( key );
00112 
00113     if ( notify() )
00114         ret = NCursesEvent::ValueChanged;
00115 
00116     return ret;
00117 }
00118 
00119 
00120 NCPad * NCMultiLineEdit::CreatePad()
00121 {
00122     wsze psze( defPadSze() );
00123     NCPad * npad = new NCTextPad( psze.H, psze.W, *this );
00124     npad->bkgd( listStyle().item.plain );
00125 
00126     return npad;
00127 }
00128 
00129 
00130 void NCMultiLineEdit::DrawPad()
00131 {
00132     myPad()->setText( ctext );
00133 }
00134 
00135 
00136 void NCMultiLineEdit::setInputMaxLength( int numberOfChars )
00137 {
00138     myPad()->setInputMaxLength( numberOfChars );
00139     YMultiLineEdit::setInputMaxLength( numberOfChars );
00140 }
 All Classes Functions Variables