Move fullscreen display resolution control to the GUI with the rest of the fullscreen...
[dolphin.git] / Source / Core / DolphinWX / Src / Frame.h
blobe51acabb39c2ae8fed2586b16f3b9be8cb4e7a3c
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 ShowLogWindow = false,
99 long style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
101 virtual ~CFrame();
103 void* GetRenderHandle()
105 #ifdef _WIN32
106 return (void *)m_RenderParent->GetHandle();
107 #elif defined(HAVE_X11) && HAVE_X11
108 return (void *)X11Utils::XWindowFromHandle(m_RenderParent->GetHandle());
109 #else
110 return m_RenderParent;
111 #endif
114 // These have to be public
115 CCodeWindow* g_pCodeWindow;
116 wxMenuBar* m_MenuBar;
117 wxBitmap aNormalFile;
118 void InitBitmaps();
119 void DoPause();
120 void DoStop();
121 bool bRenderToMain;
122 bool bNoWiimoteMsg;
123 void UpdateGUI();
124 void ToggleLogWindow(bool, int i = -1);
125 void ToggleConsole(bool, int i = -1);
126 void PostEvent(wxCommandEvent& event);
127 void PostMenuEvent(wxMenuEvent& event);
128 void PostUpdateUIEvent(wxUpdateUIEvent& event);
129 void StatusBarMessage(const char * Text, ...);
130 void ClearStatusBar();
131 void OnCustomHostMessage(int Id);
132 void OnSizeRequest(int& x, int& y, int& width, int& height);
133 void BootGame(const std::string& filename);
134 void OnRenderParentClose(wxCloseEvent& event);
135 void OnRenderParentMove(wxMoveEvent& event);
136 bool RendererHasFocus();
137 void DoFullscreen(bool bF);
138 void ToggleDisplayMode (bool bFullscreen);
140 #if defined(HAVE_XRANDR) && HAVE_XRANDR
141 X11Utils::XRRConfiguration *m_XRRConfig;
142 #endif
144 // AUI
145 wxAuiManager *m_Mgr;
146 wxAuiToolBar *m_ToolBar, *m_ToolBarDebug, *m_ToolBarAui;
147 long NOTEBOOK_STYLE, TOOLBAR_STYLE;
148 int iLeftWidth[2], iMidWidth[2];
149 bool bFloatLogWindow;
150 bool bFloatConsoleWindow;
152 // Utility
153 wxWindow * GetWxWindow(wxString);
154 #ifdef _WIN32
155 wxWindow * GetWxWindowHwnd(HWND);
156 #endif
157 wxWindow * GetFloatingPage(int Id);
158 wxWindow * GetNootebookPage(wxString);
159 wxWindow * GetNootebookPageFromId(wxWindowID Id);
160 wxAuiNotebook * GetNotebookFromId(u32);
161 wxWindowID WindowParentIdFromChildId(int Id);
162 wxString WindowNameFromId(int Id);
163 int GetNotebookCount();
164 int Limit(int,int,int);
165 int PercentageToPixels(int,int);
166 int PixelsToPercentage(int,int);
167 void ListChildren();
168 void ListTopWindows();
169 wxString GetMenuLabel(int Id);
171 // Perspectives
172 void AddRemoveBlankPage();
173 void OnNotebookPageClose(wxAuiNotebookEvent& event);
174 void OnAllowNotebookDnD(wxAuiNotebookEvent& event);
175 void OnNotebookPageChanged(wxAuiNotebookEvent& event);
176 void OnFloatWindow(wxCommandEvent& event);
177 void OnTab(wxAuiNotebookEvent& event);
178 int GetNootebookAffiliation(wxString Name);
179 void ClosePages();
180 void DoToggleWindow(int,bool);
181 void ShowAllNotebooks(bool Window = false);
182 void HideAllNotebooks(bool Window = false);
183 void CloseAllNotebooks();
184 void DoAddPage(wxWindow *, int, wxString, bool);
185 void DoRemovePage(wxWindow *, bool Hide = true);
186 void DoRemovePageId(wxWindowID Id, bool Hide = true, bool Destroy = false);
187 void DoRemovePageString(wxString, bool Hide = true, bool Destroy = false);
188 void TogglePane();
189 void SetSimplePaneSize();
190 void SetPaneSize();
191 void ResetToolbarStyle();
192 void TogglePaneStyle(bool On, int EventId);
193 void ToggleNotebookStyle(bool On, long Style);
194 void ResizeConsole();
195 // Float window
196 void DoUnfloatPage(int Id);
197 void OnFloatingPageClosed(wxCloseEvent& event);
198 void OnFloatingPageSize(wxSizeEvent& event);
199 void DoFloatNotebookPage(wxWindowID Id);
200 wxFrame * CreateParentFrame(wxWindowID Id = wxID_ANY, const wxString& title = wxT(""), wxWindow * = NULL);
201 // User perspectives. Should find a way to make these private.
202 struct SPerspectives
204 std::string Name;
205 wxString Perspective;
206 std::vector<int> Width, Height;
208 std::vector<SPerspectives> Perspectives;
209 wxString AuiFullscreen, AuiCurrent;
210 wxArrayString AuiPerspective;
211 u32 ActivePerspective;
212 void NamePanes();
213 void AddPane();
214 void Save();
215 void SaveLocal();
216 void OnPaneClose(wxAuiManagerEvent& evt);
217 void ReloadPanes();
218 void DoLoadPerspective();
219 void OnDropDownToolbarSelect(wxCommandEvent& event);
220 void OnDropDownSettingsToolbar(wxAuiToolBarEvent& event);
221 void OnDropDownToolbarItem(wxAuiToolBarEvent& event);
222 void OnSelectPerspective(wxCommandEvent& event);
224 private:
225 wxStatusBar* m_pStatusBar;
226 wxBoxSizer* sizerPanel;
227 wxBoxSizer* sizerFrame;
228 CGameListCtrl* m_GameListCtrl;
229 wxPanel* m_Panel;
230 CRenderFrame* m_RenderFrame;
231 wxPanel* m_RenderParent;
232 wxToolBarToolBase* m_ToolPlay;
233 CLogWindow* m_LogWindow;
234 bool UseDebugger;
235 bool m_bEdit;
236 bool m_bTabSplit;
237 bool m_bNoDocking;
238 bool m_bControlsCreated;
239 bool m_bGameLoading;
240 char newDiscpath[2048];
241 wxMessageDialog *m_StopDlg;
243 std::vector<std::string> drives;
245 enum EToolbar
247 Toolbar_FileOpen,
248 Toolbar_Refresh,
249 Toolbar_Browse,
250 Toolbar_Play,
251 Toolbar_Stop,
252 Toolbar_Pause,
253 Toolbar_Screenshot,
254 Toolbar_FullScreen,
255 Toolbar_PluginOptions,
256 Toolbar_PluginGFX,
257 Toolbar_PluginDSP,
258 Toolbar_PluginPAD,
259 Toolbar_Wiimote,
260 Toolbar_Help,
261 EToolbar_Max
264 enum EBitmapsThemes
266 BOOMY,
267 VISTA,
268 XPLASTIK,
269 KDE,
270 THEMES_MAX
273 wxBitmap m_Bitmaps[EToolbar_Max];
274 wxBitmap m_BitmapsMenu[EToolbar_Max];
276 void PopulateToolbar(wxAuiToolBar* toolBar);
277 void PopulateToolbarAui(wxAuiToolBar* toolBar);
278 void RecreateToolbar();
279 void CreateMenu();
280 wxPanel *CreateEmptyPanel(wxWindowID Id = wxID_ANY);
281 wxAuiNotebook *CreateEmptyNotebook();
283 #ifdef _WIN32
284 // Override window proc for tricks like screensaver disabling
285 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
286 #endif
287 // Event functions
288 void OnQuit(wxCommandEvent& event);
289 void OnHelp(wxCommandEvent& event);
290 void OnToolBar(wxCommandEvent& event);
291 void OnAuiToolBar(wxAuiToolBarEvent& event);
293 void OnOpen(wxCommandEvent& event); // File menu
294 void DoOpen(bool Boot);
295 void OnRefresh(wxCommandEvent& event);
296 void OnBrowse(wxCommandEvent& event);
297 void OnBootDrive(wxCommandEvent& event);
299 void OnPlay(wxCommandEvent& event); // Emulation
300 void OnStop(wxCommandEvent& event);
301 void OnReset(wxCommandEvent& event);
302 void OnRecord(wxCommandEvent& event);
303 void OnPlayRecording(wxCommandEvent& event);
304 void OnChangeDisc(wxCommandEvent& event);
305 void OnScreenshot(wxCommandEvent& event);
306 void OnActive(wxActivateEvent& event);
307 void OnClose(wxCloseEvent &event);
308 void OnLoadState(wxCommandEvent& event);
309 void OnSaveState(wxCommandEvent& event);
310 void OnLoadStateFromFile(wxCommandEvent& event);
311 void OnSaveStateToFile(wxCommandEvent& event);
312 void OnLoadLastState(wxCommandEvent& event);
313 void OnUndoLoadState(wxCommandEvent& event);
314 void OnUndoSaveState(wxCommandEvent& event);
316 void OnFrameSkip(wxCommandEvent& event);
317 void OnFrameStep(wxCommandEvent& event);
319 void OnConfigMain(wxCommandEvent& event); // Options
320 void OnPluginGFX(wxCommandEvent& event);
321 void OnPluginDSP(wxCommandEvent& event);
322 void OnPluginPAD(wxCommandEvent& event);
323 void OnPluginWiimote(wxCommandEvent& event);
325 void OnToggleFullscreen(wxCommandEvent& event);
326 void OnToggleDualCore(wxCommandEvent& event);
327 void OnToggleSkipIdle(wxCommandEvent& event);
328 void OnToggleThrottle(wxCommandEvent& event);
329 void OnManagerResize(wxAuiManagerEvent& event);
330 void OnMove(wxMoveEvent& event);
331 void OnResize(wxSizeEvent& event);
332 void OnToggleToolbar(wxCommandEvent& event);
333 void DoToggleToolbar(bool);
334 void OnToggleStatusbar(wxCommandEvent& event);
335 void OnToggleLogWindow(wxCommandEvent& event);
336 void OnToggleConsole(wxCommandEvent& event);
337 void OnKeyDown(wxKeyEvent& event);
338 void OnKeyUp(wxKeyEvent& event);
339 void OnDoubleClick(wxMouseEvent& event);
341 void OnHostMessage(wxCommandEvent& event);
343 void OnMemcard(wxCommandEvent& event); // Misc
344 void OnImportSave(wxCommandEvent& event);
345 void OnOpenLuaWindow(wxCommandEvent& event);
347 void OnNetPlay(wxCommandEvent& event);
349 void OnShow_CheatsWindow(wxCommandEvent& event);
350 void OnLoadWiiMenu(wxCommandEvent& event);
351 void OnConnectWiimote(wxCommandEvent& event);
352 void GameListChanged(wxCommandEvent& event);
354 void OnGameListCtrl_ItemActivated(wxListEvent& event);
355 void OnRenderParentResize(wxSizeEvent& event);
356 bool RendererIsFullscreen();
357 void StartGame(const std::string& filename);
359 // MenuBar
360 // File - Drive
361 wxMenuItem* m_pSubMenuDrive;
363 // Emulation
364 wxMenuItem* m_pSubMenuLoad;
365 wxMenuItem* m_pSubMenuSave;
366 wxMenuItem* m_pSubMenuFrameSkipping;
368 #if wxUSE_TIMER
369 // Used to process command events
370 void OnTimer(wxTimerEvent& WXUNUSED(event));
371 wxTimer m_timer;
372 #endif
374 // Event table
375 DECLARE_EVENT_TABLE();
379 #endif // __FRAME_H_