X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/32e9da8bfaafe4f462f7473a7e11e3387847e121..e72b421324f29e199e3321245fa5a92136233a85:/src/gtk1/accel.cpp diff --git a/src/gtk1/accel.cpp b/src/gtk1/accel.cpp index e101decc7d..9b861acb20 100644 --- a/src/gtk1/accel.cpp +++ b/src/gtk1/accel.cpp @@ -2,9 +2,9 @@ // Name: accel.cpp // Purpose: // Author: Robert Roebling -// Id: $id$ +// Id: $id:$ // Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -13,6 +13,8 @@ #include "wx/accel.h" +#if wxUSE_ACCEL + #include //----------------------------------------------------------------------------- @@ -21,16 +23,15 @@ class wxAccelRefData: public wxObjectRefData { - public: - - wxAccelRefData(void); - +public: + wxAccelRefData(); + wxList m_accels; }; -wxAccelRefData::wxAccelRefData(void) +wxAccelRefData::wxAccelRefData() { - m_accels.DeleteContents( TRUE ); + m_accels.DeleteContents( TRUE ); } //----------------------------------------------------------------------------- @@ -38,22 +39,23 @@ wxAccelRefData::wxAccelRefData(void) #define M_ACCELDATA ((wxAccelRefData *)m_refData) IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable,wxObject) - + wxAcceleratorTable::wxAcceleratorTable() { } wxAcceleratorTable::wxAcceleratorTable( int n, wxAcceleratorEntry entries[] ) { - m_refData = new wxAccelRefData(); - for (int i = 0; i < n; i++) - { - int flag = entries[i].GetFlags(); - int keycode = entries[i].GetKeyCode(); - int command = entries[i].GetCommand(); - if ((keycode >= (int)'A') && (keycode <= (int)'Z')) keycode = (int)tolower( (char)keycode ); - M_ACCELDATA->m_accels.Append( new wxAcceleratorEntry( flag, keycode, command ) ); - } + m_refData = new wxAccelRefData(); + + for (int i = 0; i < n; i++) + { + int flag = entries[i].GetFlags(); + int keycode = entries[i].GetKeyCode(); + int command = entries[i].GetCommand(); + if ((keycode >= (int)'A') && (keycode <= (int)'Z')) keycode = (int)tolower( (char)keycode ); + M_ACCELDATA->m_accels.Append( new wxAcceleratorEntry( flag, keycode, command ) ); + } } wxAcceleratorTable::~wxAcceleratorTable() @@ -62,25 +64,28 @@ wxAcceleratorTable::~wxAcceleratorTable() bool wxAcceleratorTable::Ok() const { - return (m_refData != NULL); + return (m_refData != NULL); } int wxAcceleratorTable::GetCommand( wxKeyEvent &event ) { - if (!Ok()) return -1; - - wxNode *node = M_ACCELDATA->m_accels.First(); - while (node) - { - wxAcceleratorEntry *entry = (wxAcceleratorEntry*)node->Data(); - if ((event.m_keyCode == entry->GetKeyCode()) && - (((entry->GetFlags() & wxACCEL_CTRL) == 0) || event.ControlDown()) && - (((entry->GetFlags() & wxACCEL_SHIFT) == 0) || event.ShiftDown()) && - (((entry->GetFlags() & wxACCEL_ALT) == 0) || event.AltDown() || event.MetaDown())) - return entry->GetCommand(); - node = node->Next(); - } - - return -1; + if (!Ok()) return -1; + + wxNode *node = M_ACCELDATA->m_accels.First(); + while (node) + { + wxAcceleratorEntry *entry = (wxAcceleratorEntry*)node->Data(); + if ((event.m_keyCode == entry->GetKeyCode()) && + (((entry->GetFlags() & wxACCEL_CTRL) == 0) || event.ControlDown()) && + (((entry->GetFlags() & wxACCEL_SHIFT) == 0) || event.ShiftDown()) && + (((entry->GetFlags() & wxACCEL_ALT) == 0) || event.AltDown() || event.MetaDown())) + { + return entry->GetCommand(); + } + node = node->Next(); + } + + return -1; } +#endif