Ejemplo n.º 1
0
static void StartFilling (OSPictContext context)
{
	switch (context->lastActivity)
	{
		case DRAWING:
			SelectObject (context->hDC, GetStockObject (NULL_PEN));
			SelectObject (context->hDC, context->theNormalBrush);
			break;
		case UNDRAWING:
			SelectObject (context->hDC, GetStockObject (NULL_PEN));
			SelectObject (context->hDC, context->theNormalBrush);
			break;
		case FILLING:
			break;
		case INVERTING:
			if (context->penMode != iModeXor)
				SetROP2 (context->hDC, R2_COPYPEN);
			break;
		case ERASING:
			SelectObject (context->hDC, context->theNormalBrush);
			/* JVG */
			if (context->penMode == iModeXor)
				SetROP2 (context->hDC, R2_NOT);
			/**/
			break;
	}
	context->lastActivity = FILLING;
}	/* StartFilling */
Ejemplo n.º 2
0
static void
l_ui_line(struct rdp_inst * inst, uint8 opcode, int startx, int starty, int endx,
	int endy, RD_PEN * pen)
{
	wfInfo * wfi;
	HPEN hpen;
	HPEN org_hpen;
	int color;
	int org_rop2;

	wfi = GET_WFI(inst);
	//printf("ui_line opcode %d startx %d starty %d endx %d endy %d\n", opcode, startx, starty, endx, endy);
	color = wf_color_convert(wfi, pen->color, inst->settings->server_depth);
	hpen = CreatePen(pen->style, pen->width, color);
	org_rop2 = SetROP2(wfi->drw->hdc, opcode + 1);
	org_hpen = (HPEN)SelectObject(wfi->drw->hdc, hpen);
	MoveToEx(wfi->drw->hdc, startx, starty, NULL);
	LineTo(wfi->drw->hdc, endx, endy);
	SelectObject(wfi->drw->hdc, org_hpen);
	SetROP2 (wfi->drw->hdc, org_rop2);
	DeleteObject(hpen);
	if (wfi->drw == wfi->backstore)
	{
		wf_invalidate_region(wfi, min(startx, endx), min(starty, endy), max(startx, endx), max(starty, endy));
	}
}
Ejemplo n.º 3
0
static void StartInverting (OSPictContext context)
{
	switch (context->lastActivity)
	{
		case UNDRAWING:
			SelectObject (context->hDC, GetStockObject (NULL_PEN));
			SelectObject (context->hDC, context->theNormalBrush);
			SetROP2 (context->hDC, R2_NOT);
			break;
		case DRAWING:
			SelectObject (context->hDC, GetStockObject (NULL_PEN));
			SelectObject (context->hDC, context->theNormalBrush);
			SetROP2 (context->hDC, R2_NOT);
			break;
		case FILLING:
			SetROP2 (context->hDC, R2_NOT);
			break;
		case INVERTING:
			break;
		case ERASING:
			SelectObject (context->hDC, context->theNormalBrush);
			SetROP2 (context->hDC, R2_NOT);
			break;
	}
	context->lastActivity = INVERTING;
}	/* StartInverting */
Ejemplo n.º 4
0
/*
   Effect:        Draw a dotted rectangle to indicate the current outline
                  of the selected widget. This outline moves whenever the
                  user drags || resizes the current widget.

   Note:          All rect, pt units are in screen coordinates.

   Called By:     DrawDragDots, EraseDragDots. This routine is *not* to
                  be called by others.
*/
static void DrawDragDotsInternal(HWND hWnd, HDC hDC, RECT rect, BOOL bXOR) 
{
    HPEN hPenBlack, hOldPen;
    short iOldROP;

    if (IsRectEmpty(&rect))
        return;

    hPenBlack = CreatePen(PS_DOT, 1, RGB_BLACK);
    hOldPen = SelectObject(hDC, hPenBlack);
    if (bXOR)
        iOldROP = SetROP2(hDC, R2_NOTXORPEN);

    KpsScreenRectToClient(hWnd, &rect);
    rect.left += 2;
    rect.right -= 2;
    rect.top += 2;
    rect.bottom -= 2;
    MoveTo(hDC, rect.left, rect.top);
    LineTo(hDC, rect.left, rect.bottom);
    LineTo(hDC, rect.right, rect.bottom);
    LineTo(hDC, rect.right, rect.top);
    LineTo(hDC, rect.left, rect.top);

    if (bXOR)
        SetROP2(hDC, iOldROP);
    DeleteObject(SelectObject(hDC, hOldPen));
}
Ejemplo n.º 5
0
static void mswin_crosshair(int id, int x, int y)
{
    HPEN mswin_cursorpen;
    HPEN oldpen;
    HDC  hdc;
    int oldmode;
    G_PALETTEENTRY g_palette;

    if (WI[id].hdc_cross) {
	g_bell();
	return;
    }
    INTERNAL_get_palette_color(&g_palette, G_WHITE);
    WI[id].hdc_cross = GetDC(WI[id].child[C_DRAWAREA].hwnd);

    mswin_cursorpen = CreatePen(PS_SOLID,
				1,
				RGB(g_palette.r,
				    g_palette.g,
				    g_palette.b));

    oldmode = GetROP2(WI[id].hdc_cross);
    SetROP2(WI[id].hdc_cross, R2_XORPEN);
    oldpen = SelectObject(WI[id].hdc_cross, mswin_cursorpen);

    mswin_draw_cursor_func[id] (id, x, y);

    SelectObject(WI[id].hdc_cross, oldpen);
    DeleteObject(mswin_cursorpen);
    SetROP2(WI[id].hdc_cross, oldmode);

    ReleaseDC(WI[id].child[C_DRAWAREA].hwnd, WI[id].hdc_cross);
    WI[id].hdc_cross = NULL;
}
void DoMouseMove(HWND hWnd,LONG lParam)
{
    HDC hdc;

    if (mouseDown)
    {
	hdc = GetDC(hWnd);
	/*
	 * Erase the old shape.
	 */
	SaveROP = SetROP2(hdc,R2_NOTXORPEN);
	DrawShape(hdc, thisShape[CurrentPoint].Points.left,
		  thisShape[CurrentPoint].Points.top, oldx, oldy,
		  thisShape[CurrentPoint].theShape,
		  thisShape[CurrentPoint].PenWidth,
		  thisShape[CurrentPoint].PenColor, 1);
	/*
	 * At this point, the slope must be positive because
	 * the coordinates could not have been switched.
	 * The next step is to draw the new shape.
	 */

	oldx = LOWORD(lParam);
	oldy = HIWORD(lParam);
	DrawShape(hdc, thisShape[CurrentPoint].Points.left,
		  thisShape[CurrentPoint].Points.top, oldx, oldy,
		  thisShape[CurrentPoint].theShape,
		  thisShape[CurrentPoint].PenWidth,
		  thisShape[CurrentPoint].PenColor, 1);
	SetROP2(hdc,SaveROP);
	ReleaseDC(hWnd,hdc);
    }

}
Ejemplo n.º 7
0
LOCAL void Palette_Select( HDC hDC, HWND hWindow, int iSelect, BOOL on )
/***********************************************************************/
{
RECT SelectRect;
int x1, x2, y1, y2;
short OldROP;
HPEN hOldPen;

if (!Palette_SelectRect(hWindow, iSelect, &SelectRect))
	return;

y1 = SelectRect.top;
y2 = SelectRect.bottom;
x1 = SelectRect.left;
x2 = SelectRect.right;

if (on)
	hOldPen = (HPEN)SelectObject( hDC, GetStockObject(BLACK_PEN) );
else
	hOldPen = (HPEN)SelectObject( hDC, GetStockObject(WHITE_PEN) );
MoveTo(hDC, x1, y1);
LineTo(hDC, x2, y1);
LineTo(hDC, x2, y2);
LineTo(hDC, x1, y2);
LineTo(hDC, x1, y1);
SelectObject(hDC, hOldPen);

OldROP = SetROP2(hDC, R2_NOT);
MoveTo(hDC, x1+1, y1+1);
LineTo(hDC, x2-1, y1+1);
LineTo(hDC, x2-1, y2-1);
LineTo(hDC, x1+1, y2-1);
LineTo(hDC, x1+1, y1+1);
SetROP2(hDC, OldROP);
}
Ejemplo n.º 8
0
/* EXPORT-> HSetXMode: Set current transfer mode */
void HSetXMode(XferMode m)
{ 
   HDC dc = GetDC(theWindow);
   switch(m) {
   case GCOPY:
      SetROP2(memDC,R2_COPYPEN);
      SetROP2(dc,R2_COPYPEN);
      break;
   case GOR:
      SetROP2(memDC,R2_MERGEPEN);
      SetROP2(dc,R2_MERGEPEN);
      break;
   case GXOR:
      SetROP2(memDC,R2_XORPEN);
      SetROP2(dc,R2_XORPEN);
      break;
   case GINVERT: 
      SetROP2(memDC,R2_NOT);
      SetROP2(dc,R2_NOT);
      break;
   default: /* GCOPY */
      SetROP2(memDC,R2_COPYPEN);
      SetROP2(dc,R2_COPYPEN);
      break;
   }
   ReleaseDC(theWindow,dc);
}
Ejemplo n.º 9
0
void CImgAreaWindow::drawZoomFrame(int mouseX, int mouseY)
{
    HDC hdc;
    HPEN oldPen;
    HBRUSH oldBrush;
    LOGBRUSH logbrush;
    int rop;

    RECT clientRectScrollbox;
    RECT clientRectImageArea;
    int x, y, w, h;
    scrollboxWindow.GetClientRect(&clientRectScrollbox);
    GetClientRect(&clientRectImageArea);
    w = clientRectImageArea.right * clientRectScrollbox.right / (clientRectImageArea.right * 2);
    h = clientRectImageArea.bottom * clientRectScrollbox.bottom / (clientRectImageArea.bottom * 2);
    x = max(0, min(clientRectImageArea.right - w, mouseX - w / 2));
    y = max(0, min(clientRectImageArea.bottom - h, mouseY - h / 2));

    hdc = GetDC();
    oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_SOLID, 0, 0));
    logbrush.lbStyle = BS_HOLLOW;
    oldBrush = (HBRUSH) SelectObject(hdc, CreateBrushIndirect(&logbrush));
    rop = SetROP2(hdc, R2_NOT);
    Rectangle(hdc, x, y, x + w, y + h);
    SetROP2(hdc, rop);
    DeleteObject(SelectObject(hdc, oldBrush));
    DeleteObject(SelectObject(hdc, oldPen));
    ReleaseDC(hdc);
}
Ejemplo n.º 10
0
static void paint_cursor(console_private_t *pcp)
{
    int yFirstCursorLine = pcp->yPos * pcp->yCharDimension + pcp->yCharDimension;
    int yLastCursorLine = pcp->yPos * pcp->yCharDimension + pcp->yCharDimension;
    int xLeft =  pcp->xPos * pcp->xCharDimension;
    int xRight = (pcp->xPos + 1) * pcp->xCharDimension - 1;
    int rop2Old;
    POINT point;

    pcp->bCursorBlinkOn = TRUE;

    yFirstCursorLine -= pcp->yCharDimension / (pcp->bInsertMode ? 2 : 4);

    /*
     paint the cursor
    */

    rop2Old = SetROP2(pcp->hdc, R2_NOT);

    while (yFirstCursorLine < yLastCursorLine) {
        MoveToEx(pcp->hdc, xLeft, yFirstCursorLine, &point);
        LineTo(pcp->hdc, xRight, yFirstCursorLine++);
    }

    SetROP2(pcp->hdc, rop2Old);
}
Ejemplo n.º 11
0
VOID DrawOutline(PT *ppt, INT ccrd, DX dx, DY dy)
{
    Y y;
    PT pt;
    INT rop2;
    if(!FGetHdc())
        return;

    pt = *ppt;

    rop2 = SetROP2(hdcCur, R2_NOT);
    MMoveTo(hdcCur, pt.x, pt.y);
    LineTo(hdcCur, pt.x+dxCrd, pt.y);
    LineTo(hdcCur, pt.x+dxCrd, y = pt.y+dyCrd+(ccrd-1) * dy);
    LineTo(hdcCur, pt.x, y);
    LineTo(hdcCur, pt.x, pt.y);
    y = pt.y;
    while(--ccrd)
    {
        y += dy;
        MMoveTo(hdcCur, pt.x, y);
        LineTo(hdcCur, pt.x+dxCrd, y);
    }
    SetROP2(hdcCur, rop2);
    ReleaseHdc();
}
Ejemplo n.º 12
0
static void StartUndrawing (OSPictContext context)
{
	switch (context->lastActivity)
	{
		case UNDRAWING:
			break;
		case DRAWING:
			SelectObject (context->hDC, context->theBackPen);
			SetTextColor (context->hDC, context->backColor);
			break;
		case FILLING:
			SelectObject (context->hDC, context->theBackPen);
			SetTextColor (context->hDC, context->backColor);
			SelectObject (context->hDC, GetStockObject (NULL_BRUSH));
			break;
		case INVERTING:
			SelectObject (context->hDC, context->theBackPen);
			SetTextColor (context->hDC, context->backColor);
			SelectObject (context->hDC, GetStockObject (NULL_BRUSH));
			if (context->penMode != iModeXor)
				SetROP2 (context->hDC, R2_COPYPEN);
			break;
		case ERASING:
			SelectObject (context->hDC, context->theBackPen);
			SetTextColor (context->hDC, context->backColor);
			SelectObject (context->hDC, GetStockObject (NULL_BRUSH));
			/* JVG */
			if (context->penMode == iModeXor)
				SetROP2 (context->hDC, R2_NOT);
			/**/
			break;
	}
	context->lastActivity = UNDRAWING;
}	/* StartUndrawing */
Ejemplo n.º 13
0
void SystemDraw::DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count,
                                       const int *subpolygon_counts, int subpolygon_count_count,
                                       const int *disjunct_polygon_counts, int disjunct_polygon_count_count,
                                       Color color, int width, Color outline, uint64 pattern, Color doxor)
{
    GuiLock __;
    if(vertex_count == 0)
        return;
    bool is_xor = !IsNull(doxor);
    HDC hdc = GetHandle();
    if(pattern) {
        int old_rop = GetROP2(hdc);
        HGDIOBJ old_brush = GetCurrentObject(hdc, OBJ_BRUSH);
        word wpat[8] = {
            (byte)(pattern >> 56), (byte)(pattern >> 48), (byte)(pattern >> 40), (byte)(pattern >> 32),
            (byte)(pattern >> 24), (byte)(pattern >> 16), (byte)(pattern >> 8), (byte)(pattern >> 0),
        };
        HBITMAP bitmap = CreateBitmap(8, 8, 1, 1, wpat);
        HBRUSH brush = ::CreatePatternBrush(bitmap);
        COLORREF old_bk = GetBkColor(hdc);
        COLORREF old_fg = GetTextColor(hdc);
        if(!is_xor) {
            SetROP2(hdc, R2_MASKPEN);
            SelectObject(hdc, brush);
            SetTextColor(hdc, Black());
            SetBkColor(hdc, White());
            SetDrawPen(PEN_NULL, Black);
            DrawPolyPolyPolygonRaw(*this, vertices, vertex_count,
                                   subpolygon_counts, subpolygon_count_count,
                                   disjunct_polygon_counts, disjunct_polygon_count_count);
            SetROP2(hdc, R2_MERGEPEN);
            SetTextColor(hdc, color);
            SetBkColor(hdc, Black());
        }
        else {
            SetROP2(hdc, R2_XORPEN);
            SetTextColor(hdc, COLORREF(color) ^ COLORREF(doxor));
            SelectObject(hdc, brush);
        }
        DrawPolyPolyPolygonRaw(*this, vertices, vertex_count,
                               subpolygon_counts, subpolygon_count_count,
                               disjunct_polygon_counts, disjunct_polygon_count_count);
        SelectObject(hdc, old_brush);
        SetTextColor(hdc, old_fg);
        SetBkColor(hdc, old_bk);
        SetROP2(hdc, old_rop);
        DeleteObject(brush);
        DeleteObject(bitmap);
        if(!IsNull(outline)) {
            SetColor(Null);
            SetDrawPen(width, outline);
            ASSERT(sizeof(POINT) == sizeof(Point));
            DrawPolyPolyPolygonRaw(*this, vertices, vertex_count,
                                   subpolygon_counts, subpolygon_count_count,
                                   disjunct_polygon_counts, disjunct_polygon_count_count);
        }
    }
    else { // simple fill
Ejemplo n.º 14
0
BOOL nulldrv_InvertRgn( PHYSDEV dev, HRGN rgn )
{
    HBRUSH prev_brush = SelectObject( dev->hdc, GetStockObject(BLACK_BRUSH) );
    INT prev_rop = SetROP2( dev->hdc, R2_NOT );
    BOOL ret = PaintRgn( dev->hdc, rgn );
    SelectObject( dev->hdc, prev_brush );
    SetROP2( dev->hdc, prev_rop );
    return ret;
}
Ejemplo n.º 15
0
void ViewPort::DrawEditContour( double pixel_size, double offset_x, double offset_y )
{
	HPEN pen, oldpen;
	HBRUSH brush, oldbrush;
	LOGBRUSH lbrush;
	int oldmode, i, x, y, numpts;
	Contour *c;
	Point *p;
	POINT *lpPoints;

	if ( EditContour && viewDC )
		if ( EditContour->points )
			{
			c = new Contour( *EditContour );				// copy the contour
			
			c->Shift( -offset_x, -offset_y );				// shift into view
			c->Scale( 1.0/pixel_size );						// scale to view's pixels
				
			numpts = c->points->Number();
			lpPoints = new POINT[ numpts ];					// create Window POINT array for drawing

			i = 0;
			p = c->points->first;
			while ( p != NULL )
				{
				lpPoints[i].x = (int)floor(p->x);
				lpPoints[i].y = height - (int)floor(p->y);
				i++;
				p = p->next;
				}
															// create pen for border of object
			pen = CreatePen( PS_DOT, 1, c->border.ref() );
			//pen = CreatePen( PS_SOLID, 1, c->border.ref() );
			oldpen = (HPEN)SelectObject( viewDC, pen );		// set pen into device context

			if ( (c->mode > 0) && c->closed )
				{
				brush = CreateSolidBrush( c->fill.ref() );	// interior will be filled
				oldbrush = (HBRUSH)SelectObject( viewDC, brush );
				SetROP2( viewDC, abs(c->mode) );			// using contour fill mode and color
				Polygon( viewDC, lpPoints, numpts );
				SelectObject( viewDC, oldbrush );			// clean up fill brush
				DeleteObject(brush);
				}

			SelectObject( viewDC, (HBRUSH)GetStockObject(NULL_BRUSH) );	// without coloring interior
			SetROP2( viewDC, R2_COPYPEN );								// draw contour border with pen
			if ( c->closed ) Polygon( viewDC, lpPoints, numpts );
			else Polyline( viewDC, lpPoints, numpts );
			
			SelectObject( viewDC, oldpen );					// clean up pen
			DeleteObject(pen);
			delete[] lpPoints;								// and dynamic memory
			delete c;
			}

}
Ejemplo n.º 16
0
void map_bkg_rectangle(MapGC *mgc, MapSettings *settings,
		       int x, int y, int width, int height)
{
  if (FALSE);
#ifdef HAVE_CAIRO
  else if (mgc->cairo_cr)
    {
      cairo_set_operator(mgc->cairo_cr, CAIRO_OPERATOR_OVER);
      cairo_set_source_rgba(mgc->cairo_cr, .937, .937, .937, .8);
      cairo_rectangle(mgc->cairo_cr, x, y, width, height);
      cairo_fill(mgc->cairo_cr);
      cairo_set_operator(mgc->cairo_cr, CAIRO_OPERATOR_SOURCE);
    }
#endif
#ifdef HAVE_GTK
  else if (mgc->gtk_drawable)
    {
      gdk_gc_set_function(mgc->gtk_gc, GDK_OR);
      gdk_gc_set_foreground(mgc->gtk_gc, &settings->textback);
      gdk_draw_rectangle(mgc->gtk_drawable, mgc->gtk_gc, TRUE,
			 x, y, width, height);
      gdk_gc_set_function(mgc->gtk_gc, GDK_COPY);
    }
#endif
#ifdef HAVE_QT
  else if (mgc->qt_painter)
    {
      qt_bkg_rectangle(mgc->qt_painter, settings,
		       x, y, width, height);
    }
#endif
#ifdef HAVE_QUARTZ
  else if (mgc->quartz_gc)
    {
      CGContextSetRGBFillColor(mgc->quartz_gc, .937, .937, .937, 1.);
      //gdk_gc_set_function(mgc->gtk_gc, GDK_OR);
      //gdk_gc_set_foreground(mgc->gtk_gc, &settings->textback);
      //gdk_draw_rectangle(mgc->gtk_drawable, mgc->gtk_gc, TRUE,
      //		 x, y, width, height);
      //gdk_gc_set_function(mgc->gtk_gc, GDK_COPY);
    }
#endif
#ifdef WIN32
  else if (mgc->win_dc)
    {
      COLORREF color = RGB(0xa5, 0xa6, 0xa5);
      HBRUSH brush = CreateSolidBrush(color);
      HBRUSH oldBrush = SelectObject(mgc->win_dc, brush);
      SetROP2(mgc->win_dc, R2_MERGEPEN);
      win32_setpen(mgc, 4, color);
      Rectangle(mgc->win_dc, x, y, x + width, y + height);
      SetROP2(mgc->win_dc, R2_COPYPEN);
      SelectObject(mgc->win_dc, oldBrush);
      DeleteObject(brush);
    }
#endif
}
Ejemplo n.º 17
0
void _DrawElementColorGrid( ChooseColorsStruct *ccs, HWND hDlg )
   {
   HWND        hWnd;
   HDC         hDC;
   BITMAPINFO  info;
   int         x;
   int         y;
   int         oldROP;


   memset( &info, 0, sizeof( BITMAPINFO ) );

   /* NOTE: -height for top-down images. */

   info.bmiHeader.biSize        = sizeof( BITMAPINFOHEADER );
   info.bmiHeader.biWidth       = ccs->elementColorGridWidth;
   info.bmiHeader.biHeight      = -( ( int )ccs->elementColorGridHeight );
   info.bmiHeader.biPlanes      = 1;
   info.bmiHeader.biBitCount    = 24;
   info.bmiHeader.biCompression = BI_RGB;

   SetDIBits( ccs->elementColorGridMemDC,
              ccs->elementColorGridBitmap,
              0,
              ccs->elementColorGridHeight,
              ccs->elementColorGridPixels,
              &info,
              DIB_RGB_COLORS
            );


   hWnd = GetDlgItem( hDlg, IDS_COLORS_GRID );

   x = ( int )( ccs->elementHsv[ ccs->selectedElement ].saturation / ccs->elementColorGridSaturationStep );
   y = 255 - ( int )( ccs->elementHsv[ ccs->selectedElement ].value / ccs->elementColorGridValueStep );

   oldROP = SetROP2( ccs->elementColorGridMemDC, R2_XORPEN );

   Arc( ccs->elementColorGridMemDC,
        x - 8,
        y - 8,
        x + 8 + 1,
        y + 8 + 1,
        x - 8,
        y,
        x - 8,
        y
      );

   SetROP2( ccs->elementColorGridMemDC, oldROP );

   hDC = GetDC( hWnd );
   BitBlt( hDC, 0, 0, ccs->elementColorGridWidth, ccs->elementColorGridHeight, ccs->elementColorGridMemDC, 0, 0, SRCCOPY );
   ReleaseDC( hWnd, hDC );

   }/* _DrawElementColorGrid() */
Ejemplo n.º 18
0
void tTVPDrawer_DrawDibNoBuffering::NotifyBitmapCompleted(tjs_int x, tjs_int y, const void * bits, const BITMAPINFO * bitmapinfo,
	const tTVPRect &cliprect)
{
	// DrawDibDraw にて TargetDC に描画を行う
	if(DrawDibHandle && TargetDC)
		DrawDibDraw(DrawDibHandle,
			TargetDC,
			x + DestLeft,
			y + DestTop,
			cliprect.get_width(),
			cliprect.get_height(),
			const_cast<BITMAPINFOHEADER*>(reinterpret_cast<const BITMAPINFOHEADER*>(bitmapinfo)),
			const_cast<void*>(bits),
			cliprect.left,
			cliprect.top,
			cliprect.get_width(),
			cliprect.get_height(),
			0);

	// 更新矩形の表示
	if(DrawUpdateRectangle)
	{
		if(!BluePen) BluePen = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
		if(!YellowPen) YellowPen = CreatePen(PS_SOLID, 1, RGB(255, 255, 0));

		HPEN oldpen;

		int ROP_save = GetROP2(TargetDC);

		tjs_int rleft   = x + DestLeft;
		tjs_int rtop    = y + DestTop;
		tjs_int rright  = rleft + cliprect.get_width();
		tjs_int rbottom = rtop  + cliprect.get_height();

		POINT points[5];
		points[0].x = rleft;
		points[0].y = rtop;
		points[1].x = rright -1;
		points[1].y = rtop;
		points[2].x = rright -1;
		points[2].y = rbottom -1;
		points[3].x = rleft;
		points[3].y = rbottom -1;
		points[4] = points[0];

		oldpen = SelectObject(TargetDC, BluePen);
		SetROP2(TargetDC, R2_NOTMASKPEN);
		Polyline(TargetDC, points, 4);

		SelectObject(TargetDC, YellowPen);
		SetROP2(TargetDC, R2_MERGEPEN);
		Polyline(TargetDC, points, 5);

		SelectObject(TargetDC, oldpen);
	}
}
Ejemplo n.º 19
0
//Draws a rectangle on the given DC with a NOT ROP2
void WindowMagnetizer::DrawNotRectangle(HDC hDC, CONST LPRECT rect)
{
	int oldROP=SetROP2(hDC,R2_NOT);
	BEGIN_SELOBJ(hDC,GetStockPen(BLACK_PEN),pen);
	BEGIN_SELOBJ(hDC,GetStockBrush(NULL_BRUSH),brush);
	Rectangle(hDC,rect->left,rect->top,rect->right,rect->bottom);
	END_SELOBJ(hDC,brush);
	END_SELOBJ(hDC,pen);
	SetROP2(hDC,oldROP);
};
Ejemplo n.º 20
0
// -----------------------------------------------------------------------
// Changes the Color to use when rendering onto the canvas.
// -----------------------------------------------------------------------
void MWcanvas16::color(const Color* c)
{
    // ---- render anything that was buffered ----
    flush();

    // ---- reference new color ----
    Resource::ref(c);
    Resource::unref(lg_color_);
    lg_color_ = c;

    // ---- set new pen color ----
    pen_stats_.lopnColor = c->rep()->msColor();
    pen_ = CreatePenIndirect(&pen_stats_);
    DeleteObject( SelectObject(drawable_, pen_));

    // ----  set new brush color ----
    if (c->rep()->stipple)
    {
        // THIS NEEDS WORK
        //
        // brush_stats_.lbStyle = BS_PATTERN;
        // brush_stats_.lbHatch = (long) c->rep()->stipple->hbm_;
    }
    else
    {
        brush_stats_.lbStyle = BS_SOLID;
        brush_stats_.lbColor = c->rep()->msColor();
    }
    brush_ = CreateBrushIndirect(&brush_stats_);
    DeleteObject( SelectObject(drawable_, brush_));

    // ---- set text color ----
    SetTextColor(drawable_, c->rep()->msColor());

    // ---- set color operation ----
    ColorRep* r = c->rep();
    if (r->op == Color::Copy)
    {
        SetROP2(drawable_, R2_COPYPEN);
    }
    else if (r->op == Color::Xor)
    {
//		SetROP2(drawable_, R2_XORPEN);
        SetROP2(drawable_, 6);   // this is insane, but...
    }
    else if (r->op == Color::Invisible)
    {
        SetROP2(drawable_, R2_NOP);
    }
    else
    {
        // ----- unrecognized color mode ----
        MWassert(0);
    }
}
void 
FrameWindowSplitter::DrawTrackerLine()
{
    wyInt32 rop;
    HPEN    hpen;
    
    rop = SetROP2(m_hdc, R2_NOTXORPEN);
    hpen = (HPEN)SelectObject(m_hdc, m_hpen);
    MoveToEx(m_hdc, m_x, m_rect.top + 1, NULL);
    LineTo(m_hdc, m_x, m_rect.bottom);
    SelectObject(m_hdc, hpen);
    SetROP2(m_hdc, rop);
}
void 
TabEditorSplitter::DrawTrackerLine()
{
    wyInt32 rop;
    HPEN    hpen;

    rop = SetROP2(m_hdc, R2_NOTXORPEN);
    hpen = (HPEN)SelectObject(m_hdc, m_hpen);
    MoveToEx(m_hdc, m_rect.left, m_y, NULL);
    LineTo(m_hdc, m_rect.right, m_y);
    SelectObject(m_hdc, hpen);
    SetROP2(m_hdc, rop);
}
Ejemplo n.º 23
0
void bar3d(int left, int top, int right, int bottom, int depth, int topflag)
{
    int temp;
    const double tan30 = 1.0/1.73205080756887729352;
    if (left > right) {     /* Turbo C corrects for badly ordered corners */
	temp = left;
	left = right;
	right = temp;
    }
    if (bottom < top) {
	temp = bottom;
	bottom = top;
	top = temp;
    }
    bar(left+line_settings.thickness, top+line_settings.thickness, 
	right-line_settings.thickness+1, bottom-line_settings.thickness+1);

    if (write_mode != COPY_PUT) { 
	SetROP2(hdc[0], write_mode_cnv[write_mode]);
	SetROP2(hdc[1], write_mode_cnv[write_mode]);
    } 
    pcache.select(ADJUSTED_MODE(write_mode) ? color : color + BG);
    int dy = int(depth*tan30);
    POINT p[11];
    p[0].x = right, p[0].y = bottom;
    p[1].x = right, p[1].y = top;
    p[2].x = left,  p[2].y = top;
    p[3].x = left,  p[3].y = bottom;
    p[4].x = right, p[4].y = bottom;
    p[5].x = right+depth, p[5].y = bottom-dy;
    p[6].x = right+depth, p[6].y = top-dy;
    p[7].x = right, p[7].y = top;

    if (topflag) { 
	p[8].x = right+depth, p[8].y = top-dy;
	p[9].x = left+depth, p[9].y = top-dy;
	p[10].x = left, p[10].y = top;	
    }
    if (bgiemu_handle_redraw || visual_page != active_page) { 
	Polyline(hdc[1], p, topflag ? 11 : 8);
    }
    if (visual_page == active_page) { 
	Polyline(hdc[0], p, topflag ? 11 : 8);
    }
    if (write_mode != COPY_PUT) { 
	SetROP2(hdc[0], R2_COPYPEN);
	SetROP2(hdc[1], R2_COPYPEN);
    }
}
Ejemplo n.º 24
0
void LocationDialog::displayCross(HWND hDlg, double latitude, double longitude)
{
    short xImage, yImage;
    HWND hMap = GetDlgItem(hDlg, IDC_MAP_PICTURE);

    HDC hDC = GetDC(hMap);
    if (hDC == NULL)
        return;
    int oRop = SetROP2(hDC, R2_XORPEN);
    HPEN pen = CreatePen(PS_SOLID, 3, CROSS_COLOR);
    HPEN oPen = (HPEN)SelectObject(hDC, pen);

    HRGN hrgn = CreateRectRgn(1, 1, mapWidth, mapHeight - 1);
    if (hrgn != NULL) {
        SelectClipRgn(hDC, hrgn);
        DeleteObject(hrgn);
    }
                                 
    // calculation of x-coordinate differs in sign from original map,
    //   which uses different convention for longitude.
    xImage = (int)((-longitude-minLongitude)*mapWidth/mapLongWidth);
    yImage = (int)((latitude-minLatitude)*mapHeight/mapLatHeight);
    if (crossVisible) {
        short xOld, yOld;
        
        xOld = (int) ((-crossLongitude-minLongitude)*mapWidth/mapLongWidth);
        yOld = (int) ((crossLatitude-minLatitude)*mapHeight/mapLatHeight);

        // erase.
        MoveToEx(hDC, xOld-CROSS_SIZE, mapHeight-yOld, NULL);
        LineTo(hDC, xOld+CROSS_SIZE, mapHeight-yOld);
        MoveToEx(hDC, xOld, mapHeight-yOld-CROSS_SIZE, NULL);
        LineTo(hDC, xOld,mapHeight-yOld+CROSS_SIZE);
    }
    MoveToEx(hDC, xImage-CROSS_SIZE, mapHeight-yImage, NULL);
    LineTo(hDC, xImage+CROSS_SIZE, mapHeight-yImage);
    MoveToEx(hDC, xImage, mapHeight-yImage-CROSS_SIZE, NULL);
    LineTo(hDC, xImage, mapHeight-yImage+CROSS_SIZE);
    crossVisible = TRUE;
    
    crossLatitude = latitude;
    crossLongitude = longitude;
    
    SetROP2(hDC, oRop);
    SelectObject(hDC, oPen);
    DeleteObject(pen);
    
    ReleaseDC(hMap, hDC);    
}
Ejemplo n.º 25
0
// 鼠标左键弹起
void CurPokerWnd::OnLButtonUp(int x, int y)
{
    RECT rect;
    RECT rectRangeSel;

    if (m_bLButtonDown == TRUE) {
        m_bLButtonDown = FALSE;
        ReleaseCapture();

        if (m_bLBtnDownAndMouseMove == TRUE) {
            m_bLBtnDownAndMouseMove = FALSE;

            HDC hdc = GetDC(m_hWnd);
            HPEN hpen = CreatePen(PS_SOLID|PS_INSIDEFRAME, SEL_CARDS_FRAME_WIDTH, SEL_CARDS_FRAME_CLR);
            HBRUSH hbrush = (HBRUSH)GetStockObject(NULL_BRUSH);
            HPEN oldpen = (HPEN)SelectObject(hdc, hpen);
            HBRUSH oldbrush = (HBRUSH)SelectObject(hdc, hbrush);
            int mode = SetROP2(hdc, R2_XORPEN);

            GetCardRangeSelectRect(&rectRangeSel);

            rect.left = max(0, min(m_ptMouseMove.x, m_ptLButtonDown.x));
            rect.right = max(m_ptMouseMove.x, m_ptLButtonDown.x);
            rect.top = max(0, min(m_ptMouseMove.y, m_ptLButtonDown.y));
            rect.bottom = max(m_ptMouseMove.y, m_ptLButtonDown.y);
            IntersectRect(&rect, &rect, &rectRangeSel);
            Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);

            SetROP2(hdc, mode);
            SelectObject(hdc, oldbrush);
            SelectObject(hdc, oldpen);

            DeleteObject(hpen);
            ReleaseDC(m_hWnd, hdc);

            SelectCardRange(min(m_ptMouseMove.x, m_ptLButtonDown.x),
                max(m_ptMouseMove.x, m_ptLButtonDown.x));

            m_ptMouseMove.x = INVALID_COORD;
            m_ptMouseMove.y = INVALID_COORD;
        } else {
            if (m_ptLButtonDown.x == x) {
                if (m_ptLButtonDown.y == y) {
                    ClickCard(x, y); // 单击鼠标选择一张牌
                }
            }
        }
    }
}
Ejemplo n.º 26
0
// 移动鼠标(当鼠标在扑克牌上按下并移动时,XOR方式画一矩形,以示玩家选择扑克区域)
void CurPokerWnd::OnMouseMove(int x, int y)
{
    RECT rect;
    RECT rectRangeSel;

    if (m_bLButtonDown != TRUE) {
        return;
    }

    GetCardRangeSelectRect(&rectRangeSel);

    if (PtInRect(&rectRangeSel, m_ptLButtonDown)) {
        m_bLBtnDownAndMouseMove = TRUE;

        HDC hdc = GetDC(m_hWnd);
        HPEN hpen = CreatePen(PS_SOLID|PS_INSIDEFRAME, SEL_CARDS_FRAME_WIDTH, SEL_CARDS_FRAME_CLR);
        HBRUSH hbrush = (HBRUSH)GetStockObject(NULL_BRUSH);
        HPEN oldpen = (HPEN)SelectObject(hdc, hpen);
        HBRUSH oldbrush = (HBRUSH)SelectObject(hdc, hbrush);
        int mode = SetROP2(hdc, R2_XORPEN);

        if (m_ptMouseMove.x != INVALID_COORD) {
            rect.left = max(0, min(m_ptMouseMove.x, m_ptLButtonDown.x));
            rect.right = max(m_ptMouseMove.x, m_ptLButtonDown.x);
            rect.top = max(0, min(m_ptMouseMove.y, m_ptLButtonDown.y));
            rect.bottom = max(m_ptMouseMove.y, m_ptLButtonDown.y);
            IntersectRect(&rect, &rect, &rectRangeSel);
            Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);
        }

        m_ptMouseMove.x = max(0, x);
        m_ptMouseMove.y = max(0, y);

        rect.left = max(0, min(m_ptMouseMove.x, m_ptLButtonDown.x));
        rect.right = max(m_ptMouseMove.x, m_ptLButtonDown.x);
        rect.top = max(0, min(m_ptMouseMove.y, m_ptLButtonDown.y));
        rect.bottom = max(m_ptMouseMove.y, m_ptLButtonDown.y);
        IntersectRect(&rect, &rect, &rectRangeSel);
        Rectangle(hdc, rect.left, rect.top, rect.right, rect.bottom);

        SetROP2(hdc, mode);
        SelectObject(hdc, oldbrush);
        SelectObject(hdc, oldpen);

        DeleteObject(hpen);

        ReleaseDC(m_hWnd, hdc);
    }
}
Ejemplo n.º 27
0
void DoPaint(HDC hdc)
{
	const char szInstructions[] = "Please touch the center of the target.";

	POINT p;
	int i, n;
	int old_rop;
	POINT last = current_target_location;
	HPEN hOldPen;
	
	if (current_target == total_targets) {
		RECT r = {10, yext/2,  xext - 10, yext/2 + 40};
		DrawDone(hdc, r);
		return;
	}
	
	if (current_target == 0)
	{
		RECT r = {10, yext - 85, xext - 10, yext - 10};
		DrawAbout(hdc, r);
	}

	current_target_location = GetTarget(current_target);

	old_rop = SetROP2(hdc, R2_XORPEN);
	hOldPen = SelectObject(hdc, GetStockObject(WHITE_PEN));

	n = 20;
	for (i=0; i < n; i++)
	{
		p.x = last.x + ((current_target_location.x - last.x) * i / n);
		p.y = last.y + ((current_target_location.y - last.y) * i / n);
		DrawTarget(hdc, p);
		Sleep(60);
		DrawTarget(hdc, p);
	}

	// final position
	SetROP2(hdc, R2_COPYPEN);
	SelectObject(hdc, GetStockObject(BLACK_PEN));

	DrawTarget(hdc, current_target_location);
	DrawLabel(hdc, current_target_location, szInstructions);

	// put things back
	SetROP2(hdc, old_rop);
	SelectObject(hdc, hOldPen);
}
Ejemplo n.º 28
0
LRESULT OnMouseMove(HWND hWnd,WPARAM wParam,LPARAM lParam)
{
	int ex,ey;
	HDC hdc;

	ex=(int)(short)LOWORD(lParam);
	ey=(int)(short)HIWORD(lParam);
	if (DragMode==DM_DRAW) {
		hdc=GetDC(hWnd);
		SetROP2(hdc,R2_NOTXORPEN);
		SelectObject(hdc,GetStockObject(NULL_BRUSH));
		switch (NowTool) {
		case DT_LINE:
			MoveToEx(hdc,sx,sy,NULL);
			LineTo(hdc,oldx,oldy);
			MoveToEx(hdc,sx,sy,NULL);
			LineTo(hdc,ex,ey);
			break;
		case DT_ELLIPSE:
			Ellipse(hdc,sx,sy,oldx,oldy);
			Ellipse(hdc,sx,sy,ex,ey);
			break;
		case DT_RECTANGLE:
			Rectangle(hdc,sx,sy,oldx,oldy);
			Rectangle(hdc,sx,sy,ex,ey);
			break;
		}
		oldx=ex;
		oldy=ey;
		ReleaseDC(hWnd,hdc);
	}
	return 0;
}
Ejemplo n.º 29
0
static void XORSelectedRegion( void )
/************************************

    XOR the select rectangle with a black pen
*/
{
    HDC         dc;
    int         old_rop;

    dc = GetDC( WinHandle );
    SelectObject( dc, Pen );
    old_rop = SetROP2( dc, R2_XORPEN );
    Rectangle( dc, SelectStartX, SelectStartY, SelectEndX, SelectEndY );
    SetROP2( dc, old_rop );
    ReleaseDC( WinHandle, dc );
}
Ejemplo n.º 30
0
void
XDrawRectangle(
    Display *display,
    Drawable d,
    GC gc,
    int x, int y,
    unsigned int width, unsigned int height)
{
    HPEN pen, oldPen;
    TkWinDCState state;
    HBRUSH oldBrush;
    HDC dc;

    if (d == None) {
	return;
    }

    dc = TkWinGetDrawableDC(display, d, &state);

    pen = SetUpGraphicsPort(gc);
    SetBkMode(dc, TRANSPARENT);
    oldPen = SelectObject(dc, pen);
    oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH));
    SetROP2(dc, tkpWinRopModes[gc->function]);

    Rectangle(dc, x, y, (int) x+width+1, (int) y+height+1);

    DeleteObject(SelectObject(dc, oldPen));
    SelectObject(dc, oldBrush);
    TkWinReleaseDrawableDC(d, dc, &state);
}