Thursday, July 18, 2013

Should they be friends?


Is making console a friend to CFrame the only way I can determine whether the border is visible or not?
Or am I missing something?
Should we be making it a friend just to satisfy this portion of the program?

Thank you in advance!

void CLineEdit::draw(int Refresh) {
  CFrame::draw(Refresh);
  console.strdsp((char*)_data + _offset,
                 (_visible) ? absRow() + 1 : absRow(),
                 (_visible) ? absCol() + 1 : absCol(),
                 (_visible) ? width() - 2 : width());
}

Thursday, May 30, 2013

ascToInt



Function which receives a char string of numbers (optional '+' or '-' in front) and returns the string as an int.

Assumes the user provides a valid string of numbers.

int ascToInt(const char *num) {
  int result = 0;
  int posOrNeg = 1;
  if ((*num == '+') || ((*num == '-') && (posOrNeg = -1)))
    num++;
  while (*num) {
    result = (result * 10) + (*num - '0');
    num++;
  }
  return result * posOrNeg;
}