| 1 | // ==================================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : aw_question.hxx // |
|---|
| 4 | // Purpose : Functions to ask questions to user // |
|---|
| 5 | // // |
|---|
| 6 | // // |
|---|
| 7 | // Coded by Ralf Westram (coder@reallysoft.de) in January 2002 // |
|---|
| 8 | // Copyright Department of Microbiology (Technical University Munich) // |
|---|
| 9 | // // |
|---|
| 10 | // Visit our web site at: http://www.arb-home.de/ // |
|---|
| 11 | // // |
|---|
| 12 | // // |
|---|
| 13 | // ==================================================================== // |
|---|
| 14 | |
|---|
| 15 | #ifndef AW_QUESTION_HXX |
|---|
| 16 | #define AW_QUESTION_HXX |
|---|
| 17 | |
|---|
| 18 | #ifndef AW_BASE_HXX |
|---|
| 19 | #include "aw_base.hxx" |
|---|
| 20 | #endif |
|---|
| 21 | #ifndef ARBTOOLS_H |
|---|
| 22 | #include <arbtools.h> |
|---|
| 23 | #endif |
|---|
| 24 | #ifndef ATTRIBUTES_H |
|---|
| 25 | #include <attributes.h> |
|---|
| 26 | #endif |
|---|
| 27 | #ifndef _GLIBCXX_CSTDLIB |
|---|
| 28 | #include <cstdlib> |
|---|
| 29 | #endif |
|---|
| 30 | |
|---|
| 31 | // if you ask the same question in a loop, it is recommended to use AW_repeated_question |
|---|
| 32 | // to avoid asking the same question again and again. |
|---|
| 33 | // |
|---|
| 34 | // Usage : 1. Create a new instance of AW_repeated_question outside the loop |
|---|
| 35 | // 2. call get_answer() inside the loop |
|---|
| 36 | |
|---|
| 37 | // The second way to get rid of unwanted questions is by using a 'unique_id' |
|---|
| 38 | // - if unique_id is set, a toggle "Never ask me again" will be added to the question-popup. |
|---|
| 39 | // - if unique_id is NULp, no such toggle will appear (i.e. the popup can NOT be suppressed!) |
|---|
| 40 | // The latter is recommended |
|---|
| 41 | // - whenever the buttons get generated dynamically |
|---|
| 42 | // - when not asking is REALLY dangerous |
|---|
| 43 | // |
|---|
| 44 | // Whenever you change the meaning of a question, it is mandatory that you change the unique_id!!! |
|---|
| 45 | |
|---|
| 46 | class AW_repeated_question FINAL_TYPE : virtual Noncopyable { |
|---|
| 47 | int answer; |
|---|
| 48 | bool dont_ask_again; |
|---|
| 49 | char *buttons_used; |
|---|
| 50 | char *helpfile; |
|---|
| 51 | |
|---|
| 52 | public: |
|---|
| 53 | AW_repeated_question() |
|---|
| 54 | : answer(0), |
|---|
| 55 | dont_ask_again(false), |
|---|
| 56 | buttons_used(NULp), |
|---|
| 57 | helpfile(NULp) |
|---|
| 58 | {} |
|---|
| 59 | virtual ~AW_repeated_question() { |
|---|
| 60 | free(buttons_used); |
|---|
| 61 | free(helpfile); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | void add_help(const char *help_file); // when called, a help button is added to the prompter |
|---|
| 65 | |
|---|
| 66 | int get_answer(const char *unique_id, const char *question, const char *buttons, const char *to_all, bool add_abort); |
|---|
| 67 | // return 0 for first button, 1 for second button, 2 for third button, ... |
|---|
| 68 | // the single buttons are separated by commas (i.e. "YES,NO") |
|---|
| 69 | // if add_abort is true an 'ABORT' button is added behind the last |
|---|
| 70 | }; |
|---|
| 71 | |
|---|
| 72 | int aw_question(const char *unique_id, const char *msg, const char *buttons, bool sameSizeButtons = true, const char *helpfile = NULp); |
|---|
| 73 | bool aw_ask_sure(const char *unique_id, const char *msg); |
|---|
| 74 | |
|---|
| 75 | // the following functions should only be used in very special cases - please use aw_message if possible! |
|---|
| 76 | void aw_popup_ok (const char *msg); |
|---|
| 77 | void aw_popup_exit(const char *msg) __ATTR__NORETURN; |
|---|
| 78 | |
|---|
| 79 | void AW_reactivate_all_questions(AW_window*); |
|---|
| 80 | |
|---|
| 81 | #else |
|---|
| 82 | #error aw_question.hxx included twice |
|---|
| 83 | #endif // AW_QUESTION_HXX |
|---|
| 84 | |
|---|