예제 #1
0
void Ide::SwitchHeader() {
	int c = filelist.GetCursor();
	if(c < 0) return;
	String currfile = filelist[c];
	const char *ext = GetFileExtPos(currfile);
	if(!stricmp(ext, ".h") || !stricmp(ext, ".hpp")
	|| !stricmp(ext, ".lay") || !stricmp(ext, ".iml")) {
		int f = filelist.Find(ForceExt(currfile, ".cpp"));
		if(f < 0) f = filelist.Find(ForceExt(currfile, ".c"));
		if(f < 0) f = filelist.Find(ForceExt(currfile, ".cc"));
		if(f >= 0) filelist.SetCursor(f);
	}
}
예제 #2
0
void Ide::BuildAndDebug0(const String& srcfile)
{
	if(Build()) {
		One<Host> h = CreateHostRunDir();
		h->ChDir(GetFileFolder(target));
		VectorMap<String, String> bm = GetMethodVars(method);
		String dbg = bm.Get("DEBUGGER", Null);
		if(IsNull(dbg)) {
			if(bm.Get("BUILDER", Null) == "MSC71") {
				String sln = ForceExt(target, ".sln");
				if(GetFileLength(sln) > 0)
					h->Launch("devenv \"" + h->GetHostPath(sln) + "\" "
					// + "\"" + h->GetHostPath(srcfile) + "\"" //TRC, 2011/09/26: wrong devenv argument
					);
				else
					h->Launch("devenv \"" + h->GetHostPath(target)
					//+ "\" \"" + h->GetHostPath(srcfile) //TRC, 2011/09/26: wrong devenv argument
					+ "\" /debugexe "
					);
				return;
			}
			dbg = "gdb";
		}
		else
			h->Launch('\"' + dbg + "\" \""
//			          + h->GetHostPath(srcfile) + ' '
			          + h->GetHostPath(target) + "\"", true);
	}
}
예제 #3
0
파일: ide.cpp 프로젝트: kolyden/mirror
String Ide::WorkspaceFile()
{
	String nm;
	for(const char *s = main; *s; s++)
		nm.Cat(*s == '\\' || *s == '/' ? '$' : *s);
	String cfg = ConfigFile("cfg");
	RealizeDirectory(cfg);
	return AppendFileName(cfg, ForceExt(nm + '@' + GetVarsName(), ".cfg"));
}
예제 #4
0
NewPackageFileWindow::NewPackageFileWindow()
{
	CtrlLayoutOKCancel(*this, "New package file");

	type.SetLineCy(max(Zy(16), Draw::GetStdFontCy()));
	type.SetDropLines(20);
	Type("cpp", "C++ source file");
	Type("h", "C++ header file");
	type.AddSeparator();
	Type("lay", "Layout file (dialog templates)");
	Type("iml", "Image file (icons)");
	Type("icpp", "Initialization C++ source file");
	Type("usc", "Escape script file (scripting TheIDE)");
	Type("witz", "Skylark template file (web framework files)");
	Type("qtf", "U++ rich text file");
	type.AddSeparator();
	Type("json", "JSON file");
	Type("xml", "XML file");
	Type("html", "HTML file");
	Type("css", "CSS file");
	type.AddSeparator();
	Type("sch", "SQL schema file");
	Type("ddl", "SQL DDL script file");
	Type("sql", "SQL script file");
	type.AddSeparator();
	Type("java", "Java");
	Type("js", "JavaScript");
	Type("py", "Python");
	type.AddSeparator();
	Type("", "Other");
	
	name << [=] {
		String ext = GetFileExt(~~name);
		if(ext.GetCount()) {
			ext = ext.Mid(1);
			type <<= type.HasKey(ext) ? ext : Null;
		}
		Sync();
	};
	name <<= ".cpp";
	
	type <<= "cpp";
	
	type << [=] {
		String ext = ~type;
		if(ext.GetCount()) {
			String h = ~name;
			name <<= ForceExt(h, "." + ext);
			int q = GetFileTitle(h).GetCount();
			name.SetSelection(q, q);
		}
		Sync();
	};
	
	Sync();
}
예제 #5
0
String Ide::GetLogPath()
{
	if(target.GetCount() == 0)
		return Null;
#ifdef PLATFORM_WIN32
	return ForceExt(target, ".log");
#else
	String p = GetFileTitle(target);
	return GetHomeDirFile(".upp/" + p + "/" + p + ".log");
#endif
}
예제 #6
0
파일: Debug.cpp 프로젝트: Sly14/upp-mirror
void Pdb::LoadModuleInfo()
{
	fninfo_cache.Clear();

	ModuleInfo f;
	dword cb = 1;
	HMODULE  h;
	if(!EnumProcessModules(hProcess, &h, sizeof(HMODULE), &cb)) {
		Error();
		return;
	}
	int n = cb / sizeof(HMODULE);
	Buffer<HMODULE> m(n);
	if(!EnumProcessModules(hProcess, m, cb, &cb)) {
		Error();
		return;
	}
	Vector<ModuleInfo> nm;
	for (int i = 0; i < n; i++) {
		MODULEINFO mi;
		if(GetModuleInformation(hProcess, m[i], &mi, sizeof(mi))) {
			ModuleInfo& f = nm.Add();
			f.base = (adr_t)mi.lpBaseOfDll;
			f.size = mi.SizeOfImage;
			int q = FindModuleIndex(f.base);
			if(q >= 0) {
				ModuleInfo& of = module[q];
				f.path = of.path;
				f.symbols = of.symbols;
				of.symbols = false;
				LLOG("Stable " << Hex(f.base) << " (" << Hex(f.size) << "): " << f.path);
			}
			else {
				char name[MAX_PATH];
				if(GetModuleFileNameEx(hProcess, m[i], name, MAX_PATH)) {
					f.path = name;
					if(FileExists(ForceExt(f.path, ".pdb"))) {
						adr_t w = (adr_t)SymLoadModule64(hProcess, NULL, name, 0, f.base, f.size);
						if(w) {
							LLOG("Loading symbols " << Hex(f.base) << '/' << hProcess << " returned base " << Hex(w));
							f.symbols = true;
							LoadGlobals(w);
						}
					}
				}
				LLOG(Hex(f.base) << " (" << Hex(f.size) << "): " << f.path);
			}
		}
	}
	UnloadModuleSymbols();
	module = pick(nm);
	refreshmodules = false;
}
예제 #7
0
void Ide::BuildAndExecute()
{
	if(Build()) {
		int time = msecs();
		One<Host> h = CreateHostRunDir();
		h->ChDir(Nvl(rundir, GetFileFolder(target)));
		String cmdline;
		if(!runexternal)
			cmdline << '\"' << h->GetHostPath(target) << "\" ";
		cmdline << ToSystemCharset(runarg);
		int exitcode;
		switch(runmode) {
		case RUN_WINDOW:
			HideBottom();
			h->Launch(cmdline, FindIndex(SplitFlags(mainconfigparam, true), "GUI") < 0);
			break;
		case RUN_CONSOLE:
			ShowConsole();
			PutConsole(String().Cat() << "Executing: " << cmdline);
			console.Sync();
			exitcode = h->ExecuteWithInput(cmdline);
			PutConsole("Finished in " + GetPrintTime(time) + ", exit code: " + AsString(exitcode));
			break;
		case RUN_FILE: {
				HideBottom();
				String fn;
				if(IsNull(stdout_file))
					fn = ForceExt(target, ".ol");
				else
					fn = stdout_file;
				FileOut out(fn);
				if(!out) {
					PromptOK("Unable to open output file [* " + DeQtf(stdout_file) + "] !");
					return;
				}
				if(h->Execute(cmdline, out) >= 0) {
					out.Close();
					EditFile(fn);
				}
			}
		}
	}
}
예제 #8
0
String WorkspaceWork::PackagePathA(const String& pn) {
	if(pn == prjaux) {
		String nm;
		String cfg = ConfigFile("cfg");
		for(const char *s = main; *s; s++)
			nm.Cat(*s == '\\' || *s == '/' ? '$' : *s);
		RealizeDirectory(cfg);
		return AppendFileName(cfg, ForceExt(nm + '@' + GetVarsName(), ".aux"));
	}
	if(pn == ideaux)
		return ConfigFile("ide.aux");
	if(pn == tempaux)
		return ConfigFile(Sprintf("aux%x.tmp",
#ifdef PLATFORM_WIN32
		          GetCurrentProcessId()
#endif
#ifdef PLATFORM_POSIX
		          getpid()
#endif
		       ));
	if(pn == METAPACKAGE)
		return Null;
	return PackagePath(pn);
}
예제 #9
0
String TopicCacheName(const char *path)
{
	String cfg = ConfigFile("cfg");
	RealizeDirectory(cfg);
	return AppendFileName(cfg, ForceExt(Filter(path, NoSlashDot), ".tdx"));
}
////////////////////////////
/// GENERATE MAKE FILE !
////////////////////////////
int CreateMakeFile(char *makename, char *ResourceFile, char* ListOfFiles[], char *objdir, char *LinkSwitches)
{
    int fObjPath=FALSE;
    if(strcmp(".",objdir) != 0)
        fObjPath = TRUE;

    char FMake[MAXPATHSIZE];
    strcpy(FMake,makename);
    //
    ForceExt(FMake,".MAK");
    FILE *fMak = fopen(FMake,"wt");
    if(!fMak)
    {
        return 1;
    }

    //
    char FCfg[MAXPATHSIZE];
    strcpy(FCfg,FMake);
    ForceExt(FCfg,".CFG");

    char *commentdash = "#=============================================================\n";
    char *commentline = "#\n";
    char buf[128+1];
    fprintf(fMak,commentdash);
    fprintf(fMak,commentline);
    fprintf(fMak,"#   %s  MakeFile Generated by %s\n",FMake,PROFESSOR_OWL_VERSION);
    ExpandDollar("$TIME",buf,"");
    fprintf(fMak,"#       Created on %s\n",buf);
    fprintf(fMak,commentline);
    fprintf(fMak,"%s\n",commentdash);
    fprintf(fMak,".AUTODEPEND\n\n");

    if(fObjPath)
    {
        fprintf(fMak,"# OBJ Files Are Located In Another Directory\n");
        fprintf(fMak,"OBJ_DIR = %s\n",objdir);
        fprintf(fMak,".PATH.obj = $(OBJ_DIR)\n\n");
    }

    fprintf(fMak,commentdash);
    fprintf(fMak,"#       Translator Definitions\n");
    fprintf(fMak,commentdash);
    fprintf(fMak,"CC = bcc +%s\n",FCfg);
    fprintf(fMak,"TASM = tasm\n");
    fprintf(fMak,"TLIB = tlib\n");
    fprintf(fMak,"TLINK = tlink\n");
    fprintf(fMak,"RC = brcc.exe\n");
    char LibPath[128+1];
    strcpy(LibPath,UserSetup.IncludePath);
    strupr(LibPath);
    char *p = strstr(LibPath,"\\INCLUDE");
    if(p)
    {
        strcpy(p,"\\LIB");
    }
    else
    {
        strcpy(LibPath,"C:\\BCOS2\\LIB");
    }
    fprintf(fMak,"LIBPATH = %s\n",LibPath);
    fprintf(fMak,"INCLUDEPATH = %s\n\n\n",UserSetup.IncludePath);
    fprintf(fMak,commentdash);
    fprintf(fMak,"#       Implicit Rules\n");
    fprintf(fMak,commentdash);
    fprintf(fMak,".c.obj:\n");
    fprintf(fMak,"  $(CC) -c {$< }\n");
    fprintf(fMak,"\n");
    fprintf(fMak,".cpp.obj:\n");
    fprintf(fMak,"  $(CC) -c {$< }\n");
    fprintf(fMak,"\n");
    fprintf(fMak,".asm.obj:\n");
    fprintf(fMak,"  $(TASM) -Mx $*.asm,$*.obj\n");
    fprintf(fMak,"\n");
    fprintf(fMak,".rc.res:\n");
    fprintf(fMak,"  $(RC) -r $*.rc\n");
    fprintf(fMak,"\n");
    fprintf(fMak,commentdash);
    fprintf(fMak,"#       List Macros\n");
    fprintf(fMak,commentdash);
    /////////////////////////////
    ForceExt(ResourceFile,"");
    fprintf(fMak,"LINK_EXCLUDE = \\\n %s.RES\n\n",ResourceFile);
    fprintf(fMak,"LINK_INCLUDE = \\\n");
    //
    for(int index=0; ListOfFiles[index]!= NULL; index++)
    {
        char ss[MAXPATHSIZE];
        strcpy(ss,ListOfFiles[index]);
        ForceExt(ss,".OBJ");
        fprintf(fMak," %s",ss,objdir);
        if(ListOfFiles[index+1] != NULL)
            fprintf(fMak," \\\n");
    }
    fprintf(fMak,"\n\n");
    /////////////////////////////
    fprintf(fMak,commentdash);
    fprintf(fMak,"#       Explicit Rules\n");
    fprintf(fMak,commentdash);
    ForceExt(FMake,"");
    fprintf(fMak,"%s.exe: %s.cfg $(LINK_INCLUDE) $(LINK_EXCLUDE)\n",FMake,FMake);
    fprintf(fMak,"  $(TLINK) %s /L$(LIBPATH) @&&|\n",LinkSwitches);
    fprintf(fMak,"%s\\C02.OBJ+\n",LibPath);
    //
    for(index=0; ListOfFiles[index]!= NULL; index++)
    {
        char s[MAXPATHSIZE];
        strcpy(s,ListOfFiles[index]);
        ForceExt(s,".OBJ");

        if(fObjPath)
        {
            char sp[MAXPATHSIZE];
            char sf[MAXPATHSIZE];
            PathSplit(sp,sf,s);
            fprintf(fMak,"$(OBJ_DIR)\\%s",sf); // macro path & file name
        }
        else
        {
            fprintf(fMak,"%s",s);       // path/filename.obj
        }
        if(ListOfFiles[index+1] != NULL)
            fprintf(fMak,"+\n");
        else
            fprintf(fMak,"\n");
    }
    fprintf(fMak,"%s,%s\n",FMake,FMake);
    fprintf(fMak,"$(LIBPATH)\\BIDS2.LIB+\n");
    fprintf(fMak,"$(LIBPATH)\\OWLPM.LIB+\n");
    fprintf(fMak,"$(LIBPATH)\\C2MT.LIB+\n");
    fprintf(fMak,"$(LIBPATH)\\OS2.LIB\n");
    fprintf(fMak,"\n");
    fprintf(fMak,"|\n");
    fprintf(fMak,"  RC.EXE %s.RES %s.exe\n\n",ResourceFile,FMake);
    /////////////////////////////
    fprintf(fMak,commentdash);
    fprintf(fMak,"#       Individual File Dependencies\n");
    fprintf(fMak,commentdash);
    fprintf(fMak,"%s.RES: %s.cfg %s.RC\n",ResourceFile,FMake,ResourceFile);
    fprintf(fMak,"    $(RC) -R -I$(INCLUDEPATH) -FO %s.RES %s.RC\n\n",ResourceFile,ResourceFile);
    //
    //
    for(index=0; ListOfFiles[index]!= NULL; index++)
    {
        char s[MAXPATHSIZE];
        strcpy(s,ListOfFiles[index]);
        ForceExt(s,"");
        fprintf(fMak,"%s.obj: %s.cfg %s.cpp\n\n",s,FMake,s);
    }
    /////////////////////////////
    fprintf(fMak,commentdash);
    fprintf(fMak,"#       Compiler Configuration File\n");
    fprintf(fMak,commentdash);
    fprintf(fMak,"%s.cfg: %s.mak\n",FMake,FMake);
    fprintf(fMak,"  copy &&|\n");
    fprintf(fMak,"-R\n");
    fprintf(fMak,"-L$(LIBPATH)\n");
    fprintf(fMak,"-I$(INCLUDEPATH)\n");
    ExpandDollar("$PATH",buf,"");
    fprintf(fMak,"-H=%s\\%s.CSM\n",buf,FMake);
    fprintf(fMak,"-vi-\n");
    fprintf(fMak,"-sm\n");
    fprintf(fMak,"-y\n");
    fprintf(fMak,"-v\n");
    fprintf(fMak,"-N\n");
    if(fObjPath)
    {
        fprintf(fMak,"-n$(OBJ_DIR)\n");
    }
    fprintf(fMak,"| %s.CFG\n",FMake);
    fprintf(fMak,commentdash);
    fclose(fMak);
    ///
    return 0;
}
// --------------------------------------------------------------------------
// Create all files necessary for application
// MYAPP.CPP                    FApp
// RESOURCE.RC  RESOURCE.H      FRes
// MAINDLG.CPP  MAINDLG.H       FMain
// MAINWIN.H    MAINWIN.CPP     FMain
// ABOUT.H      ABOUT.CPP       FAbout
// --------------------------------------------------------------------------
int CreateApplication(TWindow *Win, int Flags,char *FApp,char *FMain,char *FAbout,char *FRes)
{
    strlwr(FApp);
    strlwr(FMain);
    strlwr(FAbout);
    strlwr(FRes);
    //////////////////
    ForceExt(FApp,".cpp");
    //
    char FMainH[80+1];
    char FMainCPP[80+1];
    strcpy(FMainH,FMain);
    strcpy(FMainCPP,FMain);
    ForceExt(FMainCPP,".cpp");
    ForceExt(FMainH,".h");
    //
    char FAboutH[80+1];
    char FAboutCPP[80+1];
    strcpy(FAboutH,FAbout);
    strcpy(FAboutCPP,FAbout);
    ForceExt(FAboutH,".h");
    ForceExt(FAboutCPP,".cpp");
    //
    char FResH[80+1];
    char FResRC[80+1];
    strcpy(FResH,FRes);
    strcpy(FResRC,FRes);
    ForceExt(FResH,".h");
    ForceExt(FResRC,".rc");
    //
    ///
    int decorated = (Flags & ( NEWAPPFLAG_CONTROLBAR | NEWAPPFLAG_STATUSBAR ) );
    int retCode = 0;
    //
    //
    FILE *fMyApp = fopen(FApp,"wt");
    if(!fMyApp)
    {
        return 1;
    }
    fprintf(fMyApp,"#include <%s\\owlpch.h>\n",UserSetup.OwlPath);
    fprintf(fMyApp,"#include <%s\\applicat.h>\n",UserSetup.OwlPath);

    if(decorated)
    {
        if(Flags & NEWAPPFLAG_STATUSBAR)
        {
            fprintf(fMyApp,"#include <%s\\statusba.h>\n",UserSetup.OwlPath);
        }
        if(Flags & NEWAPPFLAG_CONTROLBAR)
        {
            fprintf(fMyApp,"#include <%s\\controlb.h>\n",UserSetup.OwlPath);
            fprintf(fMyApp,"#include <%s\\buttonga.h>\n",UserSetup.OwlPath);
        }
        fprintf(fMyApp,"#include <%s\\decframe.h>\n",UserSetup.OwlPath);
    }
    else // non decorated
    {
        fprintf(fMyApp,"#include <%s\\framewin.h>\n",UserSetup.OwlPath);
    }

    fprintf(fMyApp,"#include \"%s\"\n",FResH);
    fprintf(fMyApp,"#include <%s\\dialog.h>\n",UserSetup.OwlPath);
    //
    fprintf(fMyApp,"#include \"%s\"\n",FMainH);
    fprintf(fMyApp,"#include \"%s\"\n",FAboutH);
    fprintf(fMyApp,"//\n");
    fprintf(fMyApp,"//\n");
    fprintf(fMyApp,"// My Application Class\n");
    fprintf(fMyApp,"//\n");
    fprintf(fMyApp,"class TMyApp : public TApplication\n");
    fprintf(fMyApp,"{\n");
    fprintf(fMyApp,"public:\n");
    fprintf(fMyApp,"%sTMyApp(void);\n",UserSetup.Tabs);
    fprintf(fMyApp,"protected:\n");
    fprintf(fMyApp,"%svoid InitMainWindow(void);\n",UserSetup.Tabs);
    fprintf(fMyApp,"};\n\n\n");
    ///
    fprintf(fMyApp,"// My Application Constructor\n");
    fprintf(fMyApp,"TMyApp::TMyApp(void) : TApplication()\n");
    fprintf(fMyApp,"{\n");
    fprintf(fMyApp,"}\n\n");
    //
    fprintf(fMyApp,"void TMyApp::InitMainWindow(void)\n");
    fprintf(fMyApp,"{\n");

    if(decorated)
    {   // USE DECORATED FRAME
        if(Flags & NEWAPPFLAG_DIALOG)
            fprintf(fMyApp,"%sTDecoratedFrame *Frame = new TDecoratedFrame(0, \"My Decorated Frame Application\", new MainDlg((TWindow*)0));\n",UserSetup.Tabs);
        if(Flags & NEWAPPFLAG_SDI)
            fprintf(fMyApp,"%sTDecoratedFrame *Frame = new TDecoratedFrame(0, \"My Decorated Frame Application\", new MainWin((TWindow*)0));\n",UserSetup.Tabs);

        if(Flags & NEWAPPFLAG_CONTROLBAR)
        {
            fprintf(fMyApp,"%sTControlBar *Cbar = new TControlBar(Frame);\n",UserSetup.Tabs);
            fprintf(fMyApp,"%sCbar->Insert(*new TButtonGadget(BM_ABOUT,CM_ABOUT,TButtonGadget::Command) );\n",UserSetup.Tabs);
            fprintf(fMyApp,"%sFrame->Insert(*Cbar, TDecoratedFrame::Top);\n",UserSetup.Tabs);
        }
        if(Flags & NEWAPPFLAG_STATUSBAR)
        {
            fprintf(fMyApp,"%sTStatusBar *Sbar = new TStatusBar(Frame,TGadget::Embossed);\n",UserSetup.Tabs);
            fprintf(fMyApp,"%sFrame->Insert(*Sbar, TDecoratedFrame::Bottom);\n",UserSetup.Tabs);
        }
        fprintf(fMyApp,"%sSetMainWindow( Frame );\n",UserSetup.Tabs);
    }
    else // No Decorated Frame
    {
        if(Flags & NEWAPPFLAG_DIALOG)
            fprintf(fMyApp,"%sSetMainWindow( new TFrameWindow(0, \"My Dialog Application\", new MainDlg((TWindow*)0) ));\n",UserSetup.Tabs);
        else if(Flags & NEWAPPFLAG_SDI)
            fprintf(fMyApp,"%sSetMainWindow( new TFrameWindow(0, \"My Window Application\", new MainWin(0) ));\n",UserSetup.Tabs);
        //
        fprintf(fMyApp,"%sMainWindow->SetIcon(this,ID_MAINICON);\n",UserSetup.Tabs);
        //
    }
    if(Flags & NEWAPPFLAG_DIALOG)
    {
        fprintf(fMyApp,"%sMainWindow->Attr.Style &= ~WS_MAXIMIZEBOX;\n",UserSetup.Tabs);
    }
    if(Flags & NEWAPPFLAG_MENU)
    {
        fprintf(fMyApp,"%sGetMainWindow()->AssignMenu(ID_MAINMENU);\n",UserSetup.Tabs);
    }
    fprintf(fMyApp,"}\n\n");
    fprintf(fMyApp,"int OwlMain(int argc, char *argv[])\n");
    fprintf(fMyApp,"{\n");
    fprintf(fMyApp,"%sreturn TMyApp().Run();\n",UserSetup.Tabs);
    fprintf(fMyApp,"}\n");
    fclose(fMyApp);
    // -----------------------------------

    FILE *fR = fopen(FResH,"wt");
    if(!fR)
    {
        return 2;
    }
    fprintf(fR,"// Resouce ID Constants\n");
    fprintf(fR,"#define%sID_MAINICON%s1\n",UserSetup.Tabs,UserSetup.Tabs);
    fprintf(fR,"#define%sCM_ABOUT%s997\n",UserSetup.Tabs,UserSetup.Tabs);
    fprintf(fR,"#define%sID_ABOUTDIALOG%s1002\n",UserSetup.Tabs,UserSetup.Tabs);

    if(Flags & NEWAPPFLAG_DIALOG)
    {
        fprintf(fR,"#define%sID_MAINDIALOG%s1001\n",UserSetup.Tabs,UserSetup.Tabs);
    }
    if(Flags & NEWAPPFLAG_MENU)
    {
        fprintf(fR,"#define%sID_MAINMENU%s101\n",UserSetup.Tabs,UserSetup.Tabs);
    }

    if(Flags & (NEWAPPFLAG_MENU | NEWAPPFLAG_DIALOG) )
    {
        fprintf(fR,"#define%sCM_HELP%s301\n",UserSetup.Tabs,UserSetup.Tabs);
        fprintf(fR,"#define%sCM_HELPINDEX%s302\n",UserSetup.Tabs,UserSetup.Tabs);
    }
    if(Flags & NEWAPPFLAG_CONTROLBAR)
    {
        fprintf(fR,"#define%sBM_ABOUT%s398\n",UserSetup.Tabs,UserSetup.Tabs);
    }
    fclose(fR);
    ///-----------------------------------
    fR = fopen(FResRC,"wt");
    if(!fR)
    {
        return 2;
    }
    fprintf(fR,"#include \"%s\"\n",FResH);
    fprintf(fR,"#include <%s\\edit.rh>\n",UserSetup.OwlPath);
    fprintf(fR,"#include <%s\\docview.rh>\n",UserSetup.OwlPath);
    fprintf(fR,"#include <%s\\mdi.rh>\n",UserSetup.OwlPath);
    fprintf(fR,"\n");
    if(Flags & NEWAPPFLAG_DIALOG)
    {
        fprintf(fR,"DLGTEMPLATE ID_MAINDIALOG\n");
        fprintf(fR,"BEGIN\n");
        fprintf(fR,"    DIALOG \"\", ID_MAINDIALOG, 0, 0, 172, 113, FS_NOMOVEWITHOWNER | NOT FS_DLGBORDER | NOT WS_SAVEBITS | WS_VISIBLE | WS_CLIPSIBLINGS, FCF_NOBYTEALIGN\n");
        fprintf(fR,"    BEGIN\n");
        fprintf(fR,"        DEFPUSHBUTTON \"Close\", DID_OK, 6, 4, 51, 14\n");
        fprintf(fR,"        PUSHBUTTON \"~About\", CM_ABOUT, 60, 4, 51, 14\n");
        fprintf(fR,"        PUSHBUTTON \"~Help\", CM_HELP, 114, 4, 51, 14, BS_HELP\n");
        fprintf(fR,"    END\n");
        fprintf(fR,"END\n\n");
    }

    fprintf(fR,"DLGTEMPLATE ID_ABOUTDIALOG\n");
    fprintf(fR,"BEGIN\n");
    fprintf(fR,"    DIALOG \"About This Application\", ID_ABOUTDIALOG, 50, 79, 163, 67, WS_VISIBLE, FCF_SYSMENU | FCF_TITLEBAR\n");
    fprintf(fR,"    BEGIN\n");
    fprintf(fR,"        DEFPUSHBUTTON \"OK\", DID_OK, 104, 4, 51, 14\n");
    fprintf(fR,"        CONTROL \"Use Resource Workshop To\\n");
    fprintf(fR,"Put Your Product Name\\n");
    fprintf(fR,"And Version Number Here\", 101, 8, 28, 144, 32, WC_STATIC, SS_TEXT | DT_CENTER | DT_TOP | DT_WORDBREAK | DT_MNEMONIC | WS_VISIBLE\n");
    fprintf(fR,"    END\n");
    fprintf(fR,"END\n\n");

    if(Flags & NEWAPPFLAG_MENU)
    {
        fprintf(fR,"MENU ID_MAINMENU\n");
        fprintf(fR,"BEGIN\n");
        fprintf(fR,"    SUBMENU \"~File\", 100\n");
        fprintf(fR,"    BEGIN\n");
        fprintf(fR,"        MENUITEM \"~New...\", CM_FILENEW\n");
        fprintf(fR,"        MENUITEM \"~Open...\", CM_FILEOPEN\n");
        fprintf(fR,"        MENUITEM SEPARATOR\n");
        fprintf(fR,"        MENUITEM \"~Save...\", CM_FILESAVE\n");
        fprintf(fR,"        MENUITEM \"Save ~As...\", CM_FILESAVEAS\n");
        fprintf(fR,"        MENUITEM SEPARATOR\n");
        fprintf(fR,"        MENUITEM \"~Exit...\", CM_EXIT\n");
        fprintf(fR,"    END\n");
        fprintf(fR,"\n");
        fprintf(fR,"    SUBMENU \"~Edit\", 200\n");
        fprintf(fR,"    BEGIN\n");
        fprintf(fR,"        MENUITEM \"Cu~t\\tShift+Del\", CM_EDITCUT\n");
        fprintf(fR,"        MENUITEM \"~Copy\\tCtrl+Ins\", CM_EDITCOPY\n");
        fprintf(fR,"        MENUITEM \"~Paste\\tShift+Ins\", CM_EDITPASTE\n");
        fprintf(fR,"        MENUITEM \"C~lear\\tDel\", CM_EDITDELETE\n");
        fprintf(fR,"    END\n");
        fprintf(fR,"\n");
        fprintf(fR,"    SUBMENU \"~Help\", 300\n");
        fprintf(fR,"    BEGIN\n");
        fprintf(fR,"        MENUITEM \"~General help...\", CM_HELP\n");
        fprintf(fR,"        MENUITEM \"Help ~index...\", CM_HELPINDEX\n");
        fprintf(fR,"        MENUITEM SEPARATOR\n");
        fprintf(fR,"        MENUITEM \"~About...\", CM_ABOUT\n");
        fprintf(fR,"    END\n");
        fprintf(fR,"END\n");
        fprintf(fR,"\n");
    }


    fprintf(fR,"\n");
    fprintf(fR,"POINTER ID_MAINICON\n");
    fprintf(fR,"BEGIN\n");
    extern unsigned char MyIconData[];
    WriteHexBlock(fR,64*16+2,MyIconData);
    fprintf(fR,"END\n\n");

    //
    // CM_ABOUT ICON
    //
    if(Flags & NEWAPPFLAG_CONTROLBAR)
    {
        fprintf(fR,"\n");
        fprintf(fR,"BITMAP BM_ABOUT\n");
        fprintf(fR,"BEGIN\n");
        extern unsigned char CmAboutData[];
        WriteHexBlock(fR,(42*16)-4,CmAboutData);
        fprintf(fR,"END\n\n");
    }
    fclose(fR);

    if(Flags & NEWAPPFLAG_DIALOG)
    {
        FILE *fc = fopen(FMainCPP,"wt");
        if(!fc)
            return 3;
        fprintf(fc,"#define  INCL_WINMESSAGEMGR\n");
        fprintf(fc,"#include <os2.h>\n");
        fprintf(fc,"#include <%s\\dialog.h>\n",UserSetup.OwlPath);
        fprintf(fc,"#include \"%s\"\n",FAboutH);
        fclose(fc);

        retCode = CreateClassTDialog(FMainH, FMainCPP,  "MainDlg",
                                        "ID_MAINDIALOG",FResH);

        char cd1[256+1];
        // When Dialog is destroyed - take parent with it !
        Cproto X;
        sprintf(cd1,"%sWinPostMsg(GetParent(), WM_CLOSE, 0, 0);",UserSetup.Tabs);
        X.WriteCode(FMainCPP,"MainDlg","EvClickOk",cd1,FALSE);
        //
        X.WriteCode(FMainCPP,"MainDlg","EvClickCancel",cd1,FALSE);
        X.AddEvent(FMainCPP,"MainDlg","EV_BN_CLICKED","CM_ABOUT","EvClickAbout");
        sprintf(cd1,"%sAboutDlg MyAbout(this);\n%sMyAbout.Execute();\n",UserSetup.Tabs,UserSetup.Tabs);
        X.AddFunction(FMainH,FMainCPP, "MainDlg", "protected",
            "","void","EvClickAbout","void","Clicked On About Button/Menu",cd1);
    }

    if(Flags & NEWAPPFLAG_SDI)
    {
        retCode = CreateClassTWindow(FMainH, FMainCPP,
                                        "MainWin",FResH);
        Cproto X;
        X.AddEvent(FMainCPP,"MainWin","EV_COMMAND","CM_ABOUT","EvClickAbout");
        char cd1[256+1];
        sprintf(cd1,"%sAboutDlg MyAbout(this);\n%sMyAbout.Execute();\n",UserSetup.Tabs,UserSetup.Tabs);
        X.AddFunction(FMainH,FMainCPP, "MainWin", "protected",
            "","void","EvClickAbout","void","Clicked On About Button/Menu",cd1);
        X.AppendIncludeFile(FMainCPP,FAboutH);
        GetHeaderForClass(cd1,"TDialog");
        X.AppendIncludeFile(FMainCPP,cd1);
    }

    retCode = CreateClassTDialog(FAboutH,FAboutCPP,"AboutDlg","ID_ABOUTDIALOG",FResH);

    char *ListOfFiles[4] = {    FApp, FAboutCPP, FMainCPP, NULL };
    char makename[MAXPATHSIZE+1];
    strcpy(makename,FApp);
    ForceExt(makename,"");
    CreateMakeFile(makename,FResRC,ListOfFiles,".","/wdpl /Toe /aa");
    ///
    char msg[128+1];
    sprintf(msg," ( make -f%s.mak )\n\n"
                "Would You Like To Start\n"
                "The Compiler and Linker\n"
                "To Build %s.EXE Now ?",makename,makename);
    if( Win->MessageBox(msg,"BUILD APPLICATION",MB_YESNOno) == IDYES)
    {
        sprintf(msg,"-f%s.MAK",makename);
        StartApp(0, "Professor Owl Make",".\\","MAKE.EXE",msg);
    }
    return(retCode);
}
예제 #12
0
void DlgSqlExport::Run(Sql& cursor, String command, String tablename)
{
	Title(Nvl(tablename, t_("SQL query")) + t_(" export"));
	object_name <<= tablename;
	if(!cursor.Execute(command)) {
		Exclamation(NFormat(t_("Error executing [* \1%s\1]: \1%s"), command, cursor.GetLastError()));
		return;
	}
	for(int i = 0; i < cursor.GetColumns(); i++) {
		const SqlColumnInfo& sci = cursor.GetColumnInfo(i);
		String type;
		switch(sci.valuetype) {
			case BOOL_V:
			case INT_V: type = t_("integer"); break;
			case DOUBLE_V: type = t_("real number"); break;
			case STRING_V:
			case WSTRING_V: type = t_("string"); break;
			case DATE_V: type = t_("date"); break;
			case TIME_V: type = t_("date/time"); break;
			case /*ORA_BLOB_V*/-1: type = t_("BLOB"); break;
			case /*ORA_CLOB_V*/-2: type = t_("CLOB"); break;
			default: type = FormatInt(sci.valuetype); break;
		}
		columns.Add(sci.name, sci.valuetype, sci.width, 1);
	}
	static String cfg;
	LoadFromString(*this, cfg);
	SyncUI();
	while(TopWindow::Run() == IDOK)
		try {
			String out_table = ~object_name;
			String delim;
			switch((int)~delimiters) {
				case DELIM_TAB: delim = "\t"; break;
				case DELIM_SEMICOLON: delim = ";"; break;
			}
			Vector<int> out;
			String colstr;
			String title;
			for(int i = 0; i < columns.GetCount(); i++)
				if(columns.Get(i, 3)) {
					out.Add(i);
					String cname = cursor.GetColumnInfo(i).name;
					colstr << (i ? ", " : "") << cname;
					if(i) title << delim;
					title << cname;
				}
			if(out.IsEmpty()) {
				throw Exc(t_("No columns selected!"));
				continue;
			}
			String rowbegin, rowend;
			int fmt = ~format;
			FileSel fsel;
			String ext;
			switch(fmt) {
				case FMT_TEXT: {
					rowend = "";
					ext = ".txt";
					fsel.Type(t_("Text files (*.txt)"), "*.txt");
					break;
				}
				case FMT_SQL: {
					if(identity_insert)
						rowbegin << "set identity_insert " << out_table << " on ";
					rowbegin << "insert into " << out_table << "(" << colstr << ") values (";
					rowend = ");";
					ext = ".sql";
					fsel.Type(t_("SQL scripts (*.sql)"), "*.sql");
					break;
				}
			}
			fsel.AllFilesType().DefaultExt(ext.Mid(1));
			if(!IsNull(recent_file))
				fsel <<= ForceExt(recent_file, ext);
			if(!fsel.ExecuteSaveAs(t_("Save export as")))
				continue;
			recent_file = ~fsel;
			FileOut fo;
			if(!fo.Open(recent_file)) {
				Exclamation(NFormat(t_("Error creating file [* \1%s\1]."), recent_file));
				continue;
			}
			if(fmt == FMT_TEXT)
				fo.PutLine(title);
			Progress progress(t_("Exporting row %d"));
			while(cursor.Fetch()) {
				String script = rowbegin;
				for(int i = 0; i < out.GetCount(); i++) {
					Value v = cursor[out[i]];
					switch(fmt) {
						case FMT_TEXT: {
							if(i)
								script.Cat(delim);
							if(IsString(v) && quote) {
								String s = v;
								script << '\"';
								for(const char *p = s, *e = s.End(); p < e; p++)
									if(*p == '\"')
										script.Cat("\"\"");
									else
										script.Cat(*p);
								script << '\"';
							}
							else
								script << StdFormat(v);
							break;
						}
						case FMT_SQL: {
							if(i) script.Cat(", ");
//							script << SqlCompile(SQLD_ORACLE, SqlFormat(v));
							break;
						}
					}
				}
				script << rowend;
				fo.PutLine(script);
/*
				if(autocommit && --left <= 0) {
					fo.PutLine("commit;");
					left = autocommit;
				}
*/
				if(progress.StepCanceled()) {
					Exclamation(t_("Export aborted!"));
					return;
				}
			}
			fo.Close();
			if(fo.IsError())
				throw Exc(NFormat(t_("Error writing file %s."), recent_file));
			break;
		}
		catch(Exc e) {
			ShowExc(e);
		}

	cfg = StoreAsString(*this);
}