//----------------------------------------------------------------------------- void CSegmentButton::updateSegmentSizes () { if (isAttached () && !segments.empty ()) { if (style == kHorizontal) { CCoord width = getWidth () / segments.size (); CRect r (getViewSize ()); r.setWidth (width); for (Segments::iterator it = segments.begin (), end = segments.end (); it != end; ++it) { (*it).rect = r; r.offset (width, 0); } } else { CCoord height = getHeight () / segments.size (); CRect r (getViewSize ()); r.setHeight (height); for (Segments::iterator it = segments.begin (), end = segments.end (); it != end; ++it) { (*it).rect = r; r.offset (0, height); } } } }
//-------------------------------------------------------------------------------- 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++; } }
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; } } } }
//----------------------------------------------------------------------------- void D2DDrawContext::drawRect (const CRect &_rect, const CDrawStyle drawStyle) { if (renderTarget) { CRect rect (_rect); rect.offset (currentState.offset.x, currentState.offset.y); rect.normalize (); if (currentState.drawMode.integralMode ()) { rect.makeIntegral (); } D2DApplyClip clip (this); if (drawStyle == kDrawFilled || drawStyle == kDrawFilledAndStroked) { renderTarget->FillRectangle (makeD2DRect (rect), fillBrush); } if (drawStyle == kDrawStroked || drawStyle == kDrawFilledAndStroked) { rect.left++; rect.bottom--; if ((((int32_t)currentState.frameWidth) % 2)) renderTarget->SetTransform (D2D1::Matrix3x2F::Translation (0.f, 0.5f)); renderTarget->DrawRectangle (makeD2DRect (rect), strokeBrush, (FLOAT)currentState.frameWidth, strokeStyle); renderTarget->SetTransform (D2D1::Matrix3x2F::Identity ()); } } }
//----------------------------------------------------------------------------- CRect CScrollbar::getScrollerRect () { CRect scrollerRect (scrollerArea); CCoord l = (direction == kHorizontal) ? scrollerArea.getWidth () : scrollerArea.getHeight (); CCoord scrollerOffset = (CCoord) (value * (l - scrollerLength)); if (direction == kHorizontal) { scrollerRect.setWidth (scrollerLength); scrollerRect.offset (scrollerOffset, 0); } else { scrollerRect.setHeight (scrollerLength); scrollerRect.offset (0, scrollerOffset); } return scrollerRect; }
//------------------------------------------------------------------------ CRect CTextEdit::platformGetVisibleSize () const { CRect rect = getVisibleViewSize (); CPoint p (0, 0); localToFrame (p); rect.offset (p.x, p.y); return rect; }
//----------------------------------------------------------------------------- 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); } }
//------------------------------------------------------------------------ CRect UISearchTextField::platformGetSize () const { CRect rect = getViewSize (); CRect cmr = getClearMarkRect (); rect.right = cmr.left; CPoint p (0, 0); localToFrame (p); rect.offset (p.x, p.y); return rect; }
//---------------------------------------------------------------------------------------------------- void UnembedViewOperation::undo () { CRect containerViewSize = containerView->getViewSize (); const_iterator it = begin (); while (it != end ()) { CView* view = (*it); parent->removeView (view, false); CRect viewSize = view->getViewSize (); CRect mouseSize = view->getMouseableArea (); viewSize.offset (-containerViewSize.left, -containerViewSize.top); mouseSize.offset (-containerViewSize.left, -containerViewSize.top); view->setViewSize (viewSize); view->setMouseableArea (mouseSize); containerView->addView (view); it++; } parent->addView (containerView); selection->setExclusive (containerView); }
virtual CMouseEventResult onMouseDown (CPoint &where, const long &buttons) { if (buttons == kRButton) { CView* view = getViewAt (where); if (!view || view->isTypeOf ("CTabButton")) { CRect r; localToFrame (where); r.offset (where.x, where.y); r.offset (-size.left, -size.top); COptionMenu* menu = new COptionMenu (r, NULL, 0); menu->addEntry ("Tabs Left"); menu->addEntry ("Tabs Right"); menu->addEntry ("Tabs Top"); menu->addEntry ("Tabs Bottom"); menu->addEntry ("-"); menu->addEntry ("Align Tabs Centered"); menu->addEntry ("Align Tabs Left/Top"); menu->addEntry ("Align Tabs Right/Bottom"); getFrame ()->addView (menu); menu->takeFocus (); long res = menu->getLastResult (); getFrame ()->removeView (menu); if (res != -1) { if (res < 4) { r = size; editor->setTabView (getFrame (), r, res); } else { alignTabs (kAlignCenter + res - 5); } } return kMouseDownEventHandledButDontNeedMovedOrUpEvents; } } return CTabView::onMouseDown (where, buttons); }
void GuiCustomRowColumnView::drawBackgroundRect(CDrawContext* pContext, const CRect& _updateRect) { if (getDrawBackground()) { CRect oldClip; pContext->getClipRect(oldClip); CRect newClip(_updateRect); newClip.bound(oldClip); pContext->setClipRect(newClip); CRect tr(0, 0, getViewSize().getWidth(), getViewSize().getHeight()); getDrawBackground()->draw(pContext, tr, backgroundOffset); pContext->setClipRect(oldClip); } else if ((backgroundColor.alpha != 255 && getTransparency()) || !getTransparency()) { pContext->setDrawMode(kAliasing); pContext->setLineWidth(1); pContext->setFillColor(backgroundColor); pContext->setFrameColor(backgroundColor); pContext->setLineStyle(kLineSolid); CRect r; if (backgroundColorDrawStyle == kDrawFilled || (backgroundColorDrawStyle == kDrawFilledAndStroked && backgroundColor.alpha == 255)) { r = _updateRect; r.inset(-1, -1); } else { r = getViewSize(); r.offset(-r.left, -r.top); } pContext->drawRect(r, backgroundColorDrawStyle); } // Custom stuff pContext->setFillColor(CColor(0, 0, 0, 0)); pContext->setLineWidth(frameWidth); pContext->setFrameColor(frameColor); CRect rect = getViewSize(); rect.offset(-rect.left, -rect.top); pContext->drawRect(rect); }
/** * @param src rect which to scroll * @param distance point of distance */ void CFrame::scrollRect (const CRect& src, const CPoint& distance) { CRect rect (src); rect.offset (getViewSize ().left, getViewSize ().top); if (platformFrame) { if (platformFrame->scrollRect (src, distance)) return; } invalidRect (src); }
//----------------------------------------------------------------------------- void D2DDrawContext::drawBitmap (CBitmap* bitmap, const CRect& dest, const CPoint& offset, float alpha) { if (renderTarget == 0) return; D2DApplyClip ac (this); if (ac.isEmpty ()) return; double transformedScaleFactor = getScaleFactor (); CGraphicsTransform t = getCurrentTransform (); if (t.m11 == t.m22 && t.m12 == 0 && t.m21 == 0) transformedScaleFactor *= t.m11; IPlatformBitmap* platformBitmap = bitmap->getBestPlatformBitmapForScaleFactor (transformedScaleFactor); D2DBitmap* d2dBitmap = platformBitmap ? dynamic_cast<D2DBitmap*> (platformBitmap) : 0; if (d2dBitmap) { if (d2dBitmap->getSource ()) { ID2D1Bitmap* d2d1Bitmap = D2DBitmapCache::instance ()->getBitmap (d2dBitmap, renderTarget); if (d2d1Bitmap) { double bitmapScaleFactor = platformBitmap->getScaleFactor (); CGraphicsTransform bitmapTransform; bitmapTransform.scale (bitmapScaleFactor, bitmapScaleFactor); Transform transform (*this, bitmapTransform.inverse ()); CRect d (dest); d.makeIntegral (); CRect source (dest); source.offset (-source.left, -source.top); source.offset (offset.x, offset.y); bitmapTransform.transform (source); D2D1_RECT_F sourceRect = makeD2DRect (source); renderTarget->DrawBitmap (d2d1Bitmap, makeD2DRect (d), alpha * currentState.globalAlpha, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, &sourceRect); } } } }
//---------------------------------------------------------------------------------------------------- void UnembedViewOperation::perform () { IDependency::DeferChanges dc (selection); selection->remove (containerView); CRect containerViewSize = containerView->getViewSize (); const_reverse_iterator it = rbegin (); while (it != rend ()) { CView* view = (*it); CRect viewSize = view->getViewSize (); CRect mouseSize = view->getMouseableArea (); containerView->removeView (view, false); viewSize.offset (containerViewSize.left, containerViewSize.top); mouseSize.offset (containerViewSize.left, containerViewSize.top); view->setViewSize (viewSize); view->setMouseableArea (mouseSize); if (parent->addView (view)) selection->add (view); it++; } parent->removeView (containerView, false); }
/** * repositions the frame * @param x x coordinate * @param y y coordinate * @return true on success */ bool CFrame::setPosition (CCoord x, CCoord y) { if (platformFrame) { CRect rect (getViewSize ()); rect.offset (x - size.left, y - size.top); if (platformFrame->setSize (rect)) { size = rect; return true; } } return false; }
//----------------------------------------------------------------------------- void D2DDrawContext::drawBitmap (CBitmap* bitmap, const CRect& dest, const CPoint& offset, float alpha) { D2DBitmap* d2dBitmap = bitmap->getPlatformBitmap () ? dynamic_cast<D2DBitmap*> (bitmap->getPlatformBitmap ()) : 0; if (renderTarget && d2dBitmap) { if (d2dBitmap->getSource ()) { ID2D1Bitmap* d2d1Bitmap = D2DBitmapCache::instance ()->getBitmap (d2dBitmap, renderTarget); if (d2d1Bitmap) { D2DApplyClip clip (this); CRect d (dest); d.offset (currentState.offset.x, currentState.offset.y); d.makeIntegral (); CRect source (dest); source.offset (-source.left, -source.top); source.offset (offset.x, offset.y); D2D1_RECT_F sourceRect = makeD2DRect (source); renderTarget->DrawBitmap (d2d1Bitmap, makeD2DRect (d), alpha * currentState.globalAlpha, D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, &sourceRect); } } } }
//------------------------------------------------------------------------ CRect UISearchTextField::platformGetVisibleSize () const { CRect rect = getViewSize (); CRect cmr = getClearMarkRect (); rect.right = cmr.left; if (pParentView) rect = static_cast<CViewContainer*>(pParentView)->getVisibleSize (rect); else if (pParentFrame) rect = pParentFrame->getVisibleSize (rect); CPoint p (0, 0); localToFrame (p); rect.offset (p.x, p.y); return rect; }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- ViewCopyOperation::ViewCopyOperation (UISelection* copySelection, UISelection* workingSelection, CViewContainer* parent, const CPoint& offset, IUIDescription* desc) : parent (parent) , copySelection (copySelection) , workingSelection (workingSelection) { CRect selectionBounds = copySelection->getBounds (); FOREACH_IN_SELECTION(copySelection, view) if (!copySelection->containsParent (view)) { CRect viewSize = UISelection::getGlobalViewCoordinates (view); CRect newSize (0, 0, view->getWidth (), view->getHeight ()); newSize.offset (offset.x, offset.y); newSize.offset (viewSize.left - selectionBounds.left, viewSize.top - selectionBounds.top); view->setViewSize (newSize); view->setMouseableArea (newSize); push_back (view); } FOREACH_IN_SELECTION_END FOREACH_IN_SELECTION(workingSelection, view) oldSelectedViews.push_back (view); FOREACH_IN_SELECTION_END }
void CTextDisplay::draw(CDrawContext* pContext) { //this should be done off-screen, but I didn't feel like it. //I'll fix it in the next version (+ Mat's aplha-strip...) CColor rectColor = { 0, 0, 0, 0 }; CColor fontColor = { 255, 255, 255, 0 }; CColor frameColor = { 0, 0, 0, 0 }; pContext->setFontColor(fontColor); pContext->setFont(kSystemFont, 10); CRect tmprect = size; tmprect.offset(3, -1); pContext->setFillColor(rectColor); pContext->setFrameColor(frameColor); pContext->drawRect(size); // pContext->fillRect(size); // pContext->drawString(todisplay,tmprect,false,kLeftText); CRect sourcerect; CPoint bitmapoffset; int left = size.left + 3; //our staring point! int top = size.top; //our staring point! int bottom = size.top + ascii->getHeight(); //our staring point! int place; int width; for (int i = 0; i < 256; i++) { if (todisplay[i] == 0) break; PlaceAndWidth(todisplay[i], place, width); if (place != -1) { sourcerect(left, top, left + width, bottom); //draw bitmapoffset(place, 0); ascii->draw(pContext, sourcerect, bitmapoffset); left += width; } } setDirty(false); }
//----------------------------------------------------------------------------- CMessageResult CScrollView::notify (CBaseObject* sender, IdStringPtr message) { if (message == kMsgNewFocusView && getStyle () & kFollowFocusView) { CView* focusView = (CView*)sender; if (sc->isChild (focusView, true)) { CRect r = focusView->getViewSize (); CPoint p; focusView->localToFrame (p); frameToLocal (p); r.offset (p.x, p.y); makeRectVisible (r); } } return CViewContainer::notify (sender, message); }
//----------------------------------------------------------------------------- void CScrollContainer::onDragMove (IDataPackage* drag, const CPoint& where) { if (autoDragScroll) { float x, y; if (getScrollValue (where, x, y)) { CScrollView* scrollView = static_cast<CScrollView*> (getParentView ()); if (scrollView) { CRect r (getViewSize ()); r.offset (x, y); scrollView->makeRectVisible (r); } } } return CViewContainer::onDragMove (drag, where); }
//----------------------------------------------------------------------------- void EmbedViewOperation::perform () { CRect parentRect = newContainer->getViewSize (); const_iterator it = begin (); while (it != end ()) { CView* view = (*it).first; parent->removeView (view, false); CRect r = view->getViewSize (); r.offset (-parentRect.left, -parentRect.top); view->setViewSize (r); view->setMouseableArea (r); newContainer->addView (view); it++; } parent->addView (newContainer); newContainer->remember (); selection->setExclusive (newContainer); }
//------------------------------------------------------------------------ void CTextEdit::takeFocus () { if (platformControl) return; #if TARGET_OS_IPHONE if (getFrame ()->getFocusView () == this) return; #endif bWasReturnPressed = false; // calculate offset for CViewContainers CRect rect (getViewSize ()); CPoint p (0, 0); localToFrame (p); rect.offset (p.x, p.y); platformControl = getFrame ()->getPlatformFrame ()->createPlatformTextEdit (this); #if TARGET_OS_IPHONE getFrame ()->setFocusView (this); #endif }
//----------------------------------------------------------------------------- void UIViewSwitchContainer::setCurrentViewIndex (int32_t viewIndex) { if (controller) { CView* view = controller->createViewForIndex (viewIndex); if (view) { if (view->getAutosizeFlags () & kAutosizeAll) { CRect vs (getViewSize ()); vs.offset (-vs.left, -vs.top); view->setViewSize (vs); view->setMouseableArea (vs); } if (animationTime) { if (getFrame ()) getFrame ()->getAnimator ()->removeAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex"); CView* oldView = getView (0); if (isAttached () && oldView && getFrame ()) { getFrame ()->getAnimator ()->addAnimation (this, "UIViewSwitchContainer::setCurrentViewIndex", new Animation::ExchangeViewAnimation (oldView, view, Animation::ExchangeViewAnimation::kAlphaValueFade), new Animation::LinearTimingFunction (animationTime)); } else { removeAll (); addView (view); } } else { CViewContainer::removeAll (); CViewContainer::addView (view); } currentViewIndex = viewIndex; invalid (); } } }
//----------------------------------------------------------------------------------- bool TutorialEditor::open (void* ptr) { //-- first we create the frame with a size of 300, 300 and set the background to white CRect frameSize (0, 0, 300, 300); CFrame* newFrame = new CFrame (frameSize, ptr, this); newFrame->setBackgroundColor (kWhiteCColor); //-- load some bitmaps we need CBitmap* background = new CBitmap ("KnobBackground.png"); CBitmap* handle = new CBitmap ("KnobHandle.png"); CBitmap* handleHighlight = new CBitmap ("KnobHandleHighlight.png"); //-- creating a knob and adding it to the frame CRect r (0, 0, background->getWidth (), background->getHeight ()); CKnob* knob1 = new MyKnob (r, this, kLeftVolumeParameter, background, handle, handleHighlight); newFrame->addView (knob1); //-- creating another knob, we are offsetting the rect, so that the knob is next to the previous knob r.offset (background->getWidth () + 5, 0); CKnob* knob2 = new MyKnob (r, this, kRightVolumeParameter, background, handle, handleHighlight); newFrame->addView (knob2); //-- forget the bitmaps background->forget (); handle->forget (); //-- remember our controls so that we can sync them with the state of the effect controls[kLeftVolumeParameter] = knob1; controls[kRightVolumeParameter] = knob2; //-- set the member frame to our frame frame = newFrame; //-- sync parameters for (int i = 0; i < kNumParameters; i++) setParameter (i, effect->getParameter (i)); return true; }
void SelectBox::drawDropdown( CDrawContext* pContext ) { pContext->setFillColor( colBkgnd_ ); pContext->drawRect( rcDropdown_, kDrawFilledAndStroked ); ASSERT( indexSel_ >= 0 && (indexSel_ < (INT32)list_.size() || list_.empty())); if( indexSel_ >= 0 && (indexSel_ <= (INT32)list_.size())) { CRect rcSel; getTextRect( rcSel, indexSel_-scrollOffset_ ); rcSel.offset( 0, -1 ); pContext->setFillColor( colSel_ ); pContext->drawRect( rcSel, kDrawFilledAndStroked ); CRect rc; for( INT32 i=0; i+scrollOffset_<(INT32)list_.size() && rc.bottom<rcDropdown_.bottom; i++ ) { getTextRect( rc, i ); rc.left += 2; pContext->drawStringUTF8( list_[ i+scrollOffset_ ].c_str(), rc, kLeftText, true ); } } }
//------------------------------------------------------------------------ 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; }
//----------------------------------------------------------------------------- void CTabView::alignTabs (TabAlignment alignment) { CCoord allTabsWidth; CCoord viewWidth; CCoord offset = 0; CRect ts (tabSize.left, tabSize.top, tabSize.getWidth (), tabSize.getHeight () / 2); if (tabPosition == kPositionTop || tabPosition == kPositionBottom) { allTabsWidth = tabSize.getWidth () * numberOfChilds; viewWidth = getViewSize ().getWidth (); } else { allTabsWidth = (tabSize.getHeight () / 2) * numberOfChilds; viewWidth = getViewSize ().getHeight (); } if (alignment == kAlignCenter) offset = (viewWidth - allTabsWidth) / 2; else if (alignment == kAlignLeft) offset = 0; else if (alignment == kAlignRight) offset = viewWidth - allTabsWidth; if (tabPosition == kPositionTop) ts.offset (offset, 0); else if (tabPosition == kPositionBottom) ts.offset (offset, 0); else if (tabPosition == kPositionLeft) ts.offset (0, offset); else if (tabPosition == kPositionRight) ts.offset (0, offset); CTabChildView* v = firstChild; while (v) { v->button->setViewSize (ts); v->button->setMouseableArea (ts); if (tabPosition == kPositionTop || tabPosition == kPositionBottom) ts.offset (tabSize.getWidth (), 0); else ts.offset (0, tabSize.getHeight () / 2); v = v->next; } setDirty (true); invalid (); }
//----------------------------------------------------------------------------- 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); } } }
// // open // bool SDEditor::open (void *ptr) { // !!! always call this !!! AEffGUIEditor::open (ptr); //--load some bitmaps CBitmap* hFaderBody = new CBitmap (kFaderBodyId); CBitmap* hFaderHandle = new CBitmap (kFaderHandleId); //--init background frame----------------------------------------------- // We use a local CFrame object so that calls to setParameter won't call into objects which may not exist yet. // If all GUI objects are created we assign our class member to this one. See bottom of this method. CRect size (0, 0, hBackground->getWidth (), hBackground->getHeight ()); CFrame* lFrame = new CFrame (size, ptr, this); lFrame->setBackground (hBackground); //--init the faders------------------------------------------------ int minPos = kFaderY; int maxPos = kFaderY + hFaderBody->getHeight () - hFaderHandle->getHeight () - 1; CPoint point (0, 0); CPoint offset (1, 0); // fine pitch size (kFaderX, kFaderY, kFaderX + hFaderBody->getWidth (), kFaderY + hFaderBody->getHeight ()); finePitchFader = new CVerticalSlider (size, this, kFinePitch, minPos, maxPos, hFaderHandle, hFaderBody, point); finePitchFader->setOffsetHandle (offset); finePitchFader->setValue (effect->getParameter (kFinePitch)); lFrame->addView (finePitchFader); // delay size.offset (kFaderInc + hFaderBody->getWidth (), 0); delayFader = new CVerticalSlider (size, this, kDelay, minPos, maxPos, hFaderHandle, hFaderBody, point); delayFader->setOffsetHandle (offset); delayFader->setValue (effect->getParameter (kDelay)); lFrame->addView (delayFader); // feedback size.offset (kFaderInc + hFaderBody->getWidth (), 0); feedbackFader = new CVerticalSlider (size, this, kFeedback, minPos, maxPos, hFaderHandle, hFaderBody, point); feedbackFader->setOffsetHandle (offset); feedbackFader->setValue (effect->getParameter (kFeedback)); lFrame->addView (feedbackFader); // Coarse pitch shift in steps size (kSelectX, kSelectY, kSelectX + kSelectWidth, kSelectY + kSelectHeight); coarsePitchOption = new COptionMenu(size, this, kCoarsePitch); coarsePitchOption->addEntry("+12"); coarsePitchOption->addEntry("+11"); coarsePitchOption->addEntry("+10"); coarsePitchOption->addEntry("+9"); coarsePitchOption->addEntry("+8"); coarsePitchOption->addEntry("+7"); coarsePitchOption->addEntry("+6"); coarsePitchOption->addEntry("+5"); coarsePitchOption->addEntry("+4"); coarsePitchOption->addEntry("+3"); coarsePitchOption->addEntry("+2"); coarsePitchOption->addEntry("+1"); coarsePitchOption->addEntry("0"); coarsePitchOption->addEntry("-1"); coarsePitchOption->addEntry("-2"); coarsePitchOption->addEntry("-3"); coarsePitchOption->addEntry("-4"); coarsePitchOption->addEntry("-5"); coarsePitchOption->addEntry("-6"); coarsePitchOption->addEntry("-7"); coarsePitchOption->addEntry("-8"); coarsePitchOption->addEntry("-9"); coarsePitchOption->addEntry("-10"); coarsePitchOption->addEntry("-11"); coarsePitchOption->addEntry("-12"); coarsePitchOption->setCurrent(ROUND((effect->getParameter(kCoarsePitch)*NUM_PITCHES))); lFrame->addView (coarsePitchOption); // Mix mode size.offset( 0, kSelectInc ); mixOption = new COptionMenu(size, this, kMixMode); mixOption->addEntry("mono"); mixOption->addEntry("wet only"); mixOption->addEntry("wet left"); mixOption->addEntry("wet right"); mixOption->addEntry("wet part left"); mixOption->addEntry("wet part right"); mixOption->addEntry("stereo"); mixOption->setCurrent((int)(effect->getParameter(kMixMode)*NUM_MIX_MODES)); lFrame->addView (mixOption); // Note : in the constructor of a CBitmap, the number of references is set to 1. // Then, each time the bitmap is used (for hinstance in a vertical slider), this // number is incremented. // As a consequence, everything happens as if the constructor by itself was adding // a reference. That's why we need til here a call to forget (). // You mustn't call delete here directly, because the bitmap is used by some CControls... // These "rules" apply to the other VSTGUI objects too. hFaderBody->forget (); hFaderHandle->forget (); frame = lFrame; return true; }