libyui-ncurses  2.55.0
NCCustomStatusItemSelector.h
1 /*
2  Copyright (C) 2019 SUSE LLC
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: NCCustomStatusItemSelector.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 #ifndef NCCustomStatusItemSelector_h
26 #define NCCustomStatusItemSelector_h
27 
28 #include <iosfwd>
29 #include <string>
30 
31 #include "NCItemSelector.h"
32 
33 
34 /**
35  * Specialized subclass of NCTableTag that can not only handle a boolean
36  * "selected" flag (and accordingly set "[ ]" / "[x]" or "( )" / "(x)" as a
37  * status indicator), but extended numeric status values and an assciated text.
38  **/
39 class NCCustomStatusTableTag: public NCTableTag // base class defined in NCTablePad.h
40 {
41 public:
42 
43  NCCustomStatusTableTag( YItemSelector * parentSelector, YItem * item );
44  virtual ~NCCustomStatusTableTag() {}
45 
46  virtual void DrawAt( NCursesWindow & w, const wrect at,
47  NCTableStyle & tableStyle,
48  NCTableLine::STATE linestate,
49  unsigned colidx ) const;
50 
51  virtual void SetSelected( bool sel );
52 
53  virtual bool Selected() const;
54 
55  virtual bool SingleSelection() const { return false; }
56 
57  /**
58  * Return the numeric status value of the associated item.
59  **/
60  int status() const;
61 
62  /**
63  * Set the numeric status value of the associated item and update the
64  * status indicator.
65  **/
66  void setStatus( int newStatus );
67 
68  /**
69  * Update the status indicator according to the status of the associated
70  * item, i.e. display the status text for that custom status.
71  **/
72  void updateStatusIndicator();
73 
74 protected:
75 
76  YItemSelector * _parentSelector;
77 };
78 
79 
80 
82 {
83  friend std::ostream & operator<<( std::ostream & str, const NCCustomStatusItemSelector & obj );
84 
85 public:
86 
87  /**
88  * Constructor.
89  **/
90  NCCustomStatusItemSelector( YWidget * parent,
91  const YItemCustomStatusVector & customStates );
92 
93  /**
94  * Destructor.
95  **/
97 
98  virtual const char * location() const { return "NCCustomStatusItemSelector"; }
99 
100 
101 protected:
102 
103  /**
104  * Create a tag cell for an item. This is the cell with the "[x]" or "(x)"
105  * selector. It also stores the item pointer so the item can later be
106  * referenced by this tag.
107  **/
108  virtual NCTableTag * createTagCell( YItem * item );
109 
110  /**
111  * Cycle the status of the current item through its possible values.
112  * For a plain ItemSelector, this means true -> false -> true.
113  **/
114  virtual void cycleCurrentItemStatus();
115 
116  /**
117  * Return 'true' if a status change (by user interaction) from status
118  * 'fromStatus' to status 'toStatus' is allowed, 'false' if not.
119  **/
120  virtual bool statusChangeAllowed( int fromStatus, int toStatus );
121 
122  /**
123  * Notification that a status value was just changed in the input handler
124  * and the 'notify' flag is set.
125  **/
126  virtual NCursesEvent valueChangedNotify( YItem * item );
127 
128  /**
129  * Return the tag cell (the cell with the "[x]" or "(x)" selector) for the
130  * item with the specified index.
131  **/
132  virtual NCCustomStatusTableTag * tagCell( int index ) const;
133 
134  /**
135  * Update the status indicator.
136  * This is only called if custom status values are used.
137  *
138  * Reimplemented from YItemSelector.
139  **/
140  virtual void updateCustomStatusIndicator( YItem * item );
141 
142 
143 private:
144 
145  // Disable assignement operator and copy constructor
146 
149 };
150 
151 
152 #endif // NCCustomStatusItemSelector_h
virtual bool statusChangeAllowed(int fromStatus, int toStatus)
Return 'true' if a status change (by user interaction) from status 'fromStatus' to status 'toStatus' ...
virtual void cycleCurrentItemStatus()
Cycle the status of the current item through its possible values.
virtual NCCustomStatusTableTag * tagCell(int index) const
Return the tag cell (the cell with the "[x]" or "(x)" selector) for the item with the specified index...
NCCustomStatusItemSelector(YWidget *parent, const YItemCustomStatusVector &customStates)
Constructor.
virtual void updateCustomStatusIndicator(YItem *item)
Update the status indicator.
virtual NCursesEvent valueChangedNotify(YItem *item)
Notification that a status value was just changed in the input handler and the 'notify' flag is set.
virtual NCTableTag * createTagCell(YItem *item)
Create a tag cell for an item.
virtual ~NCCustomStatusItemSelector()
Destructor.
Specialized subclass of NCTableTag that can not only handle a boolean "selected" flag (and accordingl...
void updateStatusIndicator()
Update the status indicator according to the status of the associated item, i.e.
void setStatus(int newStatus)
Set the numeric status value of the associated item and update the status indicator.
int status() const
Return the numeric status value of the associated item.
C++ class for windows.
Definition: ncursesw.h:904