* Fixed wxToolbar95 and wxToolbarGTK to emit TOOL_ENTER event with id==-1 when the mouse
leaves a tool. * Fixed wxToolbar95::FindToolForPosition to take into account dummy spacers inserted together with a control for comctl32.dll versions < 4.71 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11676 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -99,6 +99,9 @@ protected:
|
|||||||
// the total number of toolbar elements
|
// the total number of toolbar elements
|
||||||
size_t m_nButtons;
|
size_t m_nButtons;
|
||||||
|
|
||||||
|
// the tool the cursor is in
|
||||||
|
wxToolBarToolBase *m_pInTool;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
DECLARE_DYNAMIC_CLASS(wxToolBar)
|
DECLARE_DYNAMIC_CLASS(wxToolBar)
|
||||||
|
@@ -128,11 +128,11 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// "enter_notify_event"
|
// "enter_notify_event" / "leave_notify_event"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
|
static gint gtk_toolbar_tool_callback( GtkWidget *WXUNUSED(widget),
|
||||||
GdkEventCrossing *WXUNUSED(gdk_event),
|
GdkEventCrossing *gdk_event,
|
||||||
wxToolBarTool *tool )
|
wxToolBarTool *tool )
|
||||||
{
|
{
|
||||||
if (g_isIdle) wxapp_install_idle_handler();
|
if (g_isIdle) wxapp_install_idle_handler();
|
||||||
@@ -142,7 +142,10 @@ static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
wxToolBar *tb = (wxToolBar *)tool->GetToolBar();
|
wxToolBar *tb = (wxToolBar *)tool->GetToolBar();
|
||||||
|
|
||||||
// emit the event
|
// emit the event
|
||||||
|
if( gdk_event->type == GDK_ENTER_NOTIFY )
|
||||||
tb->OnMouseEnter( tool->GetId() );
|
tb->OnMouseEnter( tool->GetId() );
|
||||||
|
else
|
||||||
|
tb->OnMouseEnter( -1 );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -349,7 +352,11 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
|
|||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(tool->m_item),
|
gtk_signal_connect( GTK_OBJECT(tool->m_item),
|
||||||
"enter_notify_event",
|
"enter_notify_event",
|
||||||
GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback),
|
GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
|
||||||
|
(gpointer)tool );
|
||||||
|
gtk_signal_connect( GTK_OBJECT(tool->m_item),
|
||||||
|
"leave_notify_event",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
|
||||||
(gpointer)tool );
|
(gpointer)tool );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -128,11 +128,11 @@ static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// "enter_notify_event"
|
// "enter_notify_event" / "leave_notify_event"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
|
static gint gtk_toolbar_tool_callback( GtkWidget *WXUNUSED(widget),
|
||||||
GdkEventCrossing *WXUNUSED(gdk_event),
|
GdkEventCrossing *gdk_event,
|
||||||
wxToolBarTool *tool )
|
wxToolBarTool *tool )
|
||||||
{
|
{
|
||||||
if (g_isIdle) wxapp_install_idle_handler();
|
if (g_isIdle) wxapp_install_idle_handler();
|
||||||
@@ -142,7 +142,10 @@ static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
wxToolBar *tb = (wxToolBar *)tool->GetToolBar();
|
wxToolBar *tb = (wxToolBar *)tool->GetToolBar();
|
||||||
|
|
||||||
// emit the event
|
// emit the event
|
||||||
|
if( gdk_event->type == GDK_ENTER_NOTIFY )
|
||||||
tb->OnMouseEnter( tool->GetId() );
|
tb->OnMouseEnter( tool->GetId() );
|
||||||
|
else
|
||||||
|
tb->OnMouseEnter( -1 );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -349,7 +352,11 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
|
|||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(tool->m_item),
|
gtk_signal_connect( GTK_OBJECT(tool->m_item),
|
||||||
"enter_notify_event",
|
"enter_notify_event",
|
||||||
GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback),
|
GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
|
||||||
|
(gpointer)tool );
|
||||||
|
gtk_signal_connect( GTK_OBJECT(tool->m_item),
|
||||||
|
"leave_notify_event",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback),
|
||||||
(gpointer)tool );
|
(gpointer)tool );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -815,9 +815,6 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For backward compatibility...
|
|
||||||
OnMouseEnter(tool->GetId());
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -872,6 +869,25 @@ wxSize wxToolBar::GetToolSize() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static wxToolBarToolBase *GetItemSkippingDummySpacers( const wxToolBarToolsList& tools, size_t index )
|
||||||
|
{
|
||||||
|
wxToolBarToolsList::Node* current = tools.GetFirst();
|
||||||
|
|
||||||
|
for( ; current != 0; current = current->GetNext() )
|
||||||
|
{
|
||||||
|
if( index == 0 )
|
||||||
|
return current->GetData();
|
||||||
|
size_t separators = ((wxToolBarTool*)current->GetData())->GetSeparatorsCount();
|
||||||
|
// if it is a normal button, sepcount == 0, so skip 1
|
||||||
|
// item ( the button )
|
||||||
|
// otherwise, skip as many items as the separator count,
|
||||||
|
// plus the control itself
|
||||||
|
index -= separators ? separators + 1: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
|
wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
|
||||||
{
|
{
|
||||||
POINT pt;
|
POINT pt;
|
||||||
@@ -884,7 +900,20 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const
|
|||||||
return (wxToolBarToolBase *)NULL;
|
return (wxToolBarToolBase *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if comctl32 version < 4.71
|
||||||
|
// wxToolBar95 adds dummy spacers
|
||||||
|
#if defined(_WIN32_IE) && (_WIN32_IE >= 0x400 )
|
||||||
|
if ( wxTheApp->GetComCtl32Version() >= 471 )
|
||||||
|
{
|
||||||
return m_tools.Item((size_t)index)->GetData();
|
return m_tools.Item((size_t)index)->GetData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return GetItemSkippingDummySpacers( m_tools, (size_t) index );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return GetItemSkippingDummySpacers( m_tools, (size_t) index );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxToolBar::UpdateSize()
|
void wxToolBar::UpdateSize()
|
||||||
@@ -1002,6 +1031,28 @@ long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( nMsg == WM_MOUSEMOVE )
|
||||||
|
{
|
||||||
|
wxCoord x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);
|
||||||
|
wxToolBarToolBase* tool = FindToolForPosition( x, y );
|
||||||
|
|
||||||
|
// cursor left current tool
|
||||||
|
if( tool != m_pInTool && !tool )
|
||||||
|
{
|
||||||
|
m_pInTool = 0;
|
||||||
|
OnMouseEnter( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// cursor entered a tool
|
||||||
|
if( tool != m_pInTool && tool )
|
||||||
|
{
|
||||||
|
m_pInTool = tool;
|
||||||
|
OnMouseEnter( tool->GetId() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// we don't handle mouse moves, so fall through
|
||||||
|
// to wxControl::MSWWindowProc
|
||||||
|
}
|
||||||
|
|
||||||
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
|
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user