1 #ifndef __KONST_UI_DLG_H__ 2 #define __KONST_UI_DLG_H__ 3 4 #include <list> 5 #include <algorithm> 6 #include <unistd.h> 7 8 #include "conf.h" 9 #include "textwindow.h" 10 #include "cmenus.h" 11 #include "treeview.h" 12 #include "horizontalbar.h" 13 #include "textbrowser.h" 14 15 __KTOOL_BEGIN_NAMESPACE 16 17 class dialogbox { 18 protected: 19 static dialogbox *it; 20 21 class keybarassociation { 22 public: 23 int key, baritem; 24 keybarassociation(int nkey, int nbarit); 25 26 bool operator == (const int akey); 27 bool operator != (const int akey); 28 }; 29 30 bool freemenu, freetree, freewindow, freebar, freebrowser, first; 31 32 verticalmenu *menu; 33 treeview *tree; 34 textwindow *window; 35 horizontalbar *bar; 36 textbrowser *browser; 37 38 list<keybarassociation> kba; 39 40 static void menuidle(verticalmenu &caller); 41 static void browseridle(textbrowser &caller); 42 static int menukeys(verticalmenu &caller, int k); 43 static int browserkeys(textbrowser &caller, int k); 44 45 public: 46 int (*otherkeys)(dialogbox &caller, int k); 47 // function called on pressing of non-standard menu keys 48 // should return a number of selected menu item or -1 to 49 // continue browsing 50 51 void (*idle)(dialogbox &caller); 52 53 dialogbox(); 54 ~dialogbox(); 55 56 void setwindow(textwindow *neww, bool fw = true); 57 void setbar(horizontalbar *newb, bool fb = true); 58 void setmenu(verticalmenu *newm, bool fm = true); 59 void settree(treeview *newt, bool ft = true); 60 void setbrowser(textbrowser *newbr, bool fbr = true); 61 62 verticalmenu *getmenu(); 63 treeview *gettree(); 64 textwindow *getwindow(); 65 horizontalbar *getbar(); 66 textbrowser *getbrowser(); 67 68 void redraw(); 69 bool open(int &menuitem, int &baritem, void **ref = 0); 70 bool open(int &menuitem); 71 bool open(); 72 void close(); 73 74 void clearkeys(); 75 void addkey(int key, int baritem); 76 void addautokeys(); 77 }; 78 79 __KTOOL_END_NAMESPACE 80 81 #ifdef __KTOOL_USE_NAMESPACES 82 83 using ktool::dialogbox; 84 85 #endif 86 87 #endif 88