예제 #1
0
static WORD
AttrVideo(int b, int f)
{
    WORD result;
    if (rvcolor) {
	result = ((WORD) ((ForeColor(f) << 4) | BackColor(b)));
	TRACE2(("rev AttrVideo(%d,%d) = %04x\n", f, b, result));
    } else {
	result = ((WORD) ((BackColor(b) << 4) | ForeColor(f)));
	TRACE2(("AttrVideo(%d,%d) = %04x\n", f, b, result));
    }
    return result;
}
예제 #2
0
static void QTVideo_DrawFrame (const Rect *trackFrame, long curSample)
{
	Str255 numStr;

		ForeColor( redColor );
		PaintRect( trackFrame );

		ForeColor( blueColor );
		NumToString (curSample, numStr);
		MoveTo ( (short)(trackFrame->right / 2), (short)(trackFrame->bottom / 2));
		TextSize ( (short)(trackFrame->bottom / 3));
		DrawString (numStr);
} 
예제 #3
0
void drawDeepBox( Rect *rect )
{
	Rect		box;
	
	box = *rect;
	box.right += 2;
	box.bottom += 2;
	
	ForeColor( blackColor );
	FrameRect( &box );
	
	OffsetRect( &box, -1, -1 );
	ForeColor( whiteColor );
	FrameRect( &box );
}
예제 #4
0
파일: tooltip.cpp 프로젝트: gitrider/wxsj2
void wxMacToolTip::Clear()
{
    m_mark++ ;
    if ( m_timer )
    {
        delete m_timer ;
        m_timer = NULL ;
    }
    if ( !m_shown )
        return ;
#if TARGET_CARBON
    HMHideTag() ;
    m_helpTextRef.Release() ;
#else         
    if ( m_window == s_ToolTipWindowRef && m_backpict )
    {
        wxMacPortStateHelper help( (GrafPtr) GetWindowPort(m_window) ) ;

        m_shown = false ;

        BackColor( whiteColor ) ;
        ForeColor(blackColor ) ;
        DrawPicture(m_backpict, &m_rect);
        KillPicture(m_backpict);
        m_backpict = NULL ;
    }
#endif
}
void PreviewDrawer(ControlRef Ctrl, void *Data)
{
	// Don't need the data arg here
	CrosshairData &Crosshairs = GetCrosshairData();	// An alias for the global crosshair data
	
	// No need for the window context -- it's assumed
	Rect Bounds = {0,0,0,0};
	
	GetControlBounds(Ctrl, &Bounds);
	
	// Get ready to draw!
	PenNormal();
	
	// Draw the background
	RGBForeColor(&BkgdColor);
	PaintRect(&Bounds);
	
	// Clip to inside of box
	ClipRect(&Bounds);
	
	// Draw the crosshairs
	Crosshairs_Render(Bounds);
	
	// Draw the boundary line
	ForeColor(blackColor);
	FrameRect(&Bounds);
}
예제 #6
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);
}
예제 #7
0
bool MCRegionCalculateMask(MCRegionRef self, int32_t w, int32_t h, MCBitmap*& r_mask)
{
	// Create a pixmap
	Pixmap t_image;
	t_image = MCscreen -> createpixmap(w, h, 1, False);
	
	// Draw into the pixmap's port
	CGrafPtr t_old_port;
	GDHandle t_old_device;
	GetGWorld(&t_old_port, &t_old_device);
	SetGWorld((CGrafPtr)t_image -> handle . pixmap, NULL);
	
	BackColor(whiteColor);
	ForeColor(blackColor);
	
	Rect t_rect;
	SetRect(&t_rect, 0, 0, w, h);
	EraseRect(&t_rect);
	
	PaintRgn((RgnHandle)self);
	
	SetGWorld(t_old_port, t_old_device);
	
	// Fetch the pixmap as a bitmap
	MCBitmap *t_bitmap;
	t_bitmap = MCscreen -> getimage(t_image, 0, 0, w, h, False);
	
	// Discard the pixmap
	MCscreen -> freepixmap(t_image);
	
	r_mask = t_bitmap;
	
	return true;
}
void drawPixelImageData()
{
	int				row, col;
	Rect			rect;
	unsigned char	value;
	char			*image;
	int				index = 0;
	Str255			string;
	RGBColor		color = { 32000, 32000, 32000 };
	//Byte			mode;
	Rect			tempRect1;
	
	ForeColor( blackColor );
	
	SetRect( &rect, 0, 0, 20, 20 );
	
	/* For this example, let's just use only the upper left corner of the image. */
	
	// Draw the offscreen image to the screen to see what it looks like.
	//CopyBits( (BitMap *)*gPixmap, &gWindow->portBits, &rect,
	//		&gWindow->portRect, srcCopy, 0 );
	//(**gPixmap).rowBytes ^= 0x8000;
	CopyBits( (BitMap *)*gPixmap, GetPortBitMapForCopyBits(GetWindowPort(gWindow)), &rect,
			GetPortBounds(GetWindowPort(gWindow), &tempRect1), srcCopy, 0 );
	//(**gPixmap).rowBytes ^= 0x8000;
	
	RGBForeColor( &color );
	
	// Again, set the pointer to the beginning of the pixel image.
	image = GetPixBaseAddr( gPixmap );
	
	/***************************************************************/
	/* Finally let's display the pixel values on top of the image. */
	/***************************************************************/
	
	/* Loop through the first 20 rows of the pixel image. */
	for (row = 0; row < rect.bottom; row++)
	{
		// Loop through the first 20 columns of the pixel image. 
		for (index = 0, col = 0; col < rect.right; col++)
		{
			// Get the value at this index into the pixel image. 
			value = (unsigned char)*(image + index);
			
			MoveTo( col * 30, row * 20 );
			LineTo( col * 30, (row + 1) * 20 );
			LineTo( (col + 1) * 30, (row + 1) * 20 );
			
			MoveTo( (col * 30) + 6, (row * 20) + 14 );
			NumToString( (long)value, string );
			DrawString( string );
			
			index++;
		}
		
		// Increment the pointer to the next row of the pixel image. 
		image += ((**gPixmap).rowBytes & 0x7fff);
	}
}
예제 #9
0
void drawItem(int left, int top, Str255 *label, Boolean listEnabled, Boolean itemEnabled )
{
	Rect		rect;
	RGBColor	color, markColor;
	
	if (listEnabled)
		color.red = color.green = color.blue = 0xffff;
	else
		color.red = color.green = color.blue = 0xffff / 2;
		
	SetRect( &rect, left, top + 2, left + 12, top + 14 );
	ForeColor( blackColor );
	FrameOval( &rect );
	
	OffsetRect( &rect, -1, -1 );
	RGBForeColor( &color );
	FrameOval( &rect );
				
	if (listEnabled && itemEnabled)
		markColor.red = markColor.green = markColor.blue = 0xffff;
	else if (itemEnabled)
		markColor.red = markColor.green = markColor.blue = 0xffff / 2;
	else
		markColor.red = markColor.green = markColor.blue = 8700;
	
	InsetRect( &rect, 3, 3 );
	RGBForeColor( &markColor );
	PaintOval( &rect );
	
	ForeColor( blackColor );
	MoveTo( left + 16, top + 11 );
	DrawString( (unsigned char*)label );
	
	RGBForeColor( &color );
	MoveTo( left + 15, top + 10 );
	DrawString( (unsigned char*)label );
}
예제 #10
0
void drawName(int left, int top, Str255 name )
{
	RGBColor	color;
	
	ForeColor( blackColor );
	MoveTo( left + 1, top + 1 );
	DrawString( name );
	
	color.red = color.green = 0xffff;
	color.blue = 40000;
	RGBForeColor( &color );
	
	MoveTo( left, top );
	DrawString( name );
}
예제 #11
0
void drawSourceImage()
{
	Rect	rect;
	Rect	outlineRect;
	Rect	tempRect1;

	GetPortBounds(gGWorld, &tempRect1);		
	SetRect( &rect, 20, 37, 20 + tempRect1.right, 37 + tempRect1.bottom);

	outlineRect = rect;
	InsetRect( &outlineRect, -5, -5 );
	drawDeepBox( &outlineRect );
	
	ForeColor( blackColor );
	BackColor( whiteColor );
	
	CopyBits( (BitMap *)(*(GetPortPixMap(gGWorld))), GetPortBitMapForCopyBits(GetWindowPort(gWindow)),
				&((**(GetPortPixMap(gGWorld))).bounds), &rect, srcCopy, nil );
}
예제 #12
0
파일: vlcshell.cpp 프로젝트: paa/vlc
int16_t NPP_HandleEvent( NPP instance, void * event )
{
    static UInt32 lastMouseUp = 0;
    if( instance == NULL )
    {
        return false;
    }

    VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
    if( p_plugin == NULL )
    {
        return false;
    }

#ifndef __x86_64__  
    EventRecord *myEvent = (EventRecord*)event;

    switch( myEvent->what )
    {
        case nullEvent:
            return true;
        case mouseDown:
        {
            if( (myEvent->when - lastMouseUp) < GetDblTime() )
            {
                /* double click */
                p_plugin->toggle_fullscreen();
            }
            return true;
        }
        case mouseUp:
            lastMouseUp = myEvent->when;
            return true;
        case keyUp:
        case keyDown:
        case autoKey:
            return true;
        case updateEvt:
        {
            const NPWindow& npwindow = p_plugin->getWindow();
            if( npwindow.window )
            {
                bool hasVout = false;

                if( p_plugin->playlist_isplaying() )
                {
                    hasVout = p_plugin->player_has_vout();
#if 0
                    if( hasVout )
                    {
                        libvlc_rectangle_t area;
                        area.left = 0;
                        area.top = 0;
                        area.right = npwindow.width;
                        area.bottom = npwindow.height;
                        libvlc_video_redraw_rectangle(p_plugin->getMD(), &area, NULL);
                    }
#else
#warning disabled code
#endif
                }

                if( ! hasVout )
                {
                    /* draw the beautiful "No Picture" */

                    ForeColor(blackColor);
                    PenMode( patCopy );

                    /* seems that firefox forgets to set the following
                     * on occasion (reload) */
                    SetOrigin(((NP_Port *)npwindow.window)->portx,
                              ((NP_Port *)npwindow.window)->porty);

                    Rect rect;
                    rect.left = 0;
                    rect.top = 0;
                    rect.right = npwindow.width;
                    rect.bottom = npwindow.height;
                    PaintRect( &rect );

                    ForeColor(whiteColor);
                    MoveTo( (npwindow.width-80)/ 2  , npwindow.height / 2 );
                    if( p_plugin->psz_text )
                        DrawText( p_plugin->psz_text, 0, strlen(p_plugin->psz_text) );
                }
            }
            return true;
        }
        case activateEvt:
            return false;
        case NPEventType_GetFocusEvent:
        case NPEventType_LoseFocusEvent:
            return true;
        case NPEventType_AdjustCursorEvent:
            return false;
        case NPEventType_MenuCommandEvent:
            return false;
        case NPEventType_ClippingChangedEvent:
            return false;
        case NPEventType_ScrollingBeginsEvent:
            return true;
        case NPEventType_ScrollingEndsEvent:
            return true;
        default:
            ;
    }
#endif // __x86_64__
    return false;
}
예제 #13
0
void CWindowOSXQT::OnPaint()
{
	int iBytesNeeded = (mSize.iCX + 1) * (mSize.iCY + 1) * 4;
	if (iBytesNeeded > miDrawBufferSize) {
		if (mpcDrawBuffer) {
			delete[] mpcDrawBuffer;
		}

		miDrawBufferSize = iBytesNeeded;
		mpcDrawBuffer = new tuchar[miDrawBufferSize];
	}

	if (mpInvalidater->IsRectInvalidated() == false) {
		// No updating neccasary
		return;
	}
	SRect RectUpdate;
	mpInvalidater->GetInvalidatedRect(RectUpdate);
	mpInvalidater->Reset();

	// Limit update rect to our actual size
	SRect RectThis(SPos(0, 0), mSize);
	RectUpdate.FitInside(RectThis);

	GetPane()->OnDraw(RectUpdate);
	if (mpControlOnTop) {
		mpControlOnTop->OnDraw(RectUpdate);
	}

	PixMap 			srcbm;
	GrafPtr 		saved;
	Rect 			portBounds;
	GrafPtr 		grafPtrThis;
	BitMapPtr 		dstbitmap;
	PixMapHandle	dstpixmap;

	memset(&srcbm,0,sizeof(PixMap));
	// setup begin
	srcbm.baseAddr = nil;
	srcbm.rowBytes = 0x8000;

	srcbm.bounds.left = 0;
	srcbm.bounds.top = 0;
	srcbm.bounds.right = mSize.iCX - 1;
	srcbm.bounds.bottom = mSize.iCY - 1;
	
	// ???
	int bytesPerRow = mSize.iCX * 4;

	srcbm.pmVersion = 4;
	srcbm.packType = 0;
	srcbm.packSize = 0;
	srcbm.hRes = 0x00480000;
	srcbm.vRes = 0x00480000;
	srcbm.pixelType = 0;
	srcbm.pixelSize = 0;
	srcbm.cmpCount = 0;
	srcbm.cmpSize = 0;
	srcbm.pmTable = nil;
	srcbm.pixelType = RGBDirect;
	srcbm.pixelSize = 32;
	srcbm.cmpCount = 3;
	srcbm.cmpSize = 5;
	srcbm.rowBytes = 0x8000 | (unsigned short) bytesPerRow;
	srcbm.baseAddr = (Ptr)mpcDrawBuffer;
	
	unsigned long ulOffsetX, ulOffsetY;
	ulOffsetX = 0;
	ulOffsetY = 0;
	
	Rect SrcRect;	
	SrcRect.left    = RectUpdate.iX;
	SrcRect.right   = RectUpdate.iX + RectUpdate.iCX - 1;
	SrcRect.top     = RectUpdate.iY;
	SrcRect.bottom  = RectUpdate.iY + RectUpdate.iCY - 1;

	Rect DstRect;
	DstRect = SrcRect;
		
	GetPort(&saved);
	
	grafPtrThis = (GrafPtr)::GetWindowPort(GetWindowRef());

	if (saved != grafPtrThis) {
		SetPort(grafPtrThis);
	}

	GetPortBounds(grafPtrThis, &portBounds);

	int port_offsetX = portBounds.left;
	int port_offsetY = portBounds.top;

	SetOrigin( port_offsetX, port_offsetY );
/*	Rect rctClip;
	rctClip.left = 0;
	rctClip.right = rctClip.left + mSize.iCX;
	rctClip.top = 0;
	rctClip.bottom = rctClip.top + mSize.iCY;
	ClipRect(&rctClip);*/
	
	dstpixmap = ::GetPortPixMap(grafPtrThis);
	
	dstbitmap = (BitMapPtr)(*dstpixmap);
	
	ForeColor(blackColor);
	BackColor(whiteColor);
	
	::CopyBits((BitMapPtr)&srcbm,
		dstbitmap,
		&SrcRect,
		&DstRect,
		srcCopy,
		nil);
		
//	SetOrigin(0, 0);

	if (saved != grafPtrThis) {
		SetPort(saved);
	}
}
예제 #14
0
/****************************************************************
   PopDraw() is the function associated with the user item that
   invokes the popup menu.  We draw the box to look like a menu
   cell, and then call the appropriate drawProc to fill in the
   cell with the actual contents.  If the drawProc is nil, we
   draw the menu item as text.  We gray the cell if the menu
   is disabled.  Finally, we draw a down arrow to indicate that
   the button is a popup menu.

   If the popup item is static, we only draw the cell contents.
 ****************************************************************/
pascal_ifMac void PopDraw(DialogPtr theDialog, short itemNum)
{
   GrafPtr        savePort;
   short          theType;
   Handle         itemHandle;
   Rect           itemBox;
   Rect           cellBox;
   MenuHandle     theMenu;
   //SysEnvRec      theWorld;
   RGBColor       SaveBack, SaveFore, DefaultBack, DefaultFore;
   char           name[256];
   short          i;
   short          drawStringFlag;

   // Added by Glen to code for support of Type-in Pop-Up menus
   // if drawStringFlag  = 1 then we don't draw text string ...
	
   drawStringFlag = 0;

   for ( i = 0 ; i < sa_numPopUps ; i++ )
      if ( (sa_popTable[i].dialogPtr == theDialog) && (sa_popTable[i].popupItemNum == itemNum) )
         break;
                              if (i == sa_numPopUps)
      { SysBeep(1); return; }    // should not happen since the dialog must have been registered
                                             // for PopDraw to have been called

   GetPortGrafPtr(&savePort);
   SetPortDialogPort(theDialog);
  // SysEnvirons(curSysEnvVers,&theWorld);

  // if (theWorld.hasColorQD) {
  if (ColorQDAvailable()) {
      GetForeColor(&SaveFore);
      GetBackColor(&SaveBack);
      DefaultMenuColors(&DefaultFore, &DefaultBack);
      if (sa_popTable[i].bStatic) {
         DefaultFore = SaveFore;
         DefaultBack = SaveBack;
      }
   }

   theMenu = GetMenuHandle(sa_popTable[i].menuID);
   if (!theMenu) { SysBeep(1); return; }
   
   /* change item's width to match the menu */
   GetDialogItem(theDialog,itemNum,&theType,&itemHandle,&itemBox);
   CalcMenuSize(theMenu);
   if (sa_popTable[i].itemWidth == 0) {
      if (sa_popTable[i].drawProc == nil)
        // itemBox.right = itemBox.left + (**theMenu).menuWidth + 20 + 2;
         itemBox.right = itemBox.left + GetMenuWidth(theMenu) + 20 + 2;
      else
         //itemBox.right = itemBox.left + (**theMenu).menuWidth + 2;
         itemBox.right = itemBox.left + GetMenuWidth(theMenu) + 2;
   }
   else if (sa_popTable[i].itemWidth == -1) {  // Type-in Pop-Up Menu
      itemBox.right = itemBox.left + 20 + 2;
      drawStringFlag = 1;
   }
   else
      itemBox.right = itemBox.left + sa_popTable[i].itemWidth + 2;
   SetDialogItem(theDialog,itemNum,theType,itemHandle,&itemBox);

   /* draw the box */
   if (TRUE) { // !sa_popTable[i].bStatic
     // if (theWorld.hasColorQD) RGBBackColor(&DefaultBack);
     if (ColorQDAvailable()) RGBBackColor(&DefaultBack);
      EraseRect( &itemBox );
     // if (theWorld.hasColorQD) RGBForeColor(&SaveFore);
     if (ColorQDAvailable())  RGBForeColor(&SaveFore);
      PenNormal();
	 // if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&qd.gray);
	  //if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&GRAY_BRUSH());
	  //if (sa_popTable[i].bStatic) PenPat((ConstPatternParam)&GRAY_BRUSH);
	  if (sa_popTable[i].bStatic) PenPatQDGlobalsGray();
      FrameRect(&itemBox);
      /* draw the shadow */
      MoveTo(itemBox.left + 3, itemBox.bottom);
      Line((itemBox.right - itemBox.left) - 3, 0);
      Line(0, -((itemBox.bottom - itemBox.top) - 2));
      PenNormal();
   }
   else
      EraseRect( &itemBox );

   /* draw the current item in the box */

  // if (theWorld.hasColorQD) RGBForeColor(&DefaultFore);
    if (ColorQDAvailable()) RGBForeColor(&DefaultFore);

   // Draw text if no Type-in Pop-Up
   if(drawStringFlag == 0){
      if (sa_popTable[i].drawProc != nil) {
         cellBox = itemBox;
         InsetRect(&cellBox, 1, 1);
         (* sa_popTable[i].drawProc) (theMenu,
                                                sa_popTable[i].lastItemSelected,
                                                &cellBox,         // so the drawProc gets the same-size rect,
                                                                      // whether it's drawing in the menu or in the pop-box
                                                true,           // since we are indeed drawing a pop box item
                                                //&theWorld,
                                                &DefaultFore,
                                                &DefaultBack);
      }
      else {
         MoveTo(itemBox.left + 15, itemBox.top + 4 + (itemBox.bottom - itemBox.top)/2);
         GetMenuItemText(theMenu, sa_popTable[i].lastItemSelected, (unsigned char *)name);
         DrawString((unsigned char *)name);
      }
   }

   if (TRUE) { // !sa_popTable[i].bStatic
      /* cover the item in gray if the menu is disabled */
     // if (!((**theMenu).enableFlags & ENABLE_BIT)) {
	  #if TARGET_API_MAC_CARBON
	 	 Boolean menuIsEnabled = IsMenuItemEnabled(theMenu,0);
	 #else
	 	 Boolean menuIsEnabled = (**theMenu).enableFlags & ENABLE_BIT;
	 #endif
      if (!menuIsEnabled) {
         //PenPat((ConstPatternParam)&qd.gray);
         //PenPat((ConstPatternParam)&GRAY_BRUSH);
		 PenPatQDGlobalsGray();
         PenMode(patOr);
         //if (theWorld.hasColorQD) RGBForeColor(&DefaultBack);
         if (ColorQDAvailable()) RGBForeColor(&DefaultBack); 
         else ForeColor(whiteColor);
         PaintRect(&itemBox);
         PenNormal();
        // if (theWorld.hasColorQD) RGBForeColor(&DefaultFore);
         if (ColorQDAvailable()) RGBForeColor(&DefaultFore);
         else ForeColor(blackColor);
      }

      /* draw the down arrow */
      itemBox.left = itemBox.right - 20;
      DrawArrow(&itemBox, kDown, sa_popTable[i].bStatic);
   }

   //if (theWorld.hasColorQD) {
   if (ColorQDAvailable()) {
     RGBForeColor(&SaveFore);
     RGBBackColor(&SaveBack);
   }

   SetPortGrafPort(savePort);
}
예제 #15
0
void 
InAdditionsContent(EventRecord* evt, WindowPtr wCurrPtr)
{
	Point 			localPt;
	Rect			r, currCellRect, checkbox;
	ControlPartCode	part;
	int				i;
	Cell			currCell;
	UInt8			hiliteVal;
	PixPatHandle	ppH;
	GrafPtr			oldPort;
	GetPort(&oldPort);
	
	SetPort(wCurrPtr);
	localPt = evt->where;
	GlobalToLocal( &localPt);
	
	/* Mouse Up */
	
	/* scroll */
	SetRect(&r, gControls->aw->compListBox.right, gControls->aw->compListBox.top, 
	            gControls->aw->compListBox.right + kScrollBarWidth, gControls->aw->compListBox.bottom);
	if ((evt->what == mouseUp) && (PtInRect( localPt, &r)))
	{    	    
	    LClick(localPt, evt->modifiers, gControls->aw->compList);
	    
	    SetRect(&r, gControls->aw->compListBox.left, gControls->aw->compListBox.top,
	                gControls->aw->compListBox.right + 1, gControls->aw->compListBox.bottom);
	    FrameRect(&r);
	}
	
	/* or un/check components */
	if ((evt->what == mouseUp) && (PtInRect( localPt, &gControls->aw->compListBox)))
	{
		LClick(localPt, evt->modifiers, gControls->aw->compList);
		AddUpdateRowHighlight(localPt);
		
		/* invert the checkbox rect */
		for (i=0; i<numRows; i++)
		{
			SetPt(&currCell, 0, i);
			LRect(&currCellRect, currCell, gControls->aw->compList);
			if (PtInRect(localPt, &currCellRect))
			{
				SetRect(&checkbox, currCellRect.left+4, currCellRect.top+2, 
							currCellRect.left+16, currCellRect.top+14);		
				INVERT_HIGHLIGHT(&checkbox);
				break;
			}
		}
		
		AddSetOptInfo(false);
	}
	
	/* Mouse Down */
	if ((evt->what == mouseDown) && (PtInRect( localPt, &gControls->aw->compListBox)))
	{
		/* show depressed button state */
	    for (i=0; i<numRows; i++)
		{
			SetPt(&currCell, 0, i);
			LRect(&currCellRect, currCell, gControls->aw->compList);
			if (PtInRect(localPt, &currCellRect))
			{
				SetRect(&checkbox, currCellRect.left+4, currCellRect.top+2, 
							currCellRect.left+16, currCellRect.top+14);	
				ppH = GetPixPat(rGrayPixPattern);
				FillCRect(&checkbox, ppH);	
				FrameRect(&checkbox);	
				if (gControls->cfg->comp[rowToComp[i]].selected)
				{
					/* draw check mark */
					MoveTo(checkbox.left+1, checkbox.top+1);
					LineTo(checkbox.right-2, checkbox.bottom-2);
					MoveTo(checkbox.right-2, checkbox.top+1);
					LineTo(checkbox.left+1, checkbox.bottom-2); 
				}
				/* create 3D depression */
				
				MoveTo(checkbox.left+1, checkbox.top+1);
				LineTo(checkbox.left+1, checkbox.bottom-1);
				MoveTo(checkbox.left+1, checkbox.top+1);
				LineTo(checkbox.right-1, checkbox.top+1);
				
				ForeColor(whiteColor);
				
				MoveTo(checkbox.right-1, checkbox.top+1);
				LineTo(checkbox.right-1, checkbox.bottom-1);
				MoveTo(checkbox.left+1, checkbox.bottom-1);
				LineTo(checkbox.right-1, checkbox.bottom-1);
				
				ForeColor(blackColor);
			
				if (ppH)
					DisposePixPat(ppH);
				break;
			}
		}
	}
			
	HLock((Handle)gControls->backB);
	r = (**(gControls->backB)).contrlRect;
	HUnlock((Handle)gControls->backB);
	if (PtInRect( localPt, &r))
	{
		/* reset all rows to be not highlighted */
		for (i=1; i<numRows; i++)
			gControls->cfg->comp[rowToComp[i]].highlighted = false;
		
		part = TrackControl(gControls->backB, evt->where, NULL);
		if (part)
		{ 
			/* extra handling since we used DrawString for static text msg 
			 * and framed our own listbox etc. 
			 */
			gControls->aw->compListBox.top = 0;
			EraseRect(&gControls->aw->compListBox);
			ClearDiskSpaceMsgs();
			
			KillControls(gWPtr);
			ShowComponentsWin();
			return;
		}
	}
			
	HLock((Handle)gControls->nextB);			
	r = (**(gControls->nextB)).contrlRect;
	HUnlock((Handle)gControls->nextB);
	if (PtInRect( localPt, &r))
	{
		/* reset all rows to be not highlighted */
		for (i=0; i<numRows; i++)
			gControls->cfg->comp[rowToComp[i]].highlighted = false;
			
		part = TrackControl(gControls->nextB, evt->where, NULL);
		if (part)
		{	
			if (!VerifyDiskSpace())
			    return;
			    		
			gControls->aw->compListBox.top = 0;
			EraseRect(&gControls->aw->compListBox);
			ClearDiskSpaceMsgs();
						
			KillControls(gWPtr);
			ShowTerminalWin();
			return;
		}
	}
	SetPort(oldPort);
}
예제 #16
0
bool MCImageBitmapToPICT(MCImageBitmap *p_bitmap, MCMacSysPictHandle &r_pict)
{
#ifdef LIBGRAPHICS_BROKEN
	bool t_success = true;
	
	Pixmap drawdata = nil, drawmask = nil;
	MCBitmap *maskimagealpha = nil;
	
	t_success = MCImageSplitPixmaps(p_bitmap, drawdata, drawmask, maskimagealpha);
	
	if (!t_success)
		return false;

	Rect t_rect;
	SetRect(&t_rect, 0, 0, p_bitmap->width, p_bitmap->height);
	
	GWorldPtr t_old_gworld;
	GDHandle t_old_gdevice;
	GetGWorld(&t_old_gworld, &t_old_gdevice);

	PixMapHandle t_draw_pixmap;
	t_draw_pixmap = GetGWorldPixMap((CGrafPtr)drawdata -> handle . pixmap);
	
	GWorldPtr t_img_gworld;
	t_img_gworld = NULL;
	if (t_success)
	{
		QDErr t_err;
		t_err = NewGWorld(&t_img_gworld, 32, &t_rect, NULL, NULL, 0);
		if (t_err != noErr)
			t_success = false;
	}
	
	if (t_success)
	{
		SetGWorld(t_img_gworld, GetGDevice());
		
		PenMode(srcCopy);
		ForeColor(blackColor);
		BackColor(whiteColor);
		
		if (maskimagealpha != NULL)
		{
			GWorldPtr t_alpha_gworld;
			if (NewGWorldFromPtr(&t_alpha_gworld, 8, &t_rect, GetCTable(40), NULL, 0, maskimagealpha -> data, maskimagealpha -> bytes_per_line) == noErr)
			{
				const BitMap *t_dst_bits;
				t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld);
				
				const BitMap *t_src_bits;
				t_src_bits = GetPortBitMapForCopyBits((CGrafPtr)drawdata -> handle . pixmap);
				
				const BitMap *t_mask_bits;
				t_mask_bits = GetPortBitMapForCopyBits(t_alpha_gworld);
				
				EraseRect(&t_rect);
				
				CopyDeepMask(t_src_bits, t_mask_bits, t_dst_bits, &t_rect, &t_rect, &t_rect, srcCopy, NULL);
			}
		}
		else if (drawmask != NULL)
		{
			PixMapHandle t_mask_pixmap;
			t_mask_pixmap = GetGWorldPixMap((CGrafPtr)drawmask -> handle . pixmap);
			
			EraseRect(&t_rect);
			
			const BitMap *t_dst_bits;
			t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld);
			
			const BitMap *t_src_bits;
			LockPixels(t_draw_pixmap);
			t_src_bits = (BitMap *)*t_draw_pixmap;
			
			const BitMap *t_mask_bits;
			LockPixels(t_mask_pixmap);
			t_mask_bits = (BitMap *)*t_mask_pixmap;
			
			CopyMask(t_src_bits, t_mask_bits, t_dst_bits, &t_rect, &t_rect, &t_rect);
			
			UnlockPixels(t_mask_pixmap);
			
			UnlockPixels(t_draw_pixmap);
		}
		else
		{
			const BitMap *t_dst_bits;
			t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld);
			
			const BitMap *t_src_bits;
			LockPixels(t_draw_pixmap);
			t_src_bits = (BitMap *)*t_draw_pixmap;
			CopyBits(t_src_bits, t_dst_bits, &t_rect, &t_rect, srcCopy, NULL);
			UnlockPixels(t_draw_pixmap);
		}
	}
	
	PicHandle t_handle;
	t_handle = NULL;
	if (t_success)
	{
		OpenCPicParams t_params;
		t_params . srcRect = t_rect;
		t_params . hRes = 72 << 16;
		t_params . vRes = 72 << 16;
		t_params . version = -2;
		t_params . reserved1 = 0;
		t_params . reserved2 = 0;
		t_handle = OpenCPicture(&t_params);
		if (t_handle == NULL)
			t_success = false;
	}

	if (t_success)
	{
		GWorldPtr t_pict_gworld;
		GDHandle t_pict_gdevice;
		GetGWorld(&t_pict_gworld, &t_pict_gdevice);
		
		PenMode(srcCopy);
		ForeColor(blackColor);
		BackColor(whiteColor);
		
		const BitMap *t_dst_bits;
		t_dst_bits = GetPortBitMapForCopyBits(t_pict_gworld);

		const BitMap *t_src_bits;
		t_src_bits = GetPortBitMapForCopyBits(t_img_gworld);
		CopyBits(t_src_bits, t_dst_bits, &t_rect, &t_rect, srcCopy, NULL);
		
		ClosePicture();
	}
	
	if (t_img_gworld != NULL)
		DisposeGWorld(t_img_gworld);
	
	SetGWorld(t_old_gworld, t_old_gdevice);

	MCscreen->freepixmap(drawdata);
	MCscreen->freepixmap(drawmask);
	if (maskimagealpha != nil)
		MCscreen->destroyimage(maskimagealpha);
	
	if (t_success)
		r_pict = (MCMacSysPictHandle)t_handle;
	
	return t_success;
#else
	return false;
#endif
}
예제 #17
0
파일: qplot.c 프로젝트: WndSks/msys
int
main(int argc, char **argv)
{
    char           *file = NULL;
    int             Do_Start = 1, tmp;
    int             m, p, i, j, n, nchars, theight, twidth, xclick, yclick;
    int             downx = 1000, downy = 1000, upx, upy;
    long            id, winclick;
    Real            xmax, xmin, ymax, ymin, xdiff, ydiff, xgrid_spacing,
		    ygrid_spacing;
    Real           *x, *y, *nls;
    LineFunction    linetype = StartLine;
    char            axis[100], line[256];
    FILE           *fd;

    x = (Real *)malloc(1000000 * sizeof(Real));
    y = (Real *)malloc(1000000 * sizeof(Real));
    nls = (Real *)malloc(1000 * sizeof(Real));
    if (x == NULL || y == NULL || nls == NULL) {
	fprintf(stderr, "Can't allocate initial memory\n");
	exit(1);
    }

    ymax = xmax = -HUGE_VAL;
    ymin = xmin = HUGE_VAL;

    for (i = 1; i < argc; i++) {
	if (*argv[i] == '-') {
	    if (!strcmp(argv[i], "-nl"))
		linetype = StartPoint;
	    else if (argv[i][1] == '\0')	/* use stdin */
		file = argv[i];
	    else {

		fprintf(stderr, "Usage:\n\t %s [options] [file]\n\n", argv[0]);
		fprintf(stderr,
			"where options include:\n"
			"  -pt                   plot with points instead of lines\n\n");

		fprintf(stderr,
			"file name `-' specifies stdin\n"
			"if no file name is specified, "
			"the default is \"%s\"\n\n", DEFAULT_DATA_FILE);

		return EXIT_FAILURE;
	    }
	} else
	    file = argv[i];
    }

    if (file && !strcmp(file, "-")) {
	fd = stdin;
	file = "stdin";
    } else {
	if (file == NULL)
	    file = DEFAULT_DATA_FILE;

	if ((fd = fopen(file, "r")) == NULL) {
	    fprintf(stderr, "%s: can't open file \"%s\"\n", argv[0], file);
	    return EXIT_FAILURE;
	}
    }
    m = 0;
    p = 0;
    while (fgets(line, sizeof(line), fd) != NULL) {
	if (sscanf(line, "%f %f", &x[m], &y[m]) == 2) {
	    if (x[m] > xmax)
		xmax = x[m];
	    else if (x[m] < xmin)
		xmin = x[m];
	    if (y[m] > ymax)
		ymax = y[m];
	    else if (y[m] < ymin)
		ymin = y[m];
	    m++;
	} else {
	    nls[p] = m;
	    p++;
	}
    }
    nls[p++] = m;

    if (m == 0)
	return;

    signal(SIGTERM, nice_end);
    signal(SIGSTOP, nice_end);
    signal(SIGTSTP, nice_end);
    signal(SIGINT, nice_end);
    signal(SIGQUIT, nice_end);
    if (!InitializeGraphics(1))
	return EXIT_FAILURE;

    n = 1;
    do {
	axis_round(&xmin, &xmax, &xgrid_spacing);
	axis_round(&ymin, &ymax, &ygrid_spacing);

	id = CreateWin(0, 0, GRX_SCALE, GRX_SCALE);
	if (id == 0) {
	    fprintf(stderr, "Help id = 0\n");
	    return EXIT_FAILURE;
	}
	/* Fill the window in black for real eye-catching graphics! */
	ForeColor(0);
	StartFill(id);
	FillArea(0, 0, GRX_SCALE, GRX_SCALE);
	Done();

	/* draw outline box in white */
	ForeColor(7);

	/* Draw outline box */
	StartLine(id);
	Extend(1000, 1000);
	Extend(1000, 9000);
	Extend(9000, 9000);
	Extend(9000, 1000);
	Extend(1000, 1000);
	Done();

	/* Draw the data - either lines or dots */
	xdiff = 8000 / (xmax - xmin);
	ydiff = 8000 / (ymax - ymin);

	for (i = j = 0; j < p; j++) {
	    int             n = 0;

	    ForeColor(j % 6 + 1);
	    while (((x[i] < xmin) || (x[i] > xmax) ||
		    (y[i] < ymin) || (y[i] > ymax)) && (i < nls[j]))
		i++;

	    while (i < nls[j]) {
		if (n == 0)
		    linetype(id);
		Extend(1000 + (x[i] - xmin) * xdiff,
		       9000 - (y[i] - ymin) * ydiff);
		n++;
		if (n > 450) {
		    Done();
		    n = 0;
		    continue;
		}
		i++;
		while ((i < nls[j]) &&
		       ((x[i] < xmin) || (x[i] > xmax) ||
			(y[i] < ymin) || (y[i] > ymax)))
		    i++;
	    }
	    if (n > 0)
		Done();
	}

	/* Do axis labels in black */
	ForeColor(7);
	QueryWin(id, &twidth, &theight);
	PlaceText(id, GRX_SCALE / 2, 0, HCENTER_TEXT | TOP_TEXT, file);
	PlaceText(id, GRX_SCALE / 2, GRX_SCALE, HCENTER_TEXT | BOTTOM_TEXT,
		  "X");
	PlaceText(id, 0, GRX_SCALE / 2, LEFT_TEXT | VCENTER_TEXT, "Y");
	sprintf(axis, "%f", ymax);
	nchars = 1000 / twidth;
	axis[nchars] = 0;
	PlaceText(id, GRX_SCALE / 10, GRX_SCALE / 10,
		  RIGHT_TEXT | TOP_TEXT, axis);
	sprintf(axis, "%f", ymin);
	axis[nchars] = 0;
	PlaceText(id, GRX_SCALE / 10, 9 * GRX_SCALE / 10,
		  RIGHT_TEXT | BOTTOM_TEXT, axis);
	sprintf(axis, "%f", xmax);
	PlaceText(id, 9 * GRX_SCALE / 10, 9 * GRX_SCALE / 10,
		  HCENTER_TEXT | TOP_TEXT, axis);
	sprintf(axis, "%f", xmin);
	PlaceText(id, GRX_SCALE / 10, 9 * GRX_SCALE / 10,
		  HCENTER_TEXT | TOP_TEXT, axis);
	fflush(stdout);

	do {
	    n = WaitForCarriageReturn(&winclick, &xclick, &yclick);
	    switch (n) {
	    case 1:
		downx = xclick;
		downy = yclick;
		break;
	    case 2:
		upx = xclick;
		upy = yclick;
		if (upx < downx) {
		    tmp = downx;
		    downx = upx;
		    upx = tmp;
		}
		if (upy < downy) {
		    tmp = downy;
		    downy = upy;
		    upy = tmp;
		}
		xmin = (xmax - xmin) * (downx - 1000) / (8000) + xmin;
		xmax = (xmax - xmin) * (upx - 1000) / (8000) + xmin;
		ymax = ymax - (ymax - ymin) * (downy - 1000) / (8000);
		ymin = ymax - (ymax - ymin) * (upy - 1000) / (8000);
		break;
	    }
	} while (n && (n != 2));
    } while (n);
    nice_end(EXIT_SUCCESS);
    return EXIT_SUCCESS;
}
예제 #18
0
void display_party(short mode,short clear_first)
//short mode; // 0 - 5 this pc, 6 - all
//short clear_first; // 1 - redraw over what's already there, 0 - don't redraw over
{
	short i,k,string_num, cur_rect=0;
	Str255 to_draw, skill_value;	
	Rect from_base = {0,0,36,28},from_rect,no_party_rect,temp_rect;
	
	// lots of stuff is global. Like ...
	// bool file_in_mem
	// short current_active_pc
	if (clear_first == 1) { // first erase what's already there
		for (i = 0; i < 6; i++)
			tileImage(pc_area_buttons[i][0],bg_gworld,bg[12]);
		tileImage(name_rect,bg_gworld,bg[12]);
		tileImage(pc_race_rect,bg_gworld,bg[12]);
		tileImage(info_area_rect,bg_gworld,bg[12]);
		frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // re-draw the frame
	}
	
	if (file_in_mem == false) { // what if no party loaded?
		no_party_rect=pc_info_rect;
		no_party_rect.top+=5;
		no_party_rect.left+=5;
		char_win_draw_string(mainPtr,no_party_rect,"No party loaded.",0,10);
	}
	else {
		from_rect = pc_info_rect;
		from_rect.top = from_rect.bottom - 14;
		if (party_in_scen == false)
			char_win_draw_string(mainPtr,from_rect,"Party not in a scenario.",0,10);
		else
			char_win_draw_string(mainPtr,from_rect,"Party is in a scenario.",0,10);
		for (i = 0; i < 6; i++) {
			if (i == current_active_pc) // active pc is drawn in blue
				ForeColor(blueColor);
			else ForeColor(blackColor);
			
			from_rect = (current_pressed_button == i) ? ed_buttons_from[1] : ed_buttons_from[0];
			
			if ((current_pressed_button < 0) || (current_pressed_button == i))
				rect_draw_some_item(buttons_gworld,from_rect,pc_area_buttons[i][0],(Point){0,0});
			ForeColor(blackColor);
			
			// pc_record_type is the records that contains chaarcters
			// main_status determins 0 - not exist, 1 - alive, OK, 2 - dead, 3 - stoned, 4 - dust
			if (univ.party[i].main_status != 0) { // PC exists?
				from_rect = from_base;
				// draw PC graphic
				OffsetRect(&from_rect,56 * (univ.party[i].which_graphic / 8),36 * (univ.party[i].which_graphic % 8));
				rect_draw_some_item(pc_gworld,from_rect,pc_area_buttons[i][1],(Point){0,0},transparent);
				
				//frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][1],0); 
				// draw name
				TextSize(9);
				if( (univ.party[i].name.length()) >= 10) {
					TextFace(0);
					sprintf((char *) to_draw, "%-s  ", (char *) univ.party[i].name.c_str());	
					TextSize(6);
				}
				else {
					sprintf((char *) to_draw, "%-s ", (char *) univ.party[i].name.c_str());	
				}
				
				ForeColor(whiteColor);
				win_draw_string(GetWindowPort(mainPtr),pc_area_buttons[i][2],to_draw,1,10);
				TextFace(bold);
				TextSize(10);
				
				if (i == current_active_pc){
					sprintf((char *) to_draw, "%-.18s  ", (char *) univ.party[i].name.c_str());
					if( (univ.party[i].name.length()) > 12)
						TextSize(8);
					ForeColor(blackColor);
					win_draw_string(GetWindowPort(mainPtr),name_rect,to_draw,1,10);
					TextSize(10);
				}
				if ((current_pressed_button < 0) || (current_pressed_button == i))
					switch (univ.party[i].main_status) {
							// draw statistics
						case 1:
							if (i == current_active_pc) {
								//Draw in race
								if (univ.party[i].race == 0)
									char_win_draw_string(mainPtr,pc_race_rect,"Human   ",1,10);
								if (univ.party[i].race == 1)
									char_win_draw_string(mainPtr,pc_race_rect,"Nephilim   ",1,10);
								if (univ.party[i].race == 2)
									char_win_draw_string(mainPtr,pc_race_rect,"Slithzerikai  ",1,10);
								// Draw in skills	
								
								sprintf((char *) to_draw, "Skills:");
								win_draw_string(GetWindowPort(mainPtr),skill_rect,to_draw,0,10);
								sprintf((char *) to_draw, "Hp: %d/%d  Sp: %d/%d",univ.party[i].cur_health,univ.party[i].max_health,univ.party[i].cur_sp,
										univ.party[i].max_sp);
								win_draw_string(GetWindowPort(mainPtr),hp_sp_rect,to_draw,0,10);
								
								
								TextSize(9);
								TextFace(0);
								string_num=1;
								for( k = 0; k < 19 ; ++k)
								{
									temp_rect = pc_skills_rect[k];
									temp_rect.left = pc_skills_rect[k].left + 80;
									
									get_str(to_draw,9,string_num);
									win_draw_string(GetWindowPort(mainPtr),pc_skills_rect[k],to_draw,0,9);
									
									sprintf((char *) skill_value,"%d",univ.party[i].skills[k]);
									win_draw_string(GetWindowPort(mainPtr),temp_rect,skill_value,0,9);	
									//frame_dlog_rect(GetWindowPort(mainPtr),pc_skills_rect[k],0);
									string_num+=2;
								}
								//end skills
								
								//Write in pc Status
								TextSize(10);
								TextFace(bold);	
								sprintf((char *) to_draw, "Status:");
								win_draw_string(GetWindowPort(mainPtr),status_rect,to_draw,0,10);
								
								TextSize(9);
								TextFace(0);
								//for(k = 0 ; k < 10; k++)
								//frame_dlog_rect(GetWindowPort(mainPtr),pc_status_rect[k],0);
								if (univ.party[i].status[0] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned Weap.",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[1] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Blessed",0,9);
										cur_rect++;
									}
									else if(univ.party[i].status[1] < 0)
										if(cur_rect <= 9) {
											char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Cursed",0,9);
											cur_rect++;
										}
								if (univ.party[i].status[2] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned",0,9);
										cur_rect++;
									}	
								if (univ.party[i].status[3] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Hasted",0,9);
										cur_rect++;
									}
									else if(univ.party[i].status[3] < 0)
										if(cur_rect <= 9) {
											char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Slowed",0,9);
											cur_rect++;
										}
								if (univ.party[i].status[4] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Invulnerable",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[5] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Magic Resistant",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[6] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Webbed",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[7] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Diseased",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[8] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Sanctury",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[9] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Dumbfounded",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[10] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Martyr's Shield",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[11] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Asleep",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[12] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Paralyzed",0,9);
										cur_rect++;
									}
								if (univ.party[i].status[13] > 0) 
									if(cur_rect <= 9) {
										char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Acid",0,9);
										cur_rect++;
									}
								//end pc status section
								
								//Write in Traits
								TextSize(10);
								TextFace(bold);	
								sprintf((char *) to_draw, "Traits:");
								win_draw_string(GetWindowPort(mainPtr),traits_rect,to_draw,0,10);
								//for(k = 0 ; k < 16; k++)
								//frame_dlog_rect(GetWindowPort(mainPtr),pc_traits_rect[k],0);
								TextSize(9);
								TextFace(0);	
								cur_rect=0;
								if (univ.party[i].traits[0] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Toughness",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[1] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Apt",0,9);
										cur_rect++;
									}		
								if (univ.party[i].traits[2] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Ambidextrous",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[3] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Nimble Fingers",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[4] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Cave Lore",0,9);
										cur_rect++;
									}
								
								if (univ.party[i].traits[5] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Woodsman",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[6] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Good Constitution",0,9);
										cur_rect++;
									}		
								if (univ.party[i].traits[7] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Highly Alert",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[8] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Exceptional Str.",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[9] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Recuperation",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[10] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Sluggish",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[11] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Inept",0,9);
										cur_rect++;
									}		
								if (univ.party[i].traits[12] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Frail",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[13] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Chronic Disease",0,9);
										cur_rect++;
									}
								if (univ.party[i].traits[14] == 1) 
									if(cur_rect <= 15) {
										char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Bad Back",0,9);
										cur_rect++;
									}
								
								//end traits
							}
							
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Alive ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							case 2:
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Dead ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							case 3:
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Dust ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							case 4:
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Stone ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							case 5:
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Fled ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							case 6:
							ForeColor(whiteColor);
							TextSize(9);
							TextFace(0); 
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Surface ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
							default:
							ForeColor(whiteColor);
							TextFace(0);
							TextSize(9);
							char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Absent ",1,10);
							TextFace(bold);
							TextSize(10);
							break;
					}
				//frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][0],0); 
				
				
			}
			
		} // Closes the for i=6 loop
		ForeColor(blackColor);			
		
		for(i = 0; i < 5; i++) 
			if ((current_pressed_button < 0) || (current_pressed_button == i + 10)) {	
				if (clear_first == 1) { // first erase what's already there
					tileImage(edit_rect[i][0],bg_gworld,bg[12]);
				}		
				//frame_dlog_rect(GetWindowPort(mainPtr),edit_rect[i][0],0);
				//frame_dlog_rect(GetWindowPort(mainPtr),edit_rect[i][1],0);
				from_rect = (current_pressed_button == i + 10) ? ed_buttons_from[1] : ed_buttons_from[0];
				rect_draw_some_item(buttons_gworld,from_rect,edit_rect[i][0],(Point){0,0});
				ForeColor(whiteColor);			
				switch(i) {
					case 0:
						char_win_draw_string(mainPtr,edit_rect[0][1],"  Add  Mage Spells ",0,10);
						break;
					case 1:
						char_win_draw_string(mainPtr,edit_rect[1][1],"  Add Priest Spells ",0,10);
						break;
					case 2: 
						char_win_draw_string(mainPtr,edit_rect[2][1]," Edit  Traits",0,10);
						break;
					case 3:
						char_win_draw_string(mainPtr,edit_rect[3][1]," Edit  Skills",0,10);
						break;
					case 4:
						char_win_draw_string(mainPtr,edit_rect[4][1]," Edit   XP",0,10);
						break;
					default:
						break;	
				}		
				ForeColor(blackColor);			
				
			}
		//			MoveTo(start_h + 10, start_v + 127);	
		//			sprintf((char *) to_draw, " Gold: %d       Food: %d ",(short) party.gold, (short) party.food);
		//			DrawString(to_draw);
	}
	
	
	ForeColor(blackColor);
}
예제 #19
0
파일: tooltip.cpp 프로젝트: gitrider/wxsj2
void wxMacToolTip::Draw()
{
    if ( m_label.Length() == 0 )
        return ;
    
    if ( m_window == s_ToolTipWindowRef )
    {
        m_shown = true ;
#if TARGET_CARBON
        HMHelpContentRec tag ;
        tag.version = kMacHelpVersion;
        SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ;

        QDLocalToGlobalRect( GetWindowPort( m_window ) , &tag.absHotRect ) ;

        m_helpTextRef.Assign( m_label  , wxFONTENCODING_DEFAULT ) ;
        tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ;
        tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ;
        tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ;
        tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ;
        tag.tagSide = kHMDefaultSide;
        HMDisplayTag( &tag );
#else
        wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) );
        FontFamilyID fontId ;
        Str255 fontName ;
        SInt16 fontSize ;
        Style fontStyle ;
        GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
        GetFNum( fontName, &fontId );
        
        TextFont( fontId ) ;
        TextSize( fontSize ) ;
        TextFace( fontStyle ) ;
        FontInfo fontInfo;
        ::GetFontInfo(&fontInfo);
        short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
        short height = 0 ;
        
        int i = 0 ;
        int length = m_label.Length() ;
        int width = 0 ;
        int thiswidth = 0 ;
        int laststop = 0 ;
        wxCharBuffer text = m_label.mb_str( wxConvLocal)  ;

        while( i < length )
        {
            if( text[i] == 13 || text[i] == 10)
            {
                thiswidth = ::TextWidth( text , laststop , i - laststop ) ;
                if ( thiswidth > width )
                    width = thiswidth ;
                
                height += lineh ;
                laststop = i+1 ;
            }
            i++ ;
        }
        if ( i - laststop > 0 )
        {
            thiswidth = ::TextWidth( text , laststop , i - laststop ) ;
            if ( thiswidth > width )
                width = thiswidth ;
            height += lineh ;
        }
        
        m_rect.left = m_position.x + kTipOffset;
        m_rect.top = m_position.y + kTipOffset;
        m_rect.right = m_rect.left + width + 2 * kTipBorder;

        m_rect.bottom = m_rect.top + height + 2 * kTipBorder;
        Rect r ;
        GetPortBounds( GetWindowPort( m_window ) , &r ) ;
        if ( m_rect.top < 0 )
        {
            m_rect.bottom += -m_rect.top ;
            m_rect.top = 0 ;
        }
        if ( m_rect.left < 0 )
        {
            m_rect.right += -m_rect.left ;
            m_rect.left = 0 ;
        }
        if ( m_rect.right > r.right )
        {
            m_rect.left -= (m_rect.right - r.right ) ;
            m_rect.right = r.right ;
        }
        if ( m_rect.bottom > r.bottom )
        {
            m_rect.top -= (m_rect.bottom - r.bottom) ;
            m_rect.bottom = r.bottom ;
        }
        ClipRect( &m_rect ) ;
        BackColor( whiteColor ) ;
        ForeColor(blackColor ) ;
        GWorldPtr port ;            
        NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ;
        CGrafPtr    origPort ;
        GDHandle    origDevice ;
        
        GetGWorld( &origPort , &origDevice ) ;
        SetGWorld( port , NULL ) ;
        
        m_backpict = OpenPicture(&m_rect);
        
        CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), 
            GetPortBitMapForCopyBits(port), 
            &m_rect, 
            &m_rect, 
            srcCopy, 
            NULL);
        ClosePicture();
        SetGWorld( origPort , origDevice ) ;
        DisposeGWorld( port ) ;
        PenNormal() ;
        
        RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ;
        BackColor( whiteColor ) ;
        RGBForeColor( &tooltipbackground ) ;
        
        PaintRect( &m_rect ) ;
        ForeColor(blackColor ) ;
        FrameRect( &m_rect ) ;
        SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ;
        ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder);
        
        i = 0 ;
        laststop = 0 ;
        height = 0 ;
        
        while( i < length )
        {
            if( text[i] == 13 || text[i] == 10)
            {
                ::DrawText( text , laststop , i - laststop ) ;
                height += lineh ;
                ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height );
                laststop = i+1 ;
            }
            i++ ;
        }
        ::DrawText( text , laststop , i - laststop ) ;
        ::TextMode( srcOr ) ;        
#endif
    }
}
예제 #20
0
void draw_shop_graphics(bool pressed,Rect clip_area_rect)
// mode 1 - drawing dark for button press
{
	Rect area_rect,item_info_from = {11,42,24,56};
	
	Rect face_rect = {6,6,38,38};
	Rect title_rect = {15,48,42,260};
	Rect dest_rect,help_from = {85,36,101,54};
	short faces[13] = {1,1,1,42,43, 1,1,1,1,1, 44,44,44};
	
	short i,what_chosen;
	RGBColor c[7] = {{0,0,0},{0,0,32767},{0,0,14535},{0,0,26623},{0,0,59391},
	{0,40959,0},{0,24575,0}};
	Rect shopper_name = {44,6,56,260};
	short current_pos;
	
	short cur_cost,what_magic_shop,what_magic_shop_item;
	char cur_name[60];
	char cur_info_str[60];
char *cost_strs[] = {"Extremely Cheap","Very Reasonable","Pretty Average","Somewhat Pricey",
	"Expensive","Exorbitant","Utterly Ridiculous"};
	GrafPtr old_port;
	cItemRec base_item;
	
	if (overall_mode != 21) {
		return;
		}
	
	
	GetPort(&old_port);
	SetPort(talk_gworld);
	TextFont(dungeon_font_num);
	TextSize(18);
	TextFace(0);

	if (pressed) {
		ClipRect(&clip_area_rect);	
		}

	GetPortBounds(talk_gworld,&area_rect);
	FrameRect(&area_rect);
	InsetRect(&area_rect,1,1);
	tileImage(area_rect,bg_gworld,bg[12]);

	FrameRect(&shop_frame);
	
	// Place store icon
	if (!pressed) { 
		SetPort(GetWindowPort(mainPtr));
		i = faces[store_shop_type];
		draw_dialog_graphic( talk_gworld, face_rect, i, PICT_TALK, false,1);
		SetPort( talk_gworld);
	}


	// Place name of store and shopper name
	RGBForeColor(&c[3]);
	dest_rect = title_rect;
	OffsetRect(&dest_rect,1,1);
	char_port_draw_string(talk_gworld,dest_rect,store_store_name,2,18);
	OffsetRect(&dest_rect,-1,-1);
	RGBForeColor(&c[4]);
	char_port_draw_string( talk_gworld,dest_rect,store_store_name,2,18);	

	TextFont(geneva_font_num);
	TextSize(12);
	TextFace(bold);

	RGBForeColor(&c[3]);
	switch (store_shop_type) {
		case 3: sprintf(cur_name,"Healing for %s.",univ.party[current_pc].name.c_str()); break;
		case 10: sprintf(cur_name,"Mage Spells for %s.",univ.party[current_pc].name.c_str());break;
		case 11: sprintf(cur_name,"Priest Spells for %s.",univ.party[current_pc].name.c_str()); break;
		case 12: sprintf(cur_name,"Buying Alchemy.");break;
		case 4: sprintf(cur_name,"Buying Food.");break;
		default:sprintf(cur_name,"Shopping for %s.",univ.party[current_pc].name.c_str()); break;
		}
	char_port_draw_string( talk_gworld,shopper_name,cur_name,2,18);	

	// Place help and done buttons
	ForeColor(blackColor);
	GetPortBounds(dlg_buttons_gworld[3][0],&help_from);
	talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
	talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
	rect_draw_some_item(dlg_buttons_gworld[3][pressed],help_from,talk_gworld,talk_help_rect);
	GetPortBounds(dlg_buttons_gworld[11][0],&help_from);
	//talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
	//talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
	rect_draw_some_item(dlg_buttons_gworld[11][pressed],help_from,talk_gworld,shop_done_rect);
	
	if (pressed)
		RGBForeColor(&c[4]);
	else ForeColor(blackColor);
		
	// Place all the items
	for (i = 0; i < 8; i++) {
		current_pos = i + GetControlValue(shop_sbar);
		if (store_shop_items[current_pos] < 0)
			break; // theoretically, this shouldn't happen
		cur_cost = store_shop_costs[current_pos];
		what_chosen = store_shop_items[current_pos];
		switch (what_chosen / 100) {
			case 0: case 1: case 2: case 3: case 4: 
				base_item = get_stored_item(what_chosen);
				base_item.ident = true;
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);
				strcpy(cur_name,base_item.full_name.c_str());
				get_item_interesting_string(base_item,cur_info_str);
				break;
			case 5:
				base_item = store_alchemy(what_chosen - 500);
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],53,PICT_ITEM, false,1);//// all graphic nums
				strcpy(cur_name,base_item.full_name.c_str());
				strcpy(cur_info_str,"");
				break;
			case 6:
				//base_item = food_types[what_chosen - 600];
				//draw_dialog_graphic( talk_gworld, shopping_rects[i][2],633, false,1);
				//strcpy(cur_name,base_item.full_name);
				//get_item_interesting_string(base_item,cur_info_str);
				break;
			case 7:
				what_chosen -= 700;
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],99,PICT_ITEM, false,1);
				strcpy(cur_name,heal_types[what_chosen]);
				strcpy(cur_info_str,"");
				break;
			case 8:
				base_item = store_mage_spells(what_chosen - 800 - 30);
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);

				strcpy(cur_name,base_item.full_name.c_str());
				strcpy(cur_info_str,"");		
				break;
			case 9:
				base_item = store_priest_spells(what_chosen - 900 - 30);
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);
				strcpy(cur_name,base_item.full_name.c_str());
				strcpy(cur_info_str,"");
				break;
			default:
				what_magic_shop = (what_chosen / 1000) - 1;
				what_magic_shop_item = what_chosen % 1000;
				base_item = univ.party.magic_store_items[what_magic_shop][what_magic_shop_item];
				base_item.ident = true;
				draw_dialog_graphic( talk_gworld, shopping_rects[i][2],base_item.graphic_num,PICT_ITEM, false,1);
				strcpy(cur_name,base_item.full_name.c_str());
				get_item_interesting_string(base_item,cur_info_str);
				break;
			}

		// Now draw item shopping_rects[i][7]
		// 0 - whole area, 1 - active area 2 - graphic 3 - item name
		// 4 - item cost 5 - item extra str  6 - item help button
		TextSize(12);
		char_port_draw_string( talk_gworld,shopping_rects[i][3],cur_name,0,12);
		sprintf(cur_name,"Cost: %d",cur_cost);
		char_port_draw_string( talk_gworld,shopping_rects[i][4],cur_name,0,12);
		TextSize(10);
		char_port_draw_string( talk_gworld,shopping_rects[i][5],cur_info_str,0,12);
		if ((store_shop_type != 3) && (store_shop_type != 4))
			rect_draw_some_item(invenbtn_gworld,item_info_from,talk_gworld,shopping_rects[i][6],pressed ? srcCopy : transparent);

		}

	// Finally, cost info and help strs
	TextSize(12);
	sprintf(cur_name,"Prices here are %s.",cost_strs[store_cost_mult]);
	TextSize(10);
	char_port_draw_string( talk_gworld,bottom_help_rects[0],cur_name,0,12);
	char_port_draw_string( talk_gworld,bottom_help_rects[1],"Click on item name (or type 'a'-'h') to buy.",0,12);
	char_port_draw_string( talk_gworld,bottom_help_rects[2],"Hit done button (or Esc.) to quit.",0,12);
	if ((store_shop_type != 3) && (store_shop_type != 4))
		char_port_draw_string( talk_gworld,bottom_help_rects[3],"'I' button brings up description.",0,12);
	
	
	ForeColor(blackColor);
	GetPortBounds(talk_gworld,&area_rect);
	ClipRect(&area_rect);
	SetPort(old_port);

	refresh_shopping();
	ShowControl(shop_sbar);
	Draw1Control(shop_sbar);
}
예제 #21
0
void do_explosion_anim(short sound_num,short special_draw)
// sound_num currently ignored
// special_draw - 0 normal 1 - first half 2 - second half
{
	Rect temp_rect,active_area_rect,to_rect,from_rect;
	Rect base_rect = {0,0,36,28},text_rect;
	char str[60];
	short i,temp_val,temp_val2;
	location screen_ul;
	
	short t,cur_boom_type = 0; 
	Point current_terrain_ul; 
	GWorldPtr temp_gworld;
	GrafPtr old_port;
	short boom_type_sound[3] = {5,10,53};
	
	if ((have_boom == false) || (boom_anim_active == false)) {
		boom_anim_active = false;
		return;
		}
	
	for (i = 0; i < 30; i++)
		if (store_booms[i].boom_type >= 0)
			i = 50;
	if (i == 30)
		return;

	// initialize general data
	if (in_startup_mode) {
		current_terrain_ul.h = 306;
		current_terrain_ul.v = 5;
	} else current_terrain_ul.h = current_terrain_ul.v = 5;
	
	// make terrain_template contain current terrain all nicely
	draw_terrain(1);
	if (special_draw != 2) {
		GetPortBounds(terrain_screen_gworld,&to_rect);
		Rect oldRect = to_rect;
		OffsetRect(&to_rect,current_terrain_ul.h, current_terrain_ul.v);
		rect_draw_some_item(terrain_screen_gworld,oldRect,to_rect,ul);
		}
		
	GetPort(&old_port);	
				
	// create and clip temporary anim template 
	GetPortBounds(terrain_screen_gworld,&temp_rect);
	NewGWorld(&temp_gworld,  0 /*8*/,&temp_rect, NULL, NULL, kNativeEndianPixMap);
	SetPort(temp_gworld);
	TextFont(geneva_font_num);
	TextFace(bold);
	TextSize(10);
	active_area_rect = temp_rect;
	InsetRect(&active_area_rect,13,13);
	ClipRect(&active_area_rect);
	SetPort(GetWindowPort(mainPtr));
	
	// init missile paths
	screen_ul.x = center.x - 4; screen_ul.y = center.y - 4;
	for (i = 0; i < 30; i++) 
		if ((store_booms[i].boom_type >= 0)  && (special_draw < 2)) {
			cur_boom_type = store_booms[i].boom_type;
			explode_place_rect[i] = base_rect;
			OffsetRect(&explode_place_rect[i],13 + 28 * (store_booms[i].dest.x - screen_ul.x) + store_booms[i].x_adj,
				13 + 36 * (store_booms[i].dest.y - screen_ul.y) + store_booms[i].y_adj);
				
			if ((store_booms[i].place_type == 1) && (special_draw < 2)) {
				temp_val = get_ran(1,0,50) - 25;
				temp_val2 = get_ran(1,0,50) - 25;
				OffsetRect(&explode_place_rect[i],temp_val,temp_val2);
				}
			
			// eliminate stuff that's too gone. 
			Rect tempRect2;
			GetPortBounds(terrain_screen_gworld,&tempRect2);
			SectRect(&explode_place_rect[i],&tempRect2,&temp_rect);
			if (EqualRect(&temp_rect,&explode_place_rect[i]) == false) {
				store_booms[i].boom_type = -1;
				}
			
			}
			else if (special_draw < 2)
				explode_place_rect[i].top =explode_place_rect[i].left =explode_place_rect[i].bottom =explode_place_rect[i].right = 0;
	
	//play_sound(-1 * sound_num);
	if (special_draw < 2)
		play_sound(-1 * boom_type_sound[cur_boom_type]);
	
	// Now, at last, do explosion
	for (t = (special_draw == 2) ? 6 : 0; t < ((special_draw == 1) ? 6 : 11); t++) { // t goes up to 10 to make sure screen gets cleaned up
		// First, lay terrain in temporary graphic area;
		for (i = 0; i < 30; i++) 
			if (store_booms[i].boom_type >= 0) 
				rect_draw_some_item(terrain_screen_gworld,explode_place_rect[i],
					temp_gworld,explode_place_rect[i]);

		// Now put in explosions
		for (i = 0; i < 30; i++) 
			if (store_booms[i].boom_type >= 0) {
				if ((t + store_booms[i].offset >= 0) && (t + store_booms[i].offset <= 7)) {
						from_rect = base_rect;
						OffsetRect(&from_rect,28 * (t + store_booms[i].offset),36 * (1 + store_booms[i].boom_type));
						rect_draw_some_item(boom_gworld,from_rect,
							temp_gworld,explode_place_rect[i],transparent);
					
					if (store_booms[i].val_to_place > 0) {
						text_rect = explode_place_rect[i];
						text_rect.top += 4;
						text_rect.left -= 10;
						if (store_booms[i].val_to_place < 10)
							text_rect.left += 8;
						sprintf(str,"%d",store_booms[i].val_to_place);
						SetPort(temp_gworld);
						ForeColor(whiteColor);
						char_port_draw_string(temp_gworld,text_rect,str,1,12);
						ForeColor(blackColor);
						SetPort(GetWindowPort(mainPtr));
						}
					}
				}
		// Now draw all missiles to screen
		for (i = 0; i < 30; i++) 
			if (store_booms[i].boom_type >= 0) {
				to_rect = explode_place_rect[i];
				OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v);
				rect_draw_some_item(temp_gworld,explode_place_rect[i],to_rect,ul);
				}
		//if (((PSD[SDF_GAME_SPEED] == 1) && (t % 3 == 0)) || ((PSD[SDF_GAME_SPEED] == 2) && (t % 2 == 0)))
			FlushAndPause(2 * (1 + PSD[SDF_GAME_SPEED]));
		}
		
	// Exit gracefully, and clean up screen
	for (i = 0; i < 30; i++) 
		if (special_draw != 1)
			store_booms[i].boom_type = -1;
	DisposeGWorld(temp_gworld);
	SetPort(old_port);

	//to_rect = terrain_screen_gworld->portRect;
	//OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v);
	//rect_draw_some_item(terrain_screen_gworld,terrain_screen_gworld->portRect,
	//	terrain_screen_gworld,to_rect,0,1);
}
예제 #22
0
void place_talk_str(char *str_to_place,char *str_to_place2,short color,Rect c_rect)
// color 0 - regular  1 - darker
{
	Rect area_rect;
	
	Rect face_rect = {6,6,38,38};
	Rect title_rect = {19,48,42,260};
	Rect dest_rect,help_from = {85,36,101,54};
	Str255 fn2 = "\pDungeon Bold";
	Str255 fn3 = "\pPalatino";

	short i,j,str_len,line_height = 17;
	Str255 p_str,str,str_to_draw,str_to_draw2;
	short text_len[257],current_rect,store_last_word_break = 0,start_of_last_kept_word = -1;
	short last_line_break = 0,last_word_break = 0,on_what_line = 0,last_stored_word_break = 0;
	bool force_skip = false;
	short face_to_draw;
	
	RGBColor c[7] = {{0,0,0},{0,0,32767},{0,0,14535},{0,0,26623},{0,0,59391},
	{0,40959,0},{0,24575,0}};
	
	GrafPtr old_port;
	
	GetPort(&old_port);
	SetPort( talk_gworld);

	// This redundancy is to try to keep the font from disappearing
	GetFNum(fn2,&dungeon_font_num);
	if (dungeon_font_num == 0)
		GetFNum(fn3,&dungeon_font_num);
		
	TextFont(dungeon_font_num);
	//TextFont(geneva_font_num);
	TextSize(18);
	TextFace(0);

	if (c_rect.right > 0) {
		ClipRect(&c_rect);	
		}

	GetPortBounds(talk_gworld,&area_rect);
	FrameRect(&area_rect);
	InsetRect(&area_rect,1,1);
	tileImage(area_rect,bg_gworld,bg[12]);

	// Put help button
	GetPortBounds(dlg_buttons_gworld[3][0], &help_from);
	talk_help_rect.right = talk_help_rect.left + help_from.right - help_from.left;
	talk_help_rect.bottom = talk_help_rect.top + help_from.bottom - help_from.top;
	rect_draw_some_item(dlg_buttons_gworld[3][0],help_from,talk_gworld,talk_help_rect);
	
	// Place face of talkee
	if ((color == 0) && (c_rect.right == 0)) { 
		////
		SetPort(GetWindowPort(mainPtr));
		face_to_draw = scenario.scen_monsters[store_monst_type].default_facial_pic;
		if (store_talk_face_pic >= 0)
			face_to_draw = store_talk_face_pic;
		if (store_talk_face_pic >= 1000) {
			draw_dialog_graphic(  talk_gworld, face_rect, store_talk_face_pic, PICT_CUSTOM + PICT_TALK, false,1);
			}
			else {
				i = get_monst_picnum(store_monst_type);
				if (face_to_draw <= 0)
					draw_dialog_graphic(talk_gworld, face_rect, i, get_monst_pictype(store_monst_type), false,1);
				else draw_dialog_graphic(talk_gworld, face_rect, face_to_draw, PICT_MONST, false,1);
			}
		SetPort( talk_gworld);
		}
	// Place name oftalkee
	RGBForeColor(&c[3]);
	dest_rect = title_rect;
	OffsetRect(&dest_rect,1,1);
	char_port_draw_string( talk_gworld,dest_rect,title_string,2,18);
	OffsetRect(&dest_rect,-1,-1);
	RGBForeColor(&c[4]);
	char_port_draw_string( talk_gworld,dest_rect,title_string,2,18);
		
	// Place buttons at bottom.
	if (color == 0)
		RGBForeColor(&c[5]);
		else RGBForeColor(&c[6]);
	for (i = 0; i < 9; i++) 
		if ((talk_end_forced == false) || (i == 6) || (i == 5)) {
			OffsetRect(&preset_words[i].word_rect,0,8);
			char_port_draw_string( talk_gworld,preset_words[i].word_rect,preset_words[i].word,2,18);
			OffsetRect(&preset_words[i].word_rect,0,-8);
			}
	// Place bulk of what said. Save words.
	//TextSize(14);
	if (color == 0)
		for (i = 0; i < 50; i++)
			store_words[i].word_rect.left = store_words[i].word_rect.right = 0;
			
	str_len = (short) strlen((char *)str_to_place);
	if (str_len == 0) {
		sprintf((char *) str_to_place,".");
		}	
	strcpy((char *) str,str_to_place);
	strcpy((char *) p_str,str_to_place);
	c2pstr((char*)p_str);	
	for (i = 0; i < 257; i++)
		text_len[i]= 0;
	MeasureText(256,p_str,text_len);

	dest_rect = word_place_rect;

	current_rect = 0;
	
	if (color == 0)
		RGBForeColor(&c[2]);
		else RGBForeColor(&c[1]);
	MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
	//for (i = 0;text_len[i] != text_len[i + 1], i < str_len;i++) {
	for (i = 0;i < str_len;i++) {
		if (((str[i] != 39) && ((str[i] < 65) || (str[i] > 122)) && ((str[i] < 48) || (str[i] > 57))) && (color == 0)) { // New word, so set up a rect
			if (((i - store_last_word_break >= 4) || (i >= str_len - 1)) 
			 && (i - last_stored_word_break >= 4) && (talk_end_forced == false)) {
				store_words[current_rect].word_rect.left = dest_rect.left + (text_len[store_last_word_break] - text_len[last_line_break]) - 2;
				store_words[current_rect].word_rect.right = dest_rect.left + (text_len[i + 1] - text_len[last_line_break]) - 1;
				store_words[current_rect].word_rect.top = dest_rect.top + 1 + line_height * on_what_line - 5;
				store_words[current_rect].word_rect.bottom = dest_rect.top + 1 + line_height * on_what_line + 13;
				
				if ((str[store_last_word_break] < 48) || (str[store_last_word_break] == 96) 
					|| (str[store_last_word_break] > 122)
					|| ((str[store_last_word_break] >= 58) && (str[store_last_word_break] <= 64)))
						store_last_word_break++;

				// adjust for if this word will be scrolled down
				//if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  		//	&& (last_word_break > last_line_break)) || (str[i] == '|')) {
		  		//	OffsetRect(&store_words[current_rect].word_rect,5 + -1 * store_words[current_rect].word_rect.left,line_height);
		  		//	}
				
				store_words[current_rect].word[0] = str[store_last_word_break];
				store_words[current_rect].word[1] = str[store_last_word_break + 1];
				store_words[current_rect].word[2] = str[store_last_word_break + 2];
				store_words[current_rect].word[3] = str[store_last_word_break + 3];
				store_words[current_rect].word[4] = 0;
				for (j = 0; j < 4; j++)
					if ((store_words[current_rect].word[j] >= 65) && (store_words[current_rect].word[j] <= 90))
						store_words[current_rect].word[j] += 32;
				if (scan_for_response(store_words[current_rect].word) < 0) {
					store_words[current_rect].word_rect.left = store_words[current_rect].word_rect.right = 0;
					}
					else {
						start_of_last_kept_word = store_last_word_break;
						if (current_rect < 49)
							current_rect++;
					
						//FrameRect(&store_words[current_rect].word_rect);
						}
				last_stored_word_break = i + 1;
				}
			}
		if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  && (last_word_break > last_line_break)) || (str[i] == '|') || (i == str_len - 1)) {
			if (str[i] == '|') {
				str[i] = ' ';
		 		force_skip = true;
	 			}
	 		store_last_word_break = last_word_break;
	 		if (i == str_len - 1)
	 			last_word_break = i + 2;
			sprintf((char *)str_to_draw,"                                                         ");
			strncpy ((char *) str_to_draw,(char *) str + last_line_break,(size_t) (last_word_break - last_line_break - 1));
			sprintf((char *)str_to_draw2," %s",str_to_draw);
			str_to_draw2[0] = (char) strlen((char *)str_to_draw);
			DrawString(str_to_draw2);
			on_what_line++;
			MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
			last_line_break = last_word_break;
			if (force_skip == true) {
				force_skip = false;
				i++;
				last_line_break++;
				last_word_break++;
				}
			if ((start_of_last_kept_word >= last_line_break) && (current_rect > 0)) {
				//SysBeep(2);
	 			OffsetRect(&store_words[current_rect - 1].word_rect,5 + -1 * store_words[current_rect - 1].word_rect.left,line_height);				
				}
		}
		if (str[i] == ' ') { // New word
			store_last_word_break = last_word_break = i + 1;
			}
		if (on_what_line == 17)
			i = 10000;
		}
		
	// Now for string 2
	str_len = (short) strlen((char *)str_to_place2);
	start_of_last_kept_word = -1;
	
	if (str_len > 0) {
		
	strcpy((char *) str,str_to_place2);
	strcpy((char *) p_str,str_to_place2);
	c2pstr((char*)p_str);	
	for (i = 0; i < 257; i++)
		text_len[i]= 0;
	MeasureText(256,p_str,text_len);
	
	last_line_break = store_last_word_break = last_word_break = last_stored_word_break = 0;
	MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
	//for (i = 0;text_len[i] != text_len[i + 1], i < str_len;i++) 
	for (i = 0;i < str_len;i++) {
		if (((str[i] != 39) && ((str[i] < 65) || (str[i] > 122)) && ((str[i] < 48) || (str[i] > 57))) && (color == 0))  { // New word, so set up a rect
			if (((i - store_last_word_break >= 4) || (i >= str_len - 1)) 
			 && (i - last_stored_word_break >= 4) && (talk_end_forced == false)) {
				store_words[current_rect].word_rect.left = dest_rect.left + (text_len[store_last_word_break] - text_len[last_line_break]) - 2;
				store_words[current_rect].word_rect.right = dest_rect.left + (text_len[i + 1] - text_len[last_line_break]) - 1;
				store_words[current_rect].word_rect.top = dest_rect.top + 1 + line_height * on_what_line - 5;
				store_words[current_rect].word_rect.bottom = dest_rect.top + 1 + line_height * on_what_line + 13;
				
				if ((str[store_last_word_break] < 48) || (str[store_last_word_break] == 96) 
					|| (str[store_last_word_break] > 122)
					|| ((str[store_last_word_break] >= 58) && (str[store_last_word_break] <= 64)))
						store_last_word_break++;

				// adjust for if this word will be scrolled down
				//if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  		//	&& (last_word_break > last_line_break)) || (str[i] == '|')) {
		  		//	OffsetRect(&store_words[current_rect].word_rect,5 + -1 * store_words[current_rect].word_rect.left,line_height);
		  		//	}
				store_words[current_rect].word[0] = str[store_last_word_break];
				store_words[current_rect].word[1] = str[store_last_word_break + 1];
				store_words[current_rect].word[2] = str[store_last_word_break + 2];
				store_words[current_rect].word[3] = str[store_last_word_break + 3];
				store_words[current_rect].word[4] = 0;
				for (j = 0; j < 4; j++)
					if ((store_words[current_rect].word[j] >= 65) && (store_words[current_rect].word[j] <= 90))
						store_words[current_rect].word[j] += 32;
				if (scan_for_response(store_words[current_rect].word) < 0)
					store_words[current_rect].word_rect.left = store_words[current_rect].word_rect.right = 0;
					else {
						start_of_last_kept_word = store_last_word_break;
						if (current_rect < 49)
							current_rect++;
					
						//FrameRect(&store_words[current_rect].word_rect);
						}
				last_stored_word_break = i + 1;
				}
			}
		if (((text_len[i] - text_len[last_line_break] > (dest_rect.right - dest_rect.left - 6)) 
		  && (last_word_break > last_line_break)) || (str[i] == '|') || (i == str_len - 1)) {
			if (str[i] == '|') {
				str[i] = ' ';
		 		force_skip = true;
	 			}
	 		store_last_word_break = last_word_break;
	 		if (i == str_len - 1)
	 			last_word_break = i + 2;
			sprintf((char *)str_to_draw,"                                                         ");
			strncpy ((char *) str_to_draw,(char *) str + last_line_break,(size_t) (last_word_break - last_line_break - 1));
			sprintf((char *)str_to_draw2," %s",str_to_draw);
			str_to_draw2[0] = (char) strlen((char *)str_to_draw);
			DrawString(str_to_draw2);
			on_what_line++;
			MoveTo(dest_rect.left + 1 , dest_rect.top + 1 + line_height * on_what_line + 9);
			last_line_break = last_word_break;
			if (force_skip == true) {
				force_skip = false;
				i++;
				last_line_break++;
				last_word_break++;
				}
			if ((start_of_last_kept_word >= last_line_break) && (current_rect > 0)) {
	 			OffsetRect(&store_words[current_rect - 1].word_rect,5 + -1 * store_words[current_rect - 1].word_rect.left,line_height);				
				}
		}
		if (str[i] == ' ') { // New word
			store_last_word_break = last_word_break = i + 1;
			}
		if (on_what_line == 17)
			i = 10000;
		}
	}
	
	ForeColor(blackColor);
	GetPortBounds(talk_gworld,&area_rect);
	Rect oldRect = area_rect;
	ClipRect(&area_rect);
	
	// Finally place processed graphics
	SetPort(GetWindowPort(mainPtr));
	rect_draw_some_item(talk_gworld,oldRect,talk_area_rect,ul);
	SetPort(old_port);
	
	// Clean up strings
	for (i = 0; i < 50; i++)
		for (j = 0; j < 4; j++)
			if ((store_words[current_rect].word[j] >= 65) && (store_words[current_rect].word[j] <= 90))
				store_words[current_rect].word[j] += 32;

}
예제 #23
0
/* convert IPIcon to Picture */
PicHandle IPIconToPicture(const IPIconRec *ipIcon,short iconKind)
{
	ResType	iconType;
	short	iconSize,iconDepth;
	long	offset=0;
	OSErr	err;
	GWorldPtr	iconGWorld;
	PixMapHandle	iconPix;
	Handle	dataHandle;
	Ptr		src,dst;
	PicHandle	picture;
	OpenCPicParams	picParam;
	Rect	iconRect;
	Rect	temp;
	long	rowBytes,iconRowBytes;
	short	i;
	CTabHandle	ctab=nil;
	GWorldPtr	cPort;
	GDHandle	cDevice;
	
	/* invalid icon kind */
	if (iconKind < 0) return nil;
	
	iconType=gIconType[iconKind];
	iconSize=gIconSize[iconKind];
	iconDepth=gIconDepth[iconKind];
	
	SetRect(&iconRect,0,0,iconSize,iconSize);
	temp=iconRect;
	temp.right++;
	
	err=GetDataFromIPIcon(&dataHandle,ipIcon,iconKind);
	
	if (err != noErr || dataHandle == nil) return nil; /* return nil when there are no icons */
	if (GetHandleSize(dataHandle) != iconSize*(long)iconSize*(iconDepth>1 ? iconDepth : 2)/8) return nil;
	
	switch (iconKind)
	{
		case kL1Mask:
			offset=32*32/8;
			break;
		
		case kS1Mask:
			offset=16*16/8;
			break;
		
		case kL8Mask:
		case kS8Mask:
		case kT8Mask:
			ctab=GetGrayscaleCTable(iconDepth,true);
			break;
	}
	
	GetGWorld(&cPort,&cDevice);
	err=NewGWorld(&iconGWorld,iconDepth,&temp,ctab,0,useTempMem);
	if (ctab != NULL) DisposeHandle((Handle)ctab);
	if (err != noErr) return nil;
	
	HLock(dataHandle);
	
	SetGWorld(iconGWorld,0);
	iconPix=GetGWorldPixMap(iconGWorld);
	LockPixels(iconPix);
	rowBytes=MyGetPixRowBytes(iconPix) & 0x3fff;
	EraseRect(&iconRect);
	
	src=*dataHandle+offset;
	dst=MyGetPixBaseAddr(iconPix);
	iconRowBytes=iconSize*iconDepth/8;
	for (i=0; i<iconSize; i++)
	{
		BlockMoveData(src,dst,iconRowBytes);
		src+=iconRowBytes;
		dst+=rowBytes;
	}
	HUnlock(dataHandle);
	UnlockPixels(iconPix);
	
	picParam.srcRect=iconRect;
	picParam.hRes=72L<<16;
	picParam.vRes=72L<<16;
	picParam.version=-2;
	picParam.reserved1=0;
	picParam.reserved2=0;
	
	picture=OpenCPicture(&picParam);
	
	ForeColor(blackColor);
	BackColor(whiteColor);
	
	ClipRect(&iconRect);
	EraseRect(&iconRect);
	#if 1
	CopyBits(GetPortBitMapForCopyBits(iconGWorld),GetPortBitMapForCopyBits(iconGWorld),
		&iconRect,&iconRect,srcCopy,nil);
	#else
	{
		IconFamilyHandle	iconFamily;
		IconRef				iconRef;
		
		err=IPIconToIconFamily(ipIcon,&iconFamily);
		err=RegisterIconRefFromIconFamily(kIconPartyCreator,'TEMP',iconFamily,&iconRef);
		DisposeHandle((Handle)iconFamily);
		
		err=PlotIconRef(&iconRect,kAlignNone,kTransformNone,kIconServicesNormalUsageFlag,
				iconRef);
		err=ReleaseIconRef(iconRef);
	}
	#endif
#if __BIG_ENDIAN__
	(**picture).picFrame=iconRect;
#endif
	ClosePicture();
	
	SetGWorld(cPort,cDevice);
	
	#if 0
	CopyBits(GetPortBitMapForCopyBits(iconGWorld),GetPortBitMapForCopyBits(GetWindowPort(MyFrontNonFloatingWindow())),
		&iconRect,&familyIconRect[iconKind],srcCopy,nil);
	
	DrawPicture(picture,&familyIconRect[iconKind]);
	#endif
	
	DisposeGWorld(iconGWorld);
	
	return picture;
}