More accelerator work
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7469 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -53,28 +53,32 @@ class WXDLLEXPORT wxAcceleratorTable: public wxObject
|
||||
DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)
|
||||
public:
|
||||
wxAcceleratorTable();
|
||||
wxAcceleratorTable(const wxString& resource); // Load from .rc resource
|
||||
wxAcceleratorTable(int n, wxAcceleratorEntry entries[]); // Load from array
|
||||
wxAcceleratorTable(const wxString& rsResource); // Load from .rc resource
|
||||
wxAcceleratorTable( int n
|
||||
,wxAcceleratorEntry vaEntries[]
|
||||
); // Load from array
|
||||
|
||||
// Copy constructors
|
||||
inline wxAcceleratorTable(const wxAcceleratorTable& accel) { Ref(accel); }
|
||||
inline wxAcceleratorTable(const wxAcceleratorTable* accel) { if (accel) Ref(*accel); }
|
||||
inline wxAcceleratorTable(const wxAcceleratorTable& rAccel) { Ref(rAccel); }
|
||||
inline wxAcceleratorTable(const wxAcceleratorTable* pAccel) { if (pAccel) Ref(*pAccel); }
|
||||
|
||||
~wxAcceleratorTable();
|
||||
|
||||
inline wxAcceleratorTable& operator = (const wxAcceleratorTable& accel)
|
||||
{ if (*this == accel) return (*this); Ref(accel); return *this; };
|
||||
inline bool operator == (const wxAcceleratorTable& accel)
|
||||
{ return m_refData == accel.m_refData; };
|
||||
inline bool operator != (const wxAcceleratorTable& accel)
|
||||
{ return m_refData != accel.m_refData; };
|
||||
inline wxAcceleratorTable& operator = (const wxAcceleratorTable& rAccel)
|
||||
{ if (*this == rAccel) return (*this); Ref(rAccel); return *this; };
|
||||
inline bool operator == (const wxAcceleratorTable& rAccel)
|
||||
{ return m_refData == rAccel.m_refData; };
|
||||
inline bool operator != (const wxAcceleratorTable& rAccel)
|
||||
{ return m_refData != rAccel.m_refData; };
|
||||
|
||||
bool Ok() const;
|
||||
void SetHACCEL(WXHACCEL hAccel);
|
||||
WXHACCEL GetHACCEL() const;
|
||||
WXHACCEL GetHACCEL(void) const;
|
||||
|
||||
// translate the accelerator, return TRUE if done
|
||||
bool Translate(wxWindow *window, WXMSG *msg) const;
|
||||
bool Translate( WXHWND hWnd
|
||||
,WXMSG* pMsg
|
||||
) const;
|
||||
};
|
||||
|
||||
WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
|
||||
|
@@ -79,6 +79,18 @@ wxAcceleratorTable::wxAcceleratorTable(
|
||||
,NULL // resources always in .exe
|
||||
,(ULONG)ulId
|
||||
);
|
||||
if (wxTheApp->GetTopWindow() != NULL)
|
||||
{
|
||||
//
|
||||
// If we have accelerators the top window is the frame
|
||||
//
|
||||
wxFrame* pFrame = (wxFrame*)wxTheApp->GetTopWindow();
|
||||
|
||||
::WinSetAccelTable( vHabmain
|
||||
,(HWND)pFrame->GetFrame()
|
||||
,hAccel
|
||||
);
|
||||
}
|
||||
M_ACCELDATA->m_hAccel = hAccel;
|
||||
M_ACCELDATA->m_ok = (hAccel != 0);
|
||||
}
|
||||
@@ -117,7 +129,7 @@ wxAcceleratorTable::wxAcceleratorTable(
|
||||
,&bIsVirtual
|
||||
);
|
||||
if (bIsVirtual)
|
||||
uVirt |= AF_VIRTUALKEY;
|
||||
uVirt = AF_CHAR | AF_VIRTUALKEY;
|
||||
|
||||
USHORT uCmd = vaEntries[i].GetCommand();
|
||||
|
||||
@@ -130,6 +142,19 @@ wxAcceleratorTable::wxAcceleratorTable(
|
||||
M_ACCELDATA->m_hAccel = ::WinCreateAccelTable( vHabmain
|
||||
,pArr
|
||||
);
|
||||
if (wxTheApp->GetTopWindow() != NULL)
|
||||
{
|
||||
//
|
||||
// If we have accelerators the top window is the frame
|
||||
//
|
||||
wxFrame* pFrame = (wxFrame*)wxTheApp->GetTopWindow();
|
||||
|
||||
::WinSetAccelTable( vHabmain
|
||||
,(HWND)pFrame->GetFrame()
|
||||
,M_ACCELDATA->m_hAccel
|
||||
);
|
||||
}
|
||||
|
||||
delete[] pArr;
|
||||
M_ACCELDATA->m_ok = (M_ACCELDATA->m_hAccel != 0);
|
||||
} // end of wxAcceleratorTable::wxAcceleratorTable
|
||||
@@ -155,14 +180,14 @@ WXHACCEL wxAcceleratorTable::GetHACCEL() const
|
||||
}
|
||||
|
||||
bool wxAcceleratorTable::Translate(
|
||||
wxWindow* pWindow
|
||||
WXHWND hWnd
|
||||
, WXMSG* pWxmsg
|
||||
) const
|
||||
{
|
||||
PQMSG pMsg = (PQMSG)pWxmsg;
|
||||
|
||||
return Ok() && ::WinTranslateAccel( vHabmain
|
||||
,GetHwndOf(pWindow)
|
||||
,(HWND)hWnd
|
||||
,GetHaccel()
|
||||
,pMsg
|
||||
);
|
||||
|
@@ -698,8 +698,8 @@ bool wxApp::ProcessMessage(
|
||||
WXMSG* pWxmsg
|
||||
)
|
||||
{
|
||||
QMSG* vMsg = (PQMSG)pWxmsg;
|
||||
HWND hWnd = vMsg->hwnd;
|
||||
QMSG* pMsg = (PQMSG)pWxmsg;
|
||||
HWND hWnd = pMsg->hwnd;
|
||||
wxWindow* pWndThis = wxFindWinFromHandle((WXHWND)hWnd);
|
||||
wxWindow* pWnd;
|
||||
|
||||
@@ -708,7 +708,7 @@ bool wxApp::ProcessMessage(
|
||||
// We must relay WM_MOUSEMOVE events to the tooltip ctrl if we want it to
|
||||
// popup the tooltip bubbles
|
||||
//
|
||||
if (pWndThis && (vMsg->msg == WM_MOUSEMOVE))
|
||||
if (pWndThis && (pMsg->msg == WM_MOUSEMOVE))
|
||||
{
|
||||
wxToolTip* pToolTip = pWndThis->GetToolTip();
|
||||
if (pToolTip)
|
||||
@@ -729,6 +729,17 @@ bool wxApp::ProcessMessage(
|
||||
pWndThis = wxFindWinFromHandle((WXHWND)hWnd);
|
||||
}
|
||||
|
||||
//
|
||||
// Try translations first; find the youngest window with
|
||||
// a translation table.
|
||||
//
|
||||
for (pWnd = pWndThis; pWnd; pWnd = pWnd->GetParent() )
|
||||
{
|
||||
if (pMsg->msg == WM_CHAR)
|
||||
if (pWnd->OS2TranslateMessage(pWxmsg))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Anyone for a non-translation message? Try youngest descendants first.
|
||||
//
|
||||
|
@@ -1147,8 +1147,6 @@ bool wxFrame::OS2TranslateMessage(
|
||||
WXMSG* pMsg
|
||||
)
|
||||
{
|
||||
if (wxWindow::OS2TranslateMessage(pMsg))
|
||||
return TRUE;
|
||||
//
|
||||
// try the menu bar accels
|
||||
//
|
||||
@@ -1158,7 +1156,7 @@ bool wxFrame::OS2TranslateMessage(
|
||||
return FALSE;
|
||||
|
||||
const wxAcceleratorTable& rAcceleratorTable = pMenuBar->GetAccelTable();
|
||||
return rAcceleratorTable.Translate(this, pMsg);
|
||||
return rAcceleratorTable.Translate(m_hFrame, pMsg);
|
||||
} // end of wxFrame::OS2TranslateMessage
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@@ -996,7 +996,7 @@ MRESULT wxMDIChildFrame::OS2DefWindowProc(WXUINT message, WXWPARAM wParam, WXLPA
|
||||
|
||||
bool wxMDIChildFrame::OS2TranslateMessage(WXMSG* msg)
|
||||
{
|
||||
return m_acceleratorTable.Translate(GetParent(), msg);
|
||||
return m_acceleratorTable.Translate(GetParent()->GetHWND(), msg);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@@ -1699,7 +1699,7 @@ bool wxWindow::OS2TranslateMessage(
|
||||
WXMSG* pMsg
|
||||
)
|
||||
{
|
||||
return m_acceleratorTable.Translate(this, pMsg);
|
||||
return m_acceleratorTable.Translate(m_hWnd, pMsg);
|
||||
} // end of wxWindow::OS2TranslateMessage
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user