コード例 #1
0
ファイル: Font.cpp プロジェクト: NeqHealthcare/MoSync
	void Font::drawBoundedString(const char* strS, int x, int y, const Rect& bound) {
		int i = 0;
		int j = 0;
		if(!mFontImage) return;
		const unsigned char* str = (const unsigned char*)strS;
		calcLineBreaks(strS, x, y, bound);
		MARect srcRect = {0, 0, 0, 0};
		MAPoint2d cursor = {x, y};
		CharDescriptor *chars = mCharset->chars;
		while(str[i]) {
			if(lineBreaks[j] == i) {
				j++;
				cursor.x = x;
				cursor.y += mCharset->lineHeight + mLineSpacing;
				if(str[i]=='\n') {
					i++;
					continue;
				}
			}

			srcRect.left = chars[str[i]].x;
			srcRect.top = chars[str[i]].y;
			srcRect.width = chars[str[i]].width;
			srcRect.height = chars[str[i]].height;

			MAPoint2d destPoint = {cursor.x + chars[str[i]].xOffset,
				cursor.y + chars[str[i]].yOffset};

			//maDrawImageRegion(this->mFontImage, &srcRect, &destPoint, 0);
			Gfx_drawImageRegion(this->mFontImage, &srcRect, &destPoint, 0);

			cursor.x += chars[str[i]].xAdvance;
			i++;
		}
	}
コード例 #2
0
ファイル: Font.cpp プロジェクト: NeqHealthcare/MoSync
	void Font::drawString(const char* strS, int x, int y) {
		if(!mFontImage) return;
		const unsigned char* str = (const unsigned char*)strS;
		MARect srcRect = {0, 0, 0, 0};
		MAPoint2d cursor = {x,y};

		CharDescriptor *chars = mCharset->chars;
		while(*str) {
			if((*str)=='\n')
			{
				cursor.x = x;
				cursor.y += mCharset->lineHeight + mLineSpacing;
				str++;
				continue;
			}

			srcRect.left = chars[*str].x;
			srcRect.top = chars[*str].y;
			srcRect.width = chars[*str].width;
			srcRect.height = chars[*str].height;

			MAPoint2d destPoint = {cursor.x + chars[*str].xOffset,
				cursor.y + chars[*str].yOffset};

			//maDrawImageRegion(this->mFontImage, &srcRect, &destPoint, 0);
			Gfx_drawImageRegion(this->mFontImage, &srcRect, &destPoint, 0);

			cursor.x += chars[*str].xAdvance;
			str++;
		}
	}
コード例 #3
0
ファイル: AnimatedImage.cpp プロジェクト: Felard/MoSync
	void AnimatedImage::drawWidget() {
		if(mResource) {
			// void maDrawImageRegion(MAHandle image, const MARect* srcRect, const MAPoint2d* dstPoint, int transformMode);
			MARect srcRect;
			srcRect.left  = 0;
			srcRect.width = EXTENT_X(mResSize);
			srcRect.top   = mCurrentFrame * paddedBounds.height; 
			srcRect.height = paddedBounds.height;
			//MAPoint2d destPoint = {paddedBounds.x, paddedBounds.y};
			MAPoint2d destPoint = {0, 0};

			//maDrawImageRegion(resource, &srcRect, &destPoint, TRANS_NONE);
			Gfx_drawImageRegion(mResource, &srcRect, &destPoint, TRANS_NONE);
		}
	}
コード例 #4
0
ファイル: WidgetSkin.cpp プロジェクト: Felard/MoSync
	void WidgetSkin::drawDirect(int x, int y, int width, int height, eType type) {
		MAPoint2d dst;
		MAPoint2d dst2;
		MAHandle image;
		switch(type) {
			case SELECTED:
				image = selectedImage;
				break;
			case UNSELECTED:
				image = unselectedImage;
				break;
			default:
				maPanic(0, "WidgetSkin::draw undefined drawing type");
		}

		if(image == 0) return;

		// draw corners
		dst.x = x; dst.y = y;
		//maDrawImageRegion(image, &topLeft, &dst, TRANS_NONE);
		Gfx_drawImageRegion(image, &topLeft, &dst, TRANS_NONE);

		dst.x = x; dst.y = y+height-bottomLeft.height;
		//maDrawImageRegion(image, &bottomLeft, &dst, TRANS_NONE);
		Gfx_drawImageRegion(image, &bottomLeft, &dst, TRANS_NONE);

		dst.x = x+width-topRight.width; dst.y = y;
		//maDrawImageRegion(image, &topRight, &dst, TRANS_NONE);
		Gfx_drawImageRegion(image, &topRight, &dst, TRANS_NONE);

		dst.x = x+width-bottomRight.width; dst.y = y+height-bottomRight.height;
		//maDrawImageRegion(image, &bottomRight, &dst, TRANS_NONE);
		Gfx_drawImageRegion(image, &bottomRight, &dst, TRANS_NONE);

		// draw middle
		if(center.height && center.width) {
		for(int j = y+top.height; j < y+height-bottom.height; j+=center.height) {
			int h = center.height;
			if(j+center.height>y+height-bottom.height) {
				center.height -= (j+center.height)-(y+height-bottom.height);
			}
			for(int i = x+left.width; i < x+width-right.width; i+=center.width) {
				dst.x = i; dst.y = j;
				int w = center.width;
				if(i+center.width>x+width-right.width) {
					center.width -= (i+center.width)-(x+width-right.width);
				}
				//maDrawImageRegion(image, &center, &dst, TRANS_NONE);
				Gfx_drawImageRegion(image, &center, &dst, TRANS_NONE);

				center.width = w;
			}
			center.height = h;
		}
		}

		// draw borders
		if(top.width) {
		for(int i = x+left.width; i < x+width-right.width; i+=top.width) {
				dst.x = i; dst.y = y;
				dst2.x = i; dst2.y = y+height-bottom.height;

				int w1 = top.width;
				int w2 = bottom.width;
				if(i+top.width>x+width-right.width) {
					top.width -= (i+w1)-(x+width-right.width);
					bottom.width -= (i+w1)-(x+width-right.width);
				}
				//maDrawImageRegion(image, &top, &dst, TRANS_NONE);
				//maDrawImageRegion(image, &bottom, &dst2, TRANS_NONE);
				Gfx_drawImageRegion(image, &top, &dst, TRANS_NONE);
				Gfx_drawImageRegion(image, &bottom, &dst2, TRANS_NONE);

				top.width = w1;
				bottom.width = w2;
		}
		}

		if(left.height) {
		for(int i = y+top.height; i < y+height-bottom.height; i+=left.height) {
				dst.x = x; dst.y = i;
				dst2.x = x+width-right.width; dst2.y = i;

				int w1 = left.height;
				int w2 = right.height;
				if(i+left.height>y+height-bottom.height) {
					left.height -= (i+w1)-(y+height-bottom.height);
					right.height -= (i+w1)-(y+height-bottom.height);
				}
				//maDrawImageRegion(image, &left, &dst, TRANS_NONE);
				//maDrawImageRegion(image, &right, &dst2, TRANS_NONE);
				Gfx_drawImageRegion(image, &left, &dst, TRANS_NONE);
				Gfx_drawImageRegion(image, &right, &dst2, TRANS_NONE);

				left.height = w1;
				right.height = w2;
		}
		}
	}