X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/43d811ea55a6dee36e17e6815dcd891a82d62e28..58c7cd12b9035450e702d36dfdce63bfd008bcd0:/src/common/tbarbase.cpp diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 724fab1429..318a701601 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -24,17 +24,19 @@ #include "wx/wx.h" #endif +#include "wx/frame.h" + // For ::UpdateWindow -#ifdef __WINDOWS__ +#ifdef __WXMSW__ #include #endif -#if USE_TOOLBAR +#if wxUSE_TOOLBAR #include "wx/tbarbase.h" #if !USE_SHARED_LIBRARY -IMPLEMENT_DYNAMIC_CLASS(wxToolBarBase, wxControl) +IMPLEMENT_ABSTRACT_CLASS(wxToolBarBase, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxToolBarTool, wxObject) BEGIN_EVENT_TABLE(wxToolBarBase, wxControl) @@ -48,20 +50,37 @@ END_EVENT_TABLE() // is still valid: a tool may have quit the toolbar. static wxList gs_ToolBars; -wxToolBarTool::wxToolBarTool(const int theIndex, - const wxBitmap& theBitmap1, const wxBitmap& theBitmap2, const bool toggle, - const long xPos, const long yPos, const wxString& helpS1, const wxString& helpS2) +#ifdef __WXGTK__ +wxToolBarTool::wxToolBarTool(wxToolBar *owner, int theIndex, + const wxBitmap& theBitmap1, const wxBitmap& theBitmap2, + bool toggle, wxObject *clientData, + const wxString& helpS1, const wxString& helpS2, + GtkWidget *pixmap ) +#else +wxToolBarTool::wxToolBarTool(int theIndex, + const wxBitmap& theBitmap1, const wxBitmap& theBitmap2, bool toggle, + long xPos, long yPos, const wxString& helpS1, const wxString& helpS2) +#endif { m_toolStyle = wxTOOL_STYLE_BUTTON; +#ifdef __WXGTK__ + m_owner = owner; + m_pixmap = pixmap; + m_item = (GtkWidget*) NULL; + m_clientData = clientData; + m_x = 0; + m_y = 0; +#else m_clientData = NULL; + m_x = xPos; + m_y = yPos; +#endif m_index = theIndex; m_isToggle = toggle; m_toggleState = FALSE; m_enabled = TRUE; m_bitmap1 = theBitmap1; m_bitmap2 = theBitmap2; - m_x = xPos; - m_y = yPos; m_width = m_height = 0; m_deleteSecondBitmap = FALSE; if (m_bitmap1.Ok()) @@ -73,7 +92,7 @@ wxToolBarTool::wxToolBarTool(const int theIndex, m_longHelpString = helpS2; } -wxToolBarTool::~wxToolBarTool(void) +wxToolBarTool::~wxToolBarTool() { /* if (m_deleteSecondBitmap && m_bitmap2) @@ -88,8 +107,8 @@ wxToolBarBase::wxToolBarBase(void) : m_tools(wxKEY_INTEGER) { gs_ToolBars.Append(this); - m_tilingDirection = wxVERTICAL; - m_rowsOrColumns = 0; + m_maxRows = 1; + m_maxCols = 32000; m_maxWidth = 0; m_maxHeight = 0; m_defaultWidth = 16; @@ -131,26 +150,34 @@ bool wxToolBarBase::OnLeftClick(int toolIndex, bool toggleDown) event.SetEventObject(this); event.SetExtraLong((long) toggleDown); + // Send events to this toolbar instead (and thence up the window hierarchy) GetEventHandler()->ProcessEvent(event); return TRUE; } // Call when right button down. -void wxToolBarBase::OnRightClick(int toolIndex, long x, long y) +void wxToolBarBase::OnRightClick(int toolIndex, + long WXUNUSED(x), + long WXUNUSED(y)) { wxCommandEvent event(wxEVT_COMMAND_TOOL_RCLICKED, toolIndex); event.SetEventObject(this); + event.SetInt(toolIndex); GetEventHandler()->ProcessEvent(event); } // Called when the mouse cursor enters a tool bitmap (no button pressed). // Argument is -1 if mouse is exiting the toolbar. +// Note that for this event, the id of the window is used, +// and the integer parameter of wxCommandEvent is used to retrieve +// the tool id. void wxToolBarBase::OnMouseEnter ( int toolIndex ) { - wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, toolIndex); + wxCommandEvent event(wxEVT_COMMAND_TOOL_ENTER, GetId()); event.SetEventObject(this); + event.SetInt(toolIndex); GetEventHandler()->ProcessEvent(event); } @@ -158,11 +185,16 @@ void wxToolBarBase::OnMouseEnter ( int toolIndex ) // If pushedBitmap is NULL, a reversed version of bitmap is // created and used as the pushed/toggled image. // If toggle is TRUE, the button toggles between the two states. -wxToolBarTool *wxToolBarBase::AddTool(const int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap, - const bool toggle, const long xPos, const long yPos, wxObject *clientData, +wxToolBarTool *wxToolBarBase::AddTool(int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap, + bool toggle, long xPos, long yPos, wxObject *clientData, const wxString& helpString1, const wxString& helpString2) { +#ifdef __WXGTK__ + wxToolBarTool *tool = new wxToolBarTool( (wxToolBar*)this, index, bitmap, pushedBitmap, toggle, + (wxObject*) NULL, helpString1, helpString2); +#else wxToolBarTool *tool = new wxToolBarTool(index, bitmap, pushedBitmap, toggle, xPos, yPos, helpString1, helpString2); +#endif tool->m_clientData = clientData; if (xPos > -1) @@ -174,7 +206,7 @@ wxToolBarTool *wxToolBarBase::AddTool(const int index, const wxBitmap& bitmap, c tool->m_y = yPos; else tool->m_y = m_yMargin; - + // Calculate reasonable max size in case Layout() not called if ((tool->m_x + bitmap.GetWidth() + m_xMargin) > m_maxWidth) m_maxWidth = (tool->m_x + bitmap.GetWidth() + m_xMargin); @@ -189,11 +221,12 @@ wxToolBarTool *wxToolBarBase::AddTool(const int index, const wxBitmap& bitmap, c void wxToolBarBase::AddSeparator () { wxToolBarTool *tool = new wxToolBarTool; + tool->m_index = -1; tool->m_toolStyle = wxTOOL_STYLE_SEPARATOR; - m_tools.Append(tool); + m_tools.Append(-1, tool); } -void wxToolBarBase::ClearTools(void) +void wxToolBarBase::ClearTools() { m_pressedTool = m_currentTool = -1; wxNode *node = m_tools.First(); @@ -207,7 +240,7 @@ void wxToolBarBase::ClearTools(void) } } -void wxToolBarBase::EnableTool(const int index, const bool enable) +void wxToolBarBase::EnableTool(int index, bool enable) { wxNode *node = m_tools.Find((long)index); if (node) @@ -218,11 +251,12 @@ void wxToolBarBase::EnableTool(const int index, const bool enable) } } -void wxToolBarBase::ToggleTool(const int index, const bool toggle) +void wxToolBarBase::ToggleTool(int WXUNUSED(index), + bool WXUNUSED(toggle)) { } -void wxToolBarBase::SetToggle(const int index, const bool value) +void wxToolBarBase::SetToggle(int index, bool value) { wxNode *node=m_tools.Find((long)index); if (node){ @@ -231,7 +265,7 @@ void wxToolBarBase::SetToggle(const int index, const bool value) } } -bool wxToolBarBase::GetToolState(const int index) const +bool wxToolBarBase::GetToolState(int index) const { wxNode *node = m_tools.Find((long)index); if (node) @@ -246,7 +280,7 @@ bool wxToolBarBase::GetToolState(const int index) const else return FALSE; } -bool wxToolBarBase::GetToolEnabled(const int index) const +bool wxToolBarBase::GetToolEnabled(int index) const { wxNode *node = m_tools.Find((long)index); if (node) @@ -261,7 +295,7 @@ bool wxToolBarBase::GetToolEnabled(const int index) const else return FALSE; } -wxObject *wxToolBarBase::GetToolClientData(const int index) const +wxObject *wxToolBarBase::GetToolClientData(int index) const { wxNode *node = m_tools.Find((long)index); if (node) @@ -276,7 +310,7 @@ wxObject *wxToolBarBase::GetToolClientData(const int index) const else return NULL; } -void wxToolBarBase::SetToolShortHelp(const int index, const wxString& helpString) +void wxToolBarBase::SetToolShortHelp(int index, const wxString& helpString) { wxNode *node=m_tools.Find((long)index); if (node) @@ -286,7 +320,7 @@ void wxToolBarBase::SetToolShortHelp(const int index, const wxString& helpString } } -wxString wxToolBarBase::GetToolShortHelp(const int index) const +wxString wxToolBarBase::GetToolShortHelp(int index) const { wxNode *node=m_tools.Find((long)index); if (node) @@ -298,7 +332,7 @@ wxString wxToolBarBase::GetToolShortHelp(const int index) const return wxString(""); } -void wxToolBarBase::SetToolLongHelp(const int index, const wxString& helpString) +void wxToolBarBase::SetToolLongHelp(int index, const wxString& helpString) { wxNode *node=m_tools.Find((long)index); if (node) @@ -308,7 +342,7 @@ void wxToolBarBase::SetToolLongHelp(const int index, const wxString& helpString) } } -wxString wxToolBarBase::GetToolLongHelp(const int index) const +wxString wxToolBarBase::GetToolLongHelp(int index) const { wxNode *node=m_tools.Find((long)index); if (node) @@ -320,7 +354,7 @@ wxString wxToolBarBase::GetToolLongHelp(const int index) const return wxString(""); } -wxToolBarTool *wxToolBarBase::FindToolForPosition(const long x, const long y) const +wxToolBarTool *wxToolBarBase::FindToolForPosition(long x, long y) const { wxNode *node = m_tools.First(); while (node) @@ -345,116 +379,28 @@ wxSize wxToolBarBase::GetMaxSize ( void ) const // the tool we're leaving was a 'sprung push button' and if so, // spring it back to the up state. // -void wxToolBarBase::SetMargins(const int x, const int y) +void wxToolBarBase::SetMargins(int x, int y) { m_xMargin = x; m_yMargin = y; } -void wxToolBarBase::SetToolPacking(const int packing) +void wxToolBarBase::SetToolPacking(int packing) { m_toolPacking = packing; } -void wxToolBarBase::SetToolSeparation(const int separation) +void wxToolBarBase::SetToolSeparation(int separation) { m_toolSeparation = separation; } -void wxToolBarBase::Command(wxCommandEvent& event) +void wxToolBarBase::Command(wxCommandEvent& WXUNUSED(event)) { } -void wxToolBarBase::Layout(void) +void wxToolBarBase::LayoutTools() { - m_currentRowsOrColumns = 0; - m_lastX = m_xMargin; - m_lastY = m_yMargin; - int maxToolWidth = 0; - int maxToolHeight = 0; - m_maxWidth = 0; - m_maxHeight = 0; - - // Find the maximum tool width and height - wxNode *node = m_tools.First(); - while (node) - { - wxToolBarTool *tool = (wxToolBarTool *)node->Data(); - if (tool->GetWidth() > maxToolWidth) - maxToolWidth = (int)tool->GetWidth(); - if (tool->GetHeight() > maxToolHeight) - maxToolHeight = (int)tool->GetHeight(); - node = node->Next(); - } - - int separatorSize = m_toolSeparation; - - node = m_tools.First(); - while (node) - { - wxToolBarTool *tool = (wxToolBarTool *)node->Data(); - if (tool->m_toolStyle == wxTOOL_STYLE_SEPARATOR) - { - if (m_tilingDirection == wxHORIZONTAL) - { - if (m_currentRowsOrColumns >= m_rowsOrColumns) - m_lastY += separatorSize; - else - m_lastX += separatorSize; - } - else - { - if (m_currentRowsOrColumns >= m_rowsOrColumns) - m_lastX += separatorSize; - else - m_lastY += separatorSize; - } - } - else if (tool->m_toolStyle == wxTOOL_STYLE_BUTTON) - { - if (m_tilingDirection == wxHORIZONTAL) - { - if (m_currentRowsOrColumns >= m_rowsOrColumns) - { - m_currentRowsOrColumns = 0; - m_lastX = m_xMargin; - m_lastY += maxToolHeight + m_toolPacking; - } - tool->m_x = (long) (m_lastX + (maxToolWidth - tool->GetWidth())/2.0); - tool->m_y = (long) (m_lastY + (maxToolHeight - tool->GetHeight())/2.0); - - m_lastX += maxToolWidth + m_toolPacking; - } - else - { - if (m_currentRowsOrColumns >= m_rowsOrColumns) - { - m_currentRowsOrColumns = 0; - m_lastX += (maxToolWidth + m_toolPacking); - m_lastY = m_yMargin; - } - tool->m_x = (long) (m_lastX + (maxToolWidth - tool->GetWidth())/2.0); - tool->m_y = (long) (m_lastY + (maxToolHeight - tool->GetHeight())/2.0); - - m_lastY += maxToolHeight + m_toolPacking; - } - m_currentRowsOrColumns ++; - } - - if (m_lastX > m_maxWidth) - m_maxWidth = m_lastX; - if (m_lastY > m_maxHeight) - m_maxHeight = m_lastY; - - node = node->Next(); - } - if (m_tilingDirection == wxVERTICAL) - m_maxWidth += maxToolWidth; - else - m_maxHeight += maxToolHeight; - - m_maxWidth += m_xMargin; - m_maxHeight += m_yMargin; } @@ -464,9 +410,9 @@ void wxToolBarBase::Layout(void) * pixelsPerUnitX/pixelsPerUnitY: number of pixels per unit (e.g. pixels per text line) * noUnitsX/noUnitsY: : no. units per scrollbar */ -void wxToolBarBase::SetScrollbars (const int pixelsPerUnitX, const int pixelsPerUnitY, - const int noUnitsX, const int noUnitsY, - const int xPos, const int yPos) +void wxToolBarBase::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY, + int noUnitsX, int noUnitsY, + int xPos, int yPos) { m_xScrollPixelsPerLine = pixelsPerUnitX; m_yScrollPixelsPerLine = pixelsPerUnitY; @@ -478,29 +424,29 @@ void wxToolBarBase::SetScrollbars (const int pixelsPerUnitX, const int pixelsPer // Recalculate scroll bar range and position if (m_xScrollLines > 0) - { - m_xScrollPosition = xPos; - SetScrollPos (wxHORIZONTAL, m_xScrollPosition, TRUE); - } + { + m_xScrollPosition = xPos; + SetScrollPos (wxHORIZONTAL, m_xScrollPosition, TRUE); + } else { - SetScrollbar(wxHORIZONTAL, 0, 0, 0, FALSE); + SetScrollbar(wxHORIZONTAL, 0, 0, 0, FALSE); m_xScrollPosition = 0; } if (m_yScrollLines > 0) - { - m_yScrollPosition = yPos; - SetScrollPos (wxVERTICAL, m_yScrollPosition, TRUE); - } + { + m_yScrollPosition = yPos; + SetScrollPos (wxVERTICAL, m_yScrollPosition, TRUE); + } else { - SetScrollbar(wxVERTICAL, 0, 0, 0, FALSE); + SetScrollbar(wxVERTICAL, 0, 0, 0, FALSE); m_yScrollPosition = 0; } - AdjustScrollbars(); + AdjustScrollbars(); Refresh(); -#ifdef __WINDOWS__ +#ifdef __WXMSW__ ::UpdateWindow ((HWND) GetHWND()); #endif } @@ -559,7 +505,7 @@ int wxToolBarBase::CalcScrollInc(wxScrollEvent& event) int nScrollInc = 0; switch (event.GetEventType()) { - case wxEVENT_TYPE_SCROLL_TOP: + case wxEVT_SCROLL_TOP: { if (orient == wxHORIZONTAL) nScrollInc = - m_xScrollPosition; @@ -567,7 +513,7 @@ int wxToolBarBase::CalcScrollInc(wxScrollEvent& event) nScrollInc = - m_yScrollPosition; break; } - case wxEVENT_TYPE_SCROLL_BOTTOM: + case wxEVT_SCROLL_BOTTOM: { if (orient == wxHORIZONTAL) nScrollInc = m_xScrollLines - m_xScrollPosition; @@ -575,17 +521,17 @@ int wxToolBarBase::CalcScrollInc(wxScrollEvent& event) nScrollInc = m_yScrollLines - m_yScrollPosition; break; } - case wxEVENT_TYPE_SCROLL_LINEUP: + case wxEVT_SCROLL_LINEUP: { nScrollInc = -1; break; } - case wxEVENT_TYPE_SCROLL_LINEDOWN: + case wxEVT_SCROLL_LINEDOWN: { nScrollInc = 1; break; } - case wxEVENT_TYPE_SCROLL_PAGEUP: + case wxEVT_SCROLL_PAGEUP: { if (orient == wxHORIZONTAL) nScrollInc = -GetScrollPageSize(wxHORIZONTAL); @@ -593,7 +539,7 @@ int wxToolBarBase::CalcScrollInc(wxScrollEvent& event) nScrollInc = -GetScrollPageSize(wxVERTICAL); break; } - case wxEVENT_TYPE_SCROLL_PAGEDOWN: + case wxEVT_SCROLL_PAGEDOWN: { if (orient == wxHORIZONTAL) nScrollInc = GetScrollPageSize(wxHORIZONTAL); @@ -601,7 +547,7 @@ int wxToolBarBase::CalcScrollInc(wxScrollEvent& event) nScrollInc = GetScrollPageSize(wxVERTICAL); break; } - case wxEVENT_TYPE_SCROLL_THUMBTRACK: + case wxEVT_SCROLL_THUMBTRACK: { if (orient == wxHORIZONTAL) nScrollInc = pos - m_xScrollPosition; @@ -617,41 +563,41 @@ int wxToolBarBase::CalcScrollInc(wxScrollEvent& event) if (orient == wxHORIZONTAL) { int w, h; - GetClientSize(&w, &h); + GetClientSize(&w, &h); - int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine; - int noPositions = (int) ( ((nMaxWidth - w)/(float)m_xScrollPixelsPerLine) + 0.5 ); - if (noPositions < 0) - noPositions = 0; + int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine; + int noPositions = (int) ( ((nMaxWidth - w)/(float)m_xScrollPixelsPerLine) + 0.5 ); + if (noPositions < 0) + noPositions = 0; - if ( (m_xScrollPosition + nScrollInc) < 0 ) - nScrollInc = -m_xScrollPosition; // As -ve as we can go - else if ( (m_xScrollPosition + nScrollInc) > noPositions ) - nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go + if ( (m_xScrollPosition + nScrollInc) < 0 ) + nScrollInc = -m_xScrollPosition; // As -ve as we can go + else if ( (m_xScrollPosition + nScrollInc) > noPositions ) + nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go return nScrollInc; } else { int w, h; - GetClientSize(&w, &h); + GetClientSize(&w, &h); - int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine; - int noPositions = (int) ( ((nMaxHeight - h)/(float)m_yScrollPixelsPerLine) + 0.5 ); - if (noPositions < 0) - noPositions = 0; + int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine; + int noPositions = (int) ( ((nMaxHeight - h)/(float)m_yScrollPixelsPerLine) + 0.5 ); + if (noPositions < 0) + noPositions = 0; - if ( (m_yScrollPosition + nScrollInc) < 0 ) - nScrollInc = -m_yScrollPosition; // As -ve as we can go - else if ( (m_yScrollPosition + nScrollInc) > noPositions ) - nScrollInc = noPositions - m_yScrollPosition; // As +ve as we can go + if ( (m_yScrollPosition + nScrollInc) < 0 ) + nScrollInc = -m_yScrollPosition; // As -ve as we can go + else if ( (m_yScrollPosition + nScrollInc) > noPositions ) + nScrollInc = noPositions - m_yScrollPosition; // As +ve as we can go return nScrollInc; } } // Adjust the scrollbars - new version. -void wxToolBarBase::AdjustScrollbars(void) +void wxToolBarBase::AdjustScrollbars() { int w, h; GetClientSize(&w, &h); @@ -666,8 +612,8 @@ void wxToolBarBase::AdjustScrollbars(void) m_xScrollPosition = wxMin(newRange, m_xScrollPosition); - // Calculate page size i.e. number of scroll units you get on the - // current client window + // Calculate page size i.e. number of scroll units you get on the + // current client window int noPagePositions = (int) ( (w/(float)m_xScrollPixelsPerLine) + 0.5 ); if (noPagePositions < 1) noPagePositions = 1; @@ -684,8 +630,8 @@ void wxToolBarBase::AdjustScrollbars(void) m_yScrollPosition = wxMin(newRange, m_yScrollPosition); - // Calculate page size i.e. number of scroll units you get on the - // current client window + // Calculate page size i.e. number of scroll units you get on the + // current client window int noPagePositions = (int) ( (h/(float)m_yScrollPixelsPerLine) + 0.5 ); if (noPagePositions < 1) noPagePositions = 1; @@ -696,9 +642,9 @@ void wxToolBarBase::AdjustScrollbars(void) } // Default OnSize resets scrollbars, if any -void wxToolBarBase::OnSize(wxSizeEvent& event) +void wxToolBarBase::OnSize(wxSizeEvent& WXUNUSED(event)) { -#if USE_CONSTRAINTS +#if wxUSE_CONSTRAINTS if (GetAutoLayout()) Layout(); #endif @@ -709,7 +655,7 @@ void wxToolBarBase::OnSize(wxSizeEvent& event) // Prepare the DC by translating it according to the current scroll position void wxToolBarBase::PrepareDC(wxDC& dc) { - dc.SetDeviceOrigin(- m_xScrollPosition * m_xScrollPixelsPerLine, - m_yScrollPosition * m_yScrollPixelsPerLine); + dc.SetDeviceOrigin(- m_xScrollPosition * m_xScrollPixelsPerLine, - m_yScrollPosition * m_yScrollPixelsPerLine); } void wxToolBarBase::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const @@ -737,7 +683,7 @@ void wxToolBarBase::SetScrollPageSize(int orient, int pageSize) /* * Scroll to given position (scroll position, not pixel position) */ -void wxToolBarBase::Scroll (const int x_pos, const int y_pos) +void wxToolBarBase::Scroll (int x_pos, int y_pos) { int old_x, old_y; ViewStart (&old_x, &old_y); @@ -755,12 +701,12 @@ void wxToolBarBase::Scroll (const int x_pos, const int y_pos) SetScrollPos (wxVERTICAL, y_pos, TRUE); } Refresh(); -#ifdef __WINDOWS__ +#ifdef __WXMSW__ UpdateWindow ((HWND) GetHWND()); #endif } -void wxToolBarBase::EnableScrolling (const bool x_scroll, const bool y_scroll) +void wxToolBarBase::EnableScrolling (bool x_scroll, bool y_scroll) { m_xScrollingEnabled = x_scroll; m_yScrollingEnabled = y_scroll; @@ -779,60 +725,48 @@ void wxToolBarBase::ViewStart (int *x, int *y) const *y = m_yScrollPosition; } -/* -void wxToolBarBase::CalcScrolledPosition(const int x, const int y, int *xx, int *yy) const +void wxToolBarBase::OnIdle(wxIdleEvent& +#ifdef __WXGTK__ + WXUNUSED(event) +#else + event +#endif + ) { - *xx = (m_calcScrolledOffset ? (x - m_xScrollPosition * m_xScrollPixelsPerLine) : x); - *yy = (m_calcScrolledOffset ? (y - m_yScrollPosition * m_yScrollPixelsPerLine) : y); -} +#ifndef __WXGTK__ + wxWindow::OnIdle(event); +#endif -void wxToolBarBase::CalcUnscrolledPosition(const int x, const int y, float *xx, float *yy) const -{ - *xx = (float)(m_calcScrolledOffset ? (x + m_xScrollPosition * m_xScrollPixelsPerLine) : x); - *yy = (float)(m_calcScrolledOffset ? (y + m_yScrollPosition * m_yScrollPixelsPerLine) : y); + DoToolbarUpdates(); } -*/ -void wxToolBarBase::OnIdle(wxIdleEvent& event) +// Do the toolbar button updates (check for EVT_UPDATE_UI handlers) +void wxToolBarBase::DoToolbarUpdates() { - wxWindow::OnIdle(event); + wxEvtHandler* evtHandler = GetEventHandler() ; - DoToolbarUpdates(); -} + wxNode* node = GetTools().First(); + while (node) + { + wxToolBarTool* tool = (wxToolBarTool* ) node->Data(); -// Do the toolbar button updates (check for EVT_UPDATE_UI handlers) -void wxToolBarBase::DoToolbarUpdates(void) -{ - wxNode* node = GetTools().First(); - while (node) - { - wxToolBarTool* tool = (wxToolBarTool* ) node->Data(); - - wxUpdateUIEvent event(tool->m_index); - event.SetEventObject(this); - - if (GetEventHandler()->ProcessEvent(event)) - { - if (event.GetSetEnabled()) - EnableTool(tool->m_index, event.GetEnabled()); - if (event.GetSetChecked()) - ToggleTool(tool->m_index, event.GetChecked()); + wxUpdateUIEvent event(tool->m_index); + event.SetEventObject(this); + + if (evtHandler->ProcessEvent(event)) + { + if (event.GetSetEnabled()) + EnableTool(tool->m_index, event.GetEnabled()); + if (event.GetSetChecked()) + ToggleTool(tool->m_index, event.GetChecked()); /* - if (event.GetSetText()) - // Set tooltip? + if (event.GetSetText()) + // Set tooltip? */ - } - - node = node->Next(); - } -} + } -#ifdef __WINDOWS__ -// Circumvent wxControl::MSWOnMouseMove which doesn't set the cursor. -void wxToolBarBase::MSWOnMouseMove(const int x, const int y, const WXUINT flags) -{ - wxWindow::MSWOnMouseMove(x, y, flags); + node = node->Next(); + } } -#endif #endif