#include <ndk_demo.h>
Inheritance diagram for TestBox:
Public Methods | |
TestBox (const string &title, int lines, int cols, int y, int x) | |
Protected Methods | |
void | on_dlg_init () |
void | on_clear_list () |
Called when the "Clear" button is pushed. | |
void | on_remove () |
void | on_arrow () |
void | on_select () |
DECLARE_BINDINGS () | |
void | on_sel_change (int id) |
void | refresh_choices () |
Protected Attributes | |
Edit * | pEdit |
EditDate * | pEditDate |
EditDouble * | pEditNum |
SelectionBox * | pSel |
ChoiceBox * | pChoice |
CheckListBox * | pCheckList |
CheckListBox * | pCheckList2 |
|
Definition at line 68 of file ndk_demo.cc.
00070 : DialogBox(1,title,lines,cols,y,x,okCancel,Control::title|Control::framed) 00071 ,pEdit(0) 00072 ,pSel(0) 00073 ,pChoice(0) 00074 ,pCheckList(0) 00075 ,pCheckList2(0) 00076 { 00077 } |
|
Reimplemented from NDK_XX::DialogBox. |
|
Definition at line 170 of file ndk_demo.cc. References pEditDate.
|
|
Called when the "Clear" button is pushed.
Definition at line 161 of file ndk_demo.cc. References NDK_XX::DialogBox::curr_child, pSel, and NDK_XX::DialogBox::set_focus_to().
00162 { 00163 long curr = curr_child; 00164 pSel->clear(); 00165 set_focus_to(curr); 00166 } |
|
we override this to add adornments to the window Reimplemented from NDK_XX::DialogBox. Definition at line 81 of file ndk_demo.cc. References NDK_XX::DialogBox::add_child(), NDK_XX::DialogBox::create_buttons(), NDK_XX::DialogBox::curr_child, NDK_XX::Control::editable, NDK_XX::Control::framed, NDK_XX::Control::get_param(), ID_ARROW, ID_CHOICE, ID_CLEAR, ID_EDIT, ID_EDIT_DATE, ID_EDIT_NUM, ID_MULTICHECK, ID_REMOVE, ID_SELECT, ID_SELECTION, ID_SINGLE_CHECK, NDK_XX::IndexList, NDK_XX::Control::notify, pCheckList, pCheckList2, pChoice, pEdit, pEditDate, pEditNum, pSel, refresh_choices(), NDK_XX::DialogBox::set_focus_to(), and NDK_XX::Control::tabstop.
00082 { 00083 // set_style(title); 00084 // DialogBox::on_dlg_init(); 00085 00086 string s1("Name:"); 00087 add_child(new Label(this,-1,s1,1,s1.length(),2,1)); 00088 00089 pEdit=new Edit(this,ID_EDIT,"",3,40,1,9); 00090 add_child(pEdit); 00091 00092 00093 s1= "Date:"; 00094 add_child(new Label(this,-1,s1,1,s1.length(),6,1)); 00095 00096 pEditDate=new EditDate(this,ID_EDIT_DATE,"dd/mm/yyyy",5,10,editable|tabstop|notify|framed); 00097 // pEditDate->use_arrow_as_tab(); 00098 add_child(pEditDate); 00099 // pEditDate->set_max_len(5); 00100 00101 s1= "Age:"; 00102 add_child(new Label(this,-1,s1,1,s1.length(),6,27)); 00103 pEditNum=new EditDouble(this,ID_EDIT_NUM,"",3,12,5,35); 00104 add_child(pEditNum); 00105 pEditNum->use_arrow_as_tab(); 00106 pEditNum->set_max_len(9); 00107 00108 int first = curr_child; 00109 00110 add_child(new PushButton(this,ID_CLEAR,"Clear List",8,1)); 00111 add_child(new PushButton(this,ID_REMOVE,"Remove",8,15)); 00112 add_child(pEdit, new PushButton(this,ID_ARROW,"Arrow as tab",8,25)); 00113 add_child(new PushButton(this,ID_SELECT,"Search pattern",8,40)); 00114 00115 pSel = new SelectionBox(this,ID_SELECTION,"",6,10,9,1); 00116 pSel->set_vscrollbar(); 00117 pSel->add_item(get_param("selection","1","First"),-1,false,false); 00118 pSel->add_item(get_param("selection","2","Second"),-1,false,false); 00119 pSel->add_item(get_param("selection","3","Third"),-1,false,false); 00120 pSel->add_item(get_param("selection","4","Fourth"),-1,false,false); 00121 pSel->add_item(get_param("selection","5","Fifth"),-1,false,false); 00122 pSel->add_item(get_param("selection","6","Sixth"),-1,false,false); 00123 pSel->add_item(get_param("selection","7","Seventh"),-1,false,false); 00124 pSel->add_item(get_param("selection","8","Eighth"),-1,false,false); 00125 pSel->add_item(get_param("selection","9","Nineth"),-1,false,false); 00126 add_child(pSel); 00127 00128 pChoice = new ChoiceBox(this,ID_CHOICE,"",6,10,9,12); 00129 pChoice->add_item("First"); 00130 pChoice->add_item("Last"); 00131 pChoice->add_item("Middle"); 00132 add_child(pChoice); 00133 refresh_choices(); 00134 00135 // pChoice->set_cur_sel(get_param("default","4",0)); 00136 00137 pCheckList = new CheckListBox(this,ID_SINGLE_CHECK,"",6,10,9,23); 00138 // pCheckList->add_item("Check 1"); 00139 // pCheckList->add_item("Check 2"); 00140 // pCheckList->add_item("Check 3"); 00141 add_child(pCheckList); 00142 00143 pCheckList2 = new CheckListBox(this,ID_MULTICHECK,"",6,10,9,34); 00144 pCheckList2->add_item("Checkme"); 00145 pCheckList2->add_item("Me too"); 00146 pCheckList2->add_item("lemmein"); 00147 pCheckList2->set_multisel(); 00148 00149 IndexList il; 00150 il.push_back(1); 00151 il.push_back(2); 00152 pCheckList2->set_sel_items(il); 00153 add_child(pCheckList2); 00154 00155 create_buttons(); 00156 set_focus_to(pEdit); 00157 } |
|
Called when the "Remove" button is pushed. we will remove the item pointed out by the second list box, the one with First, Last and Middle radio buttons Definition at line 184 of file ndk_demo.cc. References NDK_XX::DialogBox::curr_child, NDK_XX::DialogBox::pBtnOk, pChoice, pSel, refresh_choices(), and NDK_XX::DialogBox::set_focus_to().
00185 { 00186 long curr = curr_child; 00187 int choice_idx =pChoice->get_cur_sel(); 00188 if(choice_idx == -1) 00189 return; 00190 int sel_idx = (int)pChoice->get_item_data(choice_idx); 00191 pSel->remove_item(sel_idx); 00192 refresh_choices(); 00193 set_focus_to(curr); 00194 if(pBtnOk) 00195 pBtnOk->enable(); 00196 } |
|
Called whenever the pChoice listbox selection changes. It is binded to the LI_SEL_CHANGE event via the BINDING... macros Definition at line 211 of file ndk_demo.cc. References NDK_XX::DialogBox::changed, NDK_XX::DialogBox::curr_child, NDK_XX::DialogBox::pBtnOk, pChoice, pEdit, pSel, and NDK_XX::DialogBox::set_focus_to().
00212 { 00213 int curr = curr_child; 00214 changed=true; 00215 if(pBtnOk) 00216 pBtnOk->enable(); 00217 if(id == pChoice->get_ctrl_id()){ 00218 int choice_idx =pChoice->get_cur_sel(); 00219 int sel_idx = (int)pChoice->get_item_data(choice_idx); 00220 if(choice_idx < 0) 00221 return; 00222 pSel->set_cur_sel(sel_idx); 00223 pEdit->set_text(pSel->get_item_text(sel_idx)); 00224 } 00225 set_focus_to(curr); 00226 } |
|
Definition at line 177 of file ndk_demo.cc.
|
|
If we remove something we must update the items pointed to by the pChoice items Definition at line 200 of file ndk_demo.cc. Referenced by on_dlg_init(), and on_remove().
|
|
Definition at line 72 of file ndk_demo.h. Referenced by on_dlg_init(). |
|
Definition at line 73 of file ndk_demo.h. Referenced by on_dlg_init(). |
|
Definition at line 71 of file ndk_demo.h. Referenced by on_dlg_init(), on_remove(), on_sel_change(), and refresh_choices(). |
|
Definition at line 67 of file ndk_demo.h. Referenced by on_dlg_init(), on_sel_change(), and on_select(). |
|
Definition at line 68 of file ndk_demo.h. Referenced by on_arrow(), and on_dlg_init(). |
|
Definition at line 69 of file ndk_demo.h. Referenced by on_dlg_init(). |
|
Definition at line 70 of file ndk_demo.h. Referenced by on_clear_list(), on_dlg_init(), on_remove(), on_sel_change(), on_select(), and refresh_choices(). |