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/
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
31 #include <wx/aui/aui.h>
36 #include "CodeWindow.h"
37 #include "LogWindow.h"
38 #if defined(HAVE_X11) && HAVE_X11
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));
54 // The CPanel class to receive MSWWindowProc messages from the video plugin.
55 class CPanel
: public wxPanel
60 wxWindowID id
= wxID_ANY
64 DECLARE_EVENT_TABLE();
67 // Receive WndProc messages
68 WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
72 class CRenderFrame
: public wxFrame
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
);
84 // Receive WndProc messages
85 WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
89 class CFrame
: public CRenderFrame
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
);
104 void* GetRenderHandle()
107 return (void *)m_RenderParent
->GetHandle();
108 #elif defined(HAVE_X11) && HAVE_X11
109 return (void *)X11Utils::XWindowFromHandle(m_RenderParent
->GetHandle());
111 return m_RenderParent
;
115 // These have to be public
116 CCodeWindow
* g_pCodeWindow
;
117 wxMenuBar
* m_MenuBar
;
118 wxBitmap aNormalFile
;
125 void UpdateGameList();
126 void ToggleLogWindow(bool, int i
= -1);
127 void ToggleConsole(bool, int i
= -1);
128 void PostEvent(wxCommandEvent
& event
);
129 void StatusBarMessage(const char * Text
, ...);
130 void ClearStatusBar();
131 void OnSizeRequest(int& x
, int& y
, int& width
, int& height
);
132 void BootGame(const std::string
& filename
);
133 void OnRenderParentClose(wxCloseEvent
& event
);
134 void OnRenderParentMove(wxMoveEvent
& event
);
135 bool RendererHasFocus();
136 void DoFullscreen(bool bF
);
137 void ToggleDisplayMode (bool bFullscreen
);
139 #if defined(HAVE_XRANDR) && HAVE_XRANDR
140 X11Utils::XRRConfiguration
*m_XRRConfig
;
145 wxAuiToolBar
*m_ToolBar
, *m_ToolBarDebug
, *m_ToolBarAui
;
146 long NOTEBOOK_STYLE
, TOOLBAR_STYLE
;
147 int iLeftWidth
[2], iMidWidth
[2];
148 bool bFloatWindow
[IDM_VIDEOWINDOW
- IDM_LOGWINDOW
+ 1];
151 wxWindow
* GetNotebookPageFromId(wxWindowID Id
);
152 wxAuiNotebook
* GetNotebookFromId(u32
);
153 int GetNotebookCount();
154 int Limit(int,int,int);
155 int PercentageToPixels(int,int);
156 int PixelsToPercentage(int,int);
157 wxString
GetMenuLabel(int Id
);
160 void AddRemoveBlankPage();
161 void OnNotebookPageClose(wxAuiNotebookEvent
& event
);
162 void OnAllowNotebookDnD(wxAuiNotebookEvent
& event
);
163 void OnNotebookPageChanged(wxAuiNotebookEvent
& event
);
164 void OnFloatWindow(wxCommandEvent
& event
);
165 void ToggleFloatWindow(int Id
);
166 void OnTab(wxAuiNotebookEvent
& event
);
167 int GetNotebookAffiliation(wxWindowID Id
);
169 void ShowAllNotebooks(bool Window
= false);
170 void HideAllNotebooks(bool Window
= false);
171 void CloseAllNotebooks();
172 void DoAddPage(wxWindow
*, int, bool);
173 void DoRemovePage(wxWindow
*, bool Hide
= true);
174 void DoRemovePageId(wxWindowID Id
, bool bHide
, bool bDestroy
);
176 void SetSimplePaneSize();
178 void ResetToolbarStyle();
179 void TogglePaneStyle(bool On
, int EventId
);
180 void ToggleNotebookStyle(bool On
, long Style
);
181 void ResizeConsole();
183 void DoUnfloatPage(int Id
);
184 void OnFloatingPageClosed(wxCloseEvent
& event
);
185 void OnFloatingPageSize(wxSizeEvent
& event
);
186 void DoFloatNotebookPage(wxWindowID Id
);
187 wxFrame
* CreateParentFrame(wxWindowID Id
= wxID_ANY
, const wxString
& title
= wxT(""), wxWindow
* = NULL
);
188 // User perspectives. Should find a way to make these private.
192 wxString Perspective
;
193 std::vector
<int> Width
, Height
;
195 std::vector
<SPerspectives
> Perspectives
;
196 wxString AuiFullscreen
, AuiCurrent
;
197 wxArrayString AuiPerspective
;
198 u32 ActivePerspective
;
203 void OnPaneClose(wxAuiManagerEvent
& evt
);
205 void DoLoadPerspective();
206 void OnDropDownToolbarSelect(wxCommandEvent
& event
);
207 void OnDropDownSettingsToolbar(wxAuiToolBarEvent
& event
);
208 void OnDropDownToolbarItem(wxAuiToolBarEvent
& event
);
209 void OnSelectPerspective(wxCommandEvent
& event
);
212 wxStatusBar
* m_pStatusBar
;
213 wxBoxSizer
* sizerPanel
;
214 wxBoxSizer
* sizerFrame
;
215 CGameListCtrl
* m_GameListCtrl
;
217 CRenderFrame
* m_RenderFrame
;
218 wxPanel
* m_RenderParent
;
219 wxToolBarToolBase
* m_ToolPlay
;
220 CLogWindow
* m_LogWindow
;
226 bool m_bControlsCreated
;
228 char newDiscpath
[2048];
229 wxMessageDialog
*m_StopDlg
;
231 std::vector
<std::string
> drives
;
243 Toolbar_PluginOptions
,
261 wxBitmap m_Bitmaps
[EToolbar_Max
];
262 wxBitmap m_BitmapsMenu
[EToolbar_Max
];
264 void PopulateToolbar(wxAuiToolBar
* toolBar
);
265 void PopulateToolbarAui(wxAuiToolBar
* toolBar
);
266 void RecreateToolbar();
268 wxAuiNotebook
*CreateEmptyNotebook();
271 // Override window proc for tricks like screensaver disabling
272 WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
275 void OnQuit(wxCommandEvent
& event
);
276 void OnHelp(wxCommandEvent
& event
);
277 void OnToolBar(wxCommandEvent
& event
);
278 void OnAuiToolBar(wxAuiToolBarEvent
& event
);
280 void OnOpen(wxCommandEvent
& event
); // File menu
281 void DoOpen(bool Boot
);
282 void OnRefresh(wxCommandEvent
& event
);
283 void OnBrowse(wxCommandEvent
& event
);
284 void OnBootDrive(wxCommandEvent
& event
);
286 void OnPlay(wxCommandEvent
& event
); // Emulation
287 void OnStop(wxCommandEvent
& event
);
288 void OnReset(wxCommandEvent
& event
);
289 void OnRecord(wxCommandEvent
& event
);
290 void OnPlayRecording(wxCommandEvent
& event
);
291 void OnChangeDisc(wxCommandEvent
& event
);
292 void OnScreenshot(wxCommandEvent
& event
);
293 void OnActive(wxActivateEvent
& event
);
294 void OnClose(wxCloseEvent
&event
);
295 void OnLoadState(wxCommandEvent
& event
);
296 void OnSaveState(wxCommandEvent
& event
);
297 void OnLoadStateFromFile(wxCommandEvent
& event
);
298 void OnSaveStateToFile(wxCommandEvent
& event
);
299 void OnLoadLastState(wxCommandEvent
& event
);
300 void OnUndoLoadState(wxCommandEvent
& event
);
301 void OnUndoSaveState(wxCommandEvent
& event
);
303 void OnFrameSkip(wxCommandEvent
& event
);
304 void OnFrameStep(wxCommandEvent
& event
);
306 void OnConfigMain(wxCommandEvent
& event
); // Options
307 void OnPluginGFX(wxCommandEvent
& event
);
308 void OnPluginDSP(wxCommandEvent
& event
);
309 void OnPluginPAD(wxCommandEvent
& event
);
310 void OnPluginWiimote(wxCommandEvent
& event
);
312 void OnToggleFullscreen(wxCommandEvent
& event
);
313 void OnToggleDualCore(wxCommandEvent
& event
);
314 void OnToggleSkipIdle(wxCommandEvent
& event
);
315 void OnToggleThrottle(wxCommandEvent
& event
);
316 void OnManagerResize(wxAuiManagerEvent
& event
);
317 void OnMove(wxMoveEvent
& event
);
318 void OnResize(wxSizeEvent
& event
);
319 void OnToggleToolbar(wxCommandEvent
& event
);
320 void DoToggleToolbar(bool);
321 void OnToggleStatusbar(wxCommandEvent
& event
);
322 void OnToggleLogWindow(wxCommandEvent
& event
);
323 void OnToggleConsole(wxCommandEvent
& event
);
324 void OnKeyDown(wxKeyEvent
& event
);
325 void OnKeyUp(wxKeyEvent
& event
);
327 void OnHostMessage(wxCommandEvent
& event
);
329 void OnMemcard(wxCommandEvent
& event
); // Misc
330 void OnImportSave(wxCommandEvent
& event
);
331 void OnOpenLuaWindow(wxCommandEvent
& event
);
333 void OnNetPlay(wxCommandEvent
& event
);
335 void OnShow_CheatsWindow(wxCommandEvent
& event
);
336 void OnLoadWiiMenu(wxCommandEvent
& event
);
337 void OnConnectWiimote(wxCommandEvent
& event
);
338 void GameListChanged(wxCommandEvent
& event
);
340 void OnGameListCtrl_ItemActivated(wxListEvent
& event
);
341 void OnRenderParentResize(wxSizeEvent
& event
);
342 bool RendererIsFullscreen();
343 void StartGame(const std::string
& filename
);
347 wxMenuItem
* m_pSubMenuDrive
;
350 wxMenuItem
* m_pSubMenuLoad
;
351 wxMenuItem
* m_pSubMenuSave
;
352 wxMenuItem
* m_pSubMenuFrameSkipping
;
355 // Used to process command events
356 void OnTimer(wxTimerEvent
& WXUNUSED(event
));
361 DECLARE_EVENT_TABLE();