void CPanelWnd::OnSize(UINT nType, int cx, int cy) { if ( m_bPanelMode && ! m_pSkin && CCoolInterface::IsNewWindows() && ! IsIconic() ) { CRect rc; GetWindowRect( &rc ); rc.OffsetRect( -rc.left, -rc.top ); rc.right++; rc.bottom++; SetWindowRgn( CreateRectRgnIndirect( &rc ), TRUE ); } CChildWnd::OnSize( nType, cx, cy ); }
void track_bar::set_position_internal(unsigned pos) { if (!m_dragging) { POINT pt; GetCursorPos(&pt); ScreenToClient(get_wnd(), &pt); update_hot_status(pt); } RECT rc; get_thumb_rect(&rc); HRGN rgn_old = CreateRectRgnIndirect(&rc); get_thumb_rect(pos, m_range, &rc); HRGN rgn_new = CreateRectRgnIndirect(&rc); CombineRgn(rgn_new, rgn_old, rgn_new, RGN_OR); DeleteObject(rgn_old); m_display_position = pos; //InvalidateRgn(m_wnd, rgn_new, TRUE); RedrawWindow(get_wnd(), 0, rgn_new, RDW_INVALIDATE|RDW_ERASE|RDW_UPDATENOW|RDW_ERASENOW); DeleteObject(rgn_new); }
LOCAL void fb_setcliprect(WINDISPLAY *mod, struct TVRequest *req) { WINWINDOW *win = req->tvr_Op.ClipRect.Window; RECT *cr = &win->fbv_ClipRect; HRGN rgn; cr->left = req->tvr_Op.ClipRect.Rect[0]; cr->top = req->tvr_Op.ClipRect.Rect[1]; cr->right = cr->left + req->tvr_Op.ClipRect.Rect[2]; cr->bottom = cr->top + req->tvr_Op.ClipRect.Rect[3]; rgn = CreateRectRgnIndirect(cr); SelectClipRgn(win->fbv_HDC, rgn); DeleteObject(rgn); }
INT nulldrv_ExcludeClipRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) { DC *dc = get_nulldrv_dc( dev ); RECT rect = get_clip_rect( dc, left, top, right, bottom ); INT ret; HRGN rgn; if (!(rgn = CreateRectRgnIndirect( &rect ))) return ERROR; if (!dc->hClipRgn) create_default_clip_region( dc ); ret = CombineRgn( dc->hClipRgn, dc->hClipRgn, rgn, RGN_DIFF ); DeleteObject( rgn ); if (ret != ERROR) update_dc_clipping( dc ); return ret; }
void MainWindow::OnPaint() { PAINTSTRUCT ps; HDC hdc; hdc = BeginPaint(m_hwnd, &ps); if (m_pPlayer->State() != STATE_CLOSED && m_pPlayer->HasVideo()) { // The player has video, so ask the player to repaint. m_pPlayer->Repaint(hdc); } else { // The player does not have video. Fill in our client region, not // including the area for the toolbar. RECT rcClient; RECT rcToolbar; GetClientRect(m_hwnd, &rcClient); GetClientRect(rebar.Window(), &rcToolbar); HRGN hRgn1 = CreateRectRgnIndirect(&rcClient); HRGN hRgn2 = CreateRectRgnIndirect(&rcToolbar); CombineRgn(hRgn1, hRgn1, hRgn2, RGN_DIFF); FillRgn(hdc, hRgn1, brush); DeleteObject(hRgn1); DeleteObject(hRgn2); } EndPaint(m_hwnd, &ps); }
HDC SharedBitmap::DCProvider::getDC(SharedBitmap* bmp, unsigned* key) { if (!bmp || !bmp->ensureHandle()) return 0; HDC hdc = CreateCompatibleDC(0); if (!hdc) return 0; *key = reinterpret_cast<unsigned>(SelectObject(hdc, bmp->getHandle())); RECT rect = { 0, 0, bmp->width(), bmp->height() }; OwnPtr<HRGN> clipRgn = adoptPtr(CreateRectRgnIndirect(&rect)); SelectClipRgn(hdc, clipRgn.get()); return hdc; }
void vncRegion::SubtractRect(RECT &new_rect) { HRGN newregion; if (region == NULL) return; // Create a new region containing the appropriate rectangle newregion = CreateRectRgnIndirect(&new_rect); // Remove it from the existing region if (CombineRgn(region, region, newregion, RGN_DIFF) == NULLREGION) Clear(); // Now delete the temporary region DeleteObject(newregion); }
void updateHandle(Handle handle, const SkMatrix& ctm, const SkIRect& clip_bounds) override { HDC hdc = static_cast<HDC>(handle); XFORM xf; xf.eM11 = ctm[SkMatrix::kMScaleX]; xf.eM21 = ctm[SkMatrix::kMSkewX]; xf.eDx = ctm[SkMatrix::kMTransX]; xf.eM12 = ctm[SkMatrix::kMSkewY]; xf.eM22 = ctm[SkMatrix::kMScaleY]; xf.eDy = ctm[SkMatrix::kMTransY]; SetWorldTransform(hdc, &xf); HRGN hrgn = CreateRectRgnIndirect(&toRECT(clip_bounds)); int result = SelectClipRgn(hdc, hrgn); SkASSERT(result != ERROR); result = DeleteObject(hrgn); SkASSERT(result != 0); }
/*********************************************************************** * CC_PaintCross [internal] */ static void CC_PaintCross( HWND hDlg, int x, int y) { HDC hDC; int w = GetDialogBaseUnits() - 1; int wc = GetDialogBaseUnits() * 3 / 4; HWND hwnd = GetDlgItem(hDlg, 0x2c6); LPCCPRIV lpp = GetPropW( hDlg, szColourDialogProp ); RECT rect; POINT point, p; HPEN hPen; if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */ { GetClientRect(hwnd, &rect); hDC = GetDC(hwnd); SelectClipRgn( hDC, CreateRectRgnIndirect(&rect)); point.x = ((long)rect.right * (long)x) / (long)MAXHORI; point.y = rect.bottom - ((long)rect.bottom * (long)y) / (long)MAXVERT; if ( lpp->oldcross.left != lpp->oldcross.right ) BitBlt(hDC, lpp->oldcross.left, lpp->oldcross.top, lpp->oldcross.right - lpp->oldcross.left, lpp->oldcross.bottom - lpp->oldcross.top, lpp->hdcMem, lpp->oldcross.left, lpp->oldcross.top, SRCCOPY); lpp->oldcross.left = point.x - w - 1; lpp->oldcross.right = point.x + w + 1; lpp->oldcross.top = point.y - w - 1; lpp->oldcross.bottom = point.y + w + 1; hPen = CreatePen(PS_SOLID, 3, 0x000000); /* -black- color */ hPen = SelectObject(hDC, hPen); MoveToEx(hDC, point.x - w, point.y, &p); LineTo(hDC, point.x - wc, point.y); MoveToEx(hDC, point.x + wc, point.y, &p); LineTo(hDC, point.x + w, point.y); MoveToEx(hDC, point.x, point.y - w, &p); LineTo(hDC, point.x, point.y - wc); MoveToEx(hDC, point.x, point.y + wc, &p); LineTo(hDC, point.x, point.y + w); DeleteObject( SelectObject(hDC, hPen)); ReleaseDC(hwnd, hDC); } }
static bool plot_block(COLORREF col, int x, int y, int width, int height) { HRGN clipregion; HGDIOBJ original = NULL; /* Bail early if we can */ if ((x >= plot_clip.right) || ((x + width) < plot_clip.left) || (y >= plot_clip.bottom) || ((y + height) < plot_clip.top)) { /* Image completely outside clip region */ return true; } /* ensure the plot HDC is set */ if (plot_hdc == NULL) { LOG("HDC not set on call to plotters"); return false; } clipregion = CreateRectRgnIndirect(&plot_clip); if (clipregion == NULL) { return false; } SelectClipRgn(plot_hdc, clipregion); /* Saving the original pen object */ original = SelectObject(plot_hdc,GetStockObject(DC_PEN)); SelectObject(plot_hdc, GetStockObject(DC_PEN)); SelectObject(plot_hdc, GetStockObject(DC_BRUSH)); SetDCPenColor(plot_hdc, col); SetDCBrushColor(plot_hdc, col); Rectangle(plot_hdc, x, y, width, height); SelectObject(plot_hdc,original); /* Restoring the original pen object */ DeleteObject(clipregion); return true; }
static HRGN stubMakeRegionFromRects(PVBOXVIDEOCM_CMD_RECTS pRegions, uint32_t start) { HRGN hRgn, hTmpRgn; uint32_t i; if (pRegions->RectsInfo.cRects<=start) { return INVALID_HANDLE_VALUE; } hRgn = CreateRectRgn(0, 0, 0, 0); for (i=start; i<pRegions->RectsInfo.cRects; ++i) { hTmpRgn = CreateRectRgnIndirect(&pRegions->RectsInfo.aRects[i]); CombineRgn(hRgn, hRgn, hTmpRgn, RGN_OR); DeleteObject(hTmpRgn); } return hRgn; }
//Call this function when the toolbar recieves a WM_MOVE or WM_SIZE void WindowMagnetizer::OnToolbarBoundsChanged() { //No need to erase the last focus rect, the toolbar already covers it lastFocusRect.left=INT_MIN; //Eventually move the toolbar CheckToolbarPos(); BOOL dfw; SystemParametersInfo(SPI_GETDRAGFULLWINDOWS,0,&dfw,0); if(!dfw) { //Completely repaint the toolbar InvalidateRect(toolbar,NULL,TRUE); RECT tbRect; GetWindowRect(toolbar,&tbRect); HRGN refRgn = CreateRectRgnIndirect(&tbRect); FORWARD_WM_NCPAINT(toolbar,refRgn,SendMessage); DeleteRgn(refRgn); } }
//WM_DRAWITEM void PBSettings_OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem) { //Get the PBSDP PenBrushSettingsDlgParam * pbsdp=(PenBrushSettingsDlgParam *)(LONG_PTR)GetWindowLongPtr(hwnd,GWLP_USERDATA); switch(lpDrawItem->CtlID) //Controls switch { case IDC_PB_PREVIEW: //Preview pane { RECT fillRct=lpDrawItem->rcItem; HRGN fillRgn=CreateRectRgnIndirect(&fillRct); ArrowSettings tas=UITC->GetTool<UIArrowline>(IDC_TB_ARROWLINE)->GetArrowSettings(); //Paint the background with a white brush FillRgn(lpDrawItem->hDC,fillRgn,(HBRUSH)GetStockObject(WHITE_BRUSH)); //Select the pen and the brush and set the appropriate settigns BEGIN_SELOBJ(lpDrawItem->hDC,pbsdp->GetPreviewPaneFGCU().GetPen(),hDC_pen); BEGIN_SELOBJ(lpDrawItem->hDC,pbsdp->GetPreviewPaneBGCU().GetBrush(),hDC_brush); pbsdp->GetPreviewPaneFGCU().ApplyACUPs(lpDrawItem->hDC); //Draw a filled rectangle in the left part of the rectangle Rectangle(lpDrawItem->hDC,fillRct.left+5,fillRct.top+5,(fillRct.right-fillRct.left)/2-5,fillRct.bottom-5); //Draw a filled arrow in the top right part of the rectangle MoveToEx(lpDrawItem->hDC,(fillRct.right-fillRct.left)/2+5,fillRct.top+5,NULL); tas.drawSecondArrow=true; ArrowTo(lpDrawItem->hDC,fillRct.right-5,fillRct.bottom-25,&tas); //Draw a line in the bottom right part of the rectangle MoveToEx(lpDrawItem->hDC,(fillRct.right-fillRct.left)/2+5,fillRct.bottom-15,NULL); LineTo(lpDrawItem->hDC,fillRct.right-5,fillRct.bottom-5); //Deselect the pen and the brush END_SELOBJ(lpDrawItem->hDC,hDC_brush); END_SELOBJ(lpDrawItem->hDC,hDC_pen); DeleteRgn(fillRgn); break; } //End IDC_PB_PREVIEW case IDC_PB_B_COLOR: //Color panes case IDC_PB_H_COLORP: { HBRUSH hbr=CreateSolidBrush((lpDrawItem->CtlID==IDC_PB_B_COLOR?pbsdp->GetCurrentCU().GetColor():pbsdp->GetCurrentCU().GetACUPs().bgColor)); FillRect(lpDrawItem->hDC,&lpDrawItem->rcItem,hbr); DeleteBrush(hbr); break; } //End IDC_PB_B_COLOR } }
void CChildWnd::OnSize(UINT nType, int cx, int cy) { CMDIChildWnd::OnSize( nType, cx, cy ); BOOL bMinimized = IsIconic(); BOOL bVisible = IsWindowVisible(); if ( bMinimized && bVisible ) ShowWindow( SW_HIDE ); else if ( ! bMinimized && ! bVisible ) ShowWindow( SW_SHOW ); if ( ! IsIconic() ) { CRect rc; GetWindowRect( &rc ); rc.OffsetRect( -rc.left, -rc.top ); rc.right++; rc.bottom++; SetWindowRgn( CreateRectRgnIndirect( &rc ), TRUE ); } }
void CUpdateBoxHook::DisplayHookProc(HWND hWnd, HDC hDC, LPRECT lpRect) /************************************************************************/ { HRGN hrgnClip; RECT rOld; GetClipBox(hDC, &rOld); if (lpRect) hrgnClip = CreateRectRgn(lpRect->left, lpRect->top, lpRect->right+1, lpRect->bottom+1); else hrgnClip = NULL; // select entire image SelectClipRgn(hDC, hrgnClip); DrawBox(hWnd, hDC); DeleteObject(hrgnClip); hrgnClip = CreateRectRgnIndirect(&rOld); SelectClipRgn(hDC, hrgnClip); DeleteObject(hrgnClip); }
static void PaintWindowThread(void *) { /* First tell the main thread we're started */ _draw_mutex->BeginCritical(); _draw_mutex->SendSignal(); /* Do our best to make sure the main thread is the one that * gets the signal, and not our wait below. */ Sleep(0); /* Now wait for the first thing to draw! */ _draw_mutex->WaitForSignal(); while (_draw_continue) { /* Convert update region from logical to device coordinates. */ POINT pt = {0, 0}; ClientToScreen(_wnd.main_wnd, &pt); OffsetRect(&_wnd.update_rect, pt.x, pt.y); /* Create a device context that is clipped to the region we need to draw. * GetDCEx 'consumes' the update region, so we may not destroy it ourself. */ HRGN rgn = CreateRectRgnIndirect(&_wnd.update_rect); HDC dc = GetDCEx(_wnd.main_wnd, rgn, DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_INTERSECTRGN); PaintWindow(dc); /* Clear update rect. */ SetRectEmpty(&_wnd.update_rect); ReleaseDC(_wnd.main_wnd, dc); /* Flush GDI buffer to ensure drawing here doesn't conflict with any GDI usage in the main WndProc. */ GdiFlush(); _draw_mutex->WaitForSignal(); } _draw_mutex->EndCritical(); _draw_thread->Exit(); }
LPREGION REGION::CombineRegion( HRGN far * pHrgnPrev) { HRGN hrgnDest, hrgnThisOne; switch(m_type) { case I_RECT: I_ASSERT(m_usNumPoints==2); hrgnThisOne = CreateRectRgnIndirect( (LPRECT)m_aPoints); break; case I_ELLIPSE: I_ASSERT(m_usNumPoints==2); hrgnThisOne = CreateEllipticRgnIndirect( (LPRECT)m_aPoints); break; case I_POLYGON: default: hrgnThisOne = CreatePolygonRgn(m_aPoints, m_usNumPoints, WINDING); break; } hrgnDest = CreateRectRgn(0,0,0,0); if (*pHrgnPrev) { I_ASSERT(m_combineMode != I_COMBINE_INITIAL); CombineRgn(hrgnDest, *pHrgnPrev, hrgnThisOne, GetNativeCombineMode()); DeleteObject(*pHrgnPrev); } else CombineRgn(hrgnDest, hrgnThisOne, NULL, RGN_COPY); DeleteObject(hrgnThisOne); *pHrgnPrev = hrgnDest; return (LPREGION) &m_aPoints[m_usNumPoints]; }
static bool disc(int x, int y, int radius, const plot_style_t *style) { PLOT_LOG("disc at %d,%d radius %d", x, y, radius); /* ensure the plot HDC is set */ if (plot_hdc == NULL) { LOG("HDC not set on call to plotters"); return false; } HRGN clipregion = CreateRectRgnIndirect(&plot_clip); if (clipregion == NULL) { return false; } COLORREF col = (DWORD)((style->fill_colour | style->stroke_colour) & 0x00FFFFFF); HPEN pen = CreatePen(PS_GEOMETRIC | PS_SOLID, 1, col); if (pen == NULL) { DeleteObject(clipregion); return false; } HGDIOBJ penbak = SelectObject(plot_hdc, (HGDIOBJ) pen); if (penbak == NULL) { DeleteObject(clipregion); DeleteObject(pen); return false; } HBRUSH brush = CreateSolidBrush(col); if (brush == NULL) { DeleteObject(clipregion); SelectObject(plot_hdc, penbak); DeleteObject(pen); return false; } HGDIOBJ brushbak = SelectObject(plot_hdc, (HGDIOBJ) brush); if (brushbak == NULL) { DeleteObject(clipregion); SelectObject(plot_hdc, penbak); DeleteObject(pen); DeleteObject(brush); return false; } /* RECT r; r.left = x - radius; r.top = y - radius; r.right = x + radius; r.bottom = y + radius; */ SelectClipRgn(plot_hdc, clipregion); if (style->fill_type == PLOT_OP_TYPE_NONE) Arc(plot_hdc, x - radius, y - radius, x + radius, y + radius, x - radius, y - radius, x - radius, y - radius); else Ellipse(plot_hdc, x - radius, y - radius, x + radius, y + radius); SelectClipRgn(plot_hdc, NULL); pen = SelectObject(plot_hdc, penbak); brush = SelectObject(plot_hdc, brushbak); DeleteObject(clipregion); DeleteObject(pen); DeleteObject(brush); return true; }
/************************************************************************* * ScrollDC (X11DRV.@) */ BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *lprcScroll, const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate ) { RECT rcSrc, rcClip, offset; INT dxdev, dydev, res; HRGN DstRgn, clipRgn, visrgn; INT code = X11DRV_START_EXPOSURES; TRACE("dx,dy %d,%d rcScroll %s rcClip %s hrgnUpdate %p lprcUpdate %p\n", dx, dy, wine_dbgstr_rect(lprcScroll), wine_dbgstr_rect(lprcClip), hrgnUpdate, lprcUpdate); /* enable X-exposure events */ if (hrgnUpdate || lprcUpdate) ExtEscape( hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, 0, NULL ); /* get the visible region */ visrgn=CreateRectRgn( 0, 0, 0, 0); GetRandomRgn( hdc, visrgn, SYSRGN); if( !(GetVersion() & 0x80000000)) { /* Window NT/2k/XP */ POINT org; GetDCOrgEx(hdc, &org); OffsetRgn( visrgn, -org.x, -org.y); } /* intersect with the clipping Region if the DC has one */ clipRgn = CreateRectRgn( 0, 0, 0, 0); if (GetClipRgn( hdc, clipRgn) != 1) { DeleteObject(clipRgn); clipRgn=NULL; } else CombineRgn( visrgn, visrgn, clipRgn, RGN_AND); /* only those pixels in the scroll rectangle that remain in the clipping * rect are scrolled. */ if( lprcClip) rcClip = *lprcClip; else GetClipBox( hdc, &rcClip); rcSrc = rcClip; OffsetRect( &rcClip, -dx, -dy); IntersectRect( &rcSrc, &rcSrc, &rcClip); /* if an scroll rectangle is specified, only the pixels within that * rectangle are scrolled */ if( lprcScroll) IntersectRect( &rcSrc, &rcSrc, lprcScroll); /* now convert to device coordinates */ LPtoDP(hdc, (LPPOINT)&rcSrc, 2); TRACE("source rect: %s\n", wine_dbgstr_rect(&rcSrc)); /* also dx and dy */ SetRect(&offset, 0, 0, dx, dy); LPtoDP(hdc, (LPPOINT)&offset, 2); dxdev = offset.right - offset.left; dydev = offset.bottom - offset.top; /* now intersect with the visible region to get the pixels that will * actually scroll */ DstRgn = CreateRectRgnIndirect( &rcSrc); res = CombineRgn( DstRgn, DstRgn, visrgn, RGN_AND); /* and translate, giving the destination region */ OffsetRgn( DstRgn, dxdev, dydev); if( TRACE_ON( scroll)) dump_region( "Destination scroll region: ", DstRgn); /* if there are any, do it */ if( res > NULLREGION) { RECT rect ; /* clip to the destination region, so we can BitBlt with a simple * bounding rectangle */ if( clipRgn) ExtSelectClipRgn( hdc, DstRgn, RGN_AND); else SelectClipRgn( hdc, DstRgn); GetRgnBox( DstRgn, &rect); DPtoLP(hdc, (LPPOINT)&rect, 2); TRACE("destination rect: %s\n", wine_dbgstr_rect(&rect)); BitBlt( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, hdc, rect.left - dx, rect.top - dy, SRCCOPY); } /* compute the update areas. This is the combined clip rectangle * minus the scrolled region, and intersected with the visible * region. */ if (hrgnUpdate || lprcUpdate) { HRGN hrgn = hrgnUpdate; HRGN ExpRgn = 0; /* collect all the exposures */ code = X11DRV_END_EXPOSURES; ExtEscape( hdc, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, sizeof(ExpRgn), (LPSTR)&ExpRgn ); /* Intersect clip and scroll rectangles, allowing NULL values */ if( lprcScroll) if( lprcClip) IntersectRect( &rcClip, lprcClip, lprcScroll); else rcClip = *lprcScroll; else if( lprcClip) rcClip = *lprcClip; else GetClipBox( hdc, &rcClip); /* Convert the combined clip rectangle to device coordinates */ LPtoDP(hdc, (LPPOINT)&rcClip, 2); if( hrgn ) SetRectRgn( hrgn, rcClip.left, rcClip.top, rcClip.right, rcClip.bottom); else hrgn = CreateRectRgnIndirect( &rcClip); CombineRgn( hrgn, hrgn, visrgn, RGN_AND); CombineRgn( hrgn, hrgn, DstRgn, RGN_DIFF); /* add the exposures to this */ if( ExpRgn) { if( TRACE_ON( scroll)) dump_region( "Expose region: ", ExpRgn); CombineRgn( hrgn, hrgn, ExpRgn, RGN_OR); DeleteObject( ExpRgn); } if( TRACE_ON( scroll)) dump_region( "Update region: ", hrgn); if( lprcUpdate) { GetRgnBox( hrgn, lprcUpdate ); /* Put the lprcUpdate in logical coordinates */ DPtoLP( hdc, (LPPOINT)lprcUpdate, 2 ); TRACE("returning lprcUpdate %s\n", wine_dbgstr_rect(lprcUpdate)); } if( !hrgnUpdate) DeleteObject( hrgn); } /* restore original clipping region */ SelectClipRgn( hdc, clipRgn); DeleteObject( visrgn); DeleteObject( DstRgn); if( clipRgn) DeleteObject( clipRgn); return TRUE; }
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { PAINTSTRUCT ps; HDC hdc; #if CLIENT3D | IMAGE | GRAPH3D RECT rc; #endif #if GRAPH3D static int countup = 1; int id; static vec1 gx, gy; #endif #if TIMERDEMO static POINT mousept; #endif #if ARCDEMO static int startdegrees = 0; static int enddegrees = 30; #endif switch( msg) { #if TIMERDEMO case WM_CREATE: SetTimer(hwnd, 1, 100, NULL); mousept.x = 60; mousept.y = 20; break; case WM_TIMER: #if GRAPH3D GetClientRect(hwnd, &rc); if(countup) { mousept.y += 20; if(mousept.y >= rc.bottom) { mousept.y -= 20; countup = 0; } } else { mousept.y -= 20; if(mousept.y < 20) { mousept.y += 20; countup = 1; } } SendMessage(hwnd, WM_MOUSEMOVE, 0, MAKELONG(mousept.x, mousept.y)); #endif #if ARCDEMO startdegrees += 10; if(startdegrees >= 360) startdegrees = 0; enddegrees += 15; if(enddegrees >= 360) enddegrees = 0; InvalidateRect(hwnd, NULL, TRUE); #endif break; case WM_DESTROY: KillTimer(hwnd, 1); break; #endif /* TIMERDEMO*/ case WM_SIZE: break; case WM_MOVE: break; #if CLIENT3D case WM_SETFOCUS: PostMessage((HWND)wp, WM_PAINT, 0, 0L); break; case WM_KILLFOCUS: PostMessage((HWND)wp, WM_PAINT, 0, 0L); break; case WM_ERASEBKGND: if(GetFocus() != hwnd) return DefWindowProc(hwnd, msg, wp, lp); return 1; #endif #if GRAPH3D case WM_ERASEBKGND: if((GetWindowLong(hwnd, GWL_ID) & 03) == 1) return 1; return DefWindowProc(hwnd, msg, wp, lp); #endif case WM_PAINT: hdc = BeginPaint(hwnd, &ps); #if CLIENT3D if(GetFocus() == hwnd) { GetClientRect(hwnd, &rc); Draw3dShadow(hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, GetSysColor(COLOR_3DDKSHADOW), GetSysColor(COLOR_3DLIGHT)); InflateRect(&rc, -1, -1); FillRect(hdc, &rc, GetStockObject(GRAY_BRUSH)); } #endif #if IMAGE GetClientRect(hwnd, &rc); DrawDIB(hdc, rc.left+2, rc.top+2, image2); #endif #if ARCDEMO { int x, y, w, h; RECT rc; if(hdc != NULL) { GetWindowRect(hwnd, &rc); rc.top += 13; InflateRect(&rc, -3, -3); /*Ellipse(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top);*/ /*Arc(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/ /*Pie(hdc, 0, 0, rc.right-rc.left, rc.bottom-rc.top, 0,0, 0,0);*/ x = rc.left; y = rc.top; w = rc.right - rc.left; h = rc.bottom - rc.top; w += 10; GdSetForeground(GdFindColor(RGB(0,255,0))); GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64, enddegrees*64, MWPIE); GdSetForeground(GdFindColor(RGB(0,0,0))); GdArcAngle(hdc->psd, x+w/2, y+h/2, w/2, h/2, startdegrees*64, enddegrees*64, MWARCOUTLINE); /*GdSetForeground(GdFindColor(RGB(255,255,255)));*/ /*GdPoint(hdc->psd, x+w/2, y+h/2);*/ } EndPaint(hwnd, &ps); break; } #endif /* ARCDEMO*/ #if GRAPH3D id = (int)GetWindowLong(hwnd, GWL_ID) & 03; init3(hdc, id == 1? hwnd: NULL); switch(id) { case 0: rose(1.0, 7, 13); break; case 1: /*look3(0.5, 0.7, 1.5);*/ /*look3(0.2, -2 * gy, 1.0+gx);*/ look3(-2 * gx, -2 * gy, 1.2); drawgrid(-8.0, 8.0, 10, -8.0, 8.0, 10); break; case 2: setcolor3(BLACK); circle3(1.0); break; case 3: setcolor3(BLUE); daisy(1.0, 20); break; } #if CLIPDEMO if(id == 1) { HRGN hrgn, hrgn2; /* create circular clip region for effect*/ GetClientRect(hwnd, &rc); InflateRect(&rc, -80, -80); switch((int)GetWindowLong(hwnd, GWL_ID)) { default: hrgn = CreateEllipticRgnIndirect(&rc); break; case 5: hrgn = CreateRoundRectRgn(rc.left, rc.top, rc.right, rc.bottom, 100, 100); break; case 1: hrgn = CreateRectRgnIndirect(&rc); break; } /* erase background, clip out blit area*/ GetClientRect(hwnd, &rc); hrgn2 = CreateRectRgnIndirect(&rc); SelectClipRgn(hdc, hrgn2); ExtSelectClipRgn(hdc, hrgn, RGN_XOR); DeleteObject(hrgn2); GetClientRect(hwnd, &rc); FillRect(hdc, &rc, GetStockObject(BLACK_BRUSH)); /* clip in only blit area*/ SelectClipRgn(hdc, hrgn); DeleteObject(hrgn); } #endif /* CLIPDEMO*/ paint3(hdc); #endif /* GRAPH3D*/ EndPaint(hwnd, &ps); break; case WM_LBUTTONDOWN: break; case WM_MOUSEMOVE: #if GRAPH3D if((GetWindowLong(hwnd, GWL_ID) & 03) == 1) { POINT pt; POINTSTOPOINT(pt, lp); GetClientRect(hwnd, &rc); gx = (vec1)pt.x / rc.right; gy = (vec1)pt.y / rc.bottom; InvalidateRect(hwnd, NULL, FALSE); mousept.x = pt.x; mousept.y = pt.y; } #endif break; case WM_LBUTTONUP: break; case WM_RBUTTONDOWN: break; default: return DefWindowProc( hwnd, msg, wp, lp); } return( 0); }
static bool arc(int x, int y, int radius, int angle1, int angle2, const plot_style_t *style) { PLOT_LOG("arc centre %d,%d radius %d from %d to %d", x, y, radius, angle1, angle2); /* ensure the plot HDC is set */ if (plot_hdc == NULL) { LOG("HDC not set on call to plotters"); return false; } HRGN clipregion = CreateRectRgnIndirect(&plot_clip); if (clipregion == NULL) { return false; } COLORREF col = (DWORD)(style->stroke_colour & 0x00FFFFFF); HPEN pen = CreatePen(PS_GEOMETRIC | PS_SOLID, 1, col); if (pen == NULL) { DeleteObject(clipregion); return false; } HGDIOBJ penbak = SelectObject(plot_hdc, (HGDIOBJ) pen); if (penbak == NULL) { DeleteObject(clipregion); DeleteObject(pen); return false; } int q1, q2; double a1=1.0, a2=1.0, b1=1.0, b2=1.0; q1 = (int) ((angle1 + 45) / 90) - 45; q2 = (int) ((angle2 + 45) / 90) - 45; while (q1 > 4) q1 -= 4; while (q2 > 4) q2 -= 4; while (q1 <= 0) q1 += 4; while (q2 <= 0) q2 += 4; angle1 = ((angle1 + 45) % 90) - 45; angle2 = ((angle2 + 45) % 90) - 45; switch(q1) { case 1: a1 = 1.0; b1 = -tan((M_PI / 180) * angle1); break; case 2: b1 = -1.0; a1 = -tan((M_PI / 180) * angle1); break; case 3: a1 = -1.0; b1 = tan((M_PI / 180) * angle1); break; case 4: b1 = 1.0; a1 = tan((M_PI / 180) * angle1); break; } switch(q2) { case 1: a2 = 1.0; b2 = -tan((M_PI / 180) * angle2); break; case 2: b2 = -1.0; a2 = -tan((M_PI / 180) * angle2); break; case 3: a2 = -1.0; b2 = tan((M_PI / 180) * angle2); break; case 4: b2 = 1.0; a2 = tan((M_PI / 180) * angle2); break; } /* RECT r; r.left = x - radius; r.top = y - radius; r.right = x + radius; r.bottom = y + radius; */ SelectClipRgn(plot_hdc, clipregion); Arc(plot_hdc, x - radius, y - radius, x + radius, y + radius, x + (int)(a1 * radius), y + (int)(b1 * radius), x + (int)(a2 * radius), y + (int)(b2 * radius)); SelectClipRgn(plot_hdc, NULL); pen = SelectObject(plot_hdc, penbak); DeleteObject(clipregion); DeleteObject(pen); return true; }
void CWorkTab::Drawtabs(CGDI* dc) { int m_StrPos = 0; BOOL m_ViewAlltab = TRUE; CRect m_rClient; CBrush cbr; CPen cp; cp.CreatePen(PS_SOLID, 1,::GetSysColor(COLOR_BTNSHADOW)); int m_ianchoScroll=::GetSystemMetrics(SM_CXHSCROLL) * 2; m_EnableR = TRUE; m_EnableL = TRUE; cbr.CreateSolidBrush(m_wd.GetRGBColorXP()); GetClientRect(m_rClient); CRect rectT = m_rectTab; rectT.right = m_btndesplaza.left; rectT.right += 4; dc->FillRect(rectT, &cbr); HPEN hPen = dc->SelectObject(&cp); dc->MoveTo(m_rectTab.left, m_rectTab.top); dc->LineTo(m_btndesplaza.right + 1, m_rectTab.top); dc->Draw3dRect(m_rClient, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHIGHLIGHT)); if (!::IsWindow(m_toolBtn[0].GetSafeHwnd())) { CRect r = m_rectTab; r.right = r.left + 35; r.top += 1; // r.bottom-=1; if (!m_img.Create(IDB_GUI_DOCKBAR, 9, 11, RGB(255, 0, 255))) { //TRACE0("error imagelist"); } m_toolBtn[0].Create(GetSafeHwnd(),SCROLLLEFT, _T(""), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_OWNERDRAW, CRect(0, 0, 0, 0)); m_toolBtn[0].SetToolTip(_T("Scroll Left")); m_toolBtn[0].SethIcon(m_img.ExtractIcon(4)); m_toolBtn[0].ShowDark(FALSE); m_toolBtn[0].SetScrollButton(); m_toolBtn[1].Create(GetSafeHwnd(),SCROLLRIGHT, _T(""), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON | BS_OWNERDRAW, CRect(0, 0, 0, 0)); m_toolBtn[1].SetToolTip(_T("Scroll Right")); m_toolBtn[1].SethIcon(m_img.ExtractIcon(2)); m_toolBtn[1].ShowDark(FALSE); m_toolBtn[1].SetScrollButton(); } if (!::IsWindow(m_scroll.GetSafeHwnd())) { m_scroll.Create(GetSafeHwnd(),0L,NULL,WS_CHILD | WS_VISIBLE | SBS_HORZ, m_rectTab); } CSize szBtn_1 = m_toolBtn[0].GetSizeButton(); CSize szBtn_2 = m_toolBtn[0].GetSizeButton(); CRect rcSpin = CRect(0, 0, szBtn_1.cx + szBtn_2.cx + 2, szBtn_1.cy + szBtn_2.cy); m_StrPos = rcSpin.Width(); if ((m_btndesplaza.left < rcSpin.right) && ! m_btndesplaza.IsRectEmpty()) { m_btndesplaza.left = rcSpin.right + 5; m_btndesplaza.right = m_btndesplaza.left + 5; } PintaSeparador(dc); int m_Space = 8; int m_Pos = 10; int m_right = m_StrPos; if (m_iMinValRec - 26 > m_btndesplaza.left) // No existe suficioente espacio para los tabs { m_ViewAlltab = FALSE; // m_spin.EnableScrollBar(); if (m_PresLeft == TRUE) m_right += m_deplaza; if (m_PresRight == TRUE) m_right += m_deplaza; if (m_deplaza == 0) { m_EnableL = FALSE; m_EnableR = TRUE; //m_spin.EnableScrollBar(ESB_DISABLE_LTUP); } if ((m_iMinValRec + m_deplaza) - 26 <= m_btndesplaza.left) { //m_spin.EnableScrollBar(ESB_DISABLE_RTDN); m_EnableR = FALSE; m_EnableL = TRUE; } } else { m_EnableL = FALSE; m_EnableR = FALSE; // m_spin.EnableScrollBar(ESB_DISABLE_BOTH); m_ViewAlltab = TRUE; m_deplaza = 0; } CRect rectScroll; CRect rectRecorte; rectRecorte.left = m_rectTab.left + m_ianchoScroll; rectRecorte.top = m_rectTab.top; rectRecorte.bottom = m_rectTab.bottom; rectRecorte.right = m_btndesplaza.left; HRGN hRgn= CreateRectRgnIndirect(rectRecorte); dc->SelectClipRgn(hRgn); for (int iCont = 0; iCont < m_Numtabs; iCont++) { //; CTab* ctb = (CTab*)m_pArray[iCont]; CRect mrt = ctb->rect; int ancho = mrt.Width(); mrt.left = m_right; mrt.right = mrt.left + ancho; CPoint Coor[4]; // dibujar la hoja seleccionada if (iCont == 0) { dc->MoveTo(mrt.left, mrt.top); dc->LineTo((mrt.left) + m_rectTab.Height()/2, mrt.bottom - 1); dc->MoveTo((mrt.left) + m_rectTab.Height()/2, mrt.bottom - 1); dc->LineTo((mrt.right) - m_rectTab.Height()/2, mrt.bottom - 1); dc->MoveTo((mrt.right) - m_rectTab.Height()/2, mrt.bottom - 1); if (m_iSelectTab ==iCont) dc->LineTo(mrt.right - 2, mrt.top + 2); else dc->LineTo((mrt.right) - 3, mrt.top+ (m_rectTab.Height()/2)); m_right = mrt.right; } else { // Se dibuja la hoja siguiente a la seleccionada // no se dibuja toda la diagonal y no es la ultima hoja if (iCont - 1 == m_iSelectTab) { dc->MoveTo(mrt.left+ (m_rectTab.Height()/4) + 1, mrt.top + m_rectTab.Height()/2); dc->LineTo((mrt.left) + m_rectTab.Height()/2, mrt.bottom - 1); dc->MoveTo((mrt.left) + m_rectTab.Height()/2, mrt.bottom - 1); dc->LineTo((mrt.right) - m_rectTab.Height()/2, mrt.bottom - 1); dc->MoveTo((mrt.right) - m_rectTab.Height()/2, mrt.bottom - 1); if (iCont == m_Numtabs - 1) dc->LineTo((mrt.right - 2), mrt.top + 2); else dc->LineTo((mrt.right) - 3, mrt.top+ (m_rectTab.Height()/2)); } else { dc->MoveTo(mrt.left, mrt.top); dc->LineTo((mrt.left) + m_rectTab.Height()/2, mrt.bottom - 1); dc->MoveTo((mrt.left) + m_rectTab.Height()/2, mrt.bottom - 1); dc->LineTo((mrt.right) - m_rectTab.Height()/2, mrt.bottom - 1); dc->MoveTo((mrt.right) - m_rectTab.Height()/2, mrt.bottom - 1); if (iCont == m_iSelectTab || iCont == m_Numtabs - 1) dc->LineTo((mrt.right - 2), mrt.top + 2); else dc->LineTo((mrt.right) - 3, mrt.top + 3+ (m_rectTab.Height()/2)); } m_right = mrt.right; } if (iCont == m_iSelectTab) { Coor[0].x = mrt.left; Coor[0].y = mrt.top; Coor[1].x = (mrt.left) + m_rectTab.Height()/2; Coor[1].y = mrt.bottom - 1; Coor[2].x = (mrt.right) - m_rectTab.Height()/2; Coor[2].y = mrt.bottom - 1; Coor[3].x = (mrt.right - 1); Coor[3].y = mrt.top + 3; dc->Polygon(Coor, 4); dc->SelectStockObject(WHITE_PEN); dc->MoveTo(mrt.left + 3, mrt.top + 3); dc->LineTo(mrt.right - 1, mrt.top + 3); dc->MoveTo(mrt.left + 2, mrt.top + 2); dc->LineTo(mrt.right, mrt.top + 2); dc->SelectObject(&cp); } HFONT hFont= dc->SelectObject(CFont((HFONT)GetStockObject(DEFAULT_GUI_FONT))); dc->SetBkMode(TRANSPARENT); CRect mrtt = mrt; mrtt.top += 2; dc->DrawText(ctb->lpMsg, mrtt, DT_SINGLELINE | DT_CENTER | DT_VCENTER); ctb->rect = mrt; m_right -= (m_rectTab.Height()/2); if (!bIniciaArrastre) { CRect m_rectCli; GetClientRect(m_rectCli); if (m_btndesplaza.left <m_rectCli.left + rcSpin.left + 1) { m_btndesplaza.left = m_rectCli.left + rcSpin.left + 5; m_btndesplaza.right = m_btndesplaza.left + 5; PintaSeparador(dc); } m_scroll.SetWindowPos(NULL, m_btndesplaza.right, m_rectTab.top, m_rectCli.right - (m_btndesplaza.left + 5), m_rectTab.Height() - 1, SWP_NOACTIVATE | SWP_NOCOPYBITS); m_scroll.Invalidate(); m_scroll.UpdateWindow(); CSize szBtn = m_toolBtn[0].GetSizeButton(); m_toolBtn[0].MoveWindow(m_rectTab.left + 1, m_rectTab.top + 1, szBtn.cx, m_rectTab.Height() - 2); CSize szBtn1 = m_toolBtn[1].GetSizeButton(); m_toolBtn[1].MoveWindow(m_rectTab.left + szBtn.cx + 1, m_rectTab.top + 1, szBtn1.cx, m_rectTab.Height() - 2); } } cbr.DeleteObject(); dc->SelectClipRgn(NULL); ::DeleteObject(hRgn); cp.DeleteObject(); m_toolBtn[0].Invalidate(); m_toolBtn[0].UpdateWindow(); m_toolBtn[1].Invalidate(); m_toolBtn[1].UpdateWindow(); }
LRESULT CVideoMarkup::OnCreate(UINT, WPARAM, LPARAM, BOOL& ) { // create graphics structures for video and examples HDC hdc = GetDC(); hdcmem = CreateCompatibleDC(hdc); hdcmemExamples = CreateCompatibleDC(hdc); hbm = CreateCompatibleBitmap(hdc,WINDOW_X,WINDOW_Y); hbmExamples = CreateCompatibleBitmap(hdc,EXAMPLEWINDOW_WIDTH,EXAMPLEWINDOW_HEIGHT); SelectObject(hdcmem,hbm); SelectObject(hdcmemExamples,hbmExamples); ReleaseDC(hdc); graphics = new Graphics(hdcmem); graphicsExamples = new Graphics(hdcmemExamples); graphics->SetSmoothingMode(SmoothingModeAntiAlias); graphics->Clear(Color(255,255,255)); graphicsExamples->Clear(Color(255,255,255)); // create the active window region to invalidate HRGN filterRgn = CreateRectRgnIndirect(&m_filterRect); HRGN videoRgn = CreateRectRgnIndirect(&m_videoRect); activeRgn = CreateRectRgnIndirect(&m_filterRect); CombineRgn(activeRgn, filterRgn, videoRgn, RGN_OR); DeleteObject(filterRgn); DeleteObject(videoRgn); hTrashCursor = LoadCursor(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDC_TRASHCURSOR)); hDropCursor = LoadCursor(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(IDC_DROPCURSOR)); // Create the list of samples m_sampleListView.Create(m_hWnd, CRect(VIDEO_X,0,WINDOW_X-5,VIDEO_Y-50), _T(""), WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_BORDER | LVS_ICON | LVS_AUTOARRANGE); // create the list of example images m_hImageList = ImageList_Create(LISTVIEW_SAMPLE_X, LISTVIEW_SAMPLE_Y, ILC_COLOR32 | ILC_MASK, 0, MAX_SAMPLES); ListView_SetImageList(m_sampleListView, m_hImageList, LVSIL_NORMAL); // ListView_SetIconSpacing(m_sampleListView, LISTVIEW_SAMPLE_X*2, LISTVIEW_SAMPLE_Y*1.5); ListView_SetIconSpacing(m_sampleListView, LISTVIEW_SAMPLE_X+20, LISTVIEW_SAMPLE_Y+20); ListView_EnableGroupView(m_sampleListView, TRUE); ListView_SetExtendedListViewStyle(m_sampleListView, LVS_EX_DOUBLEBUFFER | LVS_EX_BORDERSELECT | LVS_EX_FLATSB); // create an image list for the group header images //hGroupHeaderImages = ImageList_Create(400,50,ILC_COLOR32 | ILC_MASK,2,2); //HBITMAP hbmPos = LoadBitmap(_Module.get_m_hInst(), MAKEINTRESOURCE(IDB_THUMBSUP)); //HBITMAP hbmNeg = LoadBitmap(_Module.get_m_hInst(), MAKEINTRESOURCE(IDB_THUMBSDOWN)); //ImageList_Add(hGroupHeaderImages, hbmPos, NULL); //ImageList_Add(hGroupHeaderImages, hbmNeg, NULL); //DeleteObject(hbmPos); //DeleteObject(hbmNeg); //ListView_SetGroupHeaderImageList(m_sampleListView, hGroupHeaderImages); // add the "positive" and "negative" groups AddListViewGroup(m_sampleListView, L"Positive Image Examples", GROUPID_POSSAMPLES); AddListViewGroup(m_sampleListView, L"Negative Image Examples", GROUPID_NEGSAMPLES); AddListViewGroup(m_sampleListView, L"Motion Examples", GROUPID_MOTIONSAMPLES); AddListViewGroup(m_sampleListView, L"Video Range Examples", GROUPID_RANGESAMPLES); AddListViewGroup(m_sampleListView, L"Trash", GROUPID_TRASH); // Create the video slider m_videoControl.Create(m_hWnd, WS_CHILD | WS_VISIBLE | WS_DISABLED ); m_videoControl.MoveWindow(0,VIDEO_Y,VIDEO_X,SLIDER_Y); m_videoControl.ShowWindow(TRUE); m_videoControl.EnableWindow(FALSE); m_videoControl.EnableSelectionRange(false); // Create the filter selector m_filterSelect.Create(m_hWnd, WS_CHILD | WS_VISIBLE | WS_DISABLED); m_filterSelect.MoveWindow(VIDEO_X, VIDEO_Y-50, WINDOW_X-VIDEO_X, WINDOW_Y-VIDEO_Y+50); // Start with "Color" mode selected m_filterSelect.SelectFilter(COLOR_FILTER); m_filterSelect.ShowWindow(TRUE); m_filterSelect.EnableWindow(FALSE); return 0; }
/*********************************************************************** * create_surface */ struct window_surface *create_surface(macdrv_window window, const RECT *rect, struct window_surface *old_surface, BOOL use_alpha) { struct macdrv_window_surface *surface; struct macdrv_window_surface *old_mac_surface = get_mac_surface(old_surface); int width = rect->right - rect->left, height = rect->bottom - rect->top; DWORD *colors; pthread_mutexattr_t attr; int err; DWORD window_background; surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(struct macdrv_window_surface, info.bmiColors[3])); if (!surface) return NULL; err = pthread_mutexattr_init(&attr); if (!err) { err = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); if (!err) err = pthread_mutex_init(&surface->mutex, &attr); pthread_mutexattr_destroy(&attr); } if (err) { HeapFree(GetProcessHeap(), 0, surface); return NULL; } surface->info.bmiHeader.biSize = sizeof(surface->info.bmiHeader); surface->info.bmiHeader.biWidth = width; surface->info.bmiHeader.biHeight = height; /* bottom-up */ surface->info.bmiHeader.biPlanes = 1; surface->info.bmiHeader.biBitCount = 32; surface->info.bmiHeader.biSizeImage = get_dib_image_size(&surface->info); surface->info.bmiHeader.biCompression = BI_RGB; surface->info.bmiHeader.biClrUsed = 0; colors = (DWORD *)((char *)&surface->info + surface->info.bmiHeader.biSize); colors[0] = 0x00ff0000; colors[1] = 0x0000ff00; colors[2] = 0x000000ff; surface->header.funcs = &macdrv_surface_funcs; surface->header.rect = *rect; surface->header.ref = 1; surface->window = window; reset_bounds(&surface->bounds); if (old_mac_surface && old_mac_surface->drawn) { surface->drawn = CreateRectRgnIndirect(rect); OffsetRgn(surface->drawn, -rect->left, -rect->top); if (CombineRgn(surface->drawn, surface->drawn, old_mac_surface->drawn, RGN_AND) <= NULLREGION) { DeleteObject(surface->drawn); surface->drawn = 0; } } update_blit_data(surface); surface->use_alpha = use_alpha; surface->bits = HeapAlloc(GetProcessHeap(), 0, surface->info.bmiHeader.biSizeImage); if (!surface->bits) goto failed; window_background = macdrv_window_background_color(); memset_pattern4(surface->bits, &window_background, surface->info.bmiHeader.biSizeImage); TRACE("created %p for %p %s bits %p-%p\n", surface, window, wine_dbgstr_rect(rect), surface->bits, surface->bits + surface->info.bmiHeader.biSizeImage); return &surface->header; failed: macdrv_surface_destroy(&surface->header); return NULL; }
/***************************************************************************** * IDirectDrawClipper::GetClipList * * Retrieve a copy of the clip list * * Arguments: * rect: Rectangle to be used to clip the clip list or NULL for the * entire clip list. * clip_list: structure for the resulting copy of the clip list. * If NULL, fills Size up to the number of bytes necessary to hold * the entire clip. * clip_list_size: Size of resulting clip list; size of the buffer at clip_list * or, if clip_list is NULL, receives the required size of the buffer * in bytes. * * RETURNS * Either DD_OK or DDERR_* ************************************************************************/ static HRESULT WINAPI ddraw_clipper_GetClipList(IDirectDrawClipper *iface, RECT *rect, RGNDATA *clip_list, DWORD *clip_list_size) { struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface); HRGN region; TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n", iface, wine_dbgstr_rect(rect), clip_list, clip_list_size); wined3d_mutex_lock(); if (clipper->window) { if (!(region = get_window_region(clipper->window))) { wined3d_mutex_unlock(); WARN("Failed to get window region.\n"); return E_FAIL; } } else { if (!(region = clipper->region)) { wined3d_mutex_unlock(); WARN("No clip list set.\n"); return DDERR_NOCLIPLIST; } } if (rect) { HRGN clip_region; if (!(clip_region = CreateRectRgnIndirect(rect))) { wined3d_mutex_unlock(); ERR("Failed to create region.\n"); if (clipper->window) DeleteObject(region); return E_FAIL; } if (CombineRgn(clip_region, region, clip_region, RGN_AND) == ERROR) { wined3d_mutex_unlock(); ERR("Failed to combine regions.\n"); DeleteObject(clip_region); if (clipper->window) DeleteObject(region); return E_FAIL; } if (clipper->window) DeleteObject(region); region = clip_region; } *clip_list_size = GetRegionData(region, *clip_list_size, clip_list); if (rect || clipper->window) DeleteObject(region); wined3d_mutex_unlock(); return DD_OK; }
LRESULT CFrameHolder::OnNcPaint(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { RecalculateFrameSizes(); if (!gpSet->isTabsInCaption) { LRESULT lRc = DefWindowProc(hWnd, uMsg, wParam, lParam); return lRc; } FrameDrawStyle fdt = gpConEmu->DrawType(); if (fdt == fdt_Aero || fdt == fdt_Win8) { LRESULT lRc = DefWindowProc(hWnd, uMsg, wParam, lParam); //TODO: Может быть на "стекле" сразу рисовать, а не в WM_PAINT? return lRc; } if (!gpSet->isTabs) { return DefWindowProc(hWnd, uMsg, wParam, lParam); } RECT dirty_box, dirty, wr = {}, tr = {}, cr = {}, xorRect; BOOL fRegionOwner = FALSE; HDC hdc; HRGN hrgn = (HRGN)wParam; GetWindowRect(hWnd, &wr); CalculateCaptionPosition(wr, &cr); CalculateTabPosition(wr, cr, &tr); // --- Регион формируем всегда сами, иначе в некоторых случаях (XP+ Theming) // --- при выезжании окна из-за пределов экрана (обратно в видимую область) // --- сильно мелькает текст в заголовке //Create a region which covers the whole window. This //must be in screen coordinates //if(TRUE || hrgn == (HRGN)1 || hrgn == NULL) { hrgn = CreateRectRgnIndirect(&wr); dirty_box = wr; fRegionOwner = TRUE; //#ifdef _DEBUG // wchar_t szDbg[255]; // wsprintf(szDbg, L"CFrameHolder::OnNcPaint - New region({%ix%i}-{%ix%i})\n", wr.left,wr.top,wr.right,wr.bottom); // OutputDebugStringW(szDbg); //#endif } //else //{ // GetRgnBox((HRGN)wParam, &dirty_box); // #ifdef _DEBUG // wchar_t szDbg[255]; // wsprintf(szDbg, L"CFrameHolder::OnNcPaint - Existing region({%ix%i}-{%ix%i})\n", dirty_box.left,dirty_box.top,dirty_box.right,dirty_box.bottom); // OutputDebugStringW(szDbg); // #endif //} xorRect = tr; xorRect.top = cr.top; if (gpConEmu->DrawType() == fdt_Aero) { } else if (gpConEmu->DrawType() == fdt_Themed) { xorRect.left = cr.left; xorRect.right = cr.right; } else { xorRect.left = cr.left; //xorRect.right = cr.right; } OffsetRect(&xorRect, wr.left, wr.top); if (IntersectRect(&dirty, &dirty_box, &xorRect)) { // This must be in screen coordinates HRGN hrgn1 = CreateRectRgnIndirect(&xorRect); //Cut out a button-shaped hole CombineRgn(hrgn, hrgn, hrgn1, RGN_XOR); DeleteObject(hrgn1); } //#ifdef _DEBUG //else //{ // OutputDebugStringW(L"CFrameHolder::OnNcPaint --- IntersectRect failed\n"); //} //#endif //if (!mb_NcAnimate) DefWindowProc(hWnd, uMsg, (WPARAM)hrgn, lParam); //#ifdef _DEBUG // Sleep(150); //#endif // Собственно отрисовка табов hdc = GetWindowDC(hWnd); //HRGN hdcrgn = CreateRectRgn(cr.left, cr.top, cr.right, tr.bottom); //hdc = GetDCEx(hWnd, hdcrgn, DCX_INTERSECTRGN); PaintDC dc = {}; gpConEmu->BeginBufferedPaint(hdc, cr, dc); gpConEmu->mp_TabBar->PaintTabs(dc, cr, tr); gpConEmu->EndBufferedPaint(dc, TRUE); //if (mb_WasGlassDraw && gpConEmu->isZoomed()) //{ // //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 hdcPaint = CreateCompatibleDC(hdc); // HBITMAP hbmp = CreateDIBSection(hdcPaint, (BITMAPINFO*)&bi, DIB_RGB_COLORS, (void**)&pPixels, NULL, 0); // HBITMAP hOldBmp = (HBITMAP)SelectObject(hdcPaint, hbmp); // //memset(pPixels, 0xFF, bi.biWidth*bi.biHeight*4); // 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, tr.bottom, bi.biWidth, bi.biHeight, hdcPaint, 0, 0, SRCCOPY); // SelectObject(hdcPaint, hOldBmp); // DeleteObject(hbmp); // DeleteDC(hdcPaint); //} ReleaseDC(hWnd, hdc); if(fRegionOwner) DeleteObject(hrgn); return 0; }
/********************************************************************** * ExtEscape (X11DRV.@) */ static INT X11DRV_ExtEscape( PHYSDEV dev, INT escape, INT in_count, LPCVOID in_data, INT out_count, LPVOID out_data ) { X11DRV_PDEVICE *physDev = get_x11drv_dev( dev ); switch(escape) { case QUERYESCSUPPORT: if (in_data && in_count >= sizeof(DWORD)) { switch (*(const INT *)in_data) { case X11DRV_ESCAPE: return TRUE; } } break; case X11DRV_ESCAPE: if (in_data && in_count >= sizeof(enum x11drv_escape_codes)) { switch(*(const enum x11drv_escape_codes *)in_data) { case X11DRV_SET_DRAWABLE: if (in_count >= sizeof(struct x11drv_escape_set_drawable)) { const struct x11drv_escape_set_drawable *data = in_data; physDev->dc_rect = data->dc_rect; physDev->drawable = data->drawable; XFreeGC( gdi_display, physDev->gc ); physDev->gc = XCreateGC( gdi_display, physDev->drawable, 0, NULL ); XSetGraphicsExposures( gdi_display, physDev->gc, False ); XSetSubwindowMode( gdi_display, physDev->gc, data->mode ); TRACE( "SET_DRAWABLE hdc %p drawable %lx dc_rect %s\n", dev->hdc, physDev->drawable, wine_dbgstr_rect(&physDev->dc_rect) ); return TRUE; } break; case X11DRV_GET_DRAWABLE: if (out_count >= sizeof(struct x11drv_escape_get_drawable)) { struct x11drv_escape_get_drawable *data = out_data; data->drawable = physDev->drawable; data->dc_rect = physDev->dc_rect; return TRUE; } break; case X11DRV_FLUSH_GL_DRAWABLE: if (in_count >= sizeof(struct x11drv_escape_flush_gl_drawable)) { const struct x11drv_escape_flush_gl_drawable *data = in_data; RECT rect = physDev->dc_rect; OffsetRect( &rect, -physDev->dc_rect.left, -physDev->dc_rect.top ); /* The GL drawable may be lagged behind if we don't flush first, so * flush the display make sure we copy up-to-date data */ XFlush( gdi_display ); XSetFunction( gdi_display, physDev->gc, GXcopy ); XCopyArea( gdi_display, data->gl_drawable, physDev->drawable, physDev->gc, 0, 0, rect.right, rect.bottom, physDev->dc_rect.left, physDev->dc_rect.top ); add_device_bounds( physDev, &rect ); return TRUE; } break; case X11DRV_START_EXPOSURES: XSetGraphicsExposures( gdi_display, physDev->gc, True ); physDev->exposures = 0; return TRUE; case X11DRV_END_EXPOSURES: if (out_count >= sizeof(HRGN)) { HRGN hrgn = 0, tmp = 0; XSetGraphicsExposures( gdi_display, physDev->gc, False ); if (physDev->exposures) { for (;;) { XEvent event; XWindowEvent( gdi_display, physDev->drawable, ~0, &event ); if (event.type == NoExpose) break; if (event.type == GraphicsExpose) { RECT rect; rect.left = event.xgraphicsexpose.x - physDev->dc_rect.left; rect.top = event.xgraphicsexpose.y - physDev->dc_rect.top; rect.right = rect.left + event.xgraphicsexpose.width; rect.bottom = rect.top + event.xgraphicsexpose.height; if (GetLayout( dev->hdc ) & LAYOUT_RTL) mirror_rect( &physDev->dc_rect, &rect ); TRACE( "got %s count %d\n", wine_dbgstr_rect(&rect), event.xgraphicsexpose.count ); if (!tmp) tmp = CreateRectRgnIndirect( &rect ); else SetRectRgn( tmp, rect.left, rect.top, rect.right, rect.bottom ); if (hrgn) CombineRgn( hrgn, hrgn, tmp, RGN_OR ); else { hrgn = tmp; tmp = 0; } if (!event.xgraphicsexpose.count) break; } else { ERR( "got unexpected event %d\n", event.type ); break; } } if (tmp) DeleteObject( tmp ); } *(HRGN *)out_data = hrgn; return TRUE; } break; default: break; } } break; } return 0; }
/*********************************************************************** * X11DRV_ExtTextOut */ BOOL CDECL X11DRV_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags, const RECT *lprect, LPCWSTR wstr, UINT count, const INT *lpDx ) { unsigned int i; fontObject* pfo; XFontStruct* font; BOOL rotated = FALSE; XChar2b *str2b = NULL; BOOL dibUpdateFlag = FALSE; BOOL result = TRUE; HRGN saved_region = 0; if(physDev->has_gdi_font) return X11DRV_XRender_ExtTextOut(physDev, x, y, flags, lprect, wstr, count, lpDx); if (!X11DRV_SetupGCForText( physDev )) return TRUE; pfo = XFONT_GetFontObject( physDev->font ); font = pfo->fs; if (pfo->lf.lfEscapement && pfo->lpX11Trans) rotated = TRUE; TRACE("hdc=%p df=%04x %d,%d %s, %d flags=%d lpDx=%p\n", physDev->hdc, (UINT16)(physDev->font), x, y, debugstr_wn (wstr, count), count, flags, lpDx); if (lprect != NULL) TRACE("\trect=(%d,%d - %d,%d)\n", lprect->left, lprect->top, lprect->right, lprect->bottom ); /* Draw the rectangle */ if (flags & ETO_OPAQUE) { X11DRV_LockDIBSection( physDev, DIB_Status_GdiMod ); dibUpdateFlag = TRUE; wine_tsx11_lock(); XSetForeground( gdi_display, physDev->gc, physDev->backgroundPixel ); XFillRectangle( gdi_display, physDev->drawable, physDev->gc, physDev->dc_rect.left + lprect->left, physDev->dc_rect.top + lprect->top, lprect->right - lprect->left, lprect->bottom - lprect->top ); wine_tsx11_unlock(); } if (!count) goto END; /* Nothing more to do */ /* Set the clip region */ if (flags & ETO_CLIPPED) { HRGN clip_region; clip_region = CreateRectRgnIndirect( lprect ); /* make a copy of the current device region */ saved_region = CreateRectRgn( 0, 0, 0, 0 ); CombineRgn( saved_region, physDev->region, 0, RGN_COPY ); X11DRV_SetDeviceClipping( physDev, saved_region, clip_region ); DeleteObject( clip_region ); } /* Draw the text background if necessary */ if (!dibUpdateFlag) { X11DRV_LockDIBSection( physDev, DIB_Status_GdiMod ); dibUpdateFlag = TRUE; } /* Draw the text (count > 0 verified) */ if (!(str2b = X11DRV_cptable[pfo->fi->cptable].punicode_to_char2b( pfo, wstr, count ))) goto FAIL; wine_tsx11_lock(); XSetForeground( gdi_display, physDev->gc, physDev->textPixel ); wine_tsx11_unlock(); if(!rotated) { if (!lpDx) { X11DRV_cptable[pfo->fi->cptable].pDrawString( pfo, gdi_display, physDev->drawable, physDev->gc, physDev->dc_rect.left + x, physDev->dc_rect.top + y, str2b, count ); } else { XTextItem16 *items, *pitem; pitem = items = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XTextItem16) ); if(items == NULL) goto FAIL; for(i = 0; i < count; i++) { pitem->chars = str2b + i; pitem->delta = lpDx[i]; pitem->nchars = 1; pitem->font = None; pitem++; } X11DRV_cptable[pfo->fi->cptable].pDrawText( pfo, gdi_display, physDev->drawable, physDev->gc, physDev->dc_rect.left + x, physDev->dc_rect.top + y, items, pitem - items ); HeapFree( GetProcessHeap(), 0, items ); } } else /* rotated */ { /* have to render character by character. */ double offset = 0.0; UINT i; for (i=0; i<count; i++) { int char_metric_offset = str2b[i].byte2 + (str2b[i].byte1 << 8) - font->min_char_or_byte2; int x_i = IROUND((double) (physDev->dc_rect.left + x) + offset * pfo->lpX11Trans->a / pfo->lpX11Trans->pixelsize ); int y_i = IROUND((double) (physDev->dc_rect.top + y) - offset * pfo->lpX11Trans->b / pfo->lpX11Trans->pixelsize ); X11DRV_cptable[pfo->fi->cptable].pDrawString( pfo, gdi_display, physDev->drawable, physDev->gc, x_i, y_i, &str2b[i], 1); if (lpDx) { offset += lpDx[i]; } else { offset += (double) (font->per_char ? font->per_char[char_metric_offset].attributes: font->min_bounds.attributes) * pfo->lpX11Trans->pixelsize / 1000.0; } } } HeapFree( GetProcessHeap(), 0, str2b ); if (flags & ETO_CLIPPED) { /* restore the device region */ X11DRV_SetDeviceClipping( physDev, saved_region, 0 ); DeleteObject( saved_region ); } goto END; FAIL: HeapFree( GetProcessHeap(), 0, str2b ); result = FALSE; END: if (dibUpdateFlag) X11DRV_UnlockDIBSection( physDev, TRUE ); return result; }
/** * @param hdc - drawing context. * @param prcPaint - the rectangle in which the painting is requested. */ void CTextView::DrawTextView(HDC hdc, RECT* prcPaint) { _ASSERTE(g_pResManager != NULL); if (prcPaint == NULL) { RECT rcClient; GetClientRect(m_hwnd, &rcClient); prcPaint = &rcClient; } if (IsRectEmpty(prcPaint)) return; #ifdef USE_MEM_DC int nClientWidth = prcPaint->right - prcPaint->left; int nClientHeight = prcPaint->bottom - prcPaint->top; HBITMAP hbmpMem; hbmpMem = CreateCompatibleBitmap(hdc, nClientWidth, nClientHeight); if (hbmpMem == NULL) return; HDC hdcMem; hdcMem = CreateCompatibleDC(hdc); if (hdcMem == NULL) { DeleteBitmap(hbmpMem); return; } SetViewportOrgEx(hdcMem, -prcPaint->left, -prcPaint->top, NULL); HBITMAP hbmpSafe = SelectBitmap(hdcMem, hbmpMem); #else // CS_PARENTDC sets the clipping rectangle of the child window to that of the parent window // so that the child can draw on the parent. Text view inherits this style from sub-classed // static control. This causes problems with unclipped TabbedTextOut() output. HRGN hrgn = CreateRectRgnIndirect(prcPaint); SelectClipRgn(hdc, hrgn); DeleteRgn(hrgn); HDC hdcMem = hdc; #endif FillRect(hdcMem, prcPaint, g_pResManager->m_hbrWindowBrush); COLORREF rgbOldTextColor = SetTextColor(hdcMem, GetSysColor(COLOR_WINDOWTEXT)); COLORREF rgbOldBackground = SetBkColor(hdcMem, GetSysColor(COLOR_WINDOW)); HFONT hOldFont = g_pResManager->m_hFixedFont ? SelectFont(hdcMem, g_pResManager->m_hFixedFont) : NULL; TEXTMETRIC tmetr; ::GetTextMetrics(hdcMem, &tmetr); DWORD dwNumLines = m_arrLines.GetCount(); DWORD dwTopLineNum = GetScrollPos(m_hwnd, SB_VERT); DWORD dwTopVisLineNum = dwTopLineNum + prcPaint->top / tmetr.tmHeight; if (dwTopVisLineNum < dwNumLines) { int nHorPos = tmetr.tmAveCharWidth - GetScrollPos(m_hwnd, SB_HORZ); int nVertPos = prcPaint->top - prcPaint->top % tmetr.tmHeight; DWORD dwNumVisLines = prcPaint->bottom / tmetr.tmHeight; if (prcPaint->bottom % tmetr.tmHeight) ++dwNumVisLines; DWORD dwBottomVisLineNum = dwTopLineNum + dwNumVisLines - 1; if (dwBottomVisLineNum >= dwNumLines) dwBottomVisLineNum = dwNumLines - 1; for (DWORD dwLineNum = dwTopVisLineNum; dwLineNum <= dwBottomVisLineNum; ++dwLineNum) { CacheLine(dwLineNum); const CLineInfo& rLineInfo = m_arrLines[(int)dwLineNum]; int nTextWidth = LOWORD(TabbedTextOut(hdcMem, nHorPos, nVertPos, m_pTextCache + rLineInfo.m_dwTextStart, rLineInfo.m_dwLength, 0, NULL, -nHorPos)); if (rLineInfo.m_bTruncated) TextOut(hdcMem, nHorPos + nTextWidth, nVertPos, g_szEllipsis, g_dwEllipsisLength); nVertPos += tmetr.tmHeight; } } SetTextColor(hdcMem, rgbOldTextColor); SetBkColor(hdcMem, rgbOldBackground); if (hOldFont) SelectFont(hdcMem, hOldFont); #ifdef USE_MEM_DC BitBlt(hdc, prcPaint->left, prcPaint->top, nClientWidth, nClientHeight, hdcMem, prcPaint->left, prcPaint->top, SRCCOPY); SelectBitmap(hdcMem, hbmpSafe); DeleteDC(hdcMem); DeleteBitmap(hbmpMem); #endif }
/********************************************************************** * ExtEscape (X11DRV.@) */ static INT X11DRV_ExtEscape( PHYSDEV dev, INT escape, INT in_count, LPCVOID in_data, INT out_count, LPVOID out_data ) { X11DRV_PDEVICE *physDev = get_x11drv_dev( dev ); switch(escape) { case QUERYESCSUPPORT: if (in_data) { switch (*(const INT *)in_data) { case DCICOMMAND: return DD_HAL_VERSION; case X11DRV_ESCAPE: return TRUE; } } break; case X11DRV_ESCAPE: if (in_data && in_count >= sizeof(enum x11drv_escape_codes)) { switch(*(const enum x11drv_escape_codes *)in_data) { case X11DRV_SET_DRAWABLE: if (in_count >= sizeof(struct x11drv_escape_set_drawable)) { const struct x11drv_escape_set_drawable *data = in_data; physDev->dc_rect = data->dc_rect; physDev->drawable = data->drawable; wine_tsx11_lock(); XSetSubwindowMode( gdi_display, physDev->gc, data->mode ); wine_tsx11_unlock(); TRACE( "SET_DRAWABLE hdc %p drawable %lx dc_rect %s\n", dev->hdc, physDev->drawable, wine_dbgstr_rect(&physDev->dc_rect) ); return TRUE; } break; case X11DRV_GET_DRAWABLE: if (out_count >= sizeof(struct x11drv_escape_get_drawable)) { struct x11drv_escape_get_drawable *data = out_data; data->drawable = physDev->drawable; return TRUE; } break; case X11DRV_START_EXPOSURES: wine_tsx11_lock(); XSetGraphicsExposures( gdi_display, physDev->gc, True ); wine_tsx11_unlock(); physDev->exposures = 0; return TRUE; case X11DRV_END_EXPOSURES: if (out_count >= sizeof(HRGN)) { HRGN hrgn = 0, tmp = 0; wine_tsx11_lock(); XSetGraphicsExposures( gdi_display, physDev->gc, False ); wine_tsx11_unlock(); if (physDev->exposures) { for (;;) { XEvent event; wine_tsx11_lock(); XWindowEvent( gdi_display, physDev->drawable, ~0, &event ); wine_tsx11_unlock(); if (event.type == NoExpose) break; if (event.type == GraphicsExpose) { RECT rect; rect.left = event.xgraphicsexpose.x - physDev->dc_rect.left; rect.top = event.xgraphicsexpose.y - physDev->dc_rect.top; rect.right = rect.left + event.xgraphicsexpose.width; rect.bottom = rect.top + event.xgraphicsexpose.height; if (GetLayout( dev->hdc ) & LAYOUT_RTL) mirror_rect( &physDev->dc_rect, &rect ); TRACE( "got %s count %d\n", wine_dbgstr_rect(&rect), event.xgraphicsexpose.count ); if (!tmp) tmp = CreateRectRgnIndirect( &rect ); else SetRectRgn( tmp, rect.left, rect.top, rect.right, rect.bottom ); if (hrgn) CombineRgn( hrgn, hrgn, tmp, RGN_OR ); else { hrgn = tmp; tmp = 0; } if (!event.xgraphicsexpose.count) break; } else { ERR( "got unexpected event %d\n", event.type ); break; } } if (tmp) DeleteObject( tmp ); } *(HRGN *)out_data = hrgn; return TRUE; } break; default: break; } } break; } return 0; }