⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i_ugldsp.cpp

📁 zinc60t22.tar.gz:zinc在tornado2.2.x下的补丁
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		return (ZAF_ERROR_INVALID);	ZafRegionStruct clip = ClipRegion();	ZafPaletteStruct savePalette = Palette();	// Hide the screen devices.	ZafRegionStruct region;	region.left = region.top = 0;	region.right = columns - 1;	region.bottom = lines - 1;	region.coordinateType = ZAF_PIXEL;	BeginDraw(0, ID_ZAF_DIRECT, region, region);	// Draw the XOR rectangles on the display.	SetPalette(*xorPalette);	SetMode(ZAF_MODE_XOR);	if (oldRegion)		ZafDisplay::Rectangle(*oldRegion);	if (newRegion)		ZafDisplay::Rectangle(*newRegion);	EndDraw();#if defined(ZAF_RTOS)	ZafScreenDisplay::classSem->Give();#endif	return (ZAF_ERROR_NONE);}ZafError ZafScreenDisplay::RegionCopy(const ZafRegionStruct &oldRegion,	int newColumn, int newLine){#if defined(ZAF_RTOS)	ZafScreenDisplay::classSem->Take(ZAF_WAIT_FOREVER_SEMAPHORE);#endif	uglBitmapBlt(gc, 0, oldRegion.left, oldRegion.top, oldRegion.right,		oldRegion.bottom, 0, newColumn, newLine);#if defined(ZAF_RTOS)	ZafScreenDisplay::classSem->Give();#endif	return (ZAF_ERROR_NONE);}// --- Tables ---------------------------------------------------------------ZafLogicalColor ZafScreenDisplay::AddColor(ZafLogicalColor index,	ZafUInt8 red, ZafUInt8 green, ZafUInt8 blue){	return (AddColor(index, 255, red, green, blue));}ZafLogicalColor ZafScreenDisplay::AddColor(ZafLogicalColor index,	ZafUInt8 alpha, ZafUInt8 red, ZafUInt8 green, ZafUInt8 blue){	if (index != ZAF_CLR_NULL &&		(index >= ZAF_MAXCOLORS))		return (ZAF_CLR_NULL);#if defined(ZAF_RTOS)    ZafAutoSemaphore autoSem(ZafScreenDisplay::classSem);#endif	int realIndex = index;	if (realIndex == ZAF_CLR_NULL)	{		// Find next available color.		int i = 0;		while (colorUsedTable[i] && i < ZAF_MAXCOLORS)			++i;		if (i < ZAF_MAXCOLORS)			realIndex = i;		else			return (ZAF_CLR_NULL);	}	// If that color is already in use, or the system doesn't support a color	// of that index, do nothing.    UGL_MODE_INFO modeInfo;    uglInfo(devID, UGL_MODE_INFO_REQ, &modeInfo);	int colorDepth = modeInfo.colorDepth;	if (colorUsedTable[realIndex] || (colorDepth < 16 &&		realIndex >= (1 << colorDepth)))		return (ZAF_CLR_NULL);	UGL_ARGB argb = UGL_MAKE_ARGB(alpha, red, green, blue);	uglColorAlloc(devID, &argb, &realIndex, &colorTable[realIndex], 1);	colorUsedTable[realIndex] = true;	return (realIndex);}ZafLogicalFont ZafScreenDisplay::AddFont(ZafLogicalFont index, char *fontFamily,	int pointSize, ZafFontWeight weight, ZafFontSlant slant, ZafFontPitch pitch){	if (index != ZAF_FNT_NULL &&		(index < 0 || index >= ZAF_MAXFONTS))		return (ZAF_FNT_NULL);#if defined(ZAF_RTOS)    ZafAutoSemaphore autoSem(ZafScreenDisplay::classSem);#endif	int realIndex = index;	if (realIndex == ZAF_FNT_NULL)	{		// Find next available font.		int i = 0;		while (fontTable[i] && i < ZAF_MAXFONTS)			++i;		if (i < ZAF_MAXFONTS)			realIndex = i;		else			return (ZAF_FNT_NULL);	}	int length = strlen(fontFamily) + 1;     // Allocate an array with enough room for the font modifiers.	char *fontName = new char[length + 40];	sprintf(fontName, "familyName=%s", fontFamily);	int emHeight = (int)(((long)pointSize * (long)pixelsPerInchY + 36) / 72);	// Add the attributes to the fontName string	if (emHeight > 0)		sprintf(&fontName[strlen(fontName)], ";pixelSize=%d", emHeight);    if (weight != ZAF_FNT_WEIGHT_NORMAL)		strcat(fontName, ";bold");	if (slant != ZAF_FNT_SLANT_NORMAL)		strcat(fontName, ";italic");	if (pitch != ZAF_FNT_PITCH_DEFAULT)		strcat(fontName, (pitch == ZAF_FNT_PITCH_FIXED) ? ";mono" :		";proportional");    UGL_FONT_DEF fontDef;    uglFontFindString(fontDrvId, fontName, &fontDef);	fontTable[realIndex] = uglFontCreate(fontDrvId, &fontDef);	delete []fontName;	if (fontTable[realIndex])		return (realIndex);	else		return (ZAF_FNT_NULL);}ZafError ZafScreenDisplay::DestroyColor(ZafLogicalColor index){	if (index >= ZAF_MAXCOLORS)		return (ZAF_ERROR_INVALID_INDEX);#if defined(ZAF_RTOS)	ZafScreenDisplay::classSem->Take(ZAF_WAIT_FOREVER_SEMAPHORE);#endif	uglColorFree(devID, &colorTable[index], 1);	colorTable[index] = ZAF_CLR_NULL;	colorUsedTable[index] = false;#if defined(ZAF_RTOS)	ZafScreenDisplay::classSem->Give();#endif	return (ZAF_ERROR_NONE);}ZafError ZafScreenDisplay::DestroyFont(ZafLogicalFont index){	if (index < 0 || index >= ZAF_MAXFONTS || !fontTable[index])		return (ZAF_ERROR_INVALID_INDEX);#if defined(ZAF_RTOS)	ZafScreenDisplay::classSem->Take(ZAF_WAIT_FOREVER_SEMAPHORE);#endif    uglFontDestroy(fontTable[index]);	fontTable[index] = 0;#if defined(ZAF_RTOS)	ZafScreenDisplay::classSem->Give();#endif	return (ZAF_ERROR_NONE);}ZafError ZafScreenDisplay::ColorInfo(ZafLogicalColor index, ZafUInt8 &red, ZafUInt8 &green, ZafUInt8 &blue){#if defined(ZAF_RTOS)    ZafAutoSemaphore autoSem(ZafScreenDisplay::classSem);#endif	if (index >= ZAF_MAXCOLORS || !colorUsedTable[index])		return (ZAF_ERROR_INVALID_INDEX);	// Return the color information.	UGL_COLOR color = colorTable[index];	UGL_RGB rgbColor;	uglColorConvert(devID, &color, UGL_DEVICE_COLOR_32, &rgbColor, UGL_RGB888, 1);	red = UGL_RGB_RED(rgbColor);	green = UGL_RGB_GREEN(rgbColor);	blue = UGL_RGB_BLUE(rgbColor);	return (ZAF_ERROR_NONE);}ZafError ZafScreenDisplay::FontInfo(ZafLogicalFont index, char *fontFamily, int bufferSize,	int *pointSize, ZafFontWeight *weight, ZafFontSlant *slant,	ZafFontPitch *pitch, ZafCoordinate *averageCharWidth,	ZafCoordinate *height, ZafCoordinate *leading){#if defined(ZAF_RTOS)    ZafAutoSemaphore autoSem(ZafScreenDisplay::classSem);#endif	if (index < 0 || index >= ZAF_MAXFONTS || !fontTable[index])		return (ZAF_ERROR_INVALID_INDEX);	UGL_FONT_METRICS fontInfo;	uglFontMetricsGet(fontTable[index], &fontInfo);	if (fontFamily)		strncpy(fontFamily, fontInfo.faceName, bufferSize);	if (pointSize)		*pointSize = fontInfo.pixelSize;	if (weight)		*weight = fontInfo.weight ? ZAF_FNT_WEIGHT_BOLD : ZAF_FNT_WEIGHT_NORMAL;	if (slant)		*slant = (fontInfo.italic == UGL_FONT_UPRIGHT) ? ZAF_FNT_SLANT_NORMAL : ZAF_FNT_SLANT_ITALIC;	if (pitch)		*pitch = fontInfo.spacing == UGL_FONT_PROPORTIONAL ? ZAF_FNT_PITCH_FIXED : ZAF_FNT_PITCH_VARIABLE;	if (averageCharWidth)		*averageCharWidth = 0; // Not yet implemented.	if (height)		*height = fontInfo.maxAscent + fontInfo.maxDescent;	if (leading)		*leading = fontInfo.leading;	return (ZAF_ERROR_NONE);}// --- Get ------------------------------------------------------------------ZafLogicalColor ZafScreenDisplay::Background(void) const{	return (palette.colorBackground);}ZafLogicalColor ZafScreenDisplay::MonoBackground(void) const{	return (palette.monoBackground);}ZafRegionStruct ZafScreenDisplay::ClipRegion(void) const{	return (clipRegion);}ZafLogicalFont ZafScreenDisplay::Font(void) const{	return (palette.font);}ZafLogicalColor ZafScreenDisplay::Foreground(void) const{	return (palette.colorForeground);}ZafLogicalColor ZafScreenDisplay::MonoForeground(void) const{	return (palette.monoForeground);}ZafLogicalLineStyle ZafScreenDisplay::LineStyle(void) const{	return (palette.lineStyle);}ZafLogicalMode ZafScreenDisplay::Mode(void) const{	return (mode);}ZafPaletteStruct ZafScreenDisplay::Palette(void) const{	return (palette);}ZafLogicalFillPattern ZafScreenDisplay::FillPattern(void) const{	return (palette.fillPattern);}// --- Set ------------------------------------------------------------------ZafLogicalColor ZafScreenDisplay::SetBackground(ZafLogicalColor color){	if (color < ZAF_MAXCOLORS)	{#if defined(ZAF_RTOS)    	ZafScreenDisplay::classSem->Take(ZAF_WAIT_FOREVER_SEMAPHORE);#endif		palette.colorBackground = color;		uglBackgroundColorSet(gc, colorTable[color]);#if defined(ZAF_RTOS)    	ZafScreenDisplay::classSem->Give();#endif    }	return(palette.colorBackground);}ZafRegionStruct ZafScreenDisplay::SetClipRegion(const ZafRegionStruct &region){#if defined(ZAF_RTOS)    ZafScreenDisplay::classSem->Take(ZAF_WAIT_FOREVER_SEMAPHORE);#endif    // Check region against master clip region. Clipping must be within	// the master clip region.	ZafRegionStruct convertRegion = region.Region(ZAF_PIXEL);	convertRegion.left = (int)((long)convertRegion.left * scaleNumerator / scaleDenominator + originX);	convertRegion.top = (int)((long)convertRegion.top * scaleNumerator / scaleDenominator + originY);	convertRegion.right = (int)((long)convertRegion.right * scaleNumerator / scaleDenominator + originX);	convertRegion.bottom = (int)((long)convertRegion.bottom * scaleNumerator / scaleDenominator + originY);	if (!convertRegion.Overlap(masterClip, clipRegion))		clipRegion.left =			clipRegion.top =			clipRegion.right=			clipRegion.bottom = -1;	uglClipRectSet(gc, clipRegion.left, clipRegion.top, clipRegion.right,		clipRegion.bottom);#if defined(ZAF_RTOS)    ZafScreenDisplay::classSem->Give();#endif    return (clipRegion);}ZafLogicalFillPattern ZafScreenDisplay::SetFillPattern(ZafLogicalFillPattern pattern){	if (pattern >= 0 && pattern < ZAF_MAXPATTERNS)	{#if defined(ZAF_RTOS)        ZafScreenDisplay::classSem->Take(ZAF_WAIT_FOREVER_SEMAPHORE);#endif		palette.fillPattern = pattern;		uglFillPatternSet(gc, patternTable[pattern]);#if defined(ZAF_RTOS)    	ZafScreenDisplay::classSem->Give();#endif	}	return(palette.fillPattern);}ZafLogicalFont ZafScreenDisplay::SetFont(ZafLogicalFont font){#if defined(ZAF_RTOS)    ZafScreenDisplay::classSem->Take(ZAF_WAIT_FOREVER_SEMAPHORE);#endif	if (font != palette.font && font >= 0 && font < ZAF_MAXFONTS)	{		palette.font = font;		uglFontSet(gc, fontTable[font]);	}#if defined(ZAF_RTOS)    ZafScreenDisplay::classSem->Give();#endif	return(palette.font);}ZafLogicalColor ZafScreenDisplay::SetForeground(ZafLogicalColor color){	if (color < ZAF_MAXCOLORS)	{#if defined(ZAF_RTOS)        ZafScreenDisplay::classSem->Take(ZAF_WAIT_FOREVER_SEMAPHORE);#endif		palette.colorForeground = color;		uglForegroundColorSet(gc, colorTable[color]);#if defined(ZAF_RTOS)    	ZafScreenDisplay::classSem->Give();#endif	}	return(palette.colorForeground);}ZafLogicalLineStyle ZafScreenDisplay::SetLineStyle(ZafLogicalLineStyle line){	if (line >= 0 && line < ZAF_MAXLINES)	{#if defined(ZAF_RTOS)        ZafScreenDisplay::classSem->Take(ZAF_WAIT_FOREVER_SEMAPHORE);#endif		palette.lineStyle = line;		uglLineStyleSet(gc, (UGL_LINE_STYLE)lineTable[line]);#if defined(ZAF_RTOS)    	ZafScreenDisplay::classSem->Give();#endif	}	return (palette.lineStyle);}ZafLogicalMode ZafScreenDisplay::SetMode(ZafLogicalMode tMode){	if (tMode >= 0 && tMode < ZAF_MAXMODES)	{#if defined(ZAF_RTOS)        ZafScreenDisplay::classSem->Take(ZAF_WAIT_FOREVER_SEMAPHORE);#endif		mode = tMode;		if (mode == ZAF_MODE_COPY)			uglRasterModeSet(gc, UGL_RASTER_OP_COPY);		else if (mode == ZAF_MODE_XOR)			uglRasterModeSet(gc, UGL_RASTER_OP_XOR);#if defined(ZAF_RTOS)    	ZafScreenDisplay::classSem->Give();#endif	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -