X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4bb6408c2631988fab9925014c6619358bf867de..abd474ea63667f727940a009cc3e0b23ba9f418f:/src/motif/accel.cpp diff --git a/src/motif/accel.cpp b/src/motif/accel.cpp index 463102260b..d66f03b8af 100644 --- a/src/motif/accel.cpp +++ b/src/motif/accel.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: accel.cpp +// Name: src/motif/accel.cpp // Purpose: wxAcceleratorTable // Author: Julian Smart // Modified by: @@ -9,85 +9,108 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "accel.h" -#endif +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" -#include "wx/setup.h" #include "wx/accel.h" -#include "wx/string.h" -#if !USE_SHARED_LIBRARIES -IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) +#ifndef WX_PRECOMP + #include "wx/string.h" + #include "wx/utils.h" #endif +#include + +IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject) + class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData { - friend class WXDLLEXPORT wxAcceleratorTable; + friend class wxAcceleratorTable; public: wxAcceleratorRefData(); - ~wxAcceleratorRefData(); + virtual ~wxAcceleratorRefData(); -/* TODO: implementation - inline HACCEL GetHACCEL() const { return m_hAccel; } -protected: - HACCEL m_hAccel; -*/ +public: + int m_count; + wxAcceleratorEntry* m_entries; }; #define M_ACCELDATA ((wxAcceleratorRefData *)m_refData) wxAcceleratorRefData::wxAcceleratorRefData() { - // TODO -/* - HACCEL m_hAccel; -*/ + m_count = 0; + m_entries = NULL; } wxAcceleratorRefData::~wxAcceleratorRefData() { -/* - if (m_hAccel) - { - DestroyAcceleratorTable((HACCEL) m_hAccel); - } - m_hAccel = 0 ; -*/ + wxDELETEA(m_entries); + m_count = 0; } wxAcceleratorTable::wxAcceleratorTable() { - m_refData = NULL; + m_refData = NULL; } wxAcceleratorTable::~wxAcceleratorTable() { + // Data deleted in ~wxObject } // Load from .rc resource -wxAcceleratorTable::wxAcceleratorTable(const wxString& resource) +wxAcceleratorTable::wxAcceleratorTable(const wxString& WXUNUSED(resource)) { m_refData = new wxAcceleratorRefData; - -/* TODO: load acelerator from resource, if appropriate for your platform - M_ACCELDATA->m_hAccel = hAccel; - M_ACCELDATA->m_ok = (hAccel != 0); -*/ } // Create from an array -wxAcceleratorTable::wxAcceleratorTable(int n, wxAcceleratorEntry entries[]) +wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]) { - m_refData = new wxAcceleratorRefData; + wxAcceleratorRefData* data = new wxAcceleratorRefData; + m_refData = data; + + data->m_count = n; + data->m_entries = new wxAcceleratorEntry[n]; + int i; + for (i = 0; i < n; i++) + data->m_entries[i] = entries[i]; -/* TODO: create table from entries - */ } -bool wxAcceleratorTable::Ok() const +bool wxAcceleratorTable::IsOk() const { - // TODO - return FALSE; + return (m_refData != NULL); } +int wxAcceleratorTable::GetCount() const +{ + return M_ACCELDATA->m_count; +} + +wxAcceleratorEntry* wxAcceleratorTable::GetEntries() const +{ + return M_ACCELDATA->m_entries; +} + +// Implementation use only +bool wxAcceleratorEntry::MatchesEvent(const wxKeyEvent& event) const +{ + bool eventAltDown = event.AltDown(); + bool eventCtrlDown = event.ControlDown(); + bool eventShiftDown = event.ShiftDown(); + int eventKeyCode = event.GetKeyCode(); + + bool accAltDown = ((GetFlags() & wxACCEL_ALT) == wxACCEL_ALT); + bool accCtrlDown = ((GetFlags() & wxACCEL_CTRL) == wxACCEL_CTRL); + bool accShiftDown = ((GetFlags() & wxACCEL_SHIFT) == wxACCEL_SHIFT); + int accKeyCode = GetKeyCode(); + int accKeyCode2 = GetKeyCode(); + if (wxIsascii(accKeyCode2)) + accKeyCode2 = wxTolower(accKeyCode2); + + return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) && + (eventShiftDown == accShiftDown) && + ((eventKeyCode == accKeyCode || eventKeyCode == accKeyCode2))) ; +}