GDocApp<OptionsFmt>::GDocApp(const char *appname, const TCHAR *icon, char *optsname) { Options = 0; _LangOptsName = 0; d = new GDocAppPrivate(this, optsname); GRect r(0, 0, 800, 600); SetPos(r); MoveToCenter(); _FileMenu = 0; d->AppName = NewStr(appname?appname:(char*)"Lgi.GDocApp"); char p[MAX_PATH]; if (LgiGetSystemPath(LSP_APP_INSTALL, p, sizeof(p))) { LgiMakePath(p, sizeof(p), p, "_write_test.txt"); GFile f; if (!f.Open(p, O_WRITE)) { d->Mode = InstallDesktop; } else { f.Close(); FileDev->Delete(p, false); } } SetQuitOnClose(true); // Setup class if (icon) { #if defined WIN32 GWin32Class *c = GWin32Class::Create(d->AppName); if (c) { #ifdef UNICODE GPointer p; p.w = (TCHAR*)icon; if (p.i < 0x10000) { c->Class.hIcon = LoadIcon(LgiProcessInst(), MAKEINTRESOURCE(icon)); } else { GAutoWString wIcon(NewStrW(icon)); c->Class.hIcon = LoadIcon(LgiProcessInst(), wIcon); } #else c->Class.hIcon = LoadIcon(LgiProcessInst(), ((NativeInt)icon&0xffff0000)?icon:MAKEINTRESOURCE(icon)); #endif } #else if (icon) SetIcon(icon); #endif } }
/* ==================== GLoad ==================== */ const GData* GLoad(const CHAR* path) { GFile file; file.Open(path); U32 pos = file.Seek(0,FS_CUR); U32 size = file.Seek(0,FS_END); file.Seek(pos,FS_SET); GData* data = GNEW(GData(size+1,0)); CHECK(data); CHECK(file.Read(data->Ptr(),data->Size())==size); file.Close(); return data; }
bool Load(char *File) { bool Status = false; Langs.Empty(); DeleteObj(Tree); Tree = new GXmlTag; if (Tree) { if (File) { GFile f; if (f.Open(File, O_READ)) { GXmlTree t(GXT_NO_ENTITIES); if (t.Read(Tree, &f, 0)) { CollectLangs(Tree); List<GLanguage> Lst; const char *Key = 0; for (bool p = Langs.First(&Key); p; p = Langs.Next(&Key)) { Lst.Insert((GLanguage*)p); } Lst.Sort(Cmp, 0); for (GLanguage *l = Lst.First(); l; l = Lst.Next()) { Inc->Insert(new LangInc(l)); } Status = true; } else { LgiMsg(this, "Couldn't parse XML.", AppName); } } else { LgiMsg(this, "Couldn't open '%s'\n", AppName, MB_OK, File); } } else { LgiMsg(this, "No file.", AppName); } } return Status; }
bool SerializeOpts(ObjProperties *p, bool Write) { bool Status = false; if (p) { GFile f; if (f.Open(OptionsFile, Write?O_WRITE:O_READ)) { if (Write) f.SetSize(0); Status = p->Serialize(f, Write); } } return Status; }
bool Save(char *File) { bool Status = false; if (Tree AND Inc) { if (Langs.Length()) { // scan tree, removing the languages we don't want RemoveLangs(Tree); // write the remaining tree out to a file... GFile f; if (f.Open(File, O_WRITE)) { f.SetSize(0); GXmlTree t(GXT_NO_ENTITIES | GXT_NO_PRETTY_WHITESPACE); if (t.Write(Tree, &f)) { Status = true; } else { LgiMsg(this, "XML output failed.", AppName); } } else { LgiMsg(this, "Couldn't open '%s'.", AppName, MB_OK, File); } } else { LgiMsg(this, "No languages selected.", AppName); } } return Status; }