Exemple #1
0
void TestMoblet::testLoadWithName()
{
	mShowing = 2;

	maSetColor(0x000000);
	MAExtent size = maGetScrSize();
	maFillRect(0,0,EXTENT_X(size),EXTENT_Y(size) );

	maSetColor(0xCD5555);

	int top = 0;
	maDrawText(10,top,"--------- Test maFontLoadWithName(test each name from list) --------- ");
	top += 20;

	for (int i=0; i<fontNames.size(); i++)
	{
		top += 20;
		int handle = maFontLoadWithName(fontNames[i].c_str(), 15);
		if ( handle == RES_FONT_NAME_NONEXISTENT )
		{
			message = "Font nonexistent: " + fontNames[i];
			maDrawText(10,top, message.c_str());
		}
		else
		{
			maFontSetCurrent(handle);
			message =  "Font " + fontNames[i] + " has handle = " + MAUtil::integerToString(handle);
			maDrawText(10, top, message.c_str());
		}
	}

	maDrawText(10, top+40, "Tap screen to test maFontLoadDefault for some combinations");
	maUpdateScreen();
}
Exemple #2
0
/*
 * @brief Sets the font
 * to display the sensors values.
 */
void setFont()
{
	int nrFonts = maFontGetCount();
	char fontName[BUFFER_SIZE];
	// get first font.
	maFontGetName(0, fontName, BUFFER_SIZE);
	// Load first font with size 20.
	int fontHandle = maFontLoadWithName(fontName, TEXT_SIZE);
	maFontSetCurrent(fontHandle);
}
Exemple #3
0
/**
 * Creates and adds main layout to the screen.
 */
void MainScreen::createMainLayout() {
	// Create and add the main layout to the screen.
	mMainLayout = new VerticalLayout();
	Screen::setMainWidget(mMainLayout);

	mButton = new Button();
	mMainLayout->addChild(mButton);

	int result = mButton->setTextVerticalAlignment(MAW_ALIGNMENT_BOTTOM);
	printf("result setTextVerticalAlignment = %d", result);

	result = mButton->setTextHorizontalAlignment(MAW_ALIGNMENT_RIGHT);
	printf("result setTextHorizontalAlignment = %d", result);

	result = mButton->setFontColor(0xFF0000);
	printf("result setFontColor = %d", result);

    result = mButton->setFontSize(15.9);
    printf("result setFontSize = %d", result);

	// Print number of available fonts.
	int fontsCount = maFontGetCount();
	Label* nrFontsLabel = new Label();

	nrFontsLabel->setText(MAUtil::integerToString(fontsCount) + " fonts available.");
	nrFontsLabel->setFontColor(0xFF0000);
	mMainLayout->addChild(nrFontsLabel);

	// Get the first font
	char buf[256];
	maFontGetName(0, buf, 256);
	Label* fontLoadedName = new Label();
	// Print the name of the font
	fontLoadedName->setText(buf);
	fontLoadedName->setFontColor(0xFF0000);
	mMainLayout->addChild(fontLoadedName);

	// Load the font with size 10 and get a handle.
	int fontHandle = maFontLoadWithName(buf, 10);

	// Set the handle to a label
	mTestFontLabel = new Button();
	mTestFontLabel->setText("Test for this font!");
	mTestFontLabel->setFontColor(0xFF0000);
	mTestFontLabel->setFont(fontHandle);
	mMainLayout->addChild(mTestFontLabel);

	mEvents = new ListView();
	mEvents->fillSpaceHorizontally();
	mEvents->fillSpaceVertically();
	mMainLayout->addChild(mEvents);
}
Exemple #4
0
/**
 * Creates and adds main layout to the screen.
 */
void MainScreen::createMainLayout() {
	// Create and add the main layout to the screen.
	mMainLayout = new VerticalLayout();
	mMainLayout->setBackgroundColor(0x9BCD9B);
	Screen::setMainWidget(mMainLayout);

	mLabel = new Label();
	mMainLayout->addChild(mLabel);

	mLabel->setText("this is a label! 2 this is a label! 3 this is a label! 4 this is a label!");
	mLabel->setFontColor(0xFF0000);
	mLabel->setWidth(50);
	mLabel->setMaxNumberOfLines(2);
	int result = mLabel->getMaxNumberOfLines();
	printf("result getMaxNumberOfLines = %d", result);

	// Print number of available fonts.
	int fontsCount = maFontGetCount();
	nrFontsLabel = new Label();

	nrFontsLabel->setText(MAUtil::integerToString(fontsCount) + " fonts available.");
	nrFontsLabel->setFontColor(0xFF0000);
	mMainLayout->addChild(nrFontsLabel);

	// Get the first font
	char buf[256];
	maFontGetName(0, buf, 256);
	fontLoadedName = new Label();
	// Print the name of the font
	fontLoadedName->setText(buf);
	fontLoadedName->setFontColor(0xFF0000);
	mMainLayout->addChild(fontLoadedName);

	// Load the font with size 10 and get a handle.
	int fontHandle = maFontLoadWithName(buf, 10);

	// Set the handle to a label
	testFontLabel = new Label();
	testFontLabel->setText("Test for this font!");
	testFontLabel->setFontColor(0xFF0000);
	testFontLabel->setFont(fontHandle);
	mMainLayout->addChild(testFontLabel);

}