#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#ifndef WX_PRECOMP
-#include <stdio.h>
-#include "wx/setup.h"
-#include "wx/menu.h"
-#include "wx/dc.h"
-#include "wx/dcclient.h"
-#include "wx/utils.h"
-#include "wx/app.h"
-#include "wx/panel.h"
-#include "wx/layout.h"
-#include "wx/dialog.h"
-#include "wx/listbox.h"
-#include "wx/button.h"
-#include "wx/settings.h"
-#include "wx/msgdlg.h"
+ #include <stdio.h>
+ #include "wx/setup.h"
+ #include "wx/menu.h"
+ #include "wx/dc.h"
+ #include "wx/dcclient.h"
+ #include "wx/utils.h"
+ #include "wx/app.h"
+ #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"
+ #include "wx/msgdlg.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 "wx/log.h"
+#include "wx/tooltip.h"
+
#include "wx/msw/private.h"
#include <string.h>
#ifndef __GNUWIN32__
-#include <shellapi.h>
-#include <mmsystem.h>
+ #include <shellapi.h>
+ #include <mmsystem.h>
#endif
#ifdef __WIN32__
-#include <windowsx.h>
+ #include <windowsx.h>
#endif
-#ifdef __GNUWIN32__
-#include <wx/msw/gnuwin32/extra.h>
+#include <commctrl.h>
+
+#ifndef __TWIN32__
+ #ifdef __GNUWIN32__
+ #include <wx/msw/gnuwin32/extra.h>
+ #endif
#endif
+// all these are defined in <windows.h>
#ifdef GetCharWidth
#undef GetCharWidth
#endif
#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);
wxWindow *wxFindWinFromHandle(WXHWND hWnd);
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
+ IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
#endif
BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
if (childWin->IsKindOf(CLASSINFO(wxControl)))
{
wxControl *item = (wxControl *)childWin;
- if (item->m_windowId == id)
+ if (item->GetId() == id)
return item;
else
{
}
bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam),
- WXLPARAM WXUNUSED(lParam),
+ WXLPARAM lParam,
WXLPARAM* WXUNUSED(result))
{
+ NMHDR* hdr = (NMHDR *)lParam;
+ if ( hdr->code == TTN_NEEDTEXT && m_tooltip )
+ {
+ TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
+ ttt->lpszText = (char *)m_tooltip->GetTip().c_str();
+
+ // processed
+ return TRUE;
+ }
+
return FALSE;
}
#if wxUSE_DRAG_AND_DROP
m_pDropTarget = NULL;
#endif
+
+ m_tooltip = NULL;
}
wxWindow::wxWindow()
{
m_isBeingDeleted = TRUE;
+ // first of all, delete the things on which nothing else depends
+
+ wxDELETE(m_tooltip);
+
// JACS - if behaviour is odd, restore this
// to the start of ~wxWindow. Vadim has changed
// it to nearer the end. Unsure of side-effects
// delete themselves.
#if wxUSE_CONSTRAINTS
DeleteRelatedConstraints();
+
if (m_constraints)
{
// This removes any dangling pointers to this window
delete m_constraints;
m_constraints = NULL;
}
- if (m_windowSizer)
- {
- delete m_windowSizer;
- m_windowSizer = NULL;
- }
+
+ wxDELETE(m_windowSizer);
+
// If this is a child of a sizer, remove self from parent
if (m_sizerParent)
m_sizerParent->RemoveChild((wxWindow *)this);
m_pDropTarget->Register(m_hWnd);
}
-#endif
+#endif // wxUSE_DRAG_AND_DROP
+
//old style file-manager drag&drop support
// I think we should retain the old-style
::DragAcceptFiles(hWnd, (BOOL)accept);
}
+// ----------------------------------------------------------------------------
+// tooltips
+// ----------------------------------------------------------------------------
+
+void wxWindow::SetToolTip(const wxString &tip)
+{
+ SetToolTip(new wxToolTip(tip));
+}
+
+void wxWindow::SetToolTip(wxToolTip *tooltip)
+{
+ if ( m_tooltip )
+ delete m_tooltip;
+
+ m_tooltip = tooltip;
+ m_tooltip->SetWindow(this);
+}
+
// Get total size
void wxWindow::GetSize(int *x, int *y) const
{
{
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)",
- wxGetMessageName(message), wParam, lParam);
+ wxGetMessageName(message), wParam, lParam);
#endif // __WXDEBUG__
HWND hWnd = (HWND)m_hWnd;
break;
}
+#if 0
case WM_KEYDOWN:
+ {
+ MSWOnKeyDown((WORD) wParam, lParam);
// we consider these message "not interesting"
if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
return Default();
else
return Default();
break;
+ }
+#endif
+ 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)
lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0);
}
- bool bForward = TRUE;
+ bool bForward = TRUE,
+ bWindowChange = FALSE;
if ( bProcess ) {
switch ( msg->wParam ) {
case VK_TAB:
- if ( lDlgCode & DLGC_WANTTAB ) // FALSE for Ctrl-Tab
+ if ( lDlgCode & DLGC_WANTTAB ) {
bProcess = FALSE;
- else
+ }
+ else {
+ // Ctrl-Tab cycles thru notebook pages
+ bWindowChange = bCtrlDown;
bForward = !(::GetKeyState(VK_SHIFT) & 0x100);
+ }
break;
case VK_UP:
bProcess = FALSE;
break;
+ case VK_RETURN:
+ // if there is a default button, Enter should press it
+ if ( !GetDefaultItem() ) {
+ // but if there is not it makes sense to make it work
+ // like a TAB
+
+ // nothing to do - all variables are already set
+
+ break;
+ }
+ //else: fall through and don't process the message
+
default:
bProcess = FALSE;
}
if ( bProcess ) {
wxNavigationKeyEvent event;
event.SetDirection(bForward);
- event.SetWindowChange(bCtrlDown);
+ event.SetWindowChange(bWindowChange);
event.SetEventObject(this);
if ( GetEventHandler()->ProcessEvent(event) )
return ::IsDialogMessage((HWND)GetHWND(), msg) != 0;
}
+#if wxUSE_TOOLTIPS
+ else if ( m_tooltip ) {
+ // relay mouse move events to the tooltip control
+ MSG *msg = (MSG *)pMsg;
+ if ( msg->message == WM_MOUSEMOVE )
+ m_tooltip->RelayEvent(pMsg);
+ }
+#endif // wxUSE_TOOLTIPS
return FALSE;
}
}
}
+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
}
-/* TODO (maybe)
-void wxWindow::OnPaint()
-{
-PaintSelectionHandles();
-}
-*/
-
void wxWindow::WarpPointer (int x_pos, int y_pos)
{
// Move the pointer to (x_pos,y_pos) coordinates. They are expressed in
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)
{
+#if 0
if ( event.KeyCode() == WXK_TAB ) {
// propagate the TABs to the parent - it's up to it to decide what
// to do with it
- if ( GetParent() ) {
- if ( GetParent()->GetEventHandler()->ProcessEvent(event) )
+ wxWindow *parent = GetParent();
+ if ( parent ) {
+ if ( parent->GetEventHandler()->ProcessEvent(event) )
return;
}
}
+#endif // 0
bool isVirtual;
int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual);
(void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam);
}
-void wxWindow::OnPaint(wxPaintEvent& event)
-{
- Default();
-}
-
bool wxWindow::IsEnabled(void) const
{
return (::IsWindowEnabled((HWND) GetHWND()) != 0);
bool wxWindow::AcceptsFocus() const
{
+ // invisible and disabled controls don't need focus
return IsShown() && IsEnabled();
}