Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

NDK_XX::ListBox Class Reference

#include <ndk++.h>

Inheritance diagram for NDK_XX::ListBox:

NDK_XX::Control NDK_XX::CheckListBox NDK_XX::ChoiceBox NDK_XX::MenuBar NDK_XX::SelectionBox NDK_XX::FramedMenuBar NDK_XX::SubMenu List of all members.

Public Methods

 ListBox (Control *parent, int id, const string &title,int lines, int cols, int y, int x,int style=tabstop|framed|notify)
 ListBox (int id, const string &title,int lines, int cols, int y, int x,int style=tabstop|framed|notify)
 ~ListBox ()
int add_item (const string &new_item, int pos=-1, bool is_default=false, bool make_visible=true)
 You can add an item just sending in a string.

int add_item (ListItemData *new_item, int pos=-1, bool make_visible=true)
int remove_item (int pos=-1)
 Drop an item from the list.

int refresh ()
 Here we will manage the virtualized list.

void show ()
 call panel's show and set our state accordingly

void hide ()
 call panel's hide and set our state accordingly

void activate ()
 Draw as active (i.e.,with bold frame).

void deactivate ()
 Draw as inactive (i.e.,with normal frame).

string get_text () const
void set_text (const string &v)
 Usualy, a control in a dialog has some kind of text on it...

virtual int get_cur_pos ()
 Where are we standing on the list?

virtual void set_cur_pos (int pos=-1)
virtual int get_cur_sel ()
 The current checked item.

void set_cur_sel (int pos)
virtual void get_sel_items (IndexList &list)
 On a multisel list, the list of checked items.

virtual void set_sel_items (const IndexList &list, bool t_or_f=true)
virtual string get_item_text (int pos=-1)
 Get tht text for the pos'th item.

virtual void set_item_text (int pos, const string &txt)
virtual int sel_string (int pos, const string &pattern)
 Select an item based on the given pattern, starting at pos.

virtual void * get_item_data (int pos=-1)
 Get the user data hooked on the pos'th item.

virtual void set_item_data (int pos, void *data)
virtual ListItemDataget_item (int pos=-1)
 Get full info for the pos'th item.

virtual void set_item (int pos, ListItemData *item)
virtual int get_count ()
 How long is the list?

void clear ()
 Remove all the elements.

int largest_name_len () const

Protected Methods

int driver (int key)
virtual void lefttext (int row, const char *label)
virtual void righttext (int row, const char *label)
void show_text (const string &t, char where)
virtual void adjust_visible_items ()
virtual int move_up ()
virtual int move_down ()
virtual void activate_item (int item_idx)
virtual void deactivate_item (int item_idx)
void update_data (int item_idx)
 Copy to the buffer the full info of item_idx'th item.

void update_item (int item_idx)
 Copy to the visible item the full info of item_idx'th item.

void refresh_items ()
 Refresh the visible elements.

void clear_items ()
 Clear (erase) the visible items.

void delete_data ()
 Clear (erase) the full list of items.

void show_empty ()
 If there are no elements to show, put the 'Empty' tag.

void draw_scrollbar ()
 Draw a vertical scroll bar (just visual sugar, we don't have mouse yet).

ListItem *& visible_item (int requested)
 Virtualize the requested item index.

void check_multisel (int pos, bool t_or_f)
 Do we allow multiple selection?

void on_sel_change (int)
 DECLARE_BINDINGS ()
 A macro for enabling message processing (see ndk_bindings.h).


Protected Attributes

string _title
int pos_x
int pos_y
VisibleItems items
ListItems data
int curr_item
int first_visible
int last_visible
int cur_sel

Friends

class ListItem

Constructor & Destructor Documentation

NDK_XX::ListBox::ListBox Control   parent,
int    id,
const string &    title,
int    lines,
int    cols,
int    y,
int    x,
int    style = tabstop|framed|notify
 

ListBox Constructor See parameters for class Control

Definition at line 885 of file ndk++.cc.

References draw_scrollbar(), NDK_XX::Control::enable_notify(), NDK_XX::Control::has_frame(), pos_x, pos_y, set_text(), and NDK_XX::Control::title.

Referenced by set_text().

00889         :Control( parent,id,lines,cols,y,x,style)
00890             ,pos_x(0), pos_y(0)
00891             ,curr_item(-1)
00892             ,first_visible(-1)
00893             ,last_visible(-1)
00894             ,cur_sel(-1)
00895 {
00896     enable_notify(false);
00897     if(has_frame()){
00898         pos_x++;
00899         pos_y++;
00900     }
00901     set_text(title);
00902     draw_scrollbar();
00903     enable_notify();
00904 }

NDK_XX::ListBox::ListBox int    id,
const string &    title,
int    lines,
int    cols,
int    y,
int    x,
int    style = tabstop|framed|notify
 

Definition at line 907 of file ndk++.cc.

References draw_scrollbar(), NDK_XX::Control::enable_notify(), NDK_XX::Control::has_frame(), pos_x, pos_y, set_text(), and NDK_XX::Control::title.

00910         :Control( id,lines,cols,y,x,style)
00911             ,pos_x(0), pos_y(0)
00912             ,curr_item(-1)
00913             ,first_visible(-1)
00914             ,last_visible(-1)
00915             ,cur_sel(-1)
00916 {
00917     enable_notify(false);
00918     if(has_frame()){
00919         pos_x++;
00920         pos_y++;
00921     }
00922     set_text(title);
00923     draw_scrollbar();
00924     enable_notify();
00925 }

NDK_XX::ListBox::~ListBox  
 

Definition at line 936 of file ndk++.cc.

References delete_data(), hide(), and items.

00937 {
00938     hide();
00939     VisibleItems::iterator it;
00940     for(it=items.begin();it!=items.end();it++){
00941         delete *it;
00942     }
00943     
00944     delete_data();
00945 }


Member Function Documentation

void NDK_XX::ListBox::activate   [virtual]
 

Draw as active (i.e.,with bold frame).

Reimplemented from NDK_XX::Control.

Definition at line 1195 of file ndk++.cc.

References _title, draw_scrollbar(), refresh(), and set_text().

01196 {
01197     Control::activate();
01198     attron(A_BOLD);
01199     set_text(_title);
01200     attroff(A_BOLD);
01201     draw_scrollbar();
01202     refresh();
01203 }

void NDK_XX::ListBox::activate_item int    item_idx [protected, virtual]
 

Definition at line 1258 of file ndk++.cc.

References NDK_XX::Button::activate(), update_item(), and visible_item().

Referenced by refresh().

01259 {
01260     update_item(item_idx);
01261     visible_item(item_idx)->activate();
01262 }

int NDK_XX::ListBox::add_item ListItemData   new_item,
int    pos = -1,
bool    make_visible = true
 

Here you are sending a full item data ptr. The list will own it and dispose it at destruction time

Definition at line 1034 of file ndk++.cc.

References adjust_visible_items(), curr_item, data, draw_scrollbar(), and refresh().

01036 {
01037     int old_current = curr_item;
01038     ///by default, we insert at the end
01039     ListItems::iterator where=data.end();
01040     
01041     if(pos!=-1 ){
01042         if(pos >-1 && pos < data.size()){
01043             where=data.begin()+pos;
01044             if(make_visible){
01045                 curr_item=pos;
01046             }
01047         }
01048         else
01049             throw
01050                 Exception<ListBox>(this
01051                                     ,"Position out of range in add_item");
01052     }
01053     else{
01054         if(data.empty()==false){/// if no data, curr_item already is 0
01055             if(make_visible){
01056                 curr_item++;
01057             }
01058         }
01059     }
01060     data.insert(where,new_item);
01061     adjust_visible_items();
01062     draw_scrollbar();
01063     refresh();
01064 }

int NDK_XX::ListBox::add_item const string &    new_item,
int    pos = -1,
bool    is_default = false,
bool    make_visible = true
 

You can add an item just sending in a string.

Definition at line 1023 of file ndk++.cc.

References data, and NDK_XX::ListItemData::set_default().

01025 {
01026     ListItemData *item=new ListItemData(new_item,data.size());
01027     item->set_default(is_default);
01028     add_item(item,pos,make_visible);
01029 }

void NDK_XX::ListBox::adjust_visible_items   [protected, virtual]
 

Definition at line 1168 of file ndk++.cc.

References curr_item, data, first_visible, items, last_visible, and refresh_items().

Referenced by add_item(), move_down(), move_up(), remove_item(), set_cur_pos(), and set_cur_sel().

01169 {
01170     
01171     if(curr_item < first_visible){
01172         first_visible = curr_item;
01173         last_visible = first_visible + (items.size()-1);
01174     }
01175     if(curr_item > last_visible){
01176         last_visible = curr_item;
01177         first_visible = last_visible - (items.size()-1);
01178         if(first_visible < 0)
01179             first_visible =0;
01180     }
01181     
01182     if(first_visible > data.size()) first_visible = (data.size()-1);
01183     if(last_visible > data.size() || items.size() >= data.size())
01184         last_visible = (data.size()-1);
01185         
01186     if(first_visible < 0) first_visible =0;
01187     if(last_visible < 0) last_visible =0;
01188     
01189     refresh_items();
01190 }

void NDK_XX::ListBox::check_multisel int    pos,
bool    t_or_f
[protected]
 

Do we allow multiple selection?

Definition at line 1484 of file ndk++.cc.

References cur_sel, data, first_visible, NDK_XX::Control::is_multisel(), last_visible, and update_item().

Referenced by on_sel_change(), and set_cur_sel().

01485 {
01486     if(!is_multisel()){
01487         if(t_or_f==true){
01488             cur_sel = pos;
01489             for(int i=0;i<data.size();i++){
01490                 if(i != pos){
01491                     data[i]->set_check(false);
01492                     if(i>=first_visible && i<=last_visible){
01493                         update_item(i);
01494                     }
01495                 }
01496             }
01497         }
01498         else //t_or_f == false
01499             cur_sel=-1;
01500     }
01501 }

void NDK_XX::ListBox::clear  
 

Remove all the elements.

Definition at line 959 of file ndk++.cc.

References curr_item, data, delete_data(), draw_scrollbar(), first_visible, last_visible, refresh(), refresh_items(), and show_empty().

00960 {
00961     delete_data();
00962     data.clear();
00963     curr_item=first_visible=last_visible=0;
00964     refresh_items();
00965     show_empty();
00966     draw_scrollbar();
00967     refresh();
00968 }

void NDK_XX::ListBox::clear_items   [protected]
 

Clear (erase) the visible items.

Definition at line 1113 of file ndk++.cc.

References data, first_visible, and items.

Referenced by refresh_items().

01114 {
01115     for( int idx=data.size()-first_visible;idx <items.size(); idx++){
01116         items[idx]->set_text("");
01117     }
01118 }

void NDK_XX::ListBox::deactivate   [virtual]
 

Draw as inactive (i.e.,with normal frame).

Reimplemented from NDK_XX::Control.

Definition at line 1208 of file ndk++.cc.

References _title, curr_item, deactivate_item(), draw_scrollbar(), refresh(), and set_text().

01209 {
01210     Control::deactivate();
01211     attron(A_BOLD);
01212     set_text(_title);
01213     attroff(A_BOLD);
01214     deactivate_item(curr_item);
01215     draw_scrollbar();
01216     refresh();
01217 }

void NDK_XX::ListBox::deactivate_item int    item_idx [protected, virtual]
 

Definition at line 1267 of file ndk++.cc.

References NDK_XX::Button::deactivate(), update_data(), and visible_item().

Referenced by deactivate(), and refresh().

01268 {
01269     visible_item(item_idx)->deactivate();
01270     update_data(item_idx);
01271 }

NDK_XX::ListBox::DECLARE_BINDINGS   [protected]
 

A macro for enabling message processing (see ndk_bindings.h).

void NDK_XX::ListBox::delete_data   [protected]
 

Clear (erase) the full list of items.

Definition at line 949 of file ndk++.cc.

References data.

Referenced by clear(), and ~ListBox().

00950 {
00951     ListItems::iterator d;
00952     for(d=data.begin();d!=data.end();d++){
00953         delete *d;
00954     }
00955 }

void NDK_XX::ListBox::draw_scrollbar   [protected]
 

Draw a vertical scroll bar (just visual sugar, we don't have mouse yet).

Definition at line 984 of file ndk++.cc.

References data, first_visible, NDK_XX::Control::has_vscrollbar(), and items.

Referenced by activate(), add_item(), clear(), deactivate(), ListBox(), move_down(), move_up(), remove_item(), set_cur_pos(), and set_cur_sel().

00985 {
00986     if(!has_vscrollbar())
00987         return;
00988     int i, row, col, h_len, v_len;
00989     int winheight=items.size();
00990     int dataheight = data.size();
00991     int top = ((first_visible==-1)? 0:first_visible);
00992 
00993     if(dataheight==0)
00994         dataheight = 1;
00995         
00996     v_len = (winheight*winheight + dataheight - 1)/dataheight;
00997     if (v_len==0)
00998       v_len = 1;
00999     if (v_len > winheight)
01000       v_len = winheight;
01001 
01002 
01003     row  = (top * winheight + dataheight - 1) / dataheight;
01004     if (row + v_len > winheight)
01005       row = winheight - v_len;
01006 
01007     vline(1,maxx(),winheight);
01008     attron(A_REVERSE);
01009     if (v_len>=2) {
01010       addch(row+1,maxx(),ACS_UARROW);
01011       for(i=2;i<v_len;i++)
01012         addch(row+i,maxx(),' ');
01013       addch(row+v_len,maxx(),ACS_DARROW);
01014     }
01015     else {
01016       for(i=1;i<=v_len;i++)
01017         addch(row+i,maxx(),' ');
01018     }
01019     attroff(A_REVERSE);
01020 }

int NDK_XX::ListBox::driver int    key [protected, virtual]
 

get a chance at processing the key, before parent does

Reimplemented from NDK_XX::Control.

Reimplemented in NDK_XX::MenuBar.

Definition at line 1123 of file ndk++.cc.

References curr_item, data, NDK_XX::ListItem::driver(), first_visible, move_down(), NDK_XX::Control::move_left(), NDK_XX::Control::move_right(), move_up(), set_cur_pos(), set_cur_sel(), and visible_item().

01124 {
01125     if( data.size()
01126         && curr_item!=-1
01127 //      && (is_multisel() || cur_sel==-1)
01128         && visible_item(curr_item)->driver(key)==TRUE)
01129         return TRUE;
01130     switch(key) {
01131         case KEY_UP:    
01132             return move_up();   
01133         case KEY_DOWN:  
01134             return move_down();
01135         case KEY_RIGHT:
01136             return move_right();
01137         case KEY_LEFT:
01138             return move_left();
01139 #ifdef NCURSES_MOUSE_VERSION
01140         case KEY_MOUSE:
01141         {
01142             MEVENT  event;
01143             getmouse(&event);
01144             if ((event.bstate & (BUTTON1_CLICKED|BUTTON1_DOUBLE_CLICKED|BUTTON1_TRIPLE_CLICKED))
01145             && wenclose(w,event.y, event.x))
01146             {   // we react only if the click was in the userwin, that means
01147                 // inside the menu display area or at the decoration window.
01148                 int ry = event.y, rx = event.x; /* screen coordinates */
01149 
01150                 if (mouse_trafo(&ry,&rx,FALSE)){
01151                     set_cur_pos(first_visible + (ry-begy()-1));
01152                     if (event.bstate & BUTTON1_DOUBLE_CLICKED)
01153                         set_cur_sel(curr_item);
01154                     return true;
01155                 }
01156             }
01157             break;
01158         }
01159 #endif /* NCURSES_MOUSE_VERSION */
01160         default:
01161             break;
01162     }
01163     return FALSE;
01164 }

virtual int NDK_XX::ListBox::get_count   [inline, virtual]
 

How long is the list?

Definition at line 1180 of file ndk++.h.

References NDK_XX::SelectionBox::initialize_items().

01181 {

int NDK_XX::ListBox::get_cur_pos   [virtual]
 

Where are we standing on the list?

Definition at line 1412 of file ndk++.cc.

References curr_item.

Referenced by NDK_XX::PopUpMenu::action().

01413 {
01414     return curr_item;   
01415 }

int NDK_XX::ListBox::get_cur_sel   [virtual]
 

The current checked item.

Definition at line 1445 of file ndk++.cc.

References cur_sel, and NDK_XX::Control::is_multisel().

01446 {
01447     if(is_multisel())
01448         throw Exception<ListBox>(this,"Calling get_selected and is_multisel==true");
01449         
01450     return cur_sel; 
01451 }

ListItemData * NDK_XX::ListBox::get_item int    pos = -1 [virtual]
 

Get full info for the pos'th item.

Definition at line 1389 of file ndk++.cc.

References data.

01390 {
01391     ListItemData *result=0;
01392     if(pos>-1 && pos < data.size())
01393         result = data[pos];
01394 
01395     return result;
01396 }

void * NDK_XX::ListBox::get_item_data int    pos = -1 [virtual]
 

Get the user data hooked on the pos'th item.

Definition at line 1370 of file ndk++.cc.

References data.

01371 {
01372     void *result=0;
01373     if(pos>-1 && pos < data.size())
01374         result = data[pos]->get_user_data();
01375 
01376     return result;
01377 }

string NDK_XX::ListBox::get_item_text int    pos = -1 [virtual]
 

Get tht text for the pos'th item.

Definition at line 1338 of file ndk++.cc.

References data.

01338                                     {
01339     string result;
01340     if(pos>-1 && pos < data.size())
01341         result = data[pos]->get_text();
01342 
01343     return result;
01344 }

void NDK_XX::ListBox::get_sel_items IndexList   list [virtual]
 

On a multisel list, the list of checked items.

Definition at line 1455 of file ndk++.cc.

References cur_sel, data, NDK_XX::IndexList, and NDK_XX::Control::is_multisel().

01456 {
01457     list.clear();
01458     if(is_multisel()){
01459         for(int i=0;i<data.size();i++){
01460             if(data[i]->is_checked())
01461                 list.push_back(i);
01462         }
01463     }
01464     else
01465         list.push_back(cur_sel);
01466     
01467 }

string NDK_XX::ListBox::get_text   const [inline, virtual]
 

Implements NDK_XX::Control.

Definition at line 1146 of file ndk++.h.

01154 : public ListBox

void NDK_XX::ListBox::hide   [inline, virtual]
 

call panel's hide and set our state accordingly

Reimplemented from NDK_XX::Control.

Definition at line 1135 of file ndk++.h.

References first_visible, and items.

Referenced by NDK_XX::MenuBar::execute(), and ~ListBox().

01137                                     {return items[requested-first_visible];}
01138 
01139     ///Do we allow multiple selection?
01140     void check_multisel(int pos, bool t_or_f);
01141     

int NDK_XX::ListBox::largest_name_len   const
 

Definition at line 1516 of file ndk++.cc.

01516                                   {
01517     unsigned MaximumNameLength = 0;
01518     ListItems::const_iterator it;
01519     for(it = data.begin(); it !=data.end();it++){
01520         string name((*it)->get_text());
01521         
01522         if (name.size() > MaximumNameLength ){
01523             MaximumNameLength  = name.size();
01524         }
01525     }
01526     return MaximumNameLength;
01527 }

void NDK_XX::ListBox::lefttext int    row,
const char *    label
[protected, virtual]
 

Put the label text at the left (0) in the specified row.

Definition at line 1237 of file ndk++.cc.

Referenced by show_text().

01237                                                 {
01238   if (label) {
01239     OnError(addstr(row, 1, label, width()));
01240   }
01241 }

int NDK_XX::ListBox::move_down   [protected, virtual]
 

Reimplemented in NDK_XX::MenuBar, and NDK_XX::SubMenu.

Definition at line 1320 of file ndk++.cc.

References adjust_visible_items(), cur_sel, curr_item, data, draw_scrollbar(), NDK_XX::Control::get_ctrl_id(), NDK_XX::Control::is_multisel(), LI_POS_CHANGE, NDK_XX::Control::notify_enabled(), NDK_XX::Control::pParent, NDK_XX::Control::process_message(), refresh(), NDK_XX::ListItem::set_check(), and visible_item().

Referenced by driver().

01321 {
01322     if(data.size() && curr_item < data.size()-1){
01323         curr_item++;
01324         adjust_visible_items();
01325         draw_scrollbar();
01326         refresh();
01327         if(!is_multisel()&& cur_sel!=-1)
01328             visible_item(curr_item)->set_check();
01329         if(notify_enabled()){
01330             process_message(pParent,LI_POS_CHANGE,get_ctrl_id(),0);
01331         }
01332     }
01333     return true;
01334 }

int NDK_XX::ListBox::move_up   [protected, virtual]
 

Reimplemented in NDK_XX::MenuBar, and NDK_XX::SubMenu.

Definition at line 1301 of file ndk++.cc.

References adjust_visible_items(), cur_sel, curr_item, draw_scrollbar(), NDK_XX::Control::get_ctrl_id(), NDK_XX::Control::is_multisel(), LI_POS_CHANGE, NDK_XX::Control::notify_enabled(), NDK_XX::Control::pParent, NDK_XX::Control::process_message(), refresh(), NDK_XX::ListItem::set_check(), and visible_item().

Referenced by driver().

01302 {
01303     if(curr_item){
01304         curr_item--;
01305         adjust_visible_items();
01306         draw_scrollbar();
01307         refresh();
01308         if(!is_multisel() && cur_sel!=-1)
01309             visible_item(curr_item)->set_check();
01310         if(notify_enabled()){
01311             process_message(pParent,LI_POS_CHANGE,get_ctrl_id(),0);
01312         }
01313     }
01314     return true;
01315 }

void NDK_XX::ListBox::on_sel_change int    [protected]
 

Definition at line 1505 of file ndk++.cc.

References check_multisel(), curr_item, data, NDK_XX::Control::get_ctrl_id(), LI_SEL_CHANGE, NDK_XX::Control::notify_enabled(), NDK_XX::Control::pParent, NDK_XX::Control::process_message(), refresh(), and update_data().

01506 {
01507     update_data(curr_item);
01508     check_multisel(curr_item,data[curr_item]->is_checked());
01509     refresh();
01510     if(notify_enabled())
01511         process_message(pParent,LI_SEL_CHANGE,get_ctrl_id(),0);
01512 }   

int NDK_XX::ListBox::refresh  
 

Here we will manage the virtualized list.

Definition at line 1091 of file ndk++.cc.

References activate_item(), curr_item, deactivate_item(), first_visible, and last_visible.

Referenced by activate(), add_item(), clear(), deactivate(), NDK_XX::MenuBar::driver(), NDK_XX::MenuBar::execute(), NDK_XX::MenuBar::execute_current_item(), move_down(), move_up(), on_sel_change(), remove_item(), set_cur_pos(), set_cur_sel(), set_item(), and set_sel_items().

01092 {
01093     for( int idx=first_visible;idx <= last_visible; idx++){
01094         if(idx!=curr_item)
01095             deactivate_item(idx);
01096     }
01097     activate_item(curr_item);
01098 }

void NDK_XX::ListBox::refresh_items   [protected]
 

Refresh the visible elements.

Definition at line 1102 of file ndk++.cc.

References clear_items(), first_visible, last_visible, and update_item().

Referenced by adjust_visible_items(), clear(), set_item(), and set_sel_items().

01103 {
01104     for( int idx=first_visible;idx <= last_visible; idx++){
01105         update_item(idx);
01106     }
01107     clear_items();
01108 
01109 }

int NDK_XX::ListBox::remove_item int    pos = -1
 

Drop an item from the list.

Definition at line 1069 of file ndk++.cc.

References adjust_visible_items(), cur_sel, curr_item, data, draw_scrollbar(), NDK_XX::Control::is_multisel(), refresh(), set_cur_sel(), and show_empty().

01070 {
01071     if(pos>=0 && pos < data.size()){
01072         data.erase(data.begin()+pos);
01073         if(pos<= curr_item && curr_item)
01074             curr_item--;
01075         if(cur_sel == pos){
01076             if(is_multisel()){
01077                 cur_sel = -1;
01078                 adjust_visible_items();
01079                 draw_scrollbar();
01080                 show_empty();
01081                 refresh();
01082             }
01083             else if(cur_sel!=-1)
01084                 set_cur_sel(curr_item);
01085         }
01086     }
01087 };

void NDK_XX::ListBox::righttext int    row,
const char *    label
[protected, virtual]
 

Put the label text to the right (ending at maxx()) in the specified row.

Definition at line 1246 of file ndk++.cc.

Referenced by show_text().

01246                                                  {
01247   if (label) {
01248     int x = maxx() - strlen(label)-1;
01249     if (x<0)
01250       x=0;
01251     OnError(addstr(row, x, label, width()));
01252   }
01253 }

int NDK_XX::ListBox::sel_string int    pos,
const string &    pattern
[virtual]
 

Select an item based on the given pattern, starting at pos.

Definition at line 1356 of file ndk++.cc.

References data, and set_cur_sel().

01357 {
01358     ListItems::iterator it;
01359     for(int i=pos;i<data.size();i++){
01360         if(data[i]->text.find(txt)!=string::npos){
01361             set_cur_sel(i);
01362             return i;
01363         }
01364     }
01365     return string::npos;
01366 }

void NDK_XX::ListBox::set_cur_pos int    pos = -1 [virtual]
 

Definition at line 1419 of file ndk++.cc.

References adjust_visible_items(), curr_item, data, draw_scrollbar(), and refresh().

Referenced by NDK_XX::PopUpMenu::action(), driver(), and NDK_XX::MenuBar::find_clicked().

01420 {
01421     if(pos>-1 && pos < data.size()){
01422         curr_item = pos;
01423         adjust_visible_items();
01424         draw_scrollbar();
01425         refresh();
01426     }
01427 }

void NDK_XX::ListBox::set_cur_sel int    pos
 

Definition at line 1431 of file ndk++.cc.

References adjust_visible_items(), check_multisel(), curr_item, data, draw_scrollbar(), refresh(), NDK_XX::ListItem::set_check(), and visible_item().

Referenced by driver(), remove_item(), and sel_string().

01432 {
01433     if(pos>-1 && pos < data.size()){
01434         curr_item = pos;
01435         adjust_visible_items();
01436         draw_scrollbar();
01437         visible_item(pos)->set_check(true);
01438         check_multisel(pos, true);
01439         refresh();
01440     }
01441 }

void NDK_XX::ListBox::set_item int    pos,
ListItemData   item
[virtual]
 

Definition at line 1400 of file ndk++.cc.

References data, refresh(), and refresh_items().

01401 {
01402     if(pos>-1 && pos < data.size()){
01403         delete data[pos];
01404         data[pos]=item;
01405         refresh_items();
01406         refresh();
01407     }
01408 }

void NDK_XX::ListBox::set_item_data int    pos,
void *    data
[virtual]
 

Definition at line 1381 of file ndk++.cc.

References data.

01382 {
01383     if(pos>-1 && pos < data.size())
01384         data[pos]->set_user_data(usr_data);
01385 }

void NDK_XX::ListBox::set_item_text int    pos,
const string &    txt
[virtual]
 

Definition at line 1348 of file ndk++.cc.

References data.

01349 {
01350     if(pos>-1 && pos < data.size())
01351         data[pos]->set_text(txt);
01352 }

void NDK_XX::ListBox::set_sel_items const IndexList   list,
bool    t_or_f = true
[virtual]
 

Definition at line 1471 of file ndk++.cc.

References data, NDK_XX::IndexList, NDK_XX::Control::is_multisel(), refresh(), and refresh_items().

01472 {
01473     if(is_multisel()){
01474         for(int i=0;i<list.size();i++){
01475             data[list[i]]->set_check(t_or_f);
01476         }
01477     }
01478     refresh_items();
01479     refresh();
01480 }

void NDK_XX::ListBox::set_text const string &    v [inline, virtual]
 

Usualy, a control in a dialog has some kind of text on it...

Implements NDK_XX::Control.

Definition at line 1147 of file ndk++.h.

References NDK_XX::Control::framed, NDK_XX::SelectionBox::initialize_items(), ListBox(), NDK_XX::Control::notify, NDK_XX::SelectionBox::SelectionBox(), NDK_XX::Control::tabstop, and NDK_XX::Control::title.

Referenced by activate(), deactivate(), and ListBox().

01154                    : public ListBox

void NDK_XX::ListBox::show   [inline, virtual]
 

call panel's show and set our state accordingly

Reimplemented from NDK_XX::Control.

Definition at line 1126 of file ndk++.h.

Referenced by NDK_XX::MenuBar::execute().

01137                                     {return items[requested-first_visible];}

void NDK_XX::ListBox::show_empty   [protected]
 

If there are no elements to show, put the 'Empty' tag.

Definition at line 972 of file ndk++.cc.

References cur_sel, data, and items.

Referenced by clear(), NDK_XX::ChoiceBox::initialize_items(), NDK_XX::CheckListBox::initialize_items(), NDK_XX::SelectionBox::initialize_items(), and remove_item().

00973 {
00974     if(data.empty()){
00975         cur_sel=-1;
00976         items[0]->set_text("Empty");
00977         items[0]->enable(false);
00978     }
00979 
00980 }

void NDK_XX::ListBox::show_text const string &    t,
char    where
[protected]
 

Definition at line 1222 of file ndk++.cc.

References lefttext(), and righttext().

01223 {
01224     if (!t.empty()){
01225         switch(where){
01226             case 'l': lefttext(0,t.c_str()); break;
01227             case 'c': centertext(0,t.c_str()); break;
01228             case 'r': righttext(0,t.c_str()); break;
01229             default: centertext(0,t.c_str()); break;
01230         }
01231     }
01232 }

void NDK_XX::ListBox::update_data int    item_idx [protected]
 

Copy to the buffer the full info of item_idx'th item.

Definition at line 1276 of file ndk++.cc.

References data, and visible_item().

Referenced by deactivate_item(), and on_sel_change().

01277 {
01278     if(data.empty()||item_idx<0||item_idx >= data.size() )
01279         return;
01280     ListItem &itm= *(visible_item(item_idx));
01281     ListItemData &dat = *(data[item_idx]);
01282     dat = itm;
01283     
01284 }

void NDK_XX::ListBox::update_item int    item_idx [protected]
 

Copy to the visible item the full info of item_idx'th item.

Definition at line 1289 of file ndk++.cc.

References data, and visible_item().

Referenced by activate_item(), check_multisel(), and refresh_items().

01290 {
01291     if(data.empty()||item_idx<0||item_idx >= data.size() )
01292         return;
01293     ListItem &itm= *(visible_item(item_idx));
01294     ListItemData &dat = *(data[item_idx]);
01295     itm = dat;
01296 }

ListItem*& NDK_XX::ListBox::visible_item int    requested [inline, protected]
 

Virtualize the requested item index.

Definition at line 1239 of file ndk++.h.

Referenced by activate_item(), deactivate_item(), driver(), NDK_XX::MenuBar::execute_current_item(), move_down(), move_up(), set_cur_sel(), update_data(), and update_item().

01250               : public ListBox


Friends And Related Function Documentation

friend class ListItem [friend]
 

Definition at line 1095 of file ndk++.h.

Referenced by NDK_XX::SelectionBox::initialize_items().


Member Data Documentation

string NDK_XX::ListBox::_title [protected]
 

Definition at line 1187 of file ndk++.h.

Referenced by NDK_XX::ExitCmd::action(), activate(), and deactivate().

int NDK_XX::ListBox::cur_sel [protected]
 

Definition at line 1196 of file ndk++.h.

Referenced by check_multisel(), get_cur_sel(), get_sel_items(), move_down(), move_up(), remove_item(), and show_empty().

int NDK_XX::ListBox::curr_item [protected]
 

Definition at line 1193 of file ndk++.h.

Referenced by add_item(), adjust_visible_items(), clear(), deactivate(), driver(), NDK_XX::MenuBar::execute_current_item(), get_cur_pos(), NDK_XX::ChoiceBox::initialize_items(), NDK_XX::CheckListBox::initialize_items(), NDK_XX::SelectionBox::initialize_items(), move_down(), move_up(), on_sel_change(), refresh(), remove_item(), set_cur_pos(), and set_cur_sel().

ListItems NDK_XX::ListBox::data [protected]
 

Definition at line 1191 of file ndk++.h.

Referenced by NDK_XX::ExitCmd::action(), add_item(), adjust_visible_items(), check_multisel(), clear(), clear_items(), delete_data(), draw_scrollbar(), driver(), NDK_XX::MenuBar::execute_current_item(), get_item(), get_item_data(), get_item_text(), get_sel_items(), move_down(), on_sel_change(), remove_item(), sel_string(), set_cur_pos(), set_cur_sel(), set_item(), set_item_data(), set_item_text(), set_sel_items(), show_empty(), update_data(), update_item(), and NDK_XX::NonImplementedItem::~NonImplementedItem().

int NDK_XX::ListBox::first_visible [protected]
 

Definition at line 1194 of file ndk++.h.

Referenced by adjust_visible_items(), check_multisel(), clear(), clear_items(), draw_scrollbar(), driver(), NDK_XX::MenuBar::find_clicked(), hide(), NDK_XX::ChoiceBox::initialize_items(), NDK_XX::CheckListBox::initialize_items(), NDK_XX::SelectionBox::initialize_items(), refresh(), and refresh_items().

VisibleItems NDK_XX::ListBox::items [protected]
 

Definition at line 1190 of file ndk++.h.

Referenced by NDK_XX::ExitCmd::action(), adjust_visible_items(), clear_items(), draw_scrollbar(), NDK_XX::MenuBar::find_clicked(), NDK_XX::MenuBar::get_next_item_x(), NDK_XX::MenuBar::get_next_item_y(), hide(), NDK_XX::ChoiceBox::initialize_items(), NDK_XX::CheckListBox::initialize_items(), NDK_XX::SelectionBox::initialize_items(), show_empty(), and ~ListBox().

int NDK_XX::ListBox::last_visible [protected]
 

Definition at line 1195 of file ndk++.h.

Referenced by adjust_visible_items(), check_multisel(), clear(), NDK_XX::ChoiceBox::initialize_items(), NDK_XX::CheckListBox::initialize_items(), NDK_XX::SelectionBox::initialize_items(), refresh(), and refresh_items().

int NDK_XX::ListBox::pos_x [protected]
 

Definition at line 1188 of file ndk++.h.

Referenced by NDK_XX::ExitCmd::action(), NDK_XX::MenuBar::get_next_item_x(), NDK_XX::ChoiceBox::initialize_items(), NDK_XX::CheckListBox::initialize_items(), NDK_XX::SelectionBox::initialize_items(), and ListBox().

int NDK_XX::ListBox::pos_y [protected]
 

Definition at line 1188 of file ndk++.h.

Referenced by NDK_XX::ExitCmd::action(), NDK_XX::MenuBar::get_next_item_y(), NDK_XX::ChoiceBox::initialize_items(), NDK_XX::CheckListBox::initialize_items(), NDK_XX::SelectionBox::initialize_items(), and ListBox().


The documentation for this class was generated from the following files:
Generated on Thu Oct 10 16:02:18 2002 by doxygen1.2.17