Quote
Procedural code gets information then makes decisions. Object-oriented code tells objects to do things.
— Alec Sharp
From the beginning of that already, I agree with that.
The idea of.. It's incomprehendable and illogical in my eyes.
Quote (ASBands @ Fri, 2 Oct 2009, 16:30)
I could look at it, but I need TextControl.h
I'll post what's relevant from it - as there's a lot I've added to that library.

Code
/* Colors defined for SetColor(int) */
enum {
BLACK = 0,
DARK_BLUE = 1,
DARK_GREEN = 2,
TEAL = 3,
DARK_RED = 4,
DARK_PURPLE = 5,
GOLD = 6,
GREY = 7,
DARK_WHITE = 8,
BLUE = 9,
GREEN = 10,
CYAN = 11,
RED = 12,
PURPLE = 13,
YELLOW = 14,
WHITE = 15
};
...
void SetColor(const int foreground) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, foreground);
return;
}
void SetColor(const int foreground, const int background) {
int Color = foreground + (background * 16);
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, Color);
return;
}
...
void PlaceCursor(const int x, const int y) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD PlaceCursorHere;
PlaceCursorHere.X = x;
PlaceCursorHere.Y = y;
SetConsoleCursorPosition(hConsole, PlaceCursorHere);
return;
}
...
void ClearConsole(const int foreground, const int background) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coordScreen = { 0, 0 };
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
if (!GetConsoleScreenBufferInfo(hConsole, &csbi)) { return; }
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
SetColor(foreground, background);
if (!FillConsoleOutputCharacter(hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten)) { return; }
if (!GetConsoleScreenBufferInfo(hConsole, &csbi)) { return; }
if (!FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten)) { return; }
return;
}
...
void RemoveCursor() {
/* Remove the cursor (does not work in full screen) */
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursoInfo;
CursoInfo.dwSize = 1; /* The size of caret */
CursoInfo.bVisible = false; /* Caret is visible? */
SetConsoleCursorInfo(hConsole, &CursoInfo);
return;
}
...
void DrawBox(const int Width, const int Height, const int PlaceX, const int PlaceY) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
/* Horizontal lines */
for (int x = 0; x < Height; x++) { PlaceCursor(PlaceX, PlaceY + x); WriteConsole(hConsole, "º", 1, 0, NULL); }
for (int x = 0; x < Height; x++) { PlaceCursor(PlaceX + Width - 1, PlaceY + x); WriteConsole(hConsole, "º", 1, 0, NULL); }
/* Vertical lines */
for (int x = 0; x < Width; x++) { PlaceCursor(PlaceX + x, PlaceY); WriteConsole(hConsole, "Í", 1, 0, NULL); }
for (int x = 0; x < Width; x++) { PlaceCursor(PlaceX + x, PlaceY + Height - 1); WriteConsole(hConsole, "Í", 1, 0, NULL); }
PlaceCursor(PlaceX, PlaceY); WriteConsole(hConsole, "É", 1, 0, NULL); /* Upper left corner */
PlaceCursor(PlaceX + Width - 1, PlaceY); WriteConsole(hConsole, "»", 1, 0, NULL); /* Upper right corner */
PlaceCursor(PlaceX, PlaceY + Height - 1); WriteConsole(hConsole, "È", 1, 0, NULL); /* Bottom left corner */
PlaceCursor(PlaceX + Width - 1, PlaceY + Height - 1); WriteConsole(hConsole, "¼", 1, 0, NULL); /* Bottom right corner */
return;
}
void DrawBox(const int Color, const int Width, const int Height, const int PlaceX, const int PlaceY) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, Color);
/* Horizontal lines */
for (int x = 0; x < Height; x++) { PlaceCursor(PlaceX, PlaceY + x); WriteConsole(hConsole, "º", 1, 0, NULL); }
for (int x = 0; x < Height; x++) { PlaceCursor(PlaceX + Width - 1, PlaceY + x); WriteConsole(hConsole, "º", 1, 0, NULL); }
/* Vertical lines */
for (int x = 0; x < Width; x++) { PlaceCursor(PlaceX + x, PlaceY); WriteConsole(hConsole, "Í", 1, 0, NULL); }
for (int x = 0; x < Width; x++) { PlaceCursor(PlaceX + x, PlaceY + Height - 1); WriteConsole(hConsole, "Í", 1, 0, NULL); }
PlaceCursor(PlaceX, PlaceY); WriteConsole(hConsole, "É", 1, 0, NULL); /* Upper left corner */
PlaceCursor(PlaceX + Width - 1, PlaceY); WriteConsole(hConsole, "»", 1, 0, NULL); /* Upper right corner */
PlaceCursor(PlaceX, PlaceY + Height - 1); WriteConsole(hConsole, "È", 1, 0, NULL); /* Bottom left corner */
PlaceCursor(PlaceX + Width - 1, PlaceY + Height - 1); WriteConsole(hConsole, "¼", 1, 0, NULL); /* Bottom right corner */
return;
}
That's everything that's relevant I believe.
If I'm missing something, let me know!
Thanks for looking at it.
This post was edited by Muted on Oct 2 2009 03:46pm