void Button::DrawElement(C4TargetFacet &cgo) { // draw base if (fDown) // pressed DrawBar(cgo, pCustomGfxDown ? *pCustomGfxDown : ::GraphicsResource.barButtonD); else // released DrawBar(cgo, pCustomGfx ? *pCustomGfx : ::GraphicsResource.barButton); // get text pos int32_t x0 = cgo.TargetX + rcBounds.x, y0 = cgo.TargetY + rcBounds.y, x1 = cgo.TargetX + rcBounds.x + rcBounds.Wdt - 1, y1 = cgo.TargetY + rcBounds.y + rcBounds.Hgt - 1; int32_t iTxtOff = fDown ? 1 : 0; // draw selection highlight if (fEnabled) if (HasDrawFocus() || (fMouseOver && IsInActiveDlg(false))) { pDraw->SetBlitMode(C4GFXBLIT_ADDITIVE); ::GraphicsResource.fctButtonHighlight.DrawX(cgo.Surface, x0+5, y0+3, rcBounds.Wdt-10, rcBounds.Hgt-6); pDraw->ResetBlitMode(); } // draw text int32_t iTextHgt = rcBounds.Hgt-2; CStdFont &rUseFont = (::GraphicsResource.TitleFont.GetLineHeight() > iTextHgt ? (::GraphicsResource.CaptionFont.GetLineHeight() > iTextHgt ? ::GraphicsResource.TextFont : ::GraphicsResource.CaptionFont) : ::GraphicsResource.TitleFont); iTextHgt = rUseFont.GetLineHeight(); pDraw->TextOut(sText.getData(), rUseFont, 1.0f, cgo.Surface, (x0+x1)/2 + iTxtOff, (y0+y1-iTextHgt)/2 + iTxtOff, C4GUI_ButtonFontClr, ACenter, true); }
void DrawBox(int sx, int sy, int w, int h, DWORD color) { DrawBar(sx, sy, w, 1, color); DrawBar(sx, sy, 1, h, color); DrawBar(sx+w, sy, 1, h, color); DrawBar(sx, sy+h, w+1, 1, color); }
void DrawAmmoBar( CBasePlayerWeapon *p, int x, int y, int width, int height) { if ( !p ) return; CBasePlayer* pPlayer = g_Prediction.GetLocalPlayer(); if ( auto pAmmo = p->GetWeaponInfo()->GetPrimaryAmmo() ) { if( !pPlayer->CountAmmo( pAmmo->GetID() ) ) return; float f = (float)pPlayer->CountAmmo( pAmmo->GetID() )/(float) pAmmo->GetMaxCarry(); x = DrawBar(x, y, width, height, f); // Do we have secondary ammo too? if ( auto pAmmo2 = p->GetWeaponInfo()->GetSecondaryAmmo() ) { f = (float)pPlayer->CountAmmo( pAmmo2->GetID() )/(float) pAmmo2->GetMaxCarry(); x += 5; //!!! DrawBar(x, y, width, height, f); } } }
// Fill in all the data in the polygon counter dialog. void PolygonCounter::DrawBars() { TSTR buf; int val; GetAppData(thePolyCounter.ip, MAX_POLYS_ID, _T("10000"), buf); if (atoi(buf, val)) thePolyCounter.maxPolys->SetValue(val, FALSE); GetAppData(thePolyCounter.ip, MAX_SELECTED_ID, _T("1000"), buf); if (atoi(buf, val)) thePolyCounter.maxSelected->SetValue(val, FALSE); HWND hName = GetDlgItem(thePolyCounter.hDlg, IDC_POLY_COUNT); TCHAR str[256]; _stprintf(str, _T("%d"), faceCount); Static_SetText(hName, str); hName = GetDlgItem(thePolyCounter.hDlg, IDC_SEL_COUNT); _stprintf(str, _T("%d"), selFaceCount); Static_SetText(hName, str); HWND hPolyBar = GetDlgItem(hDlg, IDC_POLY_BAR); int maxFaces = maxPolys->GetIVal(); DrawBar(hPolyBar, faceCount, maxFaces); HWND hSelBar = GetDlgItem(hDlg, IDC_SELECTED_BAR); int maxSel = maxSelected->GetIVal(); DrawBar(hSelBar, selFaceCount, maxSel); }
bool Button(int x, int y, bool highlight, const char* text, int id) { DWORD color1=0x000000; DWORD color2=0xA09088; DWORD color3=0x000000; bool hover=MouseInBox(x, y, 100, 17); if(hover && mouse_leftclick) vcurbutton=id; bool current=(vcurbutton==id); if(highlight) { color1=0x000000; color2=0x988070; color3=0xFFF0E0; } if(current && hover) { color1=0xA09088; color2=0xFFF0E0; color3=0xA09088; } DrawBar(x-1, y-1, 102, 19, color1); DrawBar(x, y, 100, 17, color2); DrawText(x+5, y+5, color3, text); if(current && hover && !mouse_left) return true; return false; }
void DrawAmmoBar(WEAPON *p, int x, int y, int width, int height) { if(!p) return; if(p->iAmmoType != -1) { if(!gWR.CountAmmo(p->iAmmoType)) return; float f = (float)gWR.CountAmmo(p->iAmmoType) / (float)p->iMax1; x = DrawBar(x, y, width, height, f); // Do we have secondary ammo too? if(p->iAmmo2Type != -1) { f = (float)gWR.CountAmmo(p->iAmmo2Type) / (float)p->iMax2; x += 5; //!!! DrawBar(x, y, width, height, f); } } }
////////////////// // User moved mouse: erase old bar and draw in new position. XOR makes this // easy. Keep track of previous point. // void CSizerBar::OnMouseMove(UINT nFlags, CPoint pt) { if (m_bDragging) { DrawBar(); // erase old bar pt = Constrain(pt); // don't go outside constrained rect! pt = Rectify(pt); // clip x or y depending if horizontal or vert CPoint ptDelta = pt-m_ptPrevious; m_rcBar += ptDelta; // move bar... DrawBar(); // and draw m_ptPrevious = pt; // remember for next mousemove } }
void CEntity::RenderBars() { if( !m_base->m_barsEnabled || !m_bounds || !m_visible) return; SnapToGround(); CVector3D centre = m_graphics_position; centre.Y += m_base->m_barOffset; CVector3D up = g_Game->GetView()->GetCamera()->m_Orientation.GetUp(); CVector3D right = -g_Game->GetView()->GetCamera()->m_Orientation.GetLeft(); float w = m_base->m_barWidth; float h = m_base->m_barHeight; float borderSize = m_base->m_barBorderSize; // Draw the health and stamina bars; if the unit has no stamina, the health bar is // drawn centered, otherwise it's offset slightly up and the stamina bar is offset // slightly down so that they overlap over an area of size borderSize. bool hasStamina = (m_staminaMax > 0); float backgroundW = w+2*borderSize; float backgroundH = hasStamina ? 2*h+2*borderSize : h+2*borderSize; /* ogl_tex_bind( g_Selection.m_unitUITextures[m_base->m_barBorder] ); DrawRect( centre, up, right, -backgroundW/2, -backgroundH/2, backgroundW/2, backgroundH/2 ); */ ogl_tex_bind( 0 ); float off = hasStamina ? h/2 : 0; DrawBar( centre, up, right, -w/2, off-h/2, w/2, off+h/2, SColour(0,1,0), SColour(1,0,0), m_healthCurr, m_healthMax ); if( hasStamina ) { DrawBar( centre, up, right, -w/2, -h, w/2, 0, SColour(0,0,1), SColour(0.4f,0.4f,0.1f), m_staminaCurr, m_staminaMax ); } // Draw the rank icon /* CSelectedEntities::MapFilenameToHandle::iterator it = g_Selection.m_unitUITextures.find( m_rankName ); if( it != g_Selection.m_unitUITextures.end() ) { float size = 2*h + borderSize; ogl_tex_bind( it->second ); DrawRect( centre, up, right, w/2+borderSize, -size/2, w/2+borderSize+size, size/2 ); ogl_tex_bind( 0 ); } */ }
void Block::Draw(HDC hdc) { switch (level) { case LV1 : { ::Rectangle(hdc, ptCollide.x - size * 2, ptCollide.y - size * 2, ptCollide.x + size * 2, ptCollide.y + size * 2); DrawBar(hdc); } break; case LV2 : { ::MoveToEx(hdc, ptCollide.x, ptCollide.y, NULL); ::LineTo(hdc, ptCollide.x, ptCollide.y - size * 2); ::LineTo(hdc, ptCollide.x - size * 2, ptCollide.y - size * 2); ::LineTo(hdc, ptCollide.x - size * 2, ptCollide.y); ::LineTo(hdc, ptCollide.x - size * 2, ptCollide.y + size * 2); ::LineTo(hdc, ptCollide.x, ptCollide.y + size * 2); ::LineTo(hdc, ptCollide.x + size * 2, ptCollide.y + size * 2); ::LineTo(hdc, ptCollide.x + size * 2, ptCollide.y); ::LineTo(hdc, ptCollide.x, ptCollide.y); DrawBar(hdc); } break; case LV3 : { ::Rectangle(hdc, BLT.center.x - size, BLT.center.y - size, BLT.center.x + size, BLT.center.y + size); ::Rectangle(hdc, BRB.center.x - size, BRB.center.y - size, BRB.center.x + size, BRB.center.y + size); DrawBar(hdc); } break; case LV4 : { ::Rectangle(hdc, BLT.center.x - size, BLT.center.y - size, BLT.center.x + size, BLT.center.y + size); DrawBar(hdc); } break; case LV0 : break; default : break; } }
LOCAL void Drag_OnTimer(HWND hWindow, UINT id) /***********************************************************************/ { POINT pt; int iTopItem; RECT rect; LPLISTBOXDATA lpData = ListBox_GetData(hWindow); if (!lpData) return; GetCursorPos(&pt); // convert the point to client coordinates ScreenToClient(hWindow, &pt); iTopItem = ListBox_GetTopIndex(hWindow); GetClientRect(hWindow, &rect); if (pt.y < rect.top) // scroll up { if (iTopItem > 0) { iTopItem--; // undraw the bar before we scroll up DrawBar(hWindow, lpData->iCurPos); // scroll the listbox and make sure it gets repainted ListBox_SetTopIndex(hWindow, iTopItem); UpdateWindow(hWindow); // draw the new one at y = 0 lpData->iCurPos = 0; DrawBar(hWindow, lpData->iCurPos); } } else if (pt.y > rect.bottom) // scroll down { // see if there is anything to scroll if (lpData->iVisible + iTopItem < lpData->iCount) { // undraw the bar before we scroll down DrawBar(hWindow, lpData->iCurPos); // scroll down and make sure it gets repainted iTopItem++; ListBox_SetTopIndex(hWindow, iTopItem); UpdateWindow(hWindow); // always place the bar at the bottom when we scroll down lpData->iCurPos = lpData->iVisible; // draw the new one DrawBar(hWindow, lpData->iCurPos); } } }
void CSSplitter::CancelDrag() { DrawBar(TRUE); ReleaseCapture(); ::SetFocus(m_hwndPrevFocus); m_bDragging = FALSE; }
void KernelMemoryBarMenuItem::DrawContent() { DrawBar(true); Menu()->MovePenTo(ContentLocation()); BMenuItem::DrawContent(); }
void XGProgress::SetValue (long value) { if (value >= fMax) value = fMax; if (value < fMin) value = fMin; if (fValue == value) return; fValue = value; #if OPT_MACOS if (fControl) { XGDraw draw(this, false); ::SetControlValue(fControl, fValue / fScale); return; } #endif #if OPT_WINOS if (fControl) { ::SendMessage(fControl, PBM_SETPOS, fValue / fScale, 0); return; } #endif /* * If we are here, it's either X, or we don't have a control */ XGDraw draw(this); DrawBar(draw); }
////////////////// // Cancel drag mode: release capture, erase bar, restore focus // void CSizerBar::CancelDrag() { DrawBar(); // erase bar ReleaseCapture(); // release mouse ::SetFocus(m_hwndPrevFocus); // restore original focus window m_bDragging = FALSE; // stop dragging }
//********************************************************************************************************* void CProgressBarWidget::HandleAnimate() { if (this->fValue > this->fLastDrawnValue) DrawBar(); //grow bar else if (this->fValue < this->fLastDrawnValue) RequestPaint(); //shrink bar (requires background redraw) }
void BSlider::DrawSlider() { if (LockLooper()) { #if USE_OFF_SCREEN_VIEW if (!fOffScreenBits) return; if (fOffScreenBits->Lock()) { #endif DrawBar(); DrawHashMarks(); DrawThumb(); DrawFocusMark(); DrawText(); #if USE_OFF_SCREEN_VIEW fOffScreenView->Sync(); fOffScreenBits->Unlock(); DrawBitmap(fOffScreenBits, B_ORIGIN); } #endif UnlockLooper(); } }
void MemoryBarMenuItem::BarUpdate() { area_info areaInfo; ssize_t cookie = 0; int64 lram_size = 0; int64 lwram_size = 0; bool exists = false; while (get_next_area_info(fTeamID, &cookie, &areaInfo) == B_OK) { exists = true; lram_size += areaInfo.ram_size; // TODO: this won't work this way anymore under Haiku! // int zone = (int (areaInfo.address) & 0xf0000000) >> 24; if ((areaInfo.protection & B_WRITE_AREA) != 0) lwram_size += areaInfo.ram_size; // && (zone & 0xf0) != 0xA0 // Exclude media buffers // && (fTeamID != gAppServerTeamID || zone != 0x90)) // Exclude app_server side of bitmaps } if (!exists) { team_info info; exists = get_team_info(fTeamID, &info) == B_OK; } if (exists) { fWriteMemory = lwram_size / 1024; fAllMemory = lram_size / 1024; DrawBar(false); } else fWriteMemory = -1; }
void KernelMemoryBarMenuItem::UpdateSituation(float committedMemory, float cachedMemory) { fCommittedMemory = committedMemory; fCachedMemory = cachedMemory; DrawBar(false); }
void FreeSpaceBar::paintEvent(QPaintEvent*) { // Geometry QRect bar_rect(rect()); bar_rect.setHeight(kBarHeight); QRect reflection_rect(bar_rect); reflection_rect.moveTop(reflection_rect.bottom()); QRect labels_rect(rect()); labels_rect.setTop(labels_rect.top() + kBarHeight + kLabelBoxPadding); // Draw the reflection // Create the reflected pixmap QImage reflection(reflection_rect.size(), QImage::Format_ARGB32_Premultiplied); reflection.fill(palette().color(QPalette::Background).rgba()); QPainter p(&reflection); // Set up the transformation QTransform transform; transform.scale(1.0, -1.0); transform.translate(0.0, -reflection.height()); p.setTransform(transform); // Draw the bar DrawBar(&p, QRect(QPoint(0, 0), reflection.size())); // Make it fade out towards the bottom QLinearGradient fade_gradient(reflection.rect().topLeft(), reflection.rect().bottomLeft()); fade_gradient.setColorAt(0.0, QColor(0, 0, 0, 0)); fade_gradient.setColorAt(1.0, QColor(0, 0, 0, 128)); p.setCompositionMode(QPainter::CompositionMode_DestinationIn); p.fillRect(reflection.rect(), fade_gradient); p.end(); // Draw on the widget p.begin(this); DrawBar(&p, bar_rect); p.drawImage(reflection_rect, reflection); DrawText(&p, labels_rect); }
void CSSplitter::OnLButtonDown(UINT nFlags, CPoint point) { m_bDragging = TRUE; m_DragStartPoint = point; m_BarPos = m_SplitterPos; if ( !m_bMouseMoveSplittingMode ) DrawBar(); SetCapture(); m_hwndPrevFocus = ::SetFocus(m_hWnd); ::SetCursor( AfxGetApp()->LoadStandardCursor (LPCTSTR (m_bVertSplitter ? IDC_SIZEWE : IDC_SIZENS))); CWnd::OnLButtonDown(nFlags, point); }
void CFastSplitter::OnMouseMove(UINT nFlags, CPoint point) { if (m_mode == MOD_Normal) { if (m_bDragging || m_SplitterRect.PtInRect(point)) { ::SetCursor( AfxGetApp()->LoadStandardCursor(LPCTSTR (m_bVertSplitter ? IDC_SIZEWE : IDC_SIZENS))); if (m_bDragging) { if (m_bLiveUpdate) { if (m_bVertSplitter) m_SplitterPos = m_BarPos + point.x - m_DragStartPoint.x; else m_SplitterPos = m_BarPos + point.y - m_DragStartPoint.y; MovePanes(); } else { if (m_bVertSplitter) m_BarPos = m_RealSplitterPos + point.x - m_DragStartPoint.x; else m_BarPos = m_RealSplitterPos + point.y - m_DragStartPoint.y; DrawBar(); } } else if (!m_bTracking) { //TRACE(_T("CFastSplitter::OnMouseMove !m_bTracking\r\n")); TRACKMOUSEEVENT tme; tme.cbSize = sizeof(tme); tme.hwndTrack = m_hWnd; tme.dwFlags = TME_LEAVE; tme.dwHoverTime = HOVER_DEFAULT; m_bTracking = _TrackMouseEvent(&tme); HWND hWnd = GetSafeHwnd(); if ((hWnd != NULL) && ::IsWindow (hWnd)) InvalidateRect(&m_SplitterRect); } } else { //TRACE(_T("CFastSplitter::OnMouseMove !m_bDragging !m_bTracking\r\n")); } } CWnd::OnMouseMove(nFlags, point); }
static void DrawColourBar(int playerCol, float x, float y, float first, float second) { float col[4]; int i; renderdata *prd = GetMainAppearance(); for (i = 0; i < 4; i++) { if (display_is_2d(prd)) col[i] = (float) prd->aarColour[playerCol][i]; else col[i] = prd->ChequerMat[playerCol].ambientColour[i]; } DrawBar(col, x, y, first, second); }
void MemoryBarMenuItem::DrawContent() { DrawIcon(); if (fWriteMemory < 0) BarUpdate(); else DrawBar(true); BPoint loc = ContentLocation(); loc.x += 20; Menu()->MovePenTo(loc); BMenuItem::DrawContent(); }
void mxExpressionSlider::redraw() { HWND wnd = (HWND)getHandle(); if ( !wnd ) return; HDC finalDC = GetDC( wnd ); if ( !finalDC ) return; RECT rc; GetClientRect( wnd, &rc ); int w = rc.right - rc.left; int h = rc.bottom - rc.top; HDC dc = CreateCompatibleDC( finalDC ); HBITMAP oldbm, bm; bm = CreateCompatibleBitmap( finalDC, w, h ); oldbm = (HBITMAP)SelectObject( dc, bm ); HBRUSH br = CreateSolidBrush( GetSysColor( COLOR_3DFACE ) ); FillRect( dc, &rc, br ); DeleteObject( br ); DrawTitle( dc ); DrawBar( dc ); // Draw slider for ( int i = ( m_bPaired ? 1 : 0 ); i >= 0 ; i-- ) { DrawThumb( i, dc ); } BitBlt( finalDC, 0, 0, w, h, dc, 0, 0, SRCCOPY ); SelectObject( dc, oldbm ); DeleteObject( bm ); DeleteDC( dc ); ReleaseDC( wnd, finalDC ); ValidateRect( wnd, &rc ); }
void CSSplitter::OnLButtonUp(UINT nFlags, CPoint point) { m_bDragging = FALSE; if ( !m_bMouseMoveSplittingMode ) DrawBar(TRUE); ReleaseCapture(); if (m_bVertSplitter) m_SplitterPos = m_SplitterPos + point.x - m_DragStartPoint.x; else m_SplitterPos = m_SplitterPos + point.y - m_DragStartPoint.y; MovePanes(); ::SetFocus(m_hwndPrevFocus); CWnd::OnLButtonUp(nFlags, point); }
void DrawAmmoBar(WEAPON *p, int x, int y, int width, int height) { if(!p) return; if(p->iAmmoType != -1) { if(!gWR.CountAmmo(p->iAmmoType)) return; float f = (float)gWR.CountAmmo(p->iAmmoType) / (float)p->iMax1; x = DrawBar(x, y, width, height, f); } }
void CColorProgressCtrl::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here // Do not call CProgressCtrl::OnPaint() for painting messages CMemDCPointer pMemDC(&dc); CRect rectClient; CRect rectBar; GetClientRect(rectClient); rectBar = rectClient; float right = (float)m_nCurrentPosition / (float)(m_nUpper) * (float)rectClient.right; rectBar.right = right ; DrawBar(pMemDC,rectClient,rectBar); }
void CFastSplitter::OnLButtonDown(UINT nFlags, CPoint point) { if (m_mode == MOD_Normal) { //CRect splRc = GetSplitterRect(m_SplitterPos); if (m_SplitterRect.PtInRect(point)) { m_bDragging = TRUE; m_DragStartPoint = point; m_BarPos = m_RealSplitterPos; if ( !m_bLiveUpdate) DrawBar(); SetCapture(); m_hwndPrevFocus = ::SetFocus(m_hWnd); ::SetCursor( AfxGetApp()->LoadStandardCursor (LPCTSTR (m_bVertSplitter ? IDC_SIZEWE : IDC_SIZENS))); } } CWnd::OnLButtonDown(nFlags, point); }
void BPose::DrawIcon(BPoint where, BView* view, icon_size which, bool direct, bool drawUnselected) { if (fClipboardMode == kMoveSelectionTo) { view->SetDrawingMode(B_OP_ALPHA); view->SetHighColor(0, 0, 0, 64); // set the level of transparency view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); } else if (direct) view->SetDrawingMode(B_OP_OVER); IconCache::sIconCache->Draw(ResolvedModel(), view, where, fIsSelected && !drawUnselected ? kSelectedIcon : kNormalIcon, which, true); if (fPercent != -1) DrawBar(where, view, which); }
//********************************************************************************************************* void CProgressBarWidget::Paint( //Paint widget area. // //Params: bool bUpdateRect) //(in) If true (default) and destination // surface is the screen, the screen // will be immediately updated in // the widget's rect. { //Draw inset covering entire widget area. SDL_Rect rectInset; GetRect(rectInset); DrawInset(rectInset.x, rectInset.y, rectInset.w, rectInset.h, this->images[0], GetDestSurface()); DrawBar(); this->fLastDrawnValue = this->fValue; if (bUpdateRect) UpdateRect(); }