Пример #1
0
void drawBackground()
{
	Rect		rect;
	RGBColor	color;
	Rect		tempRect1;
	
	color.red = color.green = color.blue = 8700;
	
	RGBForeColor( &color );
	PaintRect( GetPortBounds(GetWindowPort(gWindow), &tempRect1));
	
	TextFont( kFontIDTimes );
	TextMode( srcOr );
	TextSize( 24 );
	
	drawName( 85, 22, "\pSource Image" );
	drawName( GetPortBounds(GetWindowPort(gWindow), &tempRect1)->right - 215, 22, "\pNew Image" );
	
	GetPortBounds(GetWindowPort(gWindow), &tempRect1);
	SetRect( &rect, 15, tempRect1.bottom - 180, tempRect1.right - 15, tempRect1.bottom - 30);
	drawDeepBox( &rect );
	
	TextSize( 12 );
	
	drawName( tItem[0].rect.left, tItem[0].rect.top - 8, "\pTransfer Mode" );
	drawName( aItem[0].rect.left, aItem[0].rect.top - 8, "\pArithmetic Mode" );
	drawName( cItem[0].rect.left, cItem[0].rect.top - 8, "\pColorization" );
	drawName( dItem[0].rect.left, dItem[0].rect.top - 8, "\pDither" );
	drawName( mItem[0].rect.left, mItem[0].rect.top - 8, "\pColor Mapping" );
	drawName( bItem[0].rect.left, bItem[0].rect.top - 8, "\pDestination" );
	drawName( pItem[0].rect.left, pItem[0].rect.top - 8, "\pPaint Bucket" );
	drawName( lItem[0].rect.left, lItem[0].rect.top - 8, "\pLasso Tool" );
}
Пример #2
0
int4 MCScreenDC::textwidth(MCFontStruct *f, const char *s, uint2 len, bool p_unicode_override)
{
    if (len == 0)
        return 0;
    if (f->unicode || p_unicode_override)
    {
        if (MCmajorosversion >= 0x1050)
        {
            return OSX_DrawUnicodeText(0, 0, s, len, f, false, true);
        }
        else
        {
            int4 fwidth;
            short oldfid = GetPortTextFont(GetQDGlobalsThePort());
            short oldsize = GetPortTextSize(GetQDGlobalsThePort());
            short oldstyle = GetPortTextFace(GetQDGlobalsThePort());
            TextFont((short)(intptr_t)f->fid);
            TextSize(f->size);
            TextFace(f->style);


            SInt16  baseline;
            CFStringRef cfstring;

            char *tempbuffer = NULL;


            if (len)
            {
                uint2 *testchar = (uint2 *)s;
                if (testchar[(len - 2 )>> 1] == 12398)
                {
                    tempbuffer = new char[len+2];
                    memcpy(tempbuffer,s,len);
                    uint2 *tchar = (uint2 *)&tempbuffer[len];
                    *tchar = 0;
                }
            }


            cfstring = CFStringCreateWithCharactersNoCopy(NULL, (UniChar *)(tempbuffer != NULL? tempbuffer: s), (tempbuffer != NULL? len + 2:len) >> 1,
                       kCFAllocatorNull);
            Point dimensions = {0, 0};
            GetThemeTextDimensions(cfstring, kThemeCurrentPortFont, kThemeStateActive, false, &dimensions, &baseline);
            fwidth = dimensions.h;
            CFRelease(cfstring);
            if (tempbuffer)
                delete tempbuffer;

            TextFont(oldfid);
            TextSize(oldsize);
            TextFace(oldstyle);
            return fwidth;
        }
    }
    else
    {
        // MW-2012-09-21: [[ Bug 3884 ]] If the font is wide, measure using OS routine.
        if (f -> wide)
Пример #3
0
/////////////////////////////////////////////////////////////
//
// DrawString
//
void
nsPluginInstance::DrawString(const unsigned char* text, 
                             short width, 
                             short height, 
                             short centerX, 
                             Rect drawRect)
{
	short length, textHeight, textWidth;
 
	if(text == NULL)
		return;
	
	length = strlen((char*)text);
	TextFont(1);
	TextFace(bold);
	TextMode(srcCopy);
	TextSize(12);
	
	FontInfo fontInfo;
	GetFontInfo(&fontInfo);

	textHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
	textWidth = TextWidth(text, 0, length);
		
	if (width > textWidth && height > textHeight)
	{
		MoveTo(centerX - (textWidth >> 1), height >> 1);
		DrawText(text, 0, length);
	}		
Пример #4
0
// for scaling text
void MacPrinterCanvas::flush()
{
	// ---- check if there is anything to do ----
	//int nchars = (int) (text_ptr_ - text_buff_);
	//if ((nchars == 0) || (lg_font_ == nil))
	//	return;
		
	// ---- render the text ----
	if (text_item_.count > 0) {
		//set font
		FontRep* fr = lg_font_->rep(nil);
		TextFont(fr->font_);
		TextFace(fr->face_);
		float a00, a01, a10, a11, a20, a21;
		transformer().matrix(a00, a01, a10, a11, a20, a21);
		int size = int(double(fr->size_)*sqrt(a00*a00 + a01*a01) +.01);
		TextSize(size);
		TextMode(fr->mode_);
//if (printing) debugfile("flush %d %d\n",toPixelX(text_item_.x), toPixelY(text_item_.y)); 		
        MoveTo(toPixelX(text_item_.x), toPixelY(text_item_.y));
        DrawText(text_item_.buffer, 0, text_item_.count);
// text_item_.buffer[text_item_.count] = '\0';
// debugfile("|%s|\n", text_item_.buffer);
    }
    text_item_.count = 0;	
	
	return;
}
Пример #5
0
static void mac_updatelicence(WindowPtr window)
{
    Handle h;
    int len;
    long fondsize;
    Rect textrect;

    SetPort((GrafPtr)GetWindowPort(window));
    BeginUpdate(window);
    fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
    TextFont(HiWord(fondsize));
    TextSize(LoWord(fondsize));
    h = Get1Resource('TEXT', wLicence);
    len = GetResourceSizeOnDisk(h);
#if TARGET_API_MAC_CARBON
    GetPortBounds(GetWindowPort(window), &textrect);
#else
    textrect = window->portRect;
#endif
    if (h != NULL) {
	HLock(h);
	TETextBox(*h, len, &textrect, teFlushDefault);
	HUnlock(h);
    }
    EndUpdate(window);
}
void SetFont(
	TextSpec *spec)
{
	TextFont(spec->font);
	TextFace(spec->style);
	TextSize(spec->size);
}
Пример #7
0
void AboutBox::DrawUserItem( const short item )
{
	short	itemType;
	Handle	itemHand;
	Rect	itemBox;
	GetDialogItem( mDialogPtr, item, &itemType, &itemHand, &itemBox );

	if (item == kUrlItem) {
	
		if (!mUrlPane) {
			mUrlPane = MakeURLPane(itemBox);
		}
		mUrlPane->Draw();
	}
	
	else if (kVersionItem == item) {
		MoveTo(itemBox.left, itemBox.bottom - 3);
		TextFont(kFontIDGeneva);
		TextSize(9);
		DrawVersion();	
	}

	else {
		inherited::DrawUserItem(item);
		return;
	}

}
Пример #8
0
void LCD_dofont(Lcd *x, Symbol *s, short argc, Atom *argv)
{
	long font, size;			/* check patcher font settings */
	GrafPtr		sp,pp;
	short			sFont,sSize;
	
	EnterCallback();
	
	font = argv->a_w.w_long;
	size = (argv+1)->a_w.w_long;
	x->font = (short)font;
	x->f_size = (short)size;
	if (sp=patcher_setport(x->lcd_box.b_patcher)){
		GetPort(&pp);
		if (!font&&!size){
			x->font = pp->txFont;
			x->f_size = pp->txSize;			
		}
		else{
			sFont = pp->txFont;
			sSize = pp->txSize;
			TextFont(font);
			TextSize(size);
		}
		
#ifdef debug
post("font:%d size:%d",x->font,x->f_size);
#endif
		LCD_calcfont(x);
		
		LCD_resize(x);
		
		if (font||size){
			TextFont(sFont);
			TextSize(sSize);
		}
		SetPort(sp);
	} else { /* note that this needs to be calced later */
		x->f_width = -1;
		x->f_ascent = -1;
		x->f_descent = -1;
		x->f_height = -1;
		x->f_lineSpace = -1;
	}
	ExitCallback();
}
Пример #9
0
static void setfontsizestyle (short fontnum, short fontsize, short fontstyle) {

	TextFont (fontnum);
	
	TextSize (fontsize);
	
	TextFace (fontstyle);
	} /*setfontsizestyle*/
Пример #10
0
static
void set_font(int font)
{
  double rad, scale, ux, uy;
  int family, size, angle;
  double width, height, capheight;
  StyleParameter face;
  Str255 name;

  font = abs(font);
  if (font >= 101 && font <= 129)
    font -= 100;
  else if (font >= 1 && font <= 32)
    font = map[font - 1];
  else
    font = 9;

  WC_to_NDC_rel(gkss->chup[0], gkss->chup[1], gkss->cntnr, ux, uy);
  seg_xform_rel(&ux, &uy);

  rad = -atan2(ux, uy);
  angle = (int)(rad * 180 / M_PI + 0.5);
  if (angle < 0) angle += 360;
  p->path = ((angle + 45) / 90) % 4;

  scale = sqrt(gkss->chup[0] * gkss->chup[0] + gkss->chup[1] * gkss->chup[1]);
  ux = gkss->chup[0] / scale * gkss->chh;
  uy = gkss->chup[1] / scale * gkss->chh;
  WC_to_NDC_rel(ux, uy, gkss->cntnr, ux, uy);

  width = 0;
  height = sqrt(ux * ux + uy * uy);
  seg_xform_rel(&width, &height);

  height = sqrt(width * width + height * height);
  capheight = nint(height * (fabs(p->c) + 1));
  p->capheight = nint(capheight);

  size = nint(capheight / capheights[font - 1]);
  if (font > 13)
    font += 3;
  p->family = (font - 1) / 4;
  face = (font % 4 == 1 || font % 4 == 2) ? normal : bold;
  if (font % 4 == 2 || font % 4 == 0)
    face |= italic;

  CopyCStringToPascal(fonts[p->family], name);
  family = FMGetFontFamilyFromName(name);
  if (family != kInvalidFontFamily)
    {
      TextFont(family);
      TextFace(face);
      TextSize(size);
    }
  else
    gks_perror("invalid font family (%s)", fonts[p->family]);
}
Пример #11
0
void screenOpen(char *Title) {
    FontInfo fontInfo;
    int n;

    theWindow = GetNewWindow(screenWindow, nil, (WindowPtr)(-1));

    if ((Title != NULL) && (*Title != '\0')) {
        c2pstr(Title);
        SetWTitle(theWindow, Title);
        p2cstr(Title);
    }

    ShowWindow(theWindow);

    SetPort(theWindow);
    TextFont(monaco);
    TextSize(9);

    GetFontInfo(&fontInfo);
    fontHeight = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
    fontWidth = fontInfo.widMax;

    scrollRgn = NewRgn();

    screenWidth = (theWindow->portRect.right - theWindow->portRect.left - 10) /
        fontWidth;
    screenHeight = (theWindow->portRect.bottom - theWindow->portRect.top) /
        fontHeight;
    maxPosition = screenHeight * fontHeight;
    pausePosition = maxPosition - (currentPosition = fontHeight);

    SetRect(&scrollRect, theWindow->portRect.left, theWindow->portRect.top + fontInfo.descent,
        theWindow->portRect.right, theWindow->portRect.bottom);
    SetRect(&pauseRect, theWindow->portRect.left, pausePosition + fontInfo.descent,
        theWindow->portRect.right, theWindow->portRect.bottom);

    MoveTo(5, currentPosition);

    n = (sizeof(char *) + sizeof(short) + screenWidth) * screenHeight;

    screenLine = (char **)NewPtr(n);

    screenLength = (short *)&screenLine[screenHeight];
    screenImage = (char *)&screenLength[screenHeight];

    for (n = 0; n < screenHeight; n++) {
        screenLine[n] = &screenImage[n * screenWidth];
        screenLength[n] = 0;
    }

    startLine = endLine = 0;

    screenOptions = 0;

    return;
}
Пример #12
0
void _HYPlatformGraphicPane::_SetFont (_HYFont f)
{
	Str255  fontFace;
	StringToStr255 (f.face,fontFace);
	short fNum;
	GetFNum (fontFace,&fNum);
	TextFont (fNum);
	TextSize (f.size);
	TextFace (f.style);
}
Пример #13
0
/*	DisplayDialogCmd(theDialog, dlogItemNo, cmd)

	Displays the command in an IGOR-style dialog. See GBLoadWaveDialog.c
	for an example.
	
	dlogItemNo is the item number of the dialog item in which the command
	is to be displayed. On the Macintosh, this must be a user item. On Windows,
	it must be an EDITTEXT item.

	Thread Safety: DisplayDialogCmd is not thread-safe.
*/
void
DisplayDialogCmd(DialogPtr theDialog, int dlogItemNo, const char* cmd)
{
	WindowRef theWindow;
	CGrafPtr thePort;
	Rect box;
	int font, size;
	int lineHeight;
	FontInfo info;
	RgnHandle saveClipRgnH;
	
	theWindow = GetDialogWindow(theDialog);
	thePort = GetWindowPort(theWindow);
	
	font = GetPortTextFont(thePort);		// Save text characteristics.
	size = GetPortTextSize(thePort);

	TextFont(kFontIDMonaco);
	TextSize(9);
	GetFontInfo(&info);
	lineHeight = info.ascent + info.descent + info.leading;
	
	GetDBox(theDialog, dlogItemNo, &box);
	saveClipRgnH = NewRgn();
	if (saveClipRgnH != NULL) {
		GetClip(saveClipRgnH);
		ClipRect(&box);
		InsetRect(&box, 2, 2);
		EraseRect(&box);
		if (*cmd != 0) {
			MoveTo(box.left+2, box.top + info.ascent + 2);
			DrawDialogCmd(cmd, lineHeight);
		}
		SetClip(saveClipRgnH);
		DisposeRgn(saveClipRgnH);
	}

	TextFont(font);									// Restore font, size, style.
	TextSize(size);
}
Пример #14
0
sint32 WText::GetAutoHeight()
{
	sint32 height = 0;

	for (uint32 i=0 ; i<m_aDrawLine.size() ; ++i)
	{
		sint32 w, h;
		TextSize(w, h, m_oDesc.sFontPath, m_oDesc.size, m_aDrawLine[i].c_str());
		height += h;

	}
	return height;
}
Пример #15
0
sint32 WText::GetAutoWidth()
{
	sint32 width = 0;

	for (uint32 i=0 ; i<m_aDrawLine.size() ; ++i)
	{
		sint32 w, h;
		TextSize(w, h, m_oDesc.sFontPath, m_oDesc.size, m_aDrawLine[i].c_str());
		width = std::max<sint32>(width, w);

	}
	return width;
}
Пример #16
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);
} 
Пример #17
0
void RestoreQDDrawingState( QDDrawingState *inDrawingState, const Boolean inDisposeNow )
{//	PixPatHandle	tempPixPat;

#if !(ALIST_USEAPPEARANCEMGR && TARGET_RT_MAC_CFM )
	#pragma unused( inDisposeNow )	// Eliminate compiler warnings in 68K targets because PixPatHandle stuff is screwed up!
#endif

	Assert( inDrawingState != nil );

	// Restore the pen/foreground state.
/*	if ( !inDisposeNow && inDrawingState->penPixPatH != nil ) {
		// Make a copy of the penPixPatH so we can put it somewhere else later because we're not supposed to dispose of it now.
		tempPixPat = NewPixPat( );
		if ( tempPixPat != nil )
			CopyPixPat( inDrawingState->penPixPatH, tempPixPat );
	} else
		tempPixPat = nil;
	PenPixPat( inDrawingState->penPixPatH );
	inDrawingState->penPixPatH = tempPixPat;
*/	RGBForeColor( &inDrawingState->foreColor );
	SetPenState( &inDrawingState->penState );

	// Restore the background state.
/*	if ( !inDisposeNow && inDrawingState->backPixPatH != nil ) {
		// Make a copy of the backPixPatH so we can put it somewhere else later because we're not supposed to dispose of it now.
		tempPixPat = NewPixPat( );
		if ( tempPixPat != nil )
			CopyPixPat( inDrawingState->backPixPatH, tempPixPat );
	} else
		tempPixPat = nil;
	BackPixPat( inDrawingState->backPixPatH );
	inDrawingState->penPixPatH = tempPixPat;
*/	RGBBackColor( &inDrawingState->backColor );

	// Optionally restore the text state.
	if ( inDrawingState->haveTextState ) {
		TextFont( inDrawingState->textStyle.tsFont );
		TextFace( inDrawingState->textStyle.tsFace );
		TextSize( inDrawingState->textStyle.tsSize );
		TextMode( inDrawingState->textMode );
	}

#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 ( inDrawingState->haveThemeState ) {
		SetThemeDrawingState( inDrawingState->themeState, inDisposeNow );
		if ( inDisposeNow )
			inDrawingState->themeState = nil;
	}
#endif
}
Пример #18
0
static void
MagwinDrawText(MagWindow * mw, int x, int y, const char *txt)
{
   TextClass          *tc;
   int                 cw, ch;

   tc = TextclassFind("COORDS", 1);
   if (!tc)
      return;

   TextSize(tc, 0, 0, 0, txt, &cw, &ch, 17);
   TextDraw(tc, EwinGetClientWin(mw->ewin), None, 0, 0, 0,
	    txt, x, y, cw, ch, 17, 0);
}
Пример #19
0
static void Quartz_SetFont(char *family,
			   int style,  double cex, double ps, NewDevDesc *dd)
{
    QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
    int size = cex * ps + 0.5;
    FMFontFamily CurrFontId;
    GrafPtr 	savePort;
    Str255	CurrFontName;
    char	CurrFont[256];
	char *fontFamily;
	
	 
    GetPort(&savePort);
    SetPortWindowPort(xd->window);
    

	fontFamily = Quartz_TranslateFontFamily(family, style, xd->family);
	 if (fontFamily)
	     strcpy(CurrFont,fontFamily);
	 else
	     strcpy(CurrFont,"Helvetica");

	if(style==5)
		strcpy(CurrFont, "Symbol");

	

	if(strcmp(CurrFont,"Symbol")==0){
		if(WeAreOnPanther)
	     CGContextSelectFont( GetContext(xd), CurrFont, size, 
				  kCGEncodingFontSpecific);
		else 
	     CGContextSelectFont( GetContext(xd), CurrFont, size, 
				  kCGEncodingMacRoman);
	}
	else CGContextSelectFont( GetContext(xd), CurrFont, size, 
			      kCGEncodingMacRoman);	



/* This is needed for test only purposes 
    if(strcmp(CurrFont,"Symbol")==0)
     CGContextSelectFont( GetContext(xd), CurrFont, size, kCGEncodingFontSpecific);
*/
    CopyCStringToPascal(CurrFont,CurrFontName);
    GetFNum(CurrFontName, &CurrFontId);
    TextSize(size);
    TextFont(CurrFontId);
    SetPort(savePort);
}
Пример #20
0
static int open_LogWin()
		/*success-> return 0;*/
{
	open_window(&win, kLogWinID);
	position_window(&win);
	setsize_window(&win);
	
	SetPortWindowPort(win.ref);
	TextSize(10);
	gLogTE=TENew(&win.ref->portRect, &win.ref->portRect);
	if( gLogTE==0 ) mac_ErrorExit("\ppCannot open LogWindow!");
	
	TEFeatureFlag(teFAutoScroll, teBitSet, gLogTE);
	TEActivate(gLogTE);
	return 0;
}
Пример #21
0
void mac_ctl_reset_trc()
{
	int i;
	
    for(i = 0; i < MAX_CHANNELS; i++)
    {
		instr_comment[i].last_note_on = 0.0;
		instr_comment[i].comm =""; // channel_instrum_name(i);
		clear_bitset(channel_program_flags + i, 0, 128);
    }
	SetPortWindowPort(win.ref);
	TextMode(srcCopy);
	TextSize(9);
	mac_ctl_refresh_trc();
	current_voices=0;
}
Пример #22
0
int16	AboutDialog::hit(void)
{	
	GrafPtr		saveport;
	short		item;

	GetPort(&saveport);
	SetPort(dialogptr);
	BringToFront(dialogptr);
	TextFont(geneva);
	TextFace(0);
	TextSize(10);

	ShowWindow(dialogptr);

	ModalDialog(NULL, &item);	
	SetPort(saveport);
	return item;	    	
}
Пример #23
0
void mac_setfont(GWorldPtr world, Str255 fontname)
{
	GDHandle	oldGD;
	GWorldPtr	oldGW;
	
	GetGWorld(&oldGW, &oldGD);
	LockPixels(world->portPixMap);
	{
		short		fontID;
		SetGWorld( world, 0);
		GetFNum(fontname, &fontID);
		TextFont(fontID);
		TextSize(14);
		TextFace(extend/*|bold*/);
	}
	SetGWorld(oldGW, oldGD);
	UnlockPixels(world->portPixMap);
}
Пример #24
0
PRBool
SimplePluginInstance::StartDraw(nsPluginWindow* window)
{
    NP_Port* port;
    Rect clipRect;
    RGBColor  col;
	
    if (window == NULL)
        return FALSE;
    port = (NP_Port*) window->window;
    if (window->clipRect.left < window->clipRect.right)
    {
	/* Preserve the old port */
        GetPort((GrafPtr*)&gOldPort);
        SetPort((GrafPtr)port->port);
	/* Preserve the old drawing environment */
        gSavePort.portRect = port->port->portRect;
        gSavePort.txFont = port->port->txFont;
        gSavePort.txFace = port->port->txFace;
        gSavePort.txMode = port->port->txMode;
        gSavePort.rgbFgColor = port->port->rgbFgColor;
        gSavePort.rgbBkColor = port->port->rgbBkColor;
        GetClip(gSavePort.clipRgn);
	/* Setup our drawing environment */
        clipRect.top = window->clipRect.top + port->porty;
        clipRect.left = window->clipRect.left + port->portx;
        clipRect.bottom = window->clipRect.bottom + port->porty;
        clipRect.right = window->clipRect.right + port->portx;
        SetOrigin(port->portx,port->porty);
        ClipRect(&clipRect);
        clipRect.top = clipRect.left = 0;
        TextSize(12);
        TextFont(geneva);
        TextMode(srcCopy);
        col.red = col.green = col.blue = 0;
        RGBForeColor(&col);
        col.red = col.green = col.blue = 65000;
        RGBBackColor(&col);
        return TRUE;
    }
    else
        return FALSE;
}
Пример #25
0
static int open_DocWin()
		/*success-> return 0;*/
{
	Rect	r;

	open_window(&win, kDocWinID);
	position_window(&win);
	setsize_window(&win);
	
	SetPortWindowPort(win.ref);
	TextSize(10);
	r=win.ref->portRect; r.right-=16;
	gDocTE=TENew(&r, &r);
	if( gDocTE==0 ) mac_ErrorExit("\pCannot open DocWindow!");
	
	TEFeatureFlag(teFAutoScroll, teBitSet, gDocTE);
	TEActivate(gDocTE);
	return 0;
}
Пример #26
0
static int open_ListWin()
		/*success-> return 0;*/
{
	Rect		listRect, dataBounds;
	Point		cSize;

	open_window(&win, kListWinID);
	position_window(&win);
	setsize_window(&win);
	
	SetPortWindowPort(win.ref);
	TextSize(10);
	listRect=win.ref->portRect;	listRect.right-=14; listRect.bottom-=14;
	dataBounds.top=dataBounds.left=0; dataBounds.right=1; dataBounds.bottom=0;
	cSize.h=1024; cSize.v=14;
	gPlaylist = LNew(&listRect, &dataBounds, cSize, 0, win.ref, 
						1, 1, 0, 1);
	return 0;
}
Пример #27
0
Файл: MacGraph.c Проект: rolk/ug
void DrawInfoBox (WINDOWID win, const char *info)
{
  WindowPtr theMacWindow;
  Rect r,box,WinRect;
  CGrafPtr myPort;
  Rect myClipRect;
  short w;
  GRAPH_WINDOW *gw;
  Str255 pstr;

  gw = (GRAPH_WINDOW *)win;
  theMacWindow = MAC_WIN(gw);
  /* set port */
  myPort = GetWindowPort(theMacWindow);
  SetPort(myPort);

  GetPortBounds(myPort,&WinRect);

  PmForeColor(1);               /* black */
  GetPortBounds(myPort,&r);

  /* info box */
  SetRect(&box,r.left+1,r.bottom-14,r.right-121,r.bottom);

  /* set clipping region to info box */
  ClipRect(&box);

  EraseRect(&box);

  CopyCStringToPascal(info,pstr);
  w = StringWidth(pstr);
  MoveTo((box.left+box.right)/2-w/2,box.bottom-3);
  TextSize(9);
  DrawString(pstr);

  /* adjust clipping rectangle again to plottable area */
  myClipRect.left   = gw->Local_LL[0];
  myClipRect.right  = gw->Local_UR[0];
  myClipRect.bottom = gw->Local_LL[1];
  myClipRect.top    = gw->Local_UR[1];

  ClipRect(&myClipRect);
}
Пример #28
0
void
x_redraw_status_lines()
{
	// OG Disable status line
#ifndef ACTIVEGS
	Rect	rect;
	Pattern	white_pattern;
	char	tmp_buf[256];
	char	*buf;
	int	len;
	int	line;
	int	height;
	int	margin;
	
	SetPortWindowPort(g_main_window);
	PenNormal();
	height = 16;
	margin = 0;
	TextFont(g_status_font_family);
	TextFace(normal);
	TextSize(12);
	
	SetRect(&rect, 0, X_A2_WINDOW_HEIGHT + margin, X_A2_WINDOW_WIDTH,
			X_A2_WINDOW_HEIGHT + margin + MAX_STATUS_LINES*height);
	GetQDGlobalsWhite(&white_pattern);
	FillRect(&rect, &white_pattern);
	
	for(line = 0; line < MAX_STATUS_LINES; line++) {
		buf = g_status_ptrs[line];
		if(buf == 0) {
			/* skip it */
			continue;
		}
		MoveTo(10, X_A2_WINDOW_HEIGHT + height*line + margin + height);
		len = MIN(250, strlen(buf));
		strncpy(&tmp_buf[1], buf, len);
		tmp_buf[0] = len;
		DrawString((const unsigned char*)&tmp_buf[0]);
	}
#endif
}
Пример #29
0
static void mac_createeventlog(Session *s)
{
    Rect view;
    ListBounds bounds = { 0, 0, 0, 1 }; /* 1 column, 0 rows */
    Point csize = { 0, 0 };
    GrafPtr saveport;
    long fondsize;
    WinInfo *wi;

    s->eventlog_window = GetNewWindow(wEventLog, NULL, (WindowPtr)-1);
    wi = snew(WinInfo);
    memset(wi, 0, sizeof(*wi));
    wi->s = s;
    wi->wtype = wEventLog;
    wi->click = &mac_clickeventlog;
    wi->activate = &mac_activateeventlog;
    wi->grow = &mac_groweventlog;
    wi->update = &mac_updateeventlog;
    wi->close = &mac_closeeventlog;
    SetWRefCon(s->eventlog_window, (long)wi);
    GetPort(&saveport);
    SetPort((GrafPtr)GetWindowPort(s->eventlog_window));
    fondsize = GetScriptVariable(smRoman, smScriptSmallFondSize);
    TextFont(HiWord(fondsize));
    TextSize(LoWord(fondsize));
    SetPort(saveport);
#if TARGET_API_MAC_CARBON
    GetPortBounds(GetWindowPort(s->eventlog_window), &view);
#else
    view = s->eventlog_window->portRect;
#endif
    view.right -= 15; /* Scrollbar */
    s->eventlog = LNew(&view, &bounds, csize, 0, s->eventlog_window,
		       TRUE, TRUE, FALSE, TRUE);
    mac_adjusteventlogscrollbar(s);
#if TARGET_API_MAC_CARBON
    SetListSelectionFlags(s->eventlog, lExtendDrag | lNoDisjoint | lNoExtend);
#else
    (*s->eventlog)->selFlags = lExtendDrag | lNoDisjoint | lNoExtend;
#endif
}
void createWindow()
{
	Rect		rect;
	BitMap		bitMap;
	Rect		tempRect1;
	int			top, left;
	
	GetQDGlobalsScreenBits(&bitMap);
	tempRect1 = bitMap.bounds;
	
	left = (((tempRect1.right - tempRect1.left) - WWIDTH) / 2);
	top = (((tempRect1.bottom - tempRect1.top) - WHEIGHT) / 2);

	//SetRect( &rect, WLEFT, WTOP, WLEFT + WWIDTH, WTOP + WHEIGHT );
	SetRect( &rect, left, top, left + WWIDTH, top + WHEIGHT );
	gWindow = NewCWindow( 0L, &rect, "\pDirect Pixel Access", true, documentProc,
							(WindowPtr)-1L, true, 0L );						
	//SetPort( gWindow );
	SetPortWindowPort( gWindow );
	
	TextFont( kFontIDGeneva );
	TextSize( 9 );
	TextMode( srcXor );
}