Merge r3999 to trunk, updates #566.
Also, 4000 GET. Originally committed to SVN as r4000.
This commit is contained in:
parent
80fdea74e6
commit
f1fa69d528
2 changed files with 23 additions and 68 deletions
|
@ -1063,7 +1063,7 @@ void DialogOptions::OnEditHotkey(wxCommandEvent &event) {
|
||||||
int oldFlags = curKey->flags;
|
int oldFlags = curKey->flags;
|
||||||
|
|
||||||
// Open dialog
|
// Open dialog
|
||||||
DialogInputHotkey input(curKey,Shortcuts->GetItemText(sel),Shortcuts);
|
DialogInputHotkey input(this, curKey, Shortcuts->GetItemText(sel), Shortcuts);
|
||||||
input.ShowModal();
|
input.ShowModal();
|
||||||
|
|
||||||
// Update stuff if it changed
|
// Update stuff if it changed
|
||||||
|
@ -1160,44 +1160,31 @@ void DialogOptions::OnDefaultAllHotkey(wxCommandEvent &event) {
|
||||||
/// @param name
|
/// @param name
|
||||||
/// @param shorts
|
/// @param shorts
|
||||||
///
|
///
|
||||||
DialogInputHotkey::DialogInputHotkey(HotkeyType *_key,wxString name,wxListView *shorts)
|
DialogInputHotkey::DialogInputHotkey(wxWindow *parent, HotkeyType *_key, wxString name, wxListView *shorts)
|
||||||
: wxDialog(NULL, -1, _("Press Key"), wxDefaultPosition, wxSize(200,50), wxCAPTION | wxWANTS_CHARS , _T("Press key"))
|
: wxDialog(parent, -1, _("Press Key"), wxDefaultPosition, wxSize(200,50), wxCAPTION | wxWANTS_CHARS , _T("Press key"))
|
||||||
{
|
{
|
||||||
// Key
|
// Key
|
||||||
key = _key;
|
key = _key;
|
||||||
shortcuts = shorts;
|
shortcuts = shorts;
|
||||||
|
|
||||||
// Text
|
wxButton *cancel_button = new wxButton(this, wxID_CANCEL);
|
||||||
wxStaticText *text = new wxStaticText(this,-1,wxString::Format(_("Press key to bind to \"%s\" or Esc to cancel."), name.c_str()));
|
cancel_button->Connect(wxEVT_KEY_DOWN, (wxObjectEventFunction)&DialogInputHotkey::OnKeyDown, 0, this);
|
||||||
|
|
||||||
// Key capturer
|
|
||||||
capture = new CaptureKey(this);
|
|
||||||
|
|
||||||
// Main sizer
|
// Main sizer
|
||||||
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
MainSizer->Add(text,1,wxALL,5);
|
MainSizer->Add(new wxStaticText(this,-1,wxString::Format(_("Press key to bind to \"%s\" or Esc to cancel."), name.c_str())), 0, wxALL, 12);
|
||||||
|
MainSizer->Add(cancel_button, 0, wxALIGN_CENTER|wxALL&~wxTOP, 12);
|
||||||
MainSizer->SetSizeHints(this);
|
MainSizer->SetSizeHints(this);
|
||||||
SetSizer(MainSizer);
|
SetSizer(MainSizer);
|
||||||
|
CentreOnParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Capturer constructor
|
|
||||||
/// @param _parent
|
|
||||||
///
|
|
||||||
CaptureKey::CaptureKey(DialogInputHotkey *_parent)
|
|
||||||
: wxTextCtrl(_parent,-1,_T(""),wxDefaultPosition,wxSize(0,0),wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB)
|
|
||||||
{
|
|
||||||
parent = _parent;
|
|
||||||
SetFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// Input event table
|
// Input event table
|
||||||
BEGIN_EVENT_TABLE(CaptureKey,wxTextCtrl)
|
BEGIN_EVENT_TABLE(DialogInputHotkey,wxDialog)
|
||||||
EVT_KEY_DOWN(CaptureKey::OnKeyDown)
|
EVT_KEY_DOWN(DialogInputHotkey::OnKeyDown)
|
||||||
EVT_KILL_FOCUS(CaptureKey::OnLoseFocus)
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1206,10 +1193,10 @@ END_EVENT_TABLE()
|
||||||
/// @param event
|
/// @param event
|
||||||
/// @return
|
/// @return
|
||||||
///
|
///
|
||||||
void CaptureKey::OnKeyDown(wxKeyEvent &event) {
|
void DialogInputHotkey::OnKeyDown(wxKeyEvent &event) {
|
||||||
// Get key
|
// Get key
|
||||||
int keycode = event.GetKeyCode();
|
int keycode = event.GetKeyCode();
|
||||||
if (keycode == WXK_ESCAPE) parent->EndModal(0);
|
if (keycode == WXK_ESCAPE) EndModal(0);
|
||||||
else if (keycode != WXK_SHIFT && keycode != WXK_CONTROL && keycode != WXK_ALT) {
|
else if (keycode != WXK_SHIFT && keycode != WXK_CONTROL && keycode != WXK_ALT) {
|
||||||
// Get modifier
|
// Get modifier
|
||||||
int mod = 0;
|
int mod = 0;
|
||||||
|
@ -1226,32 +1213,22 @@ void CaptureKey::OnKeyDown(wxKeyEvent &event) {
|
||||||
if (dup) {
|
if (dup) {
|
||||||
int result = wxMessageBox(wxString::Format(_("The hotkey %s is already mapped to %s. If you proceed, that hotkey will be cleared. Proceed?"),dup->GetText().c_str(),dup->origName.c_str()),_("Hotkey conflict"),wxYES_NO | wxICON_EXCLAMATION);
|
int result = wxMessageBox(wxString::Format(_("The hotkey %s is already mapped to %s. If you proceed, that hotkey will be cleared. Proceed?"),dup->GetText().c_str(),dup->origName.c_str()),_("Hotkey conflict"),wxYES_NO | wxICON_EXCLAMATION);
|
||||||
if (result == wxNO) {
|
if (result == wxNO) {
|
||||||
parent->EndModal(0);
|
EndModal(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dup->keycode = 0;
|
dup->keycode = 0;
|
||||||
dup->flags = 0;
|
dup->flags = 0;
|
||||||
int item = parent->shortcuts->FindItem(-1,wxPtrToUInt(dup));
|
int item = shortcuts->FindItem(-1,wxPtrToUInt(dup));
|
||||||
if (item != -1) parent->shortcuts->SetItem(item,1,dup->GetText());
|
if (item != -1) shortcuts->SetItem(item,1,dup->GetText());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set keycode
|
// Set keycode
|
||||||
parent->key->keycode = keycode;
|
key->keycode = keycode;
|
||||||
parent->key->flags = mod;
|
key->flags = mod;
|
||||||
|
|
||||||
// End dialogue
|
// End dialogue
|
||||||
parent->EndModal(0);
|
EndModal(0);
|
||||||
}
|
}
|
||||||
else event.Skip();
|
else event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Keep focus
|
|
||||||
/// @param event
|
|
||||||
///
|
|
||||||
void CaptureKey::OnLoseFocus(wxFocusEvent &event) {
|
|
||||||
SetFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -161,26 +161,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
/// @class CaptureKey
|
|
||||||
/// @brief DOCME
|
|
||||||
///
|
|
||||||
/// DOCME
|
|
||||||
class CaptureKey : public wxTextCtrl {
|
|
||||||
private:
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
DialogInputHotkey *parent;
|
|
||||||
void OnKeyDown(wxKeyEvent &event);
|
|
||||||
void OnLoseFocus(wxFocusEvent &event);
|
|
||||||
|
|
||||||
public:
|
|
||||||
CaptureKey(DialogInputHotkey *parent);
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
/// @class DialogInputHotkey
|
/// @class DialogInputHotkey
|
||||||
|
@ -188,12 +168,6 @@ public:
|
||||||
///
|
///
|
||||||
/// DOCME
|
/// DOCME
|
||||||
class DialogInputHotkey : public wxDialog {
|
class DialogInputHotkey : public wxDialog {
|
||||||
friend class CaptureKey;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
CaptureKey *capture;
|
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
HotkeyType *key;
|
HotkeyType *key;
|
||||||
|
@ -201,8 +175,12 @@ private:
|
||||||
/// DOCME
|
/// DOCME
|
||||||
wxListView *shortcuts;
|
wxListView *shortcuts;
|
||||||
|
|
||||||
|
void OnKeyDown(wxKeyEvent &event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogInputHotkey(HotkeyType *key,wxString name,wxListView *Shortcuts);
|
DialogInputHotkey(wxWindow *parent, HotkeyType *key, wxString name, wxListView *Shortcuts);
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue