26 #define YUILogComponent "ncurses"
27 #include <yui/YUILog.h>
29 #include "NCCustomStatusItemSelector.h"
35 const YItemCustomStatusVector & customStates )
86 int oldStatus = item->status();
87 int newStatus = customStatus( oldStatus ).nextStatus();
89 yuiDebug() <<
"Cycling status of item \""
90 << item->label() <<
"\": "
91 << oldStatus <<
" -> " << newStatus
94 if ( newStatus != -1 && oldStatus != newStatus )
96 item->setStatus( newStatus );
105 if ( fromStatus == toStatus )
108 if ( ! validCustomStatusIndex( fromStatus ) || ! validCustomStatusIndex( toStatus ) )
111 return customStatus( fromStatus ).nextStatus() == toStatus;
119 event.selection = (YMenuItem *) item;
121 yuiDebug() <<
"Sending MenuEvent for item \"" << item->label() <<
"\"" << endl;
130 NCCustomStatusTableTag::NCCustomStatusTableTag( YItemSelector * parentSelector, YItem * item )
132 , _parentSelector( parentSelector )
134 YUI_CHECK_PTR( _parentSelector );
135 updateStatusIndicator();
141 YItem * item = origItem();
145 string statusText = _parentSelector->customStatus( item->status() ).textIndicator();
149 NCTableCol::SetLabel(
NCstring( statusText ) );
157 NCTableLine::STATE linestate,
158 unsigned colidx )
const
162 NCTableCol::DrawAt( w, at, tableStyle, linestate, colidx );
168 YItem * item = origItem();
170 return item ? item->status() : 0;
176 YItem * item = origItem();
180 item->setStatus( newStatus );
186 void NCCustomStatusTableTag::SetSelected(
bool sel )
192 bool NCCustomStatusTableTag::Selected()
const
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.
virtual NCTableTag * tagCell(int index) const
Return the tag cell (the cell with the "[x]" or "(x)" selector) for the item with the specified index...
virtual YItem * currentItem() const
Return the current item, i.e.