From f8c14d1176cbbed9e8265e6cde24e6485531d13d Mon Sep 17 00:00:00 2001 From: Scott Furry Date: Fri, 14 Jul 2017 16:53:11 +0200 Subject: [PATCH] Define more wxToolBar::SetToolXXX() methods in wxQt Provide a stub for SetToolShortHelp() and really implement SetTool{Normal,Disabled}Bitmap(). --- include/wx/qt/toolbar.h | 6 +++++- src/qt/toolbar.cpp | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/include/wx/qt/toolbar.h b/include/wx/qt/toolbar.h index b0da1958d4..6e9822b7c1 100644 --- a/include/wx/qt/toolbar.h +++ b/include/wx/qt/toolbar.h @@ -43,6 +43,11 @@ public: virtual QToolBar *GetQToolBar() const { return m_qtToolBar; } virtual void SetWindowStyleFlag( long style ) wxOVERRIDE; + + virtual void SetToolShortHelp(int id, const wxString& helpString) wxOVERRIDE; + virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE; + virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE; + virtual bool Realize() wxOVERRIDE; virtual wxToolBarToolBase *CreateTool(int toolid, @@ -59,7 +64,6 @@ public: QWidget *GetHandle() const wxOVERRIDE; protected: - QActionGroup* GetActionGroup(size_t pos); virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool) wxOVERRIDE; virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool) wxOVERRIDE; diff --git a/src/qt/toolbar.cpp b/src/qt/toolbar.cpp index c6ec8adc5c..dc307e086b 100644 --- a/src/qt/toolbar.cpp +++ b/src/qt/toolbar.cpp @@ -185,6 +185,41 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x), return NULL; } +void wxToolBar::SetToolShortHelp( int id, const wxString& helpString ) +{ + wxToolBarTool* tool = static_cast(FindById(id)); + if ( tool ) + { + (void)tool->SetShortHelp(helpString); + //TODO - other qt actions for tool tip string +// if (tool->m_item) +// {} + } +} + +void wxToolBar::SetToolNormalBitmap( int id, const wxBitmap& bitmap ) +{ + wxToolBarTool* tool = static_cast(FindById(id)); + if ( tool ) + { + wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools.")); + + tool->SetNormalBitmap(bitmap); + tool->SetIcon(); + } +} + +void wxToolBar::SetToolDisabledBitmap( int id, const wxBitmap& bitmap ) +{ + wxToolBarTool* tool = static_cast(FindById(id)); + if ( tool ) + { + wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools.")); + + tool->SetDisabledBitmap(bitmap); + } +} + void wxToolBar::SetWindowStyleFlag( long style ) { wxToolBarBase::SetWindowStyleFlag(style); @@ -249,7 +284,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) { wxToolBarTool* tool = static_cast(toolBase); QAction *before = NULL; - if (pos >= 0 && pos < (size_t)m_qtToolBar->actions().size()) + if (pos < (size_t)m_qtToolBar->actions().size()) before = m_qtToolBar->actions().at(pos); QAction *action;