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

NCtext.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:       NCtext.h
00014 
00015    Author:     Michael Andres <ma@suse.de>
00016    Maintainer: Michael Andres <ma@suse.de>
00017 
00018 /-*/
00019 #ifndef NCtext_h
00020 #define NCtext_h
00021 
00022 #include <iosfwd>
00023 
00024 #include <list>
00025 using namespace std;
00026 
00027 #include "NCstring.h"
00028 #include "NCWidget.h"
00029 class NCursesWindow;
00030 
00032 //
00033 //      CLASS NAME : NCtext
00034 //
00035 //      DESCRIPTION :
00036 //
00037 class NCtext {
00038 
00039   friend std::ostream & operator<<( std::ostream & STREAM, const NCtext & OBJ );
00040 
00041   public:
00042 
00043     typedef list<NCstring>::iterator       iterator;
00044     typedef list<NCstring>::const_iterator const_iterator;
00045 
00046   private:
00047 
00048     static const NCstring emptyStr;
00049 
00050   protected:
00051 
00052     list<NCstring> mtext;
00053 
00054     virtual void lset( const NCstring & ntext );
00055     void lbrset( const NCstring & ntext, size_t columns ); 
00056 
00057   public:
00058 
00059     NCtext( const NCstring & nstr = "" );
00060     NCtext( const NCstring & nstr, size_t columns );
00061 
00062     virtual ~NCtext();
00063 
00064     unsigned Lines()   const;
00065     size_t Columns() const;
00066 
00067     void append( const NCstring & line );
00068     
00069     const list<NCstring> & Text() const { return mtext; }
00070     const NCstring &       operator[]( std::wstring::size_type idx ) const;
00071 
00072     const_iterator begin() const { return mtext.begin(); }
00073     const_iterator end()   const { return mtext.end(); }
00074 };
00075 
00077 
00079 //
00080 //      CLASS NAME : NClabel
00081 //
00082 //      DESCRIPTION :
00083 //
00084 class NClabel : protected NCtext {
00085 
00086   friend std::ostream & operator<<( std::ostream & STREAM, const NClabel & OBJ );
00087 
00088   protected:
00089 
00090     std::wstring::size_type hotline;
00091 
00092     virtual void lset( const NCstring & ntext ) {
00093       NCtext::lset( ntext );
00094 //      stripHotkey();
00095     }
00096 
00097   public:
00098 
00099     void stripHotkey();
00100     NClabel( const NCstring & nstr = "" )
00101       : NCtext( nstr )
00102     { /*stripHotkey();*/ }
00103 
00104     virtual ~NClabel() {}
00105 
00106   public:
00107 
00108     size_t   width()  const { return Columns(); }
00109     unsigned height() const { return Lines(); }
00110     wsze     size()   const { return wsze( Lines(), Columns() ); }
00111     const list<NCstring> & getText() const { return Text(); }
00112     
00113     void drawAt( NCursesWindow & w, chtype style, chtype hotstyle,
00114                  const wrect & dim,
00115                  const NC::ADJUST adjust = NC::TOPLEFT,
00116                  bool fillup = true ) const;
00117 
00118     //
00119     void drawAt( NCursesWindow & w, chtype style, chtype hotstyle,
00120                  const NC::ADJUST adjust = NC::TOPLEFT,
00121                  bool fillup = true ) const {
00122       drawAt( w, style, hotstyle, wrect( 0, -1 ), adjust, fillup );
00123     }
00124 
00125     void drawAt( NCursesWindow & w, chtype style, chtype hotstyle,
00126                  const wpos & pos,
00127                  const NC::ADJUST adjust = NC::TOPLEFT,
00128                  bool fillup = true ) const {
00129       drawAt( w, style, hotstyle, wrect( pos, -1 ), adjust, fillup );
00130     }
00131 
00132     void drawAt( NCursesWindow & w, chtype style, chtype hotstyle,
00133                  const wpos & pos, const wsze & sze,
00134                  const NC::ADJUST adjust = NC::TOPLEFT,
00135                  bool fillup = true ) const {
00136       drawAt( w, style, hotstyle, wrect( pos, sze ), adjust, fillup );
00137     }
00138 
00139     //
00140     void drawAt( NCursesWindow & w, const NCstyle::StItem & istyle,
00141                  const NC::ADJUST adjust = NC::TOPLEFT,
00142                  bool fillup = true ) const {
00143       drawAt( w, istyle.label, istyle.hint, wrect( 0, -1 ), adjust, fillup );
00144     }
00145 
00146     void drawAt( NCursesWindow & w, const NCstyle::StItem & istyle,
00147                  const wpos & pos,
00148                  const NC::ADJUST adjust = NC::TOPLEFT,
00149                  bool fillup = true ) const {
00150       drawAt( w, istyle.label, istyle.hint, wrect( pos, -1 ), adjust, fillup );
00151     }
00152 
00153     void drawAt( NCursesWindow & w, const NCstyle::StItem & istyle,
00154                  const wpos & pos, const wsze & sze,
00155                  const NC::ADJUST adjust = NC::TOPLEFT,
00156                  bool fillup = true ) const {
00157       drawAt( w, istyle.label, istyle.hint, wrect( pos, sze ), adjust, fillup );
00158     }
00159 
00160     void drawAt( NCursesWindow & w, const NCstyle::StItem & istyle,
00161                  const wrect & dim,
00162                  const NC::ADJUST adjust = NC::TOPLEFT,
00163                  bool fillup = true ) const {
00164       drawAt( w, istyle.label, istyle.hint, dim, adjust, fillup );
00165     }
00166 
00167     //
00168 
00169 
00170     bool        hasHotkey() const { return hotline != wstring::npos; }
00171     wchar_t     hotkey() const { return hasHotkey() ? operator[]( hotline ).hotkey() : L'\0'; }
00172     std::wstring::size_type   hotpos() const { return hasHotkey() ? operator[]( hotline ).hotpos() : wstring::npos; }
00173 };
00174 
00176 
00177 #endif // NCtext_h

Generated on Wed Sep 14 10:52:54 2005 for yast2-ncurses by  doxygen 1.4.4