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(); } }
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); }
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(); }
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(); }
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"); }
double PointItem::getYScr() { return screenY(y); }
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); }