void UISlider::Draw(const UIGeometricData &geometricData) { const Rect & aRect = thumbButton->GetGeometricData().GetUnrotatedRect(); float32 clipPointAbsolute = aRect.x + aRect.dx * 0.5f; const Vector2& drawTranslate = RenderManager::Instance()->GetDrawTranslate(); const Vector2& drawScale = RenderManager::Instance()->GetDrawScale(); float32 screenXMin = (Core::Instance()->GetVirtualScreenXMin() - drawTranslate.x) / drawScale.x; float32 screenXMax = (Core::Instance()->GetVirtualScreenXMax() - drawTranslate.x) / drawScale.x; float32 screenYMin = - drawTranslate.y / drawScale.y; float32 screenYMax = (GetScreenHeight() - drawTranslate.y) / drawScale.y; if (minBackground) { minBackground->SetParentColor(GetBackground()->GetDrawColor()); RenderManager::Instance()->ClipPush(); RenderManager::Instance()->ClipRect(Rect(screenXMin, screenYMin, clipPointAbsolute - screenXMin, screenYMax)); minBackground->Draw(geometricData); RenderManager::Instance()->ClipPop(); } if (maxBackground) { maxBackground->SetParentColor(GetBackground()->GetDrawColor()); RenderManager::Instance()->ClipPush(); RenderManager::Instance()->ClipRect(Rect(clipPointAbsolute, screenYMin, screenXMax - clipPointAbsolute, screenYMax)); maxBackground->Draw(geometricData); RenderManager::Instance()->ClipPop(); } if (!minBackground && !maxBackground) { UIControl::Draw(geometricData); } }
void ControlRotationTest::LoadResources() { GetBackground()->SetColor(Color(0.0f, 1.0f, 0.0f, 1.0f)); GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); rotatedControl = new UIControl(Rect(256.f, 256.f, 256.f, 256.f)); rotatedControl->SetSprite("~res:/Gfx/UI/Rotation", 0); rotatedControl->pivotPoint = rotatedControl->GetSize()/2; rotatedControl->SetAngle(angle); AddControl(rotatedControl); Font *font = FTFont::Create("~res:/Fonts/korinna.ttf"); DVASSERT(font); font->SetSize(20); description = new UIStaticText(Rect(0, 256, 512, 200)); description->SetAlign(ALIGN_LEFT | ALIGN_VCENTER); description->SetMultiline(true); description->SetFont(font); AddControl(description); SafeRelease(font); }
PropertyPanel::PropertyPanel(const Rect & rect) : UIControl(rect) , lastAddedChild(0) { GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); GetBackground()->SetColor(Color(0.8f, 0.8f, 0.8f, 1.0f)); }
void UISlider::Draw(const UIGeometricData &geometricData) { const Rect & aRect = thumbButton->GetGeometricData().GetUnrotatedRect(); float32 clipPointAbsolute = aRect.x + aRect.dx * 0.5f; if (bgMin) { bgMin->SetParentColor(GetBackground()->GetDrawColor()); RenderManager::Instance()->ClipPush(); RenderManager::Instance()->ClipRect(Rect(Core::Instance()->GetVirtualScreenXMin(), 0, clipPointAbsolute - Core::Instance()->GetVirtualScreenXMin(), (float32)GetScreenHeight())); bgMin->Draw(geometricData); RenderManager::Instance()->ClipPop(); } if (bgMax) { bgMax->SetParentColor(GetBackground()->GetDrawColor()); RenderManager::Instance()->ClipPush(); RenderManager::Instance()->ClipRect(Rect(clipPointAbsolute, 0, Core::Instance()->GetVirtualScreenXMax() - clipPointAbsolute, (float32)GetScreenHeight())); bgMax->Draw(geometricData); RenderManager::Instance()->ClipPop(); } if (!bgMax && !bgMin) UIControl::Draw(geometricData); }
void ComboBox::OnRender(suic::DrawingContext * drawing) { suic::StylePtr styleArrow = FindResource(_T("ComboBox.Down")); suic::Point pt; suic::Rect drawrect(pt.x, pt.y, RenderSize().cx, RenderSize().cy); // // 先绘制背景 // if (GetBackground()) { GetBackground()->Draw(drawing, &drawrect); } // 获取下拉箭头的设置 if (styleArrow.get()) { suic::BrushPtr bkgnd(suic::Render::GetProperty(this, styleArrow.get(), _T("Background"))); if (bkgnd) { suic::Rect downRect = drawrect; downRect.Deflate(GetBorderThickness()); downRect.left = downRect.right - 16; bkgnd->Draw(drawing, &downRect); } } suic::Render::RenderBorder(drawing, this, &drawrect); }
UICheckBox::UICheckBox() : UIControl() { checked = false; checkboxDelegate = NULL; GetBackground()->SetAlign(ALIGN_HCENTER | ALIGN_VCENTER); GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT); AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UICheckBox::OnClick)); }
UICheckBox::UICheckBox(const String &spriteName, const Rect &rect, bool rectInAbsoluteCoordinates) : UIControl(rect, rectInAbsoluteCoordinates) { checkboxDelegate = NULL; GetBackground()->SetAlign(ALIGN_HCENTER | ALIGN_VCENTER); GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT); SetSprite(spriteName, 0); SetChecked(false, false); AddEvent(UIControl::EVENT_TOUCH_UP_INSIDE, Message(this, &UICheckBox::OnClick)); }
ForcePreviewControl::ForcePreviewControl() { GetBackground()->SetDrawType(UIControlBackground::DRAW_FILL); GetBackground()->SetColor(Color(0.2, 0.2, 0.2, 1)); Font *f = FTFont::Create("~res:/Fonts/MyriadPro-Regular.otf"); f->SetSize(10); f->SetColor(Color(1,1,1,1)); powerText = new UIStaticText(); powerText->SetFont(f); AddControl(powerText); SafeRelease(f); }
NS_IMETHODIMP HTMLBodyElement::GetBackground(nsAString& aBackground) { nsString background; GetBackground(background); aBackground = background; return NS_OK; }
ECode ToggleButton::OnFinishInflate() { CompoundButton::OnFinishInflate(); UpdateReferenceToIndicatorDrawable(GetBackground()); return NOERROR; }
NS_IMETHODIMP HTMLBodyElement::GetBackground(nsAString& aBackground) { DOMString background; GetBackground(background); background.ToString(aBackground); return NS_OK; }
void Border::Render (cairo_t *cr, Region *region, bool path_only) { Brush *background = GetBackground (); Brush *border_brush = GetBorderBrush (); cairo_save (cr); if (!path_only) RenderLayoutClip (cr); CornerRadius r = *GetCornerRadius (); CornerRadius *round = &r; Thickness thickness = *GetBorderThickness (); Rect paint_border = extents; Rect paint_background = paint_border.GrowBy (-thickness); CornerRadius inner_adjusted = *round; inner_adjusted.topLeft = MAX (round->topLeft - MAX (thickness.left, thickness.top) * .5, 0); inner_adjusted.topRight = MAX (round->topRight - MAX (thickness.right, thickness.top) * .5, 0); inner_adjusted.bottomRight = MAX (round->bottomRight - MAX (thickness.right, thickness.bottom) * .5, 0); inner_adjusted.bottomLeft = MAX (round->bottomLeft - MAX (thickness.left, thickness.bottom) * .5, 0); CornerRadius outer_adjusted = *round; outer_adjusted.topLeft = outer_adjusted.topLeft ? MAX (round->topLeft + MAX (thickness.left, thickness.top) * .5, 0) : 0; outer_adjusted.topRight = outer_adjusted.topRight ? MAX (round->topRight + MAX (thickness.right, thickness.top) * .5, 0) : 0; outer_adjusted.bottomRight = outer_adjusted.bottomRight ? MAX (round->bottomRight + MAX (thickness.right, thickness.bottom) * .5, 0) : 0; outer_adjusted.bottomLeft = outer_adjusted.bottomLeft ? MAX (round->bottomLeft + MAX (thickness.left, thickness.bottom) * .5, 0) : 0; /* * NOTE filling this way can leave alpha artifacts between the border fill and bg fill * but some simple inspection of the ms results make me think that is what happens there * too. */ cairo_new_path (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); if (border_brush && !paint_border.IsEmpty ()) { border_brush->SetupBrush (cr, paint_border); paint_border.Draw (cr, &outer_adjusted); paint_background.Draw (cr, &inner_adjusted); if (!path_only) border_brush->Fill (cr); } if (background && !paint_background.IsEmpty ()) { background->SetupBrush (cr, paint_background); paint_background.Draw (cr, &inner_adjusted); if (!path_only) background->Fill (cr); } cairo_restore (cr); }
Rect Canvas::GetCoverageBounds () { Brush *background = GetBackground (); if (background && background->IsOpaque ()) return coverage_bounds; return Rect (); }
void SoundTest::LoadResources() { GetBackground()->SetColor(Color::White()); sndClick = Sound::CreateFX("~res:/Sounds/click.wav", Sound::TYPE_STATIC); #ifdef __DAVAENGINE_IPHONE__ music = Sound::CreateMusic("~res:/Sounds/map.caf", Sound::TYPE_STREAMED); #else music = Sound::CreateMusic("~res:/Sounds/map.ogg", Sound::TYPE_STREAMED); #endif }
void InfoControl::Draw(const UIGeometricData &geometricData) { UIControl::Draw(geometricData); RenderManager::Instance()->SetColor(GetBackground()->color); RenderHelper::Instance()->DrawRect(geometricData.GetUnrotatedRect()); Rect outerRect(geometricData.GetUnrotatedRect()); outerRect.x -= 1.0f; outerRect.y -= 1.0f; outerRect.dx += 2.0f; outerRect.dy += 2.0f; Color outerColor(GetBackground()->color); outerColor.r = 1.0f - outerColor.r; outerColor.b = 1.0f - outerColor.b; RenderManager::Instance()->SetColor(outerColor); RenderHelper::Instance()->DrawRect(outerRect); RenderManager::Instance()->ResetColor(); }
void CXTPMarkupPanel::OnRender(CXTPMarkupDrawingContext* pDC) { CSize szRender = GetRenderSize(); if (szRender.cx <= 0 || szRender.cy <= 0) return; CXTPMarkupBrush* pBackground = GetBackground(); if (pBackground) { pDC->FillRectangle(CRect(0, 0, szRender.cx, szRender.cy), pBackground); } }
void MpButton::EnterFrame (void) // virtual, half-pressed when entered { bool draw_background = (state & in_pulldown) | (state & highlight); if (draw_background && !(state & entered)) // save background color saveBackground = GetBackground(); state |= entered; if (draw_background) { SetBackground(&Mp.PageColor); // highlight MpCanvas::RedrawPanel(); Draw(); // draw label and/or icon } MpCanvas::DrawFrame( (state & in_pulldown) ? Sunken : (state & highlight) ? GetFrameStyle() : Solid|Framed ); }
void ListBox::Render() { if (IsVisible()) { if (GetBackground()) DrawSquare(); for (uint8 i = 0; i < m_lineNbr; i++) m_lines[i]->Render(); if (m_showButtons) { if (m_upArrow) m_upArrow->Render(); if (m_downArrow) m_downArrow->Render(); } } }
void FormatsTest::LoadResources() { GetBackground()->SetColor(Color(0.0f, 1.0f, 0.0f, 1.0f)); int32 columnCount = 6; int32 rowCount = (FORMAT_COUNT-1) / columnCount; if(0 != FORMAT_COUNT % columnCount) { ++rowCount; } float32 size = Min(GetSize().x / columnCount, GetSize().y / rowCount); Font *font = FTFont::Create("~res:/Fonts/korinna.ttf"); DVASSERT(font); font->SetSize(20); for(int32 i = FORMAT_RGBA8888; i < FORMAT_COUNT; ++i) { int32 y = (i-1) / columnCount; int32 x = (i-1) % columnCount; String formatName = Texture::GetPixelFormatString((PixelFormat)i); UIControl *c = new UIControl(Rect(x*size, y*size, size - 2, size - 2)); c->SetSprite(Format("~res:/TestData/FormatTest/%s/number_0", formatName.c_str()), 0); c->GetBackground()->SetDrawType(UIControlBackground::DRAW_SCALE_TO_RECT); UIStaticText *text = new UIStaticText(Rect(0, c->GetSize().y - 30, c->GetSize().x, 30)); text->SetText(StringToWString(formatName)); text->SetFont(font); text->SetTextColor(Color(1.0f, 1.0f, 1.0f, 1.0f)); c->AddControl(text); AddControl(c); SafeRelease(text); SafeRelease(c); } SafeRelease(font); }
void PVRTest::LoadResources() { GetBackground()->SetColor(Color(0.0f, 1.0f, 0.0f, 1.0f)); Font *font = FTFont::Create("~res:/Fonts/korinna.ttf"); DVASSERT(font); font->SetSize(20); compareResultText = new UIStaticText(Rect(0, 256, 512, 200)); compareResultText->SetAlign(ALIGN_LEFT | ALIGN_VCENTER); compareResultText->SetMultiline(true); compareResultText->SetFont(font); compareResultText->SetTextColor(Color::White); AddControl(compareResultText); SafeRelease(font); }
void Border::Render (Context *ctx, Region *region) { Brush *background = GetBackground (); Brush *border_brush = GetBorderBrush (); CornerRadius radius = *GetCornerRadius (); Thickness thickness = *GetBorderThickness (); Rect paint_border = extents; Rect paint_background = paint_border.GrowBy (-thickness); double m[16]; int x0, y0; if (!background && !border_brush) return; if (paint_border.IsEmpty ()) return; if (border_brush || radius != CornerRadius ()) { cairo_t *cr = ctx->Push (Context::Cairo ()); Render (cr, region); ctx->Pop (); return; } ctx->GetMatrix (m); if (!HasLayoutClip () && Matrix3D::IsIntegerTranslation (m, &x0, &y0)) { Rect r = Rect (paint_background.x + x0, paint_background.y + y0, paint_background.width, paint_background.height); ctx->Push (Context::Clip (r)); background->Paint (ctx, paint_background); ctx->Pop (); } else { cairo_t *cr = ctx->Push (Context::Cairo ()); Render (cr, region); ctx->Pop (); } }
void wxMotifDCImpl::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask ) { wxCHECK_RET( bitmap.IsOk(), "invalid bitmap" ); wxMemoryDC memDC; memDC.SelectObjectAsSource(bitmap); #if 0 // Not sure if we need this. The mask should leave the masked areas as per // the original background of this DC. if (useMask) { // There might be transparent areas, so make these the same colour as this // DC memDC.SetBackground(* GetBackground()); memDC.Clear(); } #endif // 0 DoBlit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), &memDC, 0, 0, wxCOPY, useMask); memDC.SelectObject(wxNullBitmap); }
void ImageSplitterScreen::LoadResources() { GetBackground()->SetColor(Color::White()); }
void HashMapTest::LoadResources() { GetBackground()->SetColor(Color::White()); }
CXTPMarkupInputElement* CXTPMarkupPanel::InputHitTestOverride(CPoint /*point*/) const { return GetBackground() != NULL ? (CXTPMarkupInputElement*)this : NULL; }
void CloneTest::LoadResources() { GetBackground()->SetColor(Color(0.0f, 1.0f, 0.0f, 1.0f)); }
void CCandidateView::OnDraw( /* [in] */ ICanvas* canvas) { if (canvas != NULL) { View::OnDraw(canvas); } mTotalWidth = 0; if (mSuggestions == NULL) return; if (mBgPadding == NULL) { CRect::New(0, 0, 0, 0, (IRect**)&mBgPadding); AutoPtr<IDrawable> bg; GetBackground((IDrawable**)&bg); if (bg != NULL) { Boolean isPadding = FALSE; bg->GetPadding(mBgPadding, &isPadding); } } Int32 x = 0; Int32 count = mSuggestions->GetLength() ; Int32 height = 0; GetHeight(&height); Int32 touchX = mTouchX; Int32 scrollX = 0; GetScrollX(&scrollX); Boolean scrolled = mScrolled; Boolean typedWordValid = mTypedWordValid; Float textSize = 0, ascent = 0; mPaint->GetTextSize((Float*)&textSize); mPaint->Ascent((Float*)&ascent); Int32 y = (Int32) (((height - textSize) / 2) - ascent); Int32 top = 0; mBgPadding->GetTop(&top); for (Int32 i = 0; i < count; i++) { ICharSequence* text = (*mSuggestions)[i]; String suggestion; if (text != NULL) { text->ToString(&suggestion); } Float textWidth = 0; mPaint->MeasureText(suggestion, &textWidth); Int32 wordWidth = (Int32) textWidth + X_GAP * 2; (*mWordX)[i] = x; (*mWordWidth)[i] = wordWidth; mPaint->SetColor(mColorNormal); if (touchX + scrollX >= x && touchX + scrollX < x + wordWidth && !scrolled) { if (canvas != NULL) { canvas->Translate(x, 0); mSelectionHighlight->SetBounds(0, top, wordWidth, height); mSelectionHighlight->Draw(canvas); canvas->Translate(-x, 0); } mSelectedIndex = i; } if (canvas != NULL) { if ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid)) { mPaint->SetFakeBoldText(TRUE); mPaint->SetColor(mColorRecommended); } else if (i != 0) { mPaint->SetColor(mColorOther); } canvas->DrawText(suggestion, x + X_GAP, y, mPaint); mPaint->SetColor(mColorOther); canvas->DrawLine(x + wordWidth + 0.5f, top, x + wordWidth + 0.5f, height + 1, mPaint); mPaint->SetFakeBoldText(FALSE); } x += wordWidth; } mTotalWidth = x; Int32 tmp = 0; GetScrollX(&tmp); if (mTargetScrollX != tmp) { ScrollToTarget(); } }
void MaterialCompilerTest::LoadResources() { GetBackground()->SetColor(Color::White()); }
wxString ButcherProjectAreaConfigBase::GetFlagsDescription() { wxString ret(wxEmptyString), tmp; if (area_->GetAreaClass() == ButcherProjectArea::AC_GLOBAL) ret+=wxT("<G>"); switch (GetAreaKind()) { case AK_NONE: ret+=wxT("N"); break; case AK_IMAGE: ret+=wxT("I"); break; case AK_MASK: ret+=wxT("M"); break; default: ret+=wxT("?"); break; } if (!GetIsDefault()) ret+=wxT("C"); if (GetBackground()) ret+=wxT("B"); if (GetIsBGColor()) ret+=wxT("L"); if (GetImageSource()==IS_LINK) ret+=wxT("K"); if (GetAlternateFile()>-1) ret+=wxT("A"); if (GetInnerScrollable()) ret+=wxT("S"); if (GetVariableSize()) ret+=wxT("Z"); if (GetHaveMap()) ret+=wxT("P"); if (ImageInfo().TransparentColors().size()>0) ret+=wxT("T"); switch (GetAlign()) { case AA_LEFT: ret+=wxT("@L"); break; case AA_CENTER: ret+=wxT("@C"); break; case AA_RIGHT: ret+=wxT("@R"); break; default: break; } switch (GetVAlign()) { case AV_NONE: ret+=wxT("$N"); break; case AV_MIDDLE: ret+=wxT("$M"); break; case AV_BOTTOM: ret+=wxT("$B"); break; default: break; } switch (GetBGRepeat()) { case BR_NONE: ret+=wxT("*N"); break; case BR_HORIZONTAL: ret+=wxT("*H"); break; case BR_VERTICAL: ret+=wxT("*V"); break; default: break; } tmp=wxEmptyString; for (int i=0; i<BUTCHERCONST_VIEW_MAXALTERNATE; i++) { if (altimageinfo_[i]->GetEnabled()) tmp+=wxString::Format(wxT("%d"), i+1); } if (!tmp.IsEmpty()) { ret+=wxT("+"); ret+=tmp; } return ret; }
void EditCtrl::DoCreate( std::shared_ptr< OverlayManager > p_manager ) { std::shared_ptr< TextOverlay > l_text = p_manager->CreateText( _T( "T_CtrlEdit_" ) + StringUtils::ToString( GetId() ), Position(), GetSize(), Material( GetForegroundColour() ), p_manager->GetFont( DEFAULT_FONT_NAME, DEFAULT_FONT_HEIGHT ), GetBackground() ); l_text->SetVAlign( eVALIGN_TOP ); l_text->SetVisible( DoIsVisible() ); if ( ( GetStyle() & eEDIT_STYLE_MULTILINE ) == eEDIT_STYLE_MULTILINE ) { l_text->SetTextWrappingMode( eTEXT_WRAPPING_MODE_BREAK ); } m_text = l_text; DoUpdateCaption(); }