Fixed conflicts with Robert's similar fixes; fixed toolbar size calculation
and allowed for vertical toolbar git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14396 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		| @@ -104,6 +104,7 @@ protected: | |||||||
|  |  | ||||||
| private: | private: | ||||||
|     wxToolBarTool    *m_captured; |     wxToolBarTool    *m_captured; | ||||||
|  |     wxCoord          m_maxWidth, m_maxHeight; | ||||||
|      |      | ||||||
| private: | private: | ||||||
|     void OnMouse( wxMouseEvent &event ); |     void OnMouse( wxMouseEvent &event ); | ||||||
|   | |||||||
| @@ -297,7 +297,7 @@ void MyFrame::RecreateToolbar() | |||||||
|     toolBar->AddTool(wxID_OPEN, toolBarBitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file"); |     toolBar->AddTool(wxID_OPEN, toolBarBitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file"); | ||||||
|  |  | ||||||
|     // neither the generic nor Motif native toolbars really support this |     // neither the generic nor Motif native toolbars really support this | ||||||
| #if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXMOTIF__) | #if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXMOTIF__) && !defined(__WXX11__) | ||||||
|     // adding a combo to a vertical toolbar is not very smart |     // adding a combo to a vertical toolbar is not very smart | ||||||
|     if ( m_horzToolbar ) |     if ( m_horzToolbar ) | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -152,7 +152,7 @@ wxPoint wxFrameBase::GetClientAreaOrigin() const | |||||||
| { | { | ||||||
|     wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin(); |     wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin(); | ||||||
|  |  | ||||||
| #if wxUSE_TOOLBAR | #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) | ||||||
|     wxToolBar *toolbar = GetToolBar(); |     wxToolBar *toolbar = GetToolBar(); | ||||||
|     if ( toolbar && toolbar->IsShown() ) |     if ( toolbar && toolbar->IsShown() ) | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -98,16 +98,15 @@ void wxFrame::PositionMenuBar() | |||||||
|         wxCoord heightMbar = m_frameMenuBar->GetSize().y; |         wxCoord heightMbar = m_frameMenuBar->GetSize().y; | ||||||
|  |  | ||||||
|         wxCoord heightTbar = 0; |         wxCoord heightTbar = 0; | ||||||
|         // In between sits the toolbar |  | ||||||
|         if (m_frameToolBar) |         if (m_frameToolBar) | ||||||
|             heightTbar = m_frameToolBar->GetSize().y; |             heightTbar = m_frameToolBar->GetSize().y; | ||||||
|  |  | ||||||
|         m_frameMenuBar->SetSize(0,  |         m_frameMenuBar->SetSize(0,  | ||||||
| #ifdef __WXPM__	 // FIXME -- remove this, make wxOS2/Univ behave as | #ifdef __WXPM__	 // FIXME -- remove this, make wxOS2/Univ behave as | ||||||
|                  //          the rest of the world!!! |                  //          the rest of the world!!! | ||||||
|                                 GetClientSize().y - heightMbar, |                                 GetClientSize().y - heightMbar - heightTbar, | ||||||
| #else | #else | ||||||
|                                 - heightMbar - heightTbar, |                                 - (heightMbar + heightTbar), | ||||||
| #endif				 | #endif				 | ||||||
|                                 GetClientSize().x, heightMbar); |                                 GetClientSize().x, heightMbar); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -54,8 +54,18 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id, | |||||||
|  |  | ||||||
| void wxToolBar::Init() | void wxToolBar::Init() | ||||||
| { | { | ||||||
|     m_captured = NULL; |     // TODO: this is from tbarbase.cpp, but should be in | ||||||
|  |     // wxToolbarBase::Init | ||||||
|  |     // the list owns the pointers | ||||||
|  |     m_tools.DeleteContents(TRUE); | ||||||
|  |     m_xMargin = m_yMargin = 0; | ||||||
|  |     m_maxRows = m_maxCols = 0; | ||||||
|  |     // End TODO | ||||||
|  |  | ||||||
|  |     m_maxWidth = 0; | ||||||
|  |     m_maxHeight = 0; | ||||||
|  |  | ||||||
|  |     m_captured = NULL; | ||||||
|     SetToolBitmapSize( wxSize(16,15) ); |     SetToolBitmapSize( wxSize(16,15) ); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -186,7 +196,19 @@ bool wxToolBar::Realize() | |||||||
|     if (!wxToolBarBase::Realize()) |     if (!wxToolBarBase::Realize()) | ||||||
|         return FALSE; |         return FALSE; | ||||||
|  |  | ||||||
|     int x = 5; |     int x; | ||||||
|  |     int y; | ||||||
|  |  | ||||||
|  |     if (GetWindowStyleFlag() & wxTB_VERTICAL) | ||||||
|  |     { | ||||||
|  |         x = m_xMargin; | ||||||
|  |         y = 5; | ||||||
|  |     } | ||||||
|  |     else | ||||||
|  |     { | ||||||
|  |         y = m_yMargin; | ||||||
|  |         x = 5; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     for ( wxToolBarToolsList::Node *node = m_tools.GetFirst(); |     for ( wxToolBarToolsList::Node *node = m_tools.GetFirst(); | ||||||
|           node; |           node; | ||||||
| @@ -194,15 +216,53 @@ bool wxToolBar::Realize() | |||||||
|     { |     { | ||||||
|         wxToolBarTool *tool = (wxToolBarTool*) node->Data(); |         wxToolBarTool *tool = (wxToolBarTool*) node->Data(); | ||||||
|          |          | ||||||
|         if (tool->GetId() == -1) |         if (GetWindowStyleFlag() & wxTB_VERTICAL) | ||||||
|         { |         { | ||||||
|             x += 6; |             if (tool->GetId() == -1) | ||||||
|             continue; |             { | ||||||
|  |                 y += 6; | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  |             tool->m_x = m_xMargin; | ||||||
|  |             tool->m_y = y; | ||||||
|  |             y += m_defaultHeight + 6; | ||||||
|  |  | ||||||
|  |             // Calculate the maximum height or width (depending on style) | ||||||
|  |             // so we know how to size the toolbar in Realize. | ||||||
|  |             // We could get the size of the tool instead of the | ||||||
|  |             // default bitmap size | ||||||
|  |             if (m_maxWidth < (m_defaultWidth + 2*(m_xMargin + 2))) | ||||||
|  |                 m_maxWidth = (m_defaultWidth + 2*(m_xMargin + 2)) ; | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             if (tool->GetId() == -1) | ||||||
|  |             { | ||||||
|  |                 x += 6; | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  |             tool->m_x = x; | ||||||
|  |             tool->m_y = m_yMargin; | ||||||
|  |             x += m_defaultWidth + 6; | ||||||
|  |  | ||||||
|  |             // Calculate the maximum height or width (depending on style) | ||||||
|  |             // so we know how to size the toolbar in Realize. | ||||||
|  |             // We could get the size of the tool instead of the | ||||||
|  |             // default bitmap size | ||||||
|  |             if (m_maxHeight < (m_defaultHeight + 2*(m_yMargin + 2))) | ||||||
|  |                 m_maxHeight = (m_defaultHeight + 2*(m_yMargin + 2)) ; | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         tool->m_x = x; |     } | ||||||
|         tool->m_y = 4; |  | ||||||
|         x += m_defaultWidth + 6; |     wxSize sz = GetSize(); | ||||||
|  |     if (GetWindowStyleFlag() & wxTB_VERTICAL) | ||||||
|  |     { | ||||||
|  |         SetSize(m_maxWidth, sz.y); | ||||||
|  |     } | ||||||
|  |     else | ||||||
|  |     { | ||||||
|  |         SetSize(sz.x, m_maxHeight); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     SetSize( x+16, m_defaultHeight + 14 ); |     SetSize( x+16, m_defaultHeight + 14 ); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user