1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxAcceleratorTable
4 // Author: David Webster
8 // Copyright: (c) David Webster
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 IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable
, wxObject
)
28 class WXDLLEXPORT wxAcceleratorRefData
: public wxObjectRefData
30 friend class WXDLLEXPORT wxAcceleratorTable
;
32 wxAcceleratorRefData();
33 ~wxAcceleratorRefData();
35 inline HACCEL
GetHACCEL() const { return m_hAccel
; }
41 #define M_ACCELDATA ((wxAcceleratorRefData *)m_refData)
43 wxAcceleratorRefData::wxAcceleratorRefData()
51 wxAcceleratorRefData::~wxAcceleratorRefData()
56 DestroyAcceleratorTable((HACCEL) m_hAccel);
62 wxAcceleratorTable::wxAcceleratorTable()
67 wxAcceleratorTable::~wxAcceleratorTable()
71 // Load from .rc resource
72 wxAcceleratorTable::wxAcceleratorTable(const wxString
& resource
)
74 m_refData
= new wxAcceleratorRefData
;
76 /* TODO: load acelerator from resource, if appropriate for your platform
77 M_ACCELDATA->m_hAccel = hAccel;
78 M_ACCELDATA->m_ok = (hAccel != 0);
82 extern int wxCharCodeWXToOS2(int id
, bool *isVirtual
);
84 // Create from an array
85 wxAcceleratorTable::wxAcceleratorTable(int n
, wxAcceleratorEntry entries
[])
87 m_refData
= new wxAcceleratorRefData
;
89 /* TODO: create table from entries
93 bool wxAcceleratorTable::Ok() const
99 void wxAcceleratorTable::SetHACCEL(WXHACCEL hAccel
)
102 m_refData
= new wxAcceleratorRefData
;
104 M_ACCELDATA
->m_hAccel
= (HACCEL
) hAccel
;
107 WXHACCEL
wxAcceleratorTable::GetHACCEL() const
111 return (WXHACCEL
) M_ACCELDATA
->m_hAccel
;
114 bool wxAcceleratorTable::Translate(wxWindow
*window
, WXMSG
*wxmsg
) const
118 MSG *msg = (MSG *)wxmsg;
120 return Ok() && ::TranslateAccelerator(GetHwndOf(window), GetHaccel(), msg);