Example #1
0
//------------------------------------------------------------------------
void CDrawContext::drawString (IPlatformString* string, const CRect& _rect, const CHoriTxtAlign hAlign, bool antialias)
{
	if (!string || currentState.font == 0)
		return;
	IFontPainter* painter = currentState.font->getFontPainter ();
	if (painter == 0)
		return;
	
	CRect rect (_rect);
	
	double capHeight = -1;
	IPlatformFont* platformFont = currentState.font->getPlatformFont ();
	if (platformFont)
		capHeight = platformFont->getCapHeight ();
	
	if (capHeight > 0.)
		rect.bottom -= (rect.getHeight () / 2. - capHeight / 2.);
	else
		rect.bottom -= (rect.getHeight () / 2. - currentState.font->getSize () / 2.) + 1.;
	if (hAlign != kLeftText)
	{
		CCoord stringWidth = painter->getStringWidth (this, string, antialias);
		if (hAlign == kRightText)
			rect.left = rect.right - stringWidth;
		else
			rect.left = rect.left + (rect.getWidth () / 2.) - (stringWidth / 2.);
	}

	painter->drawString (this, string, CPoint (rect.left, rect.bottom), antialias);
}
Example #2
0
//-----------------------------------------------------------------------------
void D2DDrawContext::drawEllipse (const CRect &_rect, const CDrawStyle drawStyle)
{
	if (renderTarget == 0)
		return;
	D2DApplyClip ac (this);
	if (ac.isEmpty ())
		return;
	CRect rect (_rect);
	if (currentState.drawMode.integralMode ())
		pixelAllign (rect);
	CPoint center (rect.getTopLeft ());
	center.offset (rect.getWidth () / 2., rect.getHeight () / 2.);
	D2D1_ELLIPSE ellipse;
	ellipse.point = makeD2DPoint (center);
	ellipse.radiusX = (FLOAT)(rect.getWidth () / 2.);
	ellipse.radiusY = (FLOAT)(rect.getHeight () / 2.);
	if (drawStyle == kDrawFilled || drawStyle == kDrawFilledAndStroked)
	{
		renderTarget->FillEllipse (ellipse, fillBrush);
	}
	if (drawStyle == kDrawStroked || drawStyle == kDrawFilledAndStroked)
	{
		renderTarget->DrawEllipse (ellipse, strokeBrush, (FLOAT)currentState.frameWidth, strokeStyle);
	}
}
Example #3
0
// -----------------------------------------------------------------------------
bool AEffGUIEditor::beforeSizeChange (const CRect& newSize, const CRect& oldSize)
{
	AudioEffectX* eX = (AudioEffectX*)effect;
	if (eX && eX->canHostDo ((char*)"sizeWindow"))
	{
		if (eX->sizeWindow ((VstInt32)newSize.getWidth (), (VstInt32)newSize.getHeight ()))
		{
			return true;
		}
		return false;
	}
#if WINDOWS
	// old hack to size the window of the host. Very ugly stuff ...

	if (getFrame () == 0)
		return true;

	RECT  rctTempWnd, rctParentWnd;
	HWND  hTempWnd;
	long   iFrame = (2 * GetSystemMetrics (SM_CYFIXEDFRAME));
	
	long diffWidth  = 0;
	long diffHeight = 0;
	
	hTempWnd = (HWND)getFrame ()->getPlatformFrame ()->getPlatformRepresentation ();
	
	while ((diffWidth != iFrame) && (hTempWnd != NULL)) // look for FrameWindow
	{
		HWND hTempParentWnd = GetParent (hTempWnd);
		TCHAR buffer[1024];
		GetClassName (hTempParentWnd, buffer, 1024);
		if (!hTempParentWnd || !VSTGUI_STRCMP (buffer, TEXT("MDIClient")))
			break;
		GetWindowRect (hTempWnd, &rctTempWnd);
		GetWindowRect (hTempParentWnd, &rctParentWnd);
		
		SetWindowPos (hTempWnd, HWND_TOP, 0, 0, (int)newSize.getWidth () + diffWidth, (int)newSize.getHeight () + diffHeight, SWP_NOMOVE);
		
		diffWidth  += (rctParentWnd.right - rctParentWnd.left) - (rctTempWnd.right - rctTempWnd.left);
		diffHeight += (rctParentWnd.bottom - rctParentWnd.top) - (rctTempWnd.bottom - rctTempWnd.top);
		
		if ((diffWidth > 80) || (diffHeight > 80)) // parent belongs to host
			return true;

		if (diffWidth < 0)
			diffWidth = 0;
        if (diffHeight < 0)
			diffHeight = 0;
		
		hTempWnd = hTempParentWnd;
	}
	
	if (hTempWnd)
		SetWindowPos (hTempWnd, HWND_TOP, 0, 0, (int)newSize.getWidth () + diffWidth, (int)newSize.getHeight () + diffHeight, SWP_NOMOVE);
#endif
	return true;
}
Example #4
0
//-----------------------------------------------------------------------------
void CScrollView::makeRectVisible (const CRect& rect)
{
	CRect r (rect);
	const CPoint& scrollOffset = sc->getScrollOffset ();
	CPoint newOffset (scrollOffset);
	CRect vs;
	sc->getViewSize (vs);
	if (!(style & kDontDrawFrame))
	{
		vs.left--; //vs.top--;
		vs.right++; //vs.bottom++;
	}
	CRect cs (containerSize);
	cs.offset (-cs.left, -cs.top);
	cs.setWidth (vs.getWidth ());
	cs.setHeight (vs.getHeight ());
	if (r.top >= cs.top && r.bottom <= cs.bottom && r.left >= cs.left && r.right <= cs.right)
		return;
	if (r.top < cs.top)
	{
		newOffset.y -= (cs.top - r.top);
	}
	else if (r.bottom > cs.bottom)
	{
		newOffset.y += (r.bottom - cs.bottom);
	}
	if (r.left < cs.left)
	{
		newOffset.x -= (cs.left + r.left);
	}
	else if (r.right > cs.right && r.left != cs.left)
	{
		newOffset.x += (cs.right - r.right);
	}
	if (vsb && newOffset.y != scrollOffset.y)
	{
		if (containerSize.getHeight () == vs.getHeight ())
			vsb->setValue (0.f);
		else
			vsb->setValue ((float)(newOffset.y - vs.top) / (float)(containerSize.getHeight () - vs.getHeight ()));
		vsb->bounceValue ();
		vsb->onVisualChange ();
		vsb->invalid ();
		valueChanged (vsb);
	}
	if (hsb && newOffset.x != scrollOffset.x)
	{
		if (containerSize.getWidth () == vs.getWidth ())
			hsb->setValue (0.f);
		else
			hsb->setValue (-(float)(newOffset.x - vs.left) / (float)(containerSize.getWidth () - vs.getWidth ()));
		hsb->bounceValue ();
		hsb->onVisualChange ();
		hsb->invalid ();
		valueChanged (hsb);
	}
}
Example #5
0
//--------------------------------------------------------------------------------
void CRowColumnView::layoutViewsEqualSize ()
{
	CPoint maxSize;
	getMaxChildViewSize (maxSize);
	if (style == kRowStyle)
		maxSize.x = getViewSize ().getWidth () - (margin.right + margin.left);
	else
		maxSize.y = getViewSize ().getHeight () - (margin.top + margin.bottom);
	CPoint location = margin.getTopLeft ();
	ViewIterator it (this);
	while (*it)
	{
		CView* view = *it;
		CRect viewSize = view->getViewSize ();
		viewSize.originize ();
		viewSize.offset (location.x, location.y);
		switch (layoutStyle)
		{
			case kStretchEqualy:
			{
				viewSize.setWidth (maxSize.x);
				viewSize.setHeight (maxSize.y);
				break;
			}
			case kCenterEqualy:
			{
				CCoord diffX = (maxSize.x - viewSize.getWidth ()) / 2.;
				CCoord diffY = (maxSize.y - viewSize.getHeight ()) / 2.;
				viewSize.offset (diffX, diffY);
				break;
			}
			case kRightBottomEqualy:
			{
				CCoord diffX = maxSize.x - viewSize.getWidth ();
				CCoord diffY = maxSize.y - viewSize.getHeight ();
				viewSize.offset (diffX, diffY);
				break;
			}
			default:
				break;
		}
		resizeSubView (view, viewSize);
		if (style == kRowStyle)
		{
			location.y += spacing;
			location.y += viewSize.getHeight ();
		}
		else
		{
			location.x += spacing;
			location.x += viewSize.getWidth ();
		}
		it++;
	}
}
Example #6
0
//--------------------------------------------------------------------------------
void CRowColumnView::getMaxChildViewSize (CPoint& maxSize)
{
	ViewIterator it (this);
	while (*it)
	{
		CView* view = *it;
		CRect viewSize = view->getViewSize ();
		if (viewSize.getWidth () > maxSize.x)
			maxSize.x = viewSize.getWidth ();
		if (viewSize.getHeight () > maxSize.y)
			maxSize.y = viewSize.getHeight ();
		it++;
	}
}
Example #7
0
//-----------------------------------------------------------------------------
void CScrollView::setContainerSize (const CRect& cs, bool keepVisibleArea)
{
	CRect oldSize (containerSize);
	containerSize = cs;
	if (sc)
	{
		sc->setContainerSize (cs);
	}
	if (style & kAutoHideScrollbars)
		recalculateSubViews ();
	if (vsb)
	{
		CRect oldScrollSize = vsb->getScrollSize (oldScrollSize);
		float oldValue = vsb->getValue ();
		vsb->setScrollSize (cs);
		if (cs.getHeight () <= getViewSize ().getHeight ())
			vsb->setValue (0);
		else if (sc && keepVisibleArea && oldScrollSize.getHeight () != cs.getHeight ())
		{
			CRect vSize = sc->getViewSize (vSize);
			float newValue = (float)(oldValue * ((float)(oldScrollSize.getHeight () - vSize.getHeight ()) / ((float)cs.getHeight () - vSize.getHeight ())));
			if (newValue > 1.f)
				newValue = 1.f;
			else if (newValue < 0.f)
				newValue = 0.f;
			vsb->setValue (newValue);
		}
		valueChanged (vsb);
	}
	if (hsb)
	{
		CRect oldScrollSize = hsb->getScrollSize (oldScrollSize);
		float oldValue = hsb->getValue ();
		hsb->setScrollSize (cs);
		if (cs.getWidth () <= getViewSize ().getWidth ())
			hsb->setValue (0);
		else if (sc && keepVisibleArea && oldScrollSize.getWidth () != cs.getWidth ())
		{
			CRect vSize = sc->getViewSize (vSize);
			float newValue = (float)(oldValue * ((float)(oldScrollSize.getWidth () - vSize.getWidth ()) / ((float)cs.getWidth () - vSize.getWidth ())));
			if (newValue > 1.f)
				newValue = 1.f;
			else if (newValue < 0.f)
				newValue = 0.f;
			hsb->setValue (newValue);
		}
		valueChanged (hsb);
	}
}
Example #8
0
//------------------------------------------------------------------------
CMovieBitmap::CMovieBitmap (const CRect& size, CControlListener* listener, int32_t tag, CBitmap* background, const CPoint &offset)
    : CControl (size, listener, tag, background)
    , offset (offset)
{
    setHeightOfOneImage (size.getHeight ());
    setNumSubPixmaps (background ? (int32_t)(background->getHeight () / heightOfOneImage) : 0);
}
Example #9
0
	void valueChanged (CControl* pControl)
	{
		if (pControl->getValue ())
		{
			switch (pControl->getTag ())
			{
				case 0:
				{
					CView* view = desc->createView ("ModalView", this);
					if (view)
					{
						CFrame* frame = pControl->getFrame ();
						CPoint center = frame->getViewSize ().getCenter ();
						CRect viewSize = view->getViewSize ();
						viewSize.offset (center.x - viewSize.getWidth () / 2, center.y - viewSize.getHeight () / 2);
						view->setViewSize (viewSize);
						view->setMouseableArea (viewSize);
						frame->setModalView (view);
						view->setAlphaValue (0.f);
						view->addAnimation ("AlphaAnimation", new Animation::AlphaValueAnimation (1.f), new Animation::PowerTimingFunction (240, 2));
						pControl->setValue (0);
						view->forget ();
					}
					break;
				}
				case 1:
				{
					CView* modalView = pControl->getFrame ()->getModalView ();
					modalView->addAnimation ("AlphaAnimation", new RemoveModalViewAnimation (0.f), new Animation::PowerTimingFunction (240, 0.5));
					pControl->setMouseEnabled (false);
					break;
				}
			}
		}
	}
Example #10
0
//------------------------------------------------------------------------
bool CCheckBox::sizeToFit ()
{
	if (title == 0)
		return false;
	IFontPainter* painter = font ? font->getFontPainter () : 0;
	if (painter)
	{
		CRect fitSize (getViewSize ());
		if (getDrawBackground ())
		{
			fitSize.setWidth (getDrawBackground ()->getWidth ());
			fitSize.setHeight (getDrawBackground ()->getHeight () / 6);
		}
		else
		{
			fitSize.setWidth (fitSize.getHeight ());
		}
		fitSize.right += kCheckBoxTitleMargin;
		fitSize.right += painter->getStringWidth (0, title, true);
		setViewSize (fitSize);
		setMouseableArea (fitSize);
		return true;
	}
	return false;
}
Example #11
0
//----------------------------------------------------------------------------------------------------
void UISearchTextField::drawClearMark (CDrawContext* context) const
{
	if (getText ().empty ())
		return;

	SharedPointer<CGraphicsPath> path = owned (context->createGraphicsPath ());
	if (path == 0)
		return;

	CRect r = getClearMarkRect ();
	CColor color (fontColor);
	color.alpha /= 2;
	context->setFillColor (color);
	context->setDrawMode (kAntiAliasing);
	context->drawEllipse (r, kDrawFilled);
	double h,s,v;
	color.toHSV (h, s, v);
	v = 1. - v;
	color.fromHSV (h, s, v);
	context->setFrameColor (color);
	context->setLineWidth (2.);
	r.inset (r.getWidth () / (M_PI * 2.) + 1, r.getHeight () / (M_PI * 2.) + 1);
	path->beginSubpath (r.getTopLeft ());
	path->addLine (r.getBottomRight ());
	path->beginSubpath (r.getBottomLeft ());
	path->addLine (r.getTopRight ());
	context->setDrawMode (kAntiAliasing|kNonIntegralMode);
	context->drawGraphicsPath (path, CDrawContext::kPathStroked);
}
Example #12
0
//-----------------------------------------------------------------------------
void CScrollView::valueChanged (CControl *pControl)
{
	if (sc)
	{
		float value = pControl->getValue ();
		int32_t tag = pControl->getTag ();
		CPoint offset;
		CRect vsize = sc->getViewSize (vsize);
		CRect csize = sc->getContainerSize ();
		sc->getScrollOffset (offset);

		switch (tag)
		{
			case kHSBTag:
			{
				if (csize.getWidth () > vsize.getWidth ())
				{
					offset.x = (int32_t) (csize.left - (csize.getWidth () - vsize.getWidth ()) * value);
					sc->setScrollOffset (offset, false);
				}
				else if (offset.x < 0)
				{
					offset.x = 0;
					sc->setScrollOffset (offset, false);
				}
				break;
			}
			case kVSBTag:
			{
				if (csize.getHeight () > vsize.getHeight ())
				{
					offset.y = (int32_t) (csize.top + (csize.getHeight () - vsize.getHeight ()) * value);
					sc->setScrollOffset (offset, false);
				}
				else if (offset.y > 0)
				{
					offset.y = 0;
					sc->setScrollOffset (offset, false);
				}
				break;
			}
		}
	}
}
Example #13
0
//-----------------------------------------------------------------------------
void CGDrawContext::drawCGImageRef (CGContextRef context, CGImageRef image, CGLayerRef layer, double bitmapScaleFactor, const CRect& inRect, const CPoint& inOffset, float alpha, CBitmap* bitmap)
{
    CRect rect (inRect);
    CPoint offset (inOffset);

    CGContextSetAlpha (context, (CGFloat)alpha*currentState.globalAlpha);

    CGRect dest;
    dest.origin.x = static_cast<CGFloat> (rect.left - offset.x);
    dest.origin.y = static_cast<CGFloat> (-(rect.top) - (bitmap->getHeight () - offset.y));
    dest.size.width = static_cast<CGFloat> (bitmap->getWidth ());
    dest.size.height = static_cast<CGFloat> (bitmap->getHeight ());

    CGRect clipRect;
    clipRect.origin.x = static_cast<CGFloat> (rect.left);
    clipRect.origin.y = static_cast<CGFloat> (-(rect.top) - rect.getHeight ());
    clipRect.size.width = static_cast<CGFloat> (rect.getWidth ());
    clipRect.size.height = static_cast<CGFloat> (rect.getHeight ());


    if (bitmapScaleFactor != 1.)
    {
        CGContextConcatCTM (context, CGAffineTransformMakeScale (static_cast<CGFloat> (1./bitmapScaleFactor), static_cast<CGFloat> (1./bitmapScaleFactor)));
        CGAffineTransform transform = CGAffineTransformMakeScale (static_cast<CGFloat> (bitmapScaleFactor), static_cast<CGFloat> (bitmapScaleFactor));
        clipRect.origin = CGPointApplyAffineTransform (clipRect.origin, transform);
        clipRect.size = CGSizeApplyAffineTransform (clipRect.size, transform);
        dest.origin = CGPointApplyAffineTransform (dest.origin, transform);
        dest.size = CGSizeApplyAffineTransform (dest.size, transform);
    }
    dest = pixelAlligned (dest);
    clipRect = pixelAlligned (clipRect);

    CGContextClipToRect (context, clipRect);

    if (layer)
    {
        CGContextDrawLayerInRect (context, dest, layer);
    }
    else
    {
        CGContextDrawImage (context, dest, image);
    }
}
Example #14
0
//-----------------------------------------------------------------------------
void CShadowViewContainer::setViewSize (const CRect& rect, bool invalid)
{
	if (getViewSize () != rect)
	{
		bool diffSize = (getWidth () != rect.getWidth () || getHeight () != rect.getHeight ());
		CViewContainer::setViewSize (rect, invalid);
		if (diffSize)
			invalidateShadow ();
	}
}
Example #15
0
//------------------------------------------------------------------------
void CSlider::setViewSize (const CRect& rect, bool invalid)
{
	CControl::setViewSize (rect, invalid);
	if (style & kHorizontal)
	{
		minPos = rect.left - getViewSize ().left;
		rangeHandle = rect.getWidth () - (widthOfSlider + offsetHandle.x * 2);
	}
	else
	{
		minPos = rect.top - getViewSize ().top;
		rangeHandle = rect.getHeight () - (heightOfSlider + offsetHandle.y * 2);
	}
	
	widthControl  = rect.getWidth ();
	heightControl = rect.getHeight ();

	setOffsetHandle (offsetHandle);
}
Example #16
0
//--------------------------------------------------------------------------------
bool CRowColumnView::sizeToFit ()
{
	if (children.size () > 0)
	{
		CRect viewSize = getViewSize ();
		CPoint maxSize;
		ViewIterator it (this);
		if (style == kRowStyle)
		{
			while (*it)
			{
				CRect size = (*it)->getViewSize ();
				if (size.getWidth () > maxSize.x)
					maxSize.x = size.getWidth ();
				maxSize.y += size.getHeight () + spacing;
				it++;
			}
		}
		else
		{
			while (*it)
			{
				CRect size = (*it)->getViewSize ();
				maxSize.x += size.getWidth () + spacing;
				if (size.bottom > maxSize.y)
					maxSize.y = size.getHeight ();
				it++;
			}
		}
		viewSize.setWidth (maxSize.x + margin.left + margin.right);
		viewSize.setHeight (maxSize.y + margin.top + margin.bottom);
		if (viewSize != getViewSize ())
		{
			invalid ();
			CViewContainer::setViewSize (viewSize);
			CViewContainer::setMouseableArea (viewSize);
			invalid ();
		}
		return true;
	}
	return false;
}
Example #17
0
cSplashScreenVersion::cSplashScreenVersion(const CRect &size, CControlListener *listener, long tag,
                                           CBitmap *splash, CRect &wsize) :
CControl(wsize, listener, tag) {
  m_visible = false;
  
  CRect tsize = wsize;
  char vstring[MAX_VSTRING_SIZE];
  tsize.top = wsize.bottom - DEF_VERSION_HEIGHT;
  m_version = new CTextLabel(tsize);
  m_version->setFontColor(kWhiteCColor);
  m_version->setFrameColor(kBlackCColor);
  m_version->setBackColor(kBlackCColor);
  
  // This class expects the following preprocessor definitions to be defined in defaults.h
  // DEF_PRODUCT - product name
  // MAJ_VERSION - major version
  // MIN_VERSION - minor version
  // REL_BRANCH - can be either 'r' (release), 'b' (beta), or 'a' (alpha)
  switch(REL_BRANCH) {
    case 'a':
      snprintf(vstring, MAX_VSTRING_SIZE, "%s-v%d.0a%d - alpha", DEF_PRODUCT, MAJ_VERSION, MIN_VERSION);
      break;
    case 'b':
      snprintf(vstring, MAX_VSTRING_SIZE, "%s-v%d.0b%d - beta", DEF_PRODUCT, MAJ_VERSION, MIN_VERSION);
      break;
    case 'r':
    default:
      snprintf(vstring, MAX_VSTRING_SIZE, "%s-v%d.%d - Copyright 2006 Teragon Audio", DEF_PRODUCT, MAJ_VERSION, MIN_VERSION);
      break;
  }
  m_version->setText(vstring);
  
  m_click_area = size;
  
  m_splash = splash;
  if(m_splash) {
    m_splash_area((wsize.getWidth() / 2) - (m_splash->getWidth() / 2),
                  (wsize.getHeight() / 2) - (m_splash->getHeight() / 2),
                  (wsize.getWidth() / 2) + (m_splash->getWidth() / 2),
                  (wsize.getHeight() / 2) + (m_splash->getHeight() / 2));
  }
}
Example #18
0
//------------------------------------------------------------------------
bool CCheckBox::getFocusPath (CGraphicsPath& outPath)
{
	if (wantsFocus ())
	{
		CCoord focusWidth = getFrame ()->getFocusWidth ();
		CRect checkBoxSize (getViewSize ());
		if (getDrawBackground ())
		{
			checkBoxSize.setWidth (getDrawBackground ()->getWidth ());
			checkBoxSize.setHeight (getDrawBackground ()->getHeight () / 6);
		}
		else
		{
			checkBoxSize.setHeight (getFontCapHeight (font) + 2);
			checkBoxSize.setWidth (checkBoxSize.getHeight ());
			checkBoxSize.offset (1, ceil ((getViewSize ().getHeight () - checkBoxSize.getHeight ()) / 2));
		}
		outPath.addRect (checkBoxSize);
		checkBoxSize.inset (-focusWidth, -focusWidth);
		outPath.addRect (checkBoxSize);
	}
	return true;
}
Example #19
0
//-----------------------------------------------------------------------------
void CDrawContext::fillRectWithBitmap (CBitmap* bitmap, const CRect& srcRect, const CRect& dstRect, float alpha)
{
	if (srcRect.isEmpty () || dstRect.isEmpty ())
		return;

	CRect bitmapPartRect;
	CCoord left;
	CCoord top;
	CPoint sourceOffset (srcRect.left, srcRect.top);

	CRect currentClip = getClipRect (currentClip);

	for (top = dstRect.top; top < dstRect.bottom; top += srcRect.getHeight ())
	{
		bitmapPartRect.top = top;
		bitmapPartRect.bottom = top + srcRect.getHeight ();
		if (bitmapPartRect.bottom > dstRect.bottom)
			bitmapPartRect.bottom = dstRect.bottom;
		// The following should never be true, I guess
		if (bitmapPartRect.getHeight () > srcRect.getHeight ())
			bitmapPartRect.setHeight (srcRect.getHeight ());
		
		for (left = dstRect.left; left < dstRect.right; left += srcRect.getWidth ())
		{
			bitmapPartRect.left = left;
			bitmapPartRect.right = left + srcRect.getWidth ();
			if (bitmapPartRect.right > dstRect.right)
				bitmapPartRect.right = dstRect.right;
			// The following should never be true, I guess
			if (bitmapPartRect.getWidth () > srcRect.getWidth ())
				bitmapPartRect.setWidth (srcRect.getWidth ());
			
			if (currentClip.rectOverlap (bitmapPartRect))
				drawBitmap (bitmap, bitmapPartRect, sourceOffset, alpha);
		}
	}
}
Example #20
0
//-----------------------------------------------------------------------------
void D2DDrawContext::drawEllipse (const CRect &_rect, const CDrawStyle drawStyle)
{
    if (renderTarget)
    {
        CRect rect (_rect);
        rect.offset (currentState.offset.x, currentState.offset.y);
        rect.normalize ();
        D2DApplyClip clip (this);
        CPoint center (rect.getTopLeft ());
        center.offset (rect.getWidth () / 2., rect.getHeight () / 2.);
        D2D1_ELLIPSE ellipse;
        ellipse.point = makeD2DPoint (center);
        ellipse.radiusX = (FLOAT)(rect.getWidth () / 2.);
        ellipse.radiusY = (FLOAT)(rect.getHeight () / 2.);
        if (drawStyle == kDrawFilled || drawStyle == kDrawFilledAndStroked)
        {
            renderTarget->FillEllipse (ellipse, fillBrush);
        }
        if (drawStyle == kDrawStroked || drawStyle == kDrawFilledAndStroked)
        {
            renderTarget->DrawEllipse (ellipse, strokeBrush, (FLOAT)currentState.frameWidth, strokeStyle);
        }
    }
}
Example #21
0
//-----------------------------------------------------------------------------
bool CScrollContainer::isDirty () const
{
	if (CView::isDirty ())
		return true;

	FOREACHSUBVIEW
		if (pV->isDirty () && pV->isVisible ())
		{
			CRect r = pV->getVisibleViewSize ();
			if (r.getWidth () > 0 && r.getHeight () > 0)
				return true;
			else
				pV->setDirty (false);
		}
	ENDFOREACHSUBVIEW
	return false;
}
Example #22
0
//-----------------------------------------------------------------------------
bool Win32Frame::setSize (const CRect& newSize)
{
	if (deviceContext)
	{
		deviceContext->forget ();
		deviceContext = 0;
	}
	if (backBuffer)
	{
		backBuffer->forget ();
		backBuffer = createOffscreenContext (newSize.getWidth (), newSize.getHeight ());
	}
	// TODO for VST2: we only set the size of the window we own. In VST2 this was not the case, we also resized the parent window. This must be done upstream now.
	SetWindowPos (windowHandle, HWND_TOP, (int)newSize.left, (int)newSize.top, (int)newSize.getWidth (), (int)newSize.getHeight (), SWP_NOMOVE|SWP_NOCOPYBITS|SWP_NOREDRAW|SWP_DEFERERASE);
	invalidRect (newSize);
	return true;
}
Example #23
0
//-----------------------------------------------------------------------------
bool CScrollContainer::attached (CView* parent)
{
	bool result = CViewContainer::attached (parent);
	if (getNbViews () == 1)
	{
		CView* view = getView (0);
		if (view)
		{
			CRect r (view->getViewSize ());
			CRect newContainerSize (containerSize);
			newContainerSize.setWidth (r.getWidth ());
			newContainerSize.setHeight (r.getHeight ());
			if (newContainerSize != containerSize)
			{
				CScrollView* scrollView = (CScrollView*)getParentView ();
				scrollView->setContainerSize (newContainerSize);
			}
		}
	}
	return result;
}
Example #24
0
void CUIDisplayWorld::OnFrameMove(double fTime, float fElapsedTime)
{
	if(IsVisible() == true)
	{
		CWorld::getInstance().frameMoveRole(Matrix::UNIT, fTime, fElapsedTime);
		// ----
		CWorld::getInstance().frameMove(Matrix::UNIT, fTime, fElapsedTime);
		// ----
		CRect<int> rcViewport	= getViewport();
		// ----
		CGameCamera::getInstance().setProjParams(PI / 3, rcViewport.getWidth(), rcViewport.getHeight(), 0.1f, CWorld::getInstance().getFog().fEnd);
		// ----
// 		Vec3D vPos = CPlayerMe::getInstance().getPos();
// 		vPos.y+=CPlayerMe::getInstance().getRoleHeight()*0.6f;
// 		CGameCamera::getInstance().setTargetPos(vPos);
		// ----
		CGameCamera::getInstance().FrameMove(fElapsedTime);
		// ----
		CUIDisplay::OnFrameMove(fTime, fElapsedTime);
	}
}
Example #25
0
//-----------------------------------------------------------------------------
CMessageResult CScrollContainer::notify (CBaseObject* sender, IdStringPtr message)
{
	if (message == kMsgViewSizeChanged && !inScrolling)
	{
		uint32_t numSubViews = getNbViews ();
		CView* view = static_cast<CView*> (sender);
		if (numSubViews == 1 && view && isChild (view))
		{
			CRect r (view->getViewSize ());
			CRect newContainerSize (containerSize);
			newContainerSize.setWidth (r.getWidth ());
			newContainerSize.setHeight (r.getHeight ());
			if (newContainerSize != containerSize)
			{
				CScrollView* scrollView = (CScrollView*)getParentView ();
				scrollView->setContainerSize (newContainerSize);
			}
		}
	}
	return getParentView () ? getParentView ()->notify (sender, message) : kMessageUnknown;
}
Example #26
0
//-----------------------------------------------------------------------------
void CFrame::drawRect (CDrawContext* pContext, const CRect& updateRect)
{
	if (updateRect.getWidth () <= 0 || updateRect.getHeight () <= 0 || pContext == 0)
		return;

	if (pContext)
		pContext->remember ();

	CRect oldClip;
	pContext->getClipRect (oldClip);
	CRect newClip (updateRect);
	newClip.bound (oldClip);
	pContext->setClipRect (newClip);

	// draw the background and the children
	CViewContainer::drawRect (pContext, updateRect);

	pContext->setClipRect (oldClip);

	pContext->forget ();
}
Example #27
0
//-----------------------------------------------------------------------------
Win32Frame::Win32Frame (IPlatformFrameCallback* frame, const CRect& size, HWND parent)
: IPlatformFrame (frame)
, windowHandle (0)
, parentWindow (parent)
, tooltipWindow (0)
, backBuffer (0)
, deviceContext (0)
, inPaint (false)
, mouseInside (false)
, updateRegionList (0)
, updateRegionListSize (0)
{
	initWindowClass ();

	DWORD style = isParentLayered (parent) ? WS_EX_TRANSPARENT : 0;
	#if !DEBUG_DRAWING
	if (getD2DFactory ()) // workaround for Direct2D hotfix (KB2028560)
	{
		// when WS_EX_COMPOSITED is set drawing does not work correctly. This seems like a bug in Direct2D wich happens with this hotfix
	}
	else if (getSystemVersion ().dwMajorVersion >= 6) // Vista and above
		style |= WS_EX_COMPOSITED;
	else
		backBuffer = createOffscreenContext (size.getWidth (), size.getHeight ());
	#endif
	windowHandle = CreateWindowEx (style, gClassName, TEXT("Window"),
									WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 
									0, 0, (int)size.width (), (int)size.height (), 
									parentWindow, NULL, GetInstance (), NULL);

	if (windowHandle)
	{
		SetWindowLongPtr (windowHandle, GWLP_USERDATA, (__int3264)(LONG_PTR)this);
		RegisterDragDrop (windowHandle, new CDropTarget (this));
	}
}
Example #28
0
//-------------------------------------------------
// DebugHelpers
//-------------------------------------------------
//
void TraceRect( const CRect& r, const string s )
{
    TRACE( "%s : left=%d top=%d right=%d bottom=%d width=%d height=%d\n", s.c_str(), r.left, r.top, r.right, r.bottom, r.getWidth(), r.getHeight() );
}
//-----------------------------------------------------------------------------
void GdiplusDrawContext::drawBitmap (CBitmap* cbitmap, const CRect& dest, const CPoint& offset, float alpha)
{
	alpha *= currentState.globalAlpha;
	if (alpha == 0.f || pGraphics == 0)
		return;
	IPlatformBitmap* platformBitmap = cbitmap ? cbitmap->getPlatformBitmap () : 0;
	GdiplusBitmap* gpb = platformBitmap ? dynamic_cast<GdiplusBitmap*> (platformBitmap) : 0;
	Gdiplus::Bitmap* bitmap = gpb ? gpb->getBitmap () : 0;
	if (bitmap)
	{
		GdiplusDrawScope drawScope (pGraphics, currentState.clipRect, getCurrentTransform ());

		Gdiplus::ImageAttributes imageAtt;
		if (alpha != 1.f)
		{
			// introducing the alpha blend matrix
			Gdiplus::ColorMatrix colorMatrix =
			{
				1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
				0.0f, 0.0f, 0.0f, alpha, 0.0f,
				0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
			};
			// create the imageattribute modifier
			imageAtt.SetColorMatrix (&colorMatrix, Gdiplus::ColorMatrixFlagsDefault,
				Gdiplus::ColorAdjustTypeBitmap);
#if 1
			Gdiplus::Rect	myDestRect(
				(INT)dest.left,
				(INT)dest.top,
				(INT)dest.getWidth (),
				(INT)dest.getHeight ());
			pGraphics->DrawImage (
				bitmap,
				myDestRect,
				(INT)offset.x,
				(INT)offset.y,
				(INT)dest.getWidth (),
				(INT)dest.getHeight (),
				Gdiplus::UnitPixel,
				&imageAtt);
#else
			// create a temporary bitmap to prevent OutOfMemory errors
			Gdiplus::Bitmap myBitmapBuffer ((INT)dest.getWidth (), (INT)dest.getHeight (),PixelFormat32bppARGB);
			// create a graphics context for the temporary bitmap
			Gdiplus::Graphics* myGraphicsBuffer = Gdiplus::Graphics::FromImage (&myBitmapBuffer);
			// copy the rectangle we want to paint to the temporary bitmap
			Gdiplus::Rect myTransRect(
				0,
				0,
				(INT)dest.getWidth (),
				(INT)dest.getHeight ());
			// transfer the bitmap (without modification by imageattr!)
			myGraphicsBuffer->DrawImage (
				bitmap,myTransRect,
				(INT)offset.x,
				(INT)offset.y,
				(INT)dest.getWidth (),
				(INT)dest.getHeight (),
				Gdiplus::UnitPixel,
				0);
			// now transfer the temporary to the real context at the advised location
			Gdiplus::Rect myDestRect (
				(INT)dest.left,
				(INT)dest.top,
				(INT)dest.getWidth (),
				(INT)dest.getHeight ());
			// transfer from temporary bitmap to real context (with imageattr)
			pGraphics->DrawImage (
				&myBitmapBuffer,
				myDestRect,
				(INT)0,
				(INT)0,
				(INT)dest.getWidth (),
				(INT)dest.getHeight (),
				Gdiplus::UnitPixel,
				&imageAtt);
			// delete the temporary context of the temporary bitmap
			delete myGraphicsBuffer;
#endif
		}
		else
		{
			Gdiplus::Rect	myDestRect(
				(INT)dest.left,
				(INT)dest.top,
				(INT)dest.getWidth (),
				(INT)dest.getHeight ());
			pGraphics->DrawImage (
				bitmap,
				myDestRect,
				(INT)offset.x,
				(INT)offset.y,
				(INT)dest.getWidth (),
				(INT)dest.getHeight (),
				Gdiplus::UnitPixel,
				0);
		}
	}
}
Example #30
0
//-----------------------------------------------------------------------------
PlatformOptionMenuResult Win32OptionMenu::popup (COptionMenu* optionMenu)
{
	PlatformOptionMenuResult result = {0};
	
	//---Transform local coordinates to global coordinates
	CRect rect = optionMenu->translateToGlobal (optionMenu->getViewSize ());

	int32_t offset;

	if (optionMenu->getStyle () & kPopupStyle)
		offset = 0;
	else
		offset = static_cast<int32_t> (rect.getHeight ());

	CCoord gx = 0, gy = 0;
	optionMenu->getFrame ()->getPosition (gx, gy);
	gx += rect.left;
	gy += rect.top + offset;

	int32_t offsetIndex = 0;
	HMENU menu = createMenu (optionMenu, offsetIndex);
	if (menu)
	{
		int flags = TPM_LEFTALIGN;

// do we need the following ?
//		if (lastButton & kRButton)
//			flags |= TPM_RIGHTBUTTON;

		if (TrackPopupMenu (menu, flags, (int)gx, (int)gy, 0, windowHandle, 0))
		{
			MSG msg;
			if (PeekMessage (&msg, windowHandle, WM_COMMAND, WM_COMMAND, PM_REMOVE))
			{
				if (HIWORD (msg.wParam) == 0)
				{
					int32_t res = LOWORD (msg.wParam);
					if (res != -1)
					{
						int32_t idx = 0;
						offsetIndex = 0;
						COptionMenu* resultMenu = getItemMenu (res, idx, offsetIndex, optionMenu);
						if (resultMenu)
						{
							result.menu = resultMenu;
							result.index = idx;
						}
					}
				}
			}
		}
		std::list<HBITMAP>::iterator it = bitmaps.begin ();
		while (it != bitmaps.end ())
		{
			DeleteObject (*it);
			it++;
		}
		DestroyMenu (menu);
	}
	return result;
}