X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e55ad60e195f1007db921b2a73a3cac98ed9df65..b75867a61bad7efdce7ab11963a3672ce78a1e35:/src/gtk/accel.cpp?ds=inline diff --git a/src/gtk/accel.cpp b/src/gtk/accel.cpp index 52949c26ea..b15ece7379 100644 --- a/src/gtk/accel.cpp +++ b/src/gtk/accel.cpp @@ -2,7 +2,7 @@ // Name: accel.cpp // Purpose: // Author: Robert Roebling -// Id: +// Id: $id$ // Copyright: (c) 1998 Robert Roebling // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -15,22 +15,29 @@ #include +#ifdef __WXDEBUG__ +#ifdef NULL +#undef NULL +#endif +#define NULL ((void*)0L) +#endif + //----------------------------------------------------------------------------- // wxAcceleratorTable //----------------------------------------------------------------------------- class wxAccelRefData: public wxObjectRefData { - public: +public: - wxAccelRefData(void); + wxAccelRefData(void); - wxList m_accels; + wxList m_accels; }; wxAccelRefData::wxAccelRefData(void) { - m_accels.DeleteContents( TRUE ); + m_accels.DeleteContents( TRUE ); } //----------------------------------------------------------------------------- @@ -45,15 +52,16 @@ 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 +70,27 @@ 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(); - } + 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; + return -1; }