#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/panel.h"
#include "wx/layout.h"
#include "wx/dialog.h"
+#include "wx/frame.h"
#include "wx/listbox.h"
#include "wx/button.h"
#include "wx/settings.h"
#endif
#if wxUSE_OWNER_DRAWN
-#include "wx/ownerdrw.h"
+ #include "wx/ownerdrw.h"
#endif
#if wxUSE_DRAG_AND_DROP
-#include "wx/msw/ole/droptgt.h"
+ #include "wx/msw/ole/droptgt.h"
#endif
#include "wx/menuitem.h"
#include <windowsx.h>
#endif
+#ifndef __TWIN32__
#ifdef __GNUWIN32__
#include <wx/msw/gnuwin32/extra.h>
#endif
+#endif
#ifdef GetCharWidth
#undef GetCharWidth
#endif
#ifdef __WXDEBUG__
-const char *wxGetMessageName(int message);
+ const char *wxGetMessageName(int message);
#endif //__WXDEBUG__
#define WINDOW_MARGIN 3 // This defines sensitivity of Leave events
wxMenu *wxCurrentPopupMenu = NULL;
-extern wxList wxPendingDelete;
+extern wxList WXDLLEXPORT wxPendingDelete;
void wxRemoveHandleAssociation(wxWindow *win);
void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win);
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)
// Find an item given the MS Windows id
wxWindow *wxWindow::FindItem(int id) const
{
- if (!GetChildren())
- return NULL;
- wxNode *current = GetChildren()->First();
+// if (!GetChildren())
+// return NULL;
+ wxNode *current = GetChildren().First();
while (current)
{
wxWindow *childWin = (wxWindow *)current->Data();
if (childWin->IsKindOf(CLASSINFO(wxControl)))
{
wxControl *item = (wxControl *)childWin;
- if (item->m_windowId == id)
+ if (item->GetId() == id)
return item;
else
{
// Find an item given the MS Windows handle
wxWindow *wxWindow::FindItemByHWND(WXHWND hWnd, bool controlOnly) const
{
- if (!GetChildren())
- return NULL;
- wxNode *current = GetChildren()->First();
+// if (!GetChildren())
+// return NULL;
+ wxNode *current = GetChildren().First();
while (current)
{
wxObject *obj = (wxObject *)current->Data() ;
{
int currentX, currentY;
GetPosition(¤tX, ¤tY);
+ int currentW,currentH;
+ GetSize(¤tW, ¤tH);
+
+ if (x == currentX && y == currentY && width == currentW && height == currentH)
+ return;
+
int actualWidth = width;
int actualHeight = height;
int actualX = x;
AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
- int currentW,currentH;
- GetSize(¤tW, ¤tH);
if (width == -1)
actualWidth = currentW ;
if (height == -1)
wxWndHook = NULL;
wnd->m_hWnd = (WXHWND) hWnd;
}
- // wxDebugMsg("hWnd = %d, m_hWnd = %d, msg = %d\n", hWnd, m_hWnd, message);
// Stop right here if we don't have a valid handle
// in our wxWnd object.
// Should probably have a test for 'genuine' NT
#if defined(__WIN32__)
-#define DIMENSION_TYPE short
+ #define DIMENSION_TYPE short
#else
-#define DIMENSION_TYPE int
+ #define DIMENSION_TYPE int
#endif
// Main Windows 3 window proc
long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
wxASSERT( m_lastMsg == message &&
- m_lastWParam == wParam &&
- m_lastLParam == lParam );
+ m_lastWParam == wParam && m_lastLParam == lParam );
#ifdef __WXDEBUG__
wxLogTrace(wxTraceMessages, "Processing %s(%lx, %lx)",
}
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);
m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
(DLGPROC)wxDlgProc);
#else
+ // N.B.: if we _don't_ use this form,
+ // then with VC++ 1.5, it crashes horribly.
+#if 1
+ m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
+ (DLGPROC)wxDlgProc);
+#else
+ // Crashes when we use this.
DLGPROC dlgproc = (DLGPROC)MakeProcInstance((DLGPROC)wxWndProc, wxGetInstance());
m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent,
(DLGPROC)dlgproc);
+#endif
#endif
if (m_hWnd == 0)
{
// Rely on MSWNotify to check whether the message
// belongs to the window or not
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
// Responds to colour changes: passes event on to children.
void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event)
{
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while ( node )
{
// Only propagate to non-top-level windows
}
}
+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);
#if defined(__WIN95__)
// Try to adjust the range to cope with page size > 1
// - a Windows API quirk
- int pageSize = GetScrollPage(orient);
+ int pageSize = GetScrollThumb(orient);
if ( pageSize > 1 )
{
maxPos -= (pageSize - 1);
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();
// it's an application error (pops up a dialog)
bool wxWindow::TransferDataToWindow()
{
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while ( node )
{
wxWindow *child = (wxWindow *)node->Data();
// validation failed: don't quit
bool wxWindow::TransferDataFromWindow()
{
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while ( node )
{
wxWindow *child = (wxWindow *)node->Data();
bool wxWindow::Validate()
{
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while ( node )
{
wxWindow *child = (wxWindow *)node->Data();
void wxWindow::AddChild(wxWindow *child)
{
- GetChildren()->Append(child);
+ GetChildren().Append(child);
child->m_windowParent = this;
}
void wxWindow::RemoveChild(wxWindow *child)
{
- if (GetChildren())
- GetChildren()->DeleteObject(child);
+// if (GetChildren())
+ GetChildren().DeleteObject(child);
child->m_windowParent = NULL;
}
void wxWindow::DestroyChildren()
{
- if (GetChildren()) {
wxNode *node;
- while ((node = GetChildren()->First()) != (wxNode *)NULL) {
+ while ((node = GetChildren().First()) != (wxNode *)NULL) {
wxWindow *child;
if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) {
delete child;
- if ( GetChildren()->Member(child) )
+ if ( GetChildren().Member(child) )
delete node;
}
} /* while */
- }
}
void wxWindow::MakeModal(bool modal)
{
noChanges = 0;
noFailures = 0;
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow *)node->Data();
constr->centreX.SetDone(FALSE);
constr->centreY.SetDone(FALSE);
}
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while (node)
{
wxWindow *win = (wxWindow *)node->Data();
if (recurse)
{
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while (node)
{
wxWindow *win = (wxWindow *)node->Data();
wxObject* wxWindow::GetChild(int number) const
{
// Return a pointer to the Nth object in the Panel
- if (!GetChildren())
- return(NULL) ;
- wxNode *node = GetChildren()->First();
+// if (!GetChildren())
+// return(NULL) ;
+ wxNode *node = GetChildren().First();
int n = number;
while (node && n--)
node = node->Next() ;
{
int maxX = 0;
int maxY = 0;
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while ( node )
{
wxWindow *win = (wxWindow *)node->Data();
if ( GetId() == id)
return this;
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while ( node )
{
wxWindow *child = (wxWindow *)node->Data();
if ( GetName() == name)
return this;
- wxNode *node = GetChildren()->First();
+ wxNode *node = GetChildren().First();
while ( node )
{
wxWindow *child = (wxWindow *)node->Data();