1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxAcceleratorTable
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
18 #include "wx/window.h"
21 #include "wx/os2/accel.h"
23 #include "wx/os2/private.h"
26 #if !USE_SHARED_LIBRARIES
27 IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable
, wxObject
)
30 class WXDLLEXPORT wxAcceleratorRefData
: public wxObjectRefData
32 friend class WXDLLEXPORT wxAcceleratorTable
;
34 wxAcceleratorRefData();
35 ~wxAcceleratorRefData();
37 inline HACCEL
GetHACCEL() const { return m_hAccel
; }
42 #define M_ACCELDATA ((wxAcceleratorRefData *)m_refData)
44 wxAcceleratorRefData::wxAcceleratorRefData()
52 wxAcceleratorRefData::~wxAcceleratorRefData()
57 DestroyAcceleratorTable((HACCEL) m_hAccel);
63 wxAcceleratorTable::wxAcceleratorTable()
68 wxAcceleratorTable::~wxAcceleratorTable()
72 // Load from .rc resource
73 wxAcceleratorTable::wxAcceleratorTable(const wxString
& resource
)
75 m_refData
= new wxAcceleratorRefData
;
77 /* TODO: load acelerator from resource, if appropriate for your platform
78 M_ACCELDATA->m_hAccel = hAccel;
79 M_ACCELDATA->m_ok = (hAccel != 0);
83 // Create from an array
84 wxAcceleratorTable::wxAcceleratorTable(int n
, wxAcceleratorEntry entries
[])
86 m_refData
= new wxAcceleratorRefData
;
88 /* TODO: create table from entries
92 bool wxAcceleratorTable::Ok() const
98 void wxAcceleratorTable::SetHACCEL(WXHACCEL hAccel
)
101 m_refData
= new wxAcceleratorRefData
;
103 M_ACCELDATA
->m_hAccel
= (HACCEL
) hAccel
;
106 WXHACCEL
wxAcceleratorTable::GetHACCEL() const
110 return (WXHACCEL
) M_ACCELDATA
->m_hAccel
;
113 bool wxAcceleratorTable::Translate(wxWindow
*window
, WXMSG
*wxmsg
) const
117 MSG *msg = (MSG *)wxmsg;
119 return Ok() && ::TranslateAccelerator(GetHwndOf(window), GetHaccel(), msg);