Add wx headers and ext
This commit is contained in:
parent
6390dcef6a
commit
66d3c7b811
1531 changed files with 295895 additions and 0 deletions
96
wxheaders/wx/qt/private/converter.h
Normal file
96
wxheaders/wx/qt/private/converter.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/qt/converter.h
|
||||
// Purpose: Converter utility classes and functions
|
||||
// Author: Peter Most, Kolya Kosenko
|
||||
// Created: 02/28/10
|
||||
// Copyright: (c) Peter Most
|
||||
// (c) 2010 Kolya Kosenko
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_QT_CONVERTER_H_
|
||||
#define _WX_QT_CONVERTER_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#include "wx/kbdstate.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/colour.h"
|
||||
|
||||
#include <QtCore/QRect>
|
||||
#include <QtCore/QSize>
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QColor>
|
||||
|
||||
// Rely on overloading and let the compiler pick the correct version, which makes
|
||||
// them easier to use then to write wxQtConvertQtRectToWxRect() or wxQtConvertWxRectToQtRect()
|
||||
|
||||
inline wxPoint wxQtConvertPoint( const QPoint &point )
|
||||
{
|
||||
return wxPoint( point.x(), point.y() );
|
||||
}
|
||||
inline QPoint wxQtConvertPoint( const wxPoint &point )
|
||||
{
|
||||
return QPoint( point.x, point.y );
|
||||
}
|
||||
|
||||
inline wxRect wxQtConvertRect( const QRect &rect )
|
||||
{
|
||||
return wxRect( rect.x(), rect.y(), rect.width(), rect.height() );
|
||||
}
|
||||
|
||||
inline QRect wxQtConvertRect( const wxRect &rect )
|
||||
{
|
||||
return QRect( rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight() );
|
||||
}
|
||||
|
||||
// TODO: Check whether QString::toStdString/QString::toStdWString might be faster
|
||||
|
||||
inline wxString wxQtConvertString( const QString &str )
|
||||
{
|
||||
return wxString( str.toUtf8().data(), wxConvUTF8 );
|
||||
}
|
||||
|
||||
inline QString wxQtConvertString( const wxString &str )
|
||||
{
|
||||
return QString( str.utf8_str() );
|
||||
}
|
||||
|
||||
inline wxColour wxQtConvertColour(const QColor &colour)
|
||||
{
|
||||
return wxColour(colour.red(), colour.green(), colour.blue(), colour.alpha());
|
||||
}
|
||||
|
||||
inline QColor wxQtConvertColour(const wxColour &colour)
|
||||
{
|
||||
return QColor(colour.Red(), colour.Green(), colour.Blue(), colour.Alpha());
|
||||
}
|
||||
|
||||
#if wxUSE_DATETIME
|
||||
|
||||
class WXDLLIMPEXP_FWD_BASE wxDateTime;
|
||||
class QDate;
|
||||
|
||||
wxDateTime wxQtConvertDate(const QDate& date);
|
||||
QDate wxQtConvertDate(const wxDateTime& date);
|
||||
|
||||
#endif // wxUSE_DATETIME
|
||||
|
||||
inline wxSize wxQtConvertSize( const QSize &size )
|
||||
{
|
||||
return wxSize(size.width(), size.height());
|
||||
}
|
||||
inline QSize wxQtConvertSize( const wxSize &size )
|
||||
{
|
||||
return QSize(size.GetWidth(), size.GetHeight());
|
||||
}
|
||||
|
||||
Qt::Orientation wxQtConvertOrientation( long style, wxOrientation defaultOrientation );
|
||||
wxOrientation wxQtConvertOrientation( Qt::Orientation );
|
||||
|
||||
wxKeyCode wxQtConvertKeyCode( int key, Qt::KeyboardModifiers modifiers );
|
||||
void wxQtFillKeyboardModifiers( Qt::KeyboardModifiers modifiers, wxKeyboardState *state );
|
||||
int wxQtConvertKeyCode( int keyCode, int modifiers, Qt::KeyboardModifiers &qtmodifiers );
|
||||
|
||||
#endif // _WX_QT_CONVERTER_H_
|
||||
|
||||
43
wxheaders/wx/qt/private/pointer.h
Normal file
43
wxheaders/wx/qt/private/pointer.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/qt/private/pointer.h
|
||||
// Author: Peter Most
|
||||
// Copyright: (c) Peter Most
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_QT_POINTER_H_
|
||||
#define _WX_QT_POINTER_H_
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
// Extend QPointer with the ability to delete the object in its destructor. The
|
||||
// normal behaviour of the QPointer makes sure that this is safe, because if somebody
|
||||
// has deleted the object, then data() returns NULL and delete does nothing.
|
||||
|
||||
template < typename T >
|
||||
class wxQtPointer : public QPointer< T >
|
||||
{
|
||||
public:
|
||||
inline wxQtPointer()
|
||||
: QPointer< T >()
|
||||
{
|
||||
}
|
||||
|
||||
inline wxQtPointer( T *p )
|
||||
: QPointer< T >( p )
|
||||
{
|
||||
}
|
||||
|
||||
inline wxQtPointer< T > &operator = ( T *p )
|
||||
{
|
||||
QPointer< T >::operator = ( p );
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ~wxQtPointer()
|
||||
{
|
||||
delete QPointer< T >::data();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _WX_QT_POINTER_H_
|
||||
39
wxheaders/wx/qt/private/timer.h
Normal file
39
wxheaders/wx/qt/private/timer.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/qt/timer.h
|
||||
// Author: Javier Torres
|
||||
// Copyright: (c) Javier Torres
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_QT_TIMER_H_
|
||||
#define _WX_QT_TIMER_H_
|
||||
|
||||
#if wxUSE_TIMER
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include "wx/private/timer.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxTimer
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class QTimerEvent;
|
||||
class WXDLLIMPEXP_CORE wxQtTimerImpl : public wxTimerImpl, QObject
|
||||
{
|
||||
public:
|
||||
wxQtTimerImpl( wxTimer* timer );
|
||||
|
||||
virtual bool Start( int millisecs = -1, bool oneShot = false ) wxOVERRIDE;
|
||||
virtual void Stop() wxOVERRIDE;
|
||||
virtual bool IsRunning() const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual void timerEvent( QTimerEvent * event ) wxOVERRIDE;
|
||||
|
||||
private:
|
||||
int m_timerId;
|
||||
};
|
||||
|
||||
#endif // wxUSE_TIMER
|
||||
|
||||
#endif // _WX_QT_TIMER_H_
|
||||
99
wxheaders/wx/qt/private/treeitemdelegate.h
Normal file
99
wxheaders/wx/qt/private/treeitemdelegate.h
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/qt/private/treeitemdelegate.h
|
||||
// Purpose: Delegate to create text edit controls for the tree items
|
||||
// Author: Matthew Griffin
|
||||
// Created: 2019-05-29
|
||||
// Copyright: Matthew Griffin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_QT_PRIVATE_TREEITEM_DELEGATE_H
|
||||
#define _WX_QT_PRIVATE_TREEITEM_DELEGATE_H
|
||||
|
||||
#include <QtWidgets/QStyledItemDelegate>
|
||||
#include <QtWidgets/QToolTip>
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
#include "treeitemfactory.h"
|
||||
|
||||
class wxQTTreeItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
explicit wxQTTreeItemDelegate(wxWindow* parent)
|
||||
: m_parent(parent),
|
||||
m_textCtrl(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &WXUNUSED(option), const QModelIndex &index) const wxOVERRIDE
|
||||
{
|
||||
if ( m_textCtrl != NULL )
|
||||
destroyEditor(m_textCtrl->GetHandle(), m_currentModelIndex);
|
||||
|
||||
m_currentModelIndex = index;
|
||||
m_textCtrl = new wxQtListTextCtrl(m_parent, parent);
|
||||
m_textCtrl->SetFocus();
|
||||
return m_textCtrl->GetHandle();
|
||||
}
|
||||
|
||||
void destroyEditor(QWidget *WXUNUSED(editor), const QModelIndex &WXUNUSED(index)) const wxOVERRIDE
|
||||
{
|
||||
if ( m_textCtrl != NULL )
|
||||
{
|
||||
m_currentModelIndex = QModelIndex(); // invalidate the index
|
||||
wxTheApp->ScheduleForDestruction(m_textCtrl);
|
||||
m_textCtrl = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void setModelData(QWidget *WXUNUSED(editor), QAbstractItemModel *WXUNUSED(model), const QModelIndex &WXUNUSED(index)) const wxOVERRIDE
|
||||
{
|
||||
// Don't set model data until wx has had a chance to send out events
|
||||
}
|
||||
|
||||
wxTextCtrl* GetEditControl() const
|
||||
{
|
||||
return m_textCtrl;
|
||||
}
|
||||
|
||||
QModelIndex GetCurrentModelIndex() const
|
||||
{
|
||||
return m_currentModelIndex;
|
||||
}
|
||||
|
||||
void AcceptModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||
{
|
||||
QStyledItemDelegate::setModelData(editor, model, index);
|
||||
}
|
||||
|
||||
bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||
{
|
||||
if ( event->type() == QEvent::ToolTip )
|
||||
{
|
||||
const QRect &itemRect = view->visualRect(index);
|
||||
const QSize &bestSize = sizeHint(option, index);
|
||||
if ( itemRect.width() < bestSize.width() )
|
||||
{
|
||||
const QString &value = index.data(Qt::DisplayRole).toString();
|
||||
QToolTip::showText(event->globalPos(), value, view);
|
||||
}
|
||||
else
|
||||
{
|
||||
QToolTip::hideText();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return QStyledItemDelegate::helpEvent(event, view, option, index);
|
||||
}
|
||||
|
||||
private:
|
||||
wxWindow* m_parent;
|
||||
mutable wxTextCtrl* m_textCtrl;
|
||||
mutable QModelIndex m_currentModelIndex;
|
||||
};
|
||||
|
||||
#endif // _WX_QT_PRIVATE_TREEITEM_DELEGATE_H
|
||||
122
wxheaders/wx/qt/private/treeitemfactory.h
Normal file
122
wxheaders/wx/qt/private/treeitemfactory.h
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/qt/private/treeitemfactory.h
|
||||
// Purpose: Factory to create text edit controls for the tree items
|
||||
// Author: Graham Dawes
|
||||
// Created: 2019-02-07
|
||||
// Copyright: Graham Dawes
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_QT_PRIVATE_TREEITEM_FACTORY_H_
|
||||
#define _WX_QT_PRIVATE_TREEITEM_FACTORY_H_
|
||||
|
||||
#include <QtWidgets/QItemEditorFactory>
|
||||
#include <QtWidgets/QTreeWidget>
|
||||
#include <QtWidgets/QItemDelegate>
|
||||
|
||||
#include "wx/recguard.h"
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
// wxQT Doesn't have a mechanism for "adopting" external widgets so we have to
|
||||
// create an instance of wxTextCtrl rather than adopting the control QT would
|
||||
// create.
|
||||
//
|
||||
// Unfortunately the factory is given an internal widget as the parent for
|
||||
// editor.
|
||||
//
|
||||
// To work around these issues we create a wxTextCtl parented by the wxListCtrl
|
||||
// then recalculate its position relative to the internal widget.
|
||||
|
||||
class wxQtListTextCtrl : public wxTextCtrl
|
||||
{
|
||||
public:
|
||||
wxQtListTextCtrl(wxWindow* parent, QWidget* actualParent)
|
||||
: wxTextCtrl(parent, wxID_ANY, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxNO_BORDER),
|
||||
m_actualParent(actualParent),
|
||||
m_moving(0)
|
||||
{
|
||||
Bind(wxEVT_MOVE, &wxQtListTextCtrl::OnMove, this);
|
||||
}
|
||||
|
||||
void OnMove(wxMoveEvent &event)
|
||||
{
|
||||
// QWidget::move generates a QMoveEvent so we need to guard against
|
||||
// reentrant calls.
|
||||
wxRecursionGuard guard(m_moving);
|
||||
|
||||
if ( guard.IsInside() )
|
||||
{
|
||||
event.Skip();
|
||||
return;
|
||||
}
|
||||
|
||||
const QPoint eventPos = wxQtConvertPoint(event.GetPosition());
|
||||
const QPoint globalPos = m_actualParent->mapToGlobal(eventPos);
|
||||
|
||||
// For some reason this always gives us the offset from the header info
|
||||
// the internal control. So we need to treat this as an offset rather
|
||||
// than a position.
|
||||
QWidget* widget = GetHandle();
|
||||
const QPoint offset = widget->mapFromGlobal(globalPos);
|
||||
|
||||
widget->move(eventPos + offset);
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget* m_actualParent;
|
||||
wxRecursionGuardFlag m_moving;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxQtListTextCtrl);
|
||||
};
|
||||
|
||||
// QT doesn't give us direct access to the editor within the QTreeWidget.
|
||||
// Instead, we'll supply a factory to create the widget for QT and keep track
|
||||
// of it ourselves.
|
||||
|
||||
class wxQtTreeItemEditorFactory : public QItemEditorFactory
|
||||
{
|
||||
public:
|
||||
explicit wxQtTreeItemEditorFactory(wxWindow* parent)
|
||||
: m_parent(parent),
|
||||
m_textCtrl(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void AttachTo(QTreeWidget *tree)
|
||||
{
|
||||
QAbstractItemDelegate* delegate = tree->itemDelegate();
|
||||
QItemDelegate *qItemDelegate = static_cast<QItemDelegate*>(delegate);
|
||||
qItemDelegate->setItemEditorFactory(this);
|
||||
}
|
||||
|
||||
QWidget* createEditor(int WXUNUSED(userType), QWidget* parent) const wxOVERRIDE
|
||||
{
|
||||
if (m_textCtrl != NULL)
|
||||
ClearEditor();
|
||||
|
||||
m_textCtrl = new wxQtListTextCtrl(m_parent, parent);
|
||||
m_textCtrl->SetFocus();
|
||||
return m_textCtrl->GetHandle();
|
||||
}
|
||||
|
||||
wxTextCtrl* GetEditControl() const
|
||||
{
|
||||
return m_textCtrl;
|
||||
}
|
||||
|
||||
void ClearEditor() const
|
||||
{
|
||||
delete m_textCtrl;
|
||||
m_textCtrl = NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
wxWindow* m_parent;
|
||||
mutable wxTextCtrl* m_textCtrl;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxQtTreeItemEditorFactory);
|
||||
};
|
||||
|
||||
#endif //_WX_QT_PRIVATE_TREEITEM_FACTORY_H_
|
||||
27
wxheaders/wx/qt/private/utils.h
Normal file
27
wxheaders/wx/qt/private/utils.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/qt/utils.h
|
||||
// Purpose: utility classes and/or functions
|
||||
// Author: Peter Most, Javier Torres
|
||||
// Created: 15/05/10
|
||||
// Copyright: (c) Peter Most, Javier Torres
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_QT_UTILS_H_
|
||||
#define _WX_QT_UTILS_H_
|
||||
|
||||
#include "wx/mousestate.h"
|
||||
#include <QtCore/Qt>
|
||||
|
||||
void wxQtFillMouseButtons( Qt::MouseButtons buttons, wxMouseState *state );
|
||||
|
||||
void wxMissingImplementation( const char fileName[], unsigned lineNumber,
|
||||
const char feature[] );
|
||||
|
||||
#define wxMISSING_IMPLEMENTATION( feature )\
|
||||
wxMissingImplementation( __FILE__, __LINE__, feature )
|
||||
|
||||
#define wxMISSING_FUNCTION() \
|
||||
wxMISSING_IMPLEMENTATION( __WXFUNCTION__ )
|
||||
|
||||
#endif // _WX_QT_UTILS_H_
|
||||
461
wxheaders/wx/qt/private/winevent.h
Normal file
461
wxheaders/wx/qt/private/winevent.h
Normal file
|
|
@ -0,0 +1,461 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: include/wx/qt/winevent_qt.h
|
||||
// Purpose: QWidget to wxWindow event handler
|
||||
// Author: Javier Torres, Peter Most
|
||||
// Modified by:
|
||||
// Created: 21.06.10
|
||||
// Copyright: (c) Javier Torres
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_QT_EVENTSIGNALFORWARDER_H_
|
||||
#define _WX_QT_EVENTSIGNALFORWARDER_H_
|
||||
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtGui/QCloseEvent>
|
||||
|
||||
#include "wx/log.h"
|
||||
#include "wx/window.h"
|
||||
#include "wx/qt/private/converter.h"
|
||||
#include "wx/qt/private/utils.h"
|
||||
|
||||
#include <QtWidgets/QGestureEvent>
|
||||
#include <QtGui/QCursor>
|
||||
|
||||
class QPaintEvent;
|
||||
|
||||
template< typename Handler >
|
||||
class wxQtSignalHandler
|
||||
{
|
||||
protected:
|
||||
wxQtSignalHandler( Handler *handler )
|
||||
{
|
||||
m_handler = handler;
|
||||
}
|
||||
|
||||
void EmitEvent( wxEvent &event ) const
|
||||
{
|
||||
wxWindow *handler = GetHandler();
|
||||
event.SetEventObject( handler );
|
||||
handler->HandleWindowEvent( event );
|
||||
}
|
||||
|
||||
virtual Handler *GetHandler() const
|
||||
{
|
||||
return m_handler;
|
||||
}
|
||||
|
||||
private:
|
||||
Handler *m_handler;
|
||||
};
|
||||
|
||||
template < typename Widget, typename Handler >
|
||||
class wxQtEventSignalHandler : public Widget, public wxQtSignalHandler< Handler >
|
||||
{
|
||||
public:
|
||||
wxQtEventSignalHandler( wxWindow *parent, Handler *handler )
|
||||
: Widget( parent != NULL ? parent->GetHandle() : NULL )
|
||||
, wxQtSignalHandler< Handler >( handler )
|
||||
{
|
||||
// Set immediately as it is used to check if wxWindow is alive
|
||||
wxWindow::QtStoreWindowPointer( this, handler );
|
||||
|
||||
// Handle QWidget destruction signal AFTER it gets deleted
|
||||
QObject::connect( this, &QObject::destroyed, this,
|
||||
&wxQtEventSignalHandler::HandleDestroyedSignal );
|
||||
|
||||
Widget::setMouseTracking(true);
|
||||
}
|
||||
|
||||
void HandleDestroyedSignal()
|
||||
{
|
||||
}
|
||||
|
||||
virtual Handler *GetHandler() const wxOVERRIDE
|
||||
{
|
||||
// Only process the signal / event if the wxWindow is not destroyed
|
||||
if ( !wxWindow::QtRetrieveWindowPointer( this ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
return wxQtSignalHandler< Handler >::GetHandler();
|
||||
}
|
||||
|
||||
protected:
|
||||
/* Not implemented here: wxHelpEvent, wxIdleEvent wxJoystickEvent,
|
||||
* wxMouseCaptureLostEvent, wxMouseCaptureChangedEvent,
|
||||
* wxPowerEvent, wxScrollWinEvent, wxSysColourChangedEvent */
|
||||
|
||||
//wxActivateEvent
|
||||
virtual void changeEvent ( QEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleChangeEvent(this, event) )
|
||||
Widget::changeEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxCloseEvent
|
||||
virtual void closeEvent ( QCloseEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleCloseEvent(this, event) )
|
||||
Widget::closeEvent(event);
|
||||
else
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
//wxContextMenuEvent
|
||||
virtual void contextMenuEvent ( QContextMenuEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleContextMenuEvent(this, event) )
|
||||
Widget::contextMenuEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxDropFilesEvent
|
||||
//virtual void dropEvent ( QDropEvent * event ) { }
|
||||
|
||||
//wxMouseEvent
|
||||
virtual void enterEvent ( QEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleEnterEvent(this, event) )
|
||||
Widget::enterEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxFocusEvent.
|
||||
virtual void focusInEvent ( QFocusEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleFocusEvent(this, event) )
|
||||
Widget::focusInEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxFocusEvent.
|
||||
virtual void focusOutEvent ( QFocusEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleFocusEvent(this, event) )
|
||||
Widget::focusOutEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxShowEvent
|
||||
virtual void hideEvent ( QHideEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleShowEvent(this, event) )
|
||||
Widget::hideEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxKeyEvent
|
||||
virtual void keyPressEvent ( QKeyEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleKeyEvent(this, event) )
|
||||
Widget::keyPressEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxKeyEvent
|
||||
virtual void keyReleaseEvent ( QKeyEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleKeyEvent(this, event) )
|
||||
Widget::keyReleaseEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxMouseEvent
|
||||
virtual void leaveEvent ( QEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleEnterEvent(this, event) )
|
||||
Widget::leaveEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxMouseEvent
|
||||
virtual void mouseDoubleClickEvent ( QMouseEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleMouseEvent(this, event) )
|
||||
Widget::mouseDoubleClickEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxMouseEvent
|
||||
virtual void mouseMoveEvent ( QMouseEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleMouseEvent(this, event) )
|
||||
Widget::mouseMoveEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxMouseEvent
|
||||
virtual void mousePressEvent ( QMouseEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleMouseEvent(this, event) )
|
||||
Widget::mousePressEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxMouseEvent
|
||||
virtual void mouseReleaseEvent ( QMouseEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleMouseEvent(this, event) )
|
||||
Widget::mouseReleaseEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxMoveEvent
|
||||
virtual void moveEvent ( QMoveEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleMoveEvent(this, event) )
|
||||
Widget::moveEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxEraseEvent then wxPaintEvent
|
||||
virtual void paintEvent ( QPaintEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandlePaintEvent(this, event) )
|
||||
Widget::paintEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxSizeEvent
|
||||
virtual void resizeEvent ( QResizeEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleResizeEvent(this, event) )
|
||||
Widget::resizeEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxShowEvent
|
||||
virtual void showEvent ( QShowEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleShowEvent(this, event) )
|
||||
Widget::showEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
//wxMouseEvent
|
||||
virtual void wheelEvent ( QWheelEvent * event ) wxOVERRIDE
|
||||
{
|
||||
if ( !this->GetHandler() )
|
||||
return;
|
||||
|
||||
if ( !this->GetHandler()->QtHandleWheelEvent(this, event) )
|
||||
Widget::wheelEvent(event);
|
||||
else
|
||||
event->accept();
|
||||
}
|
||||
|
||||
/* Unused Qt events
|
||||
virtual void actionEvent ( QActionEvent * event ) { }
|
||||
virtual void dragEnterEvent ( QDragEnterEvent * event ) { }
|
||||
virtual void dragLeaveEvent ( QDragLeaveEvent * event ) { }
|
||||
virtual void dragMoveEvent ( QDragMoveEvent * event ) { }
|
||||
virtual void inputMethodEvent ( QInputMethodEvent * event ) { }
|
||||
virtual bool macEvent ( EventHandlerCallRef caller, EventRef event ) { }
|
||||
virtual bool qwsEvent ( QWSEvent * event ) { }
|
||||
virtual void tabletEvent ( QTabletEvent * event ) { }
|
||||
virtual bool winEvent ( MSG * message, long * result ) { }
|
||||
virtual bool x11Event ( XEvent * event ) { } */
|
||||
|
||||
virtual bool event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::Gesture)
|
||||
{
|
||||
return gestureEvent(static_cast<QGestureEvent*>(event), event);
|
||||
}
|
||||
|
||||
return Widget::event(event);
|
||||
}
|
||||
|
||||
bool gestureEvent(QGestureEvent *gesture, QEvent *event)
|
||||
{
|
||||
if (QGesture *tah = gesture->gesture(Qt::TapAndHoldGesture))
|
||||
{
|
||||
// Set the policy so that accepted gestures are taken by the first window that gets them
|
||||
tah->setGestureCancelPolicy ( QGesture::CancelAllInContext );
|
||||
tapandholdTriggered(static_cast<QTapAndHoldGesture *>(tah), event);
|
||||
}
|
||||
|
||||
if (QGesture *pan = gesture->gesture(Qt::PanGesture))
|
||||
{
|
||||
panTriggered(static_cast<QPanGesture *>(pan), event);
|
||||
}
|
||||
|
||||
if (QGesture *pinch = gesture->gesture(Qt::PinchGesture))
|
||||
{
|
||||
pinchTriggered(static_cast<QPinchGesture *>(pinch), event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void tapandholdTriggered(QTapAndHoldGesture *gesture, QEvent *event)
|
||||
{
|
||||
wxWindow *win = wxWindow::QtRetrieveWindowPointer( this );
|
||||
|
||||
if (gesture->state() == Qt::GestureFinished)
|
||||
{
|
||||
if ( win )
|
||||
{
|
||||
wxLongPressEvent ev(win->GetId());
|
||||
ev.SetPosition( wxQtConvertPoint( gesture->position().toPoint() ) );
|
||||
|
||||
ev.SetGestureEnd();
|
||||
win->ProcessWindowEvent( ev );
|
||||
event->accept();
|
||||
}
|
||||
|
||||
}
|
||||
else if (gesture->state() == Qt::GestureStarted)
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void panTriggered(QPanGesture *gesture, QEvent *event)
|
||||
{
|
||||
wxWindow *win = wxWindow::QtRetrieveWindowPointer( this );
|
||||
|
||||
if (win)
|
||||
{
|
||||
wxPanGestureEvent evp(win->GetId());
|
||||
QPoint pos = QCursor::pos();
|
||||
evp.SetPosition( wxQtConvertPoint( pos ) );
|
||||
|
||||
QPoint offset = gesture->offset().toPoint();
|
||||
QPoint offset_last = gesture->lastOffset().toPoint();
|
||||
QPoint delta(offset.x() - offset_last.x(), offset.y() - offset_last.y());
|
||||
|
||||
evp.SetDelta( wxQtConvertPoint( delta ) );
|
||||
|
||||
switch(gesture->state())
|
||||
{
|
||||
case Qt::GestureStarted:
|
||||
evp.SetGestureStart();
|
||||
break;
|
||||
case Qt::GestureFinished:
|
||||
case Qt::GestureCanceled:
|
||||
evp.SetGestureEnd();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
win->ProcessWindowEvent( evp );
|
||||
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void pinchTriggered(QPinchGesture *gesture, QEvent *event)
|
||||
{
|
||||
wxWindow *win = wxWindow::QtRetrieveWindowPointer( this );
|
||||
if (win)
|
||||
{
|
||||
|
||||
qreal this_sf = gesture->scaleFactor();
|
||||
QPoint center_point = gesture->centerPoint().toPoint();
|
||||
|
||||
wxZoomGestureEvent evp(win->GetId());
|
||||
evp.SetPosition( wxQtConvertPoint( center_point ) );
|
||||
evp.SetZoomFactor( this_sf);
|
||||
|
||||
switch(gesture->state())
|
||||
{
|
||||
case Qt::GestureStarted:
|
||||
evp.SetGestureStart();
|
||||
break;
|
||||
case Qt::GestureFinished:
|
||||
case Qt::GestureCanceled:
|
||||
evp.SetGestureEnd();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
win->ProcessWindowEvent( evp );
|
||||
|
||||
event->accept();
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue