void CUIPdaWnd::Draw() { inherited::Draw(); //. DrawUpdatedSections(); DrawHint(); UINoice->Draw(); // over all }
void CPuzzle::OnDraw(HDC hDC, LPRECT lpRect, BOOL fGrid) /***********************************************************************/ { int iPieces; RECT rOut, rClient, rPaint, rWindow; HDC hDCOut; POINT ptDst; PDIB pDibOut = NULL; GetClientRect(m_hWnd, &rClient); GetWindowRect(m_hWnd, &rWindow); if (!IntersectRect(&rPaint, &rClient, lpRect)) return; if (!m_pDib) return; LPSCENE lpScene = CScene::GetScene(GetParent(m_hWnd)); if (!lpScene) return; LPOFFSCREEN lpOffScreen = lpScene->GetOffScreen(); if (lpOffScreen) { hDCOut = lpOffScreen->GetDC(); rOut = rPaint; MapWindowPoints( m_hWnd, GetParent(m_hWnd), (LPPOINT)&rOut, 2 ); MapWindowPoints( m_hWnd, GetParent(m_hWnd), (LPPOINT)&rClient, 2 ); MapWindowPoints( NULL, GetParent(m_hWnd), (LPPOINT)&rWindow, 2 ); pDibOut = lpOffScreen->GetWritableDIB(); } else hDCOut = hDC; iPieces = m_iCols * m_iRows; for (int i = 0; i < iPieces; ++i) DrawPiece(i, hDCOut, pDibOut, (LPPOINT)&rClient.left, &rPaint, fGrid); if (m_iSelect >= 0) { if (m_bHintMode) DrawHint(m_iSelect, hDCOut, (LPPOINT)&rClient.left, &rPaint); DrawPiece(m_iSelect, hDCOut, pDibOut, (LPPOINT)&rClient.left, &rPaint, FALSE, &m_ptSelect); } // when we are all done we draw from the WinG DC to the output DC if (lpOffScreen) { ptDst.x = rPaint.left; ptDst.y = rPaint.top; lpOffScreen->DrawRect( hDC, &rOut, &ptDst ); } }
void ControlPad::OnPaint(HDC hDC) { RECT rcClient; GetClientRect(&rcClient); // Standard Setup HDC hMemDC = ::CreateCompatibleDC(hDC); if (hMemDC) { HBITMAP hBmp = ::CreateCompatibleBitmap(hDC, m_nWidth, m_nHeight); HGDIOBJ hOldBmp = ::SelectObject(hMemDC, hBmp); DrawBackground(hMemDC); DrawHint(hMemDC); DrawCross(hMemDC); DrawTextLabels(hMemDC); POINT ptDeflection; if (m_fAction) { ptDeflection.x = m_ptCurrent.x; ptDeflection.y = m_ptCurrent.y; } else { ptDeflection.x = m_nWidth/2; ptDeflection.y = m_nHeight/2; } DrawControl(hMemDC, &ptDeflection); // Copies the source rectangle directly to the destination rectangle ::BitBlt(hDC, 0, 0, m_nWidth, m_nHeight, hMemDC, 0, 0, SRCCOPY); // Standard End ::SelectObject(hMemDC, hOldBmp); ::DeleteDC(hMemDC); ::DeleteObject(hBmp); } else { // Error handler here TRACE2("Memory DC failed: %#X, %d\n", hDC, GetLastError()); } }
void CPuzzle::OnLButtonDown(HWND hWindow, BOOL fDoubleClick, int x, int y, UINT keyFlags) /***********************************************************************/ { if ( SHIFT ) return; if ( m_bTrack ) return; if (IsSolved()) return; SetCapture( hWindow ); m_bTrack = TRUE; if ( GetFocus() != hWindow ) SetFocus( hWindow ); m_bInRect = YES; if (!m_pDib) return; int iColWidth = m_pDib->GetWidth() / m_iCols; int iRowHeight = m_pDib->GetHeight() / m_iRows; int iCol = x / iColWidth; int iRow = y / iRowHeight; m_iSelect = (iRow * m_iCols) + iCol; m_ptSelect.x = iCol * iColWidth; m_ptSelect.y = iRow * iRowHeight; m_ptLast.x = x; m_ptLast.y = y; PlaySound(IDW_PUZZLEDOWN); if (m_bHintMode) { HDC hDC = GetDC(hWindow); DrawHint(m_iSelect, hDC, NULL, NULL); ReleaseDC(hWindow, hDC); } }
void CHitDialog::ShowHint(cocos2d::Layer* layer,int x,int y,std::string str,unsigned long Color, bool drawUp, unsigned long bColor /* = 0 */,std::string RightStr/* ="" */) { if(m_Layer)Hide(); CBaseDialog::Show(layer); m_Layer = cocos2d::Layer::create(); m_Layer->retain(); layer->addChild(m_Layer); ClearHint(); HintX = x; HintY = y; HintWidth = 0; HintWidthLeft = 0; HintHeight = 0; HintUp = drawUp; HintColor = Color; BackColor = bColor; int n = 0; std::string data; //计算左边文字宽高 while(true) { n++; if(n > 2000)break; if(str.length() == 0)break; if((int)str.find("\\") >= 0) { str = GetValidStr3Ex(str,data,'\\'); }else if((int)str.find("^") >= 0) { str = GetValidStr3Ex(str,data,'^'); }else //无法解析道具说明的\\符号 { HintList.push_back(str); break; } int w = GetStrWidth(data) + 8; if(w > HintWidth) HintWidth = w; if(data.length() > 1) { HintList.push_back(data); } } HintWidthLeft = HintWidth; HintHeight = (TextWidth("A") + 3) * (int)HintList.size() + 3 * 2; //计算右边文字宽高 并更新整体宽度高度 n = 0; int leftWidth =0; while(true) { n++; if(n > 2000)break; if(RightStr.length() == 0)break; if((int)RightStr.find("\\") >= 0) { RightStr = GetValidStr3Ex(RightStr,data,'\\'); }else if((int)RightStr.find("^") >= 0) { RightStr = GetValidStr3Ex(RightStr,data,'^'); } int w = GetStrWidth(data) + 8; if(w > leftWidth) leftWidth = w; if(data.length() > 0) { HintListRight.push_back(data); } } n = (TextWidth("A") + 3) * (int)HintListRight.size() + 3 * 2; if(leftWidth > 0) HintWidth = HintWidthLeft + leftWidth + 10; if(n > HintHeight) HintHeight = n; if(HintUp) HintY = HintY - HintHeight; //超出屏幕范围的处理 2013.9.24 if(HintY + HintHeight > SCREENHEIGHT) { HintY = SCREENHEIGHT - HintHeight; } DrawHint(); }