Fix an issue that caused the DSP-LLE window to be openned twice in windows. (Thanks...
[dolphin.git] / Source / Core / DolphinWX / Src / Frame.h
blobd5a71b28729ca328f525536fc672f874c263b383
1 // Copyright (C) 2003 Dolphin Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official SVN repository and contact information can be found at
16 // http://code.google.com/p/dolphin-emu/
19 #ifndef __FRAME_H_
20 #define __FRAME_H_
22 #include <wx/wx.h> // wxWidgets
23 #include <wx/busyinfo.h>
24 #include <wx/mstream.h>
25 #include <wx/listctrl.h>
26 #include <wx/artprov.h>
27 #if defined(__APPLE__)
28 //id is an objective-c++ type, wx team need to change this
29 #define id toolid
30 #endif
31 #include <wx/aui/aui.h>
32 #include <string>
33 #include <vector>
35 #include "CDUtils.h"
36 #include "CodeWindow.h"
37 #include "LogWindow.h"
38 #if defined(HAVE_X11) && HAVE_X11
39 #include "X11Utils.h"
40 #endif
42 // A shortcut to access the bitmaps
43 #define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
44 inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
46 wxMemoryInputStream is(data, length);
47 return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1));
50 // Class declarations
51 class CGameListCtrl;
52 class CLogWindow;
54 // The CPanel class to receive MSWWindowProc messages from the video plugin.
55 class CPanel : public wxPanel
57 public:
58 CPanel(
59 wxWindow* parent,
60 wxWindowID id = wxID_ANY
63 private:
64 DECLARE_EVENT_TABLE();
66 #ifdef _WIN32
67 // Receive WndProc messages
68 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
69 #endif
72 class CRenderFrame : public wxFrame
74 public:
75 CRenderFrame(wxFrame* parent,
76 wxWindowID id = wxID_ANY,
77 const wxString& title = wxT("Dolphin"),
78 const wxPoint& pos = wxDefaultPosition,
79 const wxSize& size = wxDefaultSize,
80 long style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
82 private:
83 #ifdef _WIN32
84 // Receive WndProc messages
85 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
86 #endif
89 class CFrame : public CRenderFrame
91 public:
92 CFrame(wxFrame* parent,
93 wxWindowID id = wxID_ANY,
94 const wxString& title = wxT("Dolphin"),
95 const wxPoint& pos = wxDefaultPosition,
96 const wxSize& size = wxDefaultSize,
97 bool _UseDebugger = false,
98 bool _BatchMode = false,
99 bool ShowLogWindow = false,
100 long style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
102 virtual ~CFrame();
104 void* GetRenderHandle()
106 #ifdef _WIN32
107 return (void *)m_RenderParent->GetHandle();
108 #elif defined(HAVE_X11) && HAVE_X11
109 return (void *)X11Utils::XWindowFromHandle(m_RenderParent->GetHandle());
110 #else
111 return m_RenderParent;
112 #endif
115 // These have to be public
116 CCodeWindow* g_pCodeWindow;
117 void InitBitmaps();
118 void DoPause();
119 void DoStop();
120 bool bRenderToMain;
121 bool bNoWiimoteMsg;
122 void UpdateGUI();
123 void UpdateGameList();
124 void ToggleLogWindow(bool bShow);
125 void ToggleConsole(bool bShow);
126 void PostEvent(wxCommandEvent& event);
127 void StatusBarMessage(const char * Text, ...);
128 void ClearStatusBar();
129 void OnSizeRequest(int& x, int& y, int& width, int& height);
130 void BootGame(const std::string& filename);
131 void OnRenderParentClose(wxCloseEvent& event);
132 void OnRenderParentMove(wxMoveEvent& event);
133 bool RendererHasFocus();
134 void DoFullscreen(bool bF);
135 void ToggleDisplayMode (bool bFullscreen);
137 #if defined(HAVE_XRANDR) && HAVE_XRANDR
138 X11Utils::XRRConfiguration *m_XRRConfig;
139 #endif
141 // AUI
142 wxAuiManager *m_Mgr;
143 wxAuiToolBar *m_ToolBar, *m_ToolBarDebug, *m_ToolBarAui;
144 bool bFloatWindow[IDM_CODEWINDOW - IDM_LOGWINDOW + 1];
146 // Utility
147 wxWindow * GetNotebookPageFromId(wxWindowID Id);
148 wxAuiNotebook * GetNotebookFromId(size_t NBId);
149 int GetNotebookCount();
150 wxString GetMenuLabel(int Id);
152 // Perspectives
153 void AddRemoveBlankPage();
154 void OnNotebookPageClose(wxAuiNotebookEvent& event);
155 void OnAllowNotebookDnD(wxAuiNotebookEvent& event);
156 void OnNotebookPageChanged(wxAuiNotebookEvent& event);
157 void OnFloatWindow(wxCommandEvent& event);
158 void ToggleFloatWindow(int Id);
159 void OnTab(wxAuiNotebookEvent& event);
160 int GetNotebookAffiliation(wxWindowID Id);
161 void ClosePages();
162 void CloseAllNotebooks();
163 void DoAddPage(wxWindow *Win, int i, bool Float);
164 void DoRemovePage(wxWindow *, bool bHide = true);
165 void TogglePane();
166 void SetPaneSize();
167 void ResetToolbarStyle();
168 void TogglePaneStyle(bool On, int EventId);
169 void ToggleNotebookStyle(bool On, long Style);
170 void ResizeConsole();
171 // Float window
172 void DoUnfloatPage(int Id);
173 void OnFloatingPageClosed(wxCloseEvent& event);
174 void OnFloatingPageSize(wxSizeEvent& event);
175 void DoFloatNotebookPage(wxWindowID Id);
176 wxFrame * CreateParentFrame(wxWindowID Id = wxID_ANY, const wxString& title = wxT(""), wxWindow * = NULL);
177 // User perspectives. Should find a way to make these private.
178 struct SPerspectives
180 std::string Name;
181 wxString Perspective;
182 std::vector<int> Width, Height;
184 std::vector<SPerspectives> Perspectives;
185 wxString AuiFullscreen, AuiCurrent;
186 wxArrayString AuiPerspective;
187 u32 ActivePerspective;
188 void AddPane();
189 void UpdateCurrentPerspective();
190 void SaveIniPerspectives();
191 void LoadIniPerspectives();
192 void OnPaneClose(wxAuiManagerEvent& evt);
193 void ReloadPanes();
194 void DoLoadPerspective();
195 void OnDropDownToolbarSelect(wxCommandEvent& event);
196 void OnDropDownSettingsToolbar(wxAuiToolBarEvent& event);
197 void OnDropDownToolbarItem(wxAuiToolBarEvent& event);
198 void OnSelectPerspective(wxCommandEvent& event);
200 private:
201 wxStatusBar* m_pStatusBar;
202 wxBoxSizer* sizerFrame;
203 CGameListCtrl* m_GameListCtrl;
204 wxPanel* m_Panel;
205 CRenderFrame* m_RenderFrame;
206 wxPanel* m_RenderParent;
207 wxToolBarToolBase* m_ToolPlay;
208 CLogWindow* m_LogWindow;
209 bool UseDebugger;
210 bool m_bBatchMode;
211 bool m_bEdit;
212 bool m_bTabSplit;
213 bool m_bNoDocking;
214 bool m_bControlsCreated;
215 bool m_bGameLoading;
216 char newDiscpath[2048];
217 wxMessageDialog *m_StopDlg;
219 std::vector<std::string> drives;
221 enum EToolbar
223 Toolbar_FileOpen,
224 Toolbar_Refresh,
225 Toolbar_Browse,
226 Toolbar_Play,
227 Toolbar_Stop,
228 Toolbar_Pause,
229 Toolbar_Screenshot,
230 Toolbar_FullScreen,
231 Toolbar_PluginOptions,
232 Toolbar_PluginGFX,
233 Toolbar_PluginDSP,
234 Toolbar_PluginPAD,
235 Toolbar_Wiimote,
236 Toolbar_Help,
237 EToolbar_Max
240 enum EBitmapsThemes
242 BOOMY,
243 VISTA,
244 XPLASTIK,
245 KDE,
246 THEMES_MAX
249 wxBitmap m_Bitmaps[EToolbar_Max];
250 wxBitmap m_BitmapsMenu[EToolbar_Max];
252 void PopulateToolbar(wxAuiToolBar* toolBar);
253 void PopulateToolbarAui(wxAuiToolBar* toolBar);
254 void RecreateToolbar();
255 void CreateMenu();
256 wxAuiNotebook *CreateEmptyNotebook();
258 #ifdef _WIN32
259 // Override window proc for tricks like screensaver disabling
260 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
261 #endif
262 // Event functions
263 void OnQuit(wxCommandEvent& event);
264 void OnHelp(wxCommandEvent& event);
265 void OnToolBar(wxCommandEvent& event);
266 void OnAuiToolBar(wxAuiToolBarEvent& event);
268 void OnOpen(wxCommandEvent& event); // File menu
269 void DoOpen(bool Boot);
270 void OnRefresh(wxCommandEvent& event);
271 void OnBrowse(wxCommandEvent& event);
272 void OnBootDrive(wxCommandEvent& event);
274 void OnPlay(wxCommandEvent& event); // Emulation
275 void OnStop(wxCommandEvent& event);
276 void OnReset(wxCommandEvent& event);
277 void OnRecord(wxCommandEvent& event);
278 void OnPlayRecording(wxCommandEvent& event);
279 void OnChangeDisc(wxCommandEvent& event);
280 void OnScreenshot(wxCommandEvent& event);
281 void OnActive(wxActivateEvent& event);
282 void OnClose(wxCloseEvent &event);
283 void OnLoadState(wxCommandEvent& event);
284 void OnSaveState(wxCommandEvent& event);
285 void OnLoadStateFromFile(wxCommandEvent& event);
286 void OnSaveStateToFile(wxCommandEvent& event);
287 void OnLoadLastState(wxCommandEvent& event);
288 void OnUndoLoadState(wxCommandEvent& event);
289 void OnUndoSaveState(wxCommandEvent& event);
291 void OnFrameSkip(wxCommandEvent& event);
292 void OnFrameStep(wxCommandEvent& event);
294 void OnConfigMain(wxCommandEvent& event); // Options
295 void OnPluginGFX(wxCommandEvent& event);
296 void OnPluginDSP(wxCommandEvent& event);
297 void OnPluginPAD(wxCommandEvent& event);
298 void OnPluginWiimote(wxCommandEvent& event);
300 void OnToggleFullscreen(wxCommandEvent& event);
301 void OnToggleDualCore(wxCommandEvent& event);
302 void OnToggleSkipIdle(wxCommandEvent& event);
303 void OnToggleThrottle(wxCommandEvent& event);
304 void OnManagerResize(wxAuiManagerEvent& event);
305 void OnMove(wxMoveEvent& event);
306 void OnResize(wxSizeEvent& event);
307 void OnToggleToolbar(wxCommandEvent& event);
308 void DoToggleToolbar(bool);
309 void OnToggleStatusbar(wxCommandEvent& event);
310 void OnToggleWindow(wxCommandEvent& event);
311 void OnKeyDown(wxKeyEvent& event);
312 void OnKeyUp(wxKeyEvent& event);
314 void OnHostMessage(wxCommandEvent& event);
316 void OnMemcard(wxCommandEvent& event); // Misc
317 void OnImportSave(wxCommandEvent& event);
318 void OnOpenLuaWindow(wxCommandEvent& event);
320 void OnNetPlay(wxCommandEvent& event);
322 void OnShow_CheatsWindow(wxCommandEvent& event);
323 void OnLoadWiiMenu(wxCommandEvent& event);
324 void OnConnectWiimote(wxCommandEvent& event);
325 void GameListChanged(wxCommandEvent& event);
327 void OnGameListCtrl_ItemActivated(wxListEvent& event);
328 void OnRenderParentResize(wxSizeEvent& event);
329 bool RendererIsFullscreen();
330 void StartGame(const std::string& filename);
332 // MenuBar
333 // File - Drive
334 wxMenuItem* m_pSubMenuDrive;
336 // Emulation
337 wxMenuItem* m_pSubMenuLoad;
338 wxMenuItem* m_pSubMenuSave;
339 wxMenuItem* m_pSubMenuFrameSkipping;
341 #if wxUSE_TIMER
342 // Used to process command events
343 void OnTimer(wxTimerEvent& WXUNUSED(event));
344 wxTimer m_timer;
345 #endif
347 // Event table
348 DECLARE_EVENT_TABLE();
352 #endif // __FRAME_H_