/*************************************************************
 * Function: animateDices ()                                 *
 * Date Created: September 29, 2012                          *
 * Date Last Modified: September 29, 2012                    *
 * Description: This function simulates the two dices being  *
 *              rolled and prints out random dices on screen *
 * Input parameters: values for die one and die two          *
 * Returns: void                                             *
 * Preconditions: Random function is working properly and    *
 *                values for die one and two to be received  *
 *                were randomly selected. Windows.h must be  *
 *                included for Sleep () and Beep ()          *
 * Postconditions: Outputs selected two dices on the screen  *
 *************************************************************/
void animateDices (int dieOne, int dieTwo)
{
	int i = 0;	   /* counter */

	for (i = 0; i < DICE_NUMBER_OF_ROTATION; i++)
	{
		/* Clears the screen */
		system ("cls");

		/* Prints the title on top of the screen */
		printTitle ();

		/* Outputs 2 simulated dice on the screen 
		   based from the generated random number */
		drawDie (getRandomNumber (6));
		printf ("\n");
		drawDie (getRandomNumber (6));

		/* Makes a beep sound */
		Beep (523, 300);

		/* Pauses the program */
		Sleep (300);
	}

	system ("cls");
	printTitle ();

	drawDie (dieOne);
	printf ("\n");
	drawDie (dieTwo);
	printf ("\n");

	Beep (659, 200);
}
Example #2
0
void printTeamFull(void)
{
	char i, encre, a;
	cls();
	ink(eencre[ville-1]);
	// affichage des titres
	printTitle(8,2, A_BGRED, " * TYRANN 3 - EQUIPE * ", 23);
	printTitle(2,4, A_BGRED, "PERSONNAGES MAISON    CARRIERE NIV ", 35);
	printTitle(2,5, A_BGBLUE, " Argent      CC CT Fo Ag In FM PV  ", 35);
	// affichage persos
	for(i=0;i<6;i++) {
		switch(characters[i].cp) {
			case 1:
				encre = A_FWYELLOW; // jaune
				break;
			case 2:
				encre = A_FWWHITE; // blanc
				break;
			case 3:
				encre = A_FWCYAN; // cyan
				break;
			case 4:
				encre = A_FWMAGENTA; // magenta
				break;
			case 5:
				encre = A_FWBLUE; // bleu
				break;
			default:
				encre = A_FWGREEN; // bleu		
		}
		attribAtXY(1,7+3*i,encre);
		printAtXY (3,7+3*i, itoa(i+1));
		printAtXY (5,7+3*i, characters[i].nom);		
		if (characters[i].mp != 1) printAtXY (17,7+3*i, maisons[characters[i].mp-2]);		
		printAtXY (27,7+3*i, classe[characters[i].cp-1]);
		printAtXY (37,7+3*i, itoa(characters[i].ni));
		printAtXY (6,7+3*i+1, itoa(characters[i].ri*10));
		printAtXY (13,7+3*i+1, "ca");
		printAtXY (18,7+3*i+1, itoa(characters[i].cc));
		printAtXY (21,7+3*i+1, itoa(characters[i].ct));
		printAtXY (24,7+3*i+1, itoa(characters[i].fo));
		printAtXY (27,7+3*i+1, itoa(characters[i].ag));
		printAtXY (30,7+3*i+1, itoa(characters[i].in));
		printAtXY (33,7+3*i+1, itoa(characters[i].fm));
		printAtXY (36,7+3*i+1, itoa(characters[i].pv));
	}
	printTitle(2,25, A_BGBLUE, " Argent      CC CT Fo Ag In FM PV  ", 35);
	printTitle(2,26, A_BGRED, "            < ESPACE >            ", 34);
	while(1) {
		a = get();
		if (a==' ') {
			break;
		} else
			ping();
	}
}
Example #3
0
QString MultiModelPrinter::printMixers()
{
  QString str = printTitle(tr("Mixers"));
  MultiColumns columns(models.size());
  columns.append("<table cellspacing='0' cellpadding='1' width='100%' border='0' style='border-collapse:collapse'>");
  for (int i=0; i<firmware->getCapability(Outputs); i++) {
    int count = 0;
    for (int k=0; k<models.size(); k++) {
      count = std::max(count, models[k]->mixes(i).size());
    }
    if (count > 0) {
      columns.append("<tr><td width='20%'><b>");
      COMPARE(modelPrinter->printMixerName(i+1));
      columns.append("</b></td><td>");
      for (int j=0; j<count; j++) {
        if (j > 0)
          columns.append("<br/>");
        COMPARE((j < model->mixes(i).size()) ? modelPrinter->printMixerLine(*model->mixes(i)[j], (j>0)) : "&nbsp;");
      }
      columns.append("</td></tr>");
    }
  }
  str.append(columns.print());
  return str;
}
Example #4
0
QString MultiModelPrinter::printCurves(QTextDocument * document)
{
  QString str;
  MultiColumns columns(models.size());
  int count = 0;
  columns.append("<table cellspacing='0' cellpadding='1' width='100%' border='0' style='border-collapse:collapse'>");
  for (int i=0; i<firmware->getCapability(NumCurves); i++) {
    bool curveEmpty = true;
    for (int k=0; k<models.size(); k++) {
      if (!models[k]->curves[i].isEmpty()) {
        curveEmpty = false;
        break;
      }
    }
    if (!curveEmpty) {
      count++;
      columns.append("<tr><td width='20%'><b>" + tr("CV%1").arg(i+1) + "</b></td><td>");
      COMPARE(modelPrinter->printCurve(i));
      for (int k=0; k<models.size(); k++)
        columns.append(k, QString("<br/><img src='%1' border='0' />").arg(modelPrinters[k]->createCurveImage(i, document)));
      columns.append("</td></tr>");
    }
  }
  columns.append("</table><br/>");
  if (count > 0) {
    str.append(printTitle(tr("Curves")));
    str.append(columns.print());
  }
  return str;
}
Example #5
0
QString MultiModelPrinter::printCustomFunctions()
{
  QString str;
  MultiColumns columns(models.size());
  int count = 0;
  columns.append("<table cellspacing='0' cellpadding='1' width='100%' border='0' style='border-collapse:collapse'>");
  for (int i=0; i<firmware->getCapability(CustomFunctions); i++) {
    bool sfEmpty = true;
    for (int k=0; k<models.size(); k++) {
      if (!modelPrinters[k]->printCustomFunctionLine(i).isEmpty()) {
        sfEmpty = false;
        break;
      }
    }
    if (!sfEmpty) {
      count++;
      columns.append("<tr><td width='20%'><b>" + tr("SF%1").arg(i+1) + "</b></td><td>");
      COMPARE(modelPrinter->printCustomFunctionLine(i));
      columns.append("</td></tr>");
    }
  }
  columns.append("</table>");
  if (count > 0) {
    str.append(printTitle(tr("Special Functions")));
    str.append(columns.print());
  }
  return str;
}
Example #6
0
void main() {
	const int PS = 3;
	int ls, pid[PS], quantity[PS];
	double price[PS];
	string fileName, productName[PS];
	ifstream readFile;
	ofstream writeFile;
	//----------------------Definition Complete----------------------//
	printTitle();

	cout << "\nWhat file contains your inventory data? ";
	fileName = getAcceptableName (fileName);
	loadFileToRead (fileName, readFile);
//----------------------Load File Complete----------------------//
	cout << "\nInput file " << fileName << " successfully opened.\n";
	ls = loadArray(readFile, productName, pid, quantity, price, PS);  
	readFile.close();

	cout << "I got " << ls << " items.\n\n\n";
	printSummary(productName, pid, quantity, price, ls);  
	printStats(productName, quantity, price, ls);

	cout << "\n\n\nDo you want this info to be saved in a file? ";
	if ( getYOrN() == 'Y' ) {
		cout << "\nWhere do you want this report to go to? ";
		fileName = getAcceptableName(fileName, " OUT.TXT");
		loadFileToWrite(fileName, writeFile);
		printSummary(productName, pid, quantity, price, ls, writeFile);    
		printStats(productName, quantity, price, ls, writeFile);  
		writeFile.close();
		cout << "\nYour report can be found in " << fileName << endl;
	}
	cout << "\n\nHit ENTER to end the program...";
	cin.get();
}
Example #7
0
//--------------主要程式碼(Main Code)--------------
//main函數架構
//版本:1.00(11)
//軟體的運行從main函數開始
//void會使debugger無法啟動!
int main(void)
{   restartProgram:
    //宣告與定義(Declaration & Definition)
    //define input
    float numf;
    //---------------------
    //call print title function
    printTitle();
    //提示輸入
    //版本:1.00(1)
    printf("請輸入一個實數:");
    scanfTriggered = 1;
    scanf("%f", &numf);
    //output
    printf("它的三倍是 %.3f。 ", numf * 3);
    //pauseProgram
    if(pauseProgram())
    {
        goto restartProgram;
    }
    //---------------------
    //傳回數字0(表程式運行成功)
    //版本:1.00(1)
    //return後面不可加註解!
    return 0;
}
Example #8
0
QString MultiModelPrinter::printLimits()
{
  QString str = printTitle(tr("Limits"));
  MultiColumns columns(models.size());
  columns.append("<table border='0' cellspacing='0' cellpadding='1' width='100%'>" \
                 "<tr>" \
                 " <td><b>" + tr("Channel") + "</b></td>" \
                 " <td><b>" + (firmware->getCapability(ChannelsName) > 0 ? tr("Name") : "") + "</b></td>" \
                 " <td><b>" + tr("Offset") + "</b></td>" \
                 " <td><b>" + tr("Min") + "</b></td>" \
                 " <td><b>" + tr("Max") + "</b></td>" \
                 " <td><b>" + tr("Invert") + "</b></td>" \
                 "</tr>");
  for (int i=0; i<firmware->getCapability(Outputs); i++) {
    columns.append("<tr><td><b>");
    COMPARE(modelPrinter->printChannelName(i));
    columns.append("</b></td><td>");
    COMPARE(modelPrinter->printOutputName(i));
    columns.append("</td><td>");
    COMPARE(model->limitData[i].offsetToString());
    columns.append("</td><td>");
    COMPARE(model->limitData[i].minToString());
    columns.append("</td><td>");
    COMPARE(model->limitData[i].maxToString());
    columns.append("</td><td>");
    COMPARE(model->limitData[i].revertToString());
    columns.append("</td></tr>");
  }
  columns.append("</table>");
  str.append(columns.print());
  return str;
}
//**************************************************************************
// Function:   printhtml
// Scope:      global
// Purpose:    prints in standard output an html
// Return:     -
//**************************************************************************
void printhtml(std::string& sDir, int iLanguage) {
   printHead(iLanguage);
   printTitle(sDir, iLanguage);
   printTitleAuthor(iLanguage);
   std::cout << "</tr>" << std::endl;

   for (int n = 0; n < vBooks.size(); n++) {
      // printing 
      std::string sNewFileName="";
      replaceName(vBooks[n].sFile, sNewFileName);
      std::cout << "<tr>" << std::endl
                << "<td>" 
                << "<A HREF=\"" << "books" << '/' << sDir << '/' << sNewFileName << "\">"
                << vBooks[n].sFileType
                << "</A>" 
                << "</td>" 
                << "<td align=" << '"' << "right" << '"' << '>';
      std::cout << vBooks[n].st_size/1024;
      std::cout << "</td>"
                << "<td>" << vBooks[n].sBook << "</td>" 
                << "<td>" << vBooks[n].sAuthors << "</td>" 
                << std::endl
                << "</tr>" << std::endl;
   }

   std::cout << "</table>" << std::endl;
   printFoot();
}
int CommonView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 9)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 9;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< Interval*>(_v) = interval(); break;
        case 1: *reinterpret_cast< ProtConf*>(_v) = getProtSubmit(); break;
        case 2: *reinterpret_cast< bool*>(_v) = showSource(); break;
        case 3: *reinterpret_cast< bool*>(_v) = selectParamsEnabled(); break;
        case 4: *reinterpret_cast< QString*>(_v) = dateTimeFormat(); break;
        case 5: *reinterpret_cast< QFont*>(_v) = font(); break;
        case 6: *reinterpret_cast< QString*>(_v) = printTitle(); break;
        case 7: *reinterpret_cast< QFont*>(_v) = printTitleFont(); break;
        case 8: *reinterpret_cast< QFont*>(_v) = printFont(); break;
        case 9: *reinterpret_cast< bool*>(_v) = getSaveChanges(); break;
        }
        _id -= 10;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setInterval(*reinterpret_cast< Interval*>(_v)); break;
        case 1: setProtConf(*reinterpret_cast< ProtConf*>(_v)); break;
        case 2: setShowSource(*reinterpret_cast< bool*>(_v)); break;
        case 3: setSelectParamsEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 4: setDateTimeFormat(*reinterpret_cast< QString*>(_v)); break;
        case 5: setFont(*reinterpret_cast< QFont*>(_v)); break;
        case 6: setPrintTitle(*reinterpret_cast< QString*>(_v)); break;
        case 7: setPrintTitleFont(*reinterpret_cast< QFont*>(_v)); break;
        case 8: setPrintFont(*reinterpret_cast< QFont*>(_v)); break;
        case 9: setSaveChanges(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 10;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 10;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #11
0
void DebugReportSection::printContent(std::ostream& out) const {
    printTitle(out);
    out << "<div style='padding-left: 1em'>\n";
    out << body << "\n";
    for (const DebugReportSection& subsection : subsections) {
        subsection.printContent(out);
    }
    out << "</div>\n";
}
/*************************************************************
 * Function: printGameRules ()                               *
 * Date Created: September 29, 2012                          *
 * Date Last Modified: September 30, 2012                    *
 * Description: This function clears the screen then jprints *
 *              the title of the game and prints the rules   *
 *              on how to play the game.                     *
 * Input parameters: void                                    *
 * Returns: void                                             *
 * Preconditions: system () is part of the compiler's        *
 *                library and user using Windows OS          *
 * Postconditions: User understand the rules of the game     *
 *************************************************************/
void printGameRules (void)
{
	system ("cls");
	printTitle ();
	printf ("              HOW TO PLAY\n");
	printf ("> Player rolls two dice\n");
	printf ("> After the dice have come to rest, the\n  sum of the spots on the two upward faces\n  is calculated.\n");
	printf ("> If the sum is 7 or 11 on the first throw,\n  the PLAYER WINS!\n");
	printf ("> If the sum is 2, 3 or 12 on the first\n  throw, CRAPS... The PLAYER LOSES!\n");
	printf ("> If the sum is 4, 5, 6, 8, 9, or 10 on\n  the first throw, then the sum becomes\n  the PLAYER'S POINT.\n");
	printf ("> To win, you must continue rolling the\n  dice until you make your POINT. The\n  player loses by rolling a 7 before\n  making the point.\n");
	printf ("       <Press ENTER to continue>");
	pressEnter ();
}
Example #13
0
//--------------主要程式碼(Main Code)--------------
//main函數架構
//版本:1.00(11)
//軟體的運行從main函數開始
//void會使debugger無法啟動!
int main(void)
	{restartProgram:
	//宣告與定義(Declaration & Definition)


	//---------------------
	//print title
		printTitle();
	//第一題
		printf("第一題(25分)\n-------------------\n");
		q1main();
		printf("-------------------\n");
	//第二題
		printf("第二題(8分)\n-------------------\n");
		q2main();
		printf("-------------------\n");
	//第三題
		printf("第三題(12分)\n-------------------\n");
		q3main();
		printf("-------------------\n");
	//第四題
		printf("第四題(10分)\n-------------------\n");
		q4main();
		printf("-------------------\n");
	//第五題
		printf("第五題\n-------------------\n");
		if(q5main() == 0)
			{
					printf("\n您的電腦隨機存取記憶體(RAM)可用空間不足,無法演示第五題\n請減少原始碼中PERSONTOTAL常數之大小\n");
					printf("\n答案請參閱原始碼\n");
					printf("-------------------\n");
			}
	//第六題
		printf("第六題(15分)\n-------------------\n");
		q6main();
		//printf("-------------------\n");

	//pauseProgram
		if(pauseProgram() == 1)
			{
				goto restartProgram;
			}
	////pauseProgram
	//---------------------
		//傳回數字0(表程式運行成功)
		//版本:1.00(1)
		//return後面不可加註解!
			return 0;
	}
Example #14
0
int main(void)
{
    int ch;
    initscr();
    atexit(quit);
    start_color();
    clear();
    noecho();
    curs_set(0);
    cbreak();
    nl();
    keypad(stdscr, TRUE);

    //set stdscr red
    init_pair(1, COLOR_BLACK, COLOR_RED);
    bkgd(COLOR_PAIR(1));
//
    refresh();
    loadConfig("config.cfg");
    clear();
    getmaxyx(stdscr,y,x);

    box(stdscr,0,0);
    if (y > 30 && configFile::getInstance()->getContents("printLogo") != "false")
    {
        titleWin = newwin(7,x-2,1,1);
        pluginWin = newwin(y-2-7,x-2,8,1);
        box(titleWin,0,0);
        printTitle();
    }
    else
        pluginWin = stdscr;

    box(pluginWin,0,0);



    refresh();
    if (titleWin != NULL)
        wrefresh(titleWin);

    wrefresh(pluginWin);


    listModules();


    return (0);
}
/*************************************************************
 * Function: printMenu ()                                    *
 * Date Created: September 29, 2012                          *
 * Date Last Modified: September 30, 2012                    *
 * Description: This function clears the screen and prints   *
 *              the title and awaits user to pick a menu     *
 *              item. Input error check implemented.         *
 * Input parameters: void                                    *
 * Returns: menu item chosen, 1 to start new game, 2 to      *
 *          show rules of the game & 3 to exit game          *
 * Preconditions: system () is part of the compiler's        *
 *                library and user using Windows OS          *
 * Postconditions: menu item chosen returned                 *
 *************************************************************/
char printMenu (void)
{
	char option = '\0';    /* menu option */

	do {
		system ("cls");
		printTitle ();
		printf ("       [ 1 ] START A NEW GAME\n");
		printf ("       [ 2 ] HOW TO PLAY CRAPS\n");
		printf ("       [ 3 ] EXIT GAME\n\n");
		printf ("       CHOOSE OPTION: ");
		option = getchar ();
	} while (option < '1' || option > '3');

	return option;
}
//Print out statistics every second
void statsLoop(struct config* config) {
  pthread_mutex_lock(&stats_lock);
  gettimeofday(&start_time, NULL);
  pthread_mutex_unlock(&stats_lock);

  sleep(2);
  printf("Stats:\n");
  printf("-------------------------\n");
  printTitle();
  while(1) {
    printGlobalStats(config);
    sleep(config->stats_time);
  }//End while()


}//End statisticsLoop()
Example #17
0
void camping(void)
{
	char i, encre, a;
	char *ptr;
	while(1) {
		text();cls();
		ptr = (char*)0x26a; *ptr = *ptr & 254; // Vire le curseur 
		ink(eencre[ville-1]);
		printFrame(15);
		printTitle(8,2, A_BGRED, "<  ++ CAMPEMENT ++  >", 21);
		printAtXY(9,6, "1. Inspecter un heros");
		printAtXY(9,8, "2. Visualiser l'equipe");
		if (ca>20 && ca<29)
			printAtXY(9,10, "3. Ouvrir un coffre");
		printAtXY(9,12,"4. Se reposer");
		printAtXY(13,16,"5. Lever le camp");
		// affichage équipe
		printTeam();
		a = get();
		switch(a) {
			case '1':
				inspect();
				break;
			case '2':
				printTeamFull();
				break;
			case '3':
				if (ca>20 && ca<29)
					chest();
				break;
			case '4':
				sleep();
				break;
			case '5':
				cls();
				printAtXY(8,10, "Bon voyage !");
				wait(150);
				return;
				break;
			default:
				ping();
				break;	
		}
		//attribAtXY(3,0,a);
	}
	
}
Example #18
0
QString MultiModelPrinter::printGvars()
{
  QString str = printTitle(tr("Global Variables"));
  int gvars = firmware->getCapability(Gvars);
  MultiColumns columns(models.size());
  columns.append("<table border='0' cellspacing='0' cellpadding='1' width='100%'><tr>");
  for (int i=0; i<gvars; i++) {
    columns.append(QString("<td><b>") + tr("GV%1").arg(i+1) + "</b></td>");
  }
  columns.append("</tr><tr>");
  for (int i=0; i<gvars; i++) {
    columns.append("<td>");
    COMPARE(model->flightModeData[0].gvars[i]);
    columns.append("</td>");
  }
  columns.append("</tr>");
  str.append(columns.print());
  return str;
}
/*************************************************************
 * Function: getBankBalance ()                               *
 * Date Created: September 29, 2012                          *
 * Date Last Modified: September 30, 2012                    *
 * Description: This function prompts player to enter a      *
 *              amount in the bank                           *
 * Input parameters: void                                    *
 * Returns: value indicating amount of money in the bank     *
 * Preconditions: None                                       *
 * Postconditions: Bank balance returned                     *
 *************************************************************/
double getBankBalance (void)
{
	double initBankBalance = 0.0;	/* initial bank balance */

	printTitle ();

	while (TRUE)
	{
		printf ("Enter Initial Bank Balance: $");
		scanf ("%lf", &initBankBalance);

		/* Checks that amount is not less than or equal to zero */
		if (initBankBalance > 0) 
			break;
		else 
			printf ("ERROR: %s, Try Again!\n", ERROR_2); 
	}

	return initBankBalance;
}
Example #20
0
//the core loop of the application keep running until the user types q
void run(void) {
    
	_generation = 0;
	char input;
    
	do {
        
		printTitle();
		drawMatrix();
        
		input = getchar();
        
		clearScreen();
		update();
        
		_generation++;
        
	} while (input != 'q' && input != 'Q');
    
}
/*************************************************************
 * Function: playAgain ()                                    *
 * Date Created: September 29, 2012                          *
 * Date Last Modified: September 30, 2012                    *
 * Description: This function prints out the current balance *
 *              and prompts player to play more or not.      *
 * Input parameters: player's current balance on hand        *
 * Returns: status indicator, 1 for play more & 0 otherwise  *
 * Preconditions: current balance is not equal to zero,      *
 *                function should not be called if player    *
 *                does not have any money on hand            *
 * Postconditions: Status indicator returned                 *
 *************************************************************/
int playAgain (double currentBalance)
{
	char ch = '\0';        /* input for Y/N option */
	int playMore = -1;	   /* status indicator to play again */

	do {
		/* clears the screen */
		system ("cls");

		/* prints title on top of the screen */
		printTitle ();

		/* prints current balance */
		printf ("Current Balance: $%.2lf\n", currentBalance);

		/* prompts user if he wants to play more or not */
		printf ("Do you want to play more (Y/N)? ");
		fflush (stdin);  /* flushes previous escape characters */
		scanf ("%c", &ch);

		if (ch == 'y' || ch == 'Y')
		{
			/* indicates player chooses to play more */
			playMore = TRUE;
		}
		else if (ch == 'n' || ch == 'N')
		{
			/* indicates player doesn't want to play any more */
			playMore = FALSE;
		}
		else
		{
			/* warns user of invalid input */
			printf ("Invalid Input! Press ENTER to continue.\n");
			pressEnter ();
		}

	} while (playMore == -1);

	return playMore;
}
Example #22
0
QString MultiModelPrinter::printTelemetry()
{
  QString str = printTitle(tr("Telemetry Settings"));

  // Analogs on non ARM boards
  if (!IS_ARM(firmware->getBoard())) {
    MultiColumns columns(models.size());
    columns.append("<table border='0' cellspacing='0' cellpadding='1' width='100%'>" \
                   "<tr><td width='22%'><b>" + tr("Analogs") + "</b></td><td width='26%'><b>" + tr("Unit") + "</b></td><td width='26%'><b>" + tr("Scale") + "</b></td><td width='26%'><b>" + tr("Offset") + "</b></td></tr>");
    for (int i=0; i<2; i++) {
      columns.append("<tr><td><b>"+tr("A%1").arg(i+1)+"</b></td><td>");
      COMPARE(getFrSkyUnits(model->frsky.channels[i].type));
      columns.append("</td><td>");
      COMPARE(QString::number((model->frsky.channels[i].ratio / (model->frsky.channels[i].type==0 ? 10.0 : 1)), 10, (model->frsky.channels[i].type==0 ? 1 : 0)));
      columns.append("</td><td>");
      COMPARE(QString::number((model->frsky.channels[i].offset*(model->frsky.channels[i].ratio / (model->frsky.channels[i].type==0 ?10.0 : 1)))/255, 10, (model->frsky.channels[i].type==0 ? 1 : 0)));
      columns.append("</td></tr>");
    }
    columns.append("</table><br/>");
    str.append(columns.print());
    // TODO I remove the analogs alarms for now
  }

  // RSSI alarms
  {
    MultiColumns columns(models.size());
    columns.append("<table border='0' cellspacing='0' cellpadding='1' width='100%'>");
    for (int i=0; i<2; i++) {
      columns.append("<tr><td><b>" + QString(i==0 ? tr("RSSI Alarms") : "") + "</b></td><td>");
      COMPARE(getFrSkyAlarmType(model->frsky.rssiAlarms[i].level));
      columns.append("</td><td>&lt;</td><td>");
      COMPARE(QString::number(model->frsky.rssiAlarms[i].value, 10));
      columns.append("</td></tr>");
    }
    columns.append("</table><br/>");
    str.append(columns.print());
  }
  
  return str;
}
Example #23
0
QString MultiModelPrinter::printSetup()
{
  QString str = printTitle(tr("General Model Settings"));

  MultiColumns columns(models.size());
  columns.appendTitle(tr("Name:"));
  COMPARE(model->name);
  columns.append("<br/>");
  columns.appendTitle(tr("EEprom Size:"));
  COMPARE(modelPrinter->printEEpromSize());
  columns.append("<br/>");
  for (int i=0; i<firmware->getCapability(Timers); i++) {
    columns.appendTitle(tr("Timer%1:").arg(i+1));
    COMPARE(modelPrinter->printTimer(i));
    columns.append("<br/>");
  }
  for (int i=0; i<firmware->getCapability(NumModules); i++) {
    columns.appendTitle(firmware->getCapability(NumModules) > 1 ? tr("Module%1:").arg(i+1) : tr("Module:"));
    COMPARE(modelPrinter->printModule(i));
    columns.append("<br/>");
  }
  if (IS_TARANIS(firmware->getBoard())) {
    columns.appendTitle(tr("Trainer port:"));
    COMPARE(modelPrinter->printTrainerMode());
    columns.append("<br/>");
  }
  columns.appendTitle(tr("Throttle Trim:"));
  COMPARE(modelPrinter->printThrottleTrimMode());
  columns.append("<br/>");
  columns.appendTitle(tr("Trim Increment:"));
  COMPARE(modelPrinter->printTrimIncrementMode());
  columns.append("<br/>");
  columns.appendTitle(tr("Center Beep:"));
  COMPARE(modelPrinter->printCenterBeep());
  str.append(columns.print());
  return str;
}
Example #24
0
printDialog::printDialog(QWidget *parent, EEGeneral *gg, SKYModelData *gm) :
    QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
    ui(new Ui::printDialog)
{
    ui->setupUi(this);
    g_model = gm;
    g_eeGeneral = gg;
    te = ui->textEdit;

    setWindowTitle(tr("Setup for: ") + getModelName());
    ui->textEdit->clear();

    printTitle();

    printSetup();
    printExpo();
    printMixes();
    printLimits();
    printCurves();
    printSwitches();
    printSafetySwitches();

    te->scrollToAnchor("1");
}
/*!
  \brief Paint the plot into a given rectangle.
  Paint the contents of a QwtPlot instance into a given rectangle.

  \param painter Painter
  \param plotRect Bounding rectangle
  \param pfilter Print filter
  \sa QwtPlotPrintFilter
*/
void QwtPlot::print(QPainter *painter, const QRect &plotRect,
                    const QwtPlotPrintFilter &pfilter) const
{
    int axisId;

    if ( painter == 0 || !painter->isActive() ||
            !plotRect.isValid() || size().isNull() )
        return;

    painter->save();
#if 1
    /*
      PDF: In Qt4 ( <= 4.3.2 ) the scales are painted in gray instead of
      black. See http://trolltech.com/developer/task-tracker/index_html?id=184671&method=entry
      The dummy lines below work around the problem.
     */
    const QPen pen = painter->pen();
    painter->setPen(QPen(Qt::black, 1));
    painter->setPen(pen);
#endif

    // All paint operations need to be scaled according to
    // the paint device metrics.

    QwtPainter::setMetricsMap(this, painter->device());
    const QwtMetricsMap &metricsMap = QwtPainter::metricsMap();

    // It is almost impossible to integrate into the Qt layout
    // framework, when using different fonts for printing
    // and screen. To avoid writing different and Qt unconform
    // layout engines we change the widget attributes, print and
    // reset the widget attributes again. This way we produce a lot of
    // useless layout events ...

    pfilter.apply((QwtPlot *)this);

    int baseLineDists[QwtPlot::axisCnt];
    if ( pfilter.options() & QwtPlotPrintFilter::PrintFrameWithScales ) {
        for (axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ) {
            QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId);
            if ( scaleWidget ) {
                baseLineDists[axisId] = scaleWidget->margin();
                scaleWidget->setMargin(0);
            }
        }
    }
    // Calculate the layout for the print.

    int layoutOptions = QwtPlotLayout::IgnoreScrollbars
                        | QwtPlotLayout::IgnoreFrames;
    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintMargin) )
        layoutOptions |= QwtPlotLayout::IgnoreMargin;
    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintLegend) )
        layoutOptions |= QwtPlotLayout::IgnoreLegend;

    ((QwtPlot *)this)->plotLayout()->activate(this,
            QwtPainter::metricsMap().deviceToLayout(plotRect),
            layoutOptions);

    if ((pfilter.options() & QwtPlotPrintFilter::PrintTitle)
            && (!titleLabel()->text().isEmpty())) {
        printTitle(painter, plotLayout()->titleRect());
    }

    if ( (pfilter.options() & QwtPlotPrintFilter::PrintLegend)
            && legend() && !legend()->isEmpty() ) {
        printLegend(painter, plotLayout()->legendRect());
    }

    for ( axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ) {
        QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId);
        if (scaleWidget) {
            int baseDist = scaleWidget->margin();

            int startDist, endDist;
            scaleWidget->getBorderDistHint(startDist, endDist);

            printScale(painter, axisId, startDist, endDist,
                       baseDist, plotLayout()->scaleRect(axisId));
        }
    }

    QRect canvasRect = plotLayout()->canvasRect();

    /*
       The border of the bounding rect needs to ba scaled to
       layout coordinates, so that it is aligned to the axes
     */
    QRect boundingRect( canvasRect.left() - 1, canvasRect.top() - 1,
                        canvasRect.width() + 2, canvasRect.height() + 2);
    boundingRect = metricsMap.layoutToDevice(boundingRect);
    boundingRect.setWidth(boundingRect.width() - 1);
    boundingRect.setHeight(boundingRect.height() - 1);

    canvasRect = metricsMap.layoutToDevice(canvasRect);

    // When using QwtPainter all sizes where computed in pixel
    // coordinates and scaled by QwtPainter later. This limits
    // the precision to screen resolution. A better solution
    // is to scale the maps and print in unlimited resolution.

    QwtScaleMap map[axisCnt];
    for (axisId = 0; axisId < axisCnt; axisId++) {
        map[axisId].setTransformation(axisScaleEngine(axisId)->transformation());

        const QwtScaleDiv &scaleDiv = *axisScaleDiv(axisId);
        map[axisId].setScaleInterval(scaleDiv.lBound(), scaleDiv.hBound());

        double from, to;
        if ( axisEnabled(axisId) ) {
            const int sDist = axisWidget(axisId)->startBorderDist();
            const int eDist = axisWidget(axisId)->endBorderDist();
            const QRect &scaleRect = plotLayout()->scaleRect(axisId);

            if ( axisId == xTop || axisId == xBottom ) {
                from = metricsMap.layoutToDeviceX(scaleRect.left() + sDist);
                to = metricsMap.layoutToDeviceX(scaleRect.right() + 1 - eDist);
            } else {
                from = metricsMap.layoutToDeviceY(scaleRect.bottom() + 1 - eDist );
                to = metricsMap.layoutToDeviceY(scaleRect.top() + sDist);
            }
        } else {
            int margin = plotLayout()->canvasMargin(axisId);
            if ( axisId == yLeft || axisId == yRight ) {
                margin = metricsMap.layoutToDeviceY(margin);
                from = canvasRect.bottom() - margin;
                to = canvasRect.top() + margin;
            } else {
                margin = metricsMap.layoutToDeviceX(margin);
                from = canvasRect.left() + margin;
                to = canvasRect.right() - margin;
            }
        }
        map[axisId].setPaintXInterval(from, to);
    }

    // The canvas maps are already scaled.
    QwtPainter::setMetricsMap(painter->device(), painter->device());
    printCanvas(painter, boundingRect, canvasRect, map, pfilter);
    QwtPainter::resetMetricsMap();

    ((QwtPlot *)this)->plotLayout()->invalidate();

    // reset all widgets with their original attributes.
    if ( pfilter.options() & QwtPlotPrintFilter::PrintFrameWithScales ) {
        // restore the previous base line dists

        for (axisId = 0; axisId < QwtPlot::axisCnt; axisId++ ) {
            QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId);
            if ( scaleWidget  )
                scaleWidget->setMargin(baseLineDists[axisId]);
        }
    }

    pfilter.reset((QwtPlot *)this);

    painter->restore();
}
Example #26
0
/*!
  \brief Paint the plot into a given rectangle.
  Paint the contents of a QwtPlot instance into a given rectangle.

  \param painter Painter
  \param plotRect Bounding rectangle
  \param pfilter Print filter
  \sa QwtPlotPrintFilter
*/
void QwtPlot::print(QPainter *painter, const QRect &plotRect,
        const QwtPlotPrintFilter &pfilter) const
{
    int axisId;

    if ( painter == 0 || !painter->isActive() ||
            !plotRect.isValid() || size().isNull() )
       return;

    painter->save();

    // All paint operations need to be scaled according to
    // the paint device metrics. 

    QwtPainter::setMetricsMap(this, painter->device());
    const QwtMetricsMap &metricsMap = QwtPainter::metricsMap();

    // It is almost impossible to integrate into the Qt layout
    // framework, when using different fonts for printing
    // and screen. To avoid writing different and Qt unconform
    // layout engines we change the widget attributes, print and 
    // reset the widget attributes again. This way we produce a lot of
    // useless layout events ...

    pfilter.apply((QwtPlot *)this);

    int baseLineDists[QwtPlot::axisCnt];
    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintCanvasBackground) )
    {
        // In case of no background we set the backbone of
        // the scale on the frame of the canvas.

        for (axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
        {
            QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId);
            if ( scaleWidget )
            {
                baseLineDists[axisId] = scaleWidget->baseLineDist();
                scaleWidget->setBaselineDist(0);
            }
        }
    }
    // Calculate the layout for the print.

    int layoutOptions = QwtPlotLayout::IgnoreScrollbars 
        | QwtPlotLayout::IgnoreFrames;
    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintMargin) )
        layoutOptions |= QwtPlotLayout::IgnoreMargin;
    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintLegend) )
        layoutOptions |= QwtPlotLayout::IgnoreLegend;

    ((QwtPlot *)this)->plotLayout()->activate(this, 
        QwtPainter::metricsMap().deviceToLayout(plotRect), 
        layoutOptions);

    if ((pfilter.options() & QwtPlotPrintFilter::PrintTitle)
        && (!titleLabel()->text().isEmpty()))
    {
        printTitle(painter, plotLayout()->titleRect());
    }

    if ( (pfilter.options() & QwtPlotPrintFilter::PrintLegend)
        && legend() && !legend()->isEmpty() )
    {
        printLegend(painter, plotLayout()->legendRect());
    }

    for ( axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
    {
        QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId);
        if (scaleWidget)
        {
            int baseDist = scaleWidget->baseLineDist();

            int startDist, endDist;
            scaleWidget->getBorderDistHint(startDist, endDist);

            printScale(painter, axisId, startDist, endDist,
                baseDist, plotLayout()->scaleRect(axisId));
        }
    }

    const QRect canvasRect = metricsMap.layoutToDevice(plotLayout()->canvasRect());

    // When using QwtPainter all sizes where computed in pixel
    // coordinates and scaled by QwtPainter later. This limits
    // the precision to screen resolution. A much better solution
    // is to scale the maps and print in unlimited resolution.

    QwtArray<QwtScaleMap> map(axisCnt);
    for (axisId = 0; axisId < axisCnt; axisId++)
    {
        map[axisId].setTransformation(axisScaleEngine(axisId)->transformation());

        const QwtScaleDiv &scaleDiv = *axisScaleDiv(axisId);
        map[axisId].setScaleInterval(scaleDiv.lBound(), scaleDiv.hBound());

        double from, to;
        if ( axisEnabled(axisId) )
        {
            const int sDist = axisWidget(axisId)->startBorderDist();
            const int eDist = axisWidget(axisId)->endBorderDist();
            const QRect &scaleRect = plotLayout()->scaleRect(axisId);

            if ( axisId == xTop || axisId == xBottom )
            {
                from = metricsMap.layoutToDeviceX(scaleRect.left() + sDist);
                to = metricsMap.layoutToDeviceX(scaleRect.right() - eDist);
            }
            else
            {
                from = metricsMap.layoutToDeviceY(scaleRect.bottom() - sDist);
                to = metricsMap.layoutToDeviceY(scaleRect.top() + eDist);
            }
        }
        else
        {
            const int margin = plotLayout()->canvasMargin(axisId);

            const QRect &canvasRect = plotLayout()->canvasRect();
            if ( axisId == yLeft || axisId == yRight )
            {
                from = metricsMap.layoutToDeviceX(canvasRect.bottom() - margin);
                to = metricsMap.layoutToDeviceX(canvasRect.top() + margin);
            }
            else
            {
                from = metricsMap.layoutToDeviceY(canvasRect.left() + margin);
                to = metricsMap.layoutToDeviceY(canvasRect.right() - margin);
            }
        }
        map[axisId].setPaintXInterval(from, to);
    }


    // The canvas maps are already scaled. 
    QwtPainter::setMetricsMap(painter->device(), painter->device());

    printCanvas(painter, canvasRect, map, pfilter);

    QwtPainter::resetMetricsMap();

    ((QwtPlot *)this)->plotLayout()->invalidate();

    // reset all widgets with their original attributes.
    if ( !(pfilter.options() & QwtPlotPrintFilter::PrintCanvasBackground) )
    {
        // restore the previous base line dists

        for (axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
        {
            QwtScaleWidget *scaleWidget = (QwtScaleWidget *)axisWidget(axisId);
            if ( scaleWidget  )
                scaleWidget->setBaselineDist(baseLineDists[axisId]);
        }
    }

    pfilter.reset((QwtPlot *)this);

    painter->restore();
}
Example #27
0
QString MultiModelPrinter::printFlightModes()
{
  QString str = printTitle(tr("Flight modes"));

  // Trims
  {
    MultiColumns columns(models.size());
    columns.append("<table cellspacing='0' cellpadding='1' width='100%' border='0' style='border-collapse:collapse'>");
    columns.append("<tr>");
    columns.append("<td><b>" + tr("Flight mode") + "</b></td>");
    columns.append("<td><b>" + tr("Switch") + "</b></td>");
    columns.append("<td><b>" + tr("Fade IN") + "</b></td>");
    columns.append("<td><b>" + tr("Fade OUT") + "</b></td>");
    for (int i=0; i<NUM_STICKS; i++) {
      columns.append("<td><b>" + AnalogString(i) + " trim</b></td>");
    }
    columns.append("</tr>");

    for (int i=0; i<firmware->getCapability(FlightModes); i++) {
      columns.append("<tr><td><b>" + tr("FM%1").arg(i) + "</b>&nbsp;");
      COMPARE(model->flightModeData[i].name);
      columns.append("</td><td>");
      COMPARE(model->flightModeData[i].swtch.toString());
      columns.append("</td><td>");
      COMPARE(model->flightModeData[i].fadeIn);
      columns.append("</td><td>");
      COMPARE(model->flightModeData[i].fadeOut);
      columns.append("</td>");
      for (int k=0; k<NUM_STICKS; k++) {
        columns.append("<td>");
        COMPARE(modelPrinter->printTrim(i, k));
        columns.append("</td>");
      }
      columns.append("</tr>");
    }

    columns.append("</table>");
    str.append(columns.print());
  }

  // GVars and Rotary Encoders
  int gvars = firmware->getCapability(Gvars);
  if ((gvars && firmware->getCapability(GvarsFlightModes)) || firmware->getCapability(RotaryEncoders)) {
    MultiColumns columns(models.size());
    columns.append("<table cellspacing='0' cellpadding='1' width='100%' border='0' style='border-collapse:collapse'>");
    columns.append("<tr><td><b>" + tr("Flight mode") + "</b></td>");
    if (firmware->getCapability(GvarsFlightModes)) {
      for (int i=0; i<gvars; i++) {
        columns.append("<td><b>" + tr("GV%1").arg(i+1) + "</b><br/>");
        COMPARE(model->gvars_names[i]);
        columns.append("</td>");
      }
    }
    for (int i=0; i<firmware->getCapability(RotaryEncoders); i++) {
      columns.append("<td><b>" + tr("RE%1").arg(i+1) + "</b></td>");
    }
    columns.append("</tr>");
    for (int i=0; i<firmware->getCapability(FlightModes); i++) {
      columns.append("<tr><td><b>" + tr("FM%1").arg(i) + "</b>&nbsp;");
      COMPARE(model->flightModeData[i].name);
      columns.append("</td>");
      if (firmware->getCapability(GvarsFlightModes)) {
        for (int k=0; k<gvars; k++) {
          columns.append("<td>");
          COMPARE(modelPrinter->printGlobalVar(i, k));
          columns.append("</td>");
        }
      }
      for (int k=0; k<firmware->getCapability(RotaryEncoders); k++) {
        columns.append("<td>");
        COMPARE(modelPrinter->printRotaryEncoder(i, k));
        columns.append("</td>");
      }
      columns.append("</tr>");
    }
    columns.append("</table>");
    str.append(columns.print());
  }

  return str;
}
Example #28
0
int main()
{
	//prototypes for main
    void printTitle(), setGridSize(), clearGrid(int grid[column_size][row_size]), playerTurn(int player, int grid[column_size][row_size]);
    int checkWinner(int grid[column_size][row_size]), continueGame();
	
	//variable initilisation.
	int player, winner;

    printTitle();
		
		do
    	{
			//construction of new game
            player = 1; //resets player
			winner = 0; // resets winner
    		setGridSize();
    		int grid[column_size][row_size]; // constructs grid
            clearGrid(grid); // sets all grid values to 0
    		clearScreen();

			//game plays out inside until winner or draw.
    		while(winner == 0)
    		{

    			playerTurn(player, grid);
    			winner = checkWinner(grid);
    			if(winner == 0) 
				{
					//switches player
    				if(player == 1)
					{
    					player = 2;
					}
    				else
					{
    					player = 1;
					}
				}
    			else
    			{
						//clears screen and prints grid between turns.
    		        	clearScreen();
                        printGrid(grid);
                        spacer(); //spacer called repeatedly to move print to center of console
    					printf("\n\n");
    					spacer();
						
    				if(winner != 3) //checks if winner was a player or a draw. A winner of '3' is a draw
					{
                        printf("Winner is Player %d!!!", winner);
					}
                    else
					{
                        printf("Draw!!!");
					}
                }
    		}
		//starts a new game if true
    	}while(continueGame());

		return(0);
}
Example #29
0
void menu(void)
{
		settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);		//set text style for the options
		setcolor(WHITE);					//set colour for the fonts
		outtextxy(60,150,"1) RESULT MENU");	//setting the position and the font
		outtextxy(60,210,"2) ENTRY/EDIT MENU");		//setting the position and the font
		outtextxy(60,270,"3) EXIT");			//setting the position and the font

	while (1)          						//loop will folow untill key board hits
   {
	while(!(kbhit()))
	{
		printTitle();
	}

	switch(getch())                					// getting options from the user
	{
		case '1':

			settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);		//set text style for the options
			setcolor(0);					//set colour for the fonts
			outtextxy(60,150,"1) RESULT MENU");	//setting the position and the font
			settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);		//set text style for the options
			setcolor(10);					//set colour for the fonts
			outtextxy(60,150,"1) RESULT MENU");	//setting the position and the font
			delay(500);

			result();
			cleardevice();
			start();
			showMenu();
			break;
			
		case '2':
			settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);		//set text style for the options
			setcolor(0);					//set colour for the fonts
			outtextxy(60,210,"2) ENTRY/EDIT MENU");	//setting the position and the font
			settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);		//set text style for the options
			setcolor(10);					//set colour for the fonts
			outtextxy(60,210,"2) ENTRY/EDIT MENU");	//setting the position and the font
			delay(500);

			entry_menu();
			cleardevice();
			start();
			showMenu();
			break;
			
		case '3':
			settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);		//set text style for the options
			setcolor(0);					//set colour for the fonts
			outtextxy(60,270,"3) EXIT");			//setting the position and the font
			settextstyle(TRIPLEX_FONT,HORIZ_DIR,5);		//set text style for the options
			setcolor(10);					//set colour for the fonts
			outtextxy(60,270,"3) EXIT");			//setting the position and the font
			delay(500);

			end();
			cleardevice();
			start();
			showMenu();                                //	END FUNCTION IS CALLED AFTER
			break;
		default:
			inv();
	}
    }
}
Example #30
0
//-----------------------------------------------------------------------------
BYTE UserInterface::editBox(const char *title, char *buffer, BYTE maxLength, bool decimal)
{
	if (maxLength <= 0 || maxLength > (maxCharsOnScreen - 2))
		maxLength = maxCharsOnScreen - 2;

	BYTE *bkm_frameSave = new BYTE[frameLength];
	memcpy(bkm_frameSave, defaultSurface->pixels, frameLength);

	menuStackLevel++;

	WORD i, len = strlen(buffer), cursor = len,
		w = (strlen(title) + 4) * fontWidth, h, x, y;

	if (w < ((maxLength + 1) * fontWidth))
		w = ((maxLength + 1) * fontWidth);

	w = (2 * GUI_CONST_BORDER) + w;
	h = (4 * GUI_CONST_BORDER);
	x = (frameWidth  - w) / 2;
	y = (frameHeight - h) / 2;

	drawDialogWithBorder(defaultSurface, x, y, w, h);
	printTitle(defaultSurface, x, y + 1, w, GUI_COLOR_BACKGROUND, title);

	x += GUI_CONST_BORDER;
	y += (2 * GUI_CONST_BORDER);
	w -= (2 * GUI_CONST_BORDER);

	DWORD nextTick;
	BYTE result = -1;
	SDL_Event event;
	bool atTheEnd = true, change = true;

	SDL_EnableUNICODE(1);
	SDL_Delay(GPU_TIMER_INTERVAL);
	while (result == (BYTE) -1) {
		nextTick = SDL_GetTicks() + CPU_TIMER_INTERVAL;

		while (SDL_PollEvent(&event)) {
			switch (event.type) {
				case SDL_KEYDOWN:
					switch (event.key.keysym.sym) {
						case SDLK_ESCAPE:
							result = 0;
							break;

						case SDLK_RETURN:
						case SDLK_KP_ENTER:
							// trim left
							cursor = 0;
							while (buffer[cursor] == ' ')
								cursor++;

							if (cursor > 0)
								for (i = 0; cursor <= len; i++, cursor++)
									buffer[i] = buffer[cursor];

							// trim right
							cursor = (len = strlen(buffer)) - 1;
							while (buffer[cursor] == ' ')
								cursor--;

							if (++cursor < len)
								buffer[cursor] = '\0';

							result = 1;
							break;

						case SDLK_LEFT:
							if (cursor > 0) {
								cursor--;
								change = true;
							}
							break;

						case SDLK_RIGHT:
							if (!atTheEnd) {
								cursor++;
								change = true;
							}
							break;

						case SDLK_BACKSPACE:
							if (cursor > 0) {
								cursor--;
								for (i = cursor; i < len; i++)
									buffer[i] = buffer[i + 1];
								change = true;
							}
							break;

						case SDLK_INSERT:
							if (!atTheEnd && len < maxLength) {
								for (i = len + 1; i > cursor; i--)
									buffer[i] = buffer[i - 1];
								buffer[cursor] = ' ';
								change = true;
							}
							break;

						case SDLK_DELETE:
							if (!atTheEnd) {
								for (i = cursor; i < len; i++)
									buffer[i] = buffer[i + 1];
								change = true;
							}
							break;

						case SDLK_HOME:
							if (cursor > 0) {
								cursor = 0;
								change = true;
							}
							break;

						case SDLK_END:
							if (!atTheEnd) {
								cursor = len;
								change = true;
							}
							break;

						default:
							if (event.key.keysym.unicode < 0x0020
							 || event.key.keysym.unicode > 0x007E)
								break;

							char c = (char) event.key.keysym.unicode;
							if (cursor < maxLength) {
								if (decimal && (c < '0' || c > '9'))
									break;

								buffer[cursor] = c;
								cursor++;
								if (atTheEnd)
									buffer[cursor] = '\0';

								change = true;
							}
							break;
					}
					break;

				case SDL_VIDEOEXPOSE:
					Emulator->RefreshDisplay();
					break;

				default:
					break;
			}

			if (change) {
				drawRectangle(defaultSurface, x, y - 1, w, fontHeight + 1,
					GUI_COLOR_BACKGROUND);
				drawRectangle(defaultSurface, x + (cursor * fontWidth), y - 1,
					fontWidth, fontHeight + 1, GUI_COLOR_HIGHLIGHT);
				printText(defaultSurface, x, y, GUI_COLOR_FOREGROUND, buffer);

				len = strlen(buffer);
				atTheEnd = (cursor == len);

				needRedraw = true;
				change = false;
				break;
			}
		}

		// have a break, have a tick-tock...
		while (SDL_GetTicks() < nextTick)
			SDL_Delay(1);
	}

	memcpy(defaultSurface->pixels, bkm_frameSave, frameLength);
	delete [] bkm_frameSave;

	SDL_Delay(GPU_TIMER_INTERVAL);
	SDL_EnableUNICODE(0);
	needRelease = true;
	needRedraw = true;

	menuStackLevel--;
	return result;
}