Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

NCMultiSelectionBox.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013    File:       NCMultiSelectionBox.h
00014 
00015    Author:     Michael Andres <ma@suse.de>
00016    Maintainer: Michael Andres <ma@suse.de>
00017 
00018 /-*/
00019 #ifndef NCMultiSelectionBox_h
00020 #define NCMultiSelectionBox_h
00021 
00022 #include <iosfwd>
00023 
00024 #include <ycp/YCPVoid.h>
00025 #include "YMultiSelectionBox.h"
00026 #include "NCPadWidget.h"
00027 #include "NCTablePad.h"
00028 
00029 class NCMultiSelectionBox;
00030 class NCTableTag;
00031 
00032 
00034 //
00035 //      CLASS NAME : NCTableTag
00036 //
00037 //      DESCRIPTION :
00038 //
00039 class NCTableTag : public NCTableCol {
00040 
00041   private:
00042 
00043     bool selected;
00044 
00045   public:
00046 
00047     NCTableTag( const bool sel = false )
00048       : NCTableCol( NCstring( "[ ]" ), SEPARATOR )
00049       , selected( sel )
00050     {}
00051     virtual ~NCTableTag() {}
00052 
00053     virtual void SetLabel( const NCstring & ) { /*NOOP*/; }
00054 
00055     virtual void DrawAt( NCursesWindow & w, const wrect at,
00056                          NCTableStyle & tableStyle,
00057                          NCTableLine::STATE linestate,
00058                          unsigned colidx ) const {
00059       NCTableCol::DrawAt( w, at, tableStyle, linestate, colidx );
00060       if ( selected ) {
00061         setBkgd( w, tableStyle, linestate, DATA );
00062         w.addch( at.Pos.L, at.Pos.C +1, 'x' );
00063       }
00064     }
00065 
00066     void SetSelected( const bool sel ) { selected = sel; }
00067     bool Selected() const              { return selected; }
00068 };
00069 
00070 
00072 //
00073 //      CLASS NAME : NCMultiSelectionBox
00074 //
00075 //      DESCRIPTION :
00076 //
00077 class NCMultiSelectionBox : public YMultiSelectionBox, public NCPadWidget {
00078 
00079   friend std::ostream & operator<<( std::ostream & STREAM, const NCMultiSelectionBox & OBJ );
00080 
00081   NCMultiSelectionBox & operator=( const NCMultiSelectionBox & );
00082   NCMultiSelectionBox            ( const NCMultiSelectionBox & );
00083 
00084   protected:
00085 
00086     NCTablePad *& pad;
00087     NCTableTag * tagCell( int index );
00088     const NCTableTag * tagCell( int index ) const;
00089 
00090     bool isItemSelected( int index ) const;
00091     bool setItemSelected( int index, bool val, bool update = true );
00092     void setAllItemsSelected( bool val );
00093 
00094     void toggleCurrentItem();
00095 
00096   protected:
00097 
00098     virtual void startMultipleChanges() { startMultidraw(); }
00099     virtual void doneMultipleChanges()  { stopMultidraw(); }
00100 
00101   protected:
00102 
00103     virtual const char * location() const { return "NCMultiSelectionBox"; }
00104 
00105     virtual NCPad * CreatePad();
00106     virtual void    wRecoded();
00107 
00108     virtual void itemAdded( const YCPString& string, bool selected );
00109     virtual void deleteAllItems();
00110 
00111     virtual bool itemIsSelected( int index ) { return isItemSelected( index ); }
00112     virtual void selectItem( int index )  { setItemSelected( index, true ); }
00113     virtual void deselectItem( int index ){ setItemSelected( index, false ); }
00114     virtual void selectAllItems()         { setAllItemsSelected( true ); }
00115     virtual void deselectAllItems()       { setAllItemsSelected( false ); }
00116 
00117   public:
00118 
00119     NCMultiSelectionBox( NCWidget * parent, const YWidgetOpt & opt,
00120                          const YCPString & label );
00121     virtual ~NCMultiSelectionBox();
00122 
00123     virtual long nicesize( YUIDimension dim );
00124     virtual void setSize( long newwidth, long newheight );
00125 
00126     virtual void setLabel( const YCPString & nlabel );
00127 
00128     virtual int getCurrentItem();
00129     virtual void setCurrentItem( int index );
00130 
00131     virtual NCursesEvent wHandleInput( wint_t key );
00132 
00133     virtual void setEnabling( bool do_bv ) { NCWidget::setEnabling( enabled=do_bv ); }
00134 
00135     virtual bool setKeyboardFocus() {
00136       if ( !grabFocus() )
00137         return YWidget::setKeyboardFocus();
00138       return true;
00139     }
00140 
00141     // added by gs
00142     unsigned int getNumLines( ) { return pad->Lines(); }
00143     const NCTableLine * getLine( const int & index ) { return pad->GetLine(index); }
00144     void clearItems() { return pad->ClearTable(); }
00145 };
00146 
00148 
00149 #endif // NCMultiSelectionBox_h

Generated on Wed Nov 12 04:52:32 2008 for yast2-ncurses by  doxygen 1.3.9.1