1 | // ==================================================================== // |
---|
2 | // // |
---|
3 | // File : aw_question.hxx // |
---|
4 | // Purpose : Functions to ask questions to user // |
---|
5 | // Time-stamp: <Tue Dec/21/2004 16:56 MET Coder@ReallySoft.de> // |
---|
6 | // // |
---|
7 | // // |
---|
8 | // Coded by Ralf Westram (coder@reallysoft.de) in January 2002 // |
---|
9 | // Copyright Department of Microbiology (Technical University Munich) // |
---|
10 | // // |
---|
11 | // Visit our web site at: http://www.arb-home.de/ // |
---|
12 | // // |
---|
13 | // // |
---|
14 | // ==================================================================== // |
---|
15 | |
---|
16 | #ifndef AW_QUESTION_HXX |
---|
17 | #define AW_QUESTION_HXX |
---|
18 | |
---|
19 | #ifndef AW_ROOT_HXX |
---|
20 | #include <aw_root.hxx> |
---|
21 | #endif |
---|
22 | #ifndef _STDLIB_H |
---|
23 | #include <stdlib.h> |
---|
24 | #endif |
---|
25 | #ifndef ARBTOOLS_H |
---|
26 | #include <arbtools.h> |
---|
27 | #endif |
---|
28 | |
---|
29 | |
---|
30 | // for simple questions use : int aw_message(const char *msg, const char *buttons) |
---|
31 | // |
---|
32 | // if you ask the same question in a loop, it is recommended to use AW_repeated_question |
---|
33 | // to avoid asking the same question again and again. |
---|
34 | // |
---|
35 | // Usage : 1. Create a new instance of AW_repeated_question outside the loop |
---|
36 | // 2. call get_answer() inside the loop |
---|
37 | |
---|
38 | class AW_repeated_question : Noncopyable { |
---|
39 | private: |
---|
40 | int answer; |
---|
41 | bool dont_ask_again; |
---|
42 | char *buttons_used; |
---|
43 | char *helpfile; |
---|
44 | |
---|
45 | public: |
---|
46 | AW_repeated_question(bool dont_ask_again_ = false) |
---|
47 | : answer(0), |
---|
48 | dont_ask_again(dont_ask_again_), |
---|
49 | buttons_used(0), |
---|
50 | helpfile(0) |
---|
51 | {} |
---|
52 | virtual ~AW_repeated_question() { |
---|
53 | free(buttons_used); |
---|
54 | free(helpfile); |
---|
55 | } |
---|
56 | |
---|
57 | void add_help(const char *help_file); // when called, a help button is added to the prompter |
---|
58 | |
---|
59 | int get_answer(const char *question, const char *buttons, const char *to_all, bool add_abort); |
---|
60 | // return 0 for first button, 1 for second button, 2 for third button, ... |
---|
61 | // the single buttons are seperated by kommas (i.e. "YES,NO") |
---|
62 | // if add_abort is true an 'ABORT' button is added behind the last |
---|
63 | }; |
---|
64 | |
---|
65 | |
---|
66 | #else |
---|
67 | #error aw_question.hxx included twice |
---|
68 | #endif // AW_QUESTION_HXX |
---|
69 | |
---|