Added wxAcceleratorTable, wxFrame::SetAcceleratorTable and additions to process it under wxMSW.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -757,7 +757,19 @@ bool wxApp::ProcessMessage(WXMSG *Msg)
|
||||
|
||||
HWND hWnd;
|
||||
|
||||
// Anyone for a message? Try youngest descendants first.
|
||||
// Try translations first; find the youngest window with
|
||||
// a translation table.
|
||||
for (hWnd = msg->hwnd; hWnd != NULL; hWnd = ::GetParent(hWnd))
|
||||
{
|
||||
wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd);
|
||||
if (wnd)
|
||||
{
|
||||
if (wnd->MSWTranslateMessage(Msg))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Anyone for a non-translation message? Try youngest descendants first.
|
||||
for (hWnd = msg->hwnd; hWnd != NULL; hWnd = ::GetParent(hWnd))
|
||||
{
|
||||
wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd);
|
||||
@@ -765,18 +777,9 @@ bool wxApp::ProcessMessage(WXMSG *Msg)
|
||||
{
|
||||
if (wnd->MSWProcessMessage(Msg))
|
||||
return TRUE;
|
||||
|
||||
// STOP if we've reached the top of the hierarchy!
|
||||
// if (m_topWindow && (wnd == m_topWindow))
|
||||
// return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Is this now obsolete, given that m_topWindow may not be defined?
|
||||
// Does it do anything useful anyway?
|
||||
// if (m_topWindow && m_topWindow->MSWProcessMessage(Msg))
|
||||
// return TRUE;
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxApp::OnIdle(wxIdleEvent& event)
|
||||
|
@@ -99,6 +99,7 @@ wxCursor *wxHOURGLASS_CURSOR = NULL;
|
||||
wxCursor *wxCROSS_CURSOR = NULL;
|
||||
|
||||
// 'Null' objects
|
||||
wxAcceleratorTable wxNullAcceleratorTable;
|
||||
wxBitmap wxNullBitmap;
|
||||
wxIcon wxNullIcon;
|
||||
wxCursor wxNullCursor;
|
||||
|
@@ -348,6 +348,11 @@ void wxFrame::SetIcon(const wxIcon& icon)
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxFrame::SetAcceleratorTable(const wxAcceleratorTable& accel)
|
||||
{
|
||||
m_acceleratorTable = accel;
|
||||
}
|
||||
|
||||
wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
|
||||
const wxString& name)
|
||||
{
|
||||
@@ -479,6 +484,7 @@ void wxFrame::SetMenuBar(wxMenuBar *menu_bar)
|
||||
menu_bar->m_menuBarFrame = this;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool wxFrame::LoadAccelerators(const wxString& table)
|
||||
{
|
||||
m_acceleratorTable = (WXHANDLE)
|
||||
@@ -498,6 +504,7 @@ bool wxFrame::LoadAccelerators(const wxString& table)
|
||||
|
||||
return (m_acceleratorTable != (WXHANDLE) NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
void wxFrame::Fit(void)
|
||||
{
|
||||
@@ -758,8 +765,13 @@ void wxFrame::MSWOnMenuHighlight(WXWORD nItem, WXWORD nFlags, WXHMENU hSysMenu)
|
||||
|
||||
bool wxFrame::MSWProcessMessage(WXMSG* pMsg)
|
||||
{
|
||||
if (m_acceleratorTable != 0 &&
|
||||
::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable, (MSG *)pMsg))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxFrame::MSWTranslateMessage(WXMSG* pMsg)
|
||||
{
|
||||
if (m_acceleratorTable.Ok() &&
|
||||
::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable.GetHACCEL(), (MSG *)pMsg))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
|
@@ -118,6 +118,7 @@ COMMONOBJS = \
|
||||
# $(MSWDIR)\matrix.obj \
|
||||
|
||||
MSWOBJS = \
|
||||
$(MSWDIR)\accel.obj \
|
||||
$(MSWDIR)\app.obj \
|
||||
$(MSWDIR)\bitmap.obj \
|
||||
$(MSWDIR)\bmpbuttn.obj \
|
||||
@@ -234,6 +235,8 @@ $(COMMDIR)\lex_yy.c: $(COMMDIR)\doslex.c
|
||||
|
||||
#$(OBJECTS): $(WXDIR)\include\wx\setup.h
|
||||
|
||||
$(MSWDIR)\accel.obj: $(MSWDIR)\accel.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\app.obj: $(MSWDIR)\app.$(SRCSUFF)
|
||||
|
||||
$(MSWDIR)\bitmap.obj: $(MSWDIR)\bitmap.$(SRCSUFF)
|
||||
|
@@ -119,6 +119,7 @@ COMMONOBJS = \
|
||||
# $(COMMDIR)\fileconf.obj # Doens't compile (nested classes)
|
||||
|
||||
MSWOBJS = \
|
||||
$(MSWDIR)\accel.obj \
|
||||
$(MSWDIR)\app.obj \
|
||||
$(MSWDIR)\bitmap.obj \
|
||||
$(MSWDIR)\bmpbuttn.obj \
|
||||
@@ -258,6 +259,11 @@ dummydll.obj: dummydll.$(SRCSUFF) $(WXDIR)\include\wx\wx.h
|
||||
$(CPPFLAGS) /YcWX/WXPREC.H /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
$(MSWDIR)/accel.obj: $*.$(SRCSUFF)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
$(MSWDIR)/app.obj: $*.$(SRCSUFF)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
|
||||
|
@@ -122,6 +122,7 @@ COMMONOBJS = \
|
||||
$(COMMDIR)/wincmn.$(OBJSUFF)
|
||||
|
||||
MSWOBJS = \
|
||||
accel.$(OBJSUFF) \
|
||||
app.$(OBJSUFF) \
|
||||
bitmap.$(OBJSUFF) \
|
||||
bmpbuttn.$(OBJSUFF) \
|
||||
|
@@ -122,6 +122,7 @@ COMMONOBJS = \
|
||||
|
||||
|
||||
MSWOBJS = \
|
||||
$(MSWDIR)\accel.obj \
|
||||
$(MSWDIR)\app.obj \
|
||||
$(MSWDIR)\bitmap.obj \
|
||||
$(MSWDIR)\bmpbuttn.obj \
|
||||
@@ -278,6 +279,11 @@ dummydll.obj: dummydll.$(SRCSUFF) $(WXDIR)\include\wx\wx.h
|
||||
$(CPPFLAGS) $(MAKEPRECOMP) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
$(MSWDIR)/accel.obj: $*.$(SRCSUFF)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
|
||||
<<
|
||||
|
||||
$(MSWDIR)/app.obj: $*.$(SRCSUFF)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@
|
||||
|
@@ -479,7 +479,7 @@ bool wxMDIParentFrame::MSWOnActivate(int state, bool minimized, WXHWND activate)
|
||||
|
||||
bool wxMDIParentFrame::MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control)
|
||||
{
|
||||
if (cmd == 0)
|
||||
// if (cmd == 0) // Why did I do this test?
|
||||
{
|
||||
// In case it's e.g. a toolbar.
|
||||
wxWindow *win = wxFindWinFromHandle(control);
|
||||
@@ -599,8 +599,18 @@ bool wxMDIParentFrame::MSWProcessMessage(WXMSG* msg)
|
||||
if ((m_currentChild != (wxWindow *)NULL) && (m_currentChild->GetHWND() != (WXHWND) NULL) && m_currentChild->MSWProcessMessage(msg))
|
||||
return TRUE;
|
||||
|
||||
if (m_acceleratorTable != (WXHANDLE) NULL &&
|
||||
::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable, pMsg))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxMDIParentFrame::MSWTranslateMessage(WXMSG* msg)
|
||||
{
|
||||
MSG *pMsg = (MSG *)msg;
|
||||
|
||||
if ((m_currentChild != (wxWindow *)NULL) && (m_currentChild->GetHWND() != (WXHWND) NULL) && m_currentChild->MSWTranslateMessage(msg))
|
||||
return TRUE;
|
||||
|
||||
if (m_acceleratorTable.Ok() &&
|
||||
::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable.GetHACCEL(), pMsg))
|
||||
return TRUE;
|
||||
|
||||
if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN)
|
||||
@@ -612,6 +622,7 @@ bool wxMDIParentFrame::MSWProcessMessage(WXMSG* msg)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
bool wxMDIParentFrame::MSWOnEraseBkgnd(WXHDC WXUNUSED(pDC))
|
||||
{
|
||||
return TRUE;
|
||||
@@ -918,7 +929,8 @@ bool wxMDIChildFrame::MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control)
|
||||
#if WXDEBUG > 1
|
||||
wxDebugMsg("wxMDIChildFrame::MSWOnCommand %d\n", GetHWND());
|
||||
#endif
|
||||
if ((cmd == 0) && GetHWND())
|
||||
// if ((cmd == 0) && GetHWND())
|
||||
if (GetHWND())
|
||||
{
|
||||
// In case it's e.g. a toolbar.
|
||||
wxWindow *win = wxFindWinFromHandle(control);
|
||||
@@ -946,14 +958,20 @@ long wxMDIChildFrame::MSWDefWindowProc(WXUINT message, WXUINT wParam, WXLPARAM l
|
||||
}
|
||||
|
||||
bool wxMDIChildFrame::MSWProcessMessage(WXMSG *msg)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxMDIChildFrame::MSWTranslateMessage(WXMSG* msg)
|
||||
{
|
||||
MSG *pMsg = (MSG *)msg;
|
||||
if (m_acceleratorTable && GetHWND())
|
||||
if (m_acceleratorTable.Ok())
|
||||
{
|
||||
wxFrame *parent = (wxFrame *)GetParent();
|
||||
HWND parent_hwnd = (HWND) parent->GetHWND();
|
||||
return (::TranslateAccelerator(parent_hwnd, (HACCEL) m_acceleratorTable, pMsg) != 0);
|
||||
return (::TranslateAccelerator(parent_hwnd, (HACCEL) m_acceleratorTable.GetHACCEL(), pMsg) != 0);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@@ -33,8 +33,11 @@
|
||||
#include "wx/log.h"
|
||||
|
||||
// Windows headers
|
||||
/*
|
||||
#define STRICT
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// other std headers
|
||||
|
@@ -252,7 +252,7 @@ wxWindow::wxWindow(void)
|
||||
m_lastMsg = 0;
|
||||
m_lastWParam = 0;
|
||||
m_lastLParam = 0;
|
||||
m_acceleratorTable = 0;
|
||||
// m_acceleratorTable = 0;
|
||||
m_hMenu = 0;
|
||||
|
||||
m_xThumbSize = 0;
|
||||
@@ -434,7 +434,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
|
||||
m_lastMsg = 0;
|
||||
m_lastWParam = 0;
|
||||
m_lastLParam = 0;
|
||||
m_acceleratorTable = 0;
|
||||
// m_acceleratorTable = 0;
|
||||
m_hMenu = 0;
|
||||
|
||||
m_xThumbSize = 0;
|
||||
@@ -2012,6 +2012,11 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxWindow::MSWTranslateMessage(WXMSG* WXUNUSED(pMsg))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag), WXHWND WXUNUSED(activate), WXHWND WXUNUSED(deactivate))
|
||||
{
|
||||
#if WXDEBUG > 1
|
||||
|
Reference in New Issue
Block a user