#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"
{ 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 },
// 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
-///////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////
// 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 <zeitlin@dptmaths.ens-cachan.fr>
-// 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__
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();
*m_ctrlText;
wxTextCtrl *m_ctrlLog;
- wxLogTarget *m_pLog, *m_pLogPrev;
+ wxLog *m_pLog, *m_pLogPrev;
+
+ wxString m_strText;
};
// ----------------------------------------------------------------------------
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
}
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
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));
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);
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();
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 <zeitlin@dptmaths.ens-cachan.fr>",
"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;
}
}
void wxToolBarBase::OnIdle(wxIdleEvent& event)
{
+ wxWindow::OnIdle(event);
+
DoToolbarUpdates();
}
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);
// 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);
}
$(MSWDIR)\wave.obj \
$(MSWDIR)\window.obj \
$(MSWDIR)\droptgt.obj \
+ $(MSWDIR)\dropsrc.obj \
+ $(MSWDIR)\dataobj.obj \
$(MSWDIR)\oleutils.obj \
$(MSWDIR)\uuid.obj
$(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)
$(MSWDIR)\wave.obj \
$(MSWDIR)\window.obj \
$(OLEDIR)\droptgt.obj \
+ $(OLEDIR)\dropsrc.obj \
+ $(OLEDIR)\dataobj.obj \
$(OLEDIR)\oleutils.obj \
$(OLEDIR)\uuid.obj
$(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)
wave.$(OBJSUFF) \
window.$(OBJSUFF) \
$(OLEDIR)/droptgt.$(OBJSUFF) \
+ $(OLEDIR)/dropsrc.$(OBJSUFF) \
+ $(OLEDIR)/dataobj.$(OBJSUFF) \
$(OLEDIR)/oleutils.$(OBJSUFF) \
$(OLEDIR)/uuid.$(OBJSUFF)
$(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
$(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 @<<
}
#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);
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);
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);
}
#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);
//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);
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);
}
#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);
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);
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);
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);
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);
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);
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);
}
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
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();
}