X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b90c32b486407a69ed81e8991c2ec8a6e0602431..d3e780ecdf69233c872d51216eedbc64a1b6db25:/src/generic/accel.cpp diff --git a/src/generic/accel.cpp b/src/generic/accel.cpp index d99b55cea6..a50bed3218 100644 --- a/src/generic/accel.cpp +++ b/src/generic/accel.cpp @@ -16,7 +16,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "accel.h" #endif @@ -53,7 +53,20 @@ WX_DEFINE_LIST(wxAccelList); class wxAccelRefData : public wxObjectRefData { public: - wxAccelRefData() { m_accels.DeleteContents(TRUE); } + wxAccelRefData() + { + } + + wxAccelRefData(const wxAccelRefData& data) + : wxObjectRefData() + { + m_accels = data.m_accels; + } + + virtual ~wxAccelRefData() + { + WX_CLEAR_LIST(wxAccelList, m_accels); + } wxAccelList m_accels; }; @@ -61,6 +74,7 @@ public: // macro which can be used to access wxAccelRefData from wxAcceleratorTable #define M_ACCELDATA ((wxAccelRefData *)m_refData) + // ============================================================================ // implementation // ============================================================================ @@ -75,7 +89,7 @@ wxAcceleratorTable::wxAcceleratorTable() { } -wxAcceleratorTable::wxAcceleratorTable(int n, wxAcceleratorEntry entries[]) +wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]) { m_refData = new wxAccelRefData; @@ -108,6 +122,8 @@ bool wxAcceleratorTable::Ok() const void wxAcceleratorTable::Add(const wxAcceleratorEntry& entry) { + AllocExclusive(); + if ( !m_refData ) { m_refData = new wxAccelRefData; @@ -118,14 +134,17 @@ void wxAcceleratorTable::Add(const wxAcceleratorEntry& entry) void wxAcceleratorTable::Remove(const wxAcceleratorEntry& entry) { - wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst(); + AllocExclusive(); + + wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); while ( node ) { const wxAcceleratorEntry *entryCur = node->GetData(); if ( *entryCur == entry ) { - M_ACCELDATA->m_accels.DeleteNode(node); + delete node->GetData(); + M_ACCELDATA->m_accels.Erase(node); return; } @@ -149,7 +168,7 @@ wxAcceleratorTable::GetEntry(const wxKeyEvent& event) const return NULL; } - wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst(); + wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); while ( node ) { const wxAcceleratorEntry *entry = node->GetData(); @@ -162,8 +181,7 @@ wxAcceleratorTable::GetEntry(const wxKeyEvent& event) const // now check flags if ( (((flags & wxACCEL_CTRL) != 0) == event.ControlDown()) && (((flags & wxACCEL_SHIFT) != 0) == event.ShiftDown()) && - (((flags & wxACCEL_ALT) != 0) == - (event.AltDown() || event.MetaDown())) ) + (((flags & wxACCEL_ALT) != 0) == event.AltDown()) ) { return entry; } @@ -189,5 +207,15 @@ int wxAcceleratorTable::GetCommand(const wxKeyEvent& event) const return entry ? entry->GetCommand() : -1; } +wxObjectRefData *wxAcceleratorTable::CreateRefData() const +{ + return new wxAccelRefData; +} + +wxObjectRefData *wxAcceleratorTable::CloneRefData(const wxObjectRefData *data) const +{ + return new wxAccelRefData(*(wxAccelRefData *)data); +} + #endif // wxUSE_ACCEL