#include <ndk++.h>
Inheritance diagram for NDK_XX::NDKDialogBox:
Public Types | |
enum | dlg_styles { info = 0x0100, warning = 0x0200, error = 0x0400, okCancel = 0x0001, yesNo = 0x0002, yesNoCancel = 0x0004 } |
enum | Dlg_Request { DLG_LOW = PAD_HIGH + 1, REQ_DLG_REFRESH = DLG_LOW, REQ_DLG_PROCESSED, REQ_DLG_NEXT, REQ_DLG_PREV, REQ_DLG_UP, REQ_DLG_DOWN, REQ_DLG_LEFT, REQ_DLG_RIGHT, REQ_DLG_EXIT, DLG_HIGH = REQ_DLG_EXIT } |
Public Methods | |
NDKDialogBox (int id, const string &title,int lines, int cols, int y=0, int x=0,int style=0) | |
~NDKDialogBox () | |
void | add_child (NDKDlgControl *new_child) |
string | get_text () const |
void | set_text (const string &v) |
Usualy, a control in a dialog has some kind of text on it... | |
int | do_modal () |
Static Public Attributes | |
NCursesPanel | dlg_stdscr |
Protected Methods | |
void | show_text (const string &t, char where) |
A simple helper. | |
void | next_control () |
When user press TAB, give me the next child. | |
DECLARE_BINDINGS () | |
virtual void | on_dlg_init () |
called at the beggining of the modal loop | |
virtual void | on_dlg_term () |
called at the end of the modal loop | |
virtual bool | can_close () |
called if user presses one of the 'exits' | |
virtual void | on_ctrl_init (NDKDlgControl &ctrl) |
called when the user enters a control | |
virtual void | on_ctrl_term (NDKDlgControl &ctrl) |
called when the user leaves the control | |
virtual void | on_cmd (int dlg_req) |
Kind of catch-all for derived windows. | |
virtual void | create_buttons () |
called on construction of dialog | |
void | add_ok () |
The next four are used by create_buttons. | |
void | add_ok_cancel () |
void | add_yes_no () |
void | add_yes_no_cancel () |
virtual void | set_focus_to (int child_idx) |
activate child at position child_idx | |
virtual void | set_focus_to (NDKDlgControl *p_child) |
activate p_child | |
int | driver (int key) |
virtual void | on_dlg_ok () |
Vanilla implementation of exits. | |
virtual void | on_dlg_yes () |
virtual void | on_dlg_no () |
virtual void | on_dlg_cancel () |
int | end_dialog (int request) |
virtual void | lefttext (int row, const char *label) |
virtual void | righttext (int row, const char *label) |
Static Protected Methods | |
int | X_POS (int pos) |
space between buttons | |
Protected Attributes | |
friend | NDKDlgControl |
Allow children to touch our stuff. | |
ListOfChildren | children |
The controls we have. | |
int | curr_child |
where is te focus now | |
string | _title |
int | dlg_style |
bool | bContinueModal |
Modal loop condition. | |
bool | changed |
So we can ask the user if she want to save. | |
NDKDlgPushButton * | pBtnYes |
NDKDlgPushButton * | pBtnNo |
NDKDlgPushButton * | pBtnCancel |
NDKDlgPushButton * | pBtnOk |
int | user_request |
this is the result of the interaction | |
Static Protected Attributes | |
int | my_w = 0 |
int | btn_w = 0 |
useable width | |
int | btns = 0 |
each button width | |
int | used_width = 0 |
number of buttons | |
int | spc = 0 |
total buttons width | |
string | lblOk = " OK " |
string | lblCancel = "Cancel" |
string | lblYes = " Yes " |
string | lblNo = " No " |
string | titDataChgd = "Data changed!" |
string | msgAskToSave = "Save before we exit?" |
|
Definition at line 1082 of file ndk++.h.
01089 {end_dialog(IDOK);} 01090 virtual void on_dlg_yes() {end_dialog(IDYES);} 01091 virtual void on_dlg_no() {end_dialog(IDNO);} 01092 virtual void on_dlg_cancel(){ 01093 if(can_close()) 01094 end_dialog(IDCANCEL); |
|
Definition at line 1073 of file ndk++.h.
01089 {end_dialog(IDOK);} |
|
Definition at line 1491 of file ndk++.cc. References _title, and show_text().
01493 : NDKDlgControl(id,lines,cols,y,x) 01494 ,_title(title) 01495 ,curr_child(0), 01496 dlg_style(style), 01497 changed(false), 01498 pBtnYes(0), 01499 pBtnNo(0), 01500 pBtnCancel(0), 01501 pBtnOk(0) 01502 { 01503 leaveok(FALSE); 01504 frame(); 01505 show_text(_title,'c'); 01506 } |
|
Definition at line 1516 of file ndk++.cc. References children, and NDK_XX::NDKDlgControl::hide().
|
|
Definition at line 1101 of file ndk++.h. References bContinueModal. Referenced by add_ok(), add_ok_cancel(), add_yes_no(), add_yes_no_cancel(), and TestBox::on_dlg_init().
01132 : public NDKDialogBox |
|
The next four are used by create_buttons.
Definition at line 1700 of file ndk++.cc. References add_child(), children, IDOK, lblOk, pBtnOk, and set_focus_to(). Referenced by create_buttons().
|
|
Definition at line 1710 of file ndk++.cc. References add_child(), btn_w, btns, NDK_XX::NDKDlgControl::enable(), IDCANCEL, IDOK, lblCancel, lblOk, my_w, pBtnCancel, pBtnOk, spc, used_width, and X_POS(). Referenced by create_buttons().
01711 { 01712 NDKDlgControl *pCtrl=0; 01713 my_w = width()-2; ///useable width 01714 btn_w= 9; ///each button width 01715 btns=2; ///number of buttons 01716 used_width=btn_w*btns; ///total buttons width 01717 spc=2; ///space between buttons 01718 pBtnOk=new NDKDlgPushButton(this,IDOK,lblOk,maxy()-1,X_POS(0)); 01719 add_child(pBtnOk); 01720 pBtnOk->enable(false); 01721 pBtnCancel=new NDKDlgPushButton(this,IDCANCEL,lblCancel,maxy()-1,X_POS(1)); 01722 add_child(pBtnCancel); 01723 } |
|
Definition at line 1744 of file ndk++.cc. References add_child(), btn_w, btns, IDNO, IDYES, lblNo, lblYes, my_w, pBtnNo, pBtnYes, spc, used_width, and X_POS(). Referenced by create_buttons().
01745 { 01746 NDKDlgControl *pCtrl=0; 01747 my_w = width()-2; ///useable width 01748 btn_w= 9; ///each button width 01749 btns=2; ///number of buttons 01750 used_width=btn_w*btns; ///total buttons width 01751 spc=2; ///space between buttons 01752 pBtnYes=new NDKDlgPushButton(this,IDYES,lblYes,maxy()-1,X_POS(0)); 01753 add_child(pBtnYes); 01754 pBtnNo=new NDKDlgPushButton(this,IDNO,lblNo,maxy()-1,X_POS(1)); 01755 add_child(pBtnNo); 01756 } |
|
Definition at line 1727 of file ndk++.cc. References add_child(), btn_w, btns, IDCANCEL, IDNO, IDYES, lblCancel, lblNo, lblYes, my_w, pBtnCancel, pBtnNo, pBtnYes, spc, used_width, and X_POS(). Referenced by create_buttons().
01728 { 01729 my_w = width()-2; ///useable width 01730 btn_w= 9; ///each button width 01731 btns=3; ///number of buttons 01732 used_width=btn_w*btns; ///total buttons width 01733 spc=2; ///space between buttons 01734 pBtnYes=new NDKDlgPushButton(this,IDYES,lblYes,maxy()-1,X_POS(0)); 01735 add_child(pBtnYes); 01736 pBtnNo=new NDKDlgPushButton(this,IDNO,lblNo,maxy()-1,X_POS(1)); 01737 add_child(pBtnNo); 01738 pBtnCancel=new NDKDlgPushButton(this,IDCANCEL,lblCancel,maxy()-1,X_POS(2)); 01739 add_child(pBtnCancel); 01740 } |
|
called if user presses one of the 'exits'
Definition at line 1638 of file ndk++.cc. References do_modal(), IDCANCEL, IDNO, IDYES, msgAskToSave, and titDataChgd.
01639 { 01640 int result = true; 01641 if(changed){ 01642 YesNoCancelBox dlg(titDataChgd,msgAskToSave); 01643 int usr_choice = dlg.do_modal(); 01644 switch(usr_choice){ 01645 case IDCANCEL: result = false; 01646 case IDYES: 01647 case IDNO: 01648 default: 01649 break; 01650 } 01651 } 01652 refresh(); 01653 return result; 01654 } |
|
called on construction of dialog
Definition at line 1689 of file ndk++.cc. References add_ok(), add_ok_cancel(), add_yes_no(), add_yes_no_cancel(), dlg_style, okCancel, yesNo, and yesNoCancel. Referenced by TestBox::on_dlg_init(), and NDK_XX::NDKMessageBox::on_dlg_init().
01690 { 01691 switch((dlg_style & 0x00ff)){ 01692 case okCancel: add_ok_cancel(); break; 01693 case yesNo: add_yes_no(); break; 01694 case yesNoCancel:add_yes_no_cancel(); break; 01695 default: add_ok(); break; 01696 } 01697 } |
|
Reimplemented in TestBox. |
|
Definition at line 1527 of file ndk++.cc. References bContinueModal, driver(), next_control(), on_cmd(), on_dlg_cancel(), on_dlg_init(), REQ_DLG_EXIT, REQ_DLG_NEXT, and user_request. Referenced by ShowTestDialogCmd::action(), and can_close().
01528 { 01529 on_dlg_init(); 01530 bContinueModal=true; 01531 int req=REQ_DLG_EXIT; 01532 do{ 01533 req=driver(getch()); 01534 switch(req){ 01535 case REQ_DLG_EXIT: on_dlg_cancel();break; 01536 case REQ_DLG_NEXT: next_control(); break; 01537 01538 default: on_cmd(req); break; 01539 } 01540 } while( bContinueModal); 01541 01542 return user_request; 01543 } |
|
get a chance at processing the key, before parent does Reimplemented from NDK_XX::NDKDlgControl. Definition at line 1561 of file ndk++.cc. References children, CTRL, curr_child, IDCANCEL, KEY_ESC, KEY_TAB, REQ_DLG_DOWN, REQ_DLG_EXIT, REQ_DLG_LEFT, REQ_DLG_NEXT, REQ_DLG_PROCESSED, REQ_DLG_RIGHT, REQ_DLG_UP, and user_request. Referenced by do_modal().
01562 { 01563 if(children[curr_child]->driver(key)==TRUE) 01564 return REQ_DLG_PROCESSED; 01565 switch(key) { 01566 case KEY_UP: return REQ_DLG_UP; 01567 case KEY_DOWN: return REQ_DLG_DOWN; 01568 case KEY_LEFT: return REQ_DLG_LEFT; 01569 case KEY_RIGHT: return REQ_DLG_RIGHT; 01570 case KEY_EXIT: 01571 case CTRL('X'): 01572 case KEY_ESC: 01573 ///same as if user press Cancel button 01574 user_request=IDCANCEL; 01575 return REQ_DLG_EXIT; 01576 case KEY_TAB: return REQ_DLG_NEXT; 01577 default: return(key); 01578 } 01579 } |
|
Break the modal loop and give the user a chance to cleanup/serialize/whatever Definition at line 1202 of file ndk++.h. References NDK_XX::NDKDlgLabel::text, and NDK_XX::NDKDlgControl::visible.
01202 : NDKDlgLabel(1000,text 01203 ,lines, cols, y, x, visible) 01204 { 01205 } 01206 }; |
|
Implements NDK_XX::NDKDlgControl. Definition at line 1105 of file ndk++.h.
01132 : public NDKDialogBox |
|
Put the label text at the left (0) in the specified row. Definition at line 1658 of file ndk++.cc. Referenced by show_text().
01658 {
01659 if (label) {
01660 OnError(addstr(row, 0, label, width()));
01661 }
01662 }
|
|
When user press TAB, give me the next child.
Definition at line 1583 of file ndk++.cc. References children, curr_child, on_ctrl_init(), and on_ctrl_term(). Referenced by do_modal().
01584 { 01585 int start_point=curr_child; 01586 if(children.size()>1){ 01587 for(;;){ 01588 if(++curr_child==children.size()) 01589 curr_child=0; 01590 if(curr_child==start_point) 01591 return;// We're back to the start_point. 01592 if(children[curr_child]->is_enabled()) 01593 break; //We found the next selectable child 01594 } 01595 on_ctrl_term(*(children[start_point])); 01596 on_ctrl_init(*(children[curr_child])); 01597 } 01598 } |
|
Kind of catch-all for derived windows.
Definition at line 1171 of file ndk++.h. Referenced by do_modal().
01172 :NDKMessageBox(title,message,style|yesNo) |
|
called when the user enters a control
Definition at line 1161 of file ndk++.h. Referenced by next_control(), and set_focus_to().
01168 : public NDKMessageBox
|
|
called when the user leaves the control
Definition at line 1166 of file ndk++.h. Referenced by next_control(), and set_focus_to().
01168 : public NDKMessageBox
|
|
Definition at line 1195 of file ndk++.h. References NDK_XX::NDKStatusBar::NDKStatusBar(), and NDK_XX::NDKDlgLabel::text. Referenced by do_modal().
01195 :-) * 01196 ************************************************************************/ 01197 class NDKStatusBar : public NDKDlgLabel 01198 { |
|
called at the beggining of the modal loop
Reimplemented in NDK_XX::NDKMessageBox, and TestBox. Definition at line 1152 of file ndk++.h. Referenced by do_modal().
01153 : public NDKMessageBox
|
|
Definition at line 1194 of file ndk++.h.
01195 :-) * |
|
Vanilla implementation of exits.
Definition at line 1192 of file ndk++.h.
01195 :-) * |
|
called at the end of the modal loop
Definition at line 1155 of file ndk++.h. References info, and okCancel.
01155 : NDKOkCancelBox(const string &title,const string &message,int style=info) |
|
Definition at line 1193 of file ndk++.h.
01195 :-) * |
|
Put the label text to the right (ending at maxx()) in the specified row. Definition at line 1666 of file ndk++.cc. Referenced by show_text().
01666 { 01667 if (label) { 01668 int x = maxx() - strlen(label); 01669 if (x<0) 01670 x=0; 01671 OnError(addstr(row, x, label, width())); 01672 } 01673 } |
|
activate p_child
Definition at line 1611 of file ndk++.cc. References children, and set_focus_to().
01612 { 01613 for(int i=0;i<children.size();i++){ 01614 if(children[i] == p_child){ 01615 set_focus_to(i); 01616 break; 01617 } 01618 } 01619 } |
|
activate child at position child_idx
Definition at line 1602 of file ndk++.cc. References children, curr_child, on_ctrl_init(), and on_ctrl_term(). Referenced by add_ok(), TestBox::on_clear_list(), TestBox::on_dlg_init(), NDK_XX::NDKMessageBox::on_dlg_init(), TestBox::on_remove(), TestBox::on_sel_change(), and set_focus_to().
01603 { 01604 on_ctrl_term(*(children[curr_child])); 01605 curr_child = child_idx; 01606 on_ctrl_init(*(children[curr_child])); 01607 } |
|
Usualy, a control in a dialog has some kind of text on it...
Implements NDK_XX::NDKDlgControl. Definition at line 1106 of file ndk++.h. References my_w.
01132 : public NDKDialogBox |
|
A simple helper.
Definition at line 1547 of file ndk++.cc. References lefttext(), and righttext(). Referenced by NDKDialogBox().
|
|
space between buttons
Definition at line 1682 of file ndk++.cc. References btn_w, btns, my_w, spc, and used_width. Referenced by add_ok_cancel(), add_yes_no(), and add_yes_no_cancel().
01683 { 01684 return (((my_w-used_width)/btns)+((btn_w+spc)*pos)); 01685 } |
|
Definition at line 1124 of file ndk++.h. Referenced by NDKDialogBox(). |
|
Modal loop condition.
|
|
useable width
Definition at line 1678 of file ndk++.cc. Referenced by add_ok_cancel(), add_yes_no(), add_yes_no_cancel(), and X_POS(). |
|
each button width
Definition at line 1679 of file ndk++.cc. Referenced by add_ok_cancel(), add_yes_no(), add_yes_no_cancel(), and X_POS(). |
|
So we can ask the user if she want to save.
Definition at line 1132 of file ndk++.h. Referenced by NDK_XX::NDKDlgCheckListBox::NDKDlgCheckListBox(), and TestBox::on_sel_change(). |
|
The controls we have.
Definition at line 1119 of file ndk++.h. Referenced by add_ok(), driver(), next_control(), set_focus_to(), and ~NDKDialogBox(). |
|
where is te focus now
Definition at line 1122 of file ndk++.h. Referenced by driver(), next_control(), TestBox::on_clear_list(), TestBox::on_dlg_init(), TestBox::on_remove(), TestBox::on_sel_change(), and set_focus_to(). |
|
|
|
Definition at line 1126 of file ndk++.h. Referenced by create_buttons(). |
|
Definition at line 44 of file ndk++.cc. Referenced by add_ok_cancel(), and add_yes_no_cancel(). |
|
Definition at line 46 of file ndk++.cc. Referenced by add_yes_no(), and add_yes_no_cancel(). |
|
Definition at line 43 of file ndk++.cc. Referenced by add_ok(), and add_ok_cancel(). |
|
Definition at line 45 of file ndk++.cc. Referenced by add_yes_no(), and add_yes_no_cancel(). |
|
Definition at line 48 of file ndk++.cc. Referenced by can_close(). |
|
Definition at line 1677 of file ndk++.cc. Referenced by add_ok_cancel(), add_yes_no(), add_yes_no_cancel(), set_text(), and X_POS(). |
|
Allow children to touch our stuff.
|
|
Definition at line 1136 of file ndk++.h. Referenced by add_ok_cancel(), add_yes_no_cancel(), NDK_XX::NDKDlgCheckListBox::NDKDlgCheckListBox(), and NDK_XX::NDKMessageBox::on_dlg_init(). |
|
Definition at line 1135 of file ndk++.h. Referenced by add_yes_no(), add_yes_no_cancel(), and NDK_XX::NDKDlgCheckListBox::NDKDlgCheckListBox(). |
|
Definition at line 1137 of file ndk++.h. Referenced by add_ok(), add_ok_cancel(), NDK_XX::NDKDlgCheckListBox::NDKDlgCheckListBox(), TestBox::on_remove(), and TestBox::on_sel_change(). |
|
Definition at line 1134 of file ndk++.h. Referenced by add_yes_no(), add_yes_no_cancel(), and NDK_XX::NDKDlgCheckListBox::NDKDlgCheckListBox(). |
|
total buttons width
Definition at line 1681 of file ndk++.cc. Referenced by add_ok_cancel(), add_yes_no(), add_yes_no_cancel(), and X_POS(). |
|
Definition at line 47 of file ndk++.cc. Referenced by can_close(). |
|
number of buttons
Definition at line 1680 of file ndk++.cc. Referenced by add_ok_cancel(), add_yes_no(), add_yes_no_cancel(), and X_POS(). |
|
this is the result of the interaction
Definition at line 1140 of file ndk++.h. Referenced by do_modal(), driver(), and NDK_XX::NDKDlgCheckListBox::NDKDlgCheckListBox(). |