X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/debe6624c1e9d4bf3243381153d1e173c849bcd8..6e13c1965f5fe259d4f9c6276cf90d2abe02c6cf:/src/common/tbarbase.cpp diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 60de3c71a3..d50620d33f 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -25,16 +25,16 @@ #endif // 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) @@ -88,8 +88,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; @@ -141,16 +141,21 @@ void wxToolBarBase::OnRightClick(int toolIndex, long x, long 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); } @@ -190,7 +195,7 @@ void wxToolBarBase::AddSeparator () { wxToolBarTool *tool = new wxToolBarTool; tool->m_toolStyle = wxTOOL_STYLE_SEPARATOR; - m_tools.Append(tool); + m_tools.Append(-1, tool); } void wxToolBarBase::ClearTools(void) @@ -367,94 +372,6 @@ void wxToolBarBase::Command(wxCommandEvent& event) void wxToolBarBase::Layout(void) { - 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; } @@ -500,7 +417,7 @@ void wxToolBarBase::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY, } AdjustScrollbars(); Refresh(); -#ifdef __WINDOWS__ +#ifdef __WXMSW__ ::UpdateWindow ((HWND) GetHWND()); #endif } @@ -559,7 +476,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 +484,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 +492,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 +510,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 +518,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; @@ -698,7 +615,7 @@ void wxToolBarBase::AdjustScrollbars(void) // Default OnSize resets scrollbars, if any void wxToolBarBase::OnSize(wxSizeEvent& event) { -#if USE_CONSTRAINTS +#if wxUSE_CONSTRAINTS if (GetAutoLayout()) Layout(); #endif @@ -755,7 +672,7 @@ void wxToolBarBase::Scroll (int x_pos, int y_pos) SetScrollPos (wxVERTICAL, y_pos, TRUE); } Refresh(); -#ifdef __WINDOWS__ +#ifdef __WXMSW__ UpdateWindow ((HWND) GetHWND()); #endif } @@ -779,20 +696,6 @@ void wxToolBarBase::ViewStart (int *x, int *y) const *y = m_yScrollPosition; } -/* -void wxToolBarBase::CalcScrolledPosition(int x, int y, int *xx, int *yy) const -{ - *xx = (m_calcScrolledOffset ? (x - m_xScrollPosition * m_xScrollPixelsPerLine) : x); - *yy = (m_calcScrolledOffset ? (y - m_yScrollPosition * m_yScrollPixelsPerLine) : y); -} - -void wxToolBarBase::CalcUnscrolledPosition(int x, 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); -} -*/ - void wxToolBarBase::OnIdle(wxIdleEvent& event) { wxWindow::OnIdle(event); @@ -827,9 +730,9 @@ void wxToolBarBase::DoToolbarUpdates(void) } } -#ifdef __WINDOWS__ +#ifdef __WXMSW__ // Circumvent wxControl::MSWOnMouseMove which doesn't set the cursor. -void wxToolBarBase::MSWOnMouseMove(int x, int y, const WXUINT flags) +void wxToolBarBase::MSWOnMouseMove(int x, int y, WXUINT flags) { wxWindow::MSWOnMouseMove(x, y, flags); }