libyui-ncurses  2.44.1
/usr/src/RPM/BUILD/libyui-ncurses-2.44.1/src/NCPadWidget.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:       NCPadWidget.h
00020 
00021    Author:     Michael Andres <ma@suse.de>
00022 
00023 /-*/
00024 
00025 #ifndef NCPadWidget_h
00026 #define NCPadWidget_h
00027 
00028 #include <iosfwd>
00029 
00030 #include "NCWidget.h"
00031 #include "NCPad.h"
00032 
00033 class NCPadWidget;
00034 class NCScrollbar;
00035 
00036 
00037 class NCPadWidget : public NCWidget, protected NCSchrollCB
00038 {
00039 private:
00040 
00041     friend std::ostream & operator<<( std::ostream & STREAM, const NCPadWidget & OBJ );
00042 
00043     NCPadWidget & operator=( const NCPadWidget & );
00044     NCPadWidget( const NCPadWidget & );
00045 
00046 
00047     NClabel         label;
00048     NCursesWindow * padwin;
00049     NCScrollbar *   hsb;
00050     NCScrollbar *   vsb;
00051 
00052     wsze  minPadSze;
00053     bool  multidraw;
00054     NCPad * pad;
00055 
00056 protected:
00057 
00058     /**
00059      * Return the current pad. Make it virtual so descendant classes
00060      * can narrow the return type.
00061      */
00062     virtual NCPad * myPad() const { return pad; }
00063 
00064     bool    hasHeadline;
00065     bool    activeLabelOnly;
00066 
00067     void startMultidraw()    { multidraw = true; }
00068 
00069     void stopMultidraw()     { multidraw = false; DrawPad(); }
00070 
00071     bool inMultidraw() const { return multidraw; }
00072 
00073 protected:
00074 
00075     virtual const char * location() const { return "NCPadWidget"; }
00076 
00077     // widget stuff
00078     unsigned labelWidth() const { return label.width(); }
00079 
00080     virtual void wCreate( const wrect & newrect );
00081     virtual void wDelete();
00082     virtual void wRedraw();
00083     virtual void wRecoded();
00084 
00085     // pad stuff
00086     wsze defPadSze() const
00087     {
00088         if ( !padwin )
00089             return 0;
00090 
00091         return wsze( padwin->height(), padwin->width() );
00092     }
00093 
00094     virtual NCPad * CreatePad();
00095     virtual void    DrawPad();
00096 
00097     void InitPad();
00098     void AdjustPad( wsze nsze );
00099     void DelPad();
00100 
00101     // scroll hints
00102     virtual void HScroll( unsigned total, unsigned visible, unsigned start );
00103     virtual void VScroll( unsigned total, unsigned visible, unsigned start );
00104     virtual void ScrollHead( NCursesWindow & w, unsigned ccol );
00105 
00106     // resize hints
00107     virtual void AdjustPadSize( wsze & minsze );
00108 
00109     // input
00110     virtual bool handleInput( wint_t key );
00111 
00112 public:
00113 
00114     NCPadWidget( NCWidget * myparent = 0 );
00115     NCPadWidget( YWidget * parent );
00116 
00117     virtual ~NCPadWidget();
00118 
00119     size_t Columns( ) { return minPadSze.W; }
00120 
00121     void setLabel( const NClabel & nlabel );
00122 
00123     virtual void setEnabled( bool do_bv ) { NCWidget::setEnabled( do_bv ); }
00124 };
00125 
00126 
00127 #endif // NCPadWidget_h
 All Classes Functions Variables