void wxStaticBox::OnPaint(wxPaintEvent& WXUNUSED(event)) { RECT rc; ::GetClientRect(GetHwnd(), &rc); // draw the entire box in a memory DC wxMemoryDC memdc; wxBitmap bitmap(rc.right, rc.bottom); memdc.SelectObject(bitmap); PaintBackground(memdc, rc); PaintForeground(memdc, rc); // now only blit the static box border itself, not the interior, to avoid // flicker when background is drawn below // // note that it seems to be faster to do 4 small blits here and then paint // directly into wxPaintDC than painting background in wxMemoryDC and then // blitting everything at once to wxPaintDC, this is why we do it like this wxPaintDC dc(this); int borderTop, border; GetBordersForSizer(&borderTop, &border); // top dc.Blit(border, 0, rc.right - border, borderTop, &memdc, border, 0); // bottom dc.Blit(border, rc.bottom - border, rc.right - border, border, &memdc, border, rc.bottom - border); // left dc.Blit(0, 0, border, rc.bottom, &memdc, 0, 0); // right (note that upper and bottom right corners were already part of the // first two blits so we shouldn't overwrite them here to avoi flicker) dc.Blit(rc.right - border, borderTop, border, rc.bottom - borderTop - border, &memdc, rc.right - border, borderTop); // create the region excluding box children AutoHRGN hrgn((HRGN)MSWGetRegionWithoutChildren()); RECT rcWin; ::GetWindowRect(GetHwnd(), &rcWin); ::OffsetRgn(hrgn, -rcWin.left, -rcWin.top); // and also the box itself MSWGetRegionWithoutSelf((WXHRGN) hrgn, rc.right, rc.bottom); wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); HDCClipper clipToBg(GetHdcOf(*impl), hrgn); // paint the inside of the box (excluding box itself and child controls) PaintBackground(dc, rc); }
void NassiDiagramWindow::OnPaint(wxPaintEvent & /*event*/) { wxBufferedPaintDC dc(this); DoPrepareDC(dc); PaintBackground(dc); Draw(dc); }
// // UspAttrTextOut // // Display a line of text previously analyzed with UspAnalyze. The stored // ATTR[] visual-attribute list is used to stylize the text as it is drawn. // // Coloured text-display using Uniscribe is very complicated. // Three passes are required if high-quality text output is the goal. // // Returns: adjusted x-coordinate // int WINAPI UspTextOut ( USPDATA * uspData, HDC hdc, int xpos, int ypos, int lineHeight, int lineAdjustY, RECT * bounds ) { HRGN hrgn, hrgnClip; if(uspData->stringLen == 0 || uspData->glyphCount == 0) return xpos; hrgnClip = CreateRectRgn(0,0,1,1); GetClipRgn(hdc, hrgnClip); // // 1. draw all background colours, including selection-highlights; // selected areas are added to the HDC clipping region which prevents // step#2 (below) from drawing over them // SetBkMode(hdc, OPAQUE); PaintBackground(uspData, hdc, xpos, ypos, lineHeight, bounds); // // 2. draw the text normally. Selected areas are left untouched // because of the clipping-region created in step#1 // SetBkMode(hdc, TRANSPARENT); PaintForeground(uspData, hdc, xpos, ypos + lineAdjustY, bounds, FALSE); // // 3. redraw the text using a single text-selection-colour (i.e. white) // in the same position, directly over the top of the text drawn in step#2 // // Before we do this, the HDC clipping-region is inverted, // so only selection areas are modified this time // hrgn = CreateRectRgnIndirect(bounds); ExtSelectClipRgn(hdc, hrgn, RGN_XOR); SetBkMode(hdc, TRANSPARENT); xpos = PaintForeground(uspData, hdc, xpos, ypos + lineAdjustY, bounds, TRUE); // remove clipping regions SelectClipRgn(hdc, hrgnClip); DeleteObject(hrgn); DeleteObject(hrgnClip); return xpos; }
DJContact::DJContact( DJHallController* hallController, const QString& selfUserName, QWidget * parent ) :QTabWidget( parent ),m_hallController(hallController),m_selfUserName(selfUserName) { djDebug() << "DJContact constructor" << selfUserName; m_selfUserId = 0; m_friendsTree = new QTreeWidget; PaintBackground( m_friendsTree, QPoint(100,0), QPoint(0,100) ); m_friendsTree->setHeaderLabels( QStringList( selfUserName + tr("'s") + tr("friend list") ) ); m_friendsTree->setRootIsDecorated( false ); m_friendsTree->setSortingEnabled( true ); m_friendsTree->setContextMenuPolicy( Qt::CustomContextMenu ); connect(m_friendsTree, SIGNAL(customContextMenuRequested ( const QPoint & )), SLOT( contextMenuOfFriend ( const QPoint & ) ) ); connect(m_friendsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *,int)), SLOT( friendDoubleClicked(QTreeWidgetItem *,int))); m_actRemoveFriend = new QAction( tr("remove"), m_friendsTree ); connect(m_actRemoveFriend, SIGNAL(triggered()),SLOT(removeFriendItem())); m_menuFriend = new QMenu( m_friendsTree ); m_menuFriend->addAction( m_actRemoveFriend ); m_unwelcomesTree = new QTreeWidget; PaintBackground( m_unwelcomesTree, QPoint(100,0), QPoint(0,100) ); m_unwelcomesTree->setHeaderLabels( QStringList( selfUserName + tr("'s") + tr("blacklist") ) ); m_unwelcomesTree->setRootIsDecorated( false ); m_unwelcomesTree->setContextMenuPolicy( Qt::CustomContextMenu ); connect(m_unwelcomesTree, SIGNAL(customContextMenuRequested ( const QPoint & )), SLOT( contextMenuOfUnwelcome ( const QPoint & ) ) ); m_actRemoveUnwelcome = new QAction( tr("remove"), m_unwelcomesTree ); connect(m_actRemoveUnwelcome, SIGNAL(triggered()),SLOT(removeUnwelcomeItem())); m_menuUnwelcome = new QMenu( m_unwelcomesTree ); m_menuUnwelcome->addAction( m_actRemoveUnwelcome ); setTabPosition( QTabWidget::North ); addTab( m_friendsTree, tr("friend") ); addTab( m_unwelcomesTree, tr("blacklist") ); m_timer = new QTimer(this); connect(m_timer, SIGNAL(timeout()), this, SLOT(checkPendingChats())); m_timer->start(1000); m_toggle = true; }
void CCheckListBoxItem::Paint(COwnerDrawListBox* pList, LPDRAWITEMSTRUCT pDrawItemStruct) { // Get the DC and rectangle to use. CDC* pDC = CDC::FromHandle(pDrawItemStruct->hDC); if (pDC != NULL) { // Get the colors to use. COLORREF clForeground; COLORREF clBackground; COLORREF clCheckBorder; COLORREF clCheckBackground; COLORREF clCheck; ComputeColors(pList, pDC, pDrawItemStruct, clForeground, clBackground, clCheckBorder, clCheckBackground, clCheck); // Compute the bounding rectangles for the check box and the item. CRect crCheckBox; CRect crItem; ComputeBounds(pList, pDC, pDrawItemStruct, crCheckBox, crItem); // Draw the background. PaintBackground(pList, pDC, pDrawItemStruct, clBackground); // Draw the checkbox. PaintCheckBox(pList, pDC, pDrawItemStruct, crCheckBox, clCheckBorder, clCheckBackground, clCheck); // Draw the item. PaintItem(pList, pDC, pDrawItemStruct, crItem, clForeground, clBackground); // If the item has the focus, draw the focus indicator. if (IsFocused(pList, pDrawItemStruct)) { PaintFocus(pList, pDC, pDrawItemStruct); } } }
void CXySlider::OnPaint() { Initialize(); int w = m_rcAll.Width(); int h = m_rcAll.Height(); CPaintDC dc(this); CDC dcmem; dcmem.CreateCompatibleDC(&dc); CBitmap bm; bm.CreateCompatibleBitmap(&dc, w, h); CSelectObject sobm(&dcmem, &bm); PaintBackground(&dcmem); // PaintValues(&dcmem); This is too noisy PaintGripper(&dcmem); dc.BitBlt(0, 0, w, h, &dcmem, 0, 0, SRCCOPY); }
/// Painting void InstanceCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxBufferedPaintDC dc(this, m_bufferBitmap); PrepareDC(dc); if (m_freezeCount > 0) return; // Paint the background PaintBackground(dc); if (GetCount() == 0) return; wxRegion dirtyRegion = GetUpdateRegion(); bool isFocused = (FindFocus() == this); int i; int count = GetCount(); int style = 0; wxRect rect, untransformedRect; for (i = 0; i < count; i++) { GetGroupRect(i, rect); wxRegionContain c = dirtyRegion.Contains(rect); if (c != wxOutRegion) { style = 0; GetGroupRect(i, untransformedRect, false); GroupVisual & gv = m_groups[i]; gv.Draw(dc, this, untransformedRect, m_selectedItem.groupIndex == i, m_selectedItem.itemIndex, m_focusItem.groupIndex == i, m_focusItem.itemIndex, i == highlightedGroup.groupIndex); } } }
void DlgOptionsChart::OnPaint() { CPaintDC dc(this); // device context for painting // get image rect CRect rect; GetDlgItem(IDC_PREVIEW)->GetWindowRect(&rect); ScreenToClient(&rect); rect.DeflateRect(16,4); rect.top+=12; // fill chart background PaintBackground(&dc,rect); // fill colors _PaintColor(&dc,IDC_COLOR_MAPNAME,0); _PaintColor(&dc,IDC_COLOR_PLAYERNAME,1); _PaintColor(&dc,IDC_COLOR_OTHER,2); _PaintColor(&dc,IDC_COLOR_CHART,CLR_CHART_MIN+m_comboType); // print test text for(int i=0;i<_CLRMAX; i++) _PaintText(&dc,rect,i); }
LRESULT WinControl::StartPaint(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { #ifndef USE_GDI if ( SUCCEEDED(CreateDeviceDependantResources() ) ) { if (0 == (D2D1_WINDOW_STATE_OCCLUDED & pRT_->CheckWindowState())) { PAINTSTRUCT ps; ::BeginPaint(GetHandle(), &ps); pBackRT_->BeginDraw(); pBackRT_->SetTransform(D2D1::Matrix3x2F::Identity()); PaintBackground(); OnRender(); pBackRT_->EndDraw(); PaintFrontBuffer(); ::EndPaint(GetHandle(), &ps); } } #else // Get whether there is a valid update Region RECT updateRect; if (!::GetUpdateRect(hwnd, &updateRect, FALSE)) return 0; // Start doing the painting PAINTSTRUCT ps; HDC hdcReal = ::BeginPaint(hwnd, &ps); if (!hdcReal) return 0; // Check that we have a buffer and if not, create one if (!hdcBack_) { RECT rcClient; GetClientRect(&rcClient); hdcBack_ = ::CreateCompatibleDC(hdcReal); hbmBack_ = ::CreateCompatibleBitmap(hdcReal, rcClient.right, rcClient.bottom); hbmOld_ = (HBITMAP) ::SelectObject(hdcBack_, hbmBack_); } // Now our subclass needs to do it's own drawing for the controls to it's back buffer if ( NeedRepaint_ ) { // If there is a parent window then we need to bitblt the contents of the area that the child is over to it's backbuffer if ( pParent_ ) { RECT rcClient; GetClientRect(&rcClient); POINT pos = GetPosition(); // Copy the parents background to the childs backbuffer ::BitBlt(hdcBack_, 0, 0, rcClient.right, rcClient.bottom, pParent_->hdcBack_, pos.x, pos.y, SRCCOPY); } OnRender(); NeedRepaint_ = false; } // Now we need to draw our backbuffer to our front buffer ::BitBlt(hdcReal, updateRect.left, updateRect.top, updateRect.right - updateRect.left, updateRect.bottom - updateRect.top, hdcBack_, updateRect.left, updateRect.top, SRCCOPY); ::EndPaint(hwnd, &ps); #endif return 0; }
void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) { wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(*impl), 0); // when using XP themes, neither setting the text colour nor transparent // background mode doesn't change anything: the static box def window proc // still draws the label in its own colours, so we need to redraw the text // ourselves if we have a non default fg colour if ( m_hasFgCol && wxUxThemeEngine::GetIfActive() ) { // draw over the text in default colour in our colour HDC hdc = GetHdcOf(*impl); ::SetTextColor(hdc, GetForegroundColour().GetPixel()); const bool rtl = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft; if ( rtl ) ::SetTextAlign(hdc, TA_RTLREADING | TA_RIGHT); // Get dimensions of the label const wxString label = GetLabel(); // choose the correct font AutoHFONT font; SelectInHDC selFont; if ( m_hasFont ) { selFont.Init(hdc, GetHfontOf(GetFont())); } else // no font set, use the one set by the theme { wxUxThemeHandle hTheme(this, L"BUTTON"); if ( hTheme ) { wxUxThemeFont themeFont; if ( wxUxThemeEngine::Get()->GetThemeFont ( hTheme, hdc, BP_GROUPBOX, GBS_NORMAL, TMT_FONT, themeFont.GetPtr() ) == S_OK ) { font.Init(themeFont.GetLOGFONT()); if ( font ) selFont.Init(hdc, font); } } } // Get the font extent int width, height; dc.GetTextExtent(wxStripMenuCodes(label, wxStrip_Mnemonics), &width, &height); int x; int y = height; // first we need to correctly paint the background of the label // as Windows ignores the brush offset when doing it // // FIXME: value of x is hardcoded as this is what it is on my system, // no idea if it's true everywhere RECT dimensions = {0, 0, 0, y}; if ( !rtl ) { x = 9; dimensions.left = x; dimensions.right = x + width; } else { x = rc.right - 7; dimensions.left = x - width; dimensions.right = x; } // need to adjust the rectangle to cover all the label background dimensions.left -= 2; dimensions.right += 2; dimensions.bottom += 2; if ( UseBgCol() ) { // our own background colour should be used for the background of // the label: this is consistent with the behaviour under pre-XP // systems (i.e. without visual themes) and generally makes sense wxBrush brush = wxBrush(GetBackgroundColour()); wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); ::FillRect(GetHdcOf(*impl), &dimensions, GetHbrushOf(brush)); } else // paint parent background { PaintBackground(dc, dimensions); } UINT drawTextFlags = DT_SINGLELINE | DT_VCENTER; // determine the state of UI queues to draw the text correctly under XP // and later systems static const bool isXPorLater = wxGetWinVersion() >= wxWinVersion_XP; if ( isXPorLater ) { if ( ::SendMessage(GetHwnd(), WM_QUERYUISTATE, 0, 0) & UISF_HIDEACCEL ) { drawTextFlags |= DT_HIDEPREFIX; } } // now draw the text if ( !rtl ) { RECT rc2 = { x, 0, x + width, y }; ::DrawText(hdc, label.t_str(), label.length(), &rc2, drawTextFlags); } else // RTL { RECT rc2 = { x, 0, x - width, y }; ::DrawText(hdc, label.t_str(), label.length(), &rc2, drawTextFlags | DT_RTLREADING); } } }
void Display::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { PaintBackground(w, r, q, ink, paper, style); Single<StdDisplayClass>().Paint0(w, r, q, ink, paper, style); }
void StdDisplayClass::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword s) const { LLOG("StdDisplay::Paint: " << q << " ink:" << ink << " paper:" << paper); PaintBackground(w, r, q, ink, paper, s); Paint0(w, r, q, ink, paper, s); }
void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) { wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(*impl), 0); // when using XP themes, neither setting the text colour nor transparent // background mode doesn't change anything: the static box def window proc // still draws the label in its own colours, so we need to redraw the text // ourselves if we have a non default fg colour if ( m_hasFgCol && wxUxThemeEngine::GetIfActive() ) { // draw over the text in default colour in our colour HDC hdc = GetHdcOf(*impl); ::SetTextColor(hdc, GetForegroundColour().GetPixel()); const bool rtl = wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft; if ( rtl ) ::SetTextAlign(hdc, TA_RTLREADING | TA_RIGHT); // Get dimensions of the label const wxString label = GetLabel(); // choose the correct font AutoHFONT font; SelectInHDC selFont; if ( m_hasFont ) { selFont.Init(hdc, GetHfontOf(GetFont())); } else // no font set, use the one set by the theme { wxUxThemeHandle hTheme(this, L"BUTTON"); if ( hTheme ) { // GetThemeFont() expects its parameter to be LOGFONTW and not // LOGFONTA even in ANSI programs and will happily corrupt // memory after the struct end if we pass a LOGFONTA (which is // smaller) to it! LOGFONTW lfw; if ( wxUxThemeEngine::Get()->GetThemeFont ( hTheme, hdc, BP_GROUPBOX, GBS_NORMAL, TMT_FONT, (LOGFONT *)&lfw ) == S_OK ) { #if wxUSE_UNICODE // ok, no conversion necessary const LOGFONT& lf = lfw; #else // !wxUSE_UNICODE // most of the fields are the same in LOGFONTA and LOGFONTW LOGFONT lf; memcpy(&lf, &lfw, sizeof(lf)); // but the face name must be converted WideCharToMultiByte(CP_ACP, 0, lfw.lfFaceName, -1, lf.lfFaceName, sizeof(lf.lfFaceName), NULL, NULL); #endif // wxUSE_UNICODE/!wxUSE_UNICODE font.Init(lf); if ( font ) selFont.Init(hdc, font); } } } // Get the font extent int width, height; dc.GetTextExtent(wxStripMenuCodes(label, wxStrip_Mnemonics), &width, &height); int x; int y = height; // first we need to correctly paint the background of the label // as Windows ignores the brush offset when doing it // // FIXME: value of x is hardcoded as this is what it is on my system, // no idea if it's true everywhere RECT dimensions = {0, 0, 0, y}; if ( !rtl ) { x = 9; dimensions.left = x; dimensions.right = x + width; } else { x = rc.right - 7; dimensions.left = x - width; dimensions.right = x; } // need to adjust the rectangle to cover all the label background dimensions.left -= 2; dimensions.right += 2; dimensions.bottom += 2; if ( UseBgCol() ) { // our own background colour should be used for the background of // the label: this is consistent with the behaviour under pre-XP // systems (i.e. without visual themes) and generally makes sense wxBrush brush = wxBrush(GetBackgroundColour()); wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); ::FillRect(GetHdcOf(*impl), &dimensions, GetHbrushOf(brush)); } else // paint parent background { PaintBackground(dc, dimensions); } // now draw the text if ( !rtl ) { RECT rc2 = { x, 0, x + width, y }; ::DrawText(hdc, label.wx_str(), label.length(), &rc2, DT_SINGLELINE | DT_VCENTER); } else // RTL { RECT rc2 = { x, 0, x - width, y }; ::DrawText(hdc, label.wx_str(), label.length(), &rc2, DT_SINGLELINE | DT_VCENTER | DT_RTLREADING); } } }
/** SWidget interface */ virtual int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const override { // First paint the background { LayerId = PaintBackground(AllottedGeometry, MyClippingRect, OutDrawElements, LayerId); LayerId++; } FArrangedChildren ArrangedChildren(EVisibility::Visible); ArrangeChildren(AllottedGeometry, ArrangedChildren); // Draw the child nodes // When drawing a marquee, need a preview of what the selection will be. const auto* SelectionToVisualize = &(SelectionManager.SelectedNodes); FGraphPanelSelectionSet SelectionPreview; if (Marquee.IsValid()) { ApplyMarqueeSelection(Marquee, SelectionManager.SelectedNodes, SelectionPreview); SelectionToVisualize = &SelectionPreview; } int32 NodesLayerId = LayerId; for (int32 ChildIndex = 0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex) { FArrangedWidget& CurWidget = ArrangedChildren[ChildIndex]; TSharedRef<SWorldTileItem> ChildNode = StaticCastSharedRef<SWorldTileItem>(CurWidget.Widget); ChildNode->bAffectedByMarquee = SelectionToVisualize->Contains(ChildNode->GetObjectBeingDisplayed()); LayerId = CurWidget.Widget->Paint(Args.WithNewParent(this), CurWidget.Geometry, MyClippingRect, OutDrawElements, NodesLayerId, InWidgetStyle, ShouldBeEnabled(bParentEnabled)); ChildNode->bAffectedByMarquee = false; } // Draw editable world bounds if (!WorldModel->IsSimulating()) { float ScreenSpaceSize = FLevelCollectionModel::EditableAxisLength()*GetZoomAmount()*2.f; FVector2D PaintSize = FVector2D(ScreenSpaceSize, ScreenSpaceSize); FVector2D PaintPosition = GraphCoordToPanelCoord(FVector2D::ZeroVector) - (PaintSize*0.5f); float Scale = 0.2f; // Scale down drawing border FSlateLayoutTransform LayoutTransform(Scale, AllottedGeometry.GetAccumulatedLayoutTransform().GetTranslation() + PaintPosition); FSlateRenderTransform RenderTransform(Scale, AllottedGeometry.GetAccumulatedRenderTransform().GetTranslation() + PaintPosition); FPaintGeometry EditableArea(LayoutTransform, RenderTransform, PaintSize/Scale); FLinearColor PaintColor = FLinearColor::Yellow; PaintColor.A = 0.4f; FSlateDrawElement::MakeBox( OutDrawElements, ++LayerId, EditableArea, FEditorStyle::GetBrush(TEXT("Graph.CompactNode.ShadowSelected")), MyClippingRect, ESlateDrawEffect::None, PaintColor ); } // Draw the marquee selection rectangle PaintMarquee(AllottedGeometry, MyClippingRect, OutDrawElements, ++LayerId); // Draw the software cursor PaintSoftwareCursor(AllottedGeometry, MyClippingRect, OutDrawElements, ++LayerId); if(WorldModel->IsSimulating()) { // Draw a surrounding indicator when PIE is active, to make it clear that the graph is read-only, etc... FSlateDrawElement::MakeBox( OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(), FEditorStyle::GetBrush(TEXT("Graph.PlayInEditor")), MyClippingRect ); } // Draw observer location { FVector ObserverPosition; FRotator ObserverRotation; if (WorldModel->GetObserverView(ObserverPosition, ObserverRotation)) { FVector2D ObserverPositionScreen = GraphCoordToPanelCoord(FVector2D(ObserverPosition.X, ObserverPosition.Y)); const FSlateBrush* CameraImage = FEditorStyle::GetBrush(TEXT("WorldBrowser.SimulationViewPositon")); FPaintGeometry PaintGeometry = AllottedGeometry.ToPaintGeometry( ObserverPositionScreen - CameraImage->ImageSize*0.5f, CameraImage->ImageSize ); FSlateDrawElement::MakeRotatedBox( OutDrawElements, ++LayerId, PaintGeometry, CameraImage, MyClippingRect, ESlateDrawEffect::None, FMath::DegreesToRadians(ObserverRotation.Yaw), CameraImage->ImageSize*0.5f, FSlateDrawElement::RelativeToElement ); } FVector PlayerPosition; FRotator PlayerRotation; if (WorldModel->GetPlayerView(PlayerPosition, PlayerRotation)) { FVector2D PlayerPositionScreen = GraphCoordToPanelCoord(FVector2D(PlayerPosition.X, PlayerPosition.Y)); const FSlateBrush* CameraImage = FEditorStyle::GetBrush(TEXT("WorldBrowser.SimulationViewPositon")); FPaintGeometry PaintGeometry = AllottedGeometry.ToPaintGeometry( PlayerPositionScreen - CameraImage->ImageSize*0.5f, CameraImage->ImageSize ); FSlateDrawElement::MakeRotatedBox( OutDrawElements, ++LayerId, PaintGeometry, CameraImage, MyClippingRect, ESlateDrawEffect::None, FMath::DegreesToRadians(PlayerRotation.Yaw), CameraImage->ImageSize*0.5f, FSlateDrawElement::RelativeToElement, FLinearColor(FColorList::Orange) ); } } LayerId = PaintScaleRuler(AllottedGeometry, MyClippingRect, OutDrawElements, LayerId); return LayerId; }
int main() { int numEnemy = 5; Enemy E[8]; pthread_t tid; //inisialisasi init(); PaintBackground(); initTargetPoint(&TP); setTarget(&TP,140,600); //pindahkan target int i; for(i = 0 ; i < numEnemy; i++) { makeEnemy(1300, i*60+30, &(E[i])); } pthread_create(&tid, NULL, inputHandler, NULL); drawTank(); while(stop == 0) { //cek collision int i; for(i = 0; i < numEnemy; i++) { int collide = detectCollision(B, E[i]); if(collide) { PaintEnemy(getEnemyPosX(E[i]), getEnemyPosY(E[i]), 0, 0, 0); PaintBomb(getPosX(B), getPosY(B), 0,0,0); setActive(&B, 0); makeEnemy(1300, i*60+30, &(E[i])); } } //gerakkan objek & gambar //enemy for(i = 0; i < numEnemy; i++) { moveEnemy(&E[i]); if(getEnemyPosX(E[i]) <= 10) { PaintEnemy(getEnemyPosX(E[i]), getEnemyPosY(E[i]), 0, 0, 0); makeEnemy(1300, i*60+30, &(E[i])); } else { PaintEnemy(getEnemyPosX(E[i]), getEnemyPosY(E[i]), 230, 80, 30); } } //gerakkan & gambar bom jika bom aktif if(isActive(B)) { nextStep(&B); if(getPosX(B) < 0 || getPosX(B) > 1340 || getPosY(B) < 10 || getPosY(B) > 740) { setActive(&B,0); PaintBomb(getPosX(B), getPosY(B), 0,0,0); } else { PaintBomb(getPosX(B), getPosY(B), 211,211,211); } } //render gambar usleep(1000); for(i = 0; i < numEnemy; i++) { clearEnemy(getEnemyPosX(E[i]), getEnemyPosY(E[i])); } if(isActive(B)) { PaintBomb(getPosX(B), getPosY(B), 0,0,0); } usleep(1000); } pthread_join(tid, NULL); //mapping memory munmap(fbp, screensize); close(fbfd); return 0; }
// Should be called from WM_PAINT. Recursively paints a given window and // all its children. Control must be the top-level window associated // with HWND. // Note: maybe should be split into BeginPaint()/Paint()/EndPaint() // calls so that the caller can do more drawing after Paint() void Painter::Paint(HWND hwnd, bool isDirty) { CrashAlwaysIf(hwnd != wnd->hwndParent); PAINTSTRUCT ps; HDC dc = BeginPaint(hwnd, &ps); Region clip; // TODO: be intelligent about only repainting changed // parts for perf. Note: if cacheBmp changes, we need // to repaint everything Graphics gDC(dc); gDC.GetClip(&clip); ClientRect r(hwnd); // TODO: fix showing black parts when resizing a window. // my theory is that we see black background on right/bottom // of the window when we resize the window because the os paints // it black and we take too long to perform the whole paint so the // black part persists long enough for human eye to notice. // To fix that we could try to paint the black part immediately // to gDC using the same color as the background. This is problematic // for two reasons: // - I don't know which part exactly needs to be repainted // - it can be tricky if background is a gradient // I thought I could just do PaintBackground(&gDC, Rect(0, 0, r.dx, r.dy)) // but that generates flickr which leads me to believe that either // Graphics::FillRectangle() ignores clip region or clip region is not set // properly. Current solution detects a resize, paints a background and the // last version of page, which somewhat eliminates the problem but also // sometimes causes flickr // See http://www.catch22.net/tuts/flicker for info on win repainting if (cacheBmp && !sizeDuringLastPaint.Equals(Size(r.dx, r.dy))) { PaintBackground(&gDC, Rect(0, 0, r.dx, r.dy)); gDC.DrawImage(cacheBmp, 0, 0); sizeDuringLastPaint = Size(r.dx, r.dy); } if (BitmapNotBigEnough(cacheBmp, r.dx, r.dy)) { ::delete cacheBmp; cacheBmp = ::new Bitmap(r.dx, r.dy, &gDC); isDirty = true; } //TODO: log clipBounds for debugging //Rect clipBounds; //clip.GetBounds(&cliBounds) // draw to a bitmap cache unless we were asked to skip // this step and just blit cached bitmap because the caller // knows it didn't change if (isDirty) { Graphics g((Image*)cacheBmp); InitGraphicsMode(&g); g.SetClip(&clip, CombineModeReplace); PaintBackground(&g, Rect(0, 0, r.dx, r.dy)); PaintWindowsInZOrder(&g, wnd); } // TODO: try to manually draw only the part that falls within // clipBounds or is it done automatically by DrawImage() ? gDC.DrawImage(cacheBmp, 0, 0); EndPaint(hwnd, &ps); }