Code: Select all
struct EditBoxStruct {
Dword width, left, top, color, shift_color, focus_border_color, blur_border_color,
text_color, max, text, mouse_variable, flags, size, pos, offset, cl_curs_x, cl_curs_y, shift, shift_old;
};
class EditBox : public Control {
public:
Dword id;
Word x,y, width, left, top;
Dword color, shift_color, focus_border_color, blur_border_color, text_color;
Dword max;
char text[256];
Dword mouse_variable;
Dword flags;
Dword size, pos, offset;
Dword cl_curs_x, cl_curs_y;
Dword shift, shift_old;
bool hidden;
EditBoxStruct component;
int type;
EditBox(int x, int y, int width);
void updateStruct();
int getType();
void draw();
virtual int getId();
virtual void sysevent(int code);
};
EditBox::EditBox(int x, int y, int size) {
this->x = x;
this->y = y;
this->width = size;
this->size = size;
this->color = COLOR_RED;
this->text_color = COLOR_BLACK;
this->max = 255;
//this->text = "Hello, world!";
this->updateStruct();
}
void EditBox::updateStruct() {
component.blur_border_color = this->blur_border_color;
component.cl_curs_x = this->cl_curs_x;
component.cl_curs_y = this->cl_curs_y;
component.color = this->color;
component.flags = this->flags;
component.focus_border_color = this->focus_border_color;
component.left = this->x;
component.max = this->max;
component.mouse_variable = (Dword)&this->mouse_variable;
component.offset = this->offset;
component.pos = this->pos;
component.shift = this->shift;
component.shift_color = this->shift_color;
component.shift_old = this->shift_old;
component.size = this->size;
component.text = (Dword)&this->text;
component.text_color = this->text_color;
component.top = this->y;
component.width = this->width;
}
void EditBox::draw() {
if (!hidden) {
BoxLib::edit_box_draw((Dword)&this->component);
}
//Dword mouse_dd;
//char fname[256];
//EditBoxStruct file_box = {200,100, 45, 0xffffff,0x6a9480, COLOR_RED, COLOR_YELLOW, 0x808080,255,(Dword)&fname,(Dword)&mouse_dd};
/**Dword width, left, top, color, shift_color, focus_border_color, blur_border_color,
text_color, max, text, mouse_variable*/
//BoxLib::edit_box_draw((Dword)&file_box);
this->call(EVENT_DRAW);
}
void EditBox::sysevent(int code) {
switch (code) {
case EVENT_KEY_PRESS:
BoxLib::edit_box_key((Dword)&this->component);
break;
}
BoxLib::edit_box_mouse((Dword)&this->component);
}
int EditBox::getType() {
return CONTROL_EDIT_BOX;
}
int EditBox::getId() {
return this->id;
}