DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Mercurial (4a108e94d3e2)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set ts=4 et sw=4 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include <QtCore/QCoreApplication>
#include <QtGui/QResizeEvent>

#include "mozqwidget.h"
#include "nsWindow.h"

using namespace mozilla::widget;

MozQWidget::MozQWidget(nsWindow* aReceiver, QWindow* aParent)
  : QWindow(aParent)
  , mReceiver(aReceiver)
  , mUpdatePending(false)
{
    mWindowType = mReceiver->WindowType();
}

MozQWidget::~MozQWidget()
{
}

void MozQWidget::render(QPainter* painter)
{
    Q_UNUSED(painter);
}

void MozQWidget::renderLater()
{
    if (!isExposed() || eWindowType_child != mWindowType || !isVisible()) {
        return;
    }

    if (!mUpdatePending) {
        mUpdatePending = true;
        QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
    }
}

void MozQWidget::renderNow()
{
    if (!isExposed() || eWindowType_child != mWindowType || !isVisible()) {
        return;
    }

    mReceiver->OnPaint();
}

bool MozQWidget::event(QEvent* event)
{
    switch (event->type()) {
    case QEvent::UpdateRequest:
        mUpdatePending = false;
        renderNow();
        return true;
    default:
        return QWindow::event(event);
    }
}

void MozQWidget::exposeEvent(QExposeEvent* event)
{
    Q_UNUSED(event);
    if (!isExposed() || eWindowType_child != mWindowType || !isVisible()) {
        return;
    }
    LOG(("MozQWidget::%s [%p] flags:%x\n", __FUNCTION__, (void *)this, flags()));
    renderNow();

}

void MozQWidget::resizeEvent(QResizeEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->resizeEvent(event);
    QWindow::resizeEvent(event);
}

void MozQWidget::focusInEvent(QFocusEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->focusInEvent(event);
    QWindow::focusInEvent(event);
}

void MozQWidget::focusOutEvent(QFocusEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->focusOutEvent(event);
    QWindow::focusOutEvent(event);
}

void MozQWidget::hideEvent(QHideEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->hideEvent(event);
    QWindow::hideEvent(event);
}

void MozQWidget::keyPressEvent(QKeyEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->keyPressEvent(event);
    QWindow::keyPressEvent(event);
}

void MozQWidget::keyReleaseEvent(QKeyEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->keyReleaseEvent(event);
    QWindow::keyReleaseEvent(event);
}

void MozQWidget::mouseDoubleClickEvent(QMouseEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->mouseDoubleClickEvent(event);
    QWindow::mouseDoubleClickEvent(event);
}

void MozQWidget::mouseMoveEvent(QMouseEvent* event)
{
    mReceiver->mouseMoveEvent(event);
    QWindow::mouseMoveEvent(event);
}

void MozQWidget::mousePressEvent(QMouseEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->mousePressEvent(event);
    QWindow::mousePressEvent(event);
}

void MozQWidget::mouseReleaseEvent(QMouseEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->mouseReleaseEvent(event);
    QWindow::mouseReleaseEvent(event);
}

void MozQWidget::moveEvent(QMoveEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->moveEvent(event);
    QWindow::moveEvent(event);
}

void MozQWidget::showEvent(QShowEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->showEvent(event);
    QWindow::showEvent(event);
}

void MozQWidget::wheelEvent(QWheelEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    mReceiver->wheelEvent(event);
    QWindow::wheelEvent(event);
}

void MozQWidget::tabletEvent(QTabletEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    QWindow::tabletEvent(event);
}

void MozQWidget::touchEvent(QTouchEvent* event)
{
    LOG(("MozQWidget::%s [%p]\n", __FUNCTION__, (void *)this));
    QWindow::touchEvent(event);
}

void MozQWidget::SetCursor(nsCursor aCursor)
{
    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);
}