/** Sets a new position, relays the change to an associated textarea and calls any existing GUI OnChange callback */ void ScrollBar::SetPos(ieDword NewPos, bool redraw) { if (!Frames[IE_GUI_SCROLLBAR_UP_UNPRESSED]) return; if (NewPos > Value) NewPos = Value; if (( State & SLIDER_GRAB ) == 0){ // set the slider to the exact y for NewPos. in SetPosForY(y) it is set to any arbitrary position that may lie between 2 values. // if the slider is grabbed dont set position! otherwise you will get a flicker as it bounces between exact positioning and arbitrary SliderYPos = ( unsigned short ) ( GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED) + ( NewPos * ( ( Height - GetFrameHeight(IE_GUI_SCROLLBAR_SLIDER) - GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED) - GetFrameHeight(IE_GUI_SCROLLBAR_DOWN_UNPRESSED) ) / ( double ) ( Value < 1 ? 1 : Value ) ) ) ); } if (Pos && ( Pos == NewPos )) { return; } Changed = true; Pos = (ieWord) NewPos; if (ta) { (( TextArea* )ta)->SetRow( Pos ); } if (VarName[0] != 0) { core->GetDictionary()->SetAt( VarName, Pos ); } RunEventHandler( ScrollBarOnChange ); if(redraw) core->RedrawAll(); }
void CFrameHolder::CalculateCaptionPosition(const RECT &rcWindow, RECT* rcCaption) { //_ASSERTE(FALSE && "CFrameHolder::CalculateCaptionPosition MUST be refactored!"); FrameDrawStyle dt = gpConEmu->DrawType(); if (dt == fdt_Aero || dt == fdt_Win8) { // Почему тут не SM_CXFRAME не помню rcCaption->left = 0; //2; //GetSystemMetrics(SM_CXFRAME); rcCaption->right = (rcWindow.right - rcWindow.left); // - 4; //GetSystemMetrics(SM_CXFRAME); rcCaption->top = GetFrameHeight(); //6; //GetSystemMetrics(SM_CYFRAME); if (gpSet->isTabsInCaption) rcCaption->bottom = rcCaption->top + GetCaptionHeight()/*это наш*/; // (gpSet->isTabs ? (GetCaptionDragHeight()+GetTabsHeight()) : GetWinCaptionHeight()); //gpConEmu->GetDwmClientRectTopOffset() - 1; else rcCaption->bottom = rcCaption->top + GetCaptionHeight()/*это наш*/; // (gpSet->isTabs ? (GetCaptionDragHeight()+GetTabsHeight()) : GetWinCaptionHeight()); //gpConEmu->GetDwmClientRectTopOffset() - 1; } else if (dt == fdt_Themed) { rcCaption->left = GetFrameWidth(); rcCaption->right = (rcWindow.right - rcWindow.left) - GetFrameWidth() - 1; rcCaption->top = GetFrameHeight(); //rcCaption->bottom = rcCaption->top + GetSystemMetrics(SM_CYCAPTION) + (gSet.isTabs ? (GetSystemMetrics(SM_CYCAPTION)/2) : 0); rcCaption->bottom = rcCaption->top + GetCaptionHeight()/*это наш*/; // (gpSet->isTabs ? (GetCaptionDragHeight()+GetTabsHeight()) : GetWinCaptionHeight()); } else { rcCaption->left = GetFrameWidth(); rcCaption->right = (rcWindow.right - rcWindow.left) - GetFrameWidth() - 1; rcCaption->top = GetFrameHeight(); //rcCaption->bottom = rcCaption->top + GetSystemMetrics(SM_CYCAPTION) - 1 + (gpSet->isTabs ? (GetSystemMetrics(SM_CYCAPTION)/2) : 0); rcCaption->bottom = rcCaption->top + GetCaptionHeight()/*это наш*/; // (gpSet->isTabs ? (GetCaptionDragHeight()+GetTabsHeight()) : GetWinCaptionHeight()); } }
/** Provides per-pixel scrolling. Top = 0px */ void ScrollBar::SetPosForY(unsigned short y) { if (Value > 1) {// if the value is 1 we are simultaniously at both the top and bottom so there is nothing to do unsigned short YMax = Height - GetFrameHeight(IE_GUI_SCROLLBAR_SLIDER) - GetFrameHeight(IE_GUI_SCROLLBAR_DOWN_UNPRESSED) - GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED); if (y > YMax) y = YMax; if (stepPx) { unsigned short NewPos = (unsigned short)(y / stepPx); if (Pos != NewPos) { SetPos( NewPos, false ); } if (ta) { // we must "scale" the pixels the slider moves TextArea* t = (TextArea*) ta; unsigned int taY = y * (t->GetRowHeight() / stepPx); t->ScrollToY(taY, this); } SliderYPos = (y + GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED) - 0); core->RedrawAll(); } }else{ // top is our default position SliderYPos = GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED); } }
/** Mouse Over Event */ void ScrollBar::OnMouseOver(unsigned short /*x*/, unsigned short y) { if (( State & SLIDER_GRAB ) != 0 && y > GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED)) { /* TODO: factor in where we grab the slider and offset it when dragging. */ SetPosForY(y - GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED)); } }
/** Draws the ScrollBar control */ void ScrollBar::Draw(unsigned short x, unsigned short y) { if (!Changed && !(Owner->Flags&WF_FLOAT) ) { return; } Changed = false; if (XPos == 65535) { return; } Video *video=core->GetVideoDriver(); int upMy = GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED); int doMy = GetFrameHeight(IE_GUI_SCROLLBAR_DOWN_UNPRESSED); unsigned int domy = (Height - doMy); //draw the up button if (( State & UP_PRESS ) != 0) { if (Frames[IE_GUI_SCROLLBAR_UP_PRESSED]) video->BlitSprite( Frames[IE_GUI_SCROLLBAR_UP_PRESSED], x + XPos, y + YPos, true ); } else { if (Frames[IE_GUI_SCROLLBAR_UP_UNPRESSED]) video->BlitSprite( Frames[IE_GUI_SCROLLBAR_UP_UNPRESSED], x + XPos, y + YPos, true ); } //draw the trough int maxy = y + YPos + Height - GetFrameHeight(IE_GUI_SCROLLBAR_DOWN_UNPRESSED); int stepy = GetFrameHeight(IE_GUI_SCROLLBAR_TROUGH); if (stepy) { Region rgn( x + XPos, y + YPos + upMy, Width, domy - upMy); for (int dy = y + YPos + upMy; dy < maxy; dy += stepy) { //TROUGH surely exists if it has a nonzero height video->BlitSprite( Frames[IE_GUI_SCROLLBAR_TROUGH], x + XPos + ( ( Width / 2 ) - Frames[IE_GUI_SCROLLBAR_TROUGH]->Width / 2 ), dy, true, &rgn ); } } //draw the down button if (( State & DOWN_PRESS ) != 0) { if (Frames[IE_GUI_SCROLLBAR_DOWN_PRESSED]) video->BlitSprite( Frames[IE_GUI_SCROLLBAR_DOWN_PRESSED], x + XPos, maxy, true ); } else { if (Frames[IE_GUI_SCROLLBAR_DOWN_UNPRESSED]) video->BlitSprite( Frames[IE_GUI_SCROLLBAR_DOWN_UNPRESSED], x + XPos, maxy, true ); } //draw the slider if it exists if (Frames[IE_GUI_SCROLLBAR_SLIDER]) { unsigned short slx = ( unsigned short ) ((Width - Frames[IE_GUI_SCROLLBAR_SLIDER]->Width) / 2 ); video->BlitSprite( Frames[IE_GUI_SCROLLBAR_SLIDER], x + XPos + slx + Frames[IE_GUI_SCROLLBAR_SLIDER]->XPos, y + YPos + Frames[IE_GUI_SCROLLBAR_SLIDER]->YPos + SliderYPos, true ); } }
static BOOLEAN GetFrameValidRect (PRECT pValidRect, HOT_SPOT *pOldHot) { COORD hx, hy; HOT_SPOT OldHot; OldHot = _CurFramePtr->HotSpot; hx = OldHot.x; hy = OldHot.y; pValidRect->corner.x = hx; pValidRect->corner.y = hy; pValidRect->extent.width = GetFrameWidth (_CurFramePtr); pValidRect->extent.height = GetFrameHeight (_CurFramePtr); if (_pCurContext->ClipRect.extent.width) { if (!BoxIntersect (&_pCurContext->ClipRect, pValidRect, pValidRect)) return (FALSE); hx -= _pCurContext->ClipRect.corner.x; hy -= _pCurContext->ClipRect.corner.y; pValidRect->corner.x += hx; pValidRect->corner.y += hy; _CurFramePtr->HotSpot = MAKE_HOT_SPOT (hx, hy); } *pOldHot = OldHot; return (TRUE); }
void JXStringCompletionMenu::CompletionRequested ( const JSize prefixLength ) { itsRequestCount++; if (itsRequestCount > 1 && !IsEmpty()) { itsPrefixLength = prefixLength; // prepend "insert tab character" option JString s; if (itsAllowTabChar && (!GetItemShortcuts(1, &s) || s != kInsertTabShortcut)) { PrependItem(kInsertTabStr, kPlainType, kInsertTabShortcut); } // place it next to the caret (use the character in front of the caret) const JIndex charIndex = itsTE->GetInsertionIndex() - 1; const JCoordinate x = itsTE->GetCharRight(charIndex) + 2; const JIndex lineIndex = itsTE->GetLineForChar(charIndex); const JCoordinate y = itsTE->GetLineTop(lineIndex) - GetFrameHeight(); Place(x,y); // open it HandleShortcut('\t', JXKeyModifiers(GetDisplay())); } }
//////////////////////////////////////// // PUBLIC UTILITY FUNCTIONS //////////////////////////////////////// // Gets the current frame in the animation // and moves to the next one in order. RECT CAnimation::GetFrame() { SetTimeWaited(GetTimeWaited() + GAME->GetTimer().GetDeltaTime()); RECT tRect; tRect.left = GetCurrentFrame() * GetFrameWidth(); tRect.top = 0; tRect.right = tRect.left + GetFrameWidth(); tRect.bottom = tRect.top + GetFrameHeight(); if(GetTimeWaited() > GetTimePerFrame() && !GetStatic()) { SetTimeWaited(0.0f); SetCurrentFrame(GetCurrentFrame() + 1); if(GetCurrentFrame() > GetFrameCount()) { if(GetLooping()) ResetAnimation(); else { SetCurrentFrame(GetFrameCount()); SetStatic(true); } } } return tRect; }
/** Sets the Maximum Value of the ScrollBar */ void ScrollBar::SetMax(unsigned short Max) { Value = Max; if (Max == 0) { SetPos( 0 ); stepPx = 0; } else { //recalculate step stepPx = (double)((double)(Height - GetFrameHeight(IE_GUI_SCROLLBAR_SLIDER) - GetFrameHeight(IE_GUI_SCROLLBAR_DOWN_UNPRESSED) - GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED)) / (double)(Value)); if (Pos >= Max) { SetPos( Max - 1 ); } } }
/** Mousewheel scroll */ void ScrollBar::OnMouseWheelScroll(short /*x*/, short y) { if ( State == 0 ){//dont allow mousewheel to do anything if the slider is being interacted with already. unsigned short fauxY = (SliderYPos - GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED)); if ((short)fauxY + y <= 0) fauxY = 0; else fauxY += y; SetPosForY(fauxY); } }
/** Sets a ScrollBar GUI resource */ void ScrollBar::SetImage(unsigned char type, Sprite2D* img) { if (type >= SB_RES_COUNT) { return; } if (Frames[type]) { core->GetVideoDriver()->FreeSprite(Frames[type]); } Frames[type] = img; //recalculate step if(Value){ stepPx = (double)((double)(Height - GetFrameHeight(IE_GUI_SCROLLBAR_SLIDER) - GetFrameHeight(IE_GUI_SCROLLBAR_DOWN_UNPRESSED) - GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED)) / (double)(Value)); }else{ stepPx = 0; } Changed = true; }
/** Mouse Button Down */ void ScrollBar::OnMouseDown(unsigned short /*x*/, unsigned short y, unsigned short Button, unsigned short /*Mod*/) { //removing the double click flag, use a more sophisticated method //if it is needed later Button&=GEM_MB_NORMAL; if (Button==GEM_MB_SCRLUP) { ScrollUp(); return; } if (Button==GEM_MB_SCRLDOWN) { ScrollDown(); return; } if (y <= GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED) ) { State |= UP_PRESS; ScrollUp(); return; } if (y >= Height - GetFrameHeight(IE_GUI_SCROLLBAR_DOWN_UNPRESSED)) { State |= DOWN_PRESS; ScrollDown(); return; } // check that stepPx is set if value is set if (Value && !stepPx) { SetMax(Value); } if (y >= SliderYPos && y < SliderYPos + GetFrameHeight(IE_GUI_SCROLLBAR_SLIDER)) { /* TODO: factor in where we grab the slider and offset it when dragging. */ State |= SLIDER_GRAB; return; } // if we made it this far we will jump the nib y and "grab" it // this way we only need to click once to jump+scroll State |= SLIDER_GRAB; SetPosForY(y - GetFrameHeight(IE_GUI_SCROLLBAR_UP_UNPRESSED)); }
void arith_frame_blit (FRAME srcFrame, const RECT *rsrc, FRAME dstFrame, const RECT *rdst, int num, int denom) { TFB_Image *srcImg, *dstImg; SDL_Surface *src, *dst; SDL_Rect srcRect, dstRect, *srp = NULL, *drp = NULL; srcImg = srcFrame->image; dstImg = dstFrame->image; LockMutex (srcImg->mutex); LockMutex (dstImg->mutex); src = (SDL_Surface *)srcImg->NormalImg; dst = (SDL_Surface *)dstImg->NormalImg; if (rdst) { dstRect.x = rdst->corner.x; dstRect.y = rdst->corner.y; dstRect.w = rdst->extent.width; dstRect.h = rdst->extent.height; drp = &dstRect; } if (rsrc) { srcRect.x = rsrc->corner.x; srcRect.y = rsrc->corner.y; srcRect.w = rsrc->extent.width; srcRect.h = rsrc->extent.height; srp = &srcRect; } else if (srcFrame->HotSpot.x || srcFrame->HotSpot.y) { if (rdst) { dstRect.x -= srcFrame->HotSpot.x; dstRect.y -= srcFrame->HotSpot.y; } else { dstRect.x = -srcFrame->HotSpot.x; dstRect.y = -srcFrame->HotSpot.y; dstRect.w = GetFrameWidth (srcFrame); dstRect.h = GetFrameHeight (srcFrame); drp = &dstRect; } } TFB_BlitSurface (src, srp, dst, drp, num, denom); UnlockMutex (srcImg->mutex); UnlockMutex (dstImg->mutex); }
bool PS3EyeCapture::Init(const int deviceNum){ //printf("PS3 Eye cameras connected: %i\n", PS3EyeDriver::GetInstance().GetNumCameras()); SetDeviceIndex(deviceNum); //The requested FPS will be changed to the next-lowest valid framerate if an invalid framerate is requested. bool success = PS3EyeDriver::GetInstance().InitCamera(deviceNum, PS3EyeDriver::RESOLUTION_SETTING::FULL_640_480, 60); if(success){ SetFrameWidth(PS3EyeDriver::GetInstance().GetHeight(deviceNum)); SetFrameHeight(PS3EyeDriver::GetInstance().GetWidth(deviceNum)); rawData = (unsigned char*)malloc(GetFrameWidth()*GetFrameHeight()*3*sizeof(unsigned char)); //cv::Mat frame(cv::Mat(cv::Size(GetFrameWidth(), GetFrameHeight()), CV_8U)); if(useThreadedUpdate) PS3EyeDriver::GetInstance().StartThreadUpdate(); } else{ //printf("Unsuccessful\n"); } return success; }
LRESULT CFrameHolder::OnPaint(HWND hWnd, BOOL abForceGetDc) { HDC hdc; PAINTSTRUCT ps = {0}; RECT wr, cr, tr; RecalculateFrameSizes(); hdc = BeginPaint(hWnd, &ps); GetClientRect(hWnd, &wr); if (gpSet->isStatusBarShow) { int nHeight = gpSet->StatusBarHeight(); if (nHeight < (wr.bottom - wr.top)) { RECT rcStatus = {wr.left, wr.bottom - nHeight, wr.right, wr.bottom}; gpConEmu->mp_Status->PaintStatus(hdc, rcStatus); wr.bottom = rcStatus.top; } } cr = wr; if (gpConEmu->DrawType() == fdt_Aero) { int nOffset = gpConEmu->GetDwmClientRectTopOffset(); // "Рамка" расширена на клиентскую область, поэтому // нужно зарисовать заголовок черной кистью, иначе идет // искажение цвета для кнопок Min/Max/Close if (gpSet->isTabs && gpSet->isTabsInCaption) { RECT captrect; CalculateCaptionPosition(cr, &captrect); CalculateTabPosition(cr, captrect, &tr); gpConEmu->mp_TabBar->PaintTabs(hdc, captrect, tr); mb_WasGlassDraw = TRUE; } cr.top += nOffset; } int nWidth = (cr.right-cr.left); int nHeight = (cr.bottom-cr.top); WARNING("Пока табы рисуем не сами и ExtendDWM отсутствует - дополнительные изыски с временным DC не нужны"); if (!gpSet->isTabsInCaption) { OnPaintClient(hdc, nWidth, nHeight); } else // Создадим временный DC, для удобства отрисовки в Glass-режиме и для фикса глюка DWM(?) см.ниже // В принципе, для режима Win2k/XP временный DC можно не создавать, если это будет тормозить { HDC hdcPaint = CreateCompatibleDC(hdc); HBITMAP hbmp = CreateCompatibleBitmap(hdc, nWidth, nHeight); HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcPaint, hbmp); OnPaintClient(hdcPaint, nWidth, nHeight); if ((gpConEmu->DrawType() == fdt_Aero) || !(mb_WasGlassDraw && gpConEmu->isZoomed())) { BitBlt(hdc, cr.left, cr.top, nWidth, nHeight, hdcPaint, 0, 0, SRCCOPY); } else { //mb_WasGlassDraw = FALSE; // Какой-то странный глюк DWM. При отключении Glass несколько верхних строк // клиентской области оказываются "разрушенными" - у них остается атрибут "прозрачности" // хотя прозрачность (Glass) уже отключена. В результате эти строки - белесые BITMAPINFOHEADER bi = {sizeof(BITMAPINFOHEADER)}; bi.biWidth = cr.right-cr.left+1; bi.biHeight = GetFrameHeight()+1; bi.biPlanes = 1; bi.biBitCount = 32; COLORREF *pPixels = NULL; HDC hdcTmp = CreateCompatibleDC(hdc); HBITMAP hTmp = CreateDIBSection(hdcTmp, (BITMAPINFO*)&bi, DIB_RGB_COLORS, (void**)&pPixels, NULL, 0); if (hTmp == NULL) { _ASSERTE(hTmp == NULL); BitBlt(hdc, cr.left, cr.top, nWidth, nHeight, hdcPaint, 0, 0, SRCCOPY); } else { HBITMAP hOldTmp = (HBITMAP)SelectObject(hdcTmp, hTmp); BitBlt(hdcTmp, 0, 0, bi.biWidth, bi.biHeight, hdcPaint, 0, 0, SRCCOPY); int i = 0; for (int y = 0; y < bi.biHeight; y++) { for (int x = 0; x < bi.biWidth; x++) { pPixels[i++] |= 0xFF000000; } } BitBlt(hdc, cr.left, cr.top, bi.biWidth, bi.biHeight, hdcTmp, 0, 0, SRCCOPY); if (nHeight > bi.biHeight) BitBlt(hdc, cr.left, cr.top+bi.biHeight, nWidth, nHeight-bi.biHeight, hdcPaint, 0, bi.biHeight, SRCCOPY); SelectObject(hdcTmp, hOldTmp); DeleteObject(hbmp); } DeleteDC(hdcTmp); } SelectObject(hdcPaint, hOldBmp); DeleteObject(hbmp); DeleteDC(hdcPaint); } EndPaint(hWnd, &ps); return 0; }
LRESULT CFrameHolder::OnPaint(HWND hWnd, HDC hdc, UINT uMsg) { if (hdc == NULL) { LRESULT lRc = 0; PAINTSTRUCT ps = {0}; hdc = BeginPaint(hWnd, &ps); if (hdc != NULL) { lRc = OnPaint(hWnd, hdc, uMsg); EndPaint(hWnd, &ps); } else { _ASSERTE(hdc != NULL); } return lRc; } #ifdef _DEBUG RECT rcClientReal = {}; GetClientRect(hWnd, &rcClientReal); MapWindowPoints(hWnd, NULL, (LPPOINT)&rcClientReal, 2); #endif // Если "завис" PostUpdate if (gpConEmu->mp_TabBar->NeedPostUpdate()) gpConEmu->mp_TabBar->Update(); // Go RECT wr, cr; RecalculateFrameSizes(); wr = gpConEmu->GetGuiClientRect(); #ifdef _DEBUG wchar_t szPaint[140]; _wsprintf(szPaint, SKIPCOUNT(szPaint) L"MainClient %s at {%i,%i}-{%i,%i} screen coords, size (%ix%i) calc (%ix%i)", (uMsg == WM_PAINT) ? L"WM_PAINT" : (uMsg == WM_PRINTCLIENT) ? L"WM_PRINTCLIENT" : L"UnknownMsg", LOGRECTCOORDS(rcClientReal), LOGRECTSIZE(rcClientReal), LOGRECTSIZE(wr)); DEBUGSTRPAINT(szPaint); #endif #if defined(CONEMU_TABBAR_EX) #ifdef RED_CLIENT_FILL HBRUSH h = CreateSolidBrush(RGB(255,0,0)); FillRect(hdc, &wr, h); DeleteObject(h); return 0; #endif #endif if (gpSet->isStatusBarShow) { int nHeight = gpSet->StatusBarHeight(); if (nHeight < (wr.bottom - wr.top)) { RECT rcStatus = {wr.left, wr.bottom - nHeight, wr.right, wr.bottom}; gpConEmu->mp_Status->PaintStatus(hdc, &rcStatus); wr.bottom = rcStatus.top; } } cr = wr; DEBUGTEST(FrameDrawStyle dt = gpConEmu->DrawType()); #if defined(CONEMU_TABBAR_EX) RECT tr = {}; if (!gpSet->isTabsInCaption) { _ASSERTE(gpConEmu->GetDwmClientRectTopOffset() == 0); // CheckIt, must be zero if (gpSet->isTabs) { RECT captrect = gpConEmu->CalcRect(CER_TAB, wr, CER_MAINCLIENT); //CalculateCaptionPosition(cr, &captrect); CalculateTabPosition(cr, captrect, &tr); PaintDC dc = {false}; RECT pr = {captrect.left, 0, captrect.right, captrect.bottom}; gpConEmu->BeginBufferedPaint(hdc, pr, dc); gpConEmu->mp_TabBar->PaintTabs(dc, captrect, tr); gpConEmu->EndBufferedPaint(dc, TRUE); } } else if (dt == fdt_Aero || dt == fdt_Win8) { _ASSERTE(gpSet->isTabsInCaption); int nOffset = gpConEmu->GetDwmClientRectTopOffset(); // "Рамка" расширена на клиентскую область, поэтому // нужно зарисовать заголовок черной кистью, иначе идет // искажение цвета для кнопок Min/Max/Close if (gpSet->isTabs) { RECT captrect = gpConEmu->CalcRect(CER_TAB, wr, CER_MAINCLIENT); //CalculateCaptionPosition(cr, &captrect); CalculateTabPosition(cr, captrect, &tr); PaintDC dc = {false}; RECT pr = {captrect.left, 0, captrect.right, captrect.bottom}; gpConEmu->BeginBufferedPaint(hdc, pr, dc); gpConEmu->mp_TabBar->PaintTabs(dc, captrect, tr); gpConEmu->EndBufferedPaint(dc, TRUE); // There is no "Glass" in Win8 mb_WasGlassDraw = IsWindows7 && !IsWindows8; } cr.top += nOffset; } #endif #ifdef _DEBUG int nWidth = (cr.right-cr.left); int nHeight = (cr.bottom-cr.top); #endif WARNING("Пока табы рисуем не сами и ExtendDWM отсутствует - дополнительные изыски с временным DC не нужны"); #if 0 if (!gpSet->isTabsInCaption) { //OnPaintClient(hdc/*, nWidth, nHeight*/); } else // Создадим временный DC, для удобства отрисовки в Glass-режиме и для фикса глюка DWM(?) см.ниже // В принципе, для режима Win2k/XP временный DC можно не создавать, если это будет тормозить { //_ASSERTE(FALSE && "Need to be rewritten"); HDC hdcPaint = CreateCompatibleDC(hdc); HBITMAP hbmp = CreateCompatibleBitmap(hdc, nWidth, nHeight); HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcPaint, hbmp); //OnPaintClient(hdcPaint/*, nWidth, nHeight*/); if ((dt == fdt_Aero) || !(mb_WasGlassDraw && gpConEmu->isZoomed())) { BitBlt(hdc, cr.left, cr.top, nWidth, nHeight, hdcPaint, 0, 0, SRCCOPY); } else { //mb_WasGlassDraw = FALSE; // Какой-то странный глюк DWM. При отключении Glass несколько верхних строк // клиентской области оказываются "разрушенными" - у них остается атрибут "прозрачности" // хотя прозрачность (Glass) уже отключена. В результате эти строки - белесые BITMAPINFOHEADER bi = {sizeof(BITMAPINFOHEADER)}; bi.biWidth = cr.right-cr.left+1; bi.biHeight = GetFrameHeight()+1; bi.biPlanes = 1; bi.biBitCount = 32; COLORREF *pPixels = NULL; HDC hdcTmp = CreateCompatibleDC(hdc); HBITMAP hTmp = CreateDIBSection(hdcTmp, (BITMAPINFO*)&bi, DIB_RGB_COLORS, (void**)&pPixels, NULL, 0); if (hTmp == NULL) { _ASSERTE(hTmp == NULL); BitBlt(hdc, cr.left, cr.top, nWidth, nHeight, hdcPaint, 0, 0, SRCCOPY); } else { HBITMAP hOldTmp = (HBITMAP)SelectObject(hdcTmp, hTmp); BitBlt(hdcTmp, 0, 0, bi.biWidth, bi.biHeight, hdcPaint, 0, 0, SRCCOPY); int i = 0; for (int y = 0; y < bi.biHeight; y++) { for (int x = 0; x < bi.biWidth; x++) { pPixels[i++] |= 0xFF000000; } } BitBlt(hdc, cr.left, cr.top, bi.biWidth, bi.biHeight, hdcTmp, 0, 0, SRCCOPY); if (nHeight > bi.biHeight) BitBlt(hdc, cr.left, cr.top+bi.biHeight, nWidth, nHeight-bi.biHeight, hdcPaint, 0, bi.biHeight, SRCCOPY); SelectObject(hdcTmp, hOldTmp); DeleteObject(hbmp); } DeleteDC(hdcTmp); } SelectObject(hdcPaint, hOldBmp); DeleteObject(hbmp); DeleteDC(hdcPaint); } #endif return 0; }
LRESULT CFrameHolder::OnNcCalcSize(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { RecalculateFrameSizes(); LRESULT lRc = 0; FrameDrawStyle fdt = gpConEmu->DrawType(); NCCALCSIZE_PARAMS* pParm = wParam ? ((NCCALCSIZE_PARAMS*)lParam) : NULL; LPRECT nccr = wParam ? pParm->rgrc : (RECT*)lParam; if (!gpSet->isTabsInCaption) { lRc = DefWindowProc(hWnd, uMsg, wParam, lParam); } else { if (!gpSet->isTabs || !gpSet->isTabsInCaption) { lRc = DefWindowProc(hWnd, uMsg, wParam, lParam); } else { RECT r[3]; r[0] = *nccr; if (wParam) { r[1] = pParm->rgrc[1]; r[2] = pParm->rgrc[2]; } if (fdt == fdt_Aero) { // В Aero (Glass) важно, чтобы клиенская область начиналась с верхнего края окна, // иначе не получится "рисовать по стеклу" nccr->top = r->top; // нада !!! nccr->left = r->left + GetFrameWidth(); nccr->right = r->right - GetFrameWidth(); nccr->bottom = r->bottom - GetFrameHeight(); } else { //TODO: Темы!!! В XP ширина/высота рамки может быть больше nccr->top = r->top + GetFrameHeight() + GetCaptionHeight(); nccr->left = r->left + GetFrameWidth(); nccr->right = r->right - GetFrameWidth(); nccr->bottom = r->bottom - GetFrameHeight(); } } // Наверное имеет смысл сбрасывать всегда, чтобы Win не пыталась // отрисовать невалидное содержимое консоли (она же размер меняет) if (wParam) { //pParm->rgrc[1] = *nccr; //pParm->rgrc[2] = r[2]; memset(pParm->rgrc+1, 0, sizeof(RECT)*2); } } return lRc; }