#include <windowsx.h>
#endif
+#ifndef __TWIN32__
#ifdef __GNUWIN32__
#include <wx/msw/gnuwin32/extra.h>
#endif
+#endif
#ifdef GetCharWidth
#undef GetCharWidth
BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
EVT_CHAR(wxWindow::OnChar)
+ EVT_KEY_DOWN(wxWindow::OnKeyDown)
+ EVT_KEY_UP(wxWindow::OnKeyUp)
EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
EVT_INIT_DIALOG(wxWindow::OnInitDialog)
if (childWin->IsKindOf(CLASSINFO(wxControl)))
{
wxControl *item = (wxControl *)childWin;
- if (item->m_windowId == id)
+ if (item->GetId() == id)
return item;
else
{
}
case WM_KEYDOWN:
+ {
+ MSWOnKeyDown((WORD) wParam, lParam);
+#if 0
// we consider these message "not interesting"
if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
return Default();
MSWOnChar((WORD)wParam, lParam);
else
return Default();
+#endif
break;
+ }
+ case WM_KEYUP:
+ {
+ MSWOnKeyUp((WORD) wParam, lParam);
+ break;
+ }
case WM_CHAR: // Always an ASCII character
{
MSWOnChar((WORD)wParam, lParam, TRUE);
{
// adding NULL hWnd is (first) surely a result of an error and
// (secondly) breaks menu command processing
- wxCHECK_RET( hWnd != NULL, "attempt to add a NULL hWnd to window list" );
+ wxCHECK_RET( hWnd != (HWND) NULL, "attempt to add a NULL hWnd to window list" );
if ( !wxWinHandleList->Find((long)hWnd) )
wxWinHandleList->Append((long)hWnd, win);
}
}
+void wxWindow::MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII)
+{
+ int id;
+
+ if ((id = wxCharCodeMSWToWX(wParam)) == 0) {
+ id = wParam;
+ }
+
+ if (id != -1)
+ {
+ wxKeyEvent event(wxEVT_KEY_DOWN);
+ event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
+ event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
+ if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
+ event.m_altDown = TRUE;
+
+ event.m_eventObject = this;
+ event.m_keyCode = id;
+ event.SetTimestamp(wxApp::sm_lastMessageTime);
+
+ POINT pt ;
+ GetCursorPos(&pt) ;
+ RECT rect ;
+ GetWindowRect((HWND) GetHWND(),&rect) ;
+ pt.x -= rect.left ;
+ pt.y -= rect.top ;
+
+ event.m_x = pt.x; event.m_y = pt.y;
+
+ if (!GetEventHandler()->ProcessEvent(event))
+ Default();
+ }
+}
+
+void wxWindow::MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII)
+{
+ int id;
+
+ if ((id = wxCharCodeMSWToWX(wParam)) == 0) {
+ id = wParam;
+ }
+
+ if (id != -1)
+ {
+ wxKeyEvent event(wxEVT_KEY_UP);
+ event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE);
+ event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE);
+ if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN)
+ event.m_altDown = TRUE;
+
+ event.m_eventObject = this;
+ event.m_keyCode = id;
+ event.SetTimestamp(wxApp::sm_lastMessageTime);
+
+ POINT pt ;
+ GetCursorPos(&pt) ;
+ RECT rect ;
+ GetWindowRect((HWND) GetHWND(),&rect) ;
+ pt.x -= rect.left ;
+ pt.y -= rect.top ;
+
+ event.m_x = pt.x; event.m_y = pt.y;
+
+ if (!GetEventHandler()->ProcessEvent(event))
+ Default();
+ }
+}
+
void wxWindow::MSWOnJoyDown(int joystick, int x, int y, WXUINT flags)
{
int buttons = 0;
{
wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance());
wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(),
-#ifdef __WIN32__
+#if defined(__WIN32__) && !defined(__TWIN32__)
GetCurrentThreadId());
// (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
#else
void wxWindow::OnEraseBackground(wxEraseEvent& event)
{
+ if (!GetHWND())
+ return;
+
RECT rect;
::GetClientRect((HWND) GetHWND(), &rect);
- HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
+ COLORREF ref = PALETTERGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()) ;
+ HBRUSH hBrush = ::CreateSolidBrush(ref);
int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
// ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect);
void wxWindow::OnChar(wxKeyEvent& event)
{
+/* I'm commenting this out because otherwise, we lose tabs in e.g. a text window (see MDI sample)
+ * (JACS, 14/01/99)
if ( event.KeyCode() == WXK_TAB ) {
// propagate the TABs to the parent - it's up to it to decide what
// to do with it
return;
}
}
+*/
bool isVirtual;
int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
(void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam);
}
+void wxWindow::OnKeyDown(wxKeyEvent& event)
+{
+ Default();
+}
+
+void wxWindow::OnKeyUp(wxKeyEvent& event)
+{
+ Default();
+}
+
void wxWindow::OnPaint(wxPaintEvent& event)
{
Default();