示例#1
0
void _draw_screen_shape_at_x_y(
	shape_descriptor shape,
	short x,
	short y)
{
	PixMapHandle pixmap;
	RGBColor old_fore, old_back;
	Rect destination;

	/* Avoid unwanted coloring.. */
	GetForeColor(&old_fore);
	GetBackColor(&old_back);
	RGBForeColor(&rgb_black);
	RGBBackColor(&rgb_white);
	
	/* Draw the panels... */
	pixmap= get_shape_pixmap(shape, FALSE);
	
	/* Offset to zero base, and add in x, y */
	destination= (*pixmap)->bounds;
	OffsetRect(&destination, x-destination.left, y-destination.top);
	
	/* Slam the puppy...  */
	assert(destination_graphics_port);
	CopyBits((BitMapPtr) *pixmap, &destination_graphics_port->portBits, //&screen_window->portBits,
		&(*pixmap)->bounds, &destination, srcCopy, (RgnHandle) nil);

	/* Restore the colors.. */
	RGBForeColor(&old_fore);
	RGBBackColor(&old_back);
}
示例#2
0
void DrawMapBoundsPoly (CMap* theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings, Boolean erasePolygon)
{
	long numPts = (**MapPolyHdl).pointCount;
	PolyHandle poly;

	LongPoint** thisPointsHdl=nil;
	Point pt,startPt;
	LongPoint wPt;
	long i;
	Boolean offQuickDrawPlane = false;
	RGBColor saveColor; // JLM ?? wouldn't compile without this

	GetForeColor (&saveColor);		/* save original forecolor */
	
	thisPointsHdl = (LongPoint**) (**MapPolyHdl).objectDataHdl;
	poly = OpenPoly();
	wPt = INDEXH(thisPointsHdl,0);
	startPt = GetQuickDrawPt(wPt.h,wPt.v,&gRect,&offQuickDrawPlane);
	MyMoveTo(startPt.h,startPt.v);
	for(i = 1; i< numPts;i++)
	{
		wPt = INDEXH(thisPointsHdl,i);
		pt = GetQuickDrawPt(wPt.h,wPt.v,&gRect,&offQuickDrawPlane);
		MyLineTo(pt.h,pt.v);
	}
	MyLineTo(startPt.h,startPt.v);
	ClosePoly();
	if (erasePolygon) ErasePoly(poly);
	FramePoly(poly);
	ErasePoly(poly);
	KillPoly(poly);

	RGBForeColor (&saveColor);
}
示例#3
0
void cPict::draw(){
	RGBColor store_color;
	Rect rect = frame;
	GrafPtr cur_port;
	GetPort(&cur_port);
	SetPortWindowPort(parent->win);
	
	if(!visible){ // Erase it
		InsetRect(&rect, -3, -3);
		tileImage(rect,bg_gworld,bg[parent->bg]);
		return;
	}
	if(picNum < 0) { // Just fill with black
		GetForeColor(&store_color);
		ForeColor(blackColor);
		PaintRect(&rect);
		RGBForeColor(&store_color);
		return;
	}
	GetBackColor(&store_color);
	BackColor(whiteColor);
	
	drawPict()[picType](picNum,rect);
	if(drawFramed) drawFrame(2,0);
	SetPort(cur_port);
}
示例#4
0
文件: Form.cpp 项目: Plantain/XCSoar
void
WndForm::on_paint(Canvas &canvas)
{
  ContainerControl::on_paint(canvas);

  // Get window coordinates
  RECT rcClient = get_client_rect();

  // Draw the borders
  canvas.raised_edge(rcClient);

  // Set the colors
  canvas.set_text_color(GetForeColor());
  canvas.set_background_color(mColorTitle);
  canvas.background_transparent();

  // Set the titlebar font and font-size
  canvas.select(*mhTitleFont);

  // JMW todo add here icons?

  // Draw titlebar text
  canvas.text_opaque(mTitleRect.left + Layout::FastScale(2),
      mTitleRect.top, &mTitleRect, mCaption);
}
示例#5
0
void CRButtonCtrl::DoPropExchange(CPropExchange* pPX)
{
	m_ResourceNumber&=0x00ffffff;
	m_ResourceNumber+=m_alignment<<24;

	ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
	COleControl::DoPropExchange(pPX);
	PX_Bool(pPX, _T("MovesParent"), m_bMovesParent, FALSE);
	PX_Long(pPX, _T("FontNum"), m_FontNum, 0);
	PX_Bool(pPX, _T("CloseButton"), m_bCloseButton, FALSE);
	PX_Bool(pPX, _T("TickButton"), m_bTickButton, FALSE);
	PX_Bool(pPX, _T("ShowShadow"), m_bShowShadow, FALSE);
	PX_Color(pPX, _T("ShadowColor"), m_ShadowColor, FALSE);
	PX_String(pPX, _T("String"), m_string, _T(""));
	PX_Long(pPX, _T("ResourceNumber"), m_ResourceNumber, 0);
	PX_Long(pPX, _T("NormalFileNum"), m_NormalFileNum, 0);
	PX_Long(pPX, _T("PressedFileNum"), m_PressedFileNum, 7);
	PX_String(pPX, _T("NormalFileNumString"), m_NormalFileNumString, _T(""));
	PX_String(pPX, _T("PressedFileNumString"), m_PressedFileNumString, _T(""));
	if (pPX->GetVersion()&0x1)
	{
		PX_String(pPX, _T("HintString"), m_hintString, _T(""));
		PX_String(pPX, _T("HintStringID"), m_hintStringID, _T(""));
		PX_Long(pPX, _T("HintResourceNumber"), m_hintResourceNumber, 0);
	}
	else
	{


	}
	if (pPX->GetVersion()&0x2)
	{


	}
	else
	{

	}
	m_alignment=m_ResourceNumber>>24;
//DeadCode MS 04May100 	UByteP(0xB0000)[160*5]='0'+m_alignment;
	m_ResourceNumber&=0x00ffffff;

	if (pPX->IsLoading())
	{
		if (GetBackColor()==0)
			SetBackColor(GetForeColor());
		if (m_bCloseButton || m_bTickButton)							  //JIM 21/05/99
			m_bHelpButton=TRUE; // remove this if it becomes a persistent property
		else
			m_bHelpButton=FALSE;
	}
	if (m_PressedFileNum==7)
		m_PressedFileNumString="";

}
 void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& /*rcInvalid*/)
 {
    CPen pen(PS_SOLID, 0, TranslateColor(GetForeColor()));
    CBrush brush(TranslateColor(GetBackColor()));
    CPen* pPenSave = pdc->SelectObject(&pen);
    CBrush* pBrushSave = pdc->SelectObject(&brush);
    pdc->Rectangle(rcBounds);
    pdc->SelectObject(pPenSave);
    pdc->SelectObject(pBrushSave);
 }
示例#7
0
void DrawContourLevelValue(short x, short y, double level)
{
	char numstr[40];
	RGBColor savecolor;
	MyNumToStr(level,numstr);
	GetForeColor(&savecolor);
	RGBForeColor(&colors[RED]);
	MyDrawString(/*CENTERED,*/x,y,numstr,true,POINTDRAWFLAG);
	RGBForeColor(&savecolor);
}
示例#8
0
void CRTreeCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	// draw the funky piccy
    m_pic.Render(pdc, rcBounds, rcBounds);

	// draw a box and fill it with text.
	// the zoom function will alter the font and box dimensions

    CFont* pOldFont;
    TEXTMETRIC tm;
    const CString& strCaption = InternalGetText();

    // Set the ForeColor property color and transparent background mode into the device context
    pdc->SetTextColor(TranslateColor(GetForeColor()));
    pdc->SetBkMode(TRANSPARENT);

    // Draw the caption using the stock Font and ForeColor properties
    pOldFont = SelectStockFont(pdc);
    pdc->GetTextMetrics(&tm);
    pdc->SetTextAlign(TA_LEFT | TA_TOP);
	int gapsize;
	int gapsize2;
	int ydistance;
	int xdistance=0;
	int index=0;
	char* buffer;
	CRect rect;
	for (int x=0;x<m_lDepth;x++)
	{
		gapsize=(int)(pow(2,x)-1)*m_lBoxHeight;
		ydistance=gapsize/2;
		gapsize2=(int)(pow(2,x-2)*m_lBoxHeight);
		for (int y=0;y<pow(2,m_lDepth-x-1);y++)
		{
			rect=CRect(xdistance,ydistance,xdistance+m_lBoxWidth,ydistance+m_lBoxHeight);
			buffer=(char*)GetText(index);
			if (buffer!=NULL)
			    pdc->ExtTextOut(rect.left+2, rect.top+2,
					ETO_CLIPPED, CRect(rect.left+2,rect.top+2,rect.right-2,rect.bottom-2), buffer, strlen(buffer), NULL);
			pdc->DrawEdge(rect,EDGE_ETCHED,BF_RECT);
			index++;
			if (x>0)
			{
				pdc->MoveTo(xdistance-m_lGapWidth,ydistance+(m_lBoxHeight/2)+gapsize2);
				pdc->LineTo(xdistance,ydistance+(m_lBoxHeight/2));
				pdc->MoveTo(xdistance-m_lGapWidth,ydistance+(m_lBoxHeight/2)-gapsize2);
				pdc->LineTo(xdistance,ydistance+(m_lBoxHeight/2));
			}
			ydistance+=gapsize+m_lBoxHeight;
		}
		xdistance+=m_lBoxWidth+m_lGapWidth;
	}
    pdc->SelectObject(pOldFont);
}
示例#9
0
void SaveQDDrawingState( QDDrawingState *ioDrawingState, const Boolean inSaveTextState )
{	GWorldPtr		tempWorld;
	GDHandle		tempDevice;

	Assert( ioDrawingState != nil );

	// Get the current GWorld, so I can access it's fields.
	GetGWorld( &tempWorld, &tempDevice );

	// Get the background state.
	GetBackColor( &ioDrawingState->backColor );
/*#if !( defined( TARGET_API_MAC_CARBON ) && ( TARGET_API_MAC_CARBON == 1 ) )
	if ( tempWorld->bkPixPat == nil )
		ioDrawingState->backPixPatH = nil;
	else
#endif
		ioDrawingState->backPixPatH = NewPixPat( );

	if ( ioDrawingState->backPixPatH != nil )
		GetPortBackPixPat( tempWorld, ioDrawingState->backPixPatH );
*/
	// Get the pen/foreground state.
	GetForeColor( &ioDrawingState->foreColor );
/*#if !( defined( TARGET_API_MAC_CARBON ) && ( TARGET_API_MAC_CARBON == 1 ) )
	if ( tempWorld->pnPixPat == nil )
		ioDrawingState->penPixPatH = nil;
	else
#endif
		ioDrawingState->penPixPatH = NewPixPat( );

	if ( ioDrawingState->penPixPatH != nil )
		GetPortPenPixPat( tempWorld, ioDrawingState->penPixPatH );
*/
	GetPenState( &ioDrawingState->penState );

	// Optionally save the text font, face, size and mode.
	ioDrawingState->haveTextState = inSaveTextState;
	if ( inSaveTextState ) {
		ioDrawingState->textStyle.tsFont = GetPortTextFont( tempWorld );
		ioDrawingState->textStyle.tsFace = GetPortTextFace( tempWorld );
		ioDrawingState->textStyle.tsSize = GetPortTextSize( tempWorld );
		ioDrawingState->textMode = GetPortTextMode( tempWorld );
	}

#if ALIST_USEAPPEARANCEMGR && TARGET_RT_MAC_CFM
	// If we're running under CFM and have Appearance Mgr 1.1 or later, use the ThemeDrawingState routines.
	if ( local_AppearanceMgrVersion( ) > 0x0110 )
		ioDrawingState->haveThemeState = ( GetThemeDrawingState( &ioDrawingState->themeState ) == noErr );
	else {
		ioDrawingState->haveThemeState = false;
		ioDrawingState->themeState = nil;
	}
#endif
}
示例#10
0
void _fill_screen_rectangle(
	screen_rectangle *rectangle, 
	short color_index)
{
	RGBColor old_color, new_color;

	GetForeColor(&old_color);
	_get_interface_color(color_index, &new_color);
	RGBForeColor(&new_color);
	PaintRect((Rect *) rectangle);
	RGBForeColor(&old_color);
}
示例#11
0
void DrawMapBoundsPoly (CMap* theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings, Boolean erasePolygon)
{
	long numPts = (**MapPolyHdl).pointCount;
	POINT **pointsH = (POINT**)_NewHandle(numPts *sizeof(POINT));
	POINT *pointsPtr = (POINT*)_NewPtr(numPts *sizeof(POINT));
	LongPoint** thisPointsHdl=nil;
	Point pt;
	LongPoint wPt;
	long i;
	Boolean offQuickDrawPlane = false;
	RGBColor saveColor; // JLM ?? wouldn't compile without this
	if(!pointsH || !pointsPtr) {SysBeep(5); return;}
	
	thisPointsHdl = (LongPoint**) (**MapPolyHdl).objectDataHdl;
	for(i = 0; i< numPts;i++)
	{
		wPt = INDEXH(thisPointsHdl,i);
		pt = GetQuickDrawPt(wPt.h,wPt.v,&gRect,&offQuickDrawPlane);
		INDEXH(pointsH,i) = MakePOINT(pt.h,pt.v);
		(pointsPtr)[i] = MakePOINT(pt.h,pt.v);
		// code goes here, make sure this point does not equal previous point JLM
	}
	GetForeColor (&saveColor);		/* save original forecolor */

		if (erasePolygon)
		{
			RgnHandle newClip=0;
			HBRUSH whiteBrush;
			newClip = CreatePolygonRgn((const POINT*)pointsPtr,numPts,ALTERNATE);
			whiteBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
			//err = SelectClipRgn(currentHDC,savedClip);
			FillRgn(currentHDC, newClip, whiteBrush);
			//DeleteObject(newClip);
			DisposeRgn(newClip);
			//SelectClipRgn(currentHDC,0);
		}
		else
		{
			POINT p[2];
			p[0] = INDEXH(pointsH,numPts-1);
			p[1] = INDEXH(pointsH,0);
			RGBForeColor(&colors[BLACK]);
			if(numPts >= 2) 
			{
				Polyline(currentHDC,*pointsH,numPts);
				Polyline(currentHDC,p,2);	// close the polygon
			}
		}

	RGBForeColor (&saveColor);
	DisposeHandle((Handle)pointsH);
	if(pointsPtr) {_DisposePtr((Ptr)pointsPtr); pointsPtr = 0;}
}
示例#12
0
static pascal void drawProc(ControlRef inControl, SInt16 inPart)
{
	#pragma unused(inControl, inPart)
	
	int i;
	RGBColor saveForeColor;
	RGBColor saveBackColor;
	PenState savePenState;

	GetForeColor(&saveForeColor);	
	GetBackColor(&saveBackColor);	
	GetPenState(&savePenState);

	RGBForeColor(&rgbBlack);
	RGBBackColor(&rgbWhite);
	PenNormal();
	
	for (i = 0; i < sNumMonitors; i++)
	{
		RGBForeColor(&rgbGray);
		PaintRect(&sMonitors[i].scaledRect);
		if (sMonitors[i].isMain)
		{
			Rect r = sMonitors[i].scaledRect;
			InsetRect(&r, 1, 1);
			r.bottom = r.top + 6;
			RGBForeColor(&rgbWhite);
			PaintRect(&r);
			RGBForeColor(&rgbBlack);
			PenSize(1,1);
			MoveTo(r.left, r.bottom);
			LineTo(r.right, r.bottom);
		}
		if (sMonitors[i].device == sSelectedDevice)
		{
			PenSize(3,3);
			RGBForeColor(&rgbBlack);
			FrameRect(&sMonitors[i].scaledRect);
		}
		else
		{
			PenSize(1,1);
			RGBForeColor(&rgbBlack);
			FrameRect(&sMonitors[i].scaledRect);
		}
	}
	
	// restore the original pen state and colors
	RGBForeColor(&saveForeColor);	
	RGBBackColor(&saveBackColor);	
	SetPenState(&savePenState);
}
示例#13
0
void _draw_screen_shape_centered(
	shape_descriptor shape,
	screen_rectangle *rectangle,
	short flags)
{
	PixMapHandle pixmap;
	RGBColor old_fore, old_back;
	Rect destination, source;
	short left_offset, top_offset;
return;
	/* Avoid unwanted coloring.. */
	GetForeColor(&old_fore);
	GetBackColor(&old_back);
	RGBForeColor(&rgb_black);
	RGBBackColor(&rgb_white);
	
	/* Draw the panels... */
	pixmap= get_shape_pixmap(shape, FALSE);
	
	/* Offset to zero base, and add in x, y */
	destination= source= (*pixmap)->bounds;
	
	if(flags & _center_horizontal)
	{
		left_offset= (RECTANGLE_WIDTH(rectangle)-RECTANGLE_WIDTH(&source))/2;
	} else {
		left_offset= 0;
	}
	
	if(flags & _center_vertical)
	{
		top_offset= (RECTANGLE_HEIGHT(rectangle)-RECTANGLE_HEIGHT(&source))/2;
	} else if (flags & _bottom_justified) {
		top_offset= RECTANGLE_HEIGHT(rectangle)-RECTANGLE_HEIGHT(&destination);
	} else {
		top_offset= 0;
	}
	
	OffsetRect(&destination, rectangle->left+left_offset, 
		rectangle->top+top_offset);
	
	/* Slam the puppy...  */
	assert(destination_graphics_port);
	CopyBits((BitMapPtr) *pixmap, &destination_graphics_port->portBits, // &screen_window->portBits,
		&source, &destination, srcCopy, (RgnHandle) nil);

	/* Restore the colors.. */
	RGBForeColor(&old_fore);
	RGBBackColor(&old_back);
}
示例#14
0
文件: lcd.c 项目: CNMAT/CNMAT-Externs
void setUpPalette(Lcd *x, RGBColor *oldColor, PaletteHandle *oldPalette)
{
	if (hasColorQD) {
		if (numPaletteColors>2){
			GetForeColor(oldColor);
			*oldPalette = GetPalette(&x->lcd_box.b_patcher->p_wind->w_gp);
			SetPalette(&x->lcd_box.b_patcher->p_wind->w_gp,x->lcd_palette,FALSE);
			PmForeColor(x->lcd_pIndex);
		}
	}
	GetPenState(&x->lcd_penState);
	PenMode(x->lcd_penMode);
	PenSize(1,1);
}
示例#15
0
文件: Draw.cpp 项目: Plantain/XCSoar
void
WndOwnerDrawFrame::on_paint(Canvas &canvas)
{
  canvas.clear(GetBackBrush());

  if (mOnPaintCallback == NULL)
    return;

  canvas.select(*GetFont());
  canvas.set_text_color(GetForeColor());
  canvas.set_background_color(GetBackColor());
  canvas.background_transparent();

  mOnPaintCallback(this, canvas);
}
示例#16
0
文件: Edit.cpp 项目: galippi/xcsoar
void
WndProperty::on_paint(Canvas &canvas)
{
  /* background and selector */
  if (edit.has_focus()) {
    canvas.clear(GetBackColor().highlight());
    PaintSelector(canvas, get_client_rect());
  } else
    canvas.clear(GetBackColor());

  SIZE tsize;
  POINT org;

  WindowControl::on_paint(canvas);

  canvas.set_text_color(GetForeColor());
  canvas.background_transparent();
  canvas.select(*GetFont());

  tsize = canvas.text_size(mCaption);

  if (mCaptionWidth == 0) {
    org.x = mEditPos.x;
    org.y = mEditPos.y - tsize.cy;
  } else {
    org.x = mCaptionWidth - mBitmapSize - (tsize.cx + 1);
    org.y = (get_size().cy - tsize.cy) / 2;
  }

  if (org.x < 1)
    org.x = 1;

  canvas.text(org.x, org.y, mCaption);

  // can't but dlgComboPicker here b/c it calls paint when combopicker closes too
  // so it calls dlgCombopicker on the click/focus handlers for the wndproperty & label
  if (!mDialogStyle && edit.has_focus() && !edit.is_read_only()) {
    canvas.stretch(mHitRectDown.left, mHitRectDown.top,
                   mBitmapSize, mBitmapSize,
                   hBmpLeft32,
                   mDownDown ? 32 : 0, 0, 32, 32);

    canvas.stretch(mHitRectUp.left, mHitRectUp.top,
                   mBitmapSize, mBitmapSize,
                   hBmpRight32,
                   mUpDown ? 32 : 0, 0, 32, 32);
  }
}
示例#17
0
/* If source==NULL, source= the shapes bounding rectangle */
void _draw_screen_shape(
	shape_descriptor shape_id, 
	screen_rectangle *destination, 
	screen_rectangle *source)
{
	PixMapHandle pixmap;
	RGBColor old_fore, old_back;
	Rect actual_source;

	/* Avoid unwanted coloring.. */
	GetForeColor(&old_fore);
	GetBackColor(&old_back);
	RGBForeColor(&rgb_black);
	RGBBackColor(&rgb_white);
	
	/* Draw the panels... */
	pixmap= get_shape_pixmap(shape_id, FALSE);
	if(!source)
	{
		actual_source= (*pixmap)->bounds;
#ifdef DEBUG
{
	short dest_width, source_width;
	short dest_height, source_height;
	
	dest_width= destination->right-destination->left;
	source_width= (*pixmap)->bounds.right-(*pixmap)->bounds.left;
	dest_height= destination->bottom-destination->top;
	source_height= (*pixmap)->bounds.bottom-(*pixmap)->bounds.top;
	if(source_height != dest_height || source_width != dest_width)
	{
		dprintf("Changing size of %d Original: %d %d New: %d %d", shape_id,
			source_width, source_height, dest_width, dest_height);
	}
}
#endif
	} else {
		actual_source= *((Rect *) source);
	}

	assert(destination_graphics_port);
	CopyBits((BitMapPtr) *pixmap, &destination_graphics_port->portBits,
		&actual_source, (Rect *) destination, srcCopy, (RgnHandle) nil);

	/* Restore the colors.. */
	RGBForeColor(&old_fore);
	RGBBackColor(&old_back);
}
示例#18
0
void CTesthelpCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& /*rcInvalid*/)
{
	// Drawing code, mostly plagiarized from the Circ MFC sample.
	// The only thing done here is setting the border and drawing text
	// specified by our name properties in the control's client area.
		if(!GetBorderStyle())   //Control will always have a border.
					SetBorderStyle(TRUE);

		// Set up variables to use for drawing text background.
		// Use our current BackColor for the background color.
		CBrush* pOldBrush;
		CBrush bkBrush(TranslateColor(GetBackColor()));
		CPen* pOldPen;
		CRect rc = rcBounds;
		CFont* pOldFont;

		// Set up background mode and text color.  Use the
		// current ForeColor for the text color.
		pdc->SetTextColor(TranslateColor(GetForeColor()));
		pdc->SetBkMode(TRANSPARENT);

		// Fill our window with the current BackColor
		pdc->FillRect(rcBounds, &bkBrush);

		// Save off the existing brush and pen so they
		// can be restored when we're done.
		pOldBrush = pdc->SelectObject(&bkBrush);
		pOldPen = (CPen*)pdc->SelectStockObject(BLACK_PEN);

		// Save off the current font so we can restore it and
		// select our current stock font into this DC
		pOldFont = SelectStockFont(pdc);

		// Draw the text on our window
		pdc->ExtTextOut(rc.left+10, rc.top +2,
			ETO_CLIPPED, rc, m_szName1, m_szName1.GetLength(), NULL);
		pdc->ExtTextOut(rc.left+10, rc.top +22,
			ETO_CLIPPED, rc, m_szName2, m_szName2.GetLength(), NULL);
		pdc->ExtTextOut(rc.left+10, rc.top +42,
			ETO_CLIPPED, rc, m_szName3, m_szName3.GetLength(), NULL);

		// Restore our DC to it's original state.
		pdc->SelectObject(pOldFont);
		pdc->SelectObject(pOldPen);
		pdc->SelectObject(pOldBrush);

}
示例#19
0
文件: MacGraph.c 项目: rolk/ug
static void MacErasePolygon (SHORT_POINT *points, INT n)
{
  int i;
  PolyHandle myPoly;
  RGBColor ForeColor, BackColor;

  if (n<3) return;

  GetForeColor(&ForeColor);
  GetBackColor(&BackColor);
  myPoly = OpenPoly();
  MoveTo (points[0].x, points[0].y);
  for (i=1; i<n; i++) LineTo (points[i].x, points[i].y);
  LineTo (points[0].x, points[0].y);
  ClosePoly();
  ErasePoly(myPoly);
  RGBForeColor(&BackColor);
  FramePoly(myPoly);
  KillPoly(myPoly);
  RGBForeColor(&ForeColor);
}
void CLesson18Ctrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	if (!pdc)
		return;

	// TODO: 用您自己的绘图代码替换下面的代码。
	//pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
	//pdc->Ellipse(rcBounds);

    CBrush brush(TranslateColor(GetBackColor()));
    pdc->FillRect(rcBounds,&brush);
    pdc->SetTextColor(TranslateColor(GetForeColor()));
    pdc->SetBkMode(TRANSPARENT);
    CTime time=CTime::GetCurrentTime();
    if(0==time.GetSecond()){
        NewMinute();
    }
    CString str=time.Format(_T("%H:%M:%S"));
    pdc->TextOutW(0,0,str);
}
示例#21
0
void CCircCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect&)
{
	CBrush* pOldBrush;
	CBrush bkBrush(TranslateColor(GetBackColor()));
	CPen* pOldPen;
	CRect rc = rcBounds;
	CFont* pOldFont;
	TEXTMETRIC tm;
	const CString& strCaption = InternalGetText();

	// Set the ForeColor property color and transparent background mode into the device context
	pdc->SetTextColor(TranslateColor(GetForeColor()));
	pdc->SetBkMode(TRANSPARENT);

	// Paint the background using the BackColor property
	pdc->FillRect(rcBounds, &bkBrush);

	// Draw the ellipse using the BackColor property and a black pen
	GetDrawRect(&rc);
	pOldBrush = pdc->SelectObject(&bkBrush);
	pOldPen = (CPen*)pdc->SelectStockObject(BLACK_PEN);
	pdc->Ellipse(rc);

	// Draw the caption and note using the stock Font and ForeColor properties
	pOldFont = SelectStockFont(pdc);
	GetStockTextMetrics(&tm);

	pdc->SetTextAlign(TA_CENTER | TA_TOP);
	pdc->ExtTextOut((rc.left + rc.right) / 2, (rc.top + rc.bottom - tm.tmHeight) / 2,
		ETO_CLIPPED, rc, strCaption, strCaption.GetLength(), NULL);
	pdc->SetTextAlign(TA_LEFT | TA_TOP);
	pdc->ExtTextOut(rcBounds.left, rcBounds.top,
		ETO_CLIPPED, rcBounds, m_note, m_note.GetLength(), NULL);
	pdc->SelectObject(pOldFont);

	pdc->SelectObject(pOldPen);
	pdc->SelectObject(pOldBrush);
}
示例#22
0
void CRTitleCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	// TODO: Replace the following code with your own drawing code.
	pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
    CRect rc = rcBounds;
    CFont* pOldFont;
    TEXTMETRIC tm;
    const CString& strCaption = InternalGetText();

    // Set the ForeColor property color and transparent background mode into the device context
    pdc->SetTextColor(TranslateColor(GetForeColor()));
    pdc->SetBkMode(TRANSPARENT);

    // Draw the caption using the stock Font and ForeColor properties
    pOldFont = SelectStockFont(pdc);
    pdc->GetTextMetrics(&tm);
    pdc->SetTextAlign(TA_CENTER | TA_TOP);
    pdc->ExtTextOut((rc.left + rc.right) / 2, 0,
		ETO_CLIPPED, rc, strCaption, strCaption.GetLength(), NULL);
    pdc->SelectObject(pOldFont);
}
示例#23
0
DisplayDialog::DisplayDialog(ProfileDoc *dc,RawData *pD,int wn):InputDialog(dc,pD,1)
{
	short		iType;
	Handle		iHandle;
	Handle		sHandle;
	Rect 		iRect, r,pRect,tRect;	
	UserItemUPP  box3D;
	
	QDErr		error;
	GDHandle	oldGD;
	GWorldPtr	oldGW;
	RGBColor	c,oldbackcolor,oldforecolor;
	WindowPtr	oldP;
	OSErr			err;
	int32 		i,wi,hi;
	double w,h;
	short		dtp_ids[] = DISPPATCH_IDS;
	Str255		theString,name;
	
	for (i=0; i<NumInputIDS; i++) ids[i] = dtp_ids[i];

	WinType = DisplayWindow;
	WinNum = wn;

	setDialog(Input_Dialog);

	
	GetIndString(theString,Display_Title,1);
	
	SetWTitle( dp, theString);
	
	// Added by James, 3D the box
	threeD_box(ids[ThreeDBox]);
	

	//playSound(8193);
	
	
	// initialize the big gworld 
	GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect);
	tRect = iRect;
	OffsetRect(&tRect,-iRect.left,-iRect.top);
	error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 );
	if (error != 0) 
		{
		delete this;
		return;
		} 
	GetGWorld(&oldGW,&oldGD);
	SetGWorld(BigGW,nil);	
	
	
//	GetBackColor(&oldbackcolor);
	GetForeColor(&oldforecolor);
	c.red = 65535;
	c.green = 65535;
	c.blue = 65535;
	RGBBackColor(&c);
	c.red = 0;
	c.green = 0;
	c.blue = 0;
	RGBForeColor(&c);		
//	EraseRect( &tRect );
	
	SetGWorld(oldGW,oldGD);	
//	RGBBackColor(&oldbackcolor);
	RGBForeColor(&oldforecolor);	

//	SetPort(oldP);
		
	GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect);
	num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top);
	top_patch = 0;
						
//init the static members
	//current_patch = total_patches-1;
	//current_patch = 0;
	current_patch = 0;
	current_strip = 0;
	current_sheet = 0;
 		
 	_done = 0;
 	_waiting = 0;
	
	SetSheetStripText();
	
	current_top = current_patch - 2*num_display_patch/3;
	current_bottom = current_top + num_display_patch - 1;
	if (current_top < 0) 
		{
		current_top = 0;
		current_bottom = current_top + num_display_patch - 1;
		}
	if (current_bottom >= total_patches-1)
		{
		current_bottom = total_patches - 1;
		current_top = current_bottom - num_display_patch + 1;
		}
	
	current_disp = 2*num_display_patch/3;
	
	init();	
	getpatchRGB();
	
	
	Disable(dp,ids[Redo]);

	
	GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect);
	SetCtlMin((ControlHandle)iHandle,0);
	SetCtlMax((ControlHandle)iHandle,total_patches-1);
	
//	GetDItem ( dp,ids[Message], &iType, (Handle*)&iHandle, &pRect );
//	SetIText(iHandle,"\p");
	
	GetDItem ( dp,PatchLabel, &iType, (Handle*)&iHandle, &pRect );
	GetIndString(theString,Message_List_ID,Patch_Message);
	SetIText(iHandle,theString);
	
	strcpy((char*)name,pD->desc);
	ctopstr((char*)name);
	SetWTitle( dp, name);
	
	DrawWindow();
}	
示例#24
0
void 
XCopyArea(
    Display* display,		/* Display. */
    Drawable src,		/* Source drawable. */
    Drawable dest,		/* Destination drawable. */
    GC gc,			/* GC to use. */
    int src_x,			/* X & Y, width & height */
    int src_y,			/* define the source rectangle */
    unsigned int width,		/* the will be copied. */
    unsigned int height,
    int dest_x,			/* Dest X & Y on dest rect. */
    int dest_y)
{
    Rect srcRect, destRect;
    BitMapPtr srcBit, destBit;
    MacDrawable *srcDraw = (MacDrawable *) src;
    MacDrawable *destDraw = (MacDrawable *) dest;
    GWorldPtr srcPort, destPort;
    CGrafPtr saveWorld;
    GDHandle saveDevice;
    short tmode;
    RGBColor origForeColor, origBackColor, whiteColor, blackColor;

    destPort = TkMacGetDrawablePort(dest);
    srcPort = TkMacGetDrawablePort(src);

    display->request++;
    GetGWorld(&saveWorld, &saveDevice);
    SetGWorld(destPort, NULL);
    GetForeColor(&origForeColor);
    GetBackColor(&origBackColor);
    whiteColor.red = 0;
    whiteColor.blue = 0;
    whiteColor.green = 0;
    RGBForeColor(&whiteColor);
    blackColor.red = 0xFFFF;
    blackColor.blue = 0xFFFF;
    blackColor.green = 0xFFFF;
    RGBBackColor(&blackColor);
    

    TkMacSetUpClippingRgn(dest);
    
    /*
     *  We will change the clip rgn in this routine, so we need to 
     *  be able to restore it when we exit.
     */
     
    if (tmpRgn2 == NULL) {
        tmpRgn2 = NewRgn();
    }
    GetClip(tmpRgn2);

    if (((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) {
	RgnHandle clipRgn = (RgnHandle)
	        ((TkpClipMask*)gc->clip_mask)->value.region;
	
	int xOffset, yOffset;
	
	if (tmpRgn == NULL) {
	    tmpRgn = NewRgn();
	}
	
	xOffset = destDraw->xOff + gc->clip_x_origin;
	yOffset = destDraw->yOff + gc->clip_y_origin;
	
	OffsetRgn(clipRgn, xOffset, yOffset);
	
	GetClip(tmpRgn);
	SectRgn(tmpRgn, clipRgn, tmpRgn);
	
	SetClip(tmpRgn);
	
	OffsetRgn(clipRgn, -xOffset, -yOffset);
    }
    
    srcBit = &((GrafPtr) srcPort)->portBits;
    destBit = &((GrafPtr) destPort)->portBits;
    SetRect(&srcRect, (short) (srcDraw->xOff + src_x),
	    (short) (srcDraw->yOff + src_y),
	    (short) (srcDraw->xOff + src_x + width),
	    (short) (srcDraw->yOff + src_y + height));	
    SetRect(&destRect, (short) (destDraw->xOff + dest_x),
	    (short) (destDraw->yOff + dest_y), 
	    (short) (destDraw->xOff + dest_x + width),
	    (short) (destDraw->yOff + dest_y + height));	
    tmode = srcCopy;

    CopyBits(srcBit, destBit, &srcRect, &destRect, tmode, NULL);
    RGBForeColor(&origForeColor);
    RGBBackColor(&origBackColor);
    SetClip(tmpRgn2);
    SetGWorld(saveWorld, saveDevice);
}
示例#25
0
TechkonDialog::TechkonDialog(ProfileDoc *dc,RawData *pD):InputDialog(dc,pD,1)
{
	short		iType;
	Handle		iHandle;
	Handle		sHandle;
	Rect 		iRect, r,pRect,tRect;	
	UserItemUPP  box3D;
	
	QDErr		error;
	GDHandle	oldGD;
	GWorldPtr	oldGW;
	RGBColor	c,oldbackcolor,oldforecolor;
	WindowPtr	oldP;
	OSErr			err;
	int32 		i,wi,hi;
	double w,h;
	short		gtsl_ids[] = GTSL_IDS;
	Str255		theString;
	PixMapHandle	bigPixMap;
	McoStatus  	state;
	
	for (i=0; i<NumInputIDS; i++) ids[i] = gtsl_ids[i];

	WinType = TechkonWindow;
	WinNum = 0;

	setDialog(Input_Dialog);
	frame_button(ids[Ok_Box]);	

	

	
	// Added by James, 3D the box
	threeD_box(ids[ThreeDBox]);
	
	HideDItem(dp,ids[Redo]);
	
	GetDItem ( dp,ids[Message], &iType, (Handle*)&iHandle, &iRect );
	GetIndString(theString,Message_List_ID,6);
	SetIText(iHandle,theString);
	
	Scramble = FALSE;	
	
	if (Scramble)
		{
		voice_set = 1;
		}	
	else
		{
		Disable(dp,ids[VoiceSet]);
		voice_set = 2;
		}

	// initialize comminications with the device
	state = doc->openInputDevice(0,0,0);
	if (state != MCO_SUCCESS) McoErrorAlert(state);
	
	// initialize the big gworld 
	GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect);
	tRect = iRect;
	OffsetRect(&tRect,-iRect.left,-iRect.top);
	error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 );
	if (error != 0) 
		{
		delete this;
		return;
		} 
	GetGWorld(&oldGW,&oldGD);
	SetGWorld(BigGW,nil);	
	
	
//	GetBackColor(&oldbackcolor);
	GetForeColor(&oldforecolor);
	c.red = 65535;
	c.green = 65535;
	c.blue = 65535;
	RGBBackColor(&c);
	c.red = 0;
	c.green = 0;
	c.blue = 0;
	RGBForeColor(&c);		
	bigPixMap = GetGWorldPixMap ( BigGW );
	if (LockPixels ( bigPixMap ))	EraseRect( &tRect );
	
	SetGWorld(oldGW,oldGD);	
//	RGBBackColor(&oldbackcolor);
	RGBForeColor(&oldforecolor);	

//	SetPort(oldP);
		
	GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect);
	num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top);
	top_patch = 0;
						
//init the static members
	//current_patch = total_patches-1;
	//current_patch = 0;
	current_patch = 0;
	current_strip = 0;
	current_sheet = 0;
 		
 	_done = 0;
 	_waiting = 0;
	
	
	SetSheetStripText();
	
	current_top = current_patch - 2*num_display_patch/3;
	current_bottom = current_top + num_display_patch - 1;
	if (current_top < 0) 
		{
		current_top = 0;
		current_bottom = current_top + num_display_patch - 1;
		}
	if (current_bottom >= total_patches-1)
		{
		current_bottom = total_patches - 1;
		current_top = current_bottom - num_display_patch + 1;
		}
	
	current_disp = 2*num_display_patch/3;
	
	init();	
	getpatchRGB();
	
	
	Disable(dp,ids[Redo]);

	
	GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect);
	SetCtlMin((ControlHandle)iHandle,0);
	SetCtlMax((ControlHandle)iHandle,total_patches-1);
	
	GetDItem(dp, ids[VoiceSet], &iType, (Handle*)&iHandle, &pRect);
	SetCtlValue((ControlHandle)iHandle,1);
	//voice_set = 1;
	checkFinished();
	DrawWindow();
}	
示例#26
0
void CRTabsCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	if (m_bInit)
	{
		m_TabUpDC.CreateCompatibleDC(pdc);
		m_TabDownDC.CreateCompatibleDC(pdc);
		m_TabUp.LoadBitmap(IDB_TABUP);
		m_TabDown.LoadBitmap(IDB_TABDOWN);	
		m_TabUpDC.SelectObject(m_TabUp);
		m_TabDownDC.SelectObject(m_TabDown);
		BITMAP bitmap;
		m_TabUp.GetBitmap(&bitmap);
		m_TabUpWidth=bitmap.bmWidth;
		m_TabUpHeight=bitmap.bmHeight;
		m_TabDown.GetBitmap(&bitmap);
		m_TabDownWidth=bitmap.bmWidth;
		m_TabDownHeight=bitmap.bmHeight;
		m_bInit=FALSE;		   
	}
	int count=m_textList.GetCount();
	if (count==0) return;
//	*(char*)0=0;
	// TODO: Replace the following code with your own drawing code.
	CDC offscreenDC;
	VERIFY(offscreenDC.CreateCompatibleDC(pdc));
	CBitmap bitmap;
	CBitmap* pOldBitmap;
	VERIFY(bitmap.CreateCompatibleBitmap(pdc,rcBounds.Width(),rcBounds.Height()));
	pOldBitmap=offscreenDC.SelectObject(&bitmap);
//	offscreenDC.FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(BLACK_BRUSH)));
	// pre calculate the tab positions
	POSITION position = m_textList.GetHeadPosition();
	CRect rect;
	this->GetParent()->GetClientRect(rect);
	m_rectList.RemoveAll();
	m_tabList.RemoveAll();
	char* text;
    offscreenDC.SetTextAlign(TA_LEFT | TA_TOP);
    offscreenDC.SetBkMode(TRANSPARENT);
    offscreenDC.SetTextColor(TranslateColor(GetForeColor()));
    CFont* pOldFont;
	if (m_hWnd) pOldFont = offscreenDC.SelectObject((CFont*)this->GetParent()->SendMessage(WM_GETGLOBALFONT,m_FontNum,NULL));
	else pOldFont = offscreenDC.GetCurrentFont();
	int width;
	int start=0;
	if (m_bHorzAlign)
	{
		int finish;
		float seperation;
		int total=0;
		int laststart;
		int lastfinish;
		float lastseperation;
		BOOL lastrow=FALSE;
		BOOL notreallylastrow=FALSE;
		int row=0;
		for (int x=0;x<count;x++)
		{
			if (x==m_iCurrentSelection) lastrow=TRUE;
			text=m_textList.GetNext(position);
			width=offscreenDC.GetTextExtent(text).cx+15; // 15 is minimum seperation between text
			total+=width;
			if (total>rect.Width() || x==count-1)
			{
				// decide whether to put this tab on the next row...
				// doesnt happen if it is the only tab on the row
				if (x>start && total>rect.Width()) //|| (x-start)<3))
				{
//					finish=x-1;
//					total-=width;
					if (x==m_iCurrentSelection) notreallylastrow=TRUE;
					x--;
					if (position==NULL) position=m_textList.GetTailPosition();
					else m_textList.GetPrev(position);
					total-=width;
				}
//				else finish=x;
				finish=x;
				seperation=(float)(rect.Width()-total+(15*(finish-start+1)))/(float)(finish-start+1);
				if (lastrow==FALSE || notreallylastrow==TRUE)
					{
					DrawRow(seperation,start,finish,&offscreenDC,row,rect.Width(),FALSE);
					notreallylastrow=FALSE;
					}
				else
				{
					laststart=start;
					lastfinish=finish;
					lastseperation=seperation;
					lastrow=FALSE;
					row--;
				}
				total=0;
				start=x+1;
				row++;
			}
		}
		DrawRow(lastseperation,laststart,lastfinish,&offscreenDC,row,rect.Width(),TRUE);
	}
	else
	{
		// Draw vertical tabs.
		long widest;
		widest=CalcWidestWord();
		CRect rect2;
		this->GetClientRect(rect2);
//		widest=rect2.Width();
//		TRACE1("Measured Width: %d\n",widest);
		int y=0;
		char word[30];
		int startpos;
		BOOL NewTab;
		int oldy;
		int starty;
		for (int z=0;z<count;z++)
		{
			NewTab=TRUE;
			text=m_textList.GetNext(position);
			// split into component words
			start=0;
			startpos=2;
			starty=y;
			for (int x=0;x<(int)strlen(text)+1;x++) // includes terminating null character
			{
				if (text[x]==' ' || text[x]==NULL)
				{
					strncpy(word,text+start,min(x-start+1,30));
					word[min(x-start+1,30)]=NULL;
					start=x+1;
					width=offscreenDC.GetTextExtent(word).cx;
					if (NewTab)
					{
						if (z==m_iCurrentSelection)
						{
							DrawIconEx(offscreenDC.m_hDC,widest-400,y+2,m_hHighTabIcon,400,30,NULL,NULL,DI_NORMAL);
							offscreenDC.MoveTo(0,y);
							offscreenDC.LineTo(widest-15,y);
							offscreenDC.MoveTo(0,y+1);
							offscreenDC.LineTo(widest-10,y+1);
						}
						else DrawIconEx(offscreenDC.m_hDC,widest-402,y+2,m_hLowTabIcon,400,30,NULL,NULL,DI_NORMAL);
					}
					else
					{
						if (width+startpos>widest-15)
						{
							// Draw it at start of next line
							y+=30;
							startpos=2;
						}
						if (y!=oldy)
						{
							if (z==m_iCurrentSelection) DrawIconEx(offscreenDC.m_hDC,widest-400,y+2,m_hHighContinueIcon,400,30,NULL,NULL,DI_NORMAL);
							else DrawIconEx(offscreenDC.m_hDC,widest-402,y+2,m_hLowContinueIcon,400,30,NULL,NULL,DI_NORMAL);
						}
					}
					oldy=y; // oldy indicates that the background tab icon has been drawn for this line
					if (z==m_iCurrentSelection)
					{
						offscreenDC.ExtTextOut(startpos+2,y,ETO_CLIPPED,CRect(0,y,widest-15,y+30),word,NULL);
						if (width+startpos+2>widest-15) offscreenDC.TextOut(widest-12,y,"...");
					}
					else
					{
						offscreenDC.ExtTextOut(startpos,y+2,ETO_CLIPPED,CRect(0,y+2,widest-15,y+22),word,NULL);
						if (width+startpos>widest-15) offscreenDC.TextOut(widest-14,y+2,"...");
						offscreenDC.MoveTo(0,y+2);
						offscreenDC.LineTo(0,y+22);
						offscreenDC.MoveTo(1,y+2);
						offscreenDC.LineTo(1,y+22);
					}
					NewTab=FALSE;
					startpos+=width;
				}
			}
			y+=30;
			if (z<count-1) m_rectList.AddTail(CRect(0,starty,widest,y));
			else m_rectList.AddTail(CRect(0,starty,widest,INT_MAX));
			m_tabList.AddTail(z);
			if (z==count-1) // if at end fill remaining area with blank tab
			{
				while (y<rect2.Height())
				{
					if (z==m_iCurrentSelection) DrawIconEx(offscreenDC.m_hDC,widest-400,y+2,m_hHighContinueIcon,400,30,NULL,NULL,DI_NORMAL);
					else DrawIconEx(offscreenDC.m_hDC,widest-402,y+2,m_hLowContinueIcon,400,30,NULL,NULL,DI_NORMAL);
					y+=30;
				}
			}
		}
	}
	VERIFY(pdc->BitBlt(0,0,rcBounds.right-rcBounds.left,rcBounds.bottom-rcBounds.top,&offscreenDC,
					0,0,SRCCOPY)); // flips offscreen dc to real dc
	// select out any objects that were selected in
	offscreenDC.SelectObject(pOldFont);
    offscreenDC.SelectObject(pOldBitmap);
	// then delete the dc
	offscreenDC.DeleteDC();
}
VPictureData_MacPicture::VPictureData_MacPicture(PortRef inPortRef, const VRect& inBounds)
{
	_SetDecoderByExtension(sCodec_pict);
	fPicHandle = NULL;
	fMetaFile = NULL;
	fTrans = NULL;
#if VERSIONWIN
	inPortRef; // pp pour warning
	inBounds;
	fGdiplusMetaFile = NULL;
#endif
#if VERSIONMAC
	GrafPtr oldPort;
	GetPort(&oldPort);
	SetPort(inPortRef);
	RGBColor saveFore, saveBack, white = { 0xffff, 0xffff, 0xffff }, black = { 0, 0, 0 };
	Rect r;

	inBounds.MAC_ToQDRect(r);

	GetBackColor(&saveFore);
	GetForeColor(&saveFore);

	RGBBackColor(&white);
	RGBForeColor(&black);

	PicHandle	newPicture = ::OpenPicture(&r);
	const BitMap*	portBits = ::GetPortBitMapForCopyBits(inPortRef);

	::ClipRect(&r);
	::CopyBits(portBits, portBits, &r, &r, srcCopy, NULL);
	::ClosePicture();

	RGBBackColor(&saveFore);
	RGBForeColor(&saveFore);

	SetPort(oldPort);
	fPicHandle = newPicture;

#if VERSIONWIN
	qtime::Rect rect;
	QDGetPictureBounds((qtime::Picture**)fPicHandle, &rect);
	fBounds.SetCoords(0, 0, rect.right - rect.left, rect.bottom - rect.top);
#else
	Rect rect;
	QDGetPictureBounds((Picture**) fPicHandle, &rect);
	fBounds.SetCoords(0, 0, rect.right - rect.left, rect.bottom - rect.top);
#endif

#if VERSIONMAC
	if (fPicHandle)
	{
		GetMacAllocator()->Lock(fPicHandle);
		CGDataProviderRef dataprov = xV4DPicture_MemoryDataProvider::CGDataProviderCreate(*(char**) fPicHandle, GetMacAllocator()->GetSize(fPicHandle), true);
		GetMacAllocator()->Unlock(fPicHandle);
		fMetaFile = QDPictCreateWithProvider(dataprov);
		CGDataProviderRelease(dataprov);
	}
#endif
#endif
}
示例#28
0
static void ROM_ShowMenuBar(_THIS)
{
#if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */
	RgnHandle		drawRgn = nil;
	RgnHandle		menuRgn = nil;
	RgnHandle		tempRgn = nil;
	RgnHandle		grayRgn = nil;
	WindowPtr		window = nil;
	GrafPtr			wMgrPort;
	GrafPtr			savePort;
	Rect			menuRect;
	long			response;
	short			height;
	EventRecord		theEvent;
	RGBColor		saveRGB;
	RGBColor		blackRGB = { 0, 0, 0 };

	height = GetMBarHeight();
	
	if ((height <= 0) && (gSaveMenuBar > 0)) {
		drawRgn = NewRgn();
		menuRgn = NewRgn();
		tempRgn = NewRgn();
		if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) {
			goto CLEANUP;
		}
		grayRgn = GetGrayRgn(); /* No need to check for this */
	
		GetPort(&savePort);
		GetWMgrPort(&wMgrPort);

		/* Set the height properly */
		LMSetMBarHeight(gSaveMenuBar);

		/* Restore the old GrayRgn: rounded corners, etc, but not
		   the menubar -- subtract that out first! */
		if (gSaveGrayRgn)
			{
			menuRect = (*GetMainDevice())->gdRect;
			menuRect.bottom = menuRect.top + gSaveMenuBar;
			RectRgn(menuRgn, &menuRect);

			DiffRgn(grayRgn, gSaveGrayRgn, drawRgn); 	/* What do we inval? */
			DiffRgn(drawRgn, menuRgn, drawRgn);			/* Clip out the menu */
			
			/* Now redraw the corners and other bits black */
			SetPort(wMgrPort);
			GetClip(tempRgn);
			SetClip(drawRgn);
			GetForeColor(&saveRGB);
			RGBForeColor(&blackRGB);
			PaintRgn(drawRgn);
			RGBForeColor(&saveRGB);
			SetClip(tempRgn);
			SetPort(savePort);
			
			UnionRgn(drawRgn, menuRgn, drawRgn);		/* Put back the menu */

			/* Now actually restore the GrayRgn */
			CopyRgn(gSaveGrayRgn, grayRgn);
			DisposeRgn(gSaveGrayRgn);
			gSaveGrayRgn = nil;
			}

		/* Modify the vis regions of exposed windows and draw menubar */
		window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L;
		PaintBehind(window, drawRgn);
		CalcVisBehind(window, drawRgn);
		DrawMenuBar();

		SetPort(savePort);
		gSaveMenuBar = 0;

		/* Now show the control strip if it's present */
		if (!Gestalt(gestaltControlStripAttr, &response) && 
				(response & (1L << gestaltControlStripExists)))
			{
			if (gSaveCSVis && !SBIsControlStripVisible())
				SBShowHideControlStrip(true);
			gSaveCSVis = true;
			}

		/* Yield time so that floaters can catch up */
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		EventAvail(0, &theEvent);
		}

CLEANUP:

	if (drawRgn) DisposeRgn(drawRgn);
	if (menuRgn) DisposeRgn(menuRgn);
	if (tempRgn) DisposeRgn(tempRgn);
#endif /* !TARGET_API_MAC_CARBON */
}
// Will draw in center of view rectangle in the current QD graphics context;
// modeled after fps display.
// It won't try to clip the ends of the lines.
bool Crosshairs_Render(Rect &ViewRect)
{
	if (!_Crosshairs_IsActive) return _Crosshairs_IsActive;
	
	// Get the crosshair data
	CrosshairData &Crosshairs = GetCrosshairData();
	
	// Push previous state
	PenState OldPen;
	RGBColor OldBackColor, OldForeColor;
	
	GetPenState(&OldPen);
	GetBackColor(&OldBackColor);
	GetForeColor(&OldForeColor);
	
	// Get ready to draw the crosshairs
	PenNormal();
	
	// Drawing color
	RGBForeColor(&Crosshairs.Color);

	// Get the center location from the view rectangle	
	// Shift it down one, so that even line widths can come out right.
	short XCen = ((ViewRect.left + ViewRect.right) >> 1) - 1;
	short YCen = ((ViewRect.top + ViewRect.bottom) >> 1) - 1;
	
	// Separate for X and Y; the points are three on top/left and three on top/right:
	// Line-split position
	// Octagon vertex (half-way)
	// Farthest extent
	short OctaPoints[2][6];
	short Len;
	
	switch(Crosshairs.Shape)
	{
	case CHShape_RealCrosshairs:
	
		PenSize(1,Crosshairs.Thickness);
		
		// Left
		MoveTo(XCen-Crosshairs.FromCenter+Crosshairs.Thickness-1,YCen);
		Line(-Crosshairs.Length,0);
		
		// Right
		MoveTo(XCen+Crosshairs.FromCenter,YCen);
		Line(Crosshairs.Length,0);
		
		PenSize(Crosshairs.Thickness,1);
		
		// Top
		MoveTo(XCen,YCen-Crosshairs.FromCenter+Crosshairs.Thickness-1);
		Line(0,-Crosshairs.Length);
		
		// Bottom
		MoveTo(XCen,YCen+Crosshairs.FromCenter);
		Line(0,Crosshairs.Length);
		
		break;
		
	case CHShape_Circle:
		// This will really be an octagon, for OpenGL-rendering convenience
		
		// Precalculate the line endpoints, for convenience
		
		Len = Crosshairs.Length;
		OctaPoints[0][0] = XCen - Len;
		OctaPoints[0][5] = XCen + Len;
		OctaPoints[1][0] = YCen - Len;
		OctaPoints[1][5] = YCen + Len;
		
		Len = Len/2;
		OctaPoints[0][1] = XCen - Len;
		OctaPoints[0][4] = XCen + Len;
		OctaPoints[1][1] = YCen - Len;
		OctaPoints[1][4] = YCen + Len;
		
		Len = MIN(Len,Crosshairs.FromCenter);
		OctaPoints[0][2] = XCen - Len;
		OctaPoints[0][3] = XCen + Len;
		OctaPoints[1][2] = YCen - Len;
		OctaPoints[1][3] = YCen + Len;
		
		// We need to do 12 line segments, so we do them in 2*2*3 fashion
		
		for (int ix=0; ix<2; ix++)
		{
			int ixi = (ix > 0) ? 5 : 0;
			int ixid = (ix > 0) ? -1 : 1;
			for (int iy=0; iy<2; iy++)
			{
				int iyi = (iy > 0) ? 5 : 0;
				int iyid = (iy > 0) ? -1 : 1;
				
				// Vertical
				PenSize(Crosshairs.Thickness,1);
				MoveTo(OctaPoints[0][ixi],OctaPoints[1][iyi+2*iyid]);
				LineTo(OctaPoints[0][ixi],OctaPoints[1][iyi+iyid]);
				
				// Diagonal
				PenSize(Crosshairs.Thickness,Crosshairs.Thickness);
				LineTo(OctaPoints[0][ixi+ixid],OctaPoints[1][iyi]);
				
				// Horizontal
				PenSize(1,Crosshairs.Thickness);
				LineTo(OctaPoints[0][ixi+2*ixid],OctaPoints[1][iyi]);
			}
		}
		
		break;
	}
	
	// Pop previous state
	SetPenState(&OldPen);
	RGBBackColor(&OldBackColor);
	RGBForeColor(&OldForeColor);
		
	return _Crosshairs_IsActive;
}
示例#30
0
void DrawMapPoly (CMap* theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings)
{
	RGBColor	saveColor;
	drawSettings -> bClosed = IsPolyClosed (MapPolyHdl);
#ifdef MAC
	long		PointCount;

	//drawSettings -> bClosed = IsPolyClosed (MapPolyHdl);

	GetForeColor (&saveColor);		/* save original forecolor */

	if (drawSettings -> bClosed)
	{
		if (drawSettings -> mode == kPictMode)
		{
			DrawSectPoly (theMap, MapPolyHdl, drawSettings);	/* changed 11/21/95 due to postscript errors */
//			DrawNoSectPoly (theMap, MapPolyHdl, drawSettings);	/* changed back on 3/28/96
		}
		else
		{
			//PointCount = GetPolyPointCount (MapPolyHdl);
			//if (PointCount > 7000)
			//{
			//	/* draw polygon interior without any frame */
			//	drawSettings -> frameCode = kNoFrameCode;
			//	DrawNoSectPoly (theMap, MapPolyHdl, drawSettings);
			//
				/* then draw polygon outline without using poly-routines */
			//	drawSettings -> frameCode = kPaintFrameCode;
			//	drawSettings -> fillCode = kNoFillCode;
			//	DrawNoSectPoly (theMap, MapPolyHdl, drawSettings);
			//}
			//else
				DrawNoSectPoly (theMap, MapPolyHdl, drawSettings);
		}
	}
	else	/* hollow polygon, no fill of any kind */
	{
		DrawNoSectPoly (theMap, MapPolyHdl, drawSettings);
	}

	RGBForeColor (&saveColor);

	return;
#else
	long numPts = (**MapPolyHdl).pointCount;
	POINT **pointsH = (POINT**)_NewHandle(numPts *sizeof(POINT));
	LongPoint** thisPointsHdl=nil;
	Point pt;
	LongPoint wPt;
	long i, esiCode;
	long penWidth = 2, halfPenWidth = 0;
	Boolean bDrawBlackAndWhite = (sharedPrinting && settings.printMode != COLORMODE);
	Boolean offQuickDrawPlane = false, drawingESILayer = false;
	if(!pointsH) {SysBeep(5); return;}
	
	thisPointsHdl = (LongPoint**) (**MapPolyHdl).objectDataHdl;
	GetObjectESICode ((ObjectRecHdl) MapPolyHdl,&esiCode); 
	if (esiCode>0) 	// -500 is the default
	{
		//halfPenWidth = penWidth/2;
		PenStyle(BLACK,penWidth);
		drawingESILayer = true;
	}
	for(i = 0; i< numPts;i++)
	{
		wPt = INDEXH(thisPointsHdl,i);
		//pt.h = SameDifferenceX(wPt.h);
		//pt.v = (gRect.bottom + gRect.top) - SameDifferenceY(wPt.v);
		pt = GetQuickDrawPt(wPt.h,wPt.v,&gRect,&offQuickDrawPlane);
		//pt.h += drawSettings -> offsetDx;
		//pt.v += drawSettings -> offsetDy;
		INDEXH(pointsH,i) = MakePOINT(pt.h-halfPenWidth,pt.v-halfPenWidth);
		// code goes here, make sure this point does not equal previous point JLM
	}
	GetForeColor (&saveColor);		/* save original forecolor */

	//Our_PmForeColor (bDrawBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);//JLM
	// make sure the blackandwhite bitmaps come out right
	Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);//JLM
	if (drawSettings -> fillCode == kNoFillCode && drawSettings->backColorInd == kWaterColorInd) 
		Our_PmForeColor (drawSettings -> foreColorInd);
	else
	{
		if(bDrawBlackAndWhite) 
		{
			//SetPenPat(UPSTRIPES);
			// we want solid outline and a patterned inside
			FillPat(UPSTRIPES);
			PenStyle(BLACK,1);
		}
	}

	//if(numPts > 2) Polygon(currentHDC,*pointsH,numPts);
	// 6/11/03 PC wasn't recognizing the flag for not filling a land polygon
	if (drawSettings -> bClosed)
	{
		if(numPts > 2) Polygon(currentHDC,*pointsH,numPts);
	}
	else
	{
		//POINT p[2];
		//p[0] = INDEXH(pointsH,numPts-1);
		//p[1] = INDEXH(pointsH,0);
		//RGBForeColor(&colors[BLACK]);
		if(numPts >= 2) 
		{
			Polyline(currentHDC,*pointsH,numPts);
			//if (!drawingESILayer)
				//Polyline(currentHDC,p,2);	// close the polygon
		}
	}

	if(bDrawBlackAndWhite) SetPenPat(BLACK);
	
	RGBForeColor (&saveColor);
	DisposeHandle((Handle)pointsH);

#endif
}