Merge branch 'qt-build'

Minor wxQt API fixes and simplifications.

See https://github.com/wxWidgets/wxWidgets/pull/962
This commit is contained in:
Vadim Zeitlin
2018-10-07 19:55:37 +02:00
6 changed files with 74 additions and 27 deletions

View File

@@ -63,16 +63,14 @@ public:
return wxItemContainer::GetStringSelection(); return wxItemContainer::GetStringSelection();
} }
virtual void Clear() wxOVERRIDE virtual void Clear() wxOVERRIDE;
{
wxTextEntry::Clear();
wxItemContainer::Clear();
}
// See wxComboBoxBase discussion of IsEmpty(). // See wxComboBoxBase discussion of IsEmpty().
bool IsListEmpty() const { return wxItemContainer::IsEmpty(); } bool IsListEmpty() const { return wxItemContainer::IsEmpty(); }
bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); } bool IsTextEmpty() const { return wxTextEntry::IsEmpty(); }
virtual void SetValue(const wxString& value) wxOVERRIDE;
virtual void Popup(); virtual void Popup();
virtual void Dismiss(); virtual void Dismiss();

View File

@@ -32,7 +32,6 @@ public:
virtual ~wxToolBar(); virtual ~wxToolBar();
void Init();
bool Create(wxWindow *parent, bool Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
@@ -44,23 +43,27 @@ public:
virtual QToolBar *GetQToolBar() const { return m_qtToolBar; } virtual QToolBar *GetQToolBar() const { return m_qtToolBar; }
virtual void SetWindowStyleFlag( long style ) wxOVERRIDE; 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 bool Realize() wxOVERRIDE;
virtual wxToolBarToolBase *CreateTool(int toolid, virtual wxToolBarToolBase *CreateTool(int toolid,
const wxString& label, const wxString& label,
const wxBitmap& bmpNormal, const wxBitmap& bmpNormal,
const wxBitmap& bmpDisabled, const wxBitmap& bmpDisabled = wxNullBitmap,
wxItemKind kind, wxItemKind kind = wxITEM_NORMAL,
wxObject *clientData, wxObject *clientData = NULL,
const wxString& shortHelp, const wxString& shortHelp = wxEmptyString,
const wxString& longHelp) wxOVERRIDE; const wxString& longHelp = wxEmptyString) wxOVERRIDE;
virtual wxToolBarToolBase *CreateTool(wxControl *control, virtual wxToolBarToolBase *CreateTool(wxControl *control,
const wxString& label) wxOVERRIDE; const wxString& label) wxOVERRIDE;
QWidget *GetHandle() const wxOVERRIDE; QWidget *GetHandle() const wxOVERRIDE;
protected: protected:
QActionGroup* GetActionGroup(size_t pos); QActionGroup* GetActionGroup(size_t pos);
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool) wxOVERRIDE; virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool) wxOVERRIDE;
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool) wxOVERRIDE; virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool) wxOVERRIDE;
@@ -69,6 +72,8 @@ protected:
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle) wxOVERRIDE; virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle) wxOVERRIDE;
private: private:
void Init();
long GetButtonStyle(); long GetButtonStyle();
QToolBar *m_qtToolBar; QToolBar *m_qtToolBar;

View File

@@ -86,7 +86,7 @@ QList< QShortcut* > *wxAcceleratorTable::ConvertShortcutTable( QWidget *parent )
{ {
QList< QShortcut* > *qtList = new QList< QShortcut* >; 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 )); qtList->push_back(ConvertAccelerator( node->GetData(), parent ));
} }

View File

@@ -118,6 +118,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
return QtCreateControl( parent, id, pos, size, style, validator, name ); 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 wxString wxComboBox::DoGetValue() const
{ {
return wxQtConvertString( m_qtComboBox->currentText() ); return wxQtConvertString( m_qtComboBox->currentText() );
@@ -133,6 +141,12 @@ void wxComboBox::Dismiss()
static_cast<QComboBox *>(GetHandle())->hidePopup(); static_cast<QComboBox *>(GetHandle())->hidePopup();
} }
void wxComboBox::Clear()
{
wxTextEntry::Clear();
wxItemContainer::Clear();
}
void wxComboBox::SetSelection( long from, long to ) void wxComboBox::SetSelection( long from, long to )
{ {
// SelectAll uses -1 to -1, adjust for qt: // SelectAll uses -1 to -1, adjust for qt:

View File

@@ -185,6 +185,41 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x),
return NULL; return NULL;
} }
void wxToolBar::SetToolShortHelp( int id, const wxString& helpString )
{
wxToolBarTool* tool = static_cast<wxToolBarTool*>(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<wxToolBarTool*>(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<wxToolBarTool*>(FindById(id));
if ( tool )
{
wxCHECK_RET( tool->IsButton(), wxT("Can only set bitmap on button tools."));
tool->SetDisabledBitmap(bitmap);
}
}
void wxToolBar::SetWindowStyleFlag( long style ) void wxToolBar::SetWindowStyleFlag( long style )
{ {
wxToolBarBase::SetWindowStyleFlag(style); wxToolBarBase::SetWindowStyleFlag(style);
@@ -249,7 +284,7 @@ bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase)
{ {
wxToolBarTool* tool = static_cast<wxToolBarTool*>(toolBase); wxToolBarTool* tool = static_cast<wxToolBarTool*>(toolBase);
QAction *before = NULL; 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); before = m_qtToolBar->actions().at(pos);
QAction *action; QAction *action;

View File

@@ -194,8 +194,7 @@ wxWindowQt::~wxWindowQt()
// Delete only if the qt widget was created or assigned to this base class // Delete only if the qt widget was created or assigned to this base class
if (m_qtWindow) if (m_qtWindow)
{ {
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow=%p"), wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow=%p"), GetName(), m_qtWindow);
(const char*)GetName(), m_qtWindow);
// Avoid sending further signals (i.e. if deleting the current page) // Avoid sending further signals (i.e. if deleting the current page)
m_qtWindow->blockSignals(true); m_qtWindow->blockSignals(true);
// Reset the pointer to avoid handling pending event and signals // Reset the pointer to avoid handling pending event and signals
@@ -206,8 +205,7 @@ wxWindowQt::~wxWindowQt()
} }
else else
{ {
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow is NULL"), wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::~wxWindow %s m_qtWindow is NULL"), GetName());
(const char*)GetName());
} }
} }
@@ -260,8 +258,7 @@ void wxWindowQt::PostCreation(bool generic)
// store pointer to the QWidget subclass (to be used in the destructor) // store pointer to the QWidget subclass (to be used in the destructor)
m_qtWindow = GetHandle(); m_qtWindow = GetHandle();
} }
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Create %s m_qtWindow=%p"), wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Create %s m_qtWindow=%p"), GetName(), m_qtWindow);
(const char*)GetName(), m_qtWindow);
// set the background style after creation (not before like in wxGTK) // set the background style after creation (not before like in wxGTK)
// (only for generic controls, to use qt defaults elsewere) // (only for generic controls, to use qt defaults elsewere)
@@ -395,7 +392,7 @@ void wxWindowQt::WarpPointer(int x, int y)
void wxWindowQt::Update() 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: // send the paint event to the inner widget in scroll areas:
if ( QtGetScrollBarsContainer() ) if ( QtGetScrollBarsContainer() )
{ {
@@ -422,14 +419,13 @@ void wxWindowQt::Refresh( bool WXUNUSED( eraseBackground ), const wxRect *rect )
if ( rect != NULL ) if ( rect != NULL )
{ {
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Refresh %s rect %d %d %d %d"), 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); rect->x, rect->y, rect->width, rect->height);
widget->update( wxQtConvertRect( *rect )); widget->update( wxQtConvertRect( *rect ));
} }
else else
{ {
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Refresh %s"), wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::Refresh %s"), GetName());
(const char*)GetName());
widget->update(); widget->update();
} }
} }
@@ -1083,7 +1079,7 @@ bool wxWindowQt::QtHandlePaintEvent ( QWidget *handler, QPaintEvent *event )
if ( UseBgCol() && !GetHandle()->autoFillBackground() ) if ( UseBgCol() && !GetHandle()->autoFillBackground() )
{ {
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::QtHandlePaintEvent %s clearing DC to %s"), wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::QtHandlePaintEvent %s clearing DC to %s"),
(const char*)GetName(), GetBackgroundColour().GetAsString() GetName(), GetBackgroundColour().GetAsString()
); );
dc.SetBackground(GetBackgroundColour()); dc.SetBackground(GetBackgroundColour());
dc.Clear(); dc.Clear();
@@ -1132,8 +1128,7 @@ bool wxWindowQt::QtHandlePaintEvent ( QWidget *handler, QPaintEvent *event )
else else
{ {
// Painter didn't begun, not handled by wxWidgets: // Painter didn't begun, not handled by wxWidgets:
wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::QtHandlePaintEvent %s Qt widget painter begin failed"), wxLogTrace(TRACE_QT_WINDOW, wxT("wxWindow::QtHandlePaintEvent %s Qt widget painter begin failed"), GetName() );
(const char*)GetName() );
return false; return false;
} }
} }