コード例 #1
0
ファイル: RenderView.cpp プロジェクト: jackiekaon/owb-mirror
void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
{
    if (printing() || ur.width() == 0 || ur.height() == 0)
        return;

    if (!m_frameView)
        return;

    // We always just invalidate the root view, since we could be an iframe that is clipped out
    // or even invisible.
    Element* elt = document()->ownerElement();
    if (!elt)
        m_frameView->repaintContentRectangle(ur, immediate);
    else if (RenderObject* obj = elt->renderer()) {
        IntRect vr = viewRect();
        IntRect r = intersection(ur, vr);
        
        // Subtract out the contentsX and contentsY offsets to get our coords within the viewing
        // rectangle.
        r.move(-vr.x(), -vr.y());
        
        // FIXME: Hardcoded offsets here are not good.
        r.move(obj->borderLeft() + obj->paddingLeft(),
               obj->borderTop() + obj->paddingTop());
        obj->repaintRectangle(r, immediate);
    }
}
コード例 #2
0
void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
{
#if PLATFORM(WKC)
    CRASH_IF_STACK_OVERFLOW(WKC_STACK_MARGIN_DEFAULT);
#endif
    if (!shouldRepaint(ur))
        return;

    // We always just invalidate the root view, since we could be an iframe that is clipped out
    // or even invisible.
    Element* elt = document()->ownerElement();
    if (!elt)
        m_frameView->repaintContentRectangle(ur, immediate);
    else if (RenderBox* obj = elt->renderBox()) {
        IntRect vr = viewRect();
        IntRect r = intersection(ur, vr);
        
        // Subtract out the contentsX and contentsY offsets to get our coords within the viewing
        // rectangle.
        r.move(-vr.x(), -vr.y());
        
        // FIXME: Hardcoded offsets here are not good.
        r.move(obj->borderLeft() + obj->paddingLeft(),
               obj->borderTop() + obj->paddingTop());
        obj->repaintRectangle(r, immediate);
    }
}
コード例 #3
0
ファイル: unitlist.cpp プロジェクト: Try/game
  void paintEvent(Tempest::PaintEvent &e){
    Button::paintEvent(e);

    Tempest::Painter p(e);

    //PainterGUI& pt = (PainterGUI&)p.device();
    p.setColor( 1, 1-std::max(1-oldHp/200.0, 0.0), 1-std::max(1-oldHp/128.0, 0.0), 1 );

    p.setBlendMode( Tempest::alphaBlend );
    p.setTexture( icon );

    int sz = std::min(w(), h());
    float k = std::min( sz/float(icon.w()),
                        sz/float(icon.h()) );

    int icW = icon.w() *k,
        icH = icon.h()*k;

    Tempest::Rect s = p.scissor();
    p.setScissor( s.intersected(viewRect()) );
    p.drawRect( (w()-icW)/2, (h()-icH)/2, icW, icH,
                0, 0, icon.w(), icon.h() );
    p.setScissor(s);

    drawFrame(p);
    }
コード例 #4
0
void Ut_MWidget::testExitedDisplay()
{
    m_dummySlotCalled = false;

    QRectF viewRect(0, 0, 864, 480);
    {
        MOnDisplayChangeEvent ev(MOnDisplayChangeEvent::FullyOnDisplay,
                                   viewRect);
        widget->event(&ev);
    }

    QVERIFY(m_dummySlotCalled == false);

    connect(widget, SIGNAL(displayExited()), this, SLOT(dummySlot()));

    {
        MOnDisplayChangeEvent ev(MOnDisplayChangeEvent::FullyOffDisplay,
                                   viewRect);
        widget->event(&ev);
    }

    QVERIFY(m_dummySlotCalled == true);

    disconnect(widget, SIGNAL(displayExited()), this, SLOT(dummySlot()));
}
コード例 #5
0
ファイル: kicongrid.cpp プロジェクト: kthxbyte/KDE1-Linaro
void KGridView::paintDropSite()
{
  QPainter p;
  p.begin( _grid );
  p.setRasterOp (NotROP);
  p.drawRect(viewRect());
  p.end();
}
コード例 #6
0
ファイル: kcolorgrid.cpp プロジェクト: kthxbyte/KDE1-Linaro
void KColorGrid::setCellSize( int s )
{
  cellsize = s;
  totalwidth = (numCols() * s) + 1;
  totalheight = (numRows() * s) + 1;
  resize(totalwidth, totalheight);
  if ( isVisible() )
    repaint(viewRect(), false);
}
コード例 #7
0
ファイル: htable.cpp プロジェクト: pmattern/qps
// TEST
void TableHead::checkProfile()
{
    QRect viewR = viewRect();
    // if(viewR.y()!=0) printf(" qps: ooooohss....\n");
    int maxViewCol = findCol(viewR.width());
    if (maxViewCol < 0)
        maxViewCol = numCols();
    tablecache.setCol(maxViewCol);
    tablecache.setRow(1);
}
コード例 #8
0
ファイル: DragHandle.cpp プロジェクト: nkutty/qforcestudio
void DragHandler::setHitAreaView(int id, QPointF viewPos, double halfWidth, double halfHeight)
{
    if (0 == halfHeight)
    {
        halfHeight = halfWidth;
    }
    QRectF viewRect(viewPos, QSize());
    viewRect.adjust(-halfWidth, -halfHeight, halfWidth, halfHeight);
    QRectF modelRect = m_view2Model.mapRect(viewRect);
    setHitArea(id, modelRect);
}
コード例 #9
0
ファイル: RenderView.cpp プロジェクト: RobinWuDev/Qt
void RenderView::invalidateTreeIfNeeded(const PaintInvalidationState& paintInvalidationState)
{
    ASSERT(!needsLayout());

    // We specifically need to issue paint invalidations for the viewRect since other renderers
    // short-circuit on full-paint invalidation.
    LayoutRect dirtyRect = viewRect();
    if (doingFullPaintInvalidation() && !dirtyRect.isEmpty()) {
        const RenderLayerModelObject* paintInvalidationContainer = &paintInvalidationState.paintInvalidationContainer();
        RenderLayer::mapRectToPaintInvalidationBacking(this, paintInvalidationContainer, dirtyRect, &paintInvalidationState);
        invalidatePaintUsingContainer(paintInvalidationContainer, dirtyRect, PaintInvalidationFull);
    }
    RenderBlock::invalidateTreeIfNeeded(paintInvalidationState);
}
コード例 #10
0
ファイル: htable.cpp プロジェクト: pmattern/qps
// TESt
void TableBody::checkProfile()
{
    htable->checkTableModel(); // important

    QRect viewR = viewRect();
    if (viewR.y() != 0)
        printf(" qps: ooooophss....\n");
    int maxViewRow = findRow(viewR.height());
    if (maxViewRow < 0)
        maxViewRow = numRows();
    int maxViewCol = findCol(viewR.width());
    if (maxViewCol < 0)
        maxViewCol = numCols();
    tablecache.setCol(maxViewCol);
    tablecache.setRow(maxViewRow);
}
コード例 #11
0
ファイル: imageviewer.cpp プロジェクト: janisozaur/opentoonz
//! Adapts image viewer's affine to display the passed viewer rect at maximized
//! ratio
void ImageViewer::adaptView(const QRect &geomRect) {
  if (!m_image) return;

  // Retrieve the rect in image reference and call the associated adaptView
  TRect imgBounds(getImageBounds(m_image));
  TRectD imgBoundsD(imgBounds.x0, imgBounds.y0, imgBounds.x1 + 1,
                    imgBounds.y1 + 1);

  TRectD geomRectD(geomRect.left(), geomRect.top(), geomRect.right() + 1,
                   geomRect.bottom() + 1);
  TRectD viewRectD(getImgToWidgetAffine().inv() * geomRectD);
  TRect viewRect(tfloor(viewRectD.x0), tfloor(viewRectD.y0),
                 tceil(viewRectD.x1) - 1, tceil(viewRectD.y1) - 1);

  adaptView(imgBounds, viewRect);
}
コード例 #12
0
ファイル: CGame.cpp プロジェクト: zZelman/Marshmallow-Duels
void CGame::initWindow()
{
	int numTiles = 25;
	int sizeTile = 32;
	int size = sizeTile * numTiles;
	m_pWindow 	= new sf::RenderWindow(sf::VideoMode(size, size), "Independent Study");

	// NOTE: do not use Virtual Sync and fixed frame rate at once
//	m_pGameWindow->setVerticalSyncEnabled(true);
	m_pWindow->setFramerateLimit(60);

	sf::FloatRect viewRect(0, 0, size, size);
	sf::View view;
	view.reset(viewRect);
	m_pWindow->setView(view);

	m_pWindow->setVisible(true);
}
コード例 #13
0
ファイル: RenderView.cpp プロジェクト: acss/owb-mirror
void RenderView::layout()
{
    layoutCounter.startCounting();
    if (printing())
        m_minPrefWidth = m_maxPrefWidth = m_width;

    // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account.
    bool relayoutChildren = !printing() && (!m_frameView || m_width != viewWidth() || m_height != viewHeight());
    if (relayoutChildren) {
        setChildNeedsLayout(true, false);
        for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
            if (child->style()->height().isPercent() || child->style()->minHeight().isPercent() || child->style()->maxHeight().isPercent())
                child->setChildNeedsLayout(true, false);
        }
    }

    ASSERT(!m_layoutState);
    LayoutState state;
    IntRect viewRectangle = viewRect();
    // An empty rect is not valid viewRect.
    state.m_clipped = !viewRectangle.isEmpty();

    if (state.m_clipped) {
        state.m_clipRect = IntRect(IntPoint(0, 0), viewRectangle.size());
        state.m_offset = IntSize(viewRectangle.x(), viewRectangle.y());
    }
    m_layoutState = &state;

    if (needsLayout())
        RenderBlock::layout();

    // Ensure that docWidth() >= width() and docHeight() >= height().
    setOverflowWidth(m_width);
    setOverflowHeight(m_height);

    setOverflowWidth(docWidth());
    setOverflowHeight(docHeight());

    ASSERT(m_layoutStateDisableCount == 0);
    ASSERT(m_layoutState == &state);
    m_layoutState = 0;
    setNeedsLayout(false);
    layoutCounter.stopCounting();
}
コード例 #14
0
ファイル: InputPreview.cpp プロジェクト: thomaschw/omnidome
    void InputPreview::paintGL()
    {
      if (!input() || !isVisible()) return;

      makeCurrent();

      if (!shader_) {
        primaryContextSwitch([&](QOpenGLFunctions& _) {
          visual::initShader(shader_,"textureRect");
        });
      }

      withCurrentContext([this](QOpenGLFunctions& _)
      {
        _.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
        auto _rect = viewRect();

        visual::viewport(this);

        /// Setup orthogonal projection
        glMatrixMode(GL_PROJECTION);
        {
          glLoadIdentity();
          QMatrix4x4 _m;
          _m.ortho(_rect.left(), _rect.right(), _rect.top(), _rect.bottom(), -1.0,
                   1.0);
          glMultMatrixf(_m.constData());
        }

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        shader_->bind();
        _.glBindTexture(GL_TEXTURE_RECTANGLE, input_->textureId());
        visual::Rectangle::draw(input_->size());
        _.glBindTexture(GL_TEXTURE_RECTANGLE, 0);
        shader_->release();
      });

      paintGLDone();
    }
コード例 #15
0
ファイル: RenderView.cpp プロジェクト: RobinWuDev/Qt
void RenderView::mapRectToPaintInvalidationBacking(const RenderLayerModelObject* paintInvalidationContainer, LayoutRect& rect, ViewportConstrainedPosition viewportConstraint, const PaintInvalidationState* state) const
{
    if (document().printing())
        return;

    if (style()->slowIsFlippedBlocksWritingMode()) {
        // We have to flip by hand since the view's logical height has not been determined.  We
        // can use the viewport width and height.
        if (style()->isHorizontalWritingMode())
            rect.setY(viewHeight() - rect.maxY());
        else
            rect.setX(viewWidth() - rect.maxX());
    }

    adjustViewportConstrainedOffset(rect, viewportConstraint);

    // Apply our transform if we have one (because of full page zooming).
    if (!paintInvalidationContainer && layer() && layer()->transform())
        rect = layer()->transform()->mapRect(rect);

    ASSERT(paintInvalidationContainer);
    if (paintInvalidationContainer == this)
        return;

    Element* owner = document().ownerElement();
    if (!owner)
        return;

    if (RenderBox* obj = owner->renderBox()) {
        // Intersect the viewport with the paint invalidation rect.
        LayoutRect viewRectangle = viewRect();
        rect.intersect(viewRectangle);

        // Adjust for scroll offset of the view.
        rect.moveBy(-viewRectangle.location());

        // Adjust for frame border.
        rect.moveBy(obj->contentBoxRect().location());
        obj->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, 0);
    }
}
コード例 #16
0
void RenderView::repaintViewRectangle(const LayoutRect& ur, bool immediate)
{
    if (!shouldRepaint(ur))
        return;

    // We always just invalidate the root view, since we could be an iframe that is clipped out
    // or even invisible.
    Element* elt = document()->ownerElement();
    if (!elt)
        m_frameView->repaintContentRectangle(pixelSnappedIntRect(ur), immediate);
    else if (RenderBox* obj = elt->renderBox()) {
        LayoutRect vr = viewRect();
        LayoutRect r = intersection(ur, vr);
        
        // Subtract out the contentsX and contentsY offsets to get our coords within the viewing
        // rectangle.
        r.moveBy(-vr.location());

        // FIXME: Hardcoded offsets here are not good.
        r.moveBy(obj->contentBoxRect().location());
        obj->repaintRectangle(r, immediate);
    }
}
コード例 #17
0
HTGAvatarView::HTGAvatarView(twitCurl* twitObj, BHandler* parent, BRect frame, uint32 resizingMode)
	: BView(frame, "AvatarView", resizingMode, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE)
{	
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	avatarTweet = NULL;
	this->twitObj = twitObj;
	displayAvatar = true;
	
	fParent = parent;

	//Set up text view 
	BRect viewRect(5,22,frame.right-60,45);
	fMessage = new HTGTextView(viewRect, "Text", BRect(5,5,viewRect.right-5,viewRect.bottom-5), B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW);
	AddChild(fMessage);
	
	//Set up post button
	fPostButton = new BButton(BRect(frame.right-55, frame.top+1+kMargin, frame.right-5, frame.top), NULL, "Tweet", new BMessage(POST));
	fPostButton->SetEnabled(false);
	
	//Set up symbol counter
	fCounterView = new BStringView(BRect(frame.right-40, frame.top+1+kMargin+fPostButton->Bounds().Height(), frame.right-15, frame.top+1+kMargin+fPostButton->Bounds().Height()+12), "Counter", "140");
	fCounterView->SetHighColor(128, 128, 128);
}
コード例 #18
0
ファイル: pdfview.cpp プロジェクト: cbiffle/runcible
  virtual QImage scaleAndRender(const Poppler::Page *page, const QWidget *widget) {
    QList<Poppler::TextBox *> textBoxen = page->textList();
    QRectF bounds;
     while (!textBoxen.isEmpty()) {
        Poppler::TextBox *box = textBoxen.takeFirst();
        bounds = bounds.united(box->boundingBox());
        delete box;
     }

    bounds.adjust(-4, -4, 8, 8);

     qreal win = bounds.width() / 72., hin = bounds.height() / 72.;
     qreal xsc = widget->width() / win, ysc = widget->height() / hin;

    qreal scale = qMin(xsc, ysc);
    QRectF viewRect(bounds.left() / 72. * scale, bounds.top() / 72. * scale,
        bounds.width() / 72. * scale, bounds.height() / 72. * scale);

    QRect iRect = viewRect.toAlignedRect();

    return page->renderToImage(scale, scale,
         iRect.left(), iRect.top(), iRect.width(), iRect.height());
  }
コード例 #19
0
ファイル: InputPreview.cpp プロジェクト: flair2005/omnidome
    void InputPreview::paintGL()
    {
      auto* _input = input();

      visual::with_current_context([this](QOpenGLFunctions& _)
      {
        _.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        _.glDisable(GL_BLEND);
      });

      if (!_input) return;

      auto _rect = viewRect();

      _input->update();
      makeCurrent();
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

      visual::viewport(this);

      /// Setup orthogonal projection
      glMatrixMode(GL_PROJECTION);
      {
        glLoadIdentity();
        QMatrix4x4 _m;
        _m.ortho(_rect.left(),_rect.right(),_rect.top(),_rect.bottom(),-1.0,1.0);
        glMultMatrixf(_m.constData());
      }

      visual::with_current_context([&](QOpenGLFunctions& _)
      {
        _.glEnable(GL_TEXTURE_2D);
        _.glBindTexture(GL_TEXTURE_2D, _input->textureId());
        visual::Rectangle::draw();
        _.glBindTexture(GL_TEXTURE_2D, 0);
      });
    }
コード例 #20
0
QAccessible::State QQmlAccessible::state() const
{
    QAccessible::State state;

    //QRect viewRect(QPoint(0, 0), m_implementation->size());
    //QRect itemRect(m_item->scenePos().toPoint(), m_item->boundingRect().size().toSize());

    QRect viewRect_ = viewRect();
    QRect itemRect = rect();

   // qDebug() << "viewRect" << viewRect << "itemRect" << itemRect;
    // error case:
    if (viewRect_.isNull() || itemRect.isNull()) {
        state.invisible = true;
    }

    if (!viewRect_.intersects(itemRect)) {
        state.offscreen = true;
        // state.invisible = true; // no set at this point to ease development
    }

    if (!object()->property("visible").toBool() || qFuzzyIsNull(object()->property("opacity").toDouble())) {
        state.invisible = true;
    }

    if ((role() == QAccessible::CheckBox || role() == QAccessible::RadioButton) && object()->property("checked").toBool()) {
        state.checked = true;
    }

    if (role() == QAccessible::EditableText)
        state.focusable = true;

    //qDebug() << "state?" << m_item->property("state").toString() << m_item->property("status").toString() << m_item->property("visible").toString();

    return state;
}
コード例 #21
0
void DisplayManager::SetViewport (WebRect *pViewRect)
{
	if (!mViewRect.Equals(pViewRect))
	{
		PresetWebRect oldRect(&mViewRect);

		mViewportChanged = WEBC_TRUE;
		mViewRect.Set(pViewRect);

		CorrectViewportPosition();

	  #ifdef WEBC_BUFFER_SCROLLING
		if (mManagerFlags & MANAGER_FLAG_BUFFER_SCROLL)
		{
			WebGraphics* gc = this->GetGraphics();
			if (gc)
			{
				if (mScrollBuffer == 0)
				{
					mScrollBuffer = gc->CreateBuffer(mViewRect.Width() * 2, mViewRect.Height() * 2);
				}
				else
				{
					if (oldRect.Width() != mViewRect.Width() ||
					    oldRect.Height() != mViewRect.Height())
					{
						mScrollBuffer = gc->ResizeBuffer(mScrollBuffer, mViewRect.Width() * 2, mViewRect.Height() * 2);
						AddDirtyRect(&mViewRect);
						SetManagerFlag(MANAGER_FLAG_DIRTY);
						return;
					}
				}

				if (mScrollBuffer)
				{
					// find non-overlapping regions
					if (mViewRect.Overlaps(&oldRect))
					{
						PresetWebRect viewRect(&mViewRect);
						WebRect extraRect;

						int count = viewRect.Split(&oldRect, &extraRect);
						if (count > 0)
						{
							if (count > 1)
							{
								if (count > 2)
								{
									if (!extraRect.Empty())
									{
										AddDirtyRect(&extraRect);
									}
								}
								if (!oldRect.Empty())
								{
									AddDirtyRect(&oldRect);
								}
							}
							if (!viewRect.Empty())
							{
								AddDirtyRect(&viewRect);
							}
						}
					}
					else
					{
						AddDirtyRect(&mViewRect);
					}

					SetManagerFlag(MANAGER_FLAG_DIRTY);
				}
			}

		}
	  #endif
	}
}
コード例 #22
0
ファイル: InterView.cpp プロジェクト: HaikuArchives/Butterfly
//--------------------------------------------------------------------
void InterView::Draw(BRect updateRect)
{
	BRect visi(Bounds());

	if (curPicture != NULL)
	{
		BRect picRect(curPicture->Bounds());
		BRect viewRect(visi);

		if (autoScale)
		{
			viewRect.right -= B_V_SCROLL_BAR_WIDTH;
			viewRect.bottom -= B_H_SCROLL_BAR_HEIGHT;
			float dx = picRect.right / viewRect.right;
			float dy = picRect.bottom / viewRect.bottom;
			if (dx > dy)
			{
				float old_height = viewRect.bottom;
				viewRect.bottom = (picRect.bottom / picRect.right) * viewRect.right;

				viewRect.OffsetBy(0., old_height/2 - viewRect.bottom/2);

				FillRect(BRect(0., 0., viewRect.right, viewRect.top-1));
				FillRect(BRect(0., viewRect.bottom, viewRect.right, visi.bottom));

				zoomFactor = 1./dx;
				SendZoomFactorModified();
			}
			else
			{
				float old_width = viewRect.right;
				viewRect.right = (picRect.right / picRect.bottom) * viewRect.bottom;

				viewRect.OffsetBy(old_width/2 - viewRect.right/2, 0.);

				FillRect(BRect(0., viewRect.top, viewRect.left-1, viewRect.bottom));
				FillRect(BRect(viewRect.right+1, viewRect.top, visi.right, viewRect.bottom));

				zoomFactor = 1./dy;
				SendZoomFactorModified();
			}

			DrawBitmap(curPicture, viewRect);
		}
		else
		{
			if (zoomFactor == 1.)
			{
				BPoint pos(viewRect.right/2 - picRect.right/2 - B_V_SCROLL_BAR_WIDTH/2,
						   viewRect.bottom/2 - picRect.bottom/2 - B_H_SCROLL_BAR_HEIGHT/2);
				if (pos.x < 0.)
					pos.x = -xOffs;
				else xOffs = 0.;
//					pos.x = 0;
				if (pos.y < 0.)
					pos.y = -yOffs;
				else yOffs = 0.;
//					pos.y = 0;
			
				DrawBitmap(curPicture, pos);

				FillRect(BRect(0., 0., visi.right, pos.y-1));
				FillRect(BRect(0., visi.bottom - pos.y - B_H_SCROLL_BAR_HEIGHT + 1, visi.right, visi.bottom));
				FillRect(BRect(0., pos.y, pos.x-1, visi.bottom-pos.y));
				FillRect(BRect(visi.right-pos.x-B_V_SCROLL_BAR_WIDTH+1, pos.y, visi.right, visi.bottom-pos.y));
			}
			else
			{
				picRect.right  *= zoomFactor;
				picRect.bottom *= zoomFactor;

				BRect srcR(curPicture->Bounds());

				BRect dstR(viewRect.right/2 - picRect.right/2 - B_V_SCROLL_BAR_WIDTH/2,
						   viewRect.bottom/2 - picRect.bottom/2 - B_H_SCROLL_BAR_HEIGHT/2,
						   viewRect.right/2 + picRect.right/2 + B_V_SCROLL_BAR_WIDTH/2,
						   viewRect.bottom/2 + picRect.bottom/2 + B_H_SCROLL_BAR_HEIGHT/2);

				if (dstR.left < 0.)	// pic wider than view
				{
					dstR.left  = 0.;
					dstR.right = visi.right - B_V_SCROLL_BAR_WIDTH;

					srcR.left  = picRect.left + xOffs/zoomFactor;
					srcR.right = picRect.left + xOffs/zoomFactor + (visi.right - B_V_SCROLL_BAR_WIDTH)/zoomFactor;
				}
				else xOffs = 0.;

				if (dstR.top < 0.) // pic higher than view
				{
					dstR.top = 0.;
					dstR.bottom = visi.bottom - B_H_SCROLL_BAR_HEIGHT;

					srcR.top = picRect.top + yOffs/zoomFactor;
					srcR.bottom = picRect.top + yOffs/zoomFactor + (visi.bottom - B_H_SCROLL_BAR_HEIGHT)/zoomFactor;
				}
				else yOffs = 0.;

				DrawBitmap(curPicture, srcR, dstR);

				FillRect(BRect(0., 0., visi.right, dstR.top-1));					// top
				FillRect(BRect(0., dstR.bottom+1, visi.right, visi.bottom));		// bottom
				FillRect(BRect(0., dstR.top, dstR.left-1, dstR.bottom));			// left
				FillRect(BRect(dstR.right+1, dstR.top, visi.right, dstR.bottom));	// right
			}

		}
	}
	else
		FillRect(Bounds());
}
コード例 #23
0
ファイル: InputPreview.cpp プロジェクト: flair2005/omnidome
 QPointF InputPreview::screenPos(QPointF const& _pos) const
 {
   QRectF&& _rect = viewRect();
   QPointF _p = QPointF(_pos.x() / width(),_pos.y() / height() );
   return QPointF(_p.x() * _rect.width(),-_p.y() * _rect.height());
 }
コード例 #24
0
ファイル: dimensions.cpp プロジェクト: frsfnrrg/qtgr
/*
 * This dialog is designed to unify the old word, view, and graph type dialogs
 * into a cohesive whole.
 *
 */
ViewDimensions::ViewDimensions(MainWindow *parent) :
    Dialog(parent, "Dimensions", true)
{
    WorldDimProp::add(this);

    viewXMin = getUnitDoubleSpinBox();
    connect(viewXMin, SIGNAL(valueChanged(double)), this, SLOT(readjXMax()));
    viewXMax = getUnitDoubleSpinBox();
    connect(viewXMax, SIGNAL(valueChanged(double)), this, SLOT(readjXMin()));
    viewYMin = getUnitDoubleSpinBox();
    connect(viewYMin, SIGNAL(valueChanged(double)), this, SLOT(readjYMax()));
    viewYMax = getUnitDoubleSpinBox();
    connect(viewYMax, SIGNAL(valueChanged(double)), this, SLOT(readjYMin()));

    worldXMin = new QLineEdit();
    connect(worldXMin, SIGNAL(textEdited(QString)), this, SLOT(updateScale()));
    worldXMax = new QLineEdit();
    connect(worldXMax, SIGNAL(textEdited(QString)), this, SLOT(updateScale()));
    worldYMin = new QLineEdit();
    connect(worldYMin, SIGNAL(textEdited(QString)), this, SLOT(updateScale()));
    worldYMax = new QLineEdit();
    connect(worldYMax, SIGNAL(textEdited(QString)), this, SLOT(updateScale()));

    worldType = new QComboBox();
    for (int k=0;k<OPTS_LEN;k++) {
        worldType->addItem(opts[k].iname);
    }
    connect(worldType, SIGNAL(currentIndexChanged(int)), this, SLOT(updateScale()));

    viewSelect = makeButton("Rect Select", SLOT(viewRect()));
    setButtonBold(viewSelect);

    rescaleAxes = makeButton("Autoscale", SLOT(rescaleTicks()));
    setButtonBold(rescaleAxes);

    autoHook(viewXMin);
    autoHook(viewXMax);
    autoHook(viewYMin);
    autoHook(viewYMax);
    autoHook(worldXMin);
    autoHook(worldXMax);
    autoHook(worldYMin);
    autoHook(worldYMax);
    autoHook(worldType);

    QHBoxLayout* header = new QHBoxLayout();
    header->addWidget(makeLabel("Graph Type"), 0);
    header->addWidget(worldType, 0);
    header->addStretch(1);

    QGridLayout* wrldl = new QGridLayout();
    addPair(wrldl, 0, makeLabel("X Min"), worldXMin);
    addPair(wrldl, 1, makeLabel("X Max"), worldXMax);
    addPair(wrldl, 2, makeLabel("Y Min"), worldYMin);
    addPair(wrldl, 3, makeLabel("Y Max"), worldYMax);
    wrldl->setRowMinimumHeight(4, 12);
    wrldl->addWidget(rescaleAxes, 5, 0, 1, 2, Qt::AlignCenter);
    wrldl->setColumnMinimumWidth(1, 100);
    wrldl->setColumnStretch(0, 0);
    wrldl->setColumnStretch(1, 2);

    QGroupBox* wrldb = makeGroupBox("World Coords");
    wrldb->setLayout(wrldl);

    QVBoxLayout* wrld = new QVBoxLayout();
    wrld->addWidget(wrldb, 0);
    wrld->addStretch(1);

    QGridLayout* viewl = new QGridLayout();
    addPair(viewl, 0, makeLabel("X Min"), viewXMin);
    addPair(viewl, 1, makeLabel("X Max"), viewXMax);
    addPair(viewl, 2, makeLabel("Y Min"), viewYMin);
    addPair(viewl, 3, makeLabel("Y Max"), viewYMax);
    viewl->setRowMinimumHeight(4, 12);
    viewl->addWidget(viewSelect, 5, 0, 1, 2, Qt::AlignCenter);
    viewl->setColumnMinimumWidth(1, 120);
    viewl->setColumnStretch(0, 0);
    viewl->setColumnStretch(1, 2);

    QGroupBox* viewb = makeGroupBox("View Coords");
    viewb->setLayout(viewl);

    QVBoxLayout* view = new QVBoxLayout();
    view->addWidget(viewb, 0);
    view->addStretch(1);

    QHBoxLayout* bot = new QHBoxLayout();
    bot->addLayout(wrld);
    bot->addLayout(view);

    QVBoxLayout* ovr = new QVBoxLayout();
    ovr->addLayout(header);
    ovr->addStrut(12);
    ovr->addLayout(bot);

    this->setDialogLayout(ovr);
}
コード例 #25
0
void PDocument::Print(void)
{
	TRACE();
	status_t	result	= B_OK;
	BPrintJob	printJob("doc_name");
	if (Lock())
	{
		if (printerSetting == NULL)
		{
			result = printJob.ConfigPage();
			if (result == B_OK)
			{
				// Get the user Settings
				SetPrintSettings(printJob.Settings());
				// Use the new settings for your internal use
				paperRect = new BRect(printJob.PaperRect());
				printableRect = new BRect(printJob.PrintableRect());
			}
		}
		// Setup the driver with user settings
		printJob.SetSettings(printerSetting);

		result = printJob.ConfigJob();
		if (result == B_OK)
		{
			// WARNING: here, setup CANNOT be NULL.
	         if (printerSetting == NULL)
	         {
	            // something's wrong, handle the error and bail out
	         }
//**dont know why this was here :-)      		 delete printerSetting;

			// Get the user Settings
			SetPrintSettings( printJob.Settings());
			paperRect 		= new BRect(printJob.PaperRect());
			printableRect	= new BRect(printJob.PrintableRect());

			// Now you have to calculate the number of pages
			// (note: page are zero-based)
			int32 firstPage = printJob.FirstPage();
			int32 lastPage = printJob.LastPage();

			// Verify the range is correct
			// 0 ... LONG_MAX -> Print all the document
			// n ... LONG_MAX -> Print from page n to the end
			// n ... m -> Print from page n to page m
			PEditor *activePEditor=editorManager->GetActivPEditor();
			if (activePEditor != NULL)
			{
				BView *editorView=activePEditor->GetView();
				if (editorView != NULL)
				{
					// calculate the Number of Pages
					bool locked	= editorView->LockLooper();
					int32 xPages,yPages;
					BRect editorRect = editorView->Bounds();
					xPages=editorRect.IntegerWidth()/printableRect->IntegerWidth();
					if (editorRect.IntegerWidth()%printableRect->IntegerWidth() > 0)
						xPages++;
					yPages=editorRect.IntegerHeight()/printableRect->IntegerHeight();
					if (editorRect.IntegerHeight()% printableRect->IntegerHeight() > 0)
						yPages++;
					int32 document_last_page= xPages*yPages;
					if (lastPage > document_last_page)
						lastPage = document_last_page;
					int32 nbPages = lastPage - firstPage + 1;
					if (nbPages <= 0)
						;
						//**return B_ERROR;
					// Now we can print the page
					printJob.BeginJob();
					// Print all pages
						bool can_continue = printJob.CanContinue();
					for (int i=firstPage-1; can_continue && i<lastPage ; i++)
					{
						float xStart	= (i%xPages)*printableRect->Width();
						float yStart	= (i/xPages)*printableRect->Height();
						BRect viewRect(xStart,yStart,xStart+printableRect->Width(),yStart+printableRect->Height());
//						printJob.DrawView(editorView, viewRect, BPoint(0,0));
						printJob.DrawView(editorView, viewRect, BPoint(printableRect->left,printableRect->top));
						printJob.SpoolPage();
						/*if (user_has_canceled)
						{
		       	        // tell the print_server to cancel the printjob
   	 	   	        	printJob.CancelJob();
							can_continue = false;
							break;
   	         		}*/
						can_continue = printJob.CanContinue();
					}
					if (can_continue)
						printJob.CommitJob();
					else
						result = B_ERROR;
					if (locked) editorView->UnlockLooper();
				}
			}
			else
			{
				//**error like no active Editor
			}
		}
		Unlock();
	}
}
コード例 #26
0
ファイル: plotdraw.cpp プロジェクト: mdavis45419/osiris
void wxPlotDrawerDataCurve::Draw(wxDC *dc, wxPlotData* curve, int curve_index)
{
    wxCHECK_RET(dc && m_owner && curve && curve->Ok(), wxT("invalid curve"));
    INITIALIZE_FAST_GRAPHICS

    wxRect dcRect(GetDCRect());

    wxRect2DDouble viewRect( GetPlotViewRect() ); //m_viewRect );
    wxRect2DDouble subViewRect( m_owner->GetPlotRectFromClientRect(dcRect) );
    wxRect2DDouble curveRect( curve->GetBoundingRect() );
    if (!wxPlotRect2DDoubleIntersects(curveRect, subViewRect)) return;

/*  // FIXME - drawing symbol bitmaps in MSW is very slow
    wxBitmap bitmap;
    if (curve == GetActiveCurve())
        bitmap = curve->GetSymbol(wxPLOTPEN_ACTIVE);
    else
        bitmap = curve->GetSymbol(wxPLOTPEN_NORMAL);

    if (!bitmap.Ok())
    {
        if (curve == GetActiveCurve())
            bitmap = wxPlotSymbolCurrent;
        else
            bitmap = wxPlotSymbolNormal;
    }

    int bitmapHalfWidth = bitmap.GetWidth()/2;
    int bitmapHalfHeight = bitmap.GetHeight()/2;
*/

    // find the starting and ending indexes into the data curve
    int n, n_start, n_end;
    bool x_ordered = curve->GetIsXOrdered();

    if (x_ordered)
    {
        n_start = curve->GetIndexFromX(subViewRect.GetLeft(), wxPlotData::index_floor);
        n_end   = curve->GetIndexFromX(subViewRect.GetRight(), wxPlotData::index_ceil);
        n_end++; // for statement comparison is <
    }
    else
    {
        n_start = 0;
        n_end   = curve->GetCount();
    }

    // set the pens to draw with
    wxPen currentPen = (curve_index == m_owner->GetActiveIndex()) ? curve->GetPen(wxPLOTPEN_ACTIVE).GetPen()
                                                                  : curve->GetPen(wxPLOTPEN_NORMAL).GetPen();
    wxPen selectedPen = curve->GetPen(wxPLOTPEN_SELECTED).GetPen();
    if (m_pen_scale != 1)
    {
        currentPen.SetWidth(int(currentPen.GetWidth() * m_pen_scale));
        selectedPen.SetWidth(int(selectedPen.GetWidth() * m_pen_scale));
    }

    dc->SetPen(currentPen);

    // handle the selected ranges and initialize the starting range
    const wxArrayRangeInt &ranges = m_owner->GetDataCurveSelection(curve_index)->GetRangeArray();
    int n_range = 0, range_count = ranges.GetCount();
    int min_sel = -1, max_sel = -1;
    for (n_range=0; n_range<range_count; n_range++)
    {
        const wxRangeInt& range = ranges[n_range];
        if ((range.m_max >= n_start) || (range.m_min >= n_start))
        {
            min_sel = range.m_min;
            max_sel = range.m_max;
            if (range.Contains(n_start))
                dc->SetPen( selectedPen );

            break;
        }
    }

    // data variables
    const double *x_data = &curve->GetXData()[n_start];
    const double *y_data = &curve->GetYData()[n_start];

    int i0, j0, i1, j1;        // curve coords in pixels
    double x0, y0, x1, y1;     // original curve coords
    double xx0, yy0, xx1, yy1; // clipped curve coords

    x0 = *x_data;
    y0 = *y_data;

    int clipped = ClippedNeither;

    bool draw_lines   = m_owner->GetDrawLines();
    bool draw_symbols = m_owner->GetDrawSymbols();
    bool draw_spline  = m_owner->GetDrawSpline();

    SplineDrawer sd;
    wxRangeDoubleSelection dblRangeSel;

    if (draw_spline)
    {
        wxRangeDouble viewRange(viewRect.m_x, viewRect.GetRight());
        wxRangeDouble dcRange(dcRect.x, dcRect.GetRight());

        for (int r = n_range; r < range_count; r++)
        {
            wxRangeDouble plotRange(curve->GetXValue(ranges[r].m_min),
                                    curve->GetXValue(ranges[r].m_max));

            if (viewRange.Intersects(plotRange))
            {
                double min_x = m_owner->GetClientCoordFromPlotX(plotRange.m_min);
                double max_x = m_owner->GetClientCoordFromPlotX(plotRange.m_max);
                dblRangeSel.SelectRange(wxRangeDouble(min_x, max_x));
            }
            else
                break;
        }

        // spline starts 2 points back for smoothness
        int s_start = n_start > 1 ? -2 : n_start > 0 ? -1 : 0;
        sd.Create(dc, currentPen, selectedPen,
                  wxRect2DDouble(dcRect.x, dcRect.y, dcRect.width, dcRect.height),
                  &dblRangeSel,
                  m_owner->GetClientCoordFromPlotX(x_data[s_start]),
                  m_owner->GetClientCoordFromPlotY(y_data[s_start]),
                  m_owner->GetClientCoordFromPlotX(x_data[s_start+1]),
                  m_owner->GetClientCoordFromPlotY(y_data[s_start+1]));
    }

    for (n = n_start; n < n_end; n++)
    {
        x1 = *x_data++;
        y1 = *y_data++;

        if (draw_spline)
            sd.DrawSpline(m_owner->GetClientCoordFromPlotX(x1),
                          m_owner->GetClientCoordFromPlotY(y1));

        xx0 = x0; yy0 = y0; xx1 = x1; yy1 = y1;
        clipped = ClipLineToRect(xx0, yy0, xx1, yy1, viewRect);
        if (clipped != ClippedOut)
        {
            i0 = m_owner->GetClientCoordFromPlotX(xx0);
            j0 = m_owner->GetClientCoordFromPlotY(yy0);
            i1 = m_owner->GetClientCoordFromPlotX(xx1);
            j1 = m_owner->GetClientCoordFromPlotY(yy1);

            if (draw_lines && ((i0 != i1) || (j0 != j1)))
            {
                wxPLOTCTRL_DRAW_LINE(dc, window, pen, i0, j0, i1, j1);
            }

            if (n == min_sel)
                dc->SetPen( selectedPen );

            if (draw_symbols && !((clipped & ClippedSecond) != 0) &&
                ((i0 != i1) || (j0 != j1) || (n == min_sel) || (n == n_start)))
            {
                //dc->DrawBitmap( bitmap, i1 - bitmapHalfWidth, j1 - bitmapHalfHeight, true );
                wxPLOTCTRL_DRAW_ELLIPSE(dc, window, pen, i1, j1, 2, 2);
            }
        }
        else if (n == min_sel)
        {
            dc->SetPen( selectedPen );
        }

        if (n == max_sel)
        {
            dc->SetPen( currentPen );
            if (n_range < range_count - 1)
            {
                n_range++;
                min_sel = ranges[n_range].m_min;
                max_sel = ranges[n_range].m_max;
            }
        }

        x0 = x1;
        y0 = y1;
    }

    if (draw_spline)
    {
        // want an extra point at the end to smooth it out
        if (n_end < (int)curve->GetCount() - 1)
            sd.DrawSpline(m_owner->GetClientCoordFromPlotX(*x_data),
                          m_owner->GetClientCoordFromPlotY(*y_data));

        sd.EndSpline();
    }

    dc->SetPen(wxNullPen);
}
コード例 #27
0
ファイル: kicongrid.cpp プロジェクト: kthxbyte/KDE1-Linaro
void KGridView::paintGrid()
{
  _grid->repaint(viewRect(), false);
}
コード例 #28
0
ファイル: grabUVMain.cpp プロジェクト: BigRoy/Maya-devkit
MStatus	grabUVContext::doPress ( MEvent & event, MHWRender::MUIDrawManager& drawMgr, const MHWRender::MFrameContext& context)
{
	if ( event.mouseButton() != MEvent::kLeftMouse || 
		!event.isModifierNone() )
		return MS::kFailure;

	fInStroke = true;

	MPxTexContext::doPress(event, drawMgr, context);

	short x, y;
	event.getPosition( x, y );
	fCurrentScreenPoint = MPoint( x, y );
	fLastScreenPoint = MPoint( x, y );
	fBrushCenterScreenPoint = MPoint( x, y );

	double xView, yView;
	portToView(x, y, xView, yView);	// pos at viewrect coordinate  

	double portW, portH;
	portSize(portW, portH);

	double left, right, bottom, top;
	viewRect(left, right, bottom, top);

	double sizeInView = portW < 1e-5 ? 0.0 : ( fBrushConfig.size() * (right - left) / portW );
	double sizeInViewSquare = sizeInView * sizeInView;

	if( fDragMode == kNormal )
	{
		fCollectedUVs.clear();

		MStatus *returnStatus = NULL;
		MSelectionMask mask = MSelectionMask::kSelectMeshUVs;
		const bool bPickSingle = false;
		MSelectionList	selectionList;

		bool bSelect = MPxTexContext::getMarqueeSelection( x - fBrushConfig.size(), y - fBrushConfig.size(), 
														   x + fBrushConfig.size(), y + fBrushConfig.size(), 
														   mask, bPickSingle, true, selectionList );

		if (bSelect)
		{
			MObject component;
			selectionList.getDagPath( 0, fDagPath, component );
			fDagPath.extendToShape();

			MFnMesh mesh(fDagPath);

			MString currentUVSetName;
			mesh.getCurrentUVSetName(currentUVSetName);

			MIntArray UVsToTest;
			if( component.apiType() == MFn::kMeshMapComponent )
			{
				MFnSingleIndexedComponent compFn( component );
				compFn.getElements( UVsToTest );

				for (unsigned int i = 0; i < UVsToTest.length(); ++i)
				{
					float u, v;
					MStatus bGetUV = mesh.getUV(UVsToTest[i], u, v, &currentUVSetName);
					if (bGetUV == MS::kSuccess)
					{
						float distSquare = ( u - xView ) * ( u - xView ) + ( v - yView ) * ( v - yView );
						if ( distSquare < sizeInViewSquare )
							fCollectedUVs.append(UVsToTest[i]);
					}
				}

			}

			// position in view(world) space. 
			fLastPoint = MPoint( xView, yView, 0.0 );
			fCurrentPoint = MPoint( xView, yView, 0.0 );
		}
	}

	return MS::kSuccess;
}
コード例 #29
0
void LegendItem::paint(QPainter *painter) {
  if (!isVisible()) {
    return;
  }

  RelationList legendItems;
  if (_auto) {
    legendItems = plot()->renderItem(PlotRenderItem::Cartesian)->relationList();
  } else {
    legendItems = _relations;
  }

  int count = legendItems.count();
  if (count <= 0) { // no legend or box if there are no legend items
    return;
  }


  QList<DrawnLegendItem> legendPixmaps;
  QSize legendSize(0, 0);

  QFont font(_font);
  font.setPointSizeF(view()->viewScaledFontSize(_fontScale));

  // generate string list of relation names
  QStringList names;
  bool allAuto = true;
  bool sameX = true;
  bool sameYUnits = true;

  LabelInfo label_info = legendItems.at(0)->xLabelInfo();
  QString yUnits =  legendItems.at(0)->yLabelInfo().units;

  for (int i = 0; i<count; i++) {
    RelationPtr relation = legendItems.at(i);
    if (relation->descriptiveNameIsManual()) {
      allAuto = false;
    }
    if (relation->xLabelInfo() != label_info) {
      sameX = false;
    }
    // sameYUnits is false if any non empty units are defined differently.
    if (yUnits.isEmpty()) {
      yUnits = relation->yLabelInfo().units;
    } else if (relation->yLabelInfo().units != yUnits) {
      if (!relation->yLabelInfo().units.isEmpty()) {
        sameYUnits = false;
      }
    }
  }

  if (!allAuto) {
    for (int i = 0; i<count; i++) {
      names.append(legendItems.at(i)->descriptiveName());
    }
  } else {
    for (int i = 0; i<count; i++) {
      RelationPtr relation = legendItems.at(i);
      QString label = relation->titleInfo().singleRenderItemLabel();
      if (label.isEmpty()) {
        label_info = relation->yLabelInfo();
        QString y_label = label_info.name;
        if (!sameYUnits) {
          if (!label_info.units.isEmpty()) {
            y_label = i18n("%1 \\[%2\\]").arg(y_label).arg(label_info.units);
          }
        }
        if (!y_label.isEmpty()) {
          LabelInfo xlabel_info = relation->xLabelInfo();
          if (!sameX) {
            label = i18n("%1 vs %2").arg(y_label).arg(xlabel_info.name);
          } else if (xlabel_info.quantity.isEmpty()) {
            label = y_label;
          } else if (xlabel_info.quantity != xlabel_info.name) {
            label = i18n("%1 vs %2").arg(y_label).arg(xlabel_info.name);
          } else {
            label = y_label;
          }
        } else {
          label = relation->descriptiveName();
        }
      }
      int i_dup = names.indexOf(label);
      if (i_dup<0) {
        names.append(label);
      } else {
        RelationPtr dup_relation = legendItems.at(i_dup);
        if (!dup_relation->yLabelInfo().file.isEmpty()) {
          names.replace(i_dup, label + " (" + dup_relation->yLabelInfo().file + ')');
        }
        if (!relation->yLabelInfo().file.isEmpty()) {
          names.append(label + " (" + relation->yLabelInfo().file + ')');
        }
      }
    }
  }

  for (int i = 0; i<count; i++) {
    RelationPtr relation = legendItems.at(i);
    DrawnLegendItem item;
    item.pixmap = QPixmap(LEGENDITEMMAXWIDTH, LEGENDITEMMAXHEIGHT);
    item.size = paintRelation(names.at(i), relation, &item.pixmap, font);

    if (_verticalDisplay) {
      legendSize.setWidth(qMax(legendSize.width(), item.size.width()));
      legendSize.setHeight(legendSize.height() + item.size.height());
    } else {
      legendSize.setHeight(qMax(legendSize.height(), item.size.height()));
      legendSize.setWidth(legendSize.width() + item.size.width());
    }

    legendPixmaps.append(item);
  }

  int x = rect().left();
  int y = rect().top();

  painter->save();

  if (!_title.isEmpty()) {
    // Paint the title
    Label::Parsed *parsed = Label::parse(_title);

    if (parsed) {
      painter->save();

      QPixmap pixmap(400, 100);
      pixmap.fill(Qt::transparent);
      QPainter pixmapPainter(&pixmap);

      Label::RenderContext rc(font, &pixmapPainter);
      QFontMetrics fm(font);
      rc.y = fm.ascent();
      Label::renderLabel(rc, parsed->chunk, false);

      int startPoint = qMax(0, (legendSize.width() / 2) - (rc.x / 2));
      int paddingValue = fm.height() / 4;
    
      setViewRect(viewRect().x(), viewRect().y(), qMax(rc.x, legendSize.width()), rc.y + legendSize.height() + paddingValue * 3);
      painter->drawRect(rect());

      painter->drawPixmap(QPoint(x + startPoint, y + paddingValue), pixmap, QRect(0, 0, rc.x, fm.height()));
      painter->restore();
      y += fm.height() + (paddingValue *2);
      delete parsed;
      parsed = 0;
    }
  } else {
    // No Title
    setViewRect(viewRect().x(), viewRect().y(), legendSize.width(), legendSize.height());
    painter->drawRect(rect());
  }


  foreach(const DrawnLegendItem &item, legendPixmaps) {
    painter->drawPixmap(QPoint(x, y), item.pixmap, QRect(0, 0, item.size.width(), item.size.height()));
    if (_verticalDisplay) {
      y += item.size.height();
    } else {
      x += item.size.width();
    }
  }
コード例 #30
0
AppWindow::AppWindow(BRect aRect) 
	: BWindow(aRect, APPLICATION, B_TITLED_WINDOW, 0) {
	setup = NULL;
	SetSizeLimits(645, 2048, 480, 2048);
	// add menu bar
	BRect rect = BRect(0, 0, aRect.Width(), aRect.Height());
	menubar = new BMenuBar(rect, "menu_bar");
	BMenu *menu; // , *popUp; 
	BMenuItem *item;

	menu = new BMenu("File");
	//menu->AddItem(new BMenuItem("New", new BMessage(MENU_APP_NEW), 'N'));
	//menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Open ...", new BMessage(MENU_APP_OPEN), 'O'));
	menu->AddItem(new BMenuItem("Save ...", new BMessage(MENU_APP_SAVE), 'S'));
	menu->AddItem(new BMenuItem("Save Graph ...", new BMessage(MENU_APP_SAVE_GRAPH), 'G'));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Page Setup ...", new BMessage(MENU_APP_PAGE_SETUP), 'P', B_SHIFT_KEY));
	menu->AddItem(new BMenuItem("Print ...", new BMessage(MENU_APP_PRINT), 'P'));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("About ...", new BMessage(B_ABOUT_REQUESTED)));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); 
	menubar->AddItem(menu);

	menu = new BMenu("Edit");
	menu->AddItem(new BMenuItem("Copy", new BMessage(MENU_APP_COPY), 'C'));
	menubar->AddItem(menu);


	menu = new BMenu("Graph");
	BMessage update(MSG_UPDATE);
	menu->AddItem(bg_color = CreateColorMenu("Background Color", 16, COLOR_TABLE_SIZE, color_table, &update));
	menu->AddItem(axes_color = CreateColorMenu("Axes Color", 16, COLOR_TABLE_SIZE, color_table, &update));
	rgb_color blue = {0, 0, 255, 255}, white = {255, 255, 255, 255};
	MarkColorMenuItem(bg_color, white);
	MarkColorMenuItem(axes_color, blue);
//	menu->AddItem(new BMenuItem("ratio", NULL));
	menubar->AddItem(menu);

	menu = new BMenu("Window");
	menu->AddItem(item = new BMenuItem("Defintions", new BMessage(MENU_APP_PROGRAM)));
	item->SetMarked(true);
	menubar->AddItem(menu);
	
	AddChild(menubar);

	// controls
	rect.Set(0, menubar->Bounds().Height()+1, aRect.Width(), 150);
	data = new DataView(rect);
	AddChild(data);
	SetDefaultButton((BButton*)data->FindView("Update"));	

	BRect textRect(0, 0, aRect.Width(), 15);
	BRect r(textRect);
	r.OffsetTo(0, aRect.Height()-textRect.Height());
	statusLine = new BTextView(r, "statusLine", textRect, 
							   B_FOLLOW_RIGHT | B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
	AddChild(statusLine);

	// add graph view
	BRect viewRect(0, data->ConvertToParent(data->Bounds()).bottom+1, aRect.Width(), 
		statusLine->ConvertToParent(statusLine->Bounds()).top-1);
	/*BRect viewRect(scrollRect.left, scrollRect.top, 
					scrollRect.right-B_V_SCROLL_BAR_WIDTH-1,
					scrollRect.bottom-B_H_SCROLL_BAR_HEIGHT-1);*/
	view = new View(viewRect);
	AddChild(view);
	/*scrollView = new BScrollView("", view, B_FOLLOW_ALL_SIDES, 0, true, true);
	AddChild(scrollView);*/
	
#ifdef WATCH_CLIPBOARD
	be_clipboard->StartWatching(this);
#endif

	// Shortcuts
	AddShortcut('f', 0, new BMessage(MSG_ADD));
	AddShortcut('d', 0, new BMessage(MSG_REMOVE));
	AddShortcut('r', 0, new BMessage(MSG_REPLACE));
	
	// Open and Save Panel
	savePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this));
	openPanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this));

	app_info ai;
	if (B_OK == be_app->GetAppInfo(&ai)) {
		BDirectory dir; BEntry entry(&ai.ref); 
		entry.GetParent(&dir);
		savePanel->SetPanelDirectory(&dir);
		openPanel->SetPanelDirectory(&dir);
	}
	BMessage msg(MSG_OPEN);
	openPanel->SetMessage(&msg);

	// Definitions Window
	program = new ProgramWindow(this, BRect(40, 40, 400, 400));
	program->Show();
	
	// make window visible
	Show();
	PostMessage(&update);
}