void GraphicsMisc::DrawGlass(CDC* pDC, LPCRECT pRect, COLORREF crFrom, COLORREF crTo, BOOL bHorz, int nBorder) { CRect rBarFrom(pRect), rBarTo(pRect); if (bHorz) { rBarFrom.right = rBarFrom.left + (rBarFrom.Width() * 2 / 5); rBarTo.left = rBarFrom.right; } else // vert { rBarFrom.bottom = rBarFrom.top + (rBarFrom.Height() * 2 / 5); rBarTo.top = rBarFrom.bottom; } DrawGradient(pDC, rBarFrom, Lighter(crFrom, 0.2), crFrom, bHorz, -1); DrawGradient(pDC, rBarTo, crTo, Lighter(crTo, 0.2), bHorz, -1); if (nBorder >= 0) { // draw a border in from the edge CRect rBorder(pRect); rBorder.DeflateRect(nBorder, nBorder); DrawRect(pDC, rBorder, CLR_NONE, crFrom); } }
void CEZSnakeCtrl::OnPaint() { PROC_TRACE; CPaintDC dc(this); CDC *pdc; pdc = &dc; CRect rect,rcLeft,rcRight,rcSnake; GetClientRect(&rect); rcLeft.CopyRect(&rect); rcRight.CopyRect(&rect); rcSnake.CopyRect(&rect); float nTailpos=(float)m_nTail/(float)m_nMax*(float)rect.right; float nHeadpos=(float)m_nPos/(float)m_nMax*(float)rect.right; rcSnake.left=(long)(m_bReverse?nHeadpos:nTailpos); rcSnake.right=(long)(m_bReverse?nTailpos:nHeadpos); rcLeft.right=rcSnake.left; rcRight.left=rcSnake.right; DrawGradient(pdc,rcSnake); CBrush brush; VERIFY(brush.CreateSolidBrush(m_clrBk)); pdc->FillRect(&rcLeft, &brush); pdc->FillRect(&rcRight,&brush); VERIFY(brush.DeleteObject()); // Do not call CStatic::OnPaint() for painting messages }
void CProgressCtrlX::DrawMultiGradient(const CDrawInfo& info, const CRect &rcGrad, const CRect &rcClip) { int nSteps = m_ardwGradColors.GetSize()-1; float nWidthPerStep = (float)rcGrad.Width() / nSteps; CRect rcGradBand(rcGrad); for (int i = 0; i < nSteps; i++) { rcGradBand.left = rcGrad.left + (int)(nWidthPerStep * i); rcGradBand.right = rcGrad.left + (int)(nWidthPerStep * (i+1)); if(i == nSteps-1) //last step (because of problems with float) rcGradBand.right = rcGrad.right; if(rcGradBand.right < rcClip.left) continue; // skip - band before cliping rect CRect rcClipBand(rcGradBand); if(rcClipBand.left < rcClip.left) rcClipBand.left = rcClip.left; if(rcClipBand.right > rcClip.right) rcClipBand.right = rcClip.right; DrawGradient(info, rcGradBand, rcClipBand, m_ardwGradColors[i], m_ardwGradColors[i+1]); if(rcClipBand.right == rcClip.right) break; // stop filling - next band is out of clipping rect } }
void GraphicsMisc::DrawVertLine(CDC* pDC, int nYFrom, int nYTo, int nXPos, COLORREF crFrom, COLORREF crTo) { CRect rLine(nXPos, nYFrom, nXPos + 1, nYTo); if ((crFrom == crTo) || (crTo == CLR_NONE)) pDC->FillSolidRect(rLine, crFrom); else DrawGradient(pDC, rLine, crFrom, crTo, FALSE, -1); }
void GraphicsMisc::DrawHorzLine(CDC* pDC, int nXFrom, int nXTo, int nYPos, COLORREF crFrom, COLORREF crTo) { CRect rLine(nXFrom, nYPos, nXTo, nYPos + 1); if ((crFrom == crTo) || (crTo == CLR_NONE)) pDC->FillSolidRect(rLine, crFrom); else DrawGradient(pDC, rLine, crFrom, crTo, TRUE, -1); }
void CSideBarCtrl::OnPaint() { CPaintDC dc(this); // device context for painting CRect rcClient; GetClientRect(rcClient); DrawGradient(&dc, rcClient, RGB(0,0,0), RGB(0,255,0), TRUE ); int oldBkMode = dc.SetBkMode(TRANSPARENT); HFONT oldFont = (HFONT)dc.SelectObject( (HFONT)::GetStockObject(ANSI_VAR_FONT) ); COLORREF oldTextColor = dc.SetTextColor( RGB(0,204,0) ); // // Bottom Text // CString str; GetWindowText(str); CRect rcText = rcClient; rcText.DeflateRect(3,3); dc.DrawText( str, rcText, DT_BOTTOM|DT_CENTER|DT_SINGLELINE ); rcText.OffsetRect(-1,-1); dc.SetTextColor( RGB(0,0,0) ); dc.DrawText( str, rcText, DT_BOTTOM|DT_CENTER|DT_SINGLELINE ); // // Top Text // CFont fntBold; LOGFONT lf = {0}; ::GetObject((HFONT)::GetStockObject(ANSI_VAR_FONT),sizeof(LOGFONT),&lf); lf.lfWeight = FW_SEMIBOLD; fntBold.CreateFontIndirect(&lf); dc.SelectObject(fntBold); dc.SetTextColor(RGB(255,255,255)); dc.DrawText("\nGameSpy\n\n\"PeerLobby\"\n\nSample\nApplication",-1,rcClient,DT_CENTER); // // Cleanup // dc.SetTextColor(oldTextColor); dc.SetBkMode(oldBkMode); dc.SelectObject(oldFont); fntBold.DeleteObject(); }
int SKY_BOX::draw_color_ref(int i) { if (i != 0) return 0; update_position(); // XXX - probably wrong... return DrawGradient(VIEW::peek()); }
void CGradientProgressCtrl::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here CRect rectClient; GetClientRect(&rectClient); // If the current positionis invalid then we should fade into the background if (m_nCurrentPosition < m_nLower || m_nCurrentPosition > m_nUpper) { CRect rect; GetClientRect(rect); CBrush brush; brush.CreateSolidBrush(::GetSysColor(COLOR_3DFACE)); dc.FillRect(&rect, &brush); VERIFY(brush.DeleteObject()); return; } // The actions to take depend on whether or not we are a vertical control DWORD dwStyles = GetStyle(); BOOL bVertical = (BOOL)(dwStyles & PBS_VERTICAL); // Figure out what part should be visible so we can stop the gradient when needed float maxWidth; if (bVertical) maxWidth = ((float)m_nCurrentPosition/(float)m_nUpper * (float)rectClient.bottom); else maxWidth = ((float)m_nCurrentPosition/(float)m_nUpper * (float)rectClient.right); // Draw the gradient DrawGradient(&dc, rectClient, (int)maxWidth, bVertical); // Show percent indicator if needed if (m_bShowPercent) { CString strPercent; float fp = 100.0f; fp *= (float)(m_nCurrentPosition-m_nLower); fp /= (float)(m_nUpper-m_nLower); strPercent.Format(_T("%ld/%ld"), m_nCurrentPosition, m_nUpper); dc.SetTextColor(m_clrText); dc.SetBkMode(TRANSPARENT); dc.DrawText(strPercent, &rectClient, DT_VCENTER | DT_CENTER | DT_SINGLELINE); } // Do not call CProgressCtrl::OnPaint() for painting messages }
void GraphicsMisc::DrawGlassWithGradient(CDC* pDC, LPCRECT pRect, COLORREF crFrom, COLORREF crTo, BOOL bHorz, int nBorder) { // draw the glass first CRect rBarFrom(pRect), rBarTo(pRect); if (bHorz) { rBarFrom.right = rBarFrom.left + (rBarFrom.Width() * 2 / 10); rBarTo.left = rBarTo.right - (rBarTo.Width() * 4 / 10); } else // vert { rBarFrom.bottom = rBarFrom.top + (rBarFrom.Height() * 2 / 10); rBarTo.top = rBarTo.bottom - (rBarTo.Height() * 4 / 10); } pDC->FillSolidRect(rBarFrom, crFrom); pDC->FillSolidRect(rBarTo, crTo); // then the gradient CRect rGrad(pRect); if (bHorz) { rGrad.left = rBarFrom.right; rGrad.right = rBarTo.left; } else { rGrad.top = rBarFrom.bottom; rGrad.bottom = rBarTo.top; } DrawGradient(pDC, rGrad, crFrom, crTo, bHorz, -1); // no border if (nBorder >= 0) { // draw a border in from the edge CRect rBorder(pRect); rBorder.DeflateRect(nBorder, nBorder); DrawRect(pDC, rBorder, CLR_NONE, crFrom); } }
void CStaticStatusBar::DrawSep(CDC *pDC, LPCRECT lpRect) { int top = lpRect->top + 4; int bottom = lpRect->bottom - 2; ASSERT(bottom > top); if(bottom <= top) { return; } CRect rcSep; rcSep.left = lpRect->left; rcSep.top = top; rcSep.right = rcSep.left + 1; rcSep.bottom = bottom; DrawGradient(pDC, rcSep, m_crBorderSepStart, m_crBorderSepEnd, FALSE, rcSep.Height()); pDC->FillSolidRect(lpRect->left + 1, top, 1, bottom - top, RGB(255, 255, 255)); }
BOOL GraphicsMisc::DrawGradient(GM_GRADIENT nType, CDC* pDC, LPCRECT pRect, COLORREF crFrom, COLORREF crTo, BOOL bHorz, int nBorder) { switch (nType) { case GMG_GRADIENT: DrawGradient(pDC, pRect, crFrom, crTo, bHorz, nBorder); return TRUE; case GMG_GLASS: DrawGlass(pDC, pRect, crFrom, crTo, bHorz, nBorder); return TRUE; case GMG_GLASSWITHGRADIENT: DrawGlassWithGradient(pDC, pRect, crFrom, crTo, bHorz, nBorder); return TRUE; } // all the rest ASSERT(0); return FALSE; }
void CTTCheckBtnGroup::OnPaint() { CPaintDC dc(this); CRect clientRect; GetClientRect(clientRect); if (clientRect.Width() <= 0 || clientRect.Height() <= 0) return; CMemDC memDC(dc, clientRect); CDC* pDC = &memDC.GetDC(); DrawThemeParentBackground(GetSafeHwnd(), memDC.GetDC().GetSafeHdc(), clientRect); Graphics graphics(pDC->GetSafeHdc()); graphics.SetSmoothingMode(SmoothingModeAntiAlias); graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic); graphics.SetTextRenderingHint(TextRenderingHintSingleBitPerPixel); // clear background CRgn bkgndRgn; CRect bkgndRect(clientRect); bkgndRect.left += 1; bkgndRect.top += 1; CreateRectRgnInDevicePoints(pDC, &bkgndRgn, bkgndRect, m_CornerRadius); pDC->SelectClipRgn(&bkgndRgn); pDC->FillSolidRect(&clientRect, RGB(255, 255, 255)); CRgn clientRgn; CreateRectRgnInDevicePoints(pDC, &clientRgn, clientRect); pDC->SelectClipRgn(&clientRgn); // Whole border Gdiplus::Rect borderRect(clientRect.left, clientRect.top, clientRect.Width(), clientRect.Height()); borderRect.Inflate(-1, -1); if (m_Buttons.size() == 0) { COLORREF borderColor = m_ColorMap.GetColor(Normal, Border); DrawRectArea(borderRect, graphics, borderColor, m_CornerRadius, m_BorderPenWidth); } for (int btnId = 0; btnId < m_Buttons.size(); ++btnId) { BtnInfo* pBtnInfo = &m_Buttons[btnId]; CRgn btnRgn; CRect t(pBtnInfo->m_rect); t.right += 1; t.bottom += 1; CreateRectRgnInDevicePoints(pDC, &btnRgn, t); btnRgn.CombineRgn(&btnRgn, &bkgndRgn, RGN_AND); pDC->SelectClipRgn(&btnRgn); ControlState buttonState = GetButtonState(pBtnInfo); // Highlight if (buttonState != Press) pDC->FillSolidRect(pBtnInfo->m_rect, m_ColorMap.GetColor(buttonState, BorderLight)); // Border graphics.SetClip(btnRgn); COLORREF borderColor = m_ColorMap.GetColor(buttonState, Border); DrawRectArea(borderRect, graphics, borderColor, m_CornerRadius, m_BorderPenWidth); graphics.ResetClip(); CRgn offsetRgn1; offsetRgn1.CreateRectRgn(0, 0, 0, 0); offsetRgn1.CopyRgn(&btnRgn); offsetRgn1.OffsetRgn(m_BorderPenWidth + 1, m_BorderPenWidth + 1); CRgn offsetRgn2; offsetRgn2.CreateRectRgn(0, 0, 0, 0); offsetRgn2.CopyRgn(&btnRgn); offsetRgn2.OffsetRgn(-(m_BorderPenWidth + 1), -(m_BorderPenWidth + 1)); CRgn backRgn; backRgn.CreateRectRgn(0, 0, 0, 0); backRgn.CombineRgn(&offsetRgn1, &offsetRgn2, RGN_AND); pDC->SelectClipRgn(&backRgn); if (buttonState != Mouseover) { DrawGradient(pDC, t); /*Draw4ColorsGradientRect(t, *pDC, m_ColorMap.GetColor(buttonState, BackgroundTopGradientStart), m_ColorMap.GetColor(buttonState, BackgroundTopGradientFinish), m_ColorMap.GetColor(buttonState, BackgroundBottomGradientStart), m_ColorMap.GetColor(buttonState, BackgroundBottomGradientFinish), m_CornerRadius, TRUE);*/ } COLORREF textColor = RGB(80,80,80);//COLOR_GRAYTEXT;//COLOR_BTNTEXT; /*if (buttonState == Press) textColor = RGB(0, 122, 224);*/ pDC->SelectClipRgn(&btnRgn); CFont* pFont = GetFont(); int nFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS; CTTButton::DrawCaptionText(pDC, &pBtnInfo->m_rect, &pBtnInfo->m_rect, pBtnInfo->m_text, nFormat, pFont, textColor); } pDC->SelectClipRgn(&clientRgn); for (int btnId = 1; btnId < m_Buttons.size(); ++btnId) { BtnInfo* pPrevBtnInfo = &m_Buttons[btnId - 1]; BtnInfo* pCurBtnInfo = &m_Buttons[btnId]; ControlState prevBtnState = GetButtonState(pPrevBtnInfo); ControlState curBtnState = GetButtonState(pCurBtnInfo); ControlState state = Normal; if (prevBtnState == Press || curBtnState == Press) state = Press; else if (prevBtnState == Mouseover || curBtnState == Mouseover) state = Mouseover; COLORREF borderColor = m_ColorMap.GetColor(state, Border); CPen borderPen(PS_SOLID, m_BorderPenWidth, borderColor); pDC->SelectObject(borderPen); pDC->MoveTo(pPrevBtnInfo->m_rect.right, pPrevBtnInfo->m_rect.top); pDC->LineTo(pPrevBtnInfo->m_rect.right, pPrevBtnInfo->m_rect.bottom); } }
void nuiDrawContext::DrawGradient(const nuiGradient& rGradient, const nuiRect& rEnclosingRect, const nuiVector2& rP1, const nuiVector2& rP2) { DrawGradient(rGradient, rEnclosingRect, rP1[0], rP1[1], rP2[0], rP2[1]); }
void CSrmmProxyWindow::OnRenderThumbnail(int width, int height) { HBITMAP hbmp = CreateDwmBitmap(width, height); HDC hdc = CreateCompatibleDC(0); SelectObject(hdc, hbmp); RGBQUAD rgb0, rgb1; rgb0.rgbRed = 0; rgb0.rgbGreen = 0; rgb0.rgbBlue = 0; rgb1.rgbRed = 19; rgb1.rgbGreen = 58; rgb1.rgbBlue = 89; DrawGradient(hdc, 0, 0, width, height, &rgb0, &rgb1); HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); SetTextColor(hdc, RGB(255, 255, 255)); SetBkMode(hdc, TRANSPARENT); RECT rc; SIZE sz; SetRect(&rc, 5, 5, width-10, height-10); int avatarWidth = 0; int avatarHeight = 0; if (true) { AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)m_hContact, 0); if (ace && (ace != (AVATARCACHEENTRY *)CALLSERVICE_NOTFOUND)) { if (ace->bmWidth < width / 4) { avatarWidth = ace->bmWidth; avatarHeight = ace->bmHeight; } else { avatarWidth = width / 4; avatarHeight = avatarWidth * ace->bmHeight / ace->bmWidth; } AVATARDRAWREQUEST avdr = {0}; avdr.cbSize = sizeof(avdr); avdr.hContact = m_hContact; avdr.hTargetDC = hdc; avdr.rcDraw = rc; avdr.rcDraw.bottom = avdr.rcDraw.top + avatarHeight; avdr.rcDraw.right = avdr.rcDraw.left + avatarWidth; avdr.dwFlags = AVDRQ_FALLBACKPROTO | AVDRQ_FORCEALPHA; avdr.alpha = 255; CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&avdr); rc.left += avatarWidth + 5; } } char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hContact, 0); if (true) { CONTACTINFO ci = {0}; ci.cbSize = sizeof(ci); ci.hContact = m_hContact; ci.szProto = proto; ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR; if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) { TCHAR name[128]; name[0] = 0; switch (ci.type) { case CNFT_ASCIIZ: mir_sntprintf(name, SIZEOF(name), _T("%s"), ci.pszVal); mir_free((void *)ci.pszVal); break; case CNFT_DWORD: mir_sntprintf(name, SIZEOF(name), _T("%u"), ci.dVal); break; } TextOut(hdc, rc.left + 20, rc.top, name, lstrlen(name)); GetTextExtentPoint32(hdc, name, lstrlen(name), &sz); } } if (true) { HIMAGELIST hIml = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0); int iIcon = CallService(MS_CLIST_GETCONTACTICON, (WPARAM)m_hContact, 0); ImageList_Draw(hIml, iIcon, hdc, rc.left, rc.top + (sz.cy - 16) / 2, ILD_TRANSPARENT); } rc.top += sz.cy + 5; rc.left += 10; struct { TCHAR *text; bool out; } msgs[10] = {0}; if (true) { int hMsgs = 0; int n = 0; HANDLE hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)m_hContact, 0); while (hEvent) { BYTE buf[1024]; DBEVENTINFO dbei = {0}; dbei.cbSize = sizeof(dbei); dbei.cbBlob = sizeof(buf); dbei.pBlob = buf; if (!CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei)) { if (dbei.eventType == EVENTTYPE_MESSAGE) { msgs[n].text = DbGetEventTextT(&dbei, CP_ACP); msgs[n].out = dbei.flags & DBEF_SENT ? true : false; RECT rcCopy = rc; hMsgs += DrawText(hdc, msgs[n].text, -1, &rcCopy, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP|DT_CALCRECT); if (n && hMsgs > rc.bottom - rc.top) { mir_free(msgs[n].text); msgs[n].text = 0; break; } hMsgs += 3; if (++n >= SIZEOF(msgs)) break; } } hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hEvent, 0); } } if (true) { for (int i = SIZEOF(msgs); i--; ) { if (!msgs[i].text) continue; TCHAR szDir[] = { (msgs[i].out ? (WCHAR)0xbb : (WCHAR)0xab), 0 }; rc.left -= 10; DrawText(hdc, szDir, -1, &rc, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP); rc.left += 10; rc.top += 3 + DrawText(hdc, msgs[i].text, -1, &rc, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP); mir_free(msgs[i].text); } } SelectObject(hdc, hfntSave); DeleteDC(hdc); MakeBitmapOpaque(hbmp); SetThumbnail(hbmp); DeleteObject(hbmp); }
static void ShowTestModeScreen( CDrawPort *pDP, CViewPort *pVP) { // try to lock draw port if( !pDP->Lock()) return; // draw rectangle PIX dpWidth = pDP->GetWidth(); PIX dpHeight = pDP->GetHeight(); pDP->Fill( C_WHITE | CT_OPAQUE); pDP->Fill( 2,2, dpWidth-4, dpHeight-4, C_BLACK | CT_OPAQUE); // draw gradients DrawGradient( pDP, C_WHITE, C_RED, 1.0f/8*dpWidth, 1.0f/16*dpHeight, 1.0f/2*dpWidth, 2.0f/16*dpHeight); DrawGradient( pDP, C_RED, C_BLACK, 1.0f/2*dpWidth, 1.0f/16*dpHeight, 7.0f/8*dpWidth, 2.0f/16*dpHeight); DrawGradient( pDP, C_BLACK, C_GREEN, 1.0f/8*dpWidth, 2.0f/16*dpHeight, 1.0f/2*dpWidth, 3.0f/16*dpHeight); DrawGradient( pDP, C_GREEN, C_WHITE, 1.0f/2*dpWidth, 2.0f/16*dpHeight, 7.0f/8*dpWidth, 3.0f/16*dpHeight); DrawGradient( pDP, C_WHITE, C_BLUE, 1.0f/8*dpWidth, 3.0f/16*dpHeight, 1.0f/2*dpWidth, 4.0f/16*dpHeight); DrawGradient( pDP, C_BLUE, C_BLACK, 1.0f/2*dpWidth, 3.0f/16*dpHeight, 7.0f/8*dpWidth, 4.0f/16*dpHeight); DrawGradient( pDP, C_BLACK, C_CYAN, 1.0f/8*dpWidth, 4.5f/16*dpHeight, 1.0f/2*dpWidth, 5.5f/16*dpHeight); DrawGradient( pDP, C_CYAN, C_WHITE, 1.0f/2*dpWidth, 4.5f/16*dpHeight, 7.0f/8*dpWidth, 5.5f/16*dpHeight); DrawGradient( pDP, C_WHITE, C_MAGENTA, 1.0f/8*dpWidth, 5.5f/16*dpHeight, 1.0f/2*dpWidth, 6.5f/16*dpHeight); DrawGradient( pDP, C_MAGENTA, C_BLACK, 1.0f/2*dpWidth, 5.5f/16*dpHeight, 7.0f/8*dpWidth, 6.5f/16*dpHeight); DrawGradient( pDP, C_BLACK, C_YELLOW, 1.0f/8*dpWidth, 6.5f/16*dpHeight, 1.0f/2*dpWidth, 7.5f/16*dpHeight); DrawGradient( pDP, C_YELLOW, C_WHITE, 1.0f/2*dpWidth, 6.5f/16*dpHeight, 7.0f/8*dpWidth, 7.5f/16*dpHeight); DrawGradient( pDP, C_WHITE, C_BLACK, 1.0f/8*dpWidth, 8.0f/16*dpHeight, 7.0f/8*dpWidth, 10.0f/16*dpHeight); // draw rectangles pDP->Fill( 1.5f/8*dpWidth, 10.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_dRED |CT_OPAQUE); pDP->Fill( 1.5f/8*dpWidth, 11.0f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_RED |CT_OPAQUE); pDP->Fill( 1.5f/8*dpWidth, 11.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_lRED |CT_OPAQUE); pDP->Fill( 2.0f/8*dpWidth, 10.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_dGREEN |CT_OPAQUE); pDP->Fill( 2.0f/8*dpWidth, 11.0f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_GREEN |CT_OPAQUE); pDP->Fill( 2.0f/8*dpWidth, 11.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_lGREEN |CT_OPAQUE); pDP->Fill( 2.5f/8*dpWidth, 10.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_dBLUE |CT_OPAQUE); pDP->Fill( 2.5f/8*dpWidth, 11.0f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_BLUE |CT_OPAQUE); pDP->Fill( 2.5f/8*dpWidth, 11.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_lBLUE |CT_OPAQUE); pDP->Fill( 3.0f/8*dpWidth, 10.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_dCYAN |CT_OPAQUE); pDP->Fill( 3.0f/8*dpWidth, 11.0f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_CYAN |CT_OPAQUE); pDP->Fill( 3.0f/8*dpWidth, 11.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_lCYAN |CT_OPAQUE); pDP->Fill( 3.5f/8*dpWidth, 10.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_dMAGENTA |CT_OPAQUE); pDP->Fill( 3.5f/8*dpWidth, 11.0f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_MAGENTA |CT_OPAQUE); pDP->Fill( 3.5f/8*dpWidth, 11.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_lMAGENTA |CT_OPAQUE); pDP->Fill( 4.0f/8*dpWidth, 10.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_dYELLOW |CT_OPAQUE); pDP->Fill( 4.0f/8*dpWidth, 11.0f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_YELLOW |CT_OPAQUE); pDP->Fill( 4.0f/8*dpWidth, 11.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_lYELLOW |CT_OPAQUE); pDP->Fill( 4.5f/8*dpWidth, 10.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_dGRAY |CT_OPAQUE); pDP->Fill( 4.5f/8*dpWidth, 11.0f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_GRAY |CT_OPAQUE); pDP->Fill( 4.5f/8*dpWidth, 11.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_lGRAY |CT_OPAQUE); pDP->Fill( 5.0f/8*dpWidth, 10.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_dORANGE |CT_OPAQUE); pDP->Fill( 5.0f/8*dpWidth, 11.0f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_ORANGE |CT_OPAQUE); pDP->Fill( 5.0f/8*dpWidth, 11.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_lORANGE |CT_OPAQUE); pDP->Fill( 5.5f/8*dpWidth, 10.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_dBROWN |CT_OPAQUE); pDP->Fill( 5.5f/8*dpWidth, 11.0f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_BROWN |CT_OPAQUE); pDP->Fill( 5.5f/8*dpWidth, 11.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_lBROWN |CT_OPAQUE); pDP->Fill( 6.0f/8*dpWidth, 10.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_dPINK |CT_OPAQUE); pDP->Fill( 6.0f/8*dpWidth, 11.0f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_PINK |CT_OPAQUE); pDP->Fill( 6.0f/8*dpWidth, 11.5f/16*dpHeight, 1.0f/16*dpWidth, 0.5f/16*dpHeight, C_lPINK |CT_OPAQUE); // set font pDP->SetFont( _pfdDisplayFont); // create text to display CTString strTestMessage = "test screen"; // type messages pDP->PutTextC( strTestMessage, 1.0f/4*dpWidth, 12.5f/16*dpHeight, C_dRED |CT_OPAQUE); pDP->PutTextC( strTestMessage, 2.0f/4*dpWidth, 12.5f/16*dpHeight, C_RED |CT_OPAQUE); pDP->PutTextC( strTestMessage, 3.0f/4*dpWidth, 12.5f/16*dpHeight, C_lRED |CT_OPAQUE); pDP->PutTextC( strTestMessage, 1.0f/4*dpWidth, 13.0f/16*dpHeight, C_dGREEN|CT_OPAQUE); pDP->PutTextC( strTestMessage, 2.0f/4*dpWidth, 13.0f/16*dpHeight, C_GREEN |CT_OPAQUE); pDP->PutTextC( strTestMessage, 3.0f/4*dpWidth, 13.0f/16*dpHeight, C_lGREEN|CT_OPAQUE); pDP->PutTextC( strTestMessage, 1.0f/4*dpWidth, 13.5f/16*dpHeight, C_dBLUE |CT_OPAQUE); pDP->PutTextC( strTestMessage, 2.0f/4*dpWidth, 13.5f/16*dpHeight, C_BLUE |CT_OPAQUE); pDP->PutTextC( strTestMessage, 3.0f/4*dpWidth, 13.5f/16*dpHeight, C_lBLUE |CT_OPAQUE); pDP->PutTextC( strTestMessage, 1.0f/4*dpWidth, 14.0f/16*dpHeight, C_dGRAY |CT_OPAQUE); pDP->PutTextC( strTestMessage, 2.0f/4*dpWidth, 14.0f/16*dpHeight, C_GRAY |CT_OPAQUE); pDP->PutTextC( strTestMessage, 3.0f/4*dpWidth, 14.0f/16*dpHeight, C_lGRAY |CT_OPAQUE); // type resolution CDisplayMode dmCurrent; _pGfx->GetCurrentDisplayMode( dmCurrent); strTestMessage.PrintF( "%d x %d x %s", dpWidth, dpHeight, dmCurrent.DepthString()); pDP->PutTextC( strTestMessage, 1.0f/2*dpWidth+2, 1.0f/2*dpHeight+2, C_dGRAY|CT_OPAQUE); pDP->PutTextC( strTestMessage, 1.0f/2*dpWidth, 1.0f/2*dpHeight, C_WHITE|CT_OPAQUE); // unlock draw port pDP->Unlock(); // show screen pVP->SwapBuffers(); }
static LRESULT CALLBACK MainWindowProc(HWND MainWindow, UINT Message, WPARAM wParam, LPARAM lParam) { LRESULT Result = 0; switch(Message) { case WM_CREATE: InitWindowComponents(MainWindow, &Controls); break; case WM_DESTROY: PostQuitMessage(0); break; case WM_ERASEBKGND: // NOTE: Return a non-zero value. Literally. Result = !0; break; case WM_PAINT: { PAINTSTRUCT PaintStruct; HDC DC = BeginPaint(MainWindow, &PaintStruct); RECT FillRegion; GetClientRect(MainWindow, &FillRegion); COLORREF Top = RGB(239, 241, 245); COLORREF Bottom = RGB(218, 223, 233); DrawGradient(DC, FillRegion, Top, Top, Bottom, Bottom); EndPaint(MainWindow, &PaintStruct); ReleaseDC(MainWindow, DC); } break; case WM_COMMAND: { HWND Ctrl = (HWND)lParam; if(HIWORD(wParam) == CBN_SELCHANGE && Ctrl == Controls.ComboBox) { DWORD Pos = SendMessageA((HWND)lParam, CB_GETCURSEL, 0, 0); window_data *WndData = (window_data*)SendMessageA((HWND)lParam, CB_GETITEMDATA, Pos, 0); if(WndData) { Controls.CurSelection = WndData; HWND Window = WndData->Window; WINDOWINFO WindowInfo = {}; WindowInfo.cbSize = sizeof(WindowInfo); if(GetWindowInfo(Window, &WindowInfo)) { RECT Rect = WindowInfo.rcWindow; LONG Width = Rect.right - Rect.left; LONG Height = Rect.bottom - Rect.top; // TODO: Display usefull data char Buffer[256]; StringCbPrintfA(Buffer, sizeof(Buffer), "%dx%d starting at (%d,%d)", Width, Height, Rect.left, Rect.top); SetWindowTextA(Controls.StaticText, Buffer); ShowWindow(Controls.StaticText, TRUE); } else { PRINT_ERR("Could not get window info.\n"); } } } else if(HIWORD(wParam) == BN_CLICKED) { if(Ctrl == Controls.ButtonOK) { if(Controls.CurSelection) { int UseConfig = SendMessageA(Controls.CheckBox, BM_GETCHECK, 0, 0); if(UseConfig == BST_CHECKED) { load_file_result LoadResult = LoadWindowSizeFromConfig(); if(LoadResult.Valid) { SetWindowMode(*Controls.CurSelection, LoadResult.Width, LoadResult.Height); } else { int SetToFullscreen = MessageBoxA(MainWindow, "Error loading config.ini.\nSet to fullscreen instead?", 0, MB_YESNO | MB_TASKMODAL); if(SetToFullscreen == IDYES) { SetFullscreen(*Controls.CurSelection); } } } else { SetFullscreen(*Controls.CurSelection); } } PostQuitMessage(0); } else if(Ctrl == Controls.ButtonCancel) { PostQuitMessage(0); } else { Result = DefWindowProcA(MainWindow, Message, wParam, lParam); } } } break; default: Result = DefWindowProcA(MainWindow, Message, wParam, lParam); } return Result; }