5
5
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
6
6
*/
7
7
8
- #include " GOMidiListDialog .h"
8
+ #include " GOMidiObjectstDialog .h"
9
9
10
10
#include < wx/button.h>
11
11
#include < wx/sizer.h>
@@ -24,18 +24,18 @@ enum {
24
24
ID_BUTTON_LAST = ID_BUTTON + 2 ,
25
25
};
26
26
27
- BEGIN_EVENT_TABLE (GOMidiListDialog , GOSimpleDialog)
28
- EVT_GRID_CMD_SELECT_CELL(ID_LIST, GOMidiListDialog::OnObjectClick )
29
- EVT_GRID_CMD_CELL_LEFT_DCLICK(ID_LIST, GOMidiListDialog ::OnObjectDoubleClick)
30
- EVT_BUTTON(ID_STATUS, GOMidiListDialog::OnStatus )
31
- EVT_BUTTON(ID_EDIT, GOMidiListDialog::OnEdit )
27
+ BEGIN_EVENT_TABLE (GOMidiObjectsDialog , GOSimpleDialog)
28
+ EVT_GRID_CMD_SELECT_CELL(ID_LIST, GOMidiObjectsDialog::OnSelectCell )
29
+ EVT_GRID_CMD_CELL_LEFT_DCLICK(ID_LIST, GOMidiObjectsDialog ::OnObjectDoubleClick)
30
+ EVT_BUTTON(ID_EDIT, GOMidiObjectsDialog::OnConfigureButton )
31
+ EVT_BUTTON(ID_STATUS, GOMidiObjectsDialog::OnStatusButton )
32
32
EVT_COMMAND_RANGE(
33
- ID_BUTTON, ID_BUTTON_LAST, wxEVT_BUTTON, GOMidiListDialog::OnButton )
33
+ ID_BUTTON, ID_BUTTON_LAST, wxEVT_BUTTON, GOMidiObjectsDialog::OnActionButton )
34
34
END_EVENT_TABLE()
35
35
36
36
enum { GRID_COL_TYPE = 0 , GRID_COL_ELEMENT };
37
37
38
- GOMidiListDialog::GOMidiListDialog (
38
+ GOMidiObjectsDialog::GOMidiObjectsDialog (
39
39
GODocumentBase *doc,
40
40
wxWindow *parent,
41
41
GODialogSizeSet &dialogSizes,
@@ -53,33 +53,34 @@ GOMidiListDialog::GOMidiListDialog(
53
53
wxBoxSizer *topSizer = new wxBoxSizer (wxVERTICAL);
54
54
topSizer->AddSpacer (5 );
55
55
56
- m_Objects = new GOGrid (this , ID_LIST, wxDefaultPosition, wxSize (250 , 200 ));
57
- m_Objects->CreateGrid (0 , 2 , wxGrid::wxGridSelectRows);
58
- m_Objects->HideRowLabels ();
59
- m_Objects->EnableEditing (false );
60
- m_Objects->SetColLabelValue (GRID_COL_TYPE, _ (" Type" ));
61
- m_Objects->SetColLabelValue (GRID_COL_ELEMENT, _ (" Element" ));
62
- m_Objects->SetColSize (GRID_COL_TYPE, 100 );
63
- m_Objects->SetColSize (GRID_COL_ELEMENT, 100 );
56
+ m_ObjectsGrid
57
+ = new GOGrid (this , ID_LIST, wxDefaultPosition, wxSize (250 , 200 ));
58
+ m_ObjectsGrid->CreateGrid (0 , 2 , wxGrid::wxGridSelectRows);
59
+ m_ObjectsGrid->HideRowLabels ();
60
+ m_ObjectsGrid->EnableEditing (false );
61
+ m_ObjectsGrid->SetColLabelValue (GRID_COL_TYPE, _ (" Type" ));
62
+ m_ObjectsGrid->SetColLabelValue (GRID_COL_ELEMENT, _ (" Element" ));
63
+ m_ObjectsGrid->SetColSize (GRID_COL_TYPE, 100 );
64
+ m_ObjectsGrid->SetColSize (GRID_COL_ELEMENT, 100 );
64
65
65
- topSizer->Add (m_Objects , 1 , wxEXPAND | wxALL, 5 );
66
+ topSizer->Add (m_ObjectsGrid , 1 , wxEXPAND | wxALL, 5 );
66
67
67
68
wxBoxSizer *sizer = new wxBoxSizer (wxHORIZONTAL);
68
69
for (unsigned id = ID_BUTTON; id <= ID_BUTTON_LAST; id++) {
69
70
wxButton *button = new wxButton (this , id, wxEmptyString);
70
71
sizer->Add (button, 0 , id == ID_BUTTON ? wxRESERVE_SPACE_EVEN_IF_HIDDEN : 0 );
71
72
button->Hide ();
72
- m_Buttons .push_back (button);
73
+ m_ActionButtons .push_back (button);
73
74
}
74
75
topSizer->Add (sizer, 0 , wxALIGN_LEFT | wxALL, 1 );
75
76
76
77
wxBoxSizer *buttons = new wxBoxSizer (wxHORIZONTAL);
77
- m_Edit = new wxButton (this , ID_EDIT, _ (" C&onfigure..." ));
78
- m_Edit ->Disable ();
79
- buttons->Add (m_Edit );
80
- m_Status = new wxButton (this , ID_STATUS, _ (" &Status" ));
81
- m_Status ->Disable ();
82
- buttons->Add (m_Status );
78
+ m_ConfigureButton = new wxButton (this , ID_EDIT, _ (" C&onfigure..." ));
79
+ m_ConfigureButton ->Disable ();
80
+ buttons->Add (m_ConfigureButton );
81
+ m_StatusButton = new wxButton (this , ID_STATUS, _ (" &Status" ));
82
+ m_StatusButton ->Disable ();
83
+ buttons->Add (m_StatusButton );
83
84
topSizer->Add (buttons, 0 , wxALIGN_RIGHT | wxALL, 1 );
84
85
85
86
topSizer->AddSpacer (5 );
@@ -88,77 +89,70 @@ GOMidiListDialog::GOMidiListDialog(
88
89
89
90
static const wxString WX_GRID_MIDI_OBJECTS = wxT(" GridMidiObjects" );
90
91
91
- void GOMidiListDialog ::ApplyAdditionalSizes (
92
+ void GOMidiObjectsDialog ::ApplyAdditionalSizes (
92
93
const GOAdditionalSizeKeeper &sizeKeeper) {
93
94
GOAdditionalSizeKeeperProxy proxyMidiObjects (
94
95
const_cast <GOAdditionalSizeKeeper &>(sizeKeeper), WX_GRID_MIDI_OBJECTS);
95
96
96
- m_Objects ->ApplyColumnSizes (proxyMidiObjects);
97
+ m_ObjectsGrid ->ApplyColumnSizes (proxyMidiObjects);
97
98
}
98
99
99
- void GOMidiListDialog ::CaptureAdditionalSizes (
100
+ void GOMidiObjectsDialog ::CaptureAdditionalSizes (
100
101
GOAdditionalSizeKeeper &sizeKeeper) const {
101
102
GOAdditionalSizeKeeperProxy proxyMidiObjects (
102
103
sizeKeeper, WX_GRID_MIDI_OBJECTS);
103
104
104
- m_Objects ->CaptureColumnSizes (proxyMidiObjects);
105
+ m_ObjectsGrid ->CaptureColumnSizes (proxyMidiObjects);
105
106
}
106
107
107
- bool GOMidiListDialog ::TransferDataToWindow () {
108
- unsigned oldRowCnt = m_Objects ->GetNumberRows ();
108
+ bool GOMidiObjectsDialog ::TransferDataToWindow () {
109
+ unsigned oldRowCnt = m_ObjectsGrid ->GetNumberRows ();
109
110
unsigned newRowCnt = r_MidiObjects.size ();
110
111
111
112
if (oldRowCnt)
112
- m_Objects ->DeleteRows (0 , oldRowCnt);
113
+ m_ObjectsGrid ->DeleteRows (0 , oldRowCnt);
113
114
114
- m_Objects ->AppendRows (newRowCnt);
115
+ m_ObjectsGrid ->AppendRows (newRowCnt);
115
116
for (unsigned i = 0 ; i < newRowCnt; i++) {
116
117
GOMidiObject *obj = r_MidiObjects[i];
117
118
118
- m_Objects ->SetCellValue (i, GRID_COL_TYPE, obj->GetMidiTypeName ());
119
- m_Objects ->SetCellValue (i, GRID_COL_ELEMENT, obj->GetName ());
119
+ m_ObjectsGrid ->SetCellValue (i, GRID_COL_TYPE, obj->GetMidiTypeName ());
120
+ m_ObjectsGrid ->SetCellValue (i, GRID_COL_ELEMENT, obj->GetName ());
120
121
}
121
122
return true ;
122
123
}
123
124
124
- GOMidiObject *GOMidiListDialog ::GetSelectedObject () const {
125
- return r_MidiObjects[m_Objects ->GetGridCursorRow ()];
125
+ GOMidiObject *GOMidiObjectsDialog ::GetSelectedObject () const {
126
+ return r_MidiObjects[m_ObjectsGrid ->GetGridCursorRow ()];
126
127
}
127
128
128
- void GOMidiListDialog::OnButton (wxCommandEvent &event) {
129
- GOMidiObject *obj = GetSelectedObject ();
130
- obj->TriggerElementActions (event.GetId () - ID_BUTTON);
129
+ void GOMidiObjectsDialog::ConfigureSelectedObject () {
130
+ GetSelectedObject ()->ShowConfigDialog ();
131
131
}
132
132
133
- void GOMidiListDialog::OnObjectClick (wxGridEvent &event) {
133
+ void GOMidiObjectsDialog::OnSelectCell (wxGridEvent &event) {
134
134
int index = event.GetRow ();
135
135
bool isAnySelected = index >= 0 ;
136
136
137
- m_Edit ->Enable (isAnySelected);
138
- m_Status ->Enable (isAnySelected);
137
+ m_ConfigureButton ->Enable (isAnySelected);
138
+ m_StatusButton ->Enable (isAnySelected);
139
139
if (isAnySelected) {
140
- m_Objects ->SelectRow (index );
140
+ m_ObjectsGrid ->SelectRow (index );
141
141
GOMidiObject *obj = r_MidiObjects[index ];
142
142
std::vector<wxString> actions = obj->GetElementActions ();
143
143
144
- for (unsigned i = 0 ; i < m_Buttons .size (); i++)
144
+ for (unsigned i = 0 ; i < m_ActionButtons .size (); i++)
145
145
if (i < actions.size ()) {
146
- m_Buttons [i]->SetLabel (actions[i]);
147
- m_Buttons [i]->Show ();
146
+ m_ActionButtons [i]->SetLabel (actions[i]);
147
+ m_ActionButtons [i]->Show ();
148
148
} else
149
- m_Buttons [i]->Hide ();
149
+ m_ActionButtons [i]->Hide ();
150
150
}
151
151
Layout ();
152
152
event.StopPropagation ();
153
153
}
154
154
155
- void GOMidiListDialog::OnObjectDoubleClick (wxGridEvent &event) {
156
- GOMidiObject *obj = GetSelectedObject ();
157
-
158
- obj->ShowConfigDialog ();
159
- }
160
-
161
- void GOMidiListDialog::OnStatus (wxCommandEvent &event) {
155
+ void GOMidiObjectsDialog::OnStatusButton (wxCommandEvent &event) {
162
156
GOMidiObject *obj = GetSelectedObject ();
163
157
wxString status = obj->GetElementStatus ();
164
158
@@ -168,7 +162,7 @@ void GOMidiListDialog::OnStatus(wxCommandEvent &event) {
168
162
wxOK);
169
163
}
170
164
171
- void GOMidiListDialog::OnEdit (wxCommandEvent &event) {
172
- wxGridEvent listevent ;
173
- OnObjectDoubleClick (listevent );
165
+ void GOMidiObjectsDialog::OnActionButton (wxCommandEvent &event) {
166
+ GOMidiObject *obj = GetSelectedObject () ;
167
+ obj-> TriggerElementActions (event. GetId () - ID_BUTTON );
174
168
}
0 commit comments