/[pcsx2_0.9.7]/trunk/pcsx2/gui/Panels/MemoryCardPanels.h
ViewVC logotype

Contents of /trunk/pcsx2/gui/Panels/MemoryCardPanels.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 2 months ago) by william
File MIME type: text/plain
File size: 6985 byte(s)
re-commit (had local access denied errors when committing)
1 /* PCSX2 - PS2 Emulator for PCs
2 * Copyright (C) 2002-2010 PCSX2 Dev Team
3 *
4 * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5 * of the GNU Lesser General Public License as published by the Free Software Found-
6 * ation, either version 3 of the License, or (at your option) any later version.
7 *
8 * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10 * PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with PCSX2.
13 * If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #pragma once
17
18 #include "AppCommon.h"
19
20 #include <wx/dnd.h>
21 #include <wx/listctrl.h>
22
23 struct ListViewColumnInfo
24 {
25 const wxChar* name;
26 int width;
27 wxListColumnFormat align;
28 };
29
30 // --------------------------------------------------------------------------------------
31 // McdListItem / IMcdList
32 // --------------------------------------------------------------------------------------
33 struct McdListItem
34 {
35 bool IsPresent;
36 bool IsEnabled;
37 bool IsFormatted;
38
39 uint SizeInMB; // size, in megabytes!
40 wxDateTime DateCreated;
41 wxDateTime DateModified;
42
43 int Slot;
44
45 wxFileName Filename; // full pathname (optional)
46
47 McdListItem()
48 {
49 //Port = -1;
50 Slot = -1;
51
52 IsPresent = false;
53 IsEnabled = false;
54 }
55
56 bool IsMultitapSlot() const;
57 uint GetMtapPort() const;
58 uint GetMtapSlot() const;
59
60 bool operator==( const McdListItem& right ) const;
61 bool operator!=( const McdListItem& right ) const;
62 };
63
64 typedef std::vector<McdListItem> McdList;
65
66 class IMcdList
67 {
68 public:
69 virtual void RefreshMcds() const=0;
70 virtual int GetLength() const=0;
71 virtual const McdListItem& GetCard( int idx ) const=0;
72 virtual McdListItem& GetCard( int idx )=0;
73
74 virtual wxDirName GetMcdPath() const=0;
75 };
76
77 // --------------------------------------------------------------------------------------
78 // BaseMcdListView
79 // --------------------------------------------------------------------------------------
80 class BaseMcdListView : public wxListView
81 {
82 typedef wxListView _parent;
83
84 protected:
85 const IMcdList* m_CardProvider;
86
87 // specifies the target of a drag&drop operation
88 int m_TargetedItem;
89
90 public:
91 virtual ~BaseMcdListView() throw() { }
92 BaseMcdListView( wxWindow* parent )
93 : _parent( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_VIRTUAL )
94 {
95 m_CardProvider = NULL;
96 }
97
98 virtual void SetCardCount( int length )=0;
99 virtual void SetMcdProvider( IMcdList* face );
100
101 virtual void LoadSaveColumns( IniInterface& ini );
102 virtual const ListViewColumnInfo& GetDefaultColumnInfo( uint idx ) const=0;
103
104 virtual const IMcdList& GetMcdProvider() const;
105 virtual void SetTargetedItem( int sel );
106 };
107
108 // --------------------------------------------------------------------------------------
109 // MemoryCardListView_Simple
110 // --------------------------------------------------------------------------------------
111 class MemoryCardListView_Simple : public BaseMcdListView
112 {
113 typedef BaseMcdListView _parent;
114
115 public:
116 virtual ~MemoryCardListView_Simple() throw() { }
117 MemoryCardListView_Simple( wxWindow* parent );
118
119 void CreateColumns();
120
121 virtual void SetCardCount( int length );
122 virtual const ListViewColumnInfo& GetDefaultColumnInfo( uint idx ) const;
123
124 protected:
125 // Overrides for wxLC_VIRTUAL
126 virtual wxString OnGetItemText(long item, long column) const;
127 virtual int OnGetItemImage(long item) const;
128 virtual int OnGetItemColumnImage(long item, long column) const;
129 virtual wxListItemAttr *OnGetItemAttr(long item) const;
130 };
131
132
133 namespace Panels
134 {
135 // --------------------------------------------------------------------------------------
136 // BaseMcdListPanel
137 // --------------------------------------------------------------------------------------
138 class BaseMcdListPanel
139 : public BaseSelectorPanel
140 , public wxFileDropTarget
141 , public IMcdList // derived classes need to implement this
142 {
143 typedef BaseSelectorPanel _parent;
144
145 protected:
146 DirPickerPanel* m_FolderPicker;
147 BaseMcdListView* m_listview;
148 wxButton* m_btn_Refresh;
149
150 wxBoxSizer* s_leftside_buttons;
151 wxBoxSizer* s_rightside_buttons;
152
153 bool m_MultitapEnabled[2];
154
155 virtual void RefreshMcds() const;
156
157 virtual wxDirName GetMcdPath() const
158 {
159 pxAssume(m_FolderPicker);
160 return m_FolderPicker->GetPath();
161 }
162
163 public:
164 virtual ~BaseMcdListPanel() throw() {}
165 BaseMcdListPanel( wxWindow* parent );
166
167 void CreateLayout();
168 void SetMultitapEnabled( uint port, bool enabled )
169 {
170 m_MultitapEnabled[port] = enabled;
171 RefreshMcds();
172 }
173
174 virtual void Apply();
175 virtual void AppStatusEvent_OnSettingsApplied();
176 };
177
178 // --------------------------------------------------------------------------------------
179 // MemoryCardListPanel_Simple
180 // --------------------------------------------------------------------------------------
181 class MemoryCardListPanel_Simple
182 : public BaseMcdListPanel
183 {
184 typedef BaseMcdListPanel _parent;
185
186 protected:
187 McdListItem m_Cards[8];
188
189 // Doubles as Create and Delete buttons
190 wxButton* m_button_Create;
191
192 // Doubles as Mount and Unmount buttons
193 wxButton* m_button_Mount;
194
195 public:
196 virtual ~MemoryCardListPanel_Simple() throw() {}
197 MemoryCardListPanel_Simple( wxWindow* parent );
198
199 void UpdateUI();
200
201 // Interface Implementation for IMcdList
202 virtual int GetLength() const;
203
204 virtual const McdListItem& GetCard( int idx ) const;
205 virtual McdListItem& GetCard( int idx );
206
207 protected:
208 void OnCreateCard(wxCommandEvent& evt);
209 void OnMountCard(wxCommandEvent& evt);
210 void OnRelocateCard(wxCommandEvent& evt);
211
212 void OnListDrag(wxListEvent& evt);
213 void OnListSelectionChanged(wxListEvent& evt);
214 void OnOpenItemContextMenu(wxListEvent& evt);
215
216 virtual bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filenames);
217
218 virtual void Apply();
219 virtual void AppStatusEvent_OnSettingsApplied();
220 virtual void DoRefresh();
221 virtual bool ValidateEnumerationStatus();
222 };
223
224 // --------------------------------------------------------------------------------------
225 // McdConfigPanel_Toggles / McdConfigPanel_Standard / McdConfigPanel_Multitap
226 // --------------------------------------------------------------------------------------
227 class McdConfigPanel_Toggles : public BaseApplicableConfigPanel
228 {
229 typedef BaseApplicableConfigPanel _parent;
230
231 protected:
232 pxCheckBox* m_check_Multitap[2];
233 pxCheckBox* m_check_Ejection;
234 pxCheckBox* m_check_SavestateBackup;
235
236 public:
237 McdConfigPanel_Toggles( wxWindow* parent );
238 virtual ~McdConfigPanel_Toggles() throw() { }
239 void Apply();
240
241 protected:
242 void AppStatusEvent_OnSettingsApplied();
243 void OnMultitapClicked();
244 };
245
246 };
247
248 extern bool EnumerateMemoryCard( McdListItem& dest, const wxFileName& filename );
249 //extern bool EnumerateMemoryCard( SimpleMcdItem& dest, const wxFileName& filename );

  ViewVC Help
Powered by ViewVC 1.1.22