void Control::GetClass(RCFile &rcFile) { if (rcFile.IsString()) { std::wstring str = rcFile.GetString(); std::wstring str1 = str; for (int i=0; i < str1.size(); i++) str1[i] = tolower(str1[i]); if (str1 == L"button") cls.SetId(Button); else if (str1 == L"edit") cls.SetId(Edit); else if (str1 == L"static") cls.SetId(Static); else if (str1 == L"listbox") cls.SetId(Listbox); else if (str1 == L"scrollbar") cls.SetId(Scrollbar); else if (str1 == L"combobox") cls.SetId(Combobox); else { cls.SetName(str); } } else switch (rcFile.GetTokenId()) { case Lexer::AUTO3STATE: case Lexer::AUTOCHECKBOX: case Lexer::AUTORADIOBUTTON: case Lexer::CHECKBOX: case Lexer::PUSHBUTTON: case Lexer::RADIOBUTTON: case Lexer::DEFPUSHBUTTON: case Lexer::STATE3: case Lexer::GROUPBOX: cls.SetId(Button); break; case Lexer::COMBOBOX: cls.SetId(Combobox); break; case Lexer::CTEXT: case Lexer::LTEXT: case Lexer::RTEXT: case Lexer::ICON: cls.SetId(Static); break; case Lexer::EDITTEXT: cls.SetId(Edit); break; case Lexer::LISTBOX: cls.SetId(Listbox); break; case Lexer::SCROLLBAR: cls.SetId(Scrollbar); break; default: throw new std::runtime_error("Unknown dialog control class"); } }
void CXMLObject::write ( RCFile f ) { int i; f.CreateWrite ( objTag ); f.CreateWrite ( objData ); f.WriteInt ( &nObjects ); for (i=0;i<nObjects;i++) StreamWrite ( f,object[i] ); }
void DlgInclude::ReadRC(RCFile &rcFile) { resInfo.SetFlags(resInfo.GetFlags() | ResourceInfo::Pure); resInfo.ReadRC(rcFile, false); if (!rcFile.IsString()) throw new std::runtime_error("Expected quoted string"); std::wstring wname = rcFile.GetString(); std::string name = rcFile.CvtString(wname); data = new ResourceData((unsigned char *)name.c_str(), name.size() + 1); }
void CSSGraph::write ( RCFile f ) { int i; int Version=1; f.WriteInt ( &Version ); f.CreateWrite ( name ); f.WriteTerLine ( devChain,False ); f.WriteInt ( &nVertices ); for (i=0;i<nVertices;i++) StreamWrite ( f,Vertex[i] ); }
void CMask::read ( RCFile f ) { int i; if (m) { delete[] m; m = NULL; } f.ReadInt ( &mlen ); if (mlen>0) { m = new word[mlen]; for (i=0;i<mlen;i++) f.ReadWord ( &(m[i]) ); } }
void Accelerators::ReadRC(RCFile &rcFile) { resInfo.SetFlags( (resInfo.GetFlags() &~ResourceInfo::Discardable) | ResourceInfo::Pure); resInfo.ReadRC(rcFile, true); rcFile.NeedBegin(); while (rcFile.IsString() || rcFile.IsNumber()) { //int done; Key key; key.ReadRC(rcFile); keys.push_back(key); } rcFile.NeedEnd(); }
void CXMLObject::read ( RCFile f ) { int i; FreeMemory(); f.CreateRead ( objTag ); f.CreateRead ( objData ); f.ReadInt ( &nObjects ); nAlloc = nObjects; if (nObjects>0) { object = new PCXMLObject[nObjects]; for (i=0;i<nObjects;i++) { object[i] = NULL; StreamRead ( f,object[i] ); } } }
bool Control::ValidType(RCFile &rcFile) { switch (rcFile.GetToken()->GetKeyword()) { case Lexer::AUTO3STATE: case Lexer::AUTOCHECKBOX: case Lexer::AUTORADIOBUTTON: case Lexer::CHECKBOX: case Lexer::COMBOBOX: case Lexer::CTEXT: case Lexer::DEFPUSHBUTTON: case Lexer::EDITTEXT: case Lexer::GROUPBOX: case Lexer::ICON: case Lexer::LISTBOX: case Lexer::LTEXT: case Lexer::PUSHBUTTON: case Lexer::RADIOBUTTON: case Lexer::RTEXT: case Lexer::SCROLLBAR: case Lexer::STATE3: case Lexer::CONTROL: return true; default: return false; } }
void MessageTable::ReadRC(RCFile &rcFile) { resInfo.SetFlags(resInfo.GetFlags() | ResourceInfo::Pure); resInfo.ReadRC(rcFile, false); ResourceData *rd = new ResourceData; rd->ReadRC(rcFile); data = rd; rcFile.NeedEol(); }
void CSSGraph::read ( RCFile f ) { int i,Version; FreeMemory(); f.ReadInt ( &Version ); f.CreateRead ( name ); f.ReadTerLine ( devChain,False ); f.ReadInt ( &nVertices ); if (nVertices>0) { nVAlloc = nVertices; Vertex = new PCSSVertex[nVertices]; for (i=0;i<nVertices;i++) { Vertex[i] = NULL; StreamRead ( f,Vertex[i] ); } } }
void GroupCursor::ReadRC(RCFile &rcFile) { resInfo.ReadRC(rcFile, false); ResourceData *rd = new ResourceData; rd->ReadRC(rcFile); rcFile.NeedEol(); rd->GetWord(); if (rd->GetWord() != 2) { throw new std::runtime_error("file does not contain cursor data"); } int count = rd->GetWord(); for (int i=0; i < count; i++) { Cursor *c = new Cursor(resInfo); rcFile.GetResFile().Add(c); cursors.push_back(c); c->ReadBin(rd); } resInfo.SetFlags(resInfo.GetFlags() | ResourceInfo::Pure); delete rd; }
void Font::ReadRC(RCFile &rcFile) { resInfo.SetFlags(resInfo.GetFlags() | ResourceInfo::Pure); resInfo.ReadRC(rcFile, false); ResourceData *rd = new ResourceData; rd->ReadRC(rcFile); rcFile.NeedEol(); int n = rd->GetWord(); int s = rd->GetWord(); // check version and size /* if *n != 0x200 && n != 0x300 || s != rd->GetLen() || s < 0x180) { delete rd; throw new std::runtime_error("Invalid font file"); } */ data = rd; }
void ResourceData::ReadRC(RCFile &rcFile) { if (rcFile.IsKeyword()) { int maxLen = 1024; data = new unsigned char [maxLen]; rcFile.NeedBegin(); while (rcFile.IsNumber()) { if (len == maxLen) { maxLen += 1024; unsigned char *hold = data; data = new unsigned char [maxLen]; memcpy(data, hold, maxLen - 1024); delete [] hold; } data[len++] = rcFile.GetNumber() & 0xff; rcFile.SkipComma(); } rcFile.NeedEnd(); } else { std::string name = rcFile.GetFileName(); std::fstream in(name.c_str(), std::ios::in | std::ios::binary); if (!in.fail()) { in.seekg(0, std::ios::end); len = in.tellg(); in.seekg(0, std::ios::beg); data = new unsigned char[len]; in.read((char *)data, len); } else throw new std::runtime_error(std::string("Could not open file '") + name + "'"); } }
void CXMLObject::WriteObject ( RCFile f, int pos, int indent ) { int i,pos1,lm,rm,tl; pstr indstr,p,p1,q; Boolean sngline; if (objTag) { pos1 = pos + indent; indstr = new char[pos1+1]; for (i=0;i<pos1;i++) indstr[i] = ' '; indstr[pos1] = char(0); indstr[pos] = char(0); f.Write ( indstr ); f.Write ( pstr("<") ); f.Write ( objTag ); if ((!objData) && (nObjects<=0)) { f.WriteLine ( pstr("/>") ); delete[] indstr; return; } f.Write ( pstr(">") ); sngline = False; if (objData) { rm = 72; // right margin lm = IMin ( pos1,36 ); // left margin tl = strlen(objTag); if ((pos+tl+2+strlen(objData)<rm-tl-2) && (nObjects<=0)) { // single-line output sngline = True; f.Write ( objData ); } else { // multiple-line output with indentation indstr[pos] = ' '; indstr[lm] = char(0); f.LF(); p = objData; do { p1 = p; i = lm; q = NULL; while ((*p1) && ((i<rm) || (!q))) { if (*p1==' ') q = p1; p1++; i++; } f.Write ( indstr ); if (*p1) { // wrap data *q = char(0); f.WriteLine ( p ); *q = ' '; p = q; while (*p==' ') p++; if (*p==char(0)) p = NULL; } else { // data exchausted f.WriteLine ( p ); p = NULL; } } while (p); indstr[lm] = ' '; indstr[pos] = char(0); } } else f.LF(); for (i=0;i<nObjects;i++) if (object[i]) object[i]->WriteObject ( f,pos+indent,indent ); if (!sngline) f.Write ( indstr ); f.Write ( pstr("</") ); f.Write ( objTag ); f.WriteLine ( pstr(">") ); delete[] indstr; } }
void Control::ReadGeneric(RCFile &rcFile, bool extended) { text.ReadRC(rcFile, true); rcFile.SkipComma(); id = rcFile.GetNumber(); rcFile.SkipComma(); GetClass(rcFile); rcFile.SkipComma(); style = rcFile.GetNumber() | WS_CHILD | WS_VISIBLE; rcFile.SkipComma(); pos.x = rcFile.GetNumber(); rcFile.SkipComma(); pos.y = rcFile.GetNumber(); rcFile.SkipComma(); size.x = rcFile.GetNumber(); rcFile.SkipComma(); size.y = rcFile.GetNumber(); if (!rcFile.AtEol()) { rcFile.SkipComma(); exStyle = rcFile.GetNumber(); } if (!rcFile.AtEol()) { helpIndex = rcFile.GetNumber(); rcFile.SkipComma(); } }
void Control::ReadStandard(RCFile &rcFile, int clss , int addStyle, int extended, int hasText) { addStyle |= WS_CHILD | WS_VISIBLE; cls.SetId(clss); if (hasText) { text.ReadRC(rcFile, true); rcFile.SkipComma(); } id = rcFile.GetNumber(); rcFile.SkipComma(); pos.x = rcFile.GetNumber(); rcFile.SkipComma(); pos.y = rcFile.GetNumber(); rcFile.SkipComma(); size.x = rcFile.GetNumber(); rcFile.SkipComma(); size.y = rcFile.GetNumber(); rcFile.SkipComma(); if (!rcFile.AtEol()) { style = addStyle | rcFile.GetNumber(); rcFile.SkipComma(); } else style = addStyle; if (!rcFile.AtEol()) { exStyle = rcFile.GetNumber(); rcFile.SkipComma(); } if (!rcFile.AtEol()) { helpIndex = rcFile.GetNumber(); rcFile.SkipComma(); } if (cls == Scrollbar) { if (style & SBS_VERT) style &= ~SBS_HORZ; } }
void ResourceInfo::ReadRC(RCFile &rcFile, bool secondary) { bool done = false; while (!done) { switch (rcFile.GetToken()->GetKeyword()) { case Lexer::DISCARDABLE: memoryFlags |= Discardable; break; case Lexer::PURE: memoryFlags |= Pure; break; case Lexer::PRELOAD: memoryFlags |= Preload; break; case Lexer::MOVEABLE: memoryFlags |= Moveable; break; case Lexer::LOADONCALL: memoryFlags |= LoadOnCall; break; case Lexer::NONDISCARDABLE: memoryFlags &= ~Discardable; break; case Lexer::IMPURE: memoryFlags &= ~Pure; break; case Lexer::FIXED: memoryFlags &= ~Moveable; break; default: done = true; break; } if (!done) rcFile.NextToken(); } if (secondary) { done = false; language = rcFile.GetLanguage(); while (!done) { switch (rcFile.GetToken()->GetKeyword()) { case Lexer::LANGUAGE: rcFile.NextToken(); language = rcFile.GetNumber(); rcFile.GetNumber(); rcFile.NeedEol(); break; case Lexer::VERSION: rcFile.NextToken(); version = rcFile.GetNumber(); rcFile.NeedEol(); break; case Lexer::CHARACTERISTICS: rcFile.NextToken(); characteristics = rcFile.GetNumber(); rcFile.NeedEol(); break; default: done = true; break; } } } }
void CMask::write ( RCFile f ) { int i; f.WriteInt ( &mlen ); for (i=0;i<mlen;i++) f.WriteWord ( &(m[i]) ); }
void Control::ReadRC(RCFile &rcFile, bool extended) { switch (rcFile.GetTokenId()) { case Lexer::AUTO3STATE: ReadStandard(rcFile, Button, BS_AUTO3STATE | WS_TABSTOP, extended, 1); break; case Lexer::AUTOCHECKBOX: ReadStandard(rcFile, Button, BS_AUTOCHECKBOX | WS_TABSTOP, extended, 1); break; case Lexer::AUTORADIOBUTTON: ReadStandard(rcFile, Button, BS_AUTORADIOBUTTON, extended, 1); break; case Lexer::CHECKBOX: ReadStandard(rcFile, Button, BS_CHECKBOX | WS_TABSTOP, extended, 1); break; case Lexer::COMBOBOX: ReadStandard(rcFile, Combobox, 0, extended, 0); if (!(style &3)) style |= CBS_SIMPLE; break; case Lexer::CTEXT: ReadStandard(rcFile, Static, SS_CENTER | WS_GROUP, extended, 1); break; case Lexer::DEFPUSHBUTTON: ReadStandard(rcFile, Button, BS_DEFPUSHBUTTON | WS_TABSTOP, extended, 1); break; case Lexer::EDITTEXT: ReadStandard(rcFile, Edit, ES_LEFT | WS_BORDER | WS_TABSTOP, extended, 0); break; case Lexer::GROUPBOX: ReadStandard(rcFile, Button, BS_GROUPBOX, extended, 1); break; case Lexer::ICON: ReadStandard(rcFile, Static, SS_ICON, extended, 1); break; case Lexer::LISTBOX: ReadStandard(rcFile, Listbox, LBS_NOTIFY | WS_BORDER, extended, 0); break; case Lexer::LTEXT: ReadStandard(rcFile, Static, SS_LEFT | WS_GROUP, extended, 1); break; case Lexer::PUSHBUTTON: ReadStandard(rcFile, Button, BS_PUSHBUTTON | WS_TABSTOP, extended, 1); break; case Lexer::RADIOBUTTON: ReadStandard(rcFile, Button, BS_RADIOBUTTON, extended, 1); break; case Lexer::RTEXT: ReadStandard(rcFile, Static, SS_RIGHT | WS_GROUP, extended, 1); break; case Lexer::SCROLLBAR: ReadStandard(rcFile, Scrollbar, SBS_HORZ, extended, 0); break; case Lexer::STATE3: ReadStandard(rcFile, Button, BS_3STATE | WS_TABSTOP, extended, 1); break; case Lexer::CONTROL: ReadGeneric(rcFile, extended); break; default: // shouldn't get here break; } rcFile.NeedEol(); }
void Dialog::ReadSettings(RCFile &rcFile) { bool hascaption = false, hasstyle = false, hasfont = false; resInfo.SetLanguage(rcFile.GetLanguage()); bool done = FALSE; while (!done && rcFile.IsKeyword()) { switch (rcFile.GetToken()->GetKeyword()) { case Lexer::LANGUAGE: { rcFile.NextToken(); int n = rcFile.GetNumber() ; rcFile.SkipComma(); n += rcFile.GetNumber() * 1024; resInfo.SetLanguage(n); } break; case Lexer::VERSION: rcFile.NextToken(); resInfo.SetVersion(rcFile.GetNumber()); break; case Lexer::CHARACTERISTICS: rcFile.NextToken(); resInfo.SetCharacteristics(rcFile.GetNumber()); break; case Lexer::STYLE: hasstyle = true; rcFile.NextToken(); style = rcFile.GetNumber(); break; case Lexer::EXSTYLE: rcFile.NextToken(); exStyle |= rcFile.GetNumber(); break; case Lexer::MENU: rcFile.NextToken(); menu.ReadRC(rcFile); break; case Lexer::FONT: hasfont = true; rcFile.NextToken(); pointSize = rcFile.GetNumber(); rcFile.SkipComma(); font = rcFile.GetString(); break; case Lexer::CAPTION: hascaption = true; rcFile.NextToken(); caption = rcFile.GetString(); break; case Lexer::CLASS: rcFile.NextToken(); cls.ReadRC(rcFile, true); break; case Lexer::HELP: rcFile.NextToken(); if (!extended) throw new std::runtime_error("Need DialogEx"); helpIndex = rcFile.GetNumber(); break; case Lexer::WEIGHT: rcFile.NextToken(); if (!extended) throw new std::runtime_error("Need DialogEx"); weight = rcFile.GetNumber(); break; case Lexer::ITALIC: rcFile.NextToken(); if (!extended) throw new std::runtime_error("Need DialogEx"); italics = rcFile.GetNumber(); break; default: done = TRUE; break; } if (!done) { rcFile.NeedEol(); } } if (hascaption) style |= WS_CAPTION; if (!hasstyle) style |= WS_POPUPWINDOW; if (hasfont) style |= DS_SETFONT; }
void Dialog::ReadRC(RCFile &rcFile) { if (extended) { italics = 256; } resInfo.SetFlags(resInfo.GetFlags() | ResourceInfo::Pure); resInfo.ReadRC(rcFile,false); pos.x = rcFile.GetNumber(); rcFile.SkipComma(); pos.y = rcFile.GetNumber(); rcFile.SkipComma(); size.x = rcFile.GetNumber(); rcFile.SkipComma(); size.y = rcFile.GetNumber(); rcFile.SkipComma(); rcFile.NeedEol(); ReadSettings(rcFile); rcFile.NeedBegin(); while (Control::ValidType(rcFile)) { Control *c = new Control; controls.push_back(c); c->ReadRC(rcFile, extended); } rcFile.NeedEnd(); }
int CXMLObject::ReadObject ( RCFile f, pstr S, int & pos, int slen ) { PCXMLObject XMLObject; pstr S1; int k,k1,k2,rc; Boolean Done; FreeMemory(); rc = XMLR_Ok; k1 = -1; while ((!f.FileEnd()) && (k1<0)) { k = strlen(S); while ((pos<k) && (k1<0)) if (S[pos]=='<') { if (S[pos+1]=='?') // in this version, ignore <?xxx ?> // constructions pos++; else if (S[pos+1]!='<') k1 = pos; else pos += 2; } else pos++; if (k1>=0) { k2 = -1; while ((pos<k) && (k2<0)) if (S[pos]=='>') { if (S[pos+1]!='>') k2 = pos; else pos += 2; } else pos++; if (k2<0) rc = XMLR_BrokenTag; } if (k1<0) { f.ReadLine ( S,slen ); pos = 0; } } if (k1<0) return XMLR_NoTag; if (rc!=XMLR_Ok) return rc; pos++; if (S[k2-1]=='/') { // <Tag/> S[k2-1] = char(0); CreateCopy ( objTag,&(S[k1+1]) ); return XMLR_Ok; } S[k2] = char(0); CreateCopy ( objTag,&(S[k1+1]) ); S[k2] = '>'; S1 = new char[slen+1]; Done = False; while ((!f.FileEnd()) && (!Done)) { k = strlen(S); while ((pos<k) && (!Done)) { k1 = pos; k2 = -1; while ((pos<k) && (k2<0)) if (S[pos]=='<') { if (S[pos+1]!='<') k2 = pos; else pos +=2; } else pos++; if (k2>=0) S[k2] = char(0); strcpy_des ( S1,&(S[k1]) ); if (S1[0]) { if (objData) CreateConcat ( objData,pstr(" "),S1 ); else CreateConcat ( objData,S1 ); } if (k2>=0) { S[k2] = '<'; if (S[k2+1]!='/') { XMLObject = new CXMLObject(); AddObject ( XMLObject ); rc = XMLObject->ReadObject ( f,S,pos,slen ); Done = (rc!=XMLR_Ok); } else { Done = True; k1 = k2+2; k2 = -1; while ((pos<k) && (k2<0)) if (S[pos]=='>') { if (S[pos+1]!='>') k2 = pos; else pos += 2; } else pos++; if (k2<0) rc = XMLR_BrokenTag; else { S[k2] = char(0); if (strcmp(objTag,&(S[k1]))) rc = XMLR_UnclosedTag; else pos++; } } } } if (!Done) { f.ReadLine ( S,slen ); pos = 0; } } delete[] S1; // this keeps pairs <tag></tag> instead of replacing them for <tag/> // on output if ((!objData) && (nObjects<=0)) CreateCopy ( objData,pstr("") ); if (rc!=XMLR_Ok) FreeMemory(); return rc; }
void Accelerators::Key::ReadRC(RCFile &rcFile) { if (rcFile.IsString()) { std::wstring str = rcFile.GetString(); if (str[0] == '^') { if (str.size() != 2) throw new std::runtime_error("Invalid key sequence"); if (str[1] == '^') key = '^'; else key = str[1] & 0x1f; } else { if (str.size() != 1) throw new std::runtime_error("Invalid key sequence"); key = str[0]; } } else { key = rcFile.GetNumber(); } rcFile.SkipComma(); id = rcFile.GetNumber(); rcFile.SkipComma(); bool done = false; while (rcFile.IsKeyword() && !done) { switch (rcFile.GetToken()->GetKeyword()) { case Lexer::ASCII: flags &= ~Virtkey; break; case Lexer::VIRTKEY: flags |= Virtkey; break; case Lexer::NOINVERT: flags |= NoInvert; break; case Lexer::SHIFT: flags |= Shift; break; case Lexer::CONTROL: flags |= Control; break; case Lexer::ALT: flags |= Alt; break; default: done = true; break; } if (!done) { rcFile.NextToken(); rcFile.SkipComma(); } } rcFile.NeedEol(); }