From 43d811ea55a6dee36e17e6815dcd891a82d62e28 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 13 Jun 1998 10:09:13 +0000 Subject: [PATCH] Correction to dnd.h; EVT_MOUSE_EVENTS now includes LEAVE/ENTER events; Windows LEAVE/ENTER events now work git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@86 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dnd.h | 2 + include/wx/event.h | 4 +- include/wx/msw/ole/dataobj.h | 2 +- samples/dnd/dnd.cpp | 160 +++++++++++++++------ src/common/tbarbase.cpp | 2 + src/msw/control.cpp | 27 ++-- src/msw/makefile.b32 | 6 + src/msw/makefile.dos | 12 ++ src/msw/makefile.g95 | 2 + src/msw/makefile.nt | 15 ++ src/msw/window.cpp | 267 +++-------------------------------- 11 files changed, 190 insertions(+), 309 deletions(-) diff --git a/include/wx/dnd.h b/include/wx/dnd.h index a654c6e7a1..3a42147fb0 100644 --- a/include/wx/dnd.h +++ b/include/wx/dnd.h @@ -2,6 +2,8 @@ #define __DNDH_BASE__ #if defined(__WINDOWS__) +#include "wx/msw/ole/dropsrc.h" +#include "wx/msw/ole/droptgt.h" #elif defined(__MOTIF__) #elif defined(__GTK__) #include "wx/gtk/dnd.h" diff --git a/include/wx/event.h b/include/wx/event.h index 2a48872a28..1860e4a4ec 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1108,7 +1108,9 @@ const wxEventTableEntry theClass::sm_eventTableEntries[] = { \ { wxEVT_MOTION, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, NULL },\ { wxEVT_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, NULL },\ { wxEVT_MIDDLE_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, NULL },\ - { wxEVT_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, NULL }, + { wxEVT_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, NULL },\ + { wxEVT_ENTER_WINDOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, NULL },\ + { wxEVT_LEAVE_WINDOW, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) & func, NULL }, // EVT_COMMAND #define EVT_COMMAND(id, cmd, fn) { cmd, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, NULL }, diff --git a/include/wx/msw/ole/dataobj.h b/include/wx/msw/ole/dataobj.h index f083f6f169..7a7c8a84ed 100644 --- a/include/wx/msw/ole/dataobj.h +++ b/include/wx/msw/ole/dataobj.h @@ -55,7 +55,7 @@ public: // function to return symbolic name of clipboard format (debug messages) static const char *GetFormatName(wxDataFormat format); #else // not used in release mode - #define GetFormatName(format) "" + inline const char* GetFormatName(wxDataFormat format) { return ""; } #endif // ctor & dtor diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index 8b6fb25f47..563c0ad7d6 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -1,19 +1,14 @@ -/////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// // Name: dnd.cpp // Purpose: Drag and drop sample // Author: Vadim Zeitlin -// Modified by: -// Created: 13.11.97 -// RCS-ID: $Id$ -// Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows license -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// headers & declarations -// ============================================================================ - -// For compilers that support precompilation, includes "wx.h". +// Modified by: +// Created: 04/01/98 +// RCS-ID: +// Copyright: +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + #include "wx/wxprec.h" #ifdef __BORLANDC__ @@ -79,7 +74,11 @@ public: void OnPaint(wxPaintEvent& event); void OnQuit (wxCommandEvent& event); void OnAbout(wxCommandEvent& event); + void OnDrag (wxCommandEvent& event); void OnHelp (wxCommandEvent& event); + void OnLogClear(wxCommandEvent& event); + + void OnMouseBtnDown(wxMouseEvent& event); bool OnClose(); @@ -90,7 +89,9 @@ private: *m_ctrlText; wxTextCtrl *m_ctrlLog; - wxLogTarget *m_pLog, *m_pLogPrev; + wxLog *m_pLog, *m_pLogPrev; + + wxString m_strText; }; // ---------------------------------------------------------------------------- @@ -99,16 +100,22 @@ private: enum { Menu_Quit = 1, + Menu_Drag, Menu_About = 101, Menu_Help, + Menu_Clear, }; BEGIN_EVENT_TABLE(DnDFrame, wxFrame) - EVT_MENU(Menu_Quit, DnDFrame::OnQuit) - EVT_MENU(Menu_About, DnDFrame::OnAbout) - EVT_MENU(Menu_Help, DnDFrame::OnHelp) - - //EVT_PAINT(DnDFrame::OnPaint) + EVT_MENU(Menu_Quit, DnDFrame::OnQuit) + EVT_MENU(Menu_About, DnDFrame::OnAbout) + EVT_MENU(Menu_Drag, DnDFrame::OnDrag) + EVT_MENU(Menu_Help, DnDFrame::OnHelp) + EVT_MENU(Menu_Clear, DnDFrame::OnLogClear) + + EVT_LEFT_DOWN(OnMouseBtnDown) + EVT_RIGHT_DOWN(OnMouseBtnDown) + EVT_MIDDLE_DOWN(OnMouseBtnDown) END_EVENT_TABLE() // `Main program' equivalent, creating windows and returning main app frame @@ -127,18 +134,34 @@ bool DnDApp::OnInit(void) } DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) - : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) + : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)), + m_strText("wxWindows drag & drop works :-)") + { + // frame icon and status bar SetIcon(wxIcon("mondrian")); + const int widths[] = { -1 }; + CreateStatusBar(); // construct menu wxMenu *file_menu = new wxMenu; - file_menu->Append(Menu_Help, "&Help"); - file_menu->Append(Menu_About, "&About"); + file_menu->Append(Menu_Drag, "&Test drag..."); file_menu->AppendSeparator(); file_menu->Append(Menu_Quit, "E&xit"); + + wxMenu *log_menu = new wxMenu; + log_menu->Append(Menu_Clear, "Clear"); + + wxMenu *help_menu = new wxMenu; + help_menu->Append(Menu_Help, "&Help..."); + help_menu->AppendSeparator(); + help_menu->Append(Menu_About, "&About"); + wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(file_menu, "&File"); + menu_bar->Append(log_menu, "&Log"); + menu_bar->Append(help_menu, "&Help"); + SetMenuBar(menu_bar); // make a panel with 3 subwindows @@ -154,9 +177,8 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) wxSUNKEN_BORDER| wxHSCROLL); // redirect log messages to the text window (don't forget to delete it!) -// m_pLog = new wxLogTextCtrl(m_ctrlLog); - m_pLog = NULL; - m_pLogPrev = wxLogTarget::SetActiveTarget(m_pLog); + m_pLog = new wxLogTextCtrl(m_ctrlLog); + m_pLogPrev = wxLog::SetActiveTarget(m_pLog); // associate drop targets with 2 text controls m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile)); @@ -168,21 +190,21 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) c->left.SameAs (this, wxLeft); c->top.SameAs (this, wxTop); c->right.PercentOf(this, wxRight, 50); - c->height.PercentOf(this, wxHeight, 50); + c->height.PercentOf(this, wxHeight, 40); m_ctrlFile->SetConstraints(c); c = new wxLayoutConstraints; c->left.SameAs (m_ctrlFile, wxRight); c->top.SameAs (this, wxTop); c->right.SameAs (this, wxRight); - c->height.PercentOf(this, wxHeight, 50); + c->height.PercentOf(this, wxHeight, 40); m_ctrlText->SetConstraints(c); c = new wxLayoutConstraints; c->left.SameAs (this, wxLeft); c->right.SameAs (this, wxRight); - c->height.PercentOf(this, wxHeight, 50); - c->bottom.SameAs(this, wxBottom); + c->height.PercentOf(this, wxHeight, 40); + c->top.SameAs(m_ctrlText, wxBottom); m_ctrlLog->SetConstraints(c); @@ -194,11 +216,26 @@ void DnDFrame::OnQuit(wxCommandEvent& /* event */) Close(TRUE); } +void DnDFrame::OnDrag(wxCommandEvent& /* event */) +{ + wxString strText = wxGetTextFromUser + ( + "After you enter text in this dialog, press any mouse\n" + "button in the bottom (empty) part of the frame and \n" + "drag it anywhere - you will be in fact dragging the\n" + "text object containing this text", + "Please enter some text", m_strText, this + ); + + m_strText = strText; +} + void DnDFrame::OnAbout(wxCommandEvent& /* event */) { wxMessageDialog dialog(this, "Drag-&-Drop Demo\n" - "Please see File|Help for details", + "Please see \"Help|Help...\" for details\n" + "Copyright (c) 1998 Vadim Zeitlin", "About wxDnD"); dialog.ShowModal(); @@ -207,35 +244,68 @@ void DnDFrame::OnAbout(wxCommandEvent& /* event */) void DnDFrame::OnHelp(wxCommandEvent& /* event */) { wxMessageDialog dialog(this, -"This small program demonstrates drag & drop support in wxWindows.\n" -"The program window consists of 3 parts: the bottom pane is for\n" -"debug messages, so that you can see what's going on inside.\n" -"The top part is split into 2 listboxes, the left one accepts\n" -"files and the right one accepts text.\n" -"\n" -"To test it: open wordpad (write.exe), select some text in it and\n" -"drag it to the right listbox (you'll notice the usual visual\n" -"feedback, i.e. the cursor will change). Also, try dragging some\n" -"files (you can select several at once) from Windows Explorer (or\n" -"File Manager) to the left pane. Hold down Ctrl/Shift keys when\n" -"you drop text (doesn't work with files) and see what changes.\n" -"\n" -"Please address any questions/bug reports/suggestions &c to\n" +"This small program demonstrates drag & drop support in wxWindows. " +"The program window consists of 3 parts: the bottom pane is for " +"debug messages, so that you can see what's going on inside. " +"The top part is split into 2 listboxes, the left one accepts " +"files and the right one accepts text." +"\n\n" +"To test wxDropTarget: open wordpad (write.exe), select some text in " +"it and drag it to the right listbox (you'll notice the usual visual " +"feedback, i.e. the cursor will change). Also, try dragging some " +"files (you can select several at once) from Windows Explorer (or " +"File Manager) to the left pane. Hold down Ctrl/Shift keys when " +"you drop text (doesn't work with files) and see what changes. " +"\n\n" +"To test wxDropSource: just press any mouse button on the empty zone of " +"the window and drag it to wordpad or any other droptarget accepting " +"text (and of course you can just drag it to the right pane). Due to " +"a lot of trace messages, the cursor might take some time to change, " +"don't release the mouse button until it does. You can change the " +"string being dragged in in \"File|Test drag...\" dialog." +"\n\n" +"Please send all questions/bug reports/suggestions &c to " "Vadim Zeitlin ", "wxDnD Help"); dialog.ShowModal(); } +void DnDFrame::OnLogClear(wxCommandEvent& event) +{ + m_ctrlLog->Clear(); +} + bool DnDFrame::OnClose() { return TRUE; } +void DnDFrame::OnMouseBtnDown(wxMouseEvent& event) +{ + if ( !m_strText.IsEmpty() ) { + // start drag operation + wxTextDataObject data(m_strText); + wxDropSource dragSource(data); + const char *pc; + + switch ( dragSource.DoDragDrop(TRUE) ) { + case wxDropSource::Error: pc = "Error!"; break; + case wxDropSource::None: pc = "Nothing"; break; + case wxDropSource::Copy: pc = "Copied"; break; + case wxDropSource::Move: pc = "Moved"; break; + case wxDropSource::Cancel: pc = "Cancelled"; break; + default: pc = "Huh?"; break; + } + + SetStatusText(wxString("Drag result: ") + pc); + } +} + DnDFrame::~DnDFrame() { if ( m_pLog != NULL ) { - if ( wxLogTarget::SetActiveTarget(m_pLogPrev) == m_pLog ) + if ( wxLog::SetActiveTarget(m_pLogPrev) == m_pLog ) delete m_pLog; } } diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 9738d699db..724fab1429 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -795,6 +795,8 @@ void wxToolBarBase::CalcUnscrolledPosition(const int x, const int y, float *xx, void wxToolBarBase::OnIdle(wxIdleEvent& event) { + wxWindow::OnIdle(event); + DoToolbarUpdates(); } diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 21c9567042..b173d2bd58 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -175,25 +175,20 @@ wxControl *wxFakeItemEvent(wxWindow *parent, wxControl *item, wxMouseEvent& even void wxControl::MSWOnMouseMove(const int x, const int y, const WXUINT flags) { - // 'normal' move event... - // Set cursor, but only if we're not in 'busy' mode - /* // Trouble with this is that it sets the cursor for controls too :-( if (m_windowCursor.Ok() && !wxIsBusy()) ::SetCursor(m_windowCursor.GetHCURSOR()); */ - wxMouseEvent event(wxEVENT_TYPE_MOTION); - -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); + if (!m_mouseInWindow) + { + // Generate an ENTER event + m_mouseInWindow = TRUE; + MSWOnMouseEnter(x, y, flags); + } - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ + wxMouseEvent event(wxEVT_MOTION); event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); @@ -207,16 +202,16 @@ void wxControl::MSWOnMouseMove(const int x, const int y, const WXUINT flags) // Window gets a click down message followed by a mouse move // message even if position isn't changed! We want to discard // the trailing move event if x and y are the same. - if ((m_lastEvent == wxEVENT_TYPE_RIGHT_DOWN || m_lastEvent == wxEVENT_TYPE_LEFT_DOWN || - m_lastEvent == wxEVENT_TYPE_MIDDLE_DOWN) && + if ((m_lastEvent == wxEVT_RIGHT_DOWN || m_lastEvent == wxEVT_LEFT_DOWN || + m_lastEvent == wxEVT_MIDDLE_DOWN) && (m_lastXPos == event.GetX() && m_lastYPos == event.GetY())) { m_lastXPos = event.GetX(); m_lastYPos = event.GetY(); - m_lastEvent = wxEVENT_TYPE_MOTION; + m_lastEvent = wxEVT_MOTION; return; } - m_lastEvent = wxEVENT_TYPE_MOTION; + m_lastEvent = wxEVT_MOTION; m_lastXPos = event.GetX(); m_lastYPos = event.GetY(); GetEventHandler()->OldOnMouseEvent(event); } diff --git a/src/msw/makefile.b32 b/src/msw/makefile.b32 index 2f14f15458..5c54df4c22 100644 --- a/src/msw/makefile.b32 +++ b/src/msw/makefile.b32 @@ -184,6 +184,8 @@ MSWOBJS = \ $(MSWDIR)\wave.obj \ $(MSWDIR)\window.obj \ $(MSWDIR)\droptgt.obj \ + $(MSWDIR)\dropsrc.obj \ + $(MSWDIR)\dataobj.obj \ $(MSWDIR)\oleutils.obj \ $(MSWDIR)\uuid.obj @@ -366,6 +368,10 @@ $(MSWDIR)\window.obj: $(MSWDIR)\window.$(SRCSUFF) $(MSWDIR)\droptgt.obj: $(OLEDIR)\droptgt.$(SRCSUFF) +$(MSWDIR)\dropsrc.obj: $(OLEDIR)\dropsrc.$(SRCSUFF) + +$(MSWDIR)\dataobj.obj: $(OLEDIR)\dataobj.$(SRCSUFF) + $(MSWDIR)\oleutils.obj: $(OLEDIR)\oleutils.$(SRCSUFF) $(MSWDIR)\uuid.obj: $(OLEDIR)\uuid.$(SRCSUFF) diff --git a/src/msw/makefile.dos b/src/msw/makefile.dos index 2116473922..aaa369bbb4 100644 --- a/src/msw/makefile.dos +++ b/src/msw/makefile.dos @@ -180,6 +180,8 @@ MSWOBJS = \ $(MSWDIR)\wave.obj \ $(MSWDIR)\window.obj \ $(OLEDIR)\droptgt.obj \ + $(OLEDIR)\dropsrc.obj \ + $(OLEDIR)\dataobj.obj \ $(OLEDIR)\oleutils.obj \ $(OLEDIR)\uuid.obj @@ -602,6 +604,16 @@ $(OLEDIR)/droptgt.obj: $*.$(SRCSUFF) $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) << +$(OLEDIR)/dropsrc.obj: $*.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) +<< + +$(OLEDIR)/dataobj.obj: $*.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) +<< + $(OLEDIR)/oleutils.obj: $*.$(SRCSUFF) cl @<< $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95 index e5748cdd8a..8e972d826e 100644 --- a/src/msw/makefile.g95 +++ b/src/msw/makefile.g95 @@ -190,6 +190,8 @@ MSWOBJS = \ wave.$(OBJSUFF) \ window.$(OBJSUFF) \ $(OLEDIR)/droptgt.$(OBJSUFF) \ + $(OLEDIR)/dropsrc.$(OBJSUFF) \ + $(OLEDIR)/dataobj.$(OBJSUFF) \ $(OLEDIR)/oleutils.$(OBJSUFF) \ $(OLEDIR)/uuid.$(OBJSUFF) diff --git a/src/msw/makefile.nt b/src/msw/makefile.nt index 5462b49788..e6671606ca 100644 --- a/src/msw/makefile.nt +++ b/src/msw/makefile.nt @@ -190,9 +190,12 @@ MSWOBJS = \ $(MSWDIR)\wave.obj \ $(MSWDIR)\window.obj \ $(OLEDIR)\droptgt.obj \ + $(OLEDIR)\dropsrc.obj \ + $(OLEDIR)\dataobj.obj \ $(OLEDIR)\oleutils.obj \ $(OLEDIR)\uuid.obj + OBJECTS = $(COMMONOBJS) $(GENERICOBJS) $(MSWOBJS) # Normal, static library @@ -644,6 +647,18 @@ $(OLEDIR)/droptgt.obj: $*.$(SRCSUFF) $(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@ << +$(OLEDIR)/dropsrc.obj: $*.$(SRCSUFF) + echo $(CPPFLAGS) + cl @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@ +<< + +$(OLEDIR)/dataobj.obj: $*.$(SRCSUFF) + echo $(CPPFLAGS) + cl @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) /Fo$@ +<< + $(OLEDIR)/oleutils.obj: $*.$(SRCSUFF) echo $(CPPFLAGS) cl @<< diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 4f8b2a6558..fec8650334 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2235,18 +2235,8 @@ void wxWindow::MSWOnLButtonDown(const int x, const int y, const WXUINT flags) } #endif -//wxDebugMsg("LButtonDown\n") ; wxMouseEvent event(wxEVENT_TYPE_LEFT_DOWN); -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); event.m_controlDown = ((flags & MK_CONTROL) != 0); @@ -2262,18 +2252,8 @@ void wxWindow::MSWOnLButtonDown(const int x, const int y, const WXUINT flags) void wxWindow::MSWOnLButtonUp(const int x, const int y, const WXUINT flags) { -//wxDebugMsg("LButtonUp\n") ; wxMouseEvent event(wxEVENT_TYPE_LEFT_UP); -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); event.m_controlDown = ((flags & MK_CONTROL) != 0); @@ -2290,20 +2270,10 @@ void wxWindow::MSWOnLButtonUp(const int x, const int y, const WXUINT flags) void wxWindow::MSWOnLButtonDClick(const int x, const int y, const WXUINT flags) { -//wxDebugMsg("LButtonDClick\n") ; /* MATTHEW: If dclick not allowed, generate another single-click */ wxMouseEvent event(m_doubleClickAllowed ? wxEVENT_TYPE_LEFT_DCLICK : wxEVENT_TYPE_LEFT_DOWN); -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); event.m_controlDown = ((flags & MK_CONTROL) != 0); @@ -2342,18 +2312,8 @@ void wxWindow::MSWOnMButtonDown(const int x, const int y, const WXUINT flags) } #endif -//wxDebugMsg("MButtonDown\n") ; wxMouseEvent event(wxEVENT_TYPE_MIDDLE_DOWN); -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); event.m_controlDown = ((flags & MK_CONTROL) != 0); @@ -2372,15 +2332,6 @@ void wxWindow::MSWOnMButtonUp(const int x, const int y, const WXUINT flags) //wxDebugMsg("MButtonUp\n") ; wxMouseEvent event(wxEVENT_TYPE_MIDDLE_UP); -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); event.m_controlDown = ((flags & MK_CONTROL) != 0); @@ -2401,15 +2352,6 @@ void wxWindow::MSWOnMButtonDClick(const int x, const int y, const WXUINT flags) wxMouseEvent event((m_doubleClickAllowed) ? wxEVENT_TYPE_MIDDLE_DCLICK : wxEVENT_TYPE_MIDDLE_DOWN); -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); event.m_controlDown = ((flags & MK_CONTROL) != 0); @@ -2447,18 +2389,8 @@ void wxWindow::MSWOnRButtonDown(const int x, const int y, const WXUINT flags) } #endif -//wxDebugMsg("RButtonDown\n") ; wxMouseEvent event(wxEVENT_TYPE_RIGHT_DOWN); -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); event.m_controlDown = ((flags & MK_CONTROL) != 0); @@ -2474,18 +2406,8 @@ void wxWindow::MSWOnRButtonDown(const int x, const int y, const WXUINT flags) void wxWindow::MSWOnRButtonUp(const int x, const int y, const WXUINT flags) { -//wxDebugMsg("RButtonUp\n") ; wxMouseEvent event(wxEVENT_TYPE_RIGHT_UP); -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); event.m_controlDown = ((flags & MK_CONTROL) != 0); @@ -2501,20 +2423,10 @@ void wxWindow::MSWOnRButtonUp(const int x, const int y, const WXUINT flags) void wxWindow::MSWOnRButtonDClick(const int x, const int y, const WXUINT flags) { -//wxDebugMsg("RButtonDClick\n") ; /* MATTHEW: If dclick not allowed, generate another single-click */ wxMouseEvent event((m_doubleClickAllowed) ? wxEVENT_TYPE_RIGHT_DCLICK : wxEVENT_TYPE_RIGHT_DOWN); -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); event.m_controlDown = ((flags & MK_CONTROL) != 0); @@ -2538,127 +2450,15 @@ void wxWindow::MSWOnMouseMove(const int x, const int y, const WXUINT flags) if (m_windowCursor.Ok() && !wxIsBusy()) ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR()); - wxMouseEvent event(wxEVENT_TYPE_MOTION); - -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - - event.m_x = x; event.m_y = y; - event.m_shiftDown = ((flags & MK_SHIFT) != 0); - event.m_controlDown = ((flags & MK_CONTROL) != 0); - event.m_leftDown = ((flags & MK_LBUTTON) != 0); - event.m_middleDown = ((flags & MK_MBUTTON) != 0); - event.m_rightDown = ((flags & MK_RBUTTON) != 0); - event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ - event.m_eventObject = this; - - // Window gets a click down message followed by a mouse move - // message even if position isn't changed! We want to discard - // the trailing move event if x and y are the same. - if ((m_lastEvent == wxEVENT_TYPE_RIGHT_DOWN || m_lastEvent == wxEVENT_TYPE_LEFT_DOWN || - m_lastEvent == wxEVENT_TYPE_MIDDLE_DOWN) && - (m_lastXPos == event.m_x && m_lastYPos == event.m_y)) - { - m_lastXPos = event.m_x; m_lastYPos = event.m_y; - m_lastEvent = wxEVENT_TYPE_MOTION; - return; - } - - m_lastEvent = wxEVENT_TYPE_MOTION; - m_lastXPos = event.m_x; m_lastYPos = event.m_y; - GetEventHandler()->OldOnMouseEvent(event); -} - -/* TODO put back leave/enter code if required - */ -#if 0 -void wxWindow::MSWOnMouseMove(int x, int y, WXUINT flags) -{ -//wxDebugMsg("Client 0x%08x Move Msg %d,%d\n",this,x,y) ; - -// #if MOUSE_EXIT_FIX //Should work now!! - - // Don't do the Leave/Enter fix if we've captured the window, - // or SetCapture won't work properly. - if (!m_winCaptured) + if (!m_mouseInWindow) { - HWND hunder ; - POINT pt ; - // See if we Leave/Enter the window. - GetCursorPos(&pt) ; - hunder = WindowFromPoint(pt) ; - if (hunder==m_hWnd) - { - // I'm in the Window, but perhaps in NC area. - RECT wind ; - RECT nc ; - GetClientRect(m_hWnd,&wind) ; - GetWindowRect(m_hWnd,&nc) ; - pt.x -= nc.left ; - pt.y -= nc.top ; - wind.left += WINDOW_MARGIN ; // to be able to 'see' leave - wind.top += WINDOW_MARGIN ; // to be able to 'see' leave - wind.right -= WINDOW_MARGIN ; // to be able to 'see' leave - wind.bottom -= WINDOW_MARGIN ; // to be able to 'see' leave - - if (!PtInRect(&wind,pt)) - hunder = NULL ; // So, I can simulate a Leave event... - } - - if (hunder!=m_hWnd) - { - if (m_mouseInWindow) - { - m_mouseInWindow = FALSE ; - // Capture/Release is no more needed... - //ReleaseCapture() ; - MSWOnMouseLeave(x,y,flags) ; - return ; - } - // We never want to see Enter or Motion in this part of the Window... - return ; - } - else - { - // Event was triggered while I'm really into my client area. - // Do an Enter if not done. - if (!m_mouseInWindow) - { - m_mouseInWindow = TRUE ; - // Capture/Release is no more needed... - //SetCapture(m_hWnd) ; - // Set cursor, but only if we're not in 'busy' mode - if (m_windowCursor.Ok() && !wxIsBusy()) - ::SetCursor(m_windowCursor.ms_cursor); - MSWOnMouseEnter(x,y,flags) ; - return ; - } - } + // Generate an ENTER event + m_mouseInWindow = TRUE; + MSWOnMouseEnter(x, y, flags); } -// #endif //MOUSE_EXIT_FIX - - // 'normal' move event... - // Set cursor, but only if we're not in 'busy' mode - if (m_windowCursor.Ok() && !wxIsBusy()) - ::SetCursor(m_windowCursor.ms_cursor); wxMouseEvent event(wxEVENT_TYPE_MOTION); -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ - event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); event.m_controlDown = ((flags & MK_CONTROL) != 0); @@ -2684,26 +2484,10 @@ void wxWindow::MSWOnMouseMove(int x, int y, WXUINT flags) m_lastXPos = event.m_x; m_lastYPos = event.m_y; GetEventHandler()->OldOnMouseEvent(event); } -#endif void wxWindow::MSWOnMouseEnter(const int x, const int y, const WXUINT flags) { -//wxDebugMsg("Client 0x%08x Enter %d,%d\n",this,x,y) ; - - // Set cursor, but only if we're not in 'busy' mode - if (m_windowCursor.Ok() && !wxIsBusy()) - ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR()); - - wxMouseEvent event(wxEVENT_TYPE_ENTER_WINDOW); - -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ + wxMouseEvent event(wxEVT_ENTER_WINDOW); event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); @@ -2714,29 +2498,14 @@ void wxWindow::MSWOnMouseEnter(const int x, const int y, const WXUINT flags) event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ event.m_eventObject = this; - m_lastEvent = wxEVENT_TYPE_ENTER_WINDOW; + m_lastEvent = wxEVT_ENTER_WINDOW; m_lastXPos = event.m_x; m_lastYPos = event.m_y; GetEventHandler()->OldOnMouseEvent(event); } void wxWindow::MSWOnMouseLeave(const int x, const int y, const WXUINT flags) { -//wxDebugMsg("Client 0x%08x Leave %d,%d\n",this,x,y) ; - - // Set cursor, but only if we're not in 'busy' mode - if (m_windowCursor.Ok() && !wxIsBusy()) - ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR()); - - wxMouseEvent event(wxEVENT_TYPE_LEAVE_WINDOW); - -/* - float px = (float)x; - float py = (float)y; - - MSWDeviceToLogical(&px, &py); - - CalcUnscrolledPosition((int)px, (int)py, &event.m_x, &event.m_y); -*/ + wxMouseEvent event(wxEVT_LEAVE_WINDOW); event.m_x = x; event.m_y = y; event.m_shiftDown = ((flags & MK_SHIFT) != 0); @@ -2747,7 +2516,7 @@ void wxWindow::MSWOnMouseLeave(const int x, const int y, const WXUINT flags) event.SetTimestamp(wxApp::sm_lastMessageTime); /* MATTHEW: timeStamp */ event.m_eventObject = this; - m_lastEvent = wxEVENT_TYPE_LEAVE_WINDOW; + m_lastEvent = wxEVT_LEAVE_WINDOW; m_lastXPos = event.m_x; m_lastYPos = event.m_y; GetEventHandler()->OldOnMouseEvent(event); } @@ -2810,13 +2579,6 @@ void wxWindow::MSWOnChar(const WXWORD wParam, const WXLPARAM lParam, const bool pt.x -= rect.left ; pt.y -= rect.top ; -/* - float fx,fy ; - fx = (float)pt.x ; - fy = (float)pt.y ; - MSWDeviceToLogical(&fx,&fy) ; - CalcUnscrolledPosition((int)fx,(int)fy,&event.m_x,&event.m_y) ; -*/ event.m_x = pt.x; event.m_y = pt.y; #if WXWIN_COMPATIBILITY @@ -4950,6 +4712,19 @@ void wxWindow::UpdateWindowUI(void) void wxWindow::OnIdle(wxIdleEvent& event) { + // Check if we need to send a LEAVE event + if (m_mouseInWindow) + { + POINT pt; + ::GetCursorPos(&pt); + if (::WindowFromPoint(pt) != (HWND) GetHWND()) + { + // Generate a LEAVE event + m_mouseInWindow = FALSE; + MSWOnMouseLeave(pt.x, pt.y, 0); + } + } + UpdateWindowUI(); } -- 2.45.2