Lots more work on making the frame aui stuff functional.
[dolphin.git] / Source / Core / DolphinWX / Src / Frame.h
blobf1bceee3a61f6fbcdc7f0966607e31ce01b9de5e
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 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 UpdateGameList();
126 void ToggleLogWindow(bool, int i = -1);
127 void ToggleConsole(bool, int i = -1);
128 void PostEvent(wxCommandEvent& event);
129 void PostMenuEvent(wxMenuEvent& event);
130 void PostUpdateUIEvent(wxUpdateUIEvent& event);
131 void StatusBarMessage(const char * Text, ...);
132 void ClearStatusBar();
133 void OnSizeRequest(int& x, int& y, int& width, int& height);
134 void BootGame(const std::string& filename);
135 void OnRenderParentClose(wxCloseEvent& event);
136 void OnRenderParentMove(wxMoveEvent& event);
137 bool RendererHasFocus();
138 void DoFullscreen(bool bF);
139 void ToggleDisplayMode (bool bFullscreen);
141 #if defined(HAVE_XRANDR) && HAVE_XRANDR
142 X11Utils::XRRConfiguration *m_XRRConfig;
143 #endif
145 // AUI
146 wxAuiManager *m_Mgr;
147 wxAuiToolBar *m_ToolBar, *m_ToolBarDebug, *m_ToolBarAui;
148 long NOTEBOOK_STYLE, TOOLBAR_STYLE;
149 int iLeftWidth[2], iMidWidth[2];
150 bool bFloatWindow[IDM_VIDEOWINDOW - IDM_LOGWINDOW + 1];
152 // Utility
153 wxWindow * GetNotebookPageFromId(wxWindowID Id);
154 wxAuiNotebook * GetNotebookFromId(u32);
155 int GetNotebookCount();
156 int Limit(int,int,int);
157 int PercentageToPixels(int,int);
158 int PixelsToPercentage(int,int);
159 wxString GetMenuLabel(int Id);
161 // Perspectives
162 void AddRemoveBlankPage();
163 void OnNotebookPageClose(wxAuiNotebookEvent& event);
164 void OnAllowNotebookDnD(wxAuiNotebookEvent& event);
165 void OnNotebookPageChanged(wxAuiNotebookEvent& event);
166 void OnFloatWindow(wxCommandEvent& event);
167 void ToggleFloatWindow(int Id);
168 void OnTab(wxAuiNotebookEvent& event);
169 int GetNotebookAffiliation(wxWindowID Id);
170 void ClosePages();
171 void ShowAllNotebooks(bool Window = false);
172 void HideAllNotebooks(bool Window = false);
173 void CloseAllNotebooks();
174 void DoAddPage(wxWindow *, int, bool);
175 void DoRemovePage(wxWindow *, bool Hide = true);
176 void DoRemovePageId(wxWindowID Id, bool bHide, bool bDestroy);
177 void TogglePane();
178 void SetSimplePaneSize();
179 void SetPaneSize();
180 void ResetToolbarStyle();
181 void TogglePaneStyle(bool On, int EventId);
182 void ToggleNotebookStyle(bool On, long Style);
183 void ResizeConsole();
184 // Float window
185 void DoUnfloatPage(int Id);
186 void OnFloatingPageClosed(wxCloseEvent& event);
187 void OnFloatingPageSize(wxSizeEvent& event);
188 void DoFloatNotebookPage(wxWindowID Id);
189 wxFrame * CreateParentFrame(wxWindowID Id = wxID_ANY, const wxString& title = wxT(""), wxWindow * = NULL);
190 // User perspectives. Should find a way to make these private.
191 struct SPerspectives
193 std::string Name;
194 wxString Perspective;
195 std::vector<int> Width, Height;
197 std::vector<SPerspectives> Perspectives;
198 wxString AuiFullscreen, AuiCurrent;
199 wxArrayString AuiPerspective;
200 u32 ActivePerspective;
201 void NamePanes();
202 void AddPane();
203 void Save();
204 void SaveLocal();
205 void OnPaneClose(wxAuiManagerEvent& evt);
206 void ReloadPanes();
207 void DoLoadPerspective();
208 void OnDropDownToolbarSelect(wxCommandEvent& event);
209 void OnDropDownSettingsToolbar(wxAuiToolBarEvent& event);
210 void OnDropDownToolbarItem(wxAuiToolBarEvent& event);
211 void OnSelectPerspective(wxCommandEvent& event);
213 private:
214 wxStatusBar* m_pStatusBar;
215 wxBoxSizer* sizerPanel;
216 wxBoxSizer* sizerFrame;
217 CGameListCtrl* m_GameListCtrl;
218 wxPanel* m_Panel;
219 CRenderFrame* m_RenderFrame;
220 wxPanel* m_RenderParent;
221 wxToolBarToolBase* m_ToolPlay;
222 CLogWindow* m_LogWindow;
223 bool UseDebugger;
224 bool m_bBatchMode;
225 bool m_bEdit;
226 bool m_bTabSplit;
227 bool m_bNoDocking;
228 bool m_bControlsCreated;
229 bool m_bGameLoading;
230 char newDiscpath[2048];
231 wxMessageDialog *m_StopDlg;
233 std::vector<std::string> drives;
235 enum EToolbar
237 Toolbar_FileOpen,
238 Toolbar_Refresh,
239 Toolbar_Browse,
240 Toolbar_Play,
241 Toolbar_Stop,
242 Toolbar_Pause,
243 Toolbar_Screenshot,
244 Toolbar_FullScreen,
245 Toolbar_PluginOptions,
246 Toolbar_PluginGFX,
247 Toolbar_PluginDSP,
248 Toolbar_PluginPAD,
249 Toolbar_Wiimote,
250 Toolbar_Help,
251 EToolbar_Max
254 enum EBitmapsThemes
256 BOOMY,
257 VISTA,
258 XPLASTIK,
259 KDE,
260 THEMES_MAX
263 wxBitmap m_Bitmaps[EToolbar_Max];
264 wxBitmap m_BitmapsMenu[EToolbar_Max];
266 void PopulateToolbar(wxAuiToolBar* toolBar);
267 void PopulateToolbarAui(wxAuiToolBar* toolBar);
268 void RecreateToolbar();
269 void CreateMenu();
270 wxAuiNotebook *CreateEmptyNotebook();
272 #ifdef _WIN32
273 // Override window proc for tricks like screensaver disabling
274 WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
275 #endif
276 // Event functions
277 void OnQuit(wxCommandEvent& event);
278 void OnHelp(wxCommandEvent& event);
279 void OnToolBar(wxCommandEvent& event);
280 void OnAuiToolBar(wxAuiToolBarEvent& event);
282 void OnOpen(wxCommandEvent& event); // File menu
283 void DoOpen(bool Boot);
284 void OnRefresh(wxCommandEvent& event);
285 void OnBrowse(wxCommandEvent& event);
286 void OnBootDrive(wxCommandEvent& event);
288 void OnPlay(wxCommandEvent& event); // Emulation
289 void OnStop(wxCommandEvent& event);
290 void OnReset(wxCommandEvent& event);
291 void OnRecord(wxCommandEvent& event);
292 void OnPlayRecording(wxCommandEvent& event);
293 void OnChangeDisc(wxCommandEvent& event);
294 void OnScreenshot(wxCommandEvent& event);
295 void OnActive(wxActivateEvent& event);
296 void OnClose(wxCloseEvent &event);
297 void OnLoadState(wxCommandEvent& event);
298 void OnSaveState(wxCommandEvent& event);
299 void OnLoadStateFromFile(wxCommandEvent& event);
300 void OnSaveStateToFile(wxCommandEvent& event);
301 void OnLoadLastState(wxCommandEvent& event);
302 void OnUndoLoadState(wxCommandEvent& event);
303 void OnUndoSaveState(wxCommandEvent& event);
305 void OnFrameSkip(wxCommandEvent& event);
306 void OnFrameStep(wxCommandEvent& event);
308 void OnConfigMain(wxCommandEvent& event); // Options
309 void OnPluginGFX(wxCommandEvent& event);
310 void OnPluginDSP(wxCommandEvent& event);
311 void OnPluginPAD(wxCommandEvent& event);
312 void OnPluginWiimote(wxCommandEvent& event);
314 void OnToggleFullscreen(wxCommandEvent& event);
315 void OnToggleDualCore(wxCommandEvent& event);
316 void OnToggleSkipIdle(wxCommandEvent& event);
317 void OnToggleThrottle(wxCommandEvent& event);
318 void OnManagerResize(wxAuiManagerEvent& event);
319 void OnMove(wxMoveEvent& event);
320 void OnResize(wxSizeEvent& event);
321 void OnToggleToolbar(wxCommandEvent& event);
322 void DoToggleToolbar(bool);
323 void OnToggleStatusbar(wxCommandEvent& event);
324 void OnToggleLogWindow(wxCommandEvent& event);
325 void OnToggleConsole(wxCommandEvent& event);
326 void OnKeyDown(wxKeyEvent& event);
327 void OnKeyUp(wxKeyEvent& event);
329 void OnHostMessage(wxCommandEvent& event);
331 void OnMemcard(wxCommandEvent& event); // Misc
332 void OnImportSave(wxCommandEvent& event);
333 void OnOpenLuaWindow(wxCommandEvent& event);
335 void OnNetPlay(wxCommandEvent& event);
337 void OnShow_CheatsWindow(wxCommandEvent& event);
338 void OnLoadWiiMenu(wxCommandEvent& event);
339 void OnConnectWiimote(wxCommandEvent& event);
340 void GameListChanged(wxCommandEvent& event);
342 void OnGameListCtrl_ItemActivated(wxListEvent& event);
343 void OnRenderParentResize(wxSizeEvent& event);
344 bool RendererIsFullscreen();
345 void StartGame(const std::string& filename);
347 // MenuBar
348 // File - Drive
349 wxMenuItem* m_pSubMenuDrive;
351 // Emulation
352 wxMenuItem* m_pSubMenuLoad;
353 wxMenuItem* m_pSubMenuSave;
354 wxMenuItem* m_pSubMenuFrameSkipping;
356 #if wxUSE_TIMER
357 // Used to process command events
358 void OnTimer(wxTimerEvent& WXUNUSED(event));
359 wxTimer m_timer;
360 #endif
362 // Event table
363 DECLARE_EVENT_TABLE();
367 #endif // __FRAME_H_