Exemplo n.º 1
0
void Ctl_DrawBtnBevel (
HDC hDC,            // Handle to DC in which to draw bevel
RECT rRect,         // Rectangle of outer bounds of the bevel
WORD wThickness)    // Thickness, multiple of windows border thicknes
/***********************************************************************/
{
    int i;
    HANDLE hDarkBrush = CreateSolidBrush (GetSysColor(COLOR_BTNSHADOW));
    HANDLE hLightBrush = CreateSolidBrush (RGB(255,255,255));
    HANDLE hOldBrush = SelectObject (hDC,hDarkBrush);
    int cxBorder = GetSystemMetrics (SM_CXBORDER);
    int cyBorder = GetSystemMetrics (SM_CYBORDER);
    int cx,cy;

    for (i=0;i<(int)wThickness;i++)
    {
        cx = i * cxBorder;
        cy = i * cyBorder;
            
        SelectObject (hDC,hLightBrush);
        PatBlt (hDC,rRect.left+cx,rRect.top+cy,
            cxBorder,(rRect.bottom-rRect.top)-2*cy,PATCOPY);
        PatBlt (hDC,rRect.left+cx,rRect.top+cy,
            (rRect.right-rRect.left)-2*cx,cyBorder,PATCOPY);
        SelectObject (hDC,hDarkBrush);
        PatBlt (hDC,rRect.right-cxBorder-cx,rRect.top+cy,
            cxBorder,(rRect.bottom-rRect.top)-2*cy,PATCOPY);
        PatBlt (hDC,rRect.left+cx,rRect.bottom-cyBorder-cy,
            (rRect.right-rRect.left)-2*cx,cyBorder,PATCOPY);
    }
    SelectObject (hDC,hOldBrush);
    DeleteObject (hDarkBrush);
    DeleteObject (hLightBrush);
}
Exemplo n.º 2
0
/*
 * internal
 */
static __inline VOID BltCard(HDC hdc, INT x, INT y, INT dx, INT dy, HDC hdcCard, DWORD dwRasterOp, BOOL bStretch)
{
	if (bStretch)
	{
		StretchBlt(hdc, x, y, dx, dy, hdcCard, 0, 0, CARD_WIDTH, CARD_HEIGHT, dwRasterOp);
	} else
	{
		BitBlt(hdc, x, y, dx, dy, hdcCard, 0, 0, dwRasterOp);
/*
 * This is need when using Microsoft images, because they use two-color red/white images for
 * red cards and thus needs fix-up of the edge to black color.
 */
#if 0
		if (ISREDCARD(card))
		{
			PatBlt(hdc, x, y + 2, 1, dy - 4, BLACKNESS);
			PatBlt(hdc, x + dx - 1, y + 2, 1, dy - 4, BLACKNESS);
			PatBlt(hdc, x + 2, y, dx - 4, 1, BLACKNESS);
			PatBlt(hdc, x + 2, y + dy - 1, dx - 4, 1, BLACKNESS);
	   		SetPixel(hdc, x + 1, y + 1, 0);
	   		SetPixel(hdc, x + dx - 2, y + 1, 0);
   			SetPixel(hdc, x + 1, y + dy - 2, 0);
   			SetPixel(hdc, x + dx - 2, y + dy - 2, 0);
		}
#endif
	}
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------
// Name: HighlightWindow (from MSDN Spy Sample)
// Object: highlight or unhightlight a window
// Parameters : 
//     in : HWND hwnd : target window handle
//          BOOL fDraw : TRUE to draw, FALSE to clear
// Return : TRUE on success
//-----------------------------------------------------------------------------
void CSelectWindow::HighlightWindow( HWND hwnd, BOOL fDraw )
{
    #define DINV                3
    HDC hdc;
    RECT rc;
    BOOL bBorderOn;
    bBorderOn = fDraw;

    if (hwnd == NULL || !IsWindow(hwnd))
        return;

    hdc = GetWindowDC(hwnd);
    GetWindowRect(hwnd, &rc);
    OffsetRect(&rc, -rc.left, -rc.top);

    if (!IsRectEmpty(&rc))
    {
        PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, DINV,  DSTINVERT);
        PatBlt(hdc, rc.left, rc.bottom - DINV, DINV,
            -(rc.bottom - rc.top - 2 * DINV), DSTINVERT);
        PatBlt(hdc, rc.right - DINV, rc.top + DINV, DINV,
            rc.bottom - rc.top - 2 * DINV, DSTINVERT);
        PatBlt(hdc, rc.right, rc.bottom - DINV, -(rc.right - rc.left),
            DINV, DSTINVERT);
    }

    ReleaseDC(hwnd, hdc);
}
Exemplo n.º 4
0
// utility function that uses the PatBlt function to
// render a tracking rectangle
void RenderTrackingRect(IN HDC HDestDC, IN const RECT& RRender)
{
   const int width = RRender.right - RRender.left;
   const int height = RRender.bottom - RRender.top;
   const DWORD dwROP3 = DSTINVERT; // experiment with others

   // render top bar
   PatBlt(HDestDC,
          RRender.left, RRender.top,
          width, line_width,
          dwROP3);
   // render bottom bar
   PatBlt(HDestDC,
          RRender.left, RRender.bottom - line_width,
          width, line_width,
          dwROP3);
   // render left bar
   PatBlt(HDestDC,
          RRender.left, RRender.top + line_width,
          line_width, height - (2 * line_width),
          dwROP3);
   // render right bar
   PatBlt(HDestDC,
          RRender.right - line_width, RRender.top + line_width,
          line_width, height - (2 * line_width),
          dwROP3);

}
Exemplo n.º 5
0
void DrawUIBorder( LPRECT lprc )
{
    HDC hDC;
    int sbx, sby;
	
    hDC = CreateDC( "DISPLAY", NULL, NULL, NULL );
    SelectObject( hDC, GetStockObject( GRAY_BRUSH ) );
    sbx = GetSystemMetrics( SM_CXBORDER );
    sby = GetSystemMetrics( SM_CYBORDER );
    PatBlt( hDC, lprc->left, 
		lprc->top, 
		lprc->right - lprc->left-sbx, 
		sby, PATINVERT );
    PatBlt( hDC, lprc->right - sbx, 
		lprc->top, 
		sbx, 
		lprc->bottom - lprc->top-sby, PATINVERT );
    PatBlt( hDC, lprc->right, 
		lprc->bottom-sby, 
		-(lprc->right - lprc->left-sbx), 
		sby, PATINVERT );
    PatBlt( hDC, lprc->left, 
		lprc->bottom, 
		sbx, 
		-(lprc->bottom - lprc->top-sby), PATINVERT );
    DeleteDC( hDC );
}
Exemplo n.º 6
0
static void Win32_AspectBlt( HDC hdc, win32BackBuffer_t *buffer, int width, int height ) {
	if ( height == 0 ) {
		height = 1;
	}
	if ( width == 0 ) {
		width = 1;
	}
	float scale = 1.f;
	int scaledWidth = buffer->width;
	int scaledHeight = buffer->height;
	if ( width < height ) {
		scaledWidth = width;
		scale = ( ( ( float ) width / ( float ) buffer->width ) + 0.5f );
		scaledHeight = ( int ) ( ( scale * ( float ) buffer->height ) + 0.5f );
	} else {
		scaledHeight = height;
		scale = ( ( ( float ) height / ( float ) buffer->height ) + 0.5f );
		scaledWidth = ( int ) ( ( scale * ( float ) buffer->width ) + 0.5f );
	}
	int x = ( int ) ( ( ( width - scaledWidth ) / 2.f ) + 0.5f );
	int y = ( int ) ( ( ( height - scaledHeight ) / 2.f ) + 0.5f );
	PatBlt( hdc, 0, 0, width, height, WHITENESS );
	PatBlt( hdc, x, y, scaledWidth, scaledHeight, BLACKNESS );
	StretchDIBits( hdc,
		x, y, scaledWidth, scaledHeight,
		0, 0, buffer->width, buffer->height,
		buffer->memory, &buffer->bitmapInfo,
		DIB_RGB_COLORS, SRCCOPY );
	/*PatBlt( hdc, 0, 0, x, y, WHITENESS );
	PatBlt( hdc, x + scaledWidth, y + scaledHeight, width - x, height - y, WHITENESS );*/
}
Exemplo n.º 7
0
/*
 * highlightWindowFrame
 *
 * Highlight (or unhighlight) the specified
 * window handle's frame.
 */
static void
highlightWindowFrame(HWND hWnd)
{
  HDC     hdc;
  RECT    rc;

  if (!IsWindow(hWnd))
    return;

  hdc = GetWindowDC(hWnd);
  GetWindowRect(hWnd, &rc);
  OffsetRect(&rc, -rc.left, -rc.top);

  if (!IsRectEmpty(&rc)) {
    PatBlt(hdc, rc.left, rc.top, rc.right-rc.left, DINV, DSTINVERT);
    PatBlt(hdc, rc.left, rc.bottom-DINV, DINV, -(rc.bottom-rc.top-2*DINV),
	   DSTINVERT);
    PatBlt(hdc, rc.right-DINV, rc.top+DINV, DINV, rc.bottom-rc.top-2*DINV,
	   DSTINVERT);
    PatBlt(hdc, rc.right, rc.bottom-DINV, -(rc.right-rc.left), DINV,
	   DSTINVERT);
  }

  ReleaseDC(hWnd, hdc);
  UpdateWindow(hWnd);
}
Exemplo n.º 8
0
INTERNAL_LINKAGE int 
Win32DisplayBufferInWindow(HDC deviceContext, Win32ScreenBuffer *screenBuffer, Win32WindowSize window_size)
{
    int result = 0;

    int offsetX = 10;
    int offsetY = 10;

#if 0
    // top
    PatBlt(deviceContext, 0, 0, window_size.width, offsetY, BLACKNESS);
    // left
    PatBlt(deviceContext, 0, 0, offsetX, window_size.height, BLACKNESS);
    // bottom
    PatBlt(deviceContext, 0, screenBuffer->height + offsetY, 
            windowSize.width, windowSize.height, BLACKNESS);
    // right
    PatBlt(deviceContext, screenBuffer->width + offsetX, 0, 
            windowSize.width, windowSize.height, BLACKNESS);

#endif
    result = StretchDIBits(deviceContext, 
                           0, 0, window_size.width, window_size.height,
                           0, 0, screenBuffer->width, screenBuffer->height, 
                           screenBuffer->memory,
                           (BITMAPINFO *)&screenBuffer->bitmapInfo, 
                           DIB_RGB_COLORS, SRCCOPY);

    return result;
}
Exemplo n.º 9
0
void DisplayStreamInfos(HWND hW)
{
	HWND hWS=GetDlgItem(hW,IDC_SAREA);
	HDC hdc;RECT r;HBRUSH hBO;int ch,dy,i,j,id;
	
	//----------------------------------------------------//
	
	GetClientRect(hWS,&r);                                // get size of stream display
	hdc=GetDC(hWS);                                       // device context
	r.right--;                                            // leave the right border intact
	ScrollDC(hdc,-1,0,&r,&r,NULL,NULL);                   // scroll one pixel to the left
	
	//----------------------------------------------------//
	
	hBO = (HBRUSH) SelectObject(hdc,hBStream[0]);                    // clean the right border
	PatBlt(hdc,r.right-1,0,1,r.bottom,PATCOPY);
	
	//----------------------------------------------------//
	
	dy=r.bottom/MAXCHAN;                                  // size of one channel area
	
	for(ch=0;ch<MAXCHAN;ch++)                             // loop the channels
  {
		if(s_chan[ch].iIrqDone)
		{
			s_chan[ch].iIrqDone=0;
			PatBlt(hdc,r.right-1,ch*r.bottom/MAXCHAN,
				1,dy,BLACKNESS);
			continue;
    }
		
		
		if(s_chan[ch].bOn)                                  // channel is on?
    {
			j=s_chan[ch].sval;if(j<0)  j=-j;                  // -> get one channel data (-32k ... 32k)
			j=(dy*j)/32768;   if(j==0) j=1;                   // -> adjust to display coords
			i=(dy/2)+(ch*r.bottom/MAXCHAN)-j/2;               // -> position where to paint it
			
			
			
			if     (s_chan[ch].iMute)    id=1;                // -> get color id
			else if(s_chan[ch].bNoise)   id=2;
			else if(s_chan[ch].bFMod==2) id=3;
			else if(s_chan[ch].bFMod==1) id=4;
			else                         id=5;
			
			SelectObject(hdc,hBStream[id]);                   // -> select the brush
			PatBlt(hdc,r.right-1,i,1,j,PATCOPY);              // -> paint the value line
    }
		
		if(ch) SetPixel(hdc,r.right-1,                      // -> not first line?
			ch*r.bottom/MAXCHAN,RGB(0,0,0));    // --> draw the line (one dot scrolled to the left)
  }
	
	//----------------------------------------------------//
	
	SelectObject(hdc,hBO);                                // repair brush
	
	ReleaseDC(hWS,hdc);                                   // release context
}
Exemplo n.º 10
0
void DrawRectangle(HDC hdc, int x1, int y1, int x2, int y2)
{
    HGDIOBJ hOldBrush = ::SelectObject(hdc, ::GetSysColorBrush(COLOR_BTNSHADOW));
    PatBlt(hdc, x1, y1, x2 - x1, 1, PATCOPY);
    PatBlt(hdc, x1, y1, 1, y2 - y1, PATCOPY);
    PatBlt(hdc, x1, y2, x2 - x1, 1, PATCOPY);
    PatBlt(hdc, x2, y1, 1, y2 - y1 + 1, PATCOPY);
    ::SelectObject(hdc, hOldBrush);
}
/**
 * Transfer our buffer into windows via StretchDIBits syscall.
 * @param *buffer A pointer to the buffer info struct. We use a pointer because
 *                it is a fairly big struct so that if the compiler doesn't inline
 *                the code, it would require a 'big' memory copy in the stack. So
 *                we send the pointer even though we do not modify the origin struct.
 */
internal void
Win32TransferBufferToWindows(HDC deviceContext,
                             win32_offscreen_buffer *buffer,
                             int windowWidth, int windowHeight)
{
  if((windowWidth >= 2 * buffer->width) &&
     (windowHeight >= 2 * buffer->height))
  {
    // If we can double stretch the buffer, we do it, because double-sampling
    // will not produce artifacts with StretchDIBits
    StretchDIBits(deviceContext,
                  /*
                  x, y, destWidth, destHeight,
                  x, y, originWidth, originHeight,
                  */
                  0, 0, 2 * buffer->width, 2 * buffer->height,
                  0, 0, buffer->width, buffer->height,
                  buffer->memory,
                  &buffer->info,
                  DIB_RGB_COLORS,
                  SRCCOPY);
  }
  else
  {
    int offsetX = 10;
    int offsetY = 10;

    // We have to clean the rectangles outside of our render target rectangle
    PatBlt(deviceContext, 0, 0, windowWidth, offsetY, BLACKNESS);
    PatBlt(deviceContext, 0, 0, offsetX, windowHeight, BLACKNESS);
    PatBlt(deviceContext, offsetX, offsetY + buffer->height,
                          windowWidth - offsetX, windowHeight - (offsetY + buffer->height),
                          BLACKNESS);
    PatBlt(deviceContext, offsetX + buffer->width, offsetY,
                          windowWidth - (offsetX + buffer->width), windowHeight - offsetY,
                          BLACKNESS);

    // NOTE(Cristián): For prototyping, we're are always going to blit 1-1 pixels
    // to make sure we don't introduce artifacts. This will change when the renderer
    // code is done.
    StretchDIBits(deviceContext,
                  /*
                  x, y, destWidth, destHeight,
                  x, y, originWidth, originHeight,
                  */
                  offsetX, offsetY, buffer->width, buffer->height,
                  0, 0, buffer->width, buffer->height,
                  buffer->memory,
                  &buffer->info,
                  DIB_RGB_COLORS,
                  SRCCOPY);
  }
}
Exemplo n.º 12
0
/*****************************************************************************
*
* TWnd_OnPaint
*
* Handle WM_PAINT message to time window.
*
* HWND hWnd                 - Window handle
*
* Repaint the 3D inset borders around the edge of the client area.
* Repaint the time.
*
*****************************************************************************/
VOID NEAR PASCAL TWnd_OnPaint( HWND hWnd) { PAINTSTRUCT ps; HDC hDC;
HBRUSH hBrOld; int nWidth; int nHeight;

    RECT                    rc;

    GetClientRect(hWnd, &rc);
    nWidth  = rc.right;
    nHeight = rc.bottom;
    
    hDC = BeginPaint(hWnd, &ps);

    hBrOld = (HBRUSH)SelectObject(hDC, GetStockObject(GRAY_BRUSH));
    PatBlt(hDC, 0, 0, 1, nHeight-1, PATCOPY);
    PatBlt(hDC, 1, 0, nWidth-2, 1, PATCOPY);

    SelectObject(hDC, GetStockObject(BLACK_BRUSH));
    PatBlt(hDC, 1, 1, 1, nHeight-3, PATCOPY);
    PatBlt(hDC, 2, 1, nWidth-4, 1, PATCOPY);

    SelectObject(hDC, GetStockObject(WHITE_BRUSH));
    PatBlt(hDC, rc.right-1, 0, 1, nHeight-1, PATCOPY);
    PatBlt(hDC, 0, rc.bottom-1, nWidth, 1, PATCOPY);

    SelectObject(hDC, GetStockObject(LTGRAY_BRUSH));
    PatBlt(hDC, rc.right-2, 1, 1, nHeight-2, PATCOPY);
    PatBlt(hDC, 1, rc.bottom-2, nWidth-2, 1, PATCOPY);
    
    SelectObject(hDC, hBrOld);

    gbRepaint = TRUE;
    PaintTime(hDC);

    EndPaint(hWnd, &ps);
}
Exemplo n.º 13
0
/******************************************************************************
 * DrawBox(hDC, xChar, yChar, wChar, kChar, scale, htSep)
 *
 * purpose: draws the edit box for the character being edited and colors the
 *          grid squares according to the pixels set for the character.
 *
 * params:  HDC hDC         : handle to display context
 *          DWORD xChar      : x-location of char box.
 *          DWORD yChar      : y-location of char box
 *          DWORD wChar      : width of char box
 *          DWORD kChar      : height of char
 *          INT   wScale     : Scale of the squares.
 *          DWORD htSep      : height of square separators
 *
 * returns: none
 *
 * side effects:  alters matBox (global 2-d array with ready pixel info. on
 *                currently displayed box)
 *****************************************************************************/
VOID
DrawBox(
	HDC hDC,
	DWORD xChar,                             /* x-location of char. */
	DWORD yChar,                             /* y-location of char. */
	DWORD wChar,                             /* width of char. */
	DWORD kChar,                             /* height of char */
	INT   wScale,				 /* scale of the squares. */
	DWORD htSep                              /* hgt of square separators */
	)
/* draw a character of separate squares of height 'scale' with sep. 'htSep' */
{
	DWORD i, j, sep;

	if (fAll) {               /* redraw them all */
	    for (j = 0; j < kChar; j++) {
		sep = (j >= font.Ascent) ? htSep : 0;
		for (i = 0; i < wChar; i++) {
		    if (wScale == 1)
			SetPixel(hDC, xChar + i, yChar + j,
				matBox[i][j] == TRUE ? BLACK : WHITE);
		    else
			PatBlt(hDC,
				xChar + wScale * i,
				yChar + wScale * j + sep,
				wScale - htSep,
				wScale - htSep,
				colors[matBox[i][j] == TRUE ? 1 : 0]);
		}
	    }
	}
	else {			/* redraw one just flipped */
	    if (wScale == 1)
		SetPixel(hDC,
			xChar + ptC.x,
			yChar + ptC.y,
			matBox[ptC.x][ptC.y] == TRUE ? BLACK : WHITE);
	    else {
		sep = (((DWORD) ptC.y >= font.Ascent) ? htSep : 0L);
		SelectObject(hDC, hbrGray);
		PatBlt(hDC,
			xChar + wScale * ptC.x,
			yChar + wScale * ptC.y + sep,
			wScale - htSep,
			wScale - htSep,
			colors[matBox[ptC.x][ptC.y]]);
	    }
	}

}
Exemplo n.º 14
0
VOID
TreeListDrawSplitBar(
	__in PTREELIST_OBJECT Object,
	__in LONG x,
	__in LONG y,
	__in BOOLEAN EndTrack
	)
{
    HDC hdc;
	RECT Rect;
	HBRUSH hBrushOld;

	hdc = GetDC(Object->hWnd);
	if (!hdc) {
        return;
	}

	GetClientRect(Object->hWnd, &Rect);
	hBrushOld = SelectObject(hdc, Object->hBrushBar);

    //
    // Clean the splibar we drew last time 
    //

	if (Object->SplitbarLeft > 0) {
		PatBlt(hdc, Object->SplitbarLeft, y, 
			   Object->SplitbarBorder, 
			   Rect.bottom - Rect.top - y, 
			   PATINVERT );
    }

    if (!EndTrack) {

        Rect.left += x;
		PatBlt(hdc, Rect.left, y, Object->SplitbarBorder, 
			   Rect.bottom - Rect.top - y, PATINVERT);

		Object->SplitbarLeft = Rect.left;

    }
    else {

		Object->SplitbarLeft = 0xffff8001;
    }

	SelectObject(hdc, hBrushOld);
	ReleaseDC(Object->hWnd, hdc);
}
Exemplo n.º 15
0
void Vid::SetMode( int ModeValue ) {
	if ( BackBuffer ) {
		Shutdown();
	}

	WindowWidth = ModeList[ModeValue].Width;
	WindowHeight = ModeList[ModeValue].Height;

	BufferHeight = WindowHeight;
	BufferWidth = WindowWidth;

	if ( ModeList[ModeValue].Type == ModeState::WINDOWED ) {
		SetWindowedMode( ModeValue );
	} else {
		SetFullscrenMode( ModeValue );
	}

	ShowWindow( MainWindow, SW_SHOWDEFAULT );

	HDC DeviceContext = GetDC( MainWindow );
	PatBlt( DeviceContext, 0, 0, BufferWidth, BufferHeight, BLACKNESS );
	ReleaseDC( MainWindow, DeviceContext );

	// define our bitmap info
	BitMapInfo.bmiHeader.biSize = sizeof( BitMapInfo.bmiHeader );
	BitMapInfo.bmiHeader.biWidth = BufferWidth;
	BitMapInfo.bmiHeader.biHeight = -BufferHeight;
	BitMapInfo.bmiHeader.biPlanes = 1;
	BitMapInfo.bmiHeader.biBitCount = 8 * BytesPerPixel;
	BitMapInfo.bmiHeader.biCompression = BI_RGB;

	BackBuffer = FrameBuffer( BufferWidth, BufferHeight, BytesPerPixel );
}
Exemplo n.º 16
0
LRESULT CALLBACK MainWindowCallback( HWND   Window,
                                     UINT   Message,
                                     WPARAM WParam,
                                     LPARAM LParam)
{
    LRESULT Result = 0;
    switch(Message){
        case WM_SIZE:
        {
            OutputDebugStringA("WN_SIZE \n" );
            
        }break;
        case WM_DESTROY:
        {
            OutputDebugStringA("WN_DESTROY \n" );
            

        }break;
        case WM_CLOSE:
        {
            OutputDebugStringA("WN_CLOSE \n" );

        }break;
        case WM_ACTIVATEAPP:
        {
            OutputDebugStringA("WM_ACTIVATEAPP \n" );
        }break;
        case WM_PAINT:
        {
            PAINTSTRUCT Paint;
            HDC DeviceContext =  BeginPaint(Window,&Paint );

            int X = Paint.rcPaint.left;
            int Y = Paint.rcPaint.top;
            int Height = Paint.rcPaint.bottom - Paint.rcPaint.top;
            int Width = Paint.rcPaint.right - Paint.rcPaint.left;
            static DWORD operation = WHITENESS;
            PatBlt(DeviceContext,X, Y, Width,Height, operation);
            if(operation == WHITENESS){
                operation  = BLACKNESS;
            }
            else{
                operation = WHITENESS;
            }

            EndPaint(Window, &Paint);
            
        }
        default:
        {
             //OutputDebugStringA("Default  \n" );
            Result = DefWindowProc(Window,Message,WParam,LParam); 
        }break;
        
    }


    return Result;
    
}
Exemplo n.º 17
0
BOOL
MyInvert(
    IN PCONSOLE_INFORMATION Console,
    IN PSMALL_RECT SmallRect
    )

/*++

    invert a rect

--*/

{
    RECT Rect;

    Rect.left = SmallRect->Left-Console->CurrentScreenBuffer->Window.Left;
    Rect.top = SmallRect->Top-Console->CurrentScreenBuffer->Window.Top;
    Rect.right = SmallRect->Right+1-Console->CurrentScreenBuffer->Window.Left;
    Rect.bottom = SmallRect->Bottom+1-Console->CurrentScreenBuffer->Window.Top;
    if (Console->CurrentScreenBuffer->Flags & CONSOLE_TEXTMODE_BUFFER) {
        Rect.left *= Console->CurrentScreenBuffer->BufferInfo.TextInfo.FontSize.X;
        Rect.top *= Console->CurrentScreenBuffer->BufferInfo.TextInfo.FontSize.Y;
        Rect.right *= Console->CurrentScreenBuffer->BufferInfo.TextInfo.FontSize.X;
        Rect.bottom *= Console->CurrentScreenBuffer->BufferInfo.TextInfo.FontSize.Y;
    }
    PatBlt(Console->hDC,
              Rect.left,
              Rect.top,
              Rect.right  - Rect.left,
              Rect.bottom - Rect.top,
              DSTINVERT
             );

    return(TRUE);
}
Exemplo n.º 18
0
HBITMAP E_Util::ConvertIconToBitmap(HICON hIcon, int nWidth, int nHeight, COLORREF clrBackground)
{
	if (hIcon == NULL)
		return NULL;
	HDC hDC = NULL;
	HDC hMemDC = NULL;
	HBITMAP hBitmap = NULL;
	HBITMAP hOldBitmap = NULL;
	HBRUSH hBrush = NULL;
	HBRUSH hOldBrush = NULL;



	BOOL bGotBitmap = false;

	try {
		hDC = ::GetDC(NULL);
		if (hDC != NULL) {
			hBitmap = CreateCompatibleBitmap(hDC, nWidth, nHeight);
			if (hBitmap != NULL) {
				hMemDC = CreateCompatibleDC(hDC);
				if (hMemDC != NULL) {
					// Select the bitmap into the memory device context
					hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);

					hBrush = CreateSolidBrush(clrBackground);
					if (hBrush != NULL) {
						// Fill the bitmap with the background color
						hOldBrush = (HBRUSH)SelectObject(hMemDC, hBrush);
						PatBlt(hMemDC, 0, 0, nWidth, nHeight, PATCOPY);

						// Draw the icon
						DrawIconEx(hMemDC, 0, 0, hIcon, nWidth, nHeight, 0, NULL, DI_IMAGE);
						bGotBitmap = true;
					}
				}
			}
		}

		// Cleanup
		if (hOldBrush != NULL)
			SelectObject(hMemDC, hOldBrush);
		if (hOldBitmap != NULL)
			SelectObject(hMemDC, hOldBitmap);
		if (hBrush != NULL)
			DeleteObject(hBrush);
		if (hMemDC != NULL)
			DeleteDC(hMemDC);
		if (hDC != NULL)
			::ReleaseDC(NULL, hDC);

		if (!bGotBitmap && hBitmap != NULL) {
			DeleteObject(hBitmap);
			hBitmap = NULL;
		}
	}
	catch (...) {
	}
	return hBitmap;
}
Exemplo n.º 19
0
/* Fill a rectangle. */
static int
win_ddb_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
		       gx_color_index color)
{
    fit_fill(dev, x, y, w, h);
    /* Use PatBlt for filling.  Special-case black. */
    if (color == 0)
	PatBlt(wdev->hdcbit, x, y, w, h, rop_write_0s);
    else {
	select_brush((int)color);
	PatBlt(wdev->hdcbit, x, y, w, h, rop_write_pattern);
    }
    win_update((gx_device_win *) dev);

    return 0;
}
Exemplo n.º 20
0
void DrawWndOnParentTransparent(HWND hWnd, PAERO_SUBCLASS_WND_DATA pWndData)
{
    RECT rcWnd;
    VERIFY(GetWindowRect(hWnd, &rcWnd));
    HWND hParent = GetParent(hWnd);
    if(hParent)
    {
        ScreenToClient(hParent, &rcWnd);

        HDC hdc = GetDC(hParent);
        if(hdc)
        {
            BP_PAINTPARAMS params = { sizeof(BP_PAINTPARAMS) };
            params.dwFlags        = BPPF_ERASE;

            HDC hdcPaint = NULL;
            HPAINTBUFFER hBufferedPaint = NULL;
            hBufferedPaint = pWndData->m_pUxTheme->BeginBufferedPaint(hdc, &rcWnd, BPBF_TOPDOWNDIB, &params, &hdcPaint);
            if (hdcPaint)
            {
                VERIFY(PatBlt(hdcPaint, 0, 0, RECTWIDTH(rcWnd), RECTHEIGHT(rcWnd), BLACKNESS));
                VERIFY(S_OK==pWndData->m_pUxTheme->BufferedPaintSetAlpha(hBufferedPaint, &rcWnd, 0x00));
                VERIFY(S_OK==pWndData->m_pUxTheme->EndBufferedPaint(hBufferedPaint, TRUE));    
            }

            VERIFY(1==ReleaseDC(hParent, hdc));
        }
    }
}
Exemplo n.º 21
0
Arquivo: draw.c Projeto: RPG-7/reactos
/*
 * @implemented
 */
INT WINAPI
FillRect(HDC hDC, CONST RECT *lprc, HBRUSH hbr)
{
    BOOL Ret;
    HBRUSH prevhbr = NULL;

    /* Select brush if specified */
    if (hbr)
    {
        /* Handle system colors */
        if (hbr <= (HBRUSH)(COLOR_MENUBAR + 1))
            hbr = GetSysColorBrush(PtrToUlong(hbr) - 1);

        prevhbr = SelectObject(hDC, hbr);
        if (prevhbr == NULL)
            return (INT)FALSE;
    }

    Ret = PatBlt(hDC, lprc->left, lprc->top, lprc->right - lprc->left,
                 lprc->bottom - lprc->top, PATCOPY);

    /* Select old brush */
    if (prevhbr)
        SelectObject(hDC, prevhbr);

    return (INT)Ret;
}
Exemplo n.º 22
0
static void MaskRegion( HDC hdc, RECT * rct, COLORREF cTransparentColor,
                        COLORREF cBackgroundColor )

{
   HDC        hdcTemp, hdcObject, hdcBack, hdcMem;
   POINT      ptSize;
   COLORREF   cColor;
   HBITMAP    bmAndObject, bmAndBack, bmBackOld, bmObjectOld,
              bmAndTemp, bmTempOld, bmAndMem, bmMemOld;
   HBRUSH     hBrush, hBrOld;

   ptSize.x = rct->right - rct->left + 1;
   ptSize.y = rct->bottom - rct->top + 1;

   hBrush      = CreateSolidBrush(cBackgroundColor);

   hdcTemp     = CreateCompatibleDC(hdc);
   hdcObject   = CreateCompatibleDC(hdc);
   hdcBack     = CreateCompatibleDC(hdc);
   hdcMem      = CreateCompatibleDC(hdc);

   bmAndTemp   = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
   bmAndMem    = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
   bmAndObject = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
   bmAndBack   = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);

   bmTempOld   = SelectObject(hdcTemp, bmAndTemp);
   bmMemOld    = SelectObject(hdcMem, bmAndMem);
   bmBackOld   = SelectObject(hdcBack, bmAndBack);
   bmObjectOld = SelectObject(hdcObject, bmAndObject);

   hBrOld      = SelectObject(hdcMem, hBrush);

   BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdc, rct->left, rct->top, SRCCOPY);

   SetMapMode(hdcTemp, GetMapMode(hdc));

   cColor = SetBkColor(hdcTemp, cTransparentColor);

   BitBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY);

   SetBkColor(hdcTemp, cColor);

   BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, NOTSRCCOPY);
   PatBlt(hdcMem, 0,0, ptSize.x, ptSize.y, PATCOPY);
   BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND);
   BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND);
   BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCPAINT);
   BitBlt(hdc, rct->left, rct->top, ptSize.x, ptSize.y, hdcMem, 0, 0, SRCCOPY);

   DeleteObject(SelectObject(hdcMem, hBrOld));
   DeleteObject(SelectObject(hdcTemp, bmTempOld));
   DeleteObject(SelectObject(hdcMem, bmMemOld));
   DeleteObject(SelectObject(hdcBack, bmBackOld));
   DeleteObject(SelectObject(hdcObject, bmObjectOld));
   DeleteDC(hdcMem);
   DeleteDC(hdcBack);
   DeleteDC(hdcObject);
   DeleteDC(hdcTemp);
}
Exemplo n.º 23
0
static void
l_ui_patblt(struct rdp_inst * inst, uint8 opcode, int x, int y, int cx, int cy,
	RD_BRUSH * brush, int bgcolor, int fgcolor)
{
	wfInfo * wfi;
	HBRUSH br;
	HBRUSH org_br;
	int org_bkmode;
	COLORREF org_bkcolor;
	COLORREF org_textcolor;

	wfi = GET_WFI(inst);
	//printf("ui_patblt: style %d x %d y %d cx %d cy %d\n", brush->style, x, y, cx, cy);
	bgcolor = wf_color_convert(wfi, bgcolor, inst->settings->server_depth);
	fgcolor = wf_color_convert(wfi, fgcolor, inst->settings->server_depth);

	br = wf_create_brush(wfi, brush, fgcolor, inst->settings->server_depth);
	org_bkmode = SetBkMode(wfi->drw->hdc, OPAQUE);
	org_bkcolor = SetBkColor(wfi->drw->hdc, bgcolor);
	org_textcolor = SetTextColor(wfi->drw->hdc, fgcolor);
	org_br = (HBRUSH)SelectObject(wfi->drw->hdc, br);
	PatBlt(wfi->drw->hdc, x, y, cx, cy, rop3_code_table[opcode]);
	SelectObject(wfi->drw->hdc, org_br);
	DeleteObject(br);
	SetBkMode(wfi->drw->hdc, org_bkmode);
	SetBkColor(wfi->drw->hdc, org_bkcolor);
	SetTextColor(wfi->drw->hdc, org_textcolor);
	if (wfi->drw == wfi->backstore)
	{
		wf_invalidate_region(wfi, x, y, x + cx, y + cy);
	}
}
Exemplo n.º 24
0
/***********************************************************************
 *           BitBlt    (GDI32.@)
 */
BOOL WINAPI DECLSPEC_HOTPATCH BitBlt( HDC hdcDst, INT xDst, INT yDst, INT width,
                                      INT height, HDC hdcSrc, INT xSrc, INT ySrc, DWORD rop )
{
    if (!rop_uses_src( rop )) return PatBlt( hdcDst, xDst, yDst, width, height, rop );
    else return StretchBlt( hdcDst, xDst, yDst, width, height,
                            hdcSrc, xSrc, ySrc, width, height, rop );
}
Exemplo n.º 25
0
void wf_gdi_patblt(wfContext* wfc, PATBLT_ORDER* patblt)
{
	HBRUSH brush;
	HBRUSH org_brush;
	int org_bkmode;
	UINT32 fgcolor;
	UINT32 bgcolor;
	COLORREF org_bkcolor;
	COLORREF org_textcolor;

	fgcolor = freerdp_color_convert_bgr(patblt->foreColor, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);
	bgcolor = freerdp_color_convert_bgr(patblt->backColor, wfc->srcBpp, wfc->dstBpp, wfc->clrconv);

	brush = wf_create_brush(wfc, &patblt->brush, fgcolor, wfc->srcBpp);
	org_bkmode = SetBkMode(wfc->drawing->hdc, OPAQUE);
	org_bkcolor = SetBkColor(wfc->drawing->hdc, bgcolor);
	org_textcolor = SetTextColor(wfc->drawing->hdc, fgcolor);
	org_brush = (HBRUSH)SelectObject(wfc->drawing->hdc, brush);

	PatBlt(wfc->drawing->hdc, patblt->nLeftRect, patblt->nTopRect,
		patblt->nWidth, patblt->nHeight, gdi_rop3_code(patblt->bRop));

	SelectObject(wfc->drawing->hdc, org_brush);
	DeleteObject(brush);

	SetBkMode(wfc->drawing->hdc, org_bkmode);
	SetBkColor(wfc->drawing->hdc, org_bkcolor);
	SetTextColor(wfc->drawing->hdc, org_textcolor);

	if (wfc->drawing == wfc->primary)
		wf_invalidate_region(wfc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight);
}
Exemplo n.º 26
0
internal void Win32DisplayBufferInWindow(win32_offscreen_buffer *Buffer, HDC DeviceContext, int WindowWidth, int WindowHeight) {
	if ((WindowWidth >= Buffer->Width * 2) && (WindowHeight >= Buffer->Height * 2)) {
		StretchDIBits(DeviceContext, 0, 0, Buffer->Width * 2, Buffer->Height * 2, 0, 0, Buffer->Width, Buffer->Height, Buffer->Memory, &Buffer->Info, DIB_RGB_COLORS, SRCCOPY);
	}
	else {
		int OffsetX = 10;
		int OffsetY = 10;

		PatBlt(DeviceContext, 0, 0, WindowWidth, OffsetY, BLACKNESS);
		PatBlt(DeviceContext, 0, OffsetY + Buffer->Height, WindowWidth, WindowHeight, BLACKNESS);
		PatBlt(DeviceContext, 0, 0, OffsetX, WindowHeight, BLACKNESS);
		PatBlt(DeviceContext, OffsetX + Buffer->Width, 0, WindowWidth, WindowHeight, BLACKNESS);

		StretchDIBits(DeviceContext, OffsetX, OffsetY, Buffer->Width, Buffer->Height, 0, 0, Buffer->Width, Buffer->Height, Buffer->Memory, &Buffer->Info, DIB_RGB_COLORS, SRCCOPY);
	}
}
Exemplo n.º 27
0
void DrawBar(HWND hWindow, int iPos)
/***********************************************************************/
{      
HRGN hClipRgn;                 // the clipping region    
RECT rClient;

LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	return;

HDC hDC = GetDC(hWindow);

// make sure we are clipped to client rect
GetClientRect(hWindow, &rClient);         
hClipRgn = CreateRectRgn(0,0, rClient.right - rClient.left, rClient.bottom - rClient.top);
SelectClipRgn(hDC, hClipRgn);
DeleteObject(hClipRgn); 
 
// draw the bar  
PatBlt(hDC, rClient.left,
			rClient.top + (iPos*lpData->iItemHeight)-(LINE_WIDTH/2),
       		rClient.right-rClient.left,
       		LINE_WIDTH,
       		PATINVERT);   

ReleaseDC(hWindow, hDC);
}
Exemplo n.º 28
0
static void TroughElementDraw(
    void *clientData, void *elementRecord, Tk_Window tkwin,
    Drawable d, Ttk_Box b, unsigned int state)
{
    TroughClientData *cd = clientData;
    TkWinDCState dcState;
    HDC hdc = TkWinGetDrawableDC(Tk_Display(tkwin), d, &dcState);
    HBRUSH hbr;
    COLORREF bk, oldbk, oldtxt;

    hbr = SelectObject(hdc, GetSysColorBrush(COLOR_SCROLLBAR));
    bk = GetSysColor(COLOR_3DHIGHLIGHT);
    oldtxt = SetTextColor(hdc, GetSysColor(COLOR_3DFACE));
    oldbk = SetBkColor(hdc, bk);

    /* WAS: if (bk (COLOR_3DHIGHLIGHT) == GetSysColor(COLOR_WINDOW)) ... */
    if (GetSysColor(COLOR_SCROLLBAR) == GetSysColor(COLOR_BTNFACE)) {
	/* Draw using the pattern brush */
	SelectObject(hdc, cd->PatternBrush);
    }

    PatBlt(hdc, b.x, b.y, b.width, b.height, PATCOPY);
    SetBkColor(hdc, oldbk);
    SetTextColor(hdc, oldtxt);
    SelectObject(hdc, hbr);
    TkWinReleaseDrawableDC(d, hdc, &dcState);
}
Exemplo n.º 29
0
void CMovPlayerFrm::OnPaint()
{


	if(NULL==lpPrimary)return;
	if(DD_OK == lpPrimary->IsLost()){
		
		if(forccNum<3){
			HDC hDC = ::GetDC(m_hWnd);
			HBRUSH brush = CreateSolidBrush(RGB(0, 0, 8));
		
			HBRUSH old_brush = (HBRUSH)SelectObject(hDC,brush);
			PatBlt(hDC,0,0, 800, 600, PATCOPY);
			SelectObject(hDC,old_brush);

			DrawSurface(GetDeviceCaps(hDC,BITSPIXEL));

			DeleteObject(brush);
			::ReleaseDC(m_hWnd,hDC);
		}
	}else{
		lpPrimary->Restore();
		if(lpSrcSurface)lpSrcSurface->Restore();
	}
} 
LRESULT CALLBACK MainWindowCallback(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam) {
	LRESULT result = NULL;
	switch (message) {
	case WM_SIZE: {
	}	break;
	case WM_DESTROY: {
	}	break;
	case WM_CLOSE: {
	}	break;
	case WM_ACTIVATEAPP: {
	}	break;
	case WM_PAINT: {
		PAINTSTRUCT paint;
		HDC deviceContext = BeginPaint(windowHandle, &paint);
		int height = paint.rcPaint.bottom - paint.rcPaint.top;
		int width = paint.rcPaint.right - paint.rcPaint.left;
		PatBlt(deviceContext, paint.rcPaint.left, paint.rcPaint.top, width, height, WHITENESS);
		EndPaint(windowHandle, &paint);
	}	break;
	default: {
		result = DefWindowProc(windowHandle, message, wParam, lParam);
	}	break;
	}
	return result;
}