void CCheckMark::draw(int fn) { bool insertMode = false; console.strdsp(_format, absRow(), absCol(), 4, 4); if(!_flag) //Overwrite an empty space when _flag is false { console.strdsp(" ",absRow(), absCol()+1); } _Label.draw(); //move cursor to the middle of the checkmark console.setPos(absRow(), absCol()+1); }
//Draws the checkmark field, changing the checkmark based on which flags are true. //Repositions cursor on top of the checkmark void CCheckMark::draw(int fn) { if(!_flag)//not checked add space _format[1] = ' '; else if(!_radio)//checked and not radio add X _format[1] = 'X'; else if(_radio)//checked and radio add O _format[1] = 'O'; console.display(_format, absRow(), absCol()); _Label.draw(); //sets cursor at the checkmark console.setPos(absRow(), absCol() + 1); }
//CButton draw() void CButton::draw(int fn) { //Call CFrame's draw CFrame::draw(fn); //Display text at absRow() and absCol() if not bordered or absRow() + 1 and absCol() + 2 if bordered console.display((char*)_data, absRow() + visible(), absCol() + (visible() ? 2 : 0)); }
//---------------------------------------------------------------------------------------------- // edit // //---------------------------------------------------------------------------------------------- int CLineEdit::edit() { int row = absRow() + (visible() ? 1 : 0); int col = absCol() + (visible() ? 1 : 0); int len = width() + (visible() ? -2 : 0); return console.edit( (char*)_data, row, col, len, _maxdatalen, &_offset, &_curpos, true, false, *_insertmode); }
//---------------------------------------------------------------------------------------------- // Draw // //---------------------------------------------------------------------------------------------- void CLineEdit::draw(int Refresh) { CFrame::draw(Refresh); int row = absRow() + (visible() ? 1 : 0); int col = absCol() + (visible() ? 1 : 0); int len = width() + (visible() ? -2 : 0); console.display((char*)_data+_offset, row, col, len, _curpos); }
//CButton edit() int CButton::edit() { //Draw the button surrounded by square brackets draw(); console.display("[", absRow() + visible(), absCol() + (visible() ? 1 : -1)); console.display("]", absRow() + visible(), absCol() + bio::strlen(_data) + (visible() ? 2 : 0)); //Place the cursor under the first character of button's text console.setPos(absRow() + visible(), absCol() + (visible() ? 2 : 0)); //Wait for user entry int key = console.getKey(); //Remove square brackets button is deselected. console.display(" ", absRow() + visible(), absCol() + (visible() ? 1 : -1)); console.display(" ", absRow() + visible(), absCol() + bio::strlen(_data) + (visible() ? 2 : 0)); //If user inputs ENTER or SPACE keys, return C_BUTTON_HIT, otherwise return entered key. if(key == SPACE || key == ENTER){ return C_BUTTON_HIT; } else{ return key; } }
/* draw -Display the actual label data */ void CLabel::draw(int fn){ console.display((char*)_data, absRow(), absCol(), width()); // Call console's display function }
void CSwitch::draw(int fn){ cio::display(_format, absRow(), absCol(), std::strlen(_format), _flag); //CField::display(_format); _label.draw(fn); }