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 #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
; }
43 #define M_ACCELDATA ((wxAcceleratorRefData *)m_refData)
45 wxAcceleratorRefData::wxAcceleratorRefData()
53 wxAcceleratorRefData::~wxAcceleratorRefData()
58 DestroyAcceleratorTable((HACCEL) m_hAccel);
64 wxAcceleratorTable::wxAcceleratorTable()
69 wxAcceleratorTable::~wxAcceleratorTable()
73 // Load from .rc resource
74 wxAcceleratorTable::wxAcceleratorTable(const wxString
& resource
)
76 m_refData
= new wxAcceleratorRefData
;
78 /* TODO: load acelerator from resource, if appropriate for your platform
79 M_ACCELDATA->m_hAccel = hAccel;
80 M_ACCELDATA->m_ok = (hAccel != 0);
84 extern int wxCharCodeWXToOS2(int id
, bool *isVirtual
);
86 // Create from an array
87 wxAcceleratorTable::wxAcceleratorTable(int n
, wxAcceleratorEntry entries
[])
89 m_refData
= new wxAcceleratorRefData
;
91 /* TODO: create table from entries
95 bool wxAcceleratorTable::Ok() const
101 void wxAcceleratorTable::SetHACCEL(WXHACCEL hAccel
)
104 m_refData
= new wxAcceleratorRefData
;
106 M_ACCELDATA
->m_hAccel
= (HACCEL
) hAccel
;
109 WXHACCEL
wxAcceleratorTable::GetHACCEL() const
113 return (WXHACCEL
) M_ACCELDATA
->m_hAccel
;
116 bool wxAcceleratorTable::Translate(wxWindow
*window
, WXMSG
*wxmsg
) const
120 MSG *msg = (MSG *)wxmsg;
122 return Ok() && ::TranslateAccelerator(GetHwndOf(window), GetHaccel(), msg);