hi, im new in this page, i need some help i learning about class , so im triyinhg to do a checkbox but doesn't works .
or some one have a good class checkbox please
class checkbox : public textbox
{
public:
checkbox(std::string checkboxname); //constructor for checkbox, takes a name
virtual ~checkbox();
virtual void show(int,int); //print on screen
virtual void focus();
void checked(bool mark); //will mark as checked or not
bool checked(); //returns checked_; 1 = checked, 0 = !checked
std::string name(); //returns name_; the checkbox name
void next (checkbox *next_); //gives next a value
void back (checkbox *back_); //gives back a value
virtual checkbox *next(); //returns next checkbox in list
virtual checkbox *back(); //returns previous checkbox in list
private:
checkbox *next__; //stores next checkbox
checkbox *back__; //stores previous checkbox
protected:
bool checked_; //variable for checked()
};
class list_checkbox
{
public:
list_checkbox(); //constructor takes no parameters
~list_checkbox();
virtual void add(std::string name); //this will add a new checkbox to the list_checkbox
int count(); //will count how many checkboxes in the list_checkbox
virtual checkbox *last(); //will return the last checkbox object in the list_checkbox
virtual void show(int x, int y, bool dir); //used to display the checkbox options
virtual void focus(); //will move to desired checkbox
virtual void result(int x, int y); //will print checked items
virtual void box(int x, int y); //prints border around items
virtual int maxwidth();
virtual checkbox *head();
private:
checkbox *ini; //initial node in the list
protected:
int count_; //used to store the number of checkboxes in the list_checkbox
//method returns next item in the list
checkbox *checkbox::next()
{
return next__;
}
//method returns previous item in the list
checkbox *checkbox::back()
{
return back__;
}
//gives next the value inserted
void checkbox::next(checkbox * next_)
{
next__=next_;
}
//gives back the value inserted
void checkbox::back(checkbox *back_)
{
back__=back_;
}
//method used to print the checkbox in the console
void checkbox::show(int x1, int y1)
{
int xmax = 80 - SHOWLEN -this->name().size(); //there are usually only 80 characters available to print on the screen, needs to take into account the name length and closing bracket "]"
if(x1>=1 && x1 <=xmax) //if x coordinate is within boundaries, assign it to x
{
x=x1;
}
else //else assign its max
{
if(x1<1) x=1;
if(x1 > xmax) x=xmax;
}
if(y1 >=1 && y1 <=25) //there are usually only 25 characters in the y direction
{
y=y1; ///if input y is within the boundary then assign it to the y coordinate
}
else //else assign its max coordinate or its min
{
if(y1 <1) y=1;
if(y1>25) y=25;
}
gotoxy(x,y); //used to move cursor to desired lovation
cprintf("["); //intiial bracket
for(int i=0; i<width_; i++)
{
cprintf(" ");
}
cprintf("]"); //closing bracket
gotoxy(x+5,y);
printf(name().c_str()); //print checkbox name
gotoxy(x+1,y); //move cursor to selection "[ ]"
}
void list_checkbox::result(int x, int y)
{
checkbox *temp = this->ini;
int xmax = 80 - temp->name().size(); //there are usually only 80 characters available to print on the screen, needs to take into account the name length
if(x<1) x=1;
if(x > xmax) x=xmax;
if(y<1 || y>25) //if outside boundaries, assign its max coordinate or its min
{
if(y <1) y=1;
if(y >25) y=25;
}