Make sure screensaver does not start while a game is running in MS Windows
[dolphin.git] / Source / Core / DolphinWX / Src / Frame.h
blobe3016899c417adb62cfccab3ab2083c396d33073
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 <gtk/gtk.h>
40 #include <gdk/gdkx.h>
41 #endif
43 // A shortcut to access the bitmaps
44 #define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name))
45 inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
47 wxMemoryInputStream is(data, length);
48 return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1));
51 // Class declarations
52 class CGameListCtrl;
53 class CLogWindow;
55 // The CPanel class to receive MSWWindowProc messages from the video plugin.
56 class CPanel : public wxPanel
58 public:
59 CPanel(
60 wxWindow* parent,
61 wxWindowID id = wxID_ANY
64 private:
65 DECLARE_EVENT_TABLE();
67 #ifdef _WIN32
68 // Receive WndProc messages
69 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
70 #endif
73 class CRenderFrame : public wxFrame
75 public:
76 CRenderFrame(wxFrame* parent,
77 wxWindowID id = wxID_ANY,
78 const wxString& title = wxT("Dolphin"),
79 const wxPoint& pos = wxDefaultPosition,
80 const wxSize& size = wxDefaultSize,
81 long style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
83 private:
84 #ifdef _WIN32
85 // Receive WndProc messages
86 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
87 #endif
90 class CFrame : public CRenderFrame
92 public:
93 CFrame(wxFrame* parent,
94 wxWindowID id = wxID_ANY,
95 const wxString& title = wxT("Dolphin"),
96 const wxPoint& pos = wxDefaultPosition,
97 const wxSize& size = wxDefaultSize,
98 bool _UseDebugger = false,
99 bool ShowLogWindow = false,
100 long style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE);
102 void* GetRenderHandle()
104 #ifdef _WIN32
105 return (void *)m_RenderParent->GetHandle();
106 #elif defined(HAVE_X11) && HAVE_X11
107 return (void *)GDK_WINDOW_XID(GTK_WIDGET(m_RenderParent->GetHandle())->window);
108 #else
109 return m_RenderParent;
110 #endif
113 virtual ~CFrame();
115 // These have to be public
116 CCodeWindow* g_pCodeWindow;
117 wxMenuBar* m_MenuBar;
118 wxBitmap aNormalFile;
119 void InitBitmaps();
120 void DoPause();
121 void DoStop();
122 bool bRenderToMain;
123 bool bNoWiimoteMsg;
124 void UpdateGUI();
125 void ToggleLogWindow(bool, int i = -1);
126 void ToggleConsole(bool, int i = -1);
127 void PostEvent(wxCommandEvent& event);
128 void PostMenuEvent(wxMenuEvent& event);
129 void PostUpdateUIEvent(wxUpdateUIEvent& event);
130 void StatusBarMessage(const char * Text, ...);
131 void ClearStatusBar();
132 void OnCustomHostMessage(int Id);
133 void OnSizeRequest(int& x, int& y, int& width, int& height);
134 void StartGame(const std::string& filename);
135 void OnRenderParentClose(wxCloseEvent& event);
136 void OnRenderParentMove(wxMoveEvent& event);
137 bool RendererHasFocus();
138 void DoFullscreen(bool bF);
140 // AUI
141 wxAuiManager *m_Mgr;
142 wxAuiToolBar *m_ToolBar, *m_ToolBarDebug, *m_ToolBarAui;
143 long NOTEBOOK_STYLE, TOOLBAR_STYLE;
144 int iLeftWidth[2], iMidWidth[2];
145 bool bFloatLogWindow;
146 bool bFloatConsoleWindow;
148 // Utility
149 wxWindow * GetWxWindow(wxString);
150 #ifdef _WIN32
151 wxWindow * GetWxWindowHwnd(HWND);
152 #endif
153 wxWindow * GetFloatingPage(int Id);
154 wxWindow * GetNootebookPage(wxString);
155 wxWindow * GetNootebookPageFromId(wxWindowID Id);
156 wxAuiNotebook * GetNotebookFromId(u32);
157 wxWindowID WindowParentIdFromChildId(int Id);
158 wxString WindowNameFromId(int Id);
159 int GetNotebookCount();
160 int Limit(int,int,int);
161 int PercentageToPixels(int,int);
162 int PixelsToPercentage(int,int);
163 void ListChildren();
164 void ListTopWindows();
165 wxString GetMenuLabel(int Id);
167 // Perspectives
168 void AddRemoveBlankPage();
169 void OnNotebookPageClose(wxAuiNotebookEvent& event);
170 void OnAllowNotebookDnD(wxAuiNotebookEvent& event);
171 void OnNotebookPageChanged(wxAuiNotebookEvent& event);
172 void OnFloatWindow(wxCommandEvent& event);
173 void OnTab(wxAuiNotebookEvent& event);
174 int GetNootebookAffiliation(wxString Name);
175 void ClosePages();
176 void DoToggleWindow(int,bool);
177 void ShowAllNotebooks(bool Window = false);
178 void HideAllNotebooks(bool Window = false);
179 void CloseAllNotebooks();
180 void DoAddPage(wxWindow *, int, wxString, bool);
181 void DoRemovePage(wxWindow *, bool Hide = true);
182 void DoRemovePageId(wxWindowID Id, bool Hide = true, bool Destroy = false);
183 void DoRemovePageString(wxString, bool Hide = true, bool Destroy = false);
184 void TogglePane();
185 void SetSimplePaneSize();
186 void SetPaneSize();
187 void ResetToolbarStyle();
188 void TogglePaneStyle(bool On, int EventId);
189 void ToggleNotebookStyle(bool On, long Style);
190 void ResizeConsole();
191 // Float window
192 void DoUnfloatPage(int Id);
193 void OnFloatingPageClosed(wxCloseEvent& event);
194 void OnFloatingPageSize(wxSizeEvent& event);
195 void DoFloatNotebookPage(wxWindowID Id);
196 wxFrame * CreateParentFrame(wxWindowID Id = wxID_ANY, const wxString& title = wxT(""), wxWindow * = NULL);
197 // User perspectives. Should find a way to make these private.
198 struct SPerspectives
200 std::string Name;
201 wxString Perspective;
202 std::vector<int> Width, Height;
204 std::vector<SPerspectives> Perspectives;
205 wxString AuiFullscreen, AuiCurrent;
206 wxArrayString AuiPerspective;
207 u32 ActivePerspective;
208 void NamePanes();
209 void AddPane();
210 void Save();
211 void SaveLocal();
212 void OnPaneClose(wxAuiManagerEvent& evt);
213 void ReloadPanes();
214 void DoLoadPerspective();
215 void OnDropDownToolbarSelect(wxCommandEvent& event);
216 void OnDropDownSettingsToolbar(wxAuiToolBarEvent& event);
217 void OnDropDownToolbarItem(wxAuiToolBarEvent& event);
218 void OnSelectPerspective(wxCommandEvent& event);
220 private:
221 wxStatusBar* m_pStatusBar;
222 wxBoxSizer* sizerPanel;
223 wxBoxSizer* sizerFrame;
224 CGameListCtrl* m_GameListCtrl;
225 wxPanel* m_Panel;
226 CRenderFrame* m_RenderFrame;
227 wxPanel* m_RenderParent;
228 wxToolBarToolBase* m_ToolPlay;
229 CLogWindow* m_LogWindow;
230 bool UseDebugger;
231 bool m_bEdit;
232 bool m_bTabSplit;
233 bool m_bNoDocking;
234 bool m_bControlsCreated;
235 char newDiscpath[2048];
236 wxMessageDialog *m_StopDlg;
238 std::vector<std::string> drives;
240 enum EToolbar
242 Toolbar_FileOpen,
243 Toolbar_Refresh,
244 Toolbar_Browse,
245 Toolbar_Play,
246 Toolbar_Stop,
247 Toolbar_Pause,
248 Toolbar_Screenshot,
249 Toolbar_FullScreen,
250 Toolbar_PluginOptions,
251 Toolbar_PluginGFX,
252 Toolbar_PluginDSP,
253 Toolbar_PluginPAD,
254 Toolbar_Wiimote,
255 Toolbar_Help,
256 EToolbar_Max
259 enum EBitmapsThemes
261 BOOMY,
262 VISTA,
263 XPLASTIK,
264 KDE,
265 THEMES_MAX
268 wxBitmap m_Bitmaps[EToolbar_Max];
269 wxBitmap m_BitmapsMenu[EToolbar_Max];
271 void PopulateToolbar(wxAuiToolBar* toolBar);
272 void PopulateToolbarAui(wxAuiToolBar* toolBar);
273 void RecreateToolbar();
274 void CreateMenu();
275 wxPanel *CreateEmptyPanel(wxWindowID Id = wxID_ANY);
276 wxAuiNotebook *CreateEmptyNotebook();
278 #ifdef _WIN32
279 // Override window proc for tricks like screensaver disabling
280 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
281 #endif
282 // Event functions
283 void OnQuit(wxCommandEvent& event);
284 void OnHelp(wxCommandEvent& event);
285 void OnToolBar(wxCommandEvent& event);
286 void OnAuiToolBar(wxAuiToolBarEvent& event);
288 void OnOpen(wxCommandEvent& event); // File menu
289 void DoOpen(bool Boot);
290 void OnRefresh(wxCommandEvent& event);
291 void OnBrowse(wxCommandEvent& event);
292 void OnBootDrive(wxCommandEvent& event);
294 void OnPlay(wxCommandEvent& event); // Emulation
295 void OnStop(wxCommandEvent& event);
296 void OnReset(wxCommandEvent& event);
297 void OnRecord(wxCommandEvent& event);
298 void OnPlayRecording(wxCommandEvent& event);
299 void OnChangeDisc(wxCommandEvent& event);
300 void OnScreenshot(wxCommandEvent& event);
301 void OnActive(wxActivateEvent& event);
302 void OnClose(wxCloseEvent &event);
303 void OnLoadState(wxCommandEvent& event);
304 void OnSaveState(wxCommandEvent& event);
305 void OnLoadStateFromFile(wxCommandEvent& event);
306 void OnSaveStateToFile(wxCommandEvent& event);
307 void OnLoadLastState(wxCommandEvent& event);
308 void OnUndoLoadState(wxCommandEvent& event);
309 void OnUndoSaveState(wxCommandEvent& event);
311 void OnFrameSkip(wxCommandEvent& event);
312 void OnFrameStep(wxCommandEvent& event);
314 void OnConfigMain(wxCommandEvent& event); // Options
315 void OnPluginGFX(wxCommandEvent& event);
316 void OnPluginDSP(wxCommandEvent& event);
317 void OnPluginPAD(wxCommandEvent& event);
318 void OnPluginWiimote(wxCommandEvent& event);
320 void OnToggleFullscreen(wxCommandEvent& event);
321 void OnToggleDualCore(wxCommandEvent& event);
322 void OnToggleSkipIdle(wxCommandEvent& event);
323 void OnToggleThrottle(wxCommandEvent& event);
324 void OnManagerResize(wxAuiManagerEvent& event);
325 void OnMove(wxMoveEvent& event);
326 void OnResize(wxSizeEvent& event);
327 void OnToggleToolbar(wxCommandEvent& event);
328 void DoToggleToolbar(bool);
329 void OnToggleStatusbar(wxCommandEvent& event);
330 void OnToggleLogWindow(wxCommandEvent& event);
331 void OnToggleConsole(wxCommandEvent& event);
332 void OnKeyDown(wxKeyEvent& event);
333 void OnKeyUp(wxKeyEvent& event);
334 void OnDoubleClick(wxMouseEvent& event);
336 void OnHostMessage(wxCommandEvent& event);
338 void OnMemcard(wxCommandEvent& event); // Misc
339 void OnImportSave(wxCommandEvent& event);
340 void OnOpenLuaWindow(wxCommandEvent& event);
342 void OnNetPlay(wxCommandEvent& event);
344 void OnShow_CheatsWindow(wxCommandEvent& event);
345 void OnLoadWiiMenu(wxCommandEvent& event);
346 void OnConnectWiimote(wxCommandEvent& event);
347 void GameListChanged(wxCommandEvent& event);
349 void OnGameListCtrl_ItemActivated(wxListEvent& event);
350 void OnRenderParentResize(wxSizeEvent& event);
351 bool RendererIsFullscreen();
352 #if defined HAVE_X11 && HAVE_X11
353 void X11_SendClientEvent(const char *message,
354 int data1 = 0, int data2 = 0, int data3 = 0, int data4 = 0);
355 #endif
357 // MenuBar
358 // File - Drive
359 wxMenuItem* m_pSubMenuDrive;
361 // Emulation
362 wxMenuItem* m_pSubMenuLoad;
363 wxMenuItem* m_pSubMenuSave;
364 wxMenuItem* m_pSubMenuFrameSkipping;
366 void BootGame(const std::string& filename);
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_