#include <ndk++.h>
Inheritance diagram for NDK_XX::NDKDlgListBox:
Public Methods | |
NDKDlgListBox (NDKDlgControl *parent, int id, const string &title,int lines, int cols, int y, int x,int style=tabstop|framed|notify) | |
~NDKDlgListBox () | |
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 (NDKDlgListItemData *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 | activate () |
Maybe these should change to set_focus/unset_focus. | |
void | deactivate () |
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 () |
virtual void | set_cur_pos (int pos=-1) |
virtual int | get_cur_sel () |
void | set_cur_sel (int pos) |
virtual void | get_sel_items (IndexList &list) |
virtual void | set_sel_items (const IndexList &list, bool t_or_f=true) |
virtual string | get_item_text (int pos=-1) |
virtual void | set_item_text (int pos, const string &txt) |
virtual void * | get_item_data (int pos=-1) |
virtual void | set_item_data (int pos, void *data) |
virtual NDKDlgListItemData * | get_item (int pos=-1) |
virtual void | set_item (int pos, NDKDlgListItemData *item) |
virtual int | get_count () |
void | clear () |
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_top_and_bottom () |
virtual void | move_up () |
virtual void | move_down () |
virtual void | move_left () |
virtual void | move_right () |
virtual void | activate_item (int item_idx) |
virtual void | deactivate_item (int item_idx) |
void | update_data (int item_idx) |
void | update_item (int item_idx) |
void | refresh_items () |
void | clear_items () |
void | delete_data () |
void | show_empty () |
void | draw_scrollbar () |
NDKDlgListItem *& | visible_item (int requested) |
void | check_multisel (int pos, bool t_or_f) |
void | on_sel_change (int) |
DECLARE_BINDINGS () | |
Protected Attributes | |
string | _title |
int | pos_x |
int | pos_y |
VisibleItems | items |
ListItems | data |
int | curr_item |
int | top_item |
int | bottom_item |
int | cur_sel |
Friends | |
class | NDKDlgListItem |
|
Definition at line 866 of file ndk++.cc. References draw_scrollbar(), NDK_XX::NDKDlgControl::has_frame(), NDK_XX::NDKDlgControl::on_initial_update, pos_x, pos_y, and set_text(). Referenced by set_text().
00870 :NDKDlgControl( parent,id,lines,cols,y,x,style) 00871 ,pos_x(0), pos_y(0) 00872 ,curr_item(-1) 00873 ,top_item(-1) 00874 ,bottom_item(-1) 00875 ,cur_sel(-1) 00876 { 00877 on_initial_update=true; 00878 if(has_frame()){ 00879 pos_x++; 00880 pos_y++; 00881 } 00882 set_text(title); 00883 draw_scrollbar(); 00884 on_initial_update=false; 00885 } |
|
Definition at line 896 of file ndk++.cc. References delete_data(), NDK_XX::NDKDlgControl::hide(), and items.
00897 { 00898 hide(); 00899 VisibleItems::iterator it; 00900 for(it=items.begin();it!=items.end();it++){ 00901 // logfile << "Deleted Visible item " << (*(it))->get_text() << endl; 00902 delete *it; 00903 } 00904 00905 delete_data(); 00906 } |
|
Maybe these should change to set_focus/unset_focus.
Reimplemented from NDK_XX::NDKDlgControl. Definition at line 1130 of file ndk++.cc. References _title, draw_scrollbar(), refresh(), and set_text().
01131 { 01132 NDKDlgControl::activate(); 01133 attron(A_BOLD); 01134 set_text(_title); 01135 attroff(A_BOLD); 01136 draw_scrollbar(); 01137 refresh(); 01138 } |
|
Definition at line 1193 of file ndk++.cc. References NDK_XX::NDKDlgButton::activate(), update_item(), and visible_item(). Referenced by refresh().
01194 { 01195 update_item(item_idx); 01196 visible_item(item_idx)->activate(); 01197 } |
|
Here you are sending a full item data ptr. The list will own it and dispose it at destruction time Definition at line 996 of file ndk++.cc. References adjust_top_and_bottom(), curr_item, data, draw_scrollbar(), and refresh().
00998 { 00999 int old_current = curr_item; 01000 ///by default, we insert at the end 01001 ListItems::iterator where=data.end(); 01002 01003 if(pos!=-1 ){ 01004 if(pos >-1 && pos < data.size()){ 01005 where=data.begin()+pos; 01006 if(make_visible){ 01007 curr_item=pos; 01008 } 01009 } 01010 else 01011 throw 01012 NDKDlgException<NDKDlgListBox>(this 01013 ,"Position out of range in add_item"); 01014 } 01015 else{ 01016 if(data.empty()==false){/// if no data, curr_item already is 0 01017 if(make_visible){ 01018 curr_item++; 01019 } 01020 } 01021 } 01022 data.insert(where,new_item); 01023 adjust_top_and_bottom(); 01024 draw_scrollbar(); 01025 refresh(); 01026 } |
|
You can add an item just sending in a string.
Definition at line 985 of file ndk++.cc. References data, and NDK_XX::NDKDlgListItemData::set_default().
|
|
Definition at line 1104 of file ndk++.cc. References bottom_item, curr_item, data, items, refresh_items(), and top_item. Referenced by add_item(), move_down(), move_up(), remove_item(), set_cur_pos(), and set_cur_sel().
01105 { 01106 01107 if(curr_item < top_item){ 01108 top_item = curr_item; 01109 bottom_item = top_item + (items.size()-1); 01110 } 01111 if(curr_item > bottom_item){ 01112 bottom_item = curr_item; 01113 top_item = bottom_item - (items.size()-1); 01114 if(top_item < 0) 01115 top_item =0; 01116 } 01117 01118 if(top_item > data.size()) top_item = (data.size()-1); 01119 if(bottom_item > data.size()) bottom_item = (data.size()-1); 01120 01121 if(top_item < 0) top_item =0; 01122 if(bottom_item < 0) bottom_item =0; 01123 01124 refresh_items(); 01125 } |
|
Definition at line 1414 of file ndk++.cc. References bottom_item, cur_sel, data, NDK_XX::NDKDlgControl::is_multisel(), top_item, and update_item(). Referenced by on_sel_change(), and set_cur_sel().
01415 { 01416 if(!is_multisel()){ 01417 if(t_or_f==true){ 01418 cur_sel = pos; 01419 for(int i=0;i<data.size();i++){ 01420 if(i != pos){ 01421 data[i]->set_check(false); 01422 if(i>=top_item && i<=bottom_item){ 01423 update_item(i); 01424 } 01425 } 01426 } 01427 } 01428 else //t_or_f == false 01429 cur_sel=-1; 01430 } 01431 } |
|
Definition at line 921 of file ndk++.cc. References bottom_item, curr_item, data, delete_data(), draw_scrollbar(), refresh(), refresh_items(), show_empty(), and top_item.
00922 { 00923 delete_data(); 00924 data.clear(); 00925 curr_item=top_item=bottom_item=0; 00926 refresh_items(); 00927 show_empty(); 00928 draw_scrollbar(); 00929 refresh(); 00930 } |
|
Definition at line 1075 of file ndk++.cc. References data, items, and top_item. Referenced by refresh_items().
|
|
Reimplemented from NDK_XX::NDKDlgControl. Definition at line 1143 of file ndk++.cc. References _title, curr_item, deactivate_item(), draw_scrollbar(), refresh(), and set_text().
01144 { 01145 NDKDlgControl::deactivate(); 01146 attron(A_BOLD); 01147 set_text(_title); 01148 attroff(A_BOLD); 01149 deactivate_item(curr_item); 01150 draw_scrollbar(); 01151 refresh(); 01152 } |
|
Definition at line 1202 of file ndk++.cc. References NDK_XX::NDKDlgButton::deactivate(), update_data(), and visible_item(). Referenced by deactivate(), and refresh().
01203 { 01204 visible_item(item_idx)->deactivate(); 01205 update_data(item_idx); 01206 } |
|
|
|
Definition at line 910 of file ndk++.cc. References data. Referenced by clear(), and ~NDKDlgListBox().
|
|
Definition at line 946 of file ndk++.cc. References data, NDK_XX::NDKDlgControl::has_vscrollbar(), items, and top_item. Referenced by activate(), add_item(), clear(), deactivate(), move_down(), move_up(), NDKDlgListBox(), remove_item(), set_cur_pos(), and set_cur_sel().
00947 { 00948 if(!has_vscrollbar()) 00949 return; 00950 int i, row, col, h_len, v_len; 00951 int winheight=items.size(); 00952 int dataheight = data.size(); 00953 int top = ((top_item==-1)? 0:top_item); 00954 00955 if(dataheight==0) 00956 dataheight = 1; 00957 00958 v_len = (winheight*winheight + dataheight - 1)/dataheight; 00959 if (v_len==0) 00960 v_len = 1; 00961 if (v_len > winheight) 00962 v_len = winheight; 00963 00964 00965 row = (top * winheight + dataheight - 1) / dataheight; 00966 if (row + v_len > winheight) 00967 row = winheight - v_len; 00968 00969 vline(1,maxx(),winheight); 00970 attron(A_REVERSE); 00971 if (v_len>=2) { 00972 addch(row+1,maxx(),ACS_UARROW); 00973 for(i=2;i<v_len;i++) 00974 addch(row+i,maxx(),' '); 00975 addch(row+v_len,maxx(),ACS_DARROW); 00976 } 00977 else { 00978 for(i=1;i<=v_len;i++) 00979 addch(row+i,maxx(),' '); 00980 } 00981 attroff(A_REVERSE); 00982 } |
|
get a chance at processing the key, before parent does Reimplemented from NDK_XX::NDKDlgControl. Definition at line 1085 of file ndk++.cc. References curr_item, data, NDK_XX::NDKDlgListItem::driver(), move_down(), move_left(), move_right(), move_up(), and visible_item().
01086 { 01087 if( data.size() 01088 && curr_item!=-1 01089 && visible_item(curr_item)->driver(key)==TRUE) 01090 return TRUE; 01091 switch(key) { 01092 case KEY_UP: move_up(); return TRUE; 01093 case KEY_DOWN: move_down();return TRUE; 01094 case KEY_LEFT: move_left();return TRUE; 01095 case KEY_RIGHT: move_right();return TRUE; 01096 default: break; 01097 } 01098 return FALSE; 01099 } |
|
Definition at line 941 of file ndk++.h.
00943 : public NDKDlgListBox |
|
Definition at line 1342 of file ndk++.cc. References curr_item.
01343 { 01344 return curr_item; 01345 } |
|
Definition at line 1375 of file ndk++.cc. References cur_sel.
01376 { 01377 // if(is_multisel()) 01378 // throw NDKDlgException<NDKDlgListBox>(this,"Calling get_selected and is_multisel==true"); 01379 01380 return cur_sel; 01381 } |
|
Definition at line 1319 of file ndk++.cc. References data.
|
|
Definition at line 1300 of file ndk++.cc. References data.
|
|
Definition at line 1281 of file ndk++.cc. References data.
|
|
Definition at line 1385 of file ndk++.cc. References cur_sel, data, NDK_XX::IndexList, and NDK_XX::NDKDlgControl::is_multisel().
01386 { 01387 list.clear(); 01388 if(is_multisel()){ 01389 for(int i=0;i<data.size();i++){ 01390 if(data[i]->is_checked()) 01391 list.push_back(i); 01392 } 01393 } 01394 else 01395 list.push_back(cur_sel); 01396 01397 } |
|
Implements NDK_XX::NDKDlgControl. Definition at line 917 of file ndk++.h.
00921 : public NDKDlgListBox |
|
Put the label text at the left (0) in the specified row. Definition at line 1172 of file ndk++.cc. Referenced by show_text().
01172 {
01173 if (label) {
01174 OnError(addstr(row, 1, label, width()));
01175 }
01176 }
|
|
Definition at line 1252 of file ndk++.cc. References adjust_top_and_bottom(), curr_item, data, draw_scrollbar(), NDK_XX::NDKDlgControl::get_ctrl_id(), LI_POS_CHANGE, NDK_XX::NDKDlgControl::notify_enabled(), NDK_XX::NDKDlgControl::pParent, NDK_XX::NDKDlgControl::process_message(), and refresh(). Referenced by driver().
01253 { 01254 if(data.size() && curr_item < data.size()-1){ 01255 curr_item++; 01256 adjust_top_and_bottom(); 01257 draw_scrollbar(); 01258 refresh(); 01259 if(notify_enabled()){ 01260 process_message(pParent,LI_POS_CHANGE,get_ctrl_id(),0); 01261 } 01262 } 01263 } |
|
Definition at line 1268 of file ndk++.cc. Referenced by driver().
01269 { 01270 } |
|
Definition at line 1275 of file ndk++.cc. Referenced by driver().
01276 { 01277 } |
|
Definition at line 1236 of file ndk++.cc. References adjust_top_and_bottom(), curr_item, draw_scrollbar(), NDK_XX::NDKDlgControl::get_ctrl_id(), LI_POS_CHANGE, NDK_XX::NDKDlgControl::notify_enabled(), NDK_XX::NDKDlgControl::pParent, NDK_XX::NDKDlgControl::process_message(), and refresh(). Referenced by driver().
01237 { 01238 if(curr_item){ 01239 curr_item--; 01240 adjust_top_and_bottom(); 01241 draw_scrollbar(); 01242 refresh(); 01243 if(notify_enabled()){ 01244 process_message(pParent,LI_POS_CHANGE,get_ctrl_id(),0); 01245 } 01246 } 01247 } |
|
Definition at line 1435 of file ndk++.cc. References check_multisel(), curr_item, data, NDK_XX::NDKDlgControl::get_ctrl_id(), LI_SEL_CHANGE, NDK_XX::NDKDlgControl::notify_enabled(), NDK_XX::NDKDlgControl::pParent, NDK_XX::NDKDlgControl::process_message(), refresh(), and update_data().
01436 { 01437 update_data(curr_item); 01438 check_multisel(curr_item,data[curr_item]->is_checked()); 01439 refresh(); 01440 if(notify_enabled()) 01441 process_message(pParent,LI_SEL_CHANGE,get_ctrl_id(),0); 01442 } |
|
Here we will manage the virtualized list.
Definition at line 1052 of file ndk++.cc. References activate_item(), bottom_item, curr_item, deactivate_item(), and top_item. Referenced by activate(), add_item(), clear(), deactivate(), move_down(), move_up(), on_sel_change(), remove_item(), set_cur_pos(), set_cur_sel(), set_item(), and set_sel_items().
01053 { 01054 for( int idx=top_item;idx <= bottom_item; idx++){ 01055 if(idx!=curr_item) 01056 deactivate_item(idx); 01057 } 01058 activate_item(curr_item); 01059 } |
|
Definition at line 1064 of file ndk++.cc. References bottom_item, clear_items(), top_item, and update_item(). Referenced by adjust_top_and_bottom(), clear(), set_item(), and set_sel_items().
01065 { 01066 for( int idx=top_item;idx <= bottom_item; idx++){ 01067 update_item(idx); 01068 } 01069 clear_items(); 01070 01071 } |
|
Drop an item from the list.
Definition at line 1031 of file ndk++.cc. References adjust_top_and_bottom(), cur_sel, curr_item, data, draw_scrollbar(), NDK_XX::logfile(), refresh(), and show_empty().
01032 { 01033 if(pos>=0 && pos < data.size()){ 01034 data.erase(data.begin()+pos); 01035 if(pos<= curr_item && curr_item) 01036 curr_item--; 01037 if(cur_sel == pos) 01038 cur_sel = -1; 01039 01040 01041 logfile << "remove_item: cursel=" << cur_sel << endl; 01042 adjust_top_and_bottom(); 01043 draw_scrollbar(); 01044 show_empty(); 01045 refresh(); 01046 } 01047 }; |
|
Put the label text to the right (ending at maxx()) in the specified row. Definition at line 1181 of file ndk++.cc. Referenced by show_text().
01181 { 01182 if (label) { 01183 int x = maxx() - strlen(label)-1; 01184 if (x<0) 01185 x=0; 01186 OnError(addstr(row, x, label, width())); 01187 } 01188 } |
|
Definition at line 1349 of file ndk++.cc. References adjust_top_and_bottom(), curr_item, data, draw_scrollbar(), and refresh().
01350 { 01351 if(pos>-1 && pos < data.size()){ 01352 curr_item = pos; 01353 adjust_top_and_bottom(); 01354 draw_scrollbar(); 01355 refresh(); 01356 } 01357 } |
|
Definition at line 1361 of file ndk++.cc. References adjust_top_and_bottom(), check_multisel(), curr_item, data, draw_scrollbar(), refresh(), NDK_XX::NDKDlgListItem::set_check(), and visible_item().
01362 { 01363 if(pos>-1 && pos < data.size()){ 01364 curr_item = pos; 01365 adjust_top_and_bottom(); 01366 draw_scrollbar(); 01367 visible_item(pos)->set_check(true); 01368 check_multisel(pos, true); 01369 refresh(); 01370 } 01371 } |
|
Definition at line 1330 of file ndk++.cc. References data, refresh(), and refresh_items().
01331 { 01332 if(pos>-1 && pos < data.size()){ 01333 delete data[pos]; 01334 data[pos]=item; 01335 refresh_items(); 01336 refresh(); 01337 } 01338 } |
|
Definition at line 1311 of file ndk++.cc. References data.
|
|
Definition at line 1292 of file ndk++.cc. References data.
|
|
Definition at line 1401 of file ndk++.cc. References data, NDK_XX::IndexList, NDK_XX::NDKDlgControl::is_multisel(), refresh(), and refresh_items().
01402 { 01403 if(is_multisel()){ 01404 for(int i=0;i<list.size();i++){ 01405 data[list[i]]->set_check(t_or_f); 01406 } 01407 } 01408 refresh_items(); 01409 refresh(); 01410 } |
|
Usualy, a control in a dialog has some kind of text on it...
Implements NDK_XX::NDKDlgControl. Definition at line 918 of file ndk++.h. References NDK_XX::NDKDlgControl::framed, NDK_XX::NDKDlgCheckListBox::initialize_items(), NDK_XX::NDKDlgCheckListBox::NDKDlgCheckListBox(), NDKDlgListBox(), NDK_XX::NDKDlgControl::notify, and NDK_XX::NDKDlgControl::tabstop. Referenced by activate(), deactivate(), and NDKDlgListBox().
00921 : public NDKDlgListBox |
|
Definition at line 934 of file ndk++.cc. References cur_sel, data, and items. Referenced by clear(), NDK_XX::NDKDlgChoiceBox::initialize_items(), NDK_XX::NDKDlgCheckListBox::initialize_items(), NDK_XX::NDKDlgSelectionBox::initialize_items(), and remove_item().
|
|
Definition at line 1157 of file ndk++.cc. References lefttext(), and righttext().
|
|
Definition at line 1211 of file ndk++.cc. References data, and visible_item(). Referenced by deactivate_item(), and on_sel_change().
01212 { 01213 if(data.empty()||item_idx<0||item_idx >= data.size() ) 01214 return; 01215 NDKDlgListItem &itm= *(visible_item(item_idx)); 01216 NDKDlgListItemData &dat = *(data[item_idx]); 01217 dat = itm; 01218 01219 } |
|
Definition at line 1224 of file ndk++.cc. References data, and visible_item(). Referenced by activate_item(), check_multisel(), and refresh_items().
01225 { 01226 if(data.empty()||item_idx<0||item_idx >= data.size() ) 01227 return; 01228 NDKDlgListItem &itm= *(visible_item(item_idx)); 01229 NDKDlgListItemData &dat = *(data[item_idx]); 01230 itm = dat; 01231 } |
|
Definition at line 987 of file ndk++.h. References NDK_XX::NDKDialogBox::DLG_HIGH, NDK_XX::NDKDialogBox::REQ_DLG_EXIT, NDK_XX::NDKDialogBox::REQ_DLG_LEFT, and NDK_XX::NDKDialogBox::REQ_DLG_RIGHT. Referenced by activate_item(), deactivate_item(), driver(), set_cur_sel(), update_data(), and update_item().
00998 { |
|
Definition at line 893 of file ndk++.h. Referenced by NDK_XX::NDKDlgSelectionBox::initialize_items(). |
|
Definition at line 946 of file ndk++.h. Referenced by activate(), deactivate(), NDK_XX::NDKDlgRadioButton::show_state(), and NDK_XX::NDKDlgListItem::state_size(). |
|
Definition at line 954 of file ndk++.h. Referenced by adjust_top_and_bottom(), check_multisel(), clear(), NDK_XX::NDKDlgChoiceBox::initialize_items(), NDK_XX::NDKDlgCheckListBox::initialize_items(), NDK_XX::NDKDlgSelectionBox::initialize_items(), refresh(), refresh_items(), and NDK_XX::NDKDlgRadioButton::state_size(). |
|
Definition at line 955 of file ndk++.h. Referenced by check_multisel(), get_cur_sel(), get_sel_items(), remove_item(), show_empty(), and NDK_XX::NDKDlgRadioButton::state_size(). |
|
Definition at line 952 of file ndk++.h. Referenced by add_item(), adjust_top_and_bottom(), clear(), deactivate(), driver(), get_cur_pos(), NDK_XX::NDKDlgChoiceBox::initialize_items(), NDK_XX::NDKDlgCheckListBox::initialize_items(), NDK_XX::NDKDlgSelectionBox::initialize_items(), move_down(), move_up(), on_sel_change(), refresh(), remove_item(), set_cur_pos(), set_cur_sel(), and NDK_XX::NDKDlgRadioButton::show_state(). |
|
Definition at line 950 of file ndk++.h. Referenced by add_item(), adjust_top_and_bottom(), check_multisel(), clear(), clear_items(), delete_data(), draw_scrollbar(), driver(), get_item(), get_item_data(), get_item_text(), get_sel_items(), move_down(), on_sel_change(), remove_item(), set_cur_pos(), set_cur_sel(), set_item(), set_item_data(), set_item_text(), set_sel_items(), show_empty(), NDK_XX::NDKDlgRadioButton::show_state(), update_data(), and update_item(). |
|
Definition at line 949 of file ndk++.h. Referenced by adjust_top_and_bottom(), clear_items(), draw_scrollbar(), NDK_XX::NDKDlgChoiceBox::initialize_items(), NDK_XX::NDKDlgCheckListBox::initialize_items(), NDK_XX::NDKDlgSelectionBox::initialize_items(), show_empty(), NDK_XX::NDKDlgRadioButton::show_state(), NDK_XX::NDKDlgCheckButton::state_size(), and ~NDKDlgListBox(). |
|
Definition at line 947 of file ndk++.h. Referenced by NDK_XX::NDKDlgChoiceBox::initialize_items(), NDK_XX::NDKDlgCheckListBox::initialize_items(), NDK_XX::NDKDlgSelectionBox::initialize_items(), NDKDlgListBox(), and NDK_XX::NDKDlgRadioButton::show_state(). |
|
Definition at line 947 of file ndk++.h. Referenced by NDK_XX::NDKDlgChoiceBox::initialize_items(), NDK_XX::NDKDlgCheckListBox::initialize_items(), NDK_XX::NDKDlgSelectionBox::initialize_items(), NDKDlgListBox(), and NDK_XX::NDKDlgRadioButton::show_state(). |
|
Definition at line 953 of file ndk++.h. Referenced by adjust_top_and_bottom(), check_multisel(), clear(), clear_items(), draw_scrollbar(), NDK_XX::NDKDlgChoiceBox::initialize_items(), NDK_XX::NDKDlgCheckListBox::initialize_items(), NDK_XX::NDKDlgSelectionBox::initialize_items(), refresh(), refresh_items(), NDK_XX::NDKDlgRadioButton::show_state(), and NDK_XX::NDKDlgCheckButton::state_size(). |