Exemplo n.º 1
0
// ---
void QGAMES::Screen::drawForm (const QGAMES::Position& p, QGAMES::Form* f, 
	int px, int py, int w, int h, int a)
{
	assert (f);

	// Calculates the real position at the screen
	// It would depend on the scale, and where the visual position f the screen is fixed.
	QGAMES::Position nP = p.projectOver (_position, _orientation);
	QGAMES::bdata x = nP.posX () - _position.posX ();
	QGAMES::bdata y = nP.posY () - _position.posY ();
	int wD = w; int hD = h;

	// If the positions are not in the screen, they are not painted
	if ((int) x > _visualWidth || (int) y > _visualHeight ||
		(int) (x + wD) <= 0 || (int) (y + hD) <= 0) 
		return; // If the form is not in the window, it is not drawn...

	// Scale the objects...if any
	if ((int) _scale._value != 1) // To speed the code up in normal situations...
	{
		x = _scale.effectToX (x);
		y = _scale.effectToY (y);
		if (_scale._scaleByAlgorithm)
		{
			wD = (int) (w * _scale._value); // Width and height have to be scaled also...
			hD = (int) (h * _scale._value);
		}
	}

	// Draw the objects...
	if ((int) _scale._value == 1)
		drawForm ((int) x, (int) y, f, px, py, wD, hD, a);
	else
	{
		if (!_scale._scaleByAlgorithm)
			activeScale ();
		drawForm ((int) x, (int) y, f, px, py, wD, hD, a);
		if (!_scale._scaleByAlgorithm)
			desactiveScale ();
	}
}
Exemplo n.º 2
0
void drawConsole(void){
    int i;
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD pos;

    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    drawForm(50, 10, 10, 1, 0);

    SetConsoleTextAttribute(hConsole, RED);
	pos.X = 21;
	pos.Y = 2;
	SetConsoleCursorPosition(hConsole, pos);
	printf("Welcome to the university !  ");

	SetConsoleTextAttribute(hConsole, WHITE);
	pos.X = 11;
	pos.Y = 4;
	SetConsoleCursorPosition(hConsole, pos);
	printf("What do you want to do? Enter \"(HELP)\":");

    pos.X = 75;
	pos.Y = 1;
	SetConsoleCursorPosition(hConsole, pos);
	SetConsoleTextAttribute(hConsole, YELLOW);
	printf("HELP");

    pos.X = 65;
	pos.Y = 3;
	SetConsoleCursorPosition(hConsole, pos);
    SetConsoleTextAttribute(hConsole, YELLOW);
    printf("1 ");
    SetConsoleTextAttribute(hConsole, PURPLE);
    printf("- push new student;\n");

    pos.X = 65;
	pos.Y = 4;
	SetConsoleCursorPosition(hConsole, pos);
    SetConsoleTextAttribute(hConsole, YELLOW);
    printf("2 ");
    SetConsoleTextAttribute(hConsole, PURPLE);
    printf("- remove student;\n");

    pos.X = 65;
	pos.Y = 5;
	SetConsoleCursorPosition(hConsole, pos);
    SetConsoleTextAttribute(hConsole, YELLOW);
    printf("3 ");
    SetConsoleTextAttribute(hConsole, PURPLE);
    printf("- show all student list;\n");

    pos.X = 65;
	pos.Y = 6;
	SetConsoleCursorPosition(hConsole, pos);
    SetConsoleTextAttribute(hConsole, YELLOW);
    printf("4 ");
    SetConsoleTextAttribute(hConsole, PURPLE);
    printf("- show all subject list;\n");

    pos.X = 65;
	pos.Y = 7;
	SetConsoleCursorPosition(hConsole, pos);
    SetConsoleTextAttribute(hConsole, YELLOW);
    printf("5 ");
    SetConsoleTextAttribute(hConsole, PURPLE);
    printf("- show all mark list;\n");

    pos.X = 65;
	pos.Y = 8;
	SetConsoleCursorPosition(hConsole, pos);
    SetConsoleTextAttribute(hConsole, YELLOW);
    printf("6 ");
    SetConsoleTextAttribute(hConsole, PURPLE);
    printf("- show exception student;\n");

    pos.X = 65;
	pos.Y = 9;
	SetConsoleCursorPosition(hConsole, pos);
    SetConsoleTextAttribute(hConsole, YELLOW);
    printf("7 ");
    SetConsoleTextAttribute(hConsole, PURPLE);
    printf("- enter new mark;\n");

    pos.X = 65;
	pos.Y = 10;
	SetConsoleCursorPosition(hConsole, pos);
    SetConsoleTextAttribute(hConsole, YELLOW);
    printf("8 ");
    SetConsoleTextAttribute(hConsole, PURPLE);
    printf("- save student list to file and exit;\n");

    for (i = 0; i <= 131; i++){
		pos.X = i;
		pos.Y = 15;
		SetConsoleTextAttribute(hConsole, AQUA);
		SetConsoleCursorPosition(hConsole, pos);
		printf("*");
    }
    for (i = 0; i <= 15; i++){
		pos.X = 132;
		pos.Y = 15 - i;
		SetConsoleTextAttribute(hConsole, AQUA);
		SetConsoleCursorPosition(hConsole, pos);
		printf("*");
    }
}