6 #include <cc++/thread.h>
11 /*! Abstract User Interface class. Needed to hide particular interface
12 * implementation (for ex. tty/curses/fltk/forms/qt/etc.)
15 class F_UI : public ost::Thread {
17 static std::vector <F_UI *> ui_list_;
19 unsigned char ui_priority_; //!< the higher value mean more prefereable ui
22 static F_UI* find_ui(ui_class_t ui_class);
23 static void (*idle_)(void); //!< ÕËÁÚÁÔÅÌØ ÎÁ idle-ÆÕÎËÃÉÀ
25 virtual void run() = 0;
26 virtual bool probe() { return false; }
27 virtual void initial() { init(); }
28 static int ui_count () { return F_UI::ui_list_.size(); }
29 static F_UI *make_ui();
33 ost::Semaphore ui_started_;
35 static void default_idle(void) { ost::Thread::sleep(10); }
39 void idle(void (*cb)()) { idle_ = cb; }
40 static void idle() { idle_(); }
42 void wait_for_started() { ui_started_.wait(); }
44 F_UI(ui_class_t ui_class, unsigned char ui_priority = 0) {
46 ui_priority_ = ui_priority;
47 ui_list_.push_back(this);
51 // setCancel(cancelImmediate);
57 // delete us from ui_list_
62 // called in sigint/sigquit signal handler
63 virtual bool exit_confirm(bool from_sighandler) {
65 log("ui", "Ctrl-C is pressed, bye ...");
68 virtual void sigcont() { log("ui", "Continuing app"); }
69 virtual void sigstop() { log("ui", "App is stopped"); }
70 // ×ÒÏÄÅ ÜÔÏ ÉÍÅÅÔ ÏÔÎÏÛÅÎÉÅ Ë ÄÉÓÐÌÅÀ
71 virtual void sigwinch() { exit_on_unimplemented("SIGWINCH"); }
72 virtual void sigsegv() { log("ui", "SIGSEGV occured"); }
75 virtual void flush() { }
76 virtual void init() { log("ui", "Default init"); } // user ui widgets init
77 virtual void shutdown() { if (!cleaned_up_) log("ui", "Default cleanup"); cleaned_up_ = true; } // ui cleanup
79 // virtual int get_key() { return 0; }
80 // virtual void beep() { }