Commit | Line | Data |
---|---|---|
69695f33 MW |
1 | /* Copyright (c) 2006 by Arkkra Enterprises */ |
2 | /* All rights reserved */ | |
3 | ||
4 | #ifndef _CONFIG_H_ | |
5 | #define _CONFIG_H_ | |
6 | ||
7 | // Classes for Config menu item off of main toolbar | |
8 | ||
9 | #include <FL/Fl_Double_Window.H> | |
10 | #include <FL/Fl_Input.H> | |
11 | #include <FL/Fl_Secret_Input.H> | |
12 | #include <FL/Fl_Button.H> | |
13 | #include <FL/Fl_Return_Button.H> | |
14 | #include <FL/Fl_Check_Button.H> | |
15 | #include <FL/Fl_Choice.H> | |
16 | #include <FL/Fl_Value_Input.H> | |
17 | #include "utils.H" | |
18 | ||
19 | ||
20 | // Class for window that asks user for file locations | |
21 | ||
22 | class FileLocations_dialog : Fl_Double_Window { | |
23 | ||
24 | friend class Config; | |
25 | ||
26 | public: | |
27 | FileLocations_dialog(void); | |
28 | ~FileLocations_dialog(); | |
29 | ||
30 | // Callbacks | |
31 | static void Apply_cb(Fl_Widget *, void *); | |
32 | static void Cancel_cb(Fl_Widget *, void *); | |
33 | ||
34 | private: | |
35 | // Callbacks | |
36 | void Apply(void); | |
37 | void Cancel(void); | |
38 | ||
39 | // Populuate fields with current values | |
40 | void set_current_values(void); | |
41 | ||
42 | // Widgets | |
43 | Fl_Input * mup_program_p; | |
44 | Fl_Input * mup_documentation_p; | |
45 | Fl_Input * music_files_p; | |
46 | Fl_Input * muppath_p; | |
47 | Fl_Input * viewer_p; | |
48 | Fl_Input * player_p; | |
49 | Fl_Return_Button * apply_p; | |
50 | Fl_Button * cancel_p; | |
51 | }; | |
52 | ||
53 | ||
54 | // Class for window that asks user for preferences, like editor font, size, etc. | |
55 | ||
56 | class Preferences_dialog : Fl_Double_Window { | |
57 | ||
58 | friend class Config; | |
59 | ||
60 | public: | |
61 | Preferences_dialog(void); | |
62 | ~Preferences_dialog(); | |
63 | ||
64 | // Callbacks | |
65 | static void Apply_cb(Fl_Widget *, void * data); | |
66 | static void Cancel_cb(Fl_Widget *, void * data); | |
67 | static void fontchg_cb(Fl_Widget *, void * data); | |
68 | ||
69 | private: | |
70 | // Callbacks | |
71 | void fontchg(void); | |
72 | void Apply(void); | |
73 | void Cancel(void); | |
74 | ||
75 | // Populate fields with current values | |
76 | void set_current_values(void); | |
77 | ||
78 | // Populate size menu as appropriate for the given font | |
79 | void set_size_list(Fl_Font font, uchar curr_size); | |
80 | ||
81 | // Widgets | |
82 | Fl_Choice * font_p; | |
83 | Fl_Choice * size_p; | |
84 | Fl_Check_Button * auto_display_p; | |
85 | Fl_Check_Button * auto_save_p; | |
86 | Fl_Value_Input * tooltips_delay_p; | |
87 | Fl_Return_Button * apply_p; | |
88 | Fl_Button * cancel_p; | |
89 | }; | |
90 | ||
91 | ||
92 | // Class for user to fill out registration form | |
93 | ||
94 | class RegistrationForm_dialog : public Fl_Double_Window | |
95 | { | |
96 | public: | |
97 | RegistrationForm_dialog(void); | |
98 | ~RegistrationForm_dialog(void); | |
99 | ||
100 | // Callbacks | |
101 | static void SaveForm_cb(Fl_Widget *, void * data); | |
102 | static void Cancel_cb(Fl_Widget *, void * data); | |
103 | ||
104 | private: | |
105 | // Callbacks | |
106 | void SaveForm(void); | |
107 | void Cancel(void); | |
108 | ||
109 | // Fill in the form and write it out for user to mail with payment. | |
110 | void generate_form(void); | |
111 | // Fill in the value in the blank before or after the given place. | |
112 | // If can't fit entire value, returns pointer to how far it got, | |
113 | // otherwise returns zero. | |
114 | const char * fill_in(bool before, char *place, const char * const value); | |
115 | // Calculate sales tax due. | |
116 | double sales_tax(void); | |
117 | ||
118 | // Widgets | |
119 | Fl_Input * name_p; | |
120 | Fl_Input * address_p; | |
121 | Fl_Input * city_p; | |
122 | Fl_Input * state_p; | |
123 | Fl_Input * postal_code_p; | |
124 | Fl_Input * country_p; | |
125 | Fl_Input * email_p; | |
126 | Fl_Input * how_heard_p; | |
127 | Fl_Check_Button * Windows_p; | |
128 | Fl_Check_Button * Mac_p; | |
129 | Fl_Check_Button * Linux_p; | |
130 | Fl_Check_Button * other_p; | |
131 | Fl_Input * other_OS_p; | |
132 | Fl_Check_Button * mailing_list_p; | |
133 | Positive_Int_Input * num_regs_p; | |
134 | ||
135 | Fl_Return_Button * save_form_p; | |
136 | Fl_Button * cancel_p; | |
137 | }; | |
138 | ||
139 | ||
140 | // Class for user to enter registration key after paying. | |
141 | ||
142 | class RegistrationKey_dialog : public Fl_Double_Window { | |
143 | public: | |
144 | RegistrationKey_dialog(void); | |
145 | ~RegistrationKey_dialog(); | |
146 | ||
147 | // Callbacks | |
148 | static void OK_cb(Fl_Widget *, void *); | |
149 | static void Cancel_cb(Fl_Widget *, void *); | |
150 | ||
151 | private: | |
152 | // Callbacks | |
153 | void OK(void); | |
154 | void Cancel(void); | |
155 | ||
156 | // Widgets | |
157 | Fl_Secret_Input * key_p; | |
158 | Fl_Return_Button * OK_p; | |
159 | Fl_Button * cancel_p; | |
160 | }; | |
161 | ||
162 | // Class for the Config menu item on main toolbar | |
163 | ||
164 | class Config { | |
165 | public: | |
166 | Config(); | |
167 | ~Config(); | |
168 | ||
169 | // Callbacks | |
170 | static void FileLocations_cb(Fl_Widget *, void *); | |
171 | static void Preferences_cb(Fl_Widget *, void *); | |
172 | static void RegistrationForm_cb(Fl_Widget *, void *); | |
173 | static void RegistrationKey_cb(Fl_Widget *, void *); | |
174 | ||
175 | // Convert font name to Fl_Font value | |
176 | static Fl_Font fontvalue(const char *); | |
177 | ||
178 | private: | |
179 | // Callbacks | |
180 | void FileLocations(void); | |
181 | void Preferences(void); | |
182 | void RegistrationForm(void); | |
183 | void RegistrationKey(void); | |
184 | ||
185 | // Widgets | |
186 | FileLocations_dialog * locations_p; | |
187 | Preferences_dialog * preferences_p; | |
188 | RegistrationForm_dialog * registrationform_p; | |
189 | RegistrationKey_dialog * registrationkey_p; | |
190 | }; | |
191 | ||
192 | ||
193 | // Any class that wants to be notified of changes in user preference | |
194 | // for font and size should register a callback function of this type | |
195 | // using the Font_change_registration class. The first arg will be user | |
196 | // data the registrant wants to have passed to it. The second argument | |
197 | // is the new font, and the third argument is the new size. | |
198 | typedef void (*Font_change_callback)(void *, Fl_Font, unsigned char); | |
199 | ||
200 | // Any class that wants to be notified of changes in user preference | |
201 | // in font/size should instantiate an instance of this class. | |
202 | class Font_change_registration { | |
203 | public: | |
204 | Font_change_registration(Font_change_callback func, void * arg); | |
205 | ~Font_change_registration(void); | |
206 | ||
207 | // This runs all the registered callbacks | |
208 | static void run_callbacks(Fl_Font font, unsigned char size); | |
209 | ||
210 | private: | |
211 | // Linked list of callbacks | |
212 | static Font_change_registration * list_p; | |
213 | Font_change_registration * next; | |
214 | ||
215 | // What function to call back, and what to pass it. | |
216 | Font_change_callback callback; | |
217 | void * callback_arg; | |
218 | }; | |
219 | ||
220 | #endif |