1 /* ScummVM Tools
2  *
3  * ScummVM Tools is the legal property of its developers, whose
4  * names are too numerous to list here. Please refer to the
5  * COPYRIGHT file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21 
22 /* Main  window classes for the tool GUI */
23 
24 #ifndef GUI_MAIN_H
25 #define GUI_MAIN_H
26 
27 #include <wx/wx.h>
28 #include <vector>
29 
30 #include "configuration.h"
31 
32 class WizardButtons;
33 struct WizardPageClass;
34 class WizardPage;
35 
36 enum GUI_ID {
37 	ID_FIRST = wxID_HIGHEST, // Ensure no collisions
38 	ID_NEXT,
39 	ID_PREV,
40 	ID_CANCEL,
41 	ID_HELP,
42 	ID_ABOUT,
43 	ID_COMPRESS,
44 	ID_EXTRACT,
45 	ID_ADVANCED,
46 	ID_WEBSITE,
47 	ID_MANUAL
48 };
49 
50 /**
51  * Top window of the application, the entire wizard, simply put
52  * Responsible for both the UI, and the management of pages
53  */
54 class ScummToolsFrame : public wxFrame
55 {
56 public:
57 	/**
58 	 * Creates the top window
59 	 *
60 	 * @param title The title of the window
61 	 * @param pos Position of the window onscreen
62 	 * @param size The target size of the window
63 	 */
64 	ScummToolsFrame(const wxString &title, const wxPoint &pos, const wxSize &size);
65 	~ScummToolsFrame();
66 
67 	/**
68 	 * Creates the menu bar for the application
69 	 * only called when running under mac osx (as menu bars are ugly in wizards when they are part of the window)
70 	 */
71 	void CreateMenuBar();
72 
73 	/**
74 	 * Switches page, old page is stored on a stack for going backwards
75 	 * Buttons are reset, and state is saved
76 	 *
77 	 * @param nextPage The page to switch too, the old page window will be destroyed
78 	 *                 and this page displayed in it's stead.
79 	 */
switchPage(WizardPage * nextPage)80 	void switchPage(WizardPage *nextPage) {
81 		switchPage(nextPage, NextPage);}
82 
83 	/**
84 	 * Switches back page to the previous page
85 	 * The current page is destroyed.
86 	 */
switchToPreviousPage()87 	void switchToPreviousPage() {
88 		switchPage(NULL, PreviousPage);}
89 
90 	/**
91 	 * Switches to the first page, the stack of old pages is emptied
92 	 * and the current pag is destroyed.
93 	 */
switchToFirstPage()94 	void switchToFirstPage() {
95 		switchPage(NULL, FirstPage);}
96 
97 	/**
98 	 * Get help text of this window
99 	 */
100 	virtual wxString GetHelpText();
101 
102 	/**
103 	 * Handle wx OnIdle events
104 	 */
105 	void onIdle(wxIdleEvent &evt);
106 
107 	/**
108 	 * Handle application close event
109 	 */
110 	void onClose(wxCloseEvent &evt);
111 
112 	void onMenuAdvanced(wxCommandEvent &evt);
113 	void onMenuHelp(wxCommandEvent &evt);
114 	void onMenuWebsite(wxCommandEvent &evt);
115 	void onMenuManual(wxCommandEvent &evt);
116 	void onMenuAbout(wxCommandEvent &evt);
117 	void onMenuExit(wxCommandEvent &evt);
118 
119 	/** The state of the wizard so far */
120 	Configuration _configuration;
121 
122 	/** The button pane */
123 	WizardButtons *_buttons;
124 private:
125 	enum SwitchToPage { NextPage, PreviousPage, FirstPage };
126 	void switchPage(WizardPage *nextPage, SwitchToPage page);
127 
128 	void destroyOldPanels();
129 
130 	wxPanel *_wizardpane;
131 
132 	std::vector<WizardPage *> _pages;
133 	std::vector<wxWindow *> _oldPanels;
134 
135 	DECLARE_EVENT_TABLE()
136 };
137 
138 /**
139  * This panel contains the "Next", "Previous" and "Abort" buttons
140  * Convenient interface as you don't need to create buttons
141  * with long, awkward calls
142  */
143 
144 class WizardButtons : public wxPanel {
145 public:
146 	/**
147 	 * Creates the button window.
148 	 *
149 	 * @param parent The parent window
150 	 * @param linetext A static text that is used to display some extra information
151 	 * @param conf The configuration object used for the tools
152 	 */
153 	WizardButtons(wxWindow *parent, wxStaticText *linetext, Configuration &conf);
154 
155 	/* Set the buttons to the standard configuration
156 	 * (prev, next shown and enabled, finish disabled)
157 	 */
158 	void reset();
159 
160 	/**
161 	 * Set the current wizard page, this is called from SwitchPage to make us
162 	 * know where to drop events generated by the buttons
163 	 */
164 	void setPage(WizardPage *current, wxWindow *panel);
165 
166 	/**
167 	 * Set the label of the line above the buttons, can display some useful info here
168 	 *
169 	 * @param label The label to display
170 	 */
171 	void setLineLabel(wxString label);
172 
173 	/**
174 	 * Enables the next button (or finish for the last page)
175 	 */
176 	void enableNext(bool enable);
177 
178 	/**
179 	 * Enables the previous button, shows it if it's disabled
180 	 */
181 	void enablePrevious(bool enable);
182 
183 	/**
184 	 * Display the previous/next button.
185 	 */
186 	void showNavigation(bool show);
187 
188 	/**
189 	 * Display the previous button.
190 	 * If the showNavigation has been used, this overrides that (for the previous button).
191 	 */
192 	void showPrevious(bool show);
193 
194 	/**
195 	 * Changes name of the 'next' button to finish
196 	 */
197 	void showFinish(bool show);
198 
199 	/**
200 	 * Changes name of the 'Cancel' button to abort
201 	 */
202 	void showAbort(bool show);
203 
204 	// wx event handlers
205 	void onClickHelp(wxCommandEvent &e);
206 	void onClickAbout(wxCommandEvent &e);
207 	void onClickNext(wxCommandEvent &e);
208 	void onClickPrevious(wxCommandEvent &e);
209 	void onClickCancel(wxCommandEvent &e);
210 
211 protected:
212 	/** Configuration used by the Wizard. */
213 	Configuration &_configuration;
214 	/** 'Next' (or finish) button. */
215 	wxButton *_next;
216 	/** 'Previous' button. */
217 	wxButton *_prev;
218 	/** 'Help' button. */
219 	wxButton *_help;
220 	/** 'Preferences' button */
221 	wxButton *_prefs;
222 	/** 'Cancel' button. */
223 	wxButton *_cancel;
224 	/** The static text on the line seperating the page area and the buttons. */
225 	wxStaticText *_linetext;
226 	/** Current page, required for dumping events to it. */
227 	WizardPage *_currentPage;
228 	/** Current panel, required so we can pass it as arguments to the handlers. */
229 	wxWindow *_currentPanel;
230 
231 	DECLARE_EVENT_TABLE()
232 };
233 
234 /**
235  * The header at the top of the window
236  * Tries to load media/logo.gif and media/tiled.gif
237  * If unavailable, it will simply be orange/brigt orange
238  */
239 
240 class Header : public wxPanel
241 {
242 public:
243 	Header(wxWindow *parent, const wxString &logo, const wxString &tile, const wxString &title = wxT(""));
244 
245 	void onPaint(wxPaintEvent &evt);
246 protected:
247 	wxBitmap loadBitmapFile(const wxString&, wxBitmapType);
248 
249 	wxFont _font;
250 	wxBitmap _logo;
251 	wxBitmap _tile;
252 	wxString _title;
253 
254 	DECLARE_EVENT_TABLE()
255 };
256 
257 /**
258  *
259  */
260 
261 class ChooseAudioOptionsMp3Page;
262 class ChooseAudioOptionsFlacPage;
263 class ChooseAudioOptionsVorbisPage;
264 
265 class AdvancedSettingsDialog : public wxDialog
266 {
267 public:
268 	AdvancedSettingsDialog(wxWindow *parent, Configuration &defaults);
269 	~AdvancedSettingsDialog();
270 
271 protected:
272 	Configuration &_defaults;
273 
274 	ChooseAudioOptionsMp3Page *_mp3;
275 	wxWindow *_mp3panel;
276 	ChooseAudioOptionsFlacPage *_flac;
277 	wxWindow *_flacpanel;
278 	ChooseAudioOptionsVorbisPage *_vorbis;
279 	wxWindow *_vorbispanel;
280 };
281 
282 #endif
283