#include "wx/ownerdrw.h"
#endif
+#include "wx/hashmap.h"
#include "wx/evtloop.h"
#include "wx/power.h"
#include "wx/sysopt.h"
} gs_lastMouseEvent;
#endif // wxUSE_MOUSEEVENT_HACK
+// hash containing the registered handlers for the custom messages
+WX_DECLARE_HASH_MAP(int, wxWindow::MSWMessageHandler,
+ wxIntegerHash, wxIntegerEqual,
+ MSWMessageHandlers);
+
+static MSWMessageHandlers gs_messageHandlers;
+
// ---------------------------------------------------------------------------
// private functions
// ---------------------------------------------------------------------------
RECT *pr;
if ( prect )
{
- rect.left = prect->x;
- rect.top = prect->y;
- rect.right = prect->x + prect->width;
- rect.bottom = prect->y + prect->height;
+ wxCopyRectToRECT(*prect, rect);
pr = ▭
}
else
const RECT *pRect;
if ( rect )
{
- mswRect.left = rect->x;
- mswRect.top = rect->y;
- mswRect.right = rect->x + rect->width;
- mswRect.bottom = rect->y + rect->height;
-
+ wxCopyRectToRECT(*rect, mswRect);
pRect = &mswRect;
}
else
SIZE sizeRect;
TEXTMETRIC tm;
- ::GetTextExtentPoint32(hdc, string, string.length(), &sizeRect);
+ ::GetTextExtentPoint32(hdc, string.wx_str(), string.length(), &sizeRect);
GetTextMetrics(hdc, &tm);
if ( x )
node = node->GetNext() )
{
wxWindow * const win = node->GetData();
- if ( win->AcceptsFocus() &&
+ if ( win->CanAcceptFocus() &&
!(::GetWindowLong(GetHwndOf(win), GWL_EXSTYLE) &
WS_EX_CONTROLPARENT) )
{
LRESULT rc;
- if ( wnd && wxEventLoop::AllowProcessing(wnd) )
+ if ( wnd && wxGUIEventLoop::AllowProcessing(wnd) )
rc = wnd->MSWWindowProc(message, wParam, lParam);
else
rc = ::DefWindowProc(hWnd, message, wParam, lParam);
// problems, so don't do it for them (unnecessary anyhow)
if ( !win->IsOfStandardClass() )
{
- if ( message == WM_LBUTTONDOWN && win->AcceptsFocus() )
+ if ( message == WM_LBUTTONDOWN && win->IsFocusable() )
win->SetFocus();
}
}
break;
#endif
+#if wxUSE_MENUS
case WM_MENUCHAR:
// we're only interested in our own menus, not MF_SYSMENU
if ( HIWORD(wParam) == MF_POPUP )
}
}
break;
+#endif // wxUSE_MENUS
#ifndef __WXWINCE__
case WM_POWERBROADCAST:
}
break;
#endif // __WXWINCE__
+
+ default:
+ // try a custom message handler
+ const MSWMessageHandlers::const_iterator
+ i = gs_messageHandlers.find(message);
+ if ( i != gs_messageHandlers.end() )
+ {
+ processed = (*i->second)(this, message, wParam, lParam);
+ }
}
if ( !processed )
m_hWnd = (WXHWND)::CreateWindowEx
(
extendedStyle,
- className,
- title ? title : (const wxChar*)m_windowName.c_str(),
+ className.wx_str(),
+ title ? title : m_windowName.wx_str(),
style,
x, y, w, h,
(HWND)MSWGetParent(),
(
CP_ACP,
0, // no flags
- ttip,
+ ttip.wx_str(),
tipLength,
buf,
WXSIZEOF(buf) - 1
return GetEventHandler()->ProcessEvent(event);
}
+#if wxUSE_MENUS
int wxWindowMSW::HandleMenuChar(int WXUNUSED_IN_WINCE(chAccel),
WXLPARAM WXUNUSED_IN_WINCE(lParam))
{
// menu creation code
wxMenuItem *item = (wxMenuItem*)mii.dwItemData;
- const wxChar *p = wxStrchr(item->GetText(), _T('&'));
+ const wxChar *p = wxStrchr(item->GetText().wx_str(), _T('&'));
while ( p++ )
{
if ( *p == _T('&') )
return GetEventHandler()->ProcessEvent(evt);
}
+#endif // wxUSE_MENUS
// ---------------------------------------------------------------------------
// joystick
return GetEventHandler()->ProcessEvent(event);
}
+// ----------------------------------------------------------------------------
+// custom message handlers
+// ----------------------------------------------------------------------------
+
+/* static */ bool
+wxWindowMSW::MSWRegisterMessageHandler(int msg, MSWMessageHandler handler)
+{
+ wxCHECK_MSG( gs_messageHandlers.find(msg) == gs_messageHandlers.end(),
+ false, _T("registering handler for the same message twice") );
+
+ gs_messageHandlers[msg] = handler;
+ return true;
+}
+
+/* static */ void
+wxWindowMSW::MSWUnregisterMessageHandler(int msg, MSWMessageHandler handler)
+{
+ const MSWMessageHandlers::iterator i = gs_messageHandlers.find(msg);
+ wxCHECK_RET( i != gs_messageHandlers.end() && i->second == handler,
+ _T("unregistering non-registered handler?") );
+
+ gs_messageHandlers.erase(i);
+}
+
// ===========================================================================
// global functions
// ===========================================================================
}
return CallNextHookEx(ms_hMsgHookProc, nCode, wParam, lParam);
- };
+ }
private:
static HHOOK ms_hMsgHookProc;