void
xQGanttBarViewPort::adjustSize()
//////////////////////////////////
{
    // printf("xQGanttBarViewPort::adjustSize()\n");

    static int sw = 0;
    static int sh = 0;

    int w = screenX(_toplevelitem->getWidth() + _marginX);
    int h = screenY(_toplevelitem->getTotalHeight() + _marginY);

    if(sw != w || sh != h)
    {

        sw = w;
        sh = h;

        resize(w, h);

        emit resized();

    }

}
Example #2
0
void
Chart::DrawArrow(const fixed x, const fixed y, const fixed mag,
                 const Angle angle, enum Style Style)
{
  POINT wv[2];

  wv[0].x = screenX(x);
  wv[0].y = screenY(y);

  const FastRotation r(angle);
  FastRotation::Pair p;

  p = r.Rotate(mag, fixed_zero);
  wv[1].x = wv[0].x + (int)p.first;
  wv[1].y = wv[0].y + (int)p.second;
  StyleLine(wv[0], wv[1], Style);

  p = r.Rotate(mag - fixed(5), fixed(-3));
  wv[1].x = wv[0].x + (int)p.first;
  wv[1].y = wv[0].y + (int)p.second;
  StyleLine(wv[0], wv[1], Style);

  p = r.Rotate(mag - fixed(5), fixed(3));
  wv[1].x = wv[0].x + (int)p.first;
  wv[1].y = wv[0].y + (int)p.second;
  StyleLine(wv[0], wv[1], Style);
}
Example #3
0
void Renderable::draw(const Matrix& mat, double wdt, double hgt) const
{
    SphericalCoordinate sc = (mat * m_Position).toSphericalCoordinate();
    if(sc.distance < 10.0) return; // "clipping"
    Gosu::Image& im = getImage(getImageName());
    Gosu::ImageData& imdata = im.getData();
    Quaternion quat = Quaternion::fromAxisAngle(Vector::RIGHT, -sc.inclination-Gosu::pi/2)*Quaternion::fromAxisAngle(Vector::UP, -sc.azimuth-Gosu::pi/2);
    Matrix mat2 = quat.inverted().toMatrix();
    double dist = sc.distance;
    if (dist > m_FixedSizeDistance) {
        dist = m_FixedSizeDistance;
    }
    Vector vn = mat2 * Vector(-double(im.width())/2*m_Scale, -double(im.height())/2*m_Scale, -dist);
    Vector vp = mat2 * Vector(double(im.width())/2*m_Scale, double(im.height())/2*m_Scale, -dist);
    SphericalCoordinate n = vn.toSphericalCoordinate();
    SphericalCoordinate p = vp.toSphericalCoordinate();
    auto drawfun = [m_Color, dist, &imdata](double nx, double ny, double px, double py)
    {
        imdata.draw(nx, ny, m_Color,
                    px, ny, m_Color,
                    px, py, m_Color,
                    nx, py, m_Color, -dist, Gosu::amDefault);
    };
    double nx = screenX(n, wdt);
    double px = screenX(p, wdt);
    double ny = screenY(n, hgt);
    double py = screenY(p, hgt);
    if (nx > px) {
        if (ny > py) {
            drawfun(nx - wdt, ny - hgt, px, py);
            drawfun(nx - wdt, ny, px, py + hgt);
            drawfun(nx, ny - hgt, px + wdt, py);
            drawfun(nx, ny, px + wdt, py + hgt);
        } else {
            drawfun(nx - wdt, ny, px, py);
            drawfun(nx, ny, px + wdt, py);
        }
    } else {
        if (ny > py) {
            drawfun(nx, ny - hgt, px, py);
            drawfun(nx, ny, px, py + hgt);
        } else {
            drawfun(nx, ny, px, py);
        }
    }
}
void
xQGanttBarViewPort::recalc()
{
    // printf("xQGanttBarViewPort::recalc()\n");
    _gItemList.clear();
    recalc(_toplevelitem, screenX(0), screenY(0), 0, 0);
    emit recalculated();
}
void
xQGanttBarViewPort::drawHeader(QPainter *p, int /*x1*/, int /*y1*/, int /*x2*/, int /*y2*/)
//////////////////////////////////////////////////////////////////////////
{
    bool drawDays = false;
    int a, e, tmp;

    QDate start(_toplevelitem->getStart().addSecs(-_marginX * 60).date());

    // subtract 1 month to draw first month
    QDate t(start.year(), start.month() - 1, start.day());

    QDateTime itemstart = _toplevelitem->getStart();

    int end = (int)(width() / (1440 * _scaleX));

    if(end < 12) drawDays = true;

    end += 30; // add 30 days to draw last month

    p->setPen(QPen(QColor(black)));

    for(int i = 0; i <= end; i++, t = t.addDays(1))
    {

        tmp = itemstart.secsTo(t) / 60;
        a = screenX(tmp);

        if(t.dayOfWeek() == 1)
        {

            p->fillRect(a, 0, (int)(1440 * 5 * _scaleX), 20, QBrush(QColor(240, 240, 240)));
            p->drawRect(a, 0, (int)(1440 * 5 * _scaleX), 20);

            if(!drawDays)
                p->drawText(a + 5, 15, QString::number(t.day()));
        }

        if(drawDays)
        {
            p->drawText(a + 5, 15, t.shortDayName(t.dayOfWeek()) + " " + QString::number(t.day()));
        }

        if(t.day() == 1)
        {

            e = t.daysInMonth();

            p->fillRect(a, 21, (int)(1440 * e * _scaleX), 20, QBrush(QColor(240, 240, 240)));
            p->drawRect(a, 21, (int)(1440 * e * _scaleX), 20);

            if(a < 0) a = 0;
            p->drawText(a + 5, 36, t.shortMonthName(t.month()));

        }

    }
}
Example #6
0
PassRefPtr<Event> MouseEvent::cloneFor(HTMLIFrameElement* iframe) const
{
    ASSERT(iframe);
    RefPtr<MouseEvent> clonedMouseEvent = MouseEvent::create();
    Frame* frame = iframe->document().frame();
    FrameView* frameView = frame ? frame->view() : 0;
    clonedMouseEvent->initMouseEvent(type(), bubbles(), cancelable(),
        iframe->document().defaultView(),
        detail(), screenX(), screenY(),
        frameView ? adjustedClientX(clientX(), iframe, frameView) : 0,
        frameView ? adjustedClientY(clientY(), iframe, frameView) : 0,
        ctrlKey(), altKey(), shiftKey(), metaKey(),
        button(),
        // Nullifies relatedTarget.
        0);
    return clonedMouseEvent.release();
}
Example #7
0
Ref<Event> MouseEvent::cloneFor(HTMLIFrameElement* iframe) const
{
    ASSERT(iframe);
    Frame* frame = iframe->document().frame();
    FrameView* frameView = frame ? frame->view() : nullptr;
    Ref<MouseEvent> clonedMouseEvent = MouseEvent::create(type(), bubbles(), cancelable(),
        iframe->document().defaultView(),
        detail(), screenX(), screenY(),
        frameView ? adjustedClientX(clientX(), iframe, frameView) : 0,
        frameView ? adjustedClientY(clientY(), iframe, frameView) : 0,
        ctrlKey(), altKey(), shiftKey(), metaKey(),
        button(),
        syntheticClickType(),
        // Nullifies relatedTarget.
        0);
    clonedMouseEvent->setForce(force());
    return WTFMove(clonedMouseEvent);
}
void
xQGanttBarViewPort::zoom(double sfactor, int sx, int sy)
///////////////////////////////////////////////////////
{
    printf("zoom %f, (%d,%d) \n", sfactor, sx, sy);

    int wx = worldX(sx);
    int wy = worldY(sy);

    _scaleX *= sfactor;

    printf("recalc ... \n");

    recalc();
    adjustSize();

    _parent->center(screenX(wx), screenY(wy));

    QWidget::update();

    printf("zoom ok.\n");

}
Example #9
0
double PointItem::getXScr()
{
    return screenX(x);
}
void
xQGanttBarViewPort::drawGrid(QPainter *p, int x1, int y1, int x2, int y2)
////////////////////////////////////////////////////////////////
{
    y2 += 5; // avoid white lines at bottom of redrawn region

    static int a, w, end, tmp;
    static QBrush _sat(QColor(200, 200, 200));
    static QBrush _sun(QColor(255, 110, 110));
    static QBrush _hol(QColor(200, 200, 250));
    static QPen penDay(QColor(235, 235, 235), 0, DotLine);
    static QPen penMonth(QColor(0, 150, 0), 3, DashDotLine);
    static QPen penHour(QColor(0, 0, 150), 0, DashDotLine);

    QDate start(_toplevelitem->getStart().addSecs(worldX(x1) * 60).date());

    end = (int)((x2 - x1) / (1440.*_scaleX)) + 1;
    w = (int)(1440. * _scaleX + 0.5);

    //  draw holydays

    QDate *ptrDate;
    QDate cmp(start.addDays(-1));

    for(ptrDate = _holidays.first(); ptrDate != 0; ptrDate = _holidays.next())
    {
        if(*ptrDate > cmp)
        {
            tmp = _toplevelitem->getStart().secsTo(*ptrDate) / 60;
            a = screenX(tmp);
            p->fillRect(a, y1, w, y2, _hol);
        }

    }

    //  draw grid

    for(int i = 0; i <= end; i++, start = start.addDays(1))
    {

        int dayOfWeek = start.dayOfWeek();
        tmp = _toplevelitem->getStart().secsTo(start) / 60;
        a = screenX(tmp);

        //  draw saturday
        if(dayOfWeek == 6)
        {

            p->fillRect(a, y1, w, y2, _sat);

            if(start.day() == 1)
            {
                p->setPen(penMonth);
                p->drawLine(a, y1, a, y2);
            }

            // continue;
        }

        //  sunday
        if(dayOfWeek == 7)
        {

            p->fillRect(a, y1, w, y2, _sun);

            if(start.day() == 1)
            {
                p->setPen(penMonth);
                p->drawLine(a, y1, a, y2);
            }

            // continue;
        }

        if(start.day() == 1)
            p->setPen(penMonth);
        else
        {
            if(dayOfWeek == 1 || dayOfWeek == 6 || dayOfWeek == 7)
                continue;
            p->setPen(penDay);
        }

        p->drawLine(a, y1, a, y2);

    }
}
Example #11
0
bool CursesAction::processEvent(QEvent *e) {
    switch(e->type()) {
        case GUIEvent::GUIMouseClicked:
            activate();
            break;

        case GUIEvent::GUIKeyTyped:
            switch(((GUIKeyEvent*)e)->key()) {
                case Qt::Key_Enter:
                    activate();
                    return true;

                case Qt::Key_Tab:
                    if(qobject_cast<GUIMenu*>(parent()) ||
                            qobject_cast<GUIMenuBar*>(parent()))
                        return false;

                default:
                    break;
            }

            break;

        case GUIEvent::GUIFocusChanged:
            markDirty();
            break;

        case GUIEvent::GUIScreenPositionChanged:
            if(!widget()->isFocused())
                break;
        case GUIEvent::GUIFocusGained:
            CursesMainWindow::current()->setCursor(screenX() + _spos, screenY());
            break;

        case GUIEvent::GUIFocusLost:
        {
            CursesMainWindow::current()->setCursor(-1, -1);
            CursesMenu* menu = qobject_cast<CursesMenu*>(parent());
            if(menu && currentFocus()) {
                CursesMenu* newMenu = qobject_cast<CursesMenu*>(currentFocus()->parent());
                while(newMenu) {
                    if(newMenu == menu)
                        break;

                    if(newMenu->currentAction())
                        newMenu = qobject_cast<CursesMenu*>(newMenu->currentAction()->parent());
                }
                if(newMenu == menu)
                    break;

                menu->close();
            }

            break;
        }

        default:
            break;
    }

    return CursesBase::processEvent(e);
}