libyui-ncurses  2.57.2
NCPadWidget.h
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: NCPadWidget.h
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #ifndef NCPadWidget_h
26 #define NCPadWidget_h
27 
28 #include <iosfwd>
29 
30 #include "NCWidget.h"
31 #include "NCPad.h"
32 
33 class NCPadWidget;
34 class NCScrollbar;
35 
36 /**
37  * Base class for widgets with scrollable contents
38  */
39 class NCPadWidget : public NCWidget, protected NCSchrollCB
40 {
41 private:
42 
43  friend std::ostream & operator<<( std::ostream & str, const NCPadWidget & obj );
44 
45  NCPadWidget & operator=( const NCPadWidget & );
46  NCPadWidget( const NCPadWidget & );
47 
48 
49  NClabel label;
50  NCursesWindow * padwin; ///< (owned IFF different from NCWidget::*win*)
51  NCScrollbar * hsb; ///< (owned)
52  NCScrollbar * vsb; ///< (owned)
53 
54  wsze minPadSze;
55  bool multidraw;
56  NCPad * pad; ///< (owned)
57 
58 protected:
59 
60  /**
61  * Return the current pad. Make it virtual so descendant classes
62  * can narrow the return type.
63  */
64  virtual NCPad * myPad() const { return pad; }
65 
66  bool hasHeadline;
67  bool activeLabelOnly;
68 
69  void startMultidraw() { multidraw = true; }
70 
71  void stopMultidraw() { multidraw = false; DrawPad(); }
72 
73  bool inMultidraw() const { return multidraw; }
74 
75 protected:
76 
77  virtual const char * location() const { return "NCPadWidget"; }
78 
79  // widget stuff
80  unsigned labelWidth() const { return label.width(); }
81 
82  virtual void wCreate( const wrect & newrect );
83  virtual void wDelete();
84  virtual void wRedraw();
85  virtual void wRecoded();
86 
87  // pad stuff
88  wsze defPadSze() const
89  {
90  if ( !padwin )
91  return 0;
92 
93  return wsze( padwin->height(), padwin->width() );
94  }
95 
96  virtual NCPad * CreatePad();
97  virtual void DrawPad();
98 
99  void InitPad();
100  void AdjustPad( wsze nsze );
101  void DelPad();
102 
103  // scroll hints
104  virtual void HScroll( unsigned total, unsigned visible, unsigned start );
105  virtual void VScroll( unsigned total, unsigned visible, unsigned start );
106  virtual void ScrollHead( NCursesWindow & w, unsigned ccol );
107 
108  // resize hints
109  virtual void AdjustPadSize( wsze & minsze );
110 
111  // input
112  virtual bool handleInput( wint_t key );
113 
114 public:
115 
116  NCPadWidget( NCWidget * myparent = 0 );
117  NCPadWidget( YWidget * parent );
118 
119  virtual ~NCPadWidget();
120 
121  size_t Columns() { return minPadSze.W; }
122 
123  void setLabel( const NClabel & nlabel );
124 
125  virtual void setEnabled( bool do_bv ) { NCWidget::setEnabled( do_bv ); }
126 };
127 
128 
129 #endif // NCPadWidget_h
wsze
Screen dimension (screen size) in the order height, width: (H, W)
Definition: position.h:154
NCPadWidget::VScroll
virtual void VScroll(unsigned total, unsigned visible, unsigned start)
Definition: NCPadWidget.cc:516
NCursesWindow
C++ class for windows.
Definition: ncursesw.h:907
NCWidget::setEnabled
virtual void setEnabled(bool do_bv)=0
Pure virtual to make sure every widget implements it.
Definition: NCWidget.cc:392
NClabel
Multi-line string, with optional hotkey, drawable.
Definition: NCtext.h:82
NCPadWidget::HScroll
virtual void HScroll(unsigned total, unsigned visible, unsigned start)
Definition: NCPadWidget.cc:505
NCSchrollCB
Interface for scroll callbacks.
Definition: NCPad.h:36
NCWidget
Definition: NCWidget.h:46
NCursesWindow::width
int width() const
Number of columns in this window.
Definition: ncursesw.h:1077
NCPad
A virtual window with a real viewport (which is NCursesWindow) and a scrolling mechanism.
Definition: NCPad.h:113
NCursesWindow::height
int height() const
Number of lines in this window.
Definition: ncursesw.h:1072
NCScrollbar
Scrollbar indicator.
Definition: NCPadWidget.cc:49
NCPadWidget::myPad
virtual NCPad * myPad() const
Return the current pad.
Definition: NCPadWidget.h:64
wrect
A rectangle is defined by its position and size: wpos Pos, wsze Sze.
Definition: position.h:194
NCPadWidget
Base class for widgets with scrollable contents.
Definition: NCPadWidget.h:40
NCPadWidget::setEnabled
virtual void setEnabled(bool do_bv)
Pure virtual to make sure every widget implements it.
Definition: NCPadWidget.h:125