Is it possible, from looking at this ....thing.... from my program, to tell if this goodamn function has a bug? it compiles, but when i try and run it in main..... results are spectacular. Program crashes (not winblows tho), once i got beeps, blah.
Code:
class GuiElement {
public :
bool OutOfBounds (); //Returns true if box will not fit on screen.
//Appearance Accessors
int ChangeColor ( int ArgBox, int ArgHead, int ArgText );
int ChangeThickness ( bool ArgThickness );
int ChangeSizePos ( int ArgXPos, int ArgYPos, int ArgXSize, int ArgYSize );
int ChangePosition ( int ArgPos, int ArgYPos );
int ChangeSize ( int ArgXSize, int ArgYSize );
protected :
//Appearance Characteristics
unsigned short int BoxColor; //Colour the box will be
unsigned short int HeaderColor; //Colour the header will be
unsigned short int TextColor; //Colour text will be
bool Thickness; //Thickness of box ( single or double )
//size/position
int XPos;
int YPos;
int XSize;
int YSize;
};
class TextBox : public GuiElement{
public :
//Output
virtual int Display (); //displays as a textbox with.... box.
int Range ( int ArgStart, int ArgEnd ); //Displays a given portion of the text string without the box.
//Editing Functions
int Prepend ( string szArgText ); //Add to the start
int Append ( string szArgText ); //Add to the end
int Rewrite ( string szArgText ); //Totally rewrites contents of string.
int ChangeHeader ( string szArgHeader ); //Totally rewrites header string.
//Error Checking Functions : as well as returning true, they will also output a log to a file
// bool TextSizeIllegal(); //Returns true if size of text exceeds what can fit in box.
// bool HeaderIllegal (); //Returns true if header wil not fit.
protected :
//Text
string szHeader; //Holds the header
string szText; //Holds the actual text
};
int TextBox::Display()
{
Draw Draw;
Draw.ChangeColor ( BoxColor );
Draw.Box ( XPos, YPos, XSize, YSize, Thickness );
Draw.CursorLocation ( XPos + 1, YPos + 1 ); //relocate the curosr to the top left corner of teh box
Draw.ChangeColorGlobal ( HeaderColor );
cout.write ( szHeader.c_str(), XSize - 2 ); //Make sure you dont write over the box
Draw.CursorLocation ( XPos + 1, YPos + 2 );
int i;
int j;
int k;
for ( i = 0 ; i < YSize - 2 ; i++ )
{
Draw.CursorLocation ( XPos + 1, YPos + 2 + i);
for ( j = 0 ; j < XSize - 2 ; j++ )
{
if ( szText [k] == 32 || j == XSize - 3 )
cout << "-";
else
cout << szText [k];
k++;
}
}
return 0;
}
if you took the time to read all of this uncommented..... kudos to you (what is a kudo??)
Thanks for the couple of hours youll spend scratching your head in confusion and derision :)
(edit) sorry about the tabs - they look fine in my IDE.... i have weird settings on tabs.