2008-04-19 15:31:50 +00:00
|
|
|
#include "mozqwidget.h"
|
2008-04-19 15:37:51 +00:00
|
|
|
#include "nsWindow.h"
|
2008-04-19 15:31:50 +00:00
|
|
|
|
2010-02-16 18:14:20 +00:00
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include <QtGui/QCursor>
|
|
|
|
#include <QtGui/QInputContext>
|
|
|
|
#include <QtGui/QGraphicsSceneContextMenuEvent>
|
|
|
|
#include <QtGui/QGraphicsSceneDragDropEvent>
|
|
|
|
#include <QtGui/QGraphicsSceneMouseEvent>
|
|
|
|
#include <QtGui/QGraphicsSceneHoverEvent>
|
|
|
|
#include <QtGui/QGraphicsSceneWheelEvent>
|
|
|
|
|
|
|
|
#include <QtCore/QEvent>
|
|
|
|
#include <QtCore/QVariant>
|
|
|
|
|
|
|
|
|
|
|
|
MozQWidget::MozQWidget(nsWindow* aReceiver, QGraphicsItem* aParent)
|
|
|
|
: QGraphicsWidget(aParent),
|
|
|
|
mReceiver(aReceiver)
|
2008-04-19 15:31:50 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-03-27 11:35:27 +00:00
|
|
|
MozQWidget::~MozQWidget()
|
|
|
|
{
|
|
|
|
if (mReceiver)
|
|
|
|
mReceiver->QWidgetDestroyed();
|
|
|
|
}
|
|
|
|
|
2010-02-16 18:14:20 +00:00
|
|
|
void MozQWidget::paint(QPainter* aPainter, const QStyleOptionGraphicsItem* aOption, QWidget* aWidget /*= 0*/)
|
2008-04-19 15:31:50 +00:00
|
|
|
{
|
2010-02-16 18:14:20 +00:00
|
|
|
mReceiver->DoPaint(aPainter, aOption);
|
|
|
|
}
|
|
|
|
|
2010-02-25 18:58:19 +00:00
|
|
|
void MozQWidget::activate()
|
|
|
|
{
|
|
|
|
mReceiver->DispatchActivateEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::deactivate()
|
|
|
|
{
|
|
|
|
mReceiver->DispatchDeactivateEvent();
|
|
|
|
}
|
|
|
|
|
2010-02-16 18:14:20 +00:00
|
|
|
void MozQWidget::resizeEvent(QGraphicsSceneResizeEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnResizeEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->contextMenuEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::dragEnterEvent(QGraphicsSceneDragDropEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnDragEnter(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnDragLeaveEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::dragMoveEvent(QGraphicsSceneDragDropEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnDragMotionEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::dropEvent(QGraphicsSceneDragDropEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnDragDropEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::focusInEvent(QFocusEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnFocusInEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::focusOutEvent(QFocusEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnFocusOutEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::hoverEnterEvent(QGraphicsSceneHoverEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnEnterNotifyEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnLeaveNotifyEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::hoverMoveEvent(QGraphicsSceneHoverEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnMoveEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::keyPressEvent(QKeyEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnKeyPressEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::keyReleaseEvent(QKeyEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnKeyReleaseEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->mouseDoubleClickEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::mouseMoveEvent(QGraphicsSceneMouseEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnMotionNotifyEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::mousePressEvent(QGraphicsSceneMouseEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnButtonPressEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnButtonReleaseEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MozQWidget::wheelEvent(QGraphicsSceneWheelEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnScrollEvent(aEvent);
|
|
|
|
}
|
2008-04-20 08:37:07 +00:00
|
|
|
|
2010-02-16 18:14:20 +00:00
|
|
|
void MozQWidget::closeEvent(QCloseEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->OnCloseEvent(aEvent);
|
|
|
|
}
|
2008-04-19 15:31:50 +00:00
|
|
|
|
2010-02-16 18:14:20 +00:00
|
|
|
void MozQWidget::hideEvent(QHideEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->hideEvent(aEvent);
|
|
|
|
}
|
2008-04-20 08:16:40 +00:00
|
|
|
|
2010-02-16 18:14:20 +00:00
|
|
|
void MozQWidget::showEvent(QShowEvent* aEvent)
|
|
|
|
{
|
|
|
|
mReceiver->showEvent(aEvent);
|
2008-04-19 15:31:50 +00:00
|
|
|
}
|
|
|
|
|
2010-02-16 18:14:20 +00:00
|
|
|
bool MozQWidget::SetCursor(nsCursor aCursor)
|
2008-04-19 15:37:55 +00:00
|
|
|
{
|
|
|
|
Qt::CursorShape cursor = Qt::ArrowCursor;
|
|
|
|
switch(aCursor) {
|
|
|
|
case eCursor_standard:
|
|
|
|
cursor = Qt::ArrowCursor;
|
|
|
|
break;
|
|
|
|
case eCursor_wait:
|
|
|
|
cursor = Qt::WaitCursor;
|
|
|
|
break;
|
|
|
|
case eCursor_select:
|
|
|
|
cursor = Qt::IBeamCursor;
|
|
|
|
break;
|
|
|
|
case eCursor_hyperlink:
|
|
|
|
cursor = Qt::PointingHandCursor;
|
|
|
|
break;
|
|
|
|
case eCursor_ew_resize:
|
|
|
|
cursor = Qt::SplitHCursor;
|
|
|
|
break;
|
|
|
|
case eCursor_ns_resize:
|
|
|
|
cursor = Qt::SplitVCursor;
|
|
|
|
break;
|
|
|
|
case eCursor_nw_resize:
|
|
|
|
case eCursor_se_resize:
|
|
|
|
cursor = Qt::SizeBDiagCursor;
|
|
|
|
break;
|
|
|
|
case eCursor_ne_resize:
|
|
|
|
case eCursor_sw_resize:
|
|
|
|
cursor = Qt::SizeFDiagCursor;
|
|
|
|
break;
|
|
|
|
case eCursor_crosshair:
|
|
|
|
case eCursor_move:
|
|
|
|
cursor = Qt::SizeAllCursor;
|
|
|
|
break;
|
|
|
|
case eCursor_help:
|
|
|
|
cursor = Qt::WhatsThisCursor;
|
|
|
|
break;
|
|
|
|
case eCursor_copy:
|
|
|
|
case eCursor_alias:
|
|
|
|
break;
|
|
|
|
case eCursor_context_menu:
|
|
|
|
case eCursor_cell:
|
|
|
|
case eCursor_grab:
|
|
|
|
case eCursor_grabbing:
|
|
|
|
case eCursor_spinning:
|
|
|
|
case eCursor_zoom_in:
|
|
|
|
case eCursor_zoom_out:
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
setCursor(cursor);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-16 18:14:20 +00:00
|
|
|
bool MozQWidget::SetCursor(const QPixmap& aCursor, int aHotX, int aHotY)
|
2008-04-19 15:31:50 +00:00
|
|
|
{
|
2010-02-16 18:14:20 +00:00
|
|
|
QCursor bitmapCursor(aCursor, aHotX, aHotY);
|
|
|
|
setCursor(bitmapCursor);
|
|
|
|
|
|
|
|
return NS_OK;
|
2008-04-19 15:31:50 +00:00
|
|
|
}
|
2008-04-20 08:16:40 +00:00
|
|
|
|
2010-02-16 18:14:20 +00:00
|
|
|
void MozQWidget::setModal(bool modal)
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= 0x040600
|
|
|
|
setPanelModality(modal ? QGraphicsItem::SceneModal : QGraphicsItem::NonModal);
|
|
|
|
#else
|
|
|
|
LOG(("Modal QGraphicsWidgets not supported in Qt < 4.6\n"));
|
|
|
|
#endif
|
|
|
|
}
|