Example #1
0
//--------------------------------------------------------------
void processPoint(const String& point, Uint32& v, Uint32& vt, Uint32& vn)
{
	Uint32 occ = point.countOccurrence('/');

	switch(occ)
	{
	case 0:
		sscanf(point.getValue(), "%u", &v);
		vt = 1;
		vn = 1;
	break;
	case 1:
		sscanf(point.getValue(), "%u/%u", &v, &vt);
		vn = 1;
	break;
	case 2:
		if(point.getChar(point.find('/')+1) == '/') // find "//" pattern
		{
			sscanf(point.getValue(), "%u//%u", &v, &vn);
			vt = 1;
		}
		else
		{
			sscanf(point.getValue(), "%u/%u/%u", &v, &vt, &vn);
		}
	break;
	default:
		fprintf(stdout, "wut?\n");
	break;
	}
}
Example #2
0
VOID MDIFrame::onOpen() {
  String tmpfile;
  OPENFILENAME l={sizeof(l),};
  l.lpstrFilter = "Image Files\0*.png;*.jpg\0";
  char *temp = (char *)GlobalAlloc(GMEM_FIXED,4096);
  temp[0] = 0;
  l.lpstrFile = temp;
  l.nMaxFile = 4095;
  l.lpstrTitle = "Load Image";
  l.lpstrDefExt = "";
  l.Flags = OFN_EXPLORER;
  if (GetOpenFileName(&l)) {
    tmpfile = temp;
  } else {
    GlobalFree(temp);
    return;
  }
  GlobalFree(temp);
  Bitmap *bmp = new Bitmap(tmpfile);
  if (bmp->isInvalid()) {
    MessageBox(gethWnd(), StringPrintf("Error loading %s", tmpfile.getValue()), "Error", 16);
    delete bmp;
  } else {
    MDIChild *child = new MDIChild(this, bmp);
    child->setName(tmpfile);
    child->setIcon(IDI_MDICHILD);
    addMDIChild(child); // self registers
  }
}
Example #3
0
String String::operator+(String other)
{
  if (this == &other)
    return *this;
  append(other.getValue());
  return *this;
};
Example #4
0
String String::operator=(String other)
{
  if (this == &other)
    return *this;
  setValue(other.getValue());
  return *this;
};
Example #5
0
void TimeFmt::printCustom(int sec, const char *buf, int bufsize, const char *str_sep, const char *str_seconds, const char *str_minutes, const char *str_hours, const char *str_days) {
  if (buf == NULL || bufsize == 0) return;
  char *p = (char *)buf;
  *p = 0;
  int days, hours, minutes;
  String s;

  if (str_days) {
    days = sec / (3600*24);
    sec -= days * (3600*24);
    if (days != 0) {
      s += StringPrintf("%d%s", days, str_days);
    }
  }
  if (str_hours) {
    hours = sec / 3600;
    sec -= hours * 3600;
    if (hours != 0) {
      if (!s.isempty()) s += str_sep;
      s += StringPrintf("%d%s", hours, str_hours);
    }
  }
  if (str_minutes) {
    minutes = sec / 60;
    sec -= minutes * 60;
    if (minutes != 0) {
      if (!s.isempty()) s += str_sep;
      s += StringPrintf("%d%s", minutes, str_minutes);
    }
  }
  if (str_seconds) {
    if (sec != 0) {
      if (!s.isempty()) s += str_sep;
      s += StringPrintf("%d%s", sec, str_seconds);
    }
  }
  STRNCPY(p, s.getValue(), bufsize);
  int l = s.len();
  if (l < bufsize) p[l] = 0;
}