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

TestBox Class Reference

#include <ndk_demo.h>

Inheritance diagram for TestBox:

NDK_XX::NDKDialogBox NDK_XX::NDKDlgControl List of all members.

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 ()
 DECLARE_BINDINGS ()
void on_sel_change (int id)
void refresh_choices ()

Protected Attributes

NDKDlgEdit * pEdit
NDKDlgSelectionBox * pSel
NDKDlgChoiceBox * pChoice
NDKDlgCheckListBox * pCheckList
NDKDlgCheckListBox * pCheckList2

Constructor & Destructor Documentation

TestBox::TestBox const string &    title,
int    lines,
int    cols,
int    y,
int    x
 

Definition at line 62 of file ndk_demo.cc.

00064     : NDKDialogBox(1,title,lines,cols,y,x,okCancel)
00065         ,pEdit(0)
00066         ,pSel(0)
00067         ,pChoice(0)
00068         ,pCheckList(0)
00069         ,pCheckList2(0)
00070 {
00071 }


Member Function Documentation

TestBox::DECLARE_BINDINGS   [protected]
 

Reimplemented from NDK_XX::NDKDialogBox.

void TestBox::on_clear_list   [protected]
 

Called when the "Clear" button is pushed.

Definition at line 135 of file ndk_demo.cc.

References NDK_XX::NDKDialogBox::curr_child, pSel, and NDK_XX::NDKDialogBox::set_focus_to().

00136 {
00137     long curr = curr_child;
00138     pSel->clear();
00139     set_focus_to(curr);
00140 }

void TestBox::on_dlg_init   [protected, virtual]
 

we override this to add adornments to the window

Reimplemented from NDK_XX::NDKDialogBox.

Definition at line 75 of file ndk_demo.cc.

References NDK_XX::NDKDialogBox::add_child(), NDK_XX::NDKDialogBox::create_buttons(), NDK_XX::NDKDialogBox::curr_child, NDK_XX::NDKDlgControl::get_param(), ID_CHOICE, ID_CLEAR, ID_EDIT, ID_MULTICHECK, ID_REMOVE, ID_SELECTION, ID_SINGLE_CHECK, NDK_XX::IndexList, pCheckList, pCheckList2, pChoice, pEdit, pSel, refresh_choices(), and NDK_XX::NDKDialogBox::set_focus_to().

00076 {
00077     string s1("Name:");
00078     add_child(new NDKDlgLabel(this,-1,s1,1,s1.length(),1,1));
00079 
00080     pEdit=new NDKDlgEdit(this,ID_EDIT,"",3,40,2,1);
00081     add_child(pEdit);
00082 //  pCtrl->set_overwrite();
00083     
00084     int first = curr_child;
00085     
00086     add_child(new NDKDlgPushButton(this,ID_CLEAR,"Clear List",6,1));
00087     add_child(new NDKDlgPushButton(this,ID_REMOVE,"Remove",6,15));
00088 
00089     pSel = new NDKDlgSelectionBox(this,ID_SELECTION,"",6,10,8,1);
00090     pSel->set_vscrollbar();
00091     pSel->add_item(get_param("selection","1","First"));
00092     pSel->add_item(get_param("selection","2","Second"));
00093     pSel->add_item(get_param("selection","3","Third"));
00094     pSel->add_item(get_param("selection","4","Fourth"));
00095     pSel->add_item(get_param("selection","5","Fifth"));
00096     pSel->add_item(get_param("selection","6","Sixth"));
00097     pSel->add_item(get_param("selection","7","Seventh"));
00098     pSel->add_item(get_param("selection","8","Eighth"));
00099     pSel->add_item(get_param("selection","9","Nineth"));
00100     add_child(pSel);
00101     
00102     pChoice = new NDKDlgChoiceBox(this,ID_CHOICE,"",6,10,8,12);
00103     pChoice->add_item("First");
00104     pChoice->add_item("Last");
00105     pChoice->add_item("Middle");
00106     add_child(pChoice);
00107     refresh_choices();
00108 
00109     pChoice->set_cur_sel(get_param("default","4",0));
00110     
00111     pCheckList = new NDKDlgCheckListBox(this,ID_SINGLE_CHECK,"",6,10,8,23);
00112 //  pCheckList->add_item("Check 1");
00113 //  pCheckList->add_item("Check 2");
00114 //  pCheckList->add_item("Check 3");
00115     add_child(pCheckList);
00116     
00117     pCheckList2 = new NDKDlgCheckListBox(this,ID_MULTICHECK,"",6,10,8,34);
00118     pCheckList2->add_item("Checkme");
00119     pCheckList2->add_item("Me too");
00120     pCheckList2->add_item("lemmein");
00121     pCheckList2->set_multisel();
00122     
00123     IndexList il;
00124     il.push_back(1);
00125     il.push_back(2);
00126     pCheckList2->set_sel_items(il);
00127     add_child(pCheckList2);
00128 
00129     create_buttons(); 
00130     set_focus_to(pEdit);
00131 }

void TestBox::on_remove   [protected]
 

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 144 of file ndk_demo.cc.

References NDK_XX::NDKDialogBox::curr_child, NDK_XX::NDKDialogBox::pBtnOk, pChoice, pSel, refresh_choices(), and NDK_XX::NDKDialogBox::set_focus_to().

00145 {
00146     long curr = curr_child;
00147     int choice_idx =pChoice->get_cur_sel();
00148     if(choice_idx == -1)
00149         return;
00150     int sel_idx = (int)pChoice->get_item_data(choice_idx);
00151     pSel->remove_item(sel_idx);
00152     refresh_choices();
00153     set_focus_to(curr);
00154     if(pBtnOk)
00155         pBtnOk->enable(); 
00156 }

void TestBox::on_sel_change int    id [protected]
 

Called whenever the pChoice listbox selection changes. It is binded to the LI_SEL_CHANGE event via the BINDING... macros

Definition at line 171 of file ndk_demo.cc.

References NDK_XX::NDKDialogBox::changed, NDK_XX::NDKDialogBox::curr_child, NDK_XX::NDKDialogBox::pBtnOk, pChoice, pEdit, pSel, and NDK_XX::NDKDialogBox::set_focus_to().

00172 {
00173     int curr = curr_child;
00174     changed=true;
00175     if(pBtnOk)
00176         pBtnOk->enable();
00177     if(id == pChoice->get_ctrl_id()){
00178         int choice_idx =pChoice->get_cur_sel();
00179         int sel_idx = (int)pChoice->get_item_data(choice_idx);
00180         if(choice_idx < 0)
00181             return; 
00182         pSel->set_cur_sel(sel_idx);     
00183         pEdit->set_text(pSel->get_item_text(sel_idx));
00184     }
00185     set_focus_to(curr);
00186 }

void TestBox::refresh_choices   [protected]
 

If we remove something we must update the items pointed to by the pChoice items

Definition at line 160 of file ndk_demo.cc.

References pChoice, and pSel.

Referenced by on_dlg_init(), and on_remove().

00161 {
00162     pChoice->set_item_data(0,0);
00163     pChoice->set_item_data(1,(void *)(pSel->get_count()-1));
00164     int pos =(pSel->get_count()/2)-1;
00165     if(pos < 0) pos=0;
00166     pChoice->set_item_data(2,(void *)(pos));
00167 }


Member Data Documentation

NDKDlgCheckListBox* TestBox::pCheckList [protected]
 

Definition at line 66 of file ndk_demo.h.

Referenced by on_dlg_init().

NDKDlgCheckListBox* TestBox::pCheckList2 [protected]
 

Definition at line 67 of file ndk_demo.h.

Referenced by on_dlg_init().

NDKDlgChoiceBox* TestBox::pChoice [protected]
 

Definition at line 65 of file ndk_demo.h.

Referenced by on_dlg_init(), on_remove(), on_sel_change(), and refresh_choices().

NDKDlgEdit* TestBox::pEdit [protected]
 

Definition at line 63 of file ndk_demo.h.

Referenced by on_dlg_init(), and on_sel_change().

NDKDlgSelectionBox* TestBox::pSel [protected]
 

Definition at line 64 of file ndk_demo.h.

Referenced by on_clear_list(), on_dlg_init(), on_remove(), on_sel_change(), and refresh_choices().


The documentation for this class was generated from the following files:
Generated on Tue Aug 27 10:49:45 2002 by doxygen1.2.17