From 4c0b91985141846bb1db4c97d8992dee89a233fd Mon Sep 17 00:00:00 2001 From: Scott Furry Date: Fri, 14 Jul 2017 16:40:09 +0200 Subject: [PATCH 1/7] Make wxToolBar::Init() private in wxQt No real changes, just keep private method out of the public part. --- include/wx/qt/toolbar.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/wx/qt/toolbar.h b/include/wx/qt/toolbar.h index 850ef5eb67..9df7555e80 100644 --- a/include/wx/qt/toolbar.h +++ b/include/wx/qt/toolbar.h @@ -32,7 +32,6 @@ public: virtual ~wxToolBar(); - void Init(); bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, @@ -69,6 +68,8 @@ protected: virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle) wxOVERRIDE; private: + void Init(); + long GetButtonStyle(); QToolBar *m_qtToolBar; From 019cf6e6f06dbd435f9d05aab7f82baaf6a51a12 Mon Sep 17 00:00:00 2001 From: Scott Furry Date: Fri, 14 Jul 2017 16:49:53 +0200 Subject: [PATCH 2/7] Move wxComboBox::Clear() out of line in wxQt No real changes. --- include/wx/qt/combobox.h | 6 +----- src/qt/combobox.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/wx/qt/combobox.h b/include/wx/qt/combobox.h index b2fe23d305..4daf97c90c 100644 --- a/include/wx/qt/combobox.h +++ b/include/wx/qt/combobox.h @@ -63,11 +63,7 @@ public: return wxItemContainer::GetStringSelection(); } - virtual void Clear() wxOVERRIDE - { - wxTextEntry::Clear(); - wxItemContainer::Clear(); - } + virtual void Clear() wxOVERRIDE; // See wxComboBoxBase discussion of IsEmpty(). bool IsListEmpty() const { return wxItemContainer::IsEmpty(); } diff --git a/src/qt/combobox.cpp b/src/qt/combobox.cpp index 67757fd2ee..9fd3308f5e 100644 --- a/src/qt/combobox.cpp +++ b/src/qt/combobox.cpp @@ -133,6 +133,12 @@ void wxComboBox::Dismiss() static_cast(GetHandle())->hidePopup(); } +void wxComboBox::Clear() +{ + wxTextEntry::Clear(); + wxItemContainer::Clear(); +} + void wxComboBox::SetSelection( long from, long to ) { // SelectAll uses -1 to -1, adjust for qt: From fd7f4dfe3de3ce6b9d25e6a78eecc8d58a0041ca Mon Sep 17 00:00:00 2001 From: Scott Furry Date: Fri, 14 Jul 2017 16:50:21 +0200 Subject: [PATCH 3/7] Implement wxComboBox::SetValue() in wxQt Make setting combobox value work. --- include/wx/qt/combobox.h | 2 ++ src/qt/combobox.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/wx/qt/combobox.h b/include/wx/qt/combobox.h index 4daf97c90c..490e2cb117 100644 --- a/include/wx/qt/combobox.h +++ b/include/wx/qt/combobox.h @@ -69,6 +69,8 @@ public: bool IsListEmpty() const { return wxItemContainer::IsEmpty(); } bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); } + virtual void SetValue(const wxString& value) wxOVERRIDE; + virtual void Popup(); virtual void Dismiss(); diff --git a/src/qt/combobox.cpp b/src/qt/combobox.cpp index 9fd3308f5e..14af9eb2d9 100644 --- a/src/qt/combobox.cpp +++ b/src/qt/combobox.cpp @@ -118,6 +118,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, return QtCreateControl( parent, id, pos, size, style, validator, name ); } +void wxComboBox::SetValue(const wxString& value) +{ + if ( HasFlag(wxCB_READONLY) ) + SetStringSelection(value); + else + wxTextEntry::SetValue(value); +} + wxString wxComboBox::DoGetValue() const { return wxQtConvertString( m_qtComboBox->currentText() ); From 2ea9548ffb220b8979bf8bc3b50fbc3f2acbda5e Mon Sep 17 00:00:00 2001 From: Scott Furry Date: Fri, 14 Jul 2017 16:51:18 +0200 Subject: [PATCH 4/7] Add default argument values to wxToolBar::CreateTool() in wxQt Make the API consistent with the other ports. --- include/wx/qt/toolbar.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/wx/qt/toolbar.h b/include/wx/qt/toolbar.h index 9df7555e80..b0da1958d4 100644 --- a/include/wx/qt/toolbar.h +++ b/include/wx/qt/toolbar.h @@ -48,11 +48,11 @@ public: virtual wxToolBarToolBase *CreateTool(int toolid, const wxString& label, const wxBitmap& bmpNormal, - const wxBitmap& bmpDisabled, - wxItemKind kind, - wxObject *clientData, - const wxString& shortHelp, - const wxString& longHelp) wxOVERRIDE; + const wxBitmap& bmpDisabled = wxNullBitmap, + wxItemKind kind = wxITEM_NORMAL, + wxObject *clientData = NULL, + const wxString& shortHelp = wxEmptyString, + const wxString& longHelp = wxEmptyString) wxOVERRIDE; virtual wxToolBarToolBase *CreateTool(wxControl *control, const wxString& label) wxOVERRIDE; From f8c14d1176cbbed9e8265e6cde24e6485531d13d Mon Sep 17 00:00:00 2001 From: Scott Furry Date: Fri, 14 Jul 2017 16:53:11 +0200 Subject: [PATCH 5/7] 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; From 0d63351eefe56fe13b845450cb998770da267806 Mon Sep 17 00:00:00 2001 From: Scott Furry Date: Fri, 14 Jul 2017 16:54:17 +0200 Subject: [PATCH 6/7] Fix wxQt compilation in STL build Use compatibility_iterator instead of Node* for iterating over wxList, the latter doesn't compile when wxUSE_STD_CONTAINERS==1. --- src/qt/accel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/accel.cpp b/src/qt/accel.cpp index 1ecb0c85fb..046c504a20 100644 --- a/src/qt/accel.cpp +++ b/src/qt/accel.cpp @@ -86,7 +86,7 @@ QList< QShortcut* > *wxAcceleratorTable::ConvertShortcutTable( QWidget *parent ) { QList< QShortcut* > *qtList = new QList< QShortcut* >; - for ( wxAccelList::Node *node = M_ACCELDATA->m_accels.GetFirst(); node; node = node->GetNext() ) + for ( wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); node; node = node->GetNext() ) { qtList->push_back(ConvertAccelerator( node->GetData(), parent )); } From b368fa2de5148e9381d816f1e3180d9045a33e47 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 14 Jul 2017 16:56:33 +0200 Subject: [PATCH 7/7] Remove casts from wxString to "const char*" in wxQt code These casts didn't compile in Unicode build and were completely unnecessary anyhow, just remove them. --- src/qt/window.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/qt/window.cpp b/src/qt/window.cpp index b82a4e3054..c36177e52b 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -194,8 +194,7 @@ wxWindowQt::~wxWindowQt() // Delete only if the qt widget was created or assigned to this base class if (m_qtWindow) { - wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow=%p"), - (const char*)GetName(), m_qtWindow); + wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow=%p"), GetName(), m_qtWindow); // Avoid sending further signals (i.e. if deleting the current page) m_qtWindow->blockSignals(true); // Reset the pointer to avoid handling pending event and signals @@ -206,8 +205,7 @@ wxWindowQt::~wxWindowQt() } else { - wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow is NULL"), - (const char*)GetName()); + wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow is NULL"), GetName()); } } @@ -260,8 +258,7 @@ void wxWindowQt::PostCreation(bool generic) // store pointer to the QWidget subclass (to be used in the destructor) m_qtWindow = GetHandle(); } - wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Create %s m_qtWindow=%p"), - (const char*)GetName(), m_qtWindow); + wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Create %s m_qtWindow=%p"), GetName(), m_qtWindow); // set the background style after creation (not before like in wxGTK) // (only for generic controls, to use qt defaults elsewere) @@ -395,7 +392,7 @@ void wxWindowQt::WarpPointer(int x, int y) void wxWindowQt::Update() { - wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Update %s"), (const char*)GetName()); + wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Update %s"), GetName()); // send the paint event to the inner widget in scroll areas: if ( QtGetScrollBarsContainer() ) { @@ -422,14 +419,13 @@ void wxWindowQt::Refresh( bool WXUNUSED( eraseBackground ), const wxRect *rect ) if ( rect != NULL ) { wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Refresh %s rect %d %d %d %d"), - (const char*)GetName(), + GetName(), rect->x, rect->y, rect->width, rect->height); widget->update( wxQtConvertRect( *rect )); } else { - wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Refresh %s"), - (const char*)GetName()); + wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Refresh %s"), GetName()); widget->update(); } } @@ -1081,7 +1077,7 @@ bool wxWindowQt::QtHandlePaintEvent ( QWidget *handler, QPaintEvent *event ) if ( UseBgCol() && !GetHandle()->autoFillBackground() ) { wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::QtHandlePaintEvent %s clearing DC to %s"), - (const char*)GetName(), GetBackgroundColour().GetAsString() + GetName(), GetBackgroundColour().GetAsString() ); dc.SetBackground(GetBackgroundColour()); dc.Clear(); @@ -1130,8 +1126,7 @@ bool wxWindowQt::QtHandlePaintEvent ( QWidget *handler, QPaintEvent *event ) else { // Painter didn't begun, not handled by wxWidgets: - wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::QtHandlePaintEvent %s Qt widget painter begin failed"), - (const char*)GetName() ); + wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::QtHandlePaintEvent %s Qt widget painter begin failed"), GetName() ); return false; } }