コード例 #1
0
// draws the focus screen's active button
void AnsiWidget::drawActiveButton() {
#if defined(_FLTK)
  maUpdateScreen();
#elif defined(_SDL)
  if (_focus != NULL && !_activeButton->hasHover()) {
    MAHandle currentHandle = maSetDrawTarget(HANDLE_SCREEN);
    _focus->drawShape(_activeButton);
    _focus->drawLabel();
    maUpdateScreen();
    maSetDrawTarget(currentHandle);
  }
#else
  if (_activeButton->hasHover()) {
    int dx = _front->_x;
    int dy = _front->_y - _front->_scrollY;
    _activeButton->drawHover(dx, dy, _activeButton->_pressed);
  } else if (_focus != NULL) {
    MAHandle currentHandle = maSetDrawTarget(HANDLE_SCREEN);
    _focus->drawShape(_activeButton);
    _focus->drawLabel();
    maUpdateScreen();
    maSetDrawTarget(currentHandle);
  }
#endif
}
コード例 #2
0
ファイル: ScreenColorList.cpp プロジェクト: AliSayed/MoSync
/**
 * Create a colored image.
 * @param color The color of the image (a hex value).
 * @param width The width of the image.
 * @param height The height of the image.
 * @return Handle to the image. The image needs to be
 * deallocated with maDestoryObject.
 */
MAHandle ScreenColorList::createColorImage(int color, int width, int height)
{
	MAHandle image = maCreatePlaceholder();
	maCreateDrawableImage(image, width, height);
	MAHandle previousDrawTarget = maSetDrawTarget(image);
	maSetColor(color);
	maFillRect(0, 0, width, height);
	maSetDrawTarget(previousDrawTarget);
	return image;
}
コード例 #3
0
ファイル: main.c プロジェクト: Felard/MoSync
int MAMain() {
	int x=0, y=0, dx=1, dy=1;
	int scrW, scrH;
	int srcW, srcH;
	{
		int srcSize = maGetImageSize(SIMG);
		srcW = EXTENT_X(srcSize);
		srcH = EXTENT_Y(srcSize);
	}
	maCreateDrawableImage(TIMG, srcW,srcH);
	maSetDrawTarget(TIMG);

	maSetColor(0);	//black
	maFillRect(0,0, srcW,srcH);
	maDrawImage(SIMG, 0,0);
	maSetColor(0xff0000);	//red
	maLine(0,0, srcW,srcH);
	maLine(srcW,0, 0,srcH);

	maSetDrawTarget(HANDLE_SCREEN);
	{
		int scrSize = maGetScrSize();
		scrW = EXTENT_X(scrSize);
		scrH = EXTENT_Y(scrSize);
	}
	while(1) {
		//int then = maGetMilliSecondCount();

		maSetColor(0);	//black
		maFillRect(0,0, scrW,scrH);

		maDrawImage(TIMG, x, y);
		if((dx > 0 && x + srcW > scrW) || (dx < 0 && x < 0)) {
			dx = -dx;
		}
		if((dy > 0 && y + srcH > scrH) || (dy < 0 && y < 0)) {
			dy = -dy;
		}
		x += dx;
		y += dy;
		maUpdateScreen();
		/*{
		int now = maGetMilliSecondCount();
		int time_padding = 10 - (now - then);
		if(time_padding > 0)
		maSleep(time_padding);
		}*/
	}
}
コード例 #4
0
ファイル: Resources.cpp プロジェクト: comforx/MoSync
	void testDrawableImages() {
		const unsigned int colors[] = {
			0xff000000,
			0xff0000ff,
			0xff00ff00,
			0xff00ffff,
			0xffff0000,
			0xffff00ff,
			0xffffff00,
			0xffffffff,
		};

		const unsigned int NUMCOLORS = sizeof(colors)/sizeof(int);

		unsigned int colors2[NUMCOLORS];

		MAHandle testImg = maCreatePlaceholder();

		printf("testing resources\n");

		int res = maCreateDrawableImage(testImg, NUMCOLORS, 1);
		assert("maCreateImageRaw", res == RES_OK);

		MAExtent e1 = maGetImageSize(testImg);

		assert("maGetImageSize", e1 == EXTENT(NUMCOLORS,1));

		maSetDrawTarget(testImg);

		for(unsigned int i = 0; i < NUMCOLORS; i++) {
			maSetColor(colors[i]);
			maPlot(i, 0);
		}

		MARect rect = {0, 0, NUMCOLORS, 1};

		maSetDrawTarget(0);

		maGetImageData(testImg, colors2, &rect, NUMCOLORS);

		assert(
				"testing drawable image res",
				(memcmp(colors, colors2, sizeof(colors)) == 0)
		);
	}
コード例 #5
0
LoadScreen::LoadScreen(void) {
	/* ---------------------------------- */
	maSetDrawTarget(HANDLE_SCREEN);

	MAExtent screenSize = maGetScrSize();
	int scrHeight = EXTENT_Y(screenSize);

	/* ---------------------------------- */
	drawText(40, LANG_PLEASE_WAIT, 0xffffff);
	drawText(60, LANG_LOADING_TABLES, 0xffffff);

	/* ---------------------------------- */
	String str(LANG_VERSION);
	str.append(VERSION, strlen(VERSION));

	/* ---------------------------------- */
	drawText(scrHeight-16, (const char*)str.c_str(), 0xff7700);
}
コード例 #6
0
void VisueelScherm::update()
{
	//update waarden vam weerdata
	this->weerData->update();

	//stel draw target in op onze tekening
	maSetDrawTarget( this->diagramTekening );

	//teken een staaf diagram

	//legenda
	//teken blokje en text met zonneschijn, neerslag en temperatuur
	maSetColor(0xffffff);
	maDrawText(10, 10, "Legenda");
	maDrawText(10, 25, "Zonneschijn");
	maDrawText(10, 40, "Neerslag");
	maDrawText(10, 55, "Temperatuur");

	//zonneschijn
	maSetColor(0xffff00);
	maFillRect(100, 25, 15, 15);

	//neerslag
	maSetColor(0x0000ff);
	maFillRect(100, 40, 15, 15);

	//temperatuur
	maSetColor(0xff0000);
	maFillRect(100, 55, 15, 15);

	//teken 10-stap lijnen
	maSetColor(0xffffff);

	//grid-lijnen
	for(int i=100; i<=200; i+=10)
	{
		maLine(20, i, 200, i);
	}

	//teken de staven van zonneschijn, neerslag en minimum temperatuur

	// Zonneschijn
	maSetColor(0xffff00);
	maFillRect(30, 100+(100-this->weerData->zonneschijn[0]), 10, this->weerData->zonneschijn[0]); //vandaag
	maFillRect(45, 100+(100-this->weerData->zonneschijn[1]), 10, this->weerData->zonneschijn[1]); //morgen
	maFillRect(60, 100+(100-this->weerData->zonneschijn[2]), 10, this->weerData->zonneschijn[2]); //overmorgen

	// Neerslag
	maSetColor(0x0000ff);
	maFillRect(85, 100+(100-this->weerData->neerslag[0]), 10, this->weerData->neerslag[0]); //vandaag
	maFillRect(100, 100+(100-this->weerData->neerslag[1]), 10, this->weerData->neerslag[1]); //morgen
	maFillRect(115, 100+(100-this->weerData->neerslag[2]), 10, this->weerData->neerslag[2]); //overmorgen

	// Temperatuur
	maSetColor(0xff0000);
	maFillRect(140, 100+(100-this->weerData->minimumtemperatuur[0]), 10, this->weerData->minimumtemperatuur[0]); //vandaag
	maFillRect(155, 100+(100-this->weerData->minimumtemperatuur[1]), 10, this->weerData->minimumtemperatuur[1]); //morgen
	maFillRect(170, 100+(100-this->weerData->minimumtemperatuur[2]), 10, this->weerData->minimumtemperatuur[2]); //overmorgen

	//altijd draw target na tekenen teruggeven naar scherm!
	maSetDrawTarget( HANDLE_SCREEN );

	//update de image met de nieuwe tekening
	this->diagramImage->setResource( this->diagramTekening );
}
コード例 #7
0
ファイル: ImageGenerators.cpp プロジェクト: AliSayed/MoSync
	void ImageGenerators::linearGradient(
		MAHandle image, 
		Point start, 
		Point end, 
		int startColor,
		int endColor, 
		ImageGenerators::AlphaMode alphaMode)
	{
		MAExtent size = maGetImageSize(image);
		int imgWidth = EXTENT_X(size);
		int imgHeight = EXTENT_Y(size);

		int gradVecX;
		int gradVecY;
		int gradOrthoVecX;
		int gradOrthoVecY;

		gradVecX = end.x - start.x;
		gradVecY = end.y - start.y;
		gradOrthoVecX = gradVecY;
		gradOrthoVecY = -gradVecX;

		int startAlpha =	(startColor&0xff000000)>>24;
		int startRed =		(startColor&0x00ff0000)>>16;
		int startGreen =	(startColor&0x0000ff00)>>8;
		int startBlue =		(startColor&0x000000ff);

		int endAlpha =		(endColor&0xff000000)>>24;
		int endRed =		(endColor&0x00ff0000)>>16;
		int endGreen =		(endColor&0x0000ff00)>>8;
		int endBlue =		(endColor&0x000000ff);

		int *tempSurface = new int[imgWidth*imgHeight];

		if(!tempSurface) {
			maPanic(0, "ImageGenerators::linearGradient, NO MEMORY!");
		}

		int *dst = tempSurface;

		MAHandle lastDrawTarget = maSetDrawTarget(image);

		int sqrLen = gradOrthoVecX*gradOrthoVecX + gradOrthoVecY*gradOrthoVecY;
		double sqrtLen = (sqrt((double)sqrLen));
		double sqrtLenRecip = 1.0/sqrtLen;
		//lprintfln("imgWidth: %d, imgHeight: %d\n", imgWidth, imgHeight);
		for(int j = 0; j < imgHeight; j++) {
			for(int i = 0; i < imgWidth; i++) {

				int u = (((i - start.x)*gradOrthoVecX + 
					(j - start.y)*gradOrthoVecY)<<16) / sqrLen;

				int projectedPointX = ((u*gradOrthoVecX)>>16);
				int projectedPointY = ((u*gradOrthoVecY)>>16);

				//lprintfln("we come here! %d\n", i + j*imgWidth);

				double distToStart = 
					(sqrt((double)
						(((start.x+projectedPointX)-i)*((start.x+projectedPointX)-i) +
						((start.y+projectedPointY)-j)*((start.y+projectedPointY)-j))
						));

				double distToEnd = (sqrt((double)
					(((end.x+projectedPointX)-i)*((end.x+projectedPointX)-i) +
					((end.y+projectedPointY)-j)*((end.y+projectedPointY)-j))
					)); 
				//double distToStart = 0.0;
				//double distToEnd = 0.0;

				//	double distToEnd = sqrtLen - distToStart;

				if(distToEnd >= sqrtLen) {
					*dst++  = startColor;
				} 
				else if(distToStart >= sqrtLen) {
					*dst++ = endColor;
				} 
				else {
					int r = (int)(((distToStart*(double)endRed) 
						+ (distToEnd*(double)startRed))*sqrtLenRecip);
					int g = (int)(((distToStart*(double)endGreen) 
						+ (distToEnd*(double)startGreen))*sqrtLenRecip);
					int b = (int)(((distToStart*(double)endBlue) 
						+ (distToEnd*(double)startBlue))*sqrtLenRecip);
					int a = (int)(((distToStart*(double)endAlpha) 
						+ (distToEnd*(double)startAlpha))*sqrtLenRecip);
					if(r<0)		r = 0;
					if(r>255)	r = 255;
					if(g<0)		g = 0;
					if(g>255)	g = 255;
					if(b<0)		b = 0;
					if(b>255)	b = 255;
					if(a<0)		a = 0;
					if(a>255)	a = 255;

					*dst++ = (a<<24)|(r<<16)|(g<<8)|(b);
				}
			} 
		}

		if(alphaMode == AM_WRITEALPHA) {
			MAPoint2d dstPoint = {0, 0};
			MARect srcRect = {0, 0, imgWidth, imgHeight};
			maDrawRGB(&dstPoint, tempSurface, &srcRect, imgWidth);
			maSetDrawTarget(lastDrawTarget);
		} 
		else if(alphaMode == AM_USEALPHA) {
			// TODO: Implement missing code.
		} 
		else if(alphaMode == AM_NOALPHA) {
			// TODO: Implement missing code.
		}

		delete []tempSurface;
	}