Exemplo n.º 1
0
ProjectPtr CppCheckPlugin::FindSelectedProject()
{
    ProjectPtr proj = NULL;

    if(!m_mgr->GetWorkspace() || !m_mgr->IsWorkspaceOpen()) { return proj; }

    TreeItemInfo item = m_mgr->GetSelectedTreeItemInfo(TreeFileView);
    if(item.m_itemType == ProjectItem::TypeProject) {
        wxString project_name(item.m_text);
        wxString err_msg;
        proj = m_mgr->GetWorkspace()->FindProjectByName(project_name, err_msg);
    }

    return proj;
}
Exemplo n.º 2
0
void MacBundler::onBundleInvoked_selected(wxCommandEvent& evt)
{
    if(not m_mgr->GetWorkspace() or not m_mgr->IsWorkspaceOpen()) return;

    TreeItemInfo item = m_mgr->GetSelectedTreeItemInfo(TreeFileView);
    if(item.m_itemType == ProjectItem::TypeProject) {

        wxString project_name(item.m_text);
        wxString err_msg;

        ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(project_name, err_msg);
        if(not proj) return;

        showSettingsDialogFor(proj);
    } else {
        wxMessageBox(_("This menu item can only be invoked when right-clicking a project."));
    }
}
Exemplo n.º 3
0
void MainWnd_OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem) {
    if (lpDrawItem->itemID == -1)
        return;
    RECT rect = lpDrawItem->rcItem;
    project_t *project = project_get(lpDrawItem->itemID);
    WCHAR *name = U2W(project_name(project));
    HFONT hOldFont;

    // http://www.codeproject.com/KB/combobox/TransListBox.aspx
    switch (lpDrawItem->itemAction) {
        case ODA_SELECT:
        case ODA_DRAWENTIRE:
            if (lpDrawItem->itemState & ODS_SELECTED) {
                DrawState(lpDrawItem->hDC, NULL, NULL, (LPARAM)g_hListBoxSelectionBgBitmap, 0, rect.left, rect.top, 0, 0, DST_BITMAP);
            } else {
                RECT parentRect = rect;
                MapWindowPoints(g_hProjectListView, g_hMainWindow, (LPPOINT)&parentRect, 2);

                HDC hBitmapDC = CreateCompatibleDC(lpDrawItem->hDC);
                HBITMAP hOldBitmap = SelectBitmap(hBitmapDC, g_hMainWindowBgBitmap);
                BitBlt(lpDrawItem->hDC, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
                    hBitmapDC, parentRect.left, parentRect.top, SRCCOPY);
                SelectBitmap(hBitmapDC, hOldBitmap);
                DeleteDC(hBitmapDC);
            }
            DrawState(lpDrawItem->hDC, NULL, NULL, (LPARAM)g_hProjectIcon, 0, rect.left + 18, rect.top + 2, 0, 0, DST_ICON);
            SetTextAlign(lpDrawItem->hDC, TA_TOP | TA_LEFT);
            hOldFont = SelectFont(lpDrawItem->hDC, g_hNormalFont12);
            if (lpDrawItem->itemState & ODS_SELECTED) {
                SetTextColor(lpDrawItem->hDC, RGB(0xFF, 0xFF, 0xFF));
            } else {
                SetTextColor(lpDrawItem->hDC, RGB(0x00, 0x00, 0x00));
            }
            TextOut(lpDrawItem->hDC, rect.left + 39, rect.top + 1, name, wcslen(name));
            SelectFont(lpDrawItem->hDC, hOldFont);
    }
}
Exemplo n.º 4
0
int main(int argc,char *argv[]) 
{
	//
	// Some initialization for the common library
	//
	SetApplicationParameters(
		"MemMap",
		TOOL_VERSION_MAJOR,
		TOOL_VERSION_MINOR,
		"{ApplicationName} - Version {ApplicationVersion} - This program is a part of the OSDK\r\n"
		"\r\n"
		"Author:\r\n"
		"  Pointier Mickael\r\n"
		"\r\n"
		"Switches:\r\n"
		" -f   Format\r\n"
		"       -f0 => XA (Oric) [default]\r\n"
		"       -f1 => Devpac (Atari ST)\r\n"
		"\r\n"
		);


	INPUT_FORMAT inputFormat=INPUT_FORMAT_ORIC_XA;		// 0=XA / 1=Devpac

	ArgumentParser cArgumentParser(argc,argv);

	while (cArgumentParser.ProcessNextArgument())
	{
		if (cArgumentParser.IsSwitch("-f"))
		{
			//format: [-f]
			//	0 => XA (Oric)
			// 	1 => Devpac (Atari)
			inputFormat=(INPUT_FORMAT)cArgumentParser.GetIntegerValue(INPUT_FORMAT_ORIC_XA);
		}
	}


    if (cArgumentParser.GetParameterCount()!=NB_ARG)
    {
		ShowError(0);
    }


	//
	// Copy last parameters
	//
	std::string	source_name(cArgumentParser.GetParameter(0));
	std::string	dest_name(cArgumentParser.GetParameter(1));
	std::string	project_name(cArgumentParser.GetParameter(2));
	std::string	css_name(cArgumentParser.GetParameter(3));

	/*
	printf("\n0=%s\n",source_name.c_str());
	printf("\n1=%s\n",dest_name.c_str());
	printf("\n2=%s\n",project_name.c_str());
	printf("\n3=%s\n",css_name.c_str());
	*/

	void* ptr_buffer_void;
	size_t size_buffer_src;

	//
	// Load the file
	//
	if (!LoadFile(source_name.c_str(),ptr_buffer_void,size_buffer_src))
	{
		printf("\nUnable to load file '%s'",source_name.c_str());
		printf("\n");
		exit(1);
	}

	unsigned char *ptr_buffer=(unsigned char*)ptr_buffer_void;

	//
	// Parse the file, and generate the list of values
	//
	std::map<std::string,Section>	Sections;

	switch (inputFormat)
	{
	case INPUT_FORMAT_ORIC_XA:
		{
			Section& section_zeropage=Sections["Zero"];
			section_zeropage.m_anchor_name	="Zero";
			section_zeropage.m_section_name	="Zero page";
			section_zeropage.m_adress_size	=2;
			section_zeropage.m_begin_adress	=0x0;
			section_zeropage.m_end_adress	=0xFF;

			Section& section_normal=Sections["Normal"];
			section_normal.m_anchor_name	="Normal";
			section_normal.m_section_name	="Normal memory";
			section_normal.m_adress_size	=4;
			section_normal.m_begin_adress	=0x400;
			section_normal.m_end_adress		=0xBFFF;

			Section& section_overlay=Sections["Overlay"];
			section_overlay.m_anchor_name	="Overlay";
			section_overlay.m_section_name	="Overlay memory";
			section_overlay.m_adress_size	=4;
			section_overlay.m_begin_adress	=0xC000;
			section_overlay.m_end_adress	=0xFFFF;
		}
		break;

	case INPUT_FORMAT_ATARI_DEVPAC:
		{
			Section& section_zeropage=Sections["Text"];
			section_zeropage.m_anchor_name	="Text";
			section_zeropage.m_section_name	="Section TEXT";
			section_zeropage.m_adress_size	=4;
			section_zeropage.m_begin_adress	=0x00;
			section_zeropage.m_end_adress	=0xFFFFFF;

			Section& section_normal=Sections["Data"];
			section_normal.m_anchor_name	="Data";
			section_normal.m_section_name	="Section DATA";
			section_normal.m_adress_size	=4;
			section_normal.m_begin_adress	=0x00;
			section_normal.m_end_adress		=0xFFFFFF;

			Section& section_overlay=Sections["Bss"];
			section_overlay.m_anchor_name	="Bss";
			section_overlay.m_section_name	="Section BSS";
			section_overlay.m_adress_size	=4;
			section_overlay.m_begin_adress	=0x00;
			section_overlay.m_end_adress	=0xFFFFFF;

			Section& section_rs=Sections["RS"];
			section_rs.m_anchor_name	="RS";
			section_rs.m_section_name	="RS offsets";
			section_rs.m_adress_size	=4;
			section_rs.m_begin_adress	=0x00;
			section_rs.m_end_adress	=0xFFFFFF;
		}
		break;
	}


	char *ptr_tok=strtok((char*)ptr_buffer," \r\n");
	while (ptr_tok)
	{
		// Address
		int value=strtol(ptr_tok,0,16);

		switch (inputFormat)
		{
		case INPUT_FORMAT_ORIC_XA:
			{
				ptr_tok=strtok(0," \r\n");
				// Name
				if (value<256)
				{
					// Zero page
					Sections["Zero"].GetMap()[value]=ptr_tok;
				}
				else
				if (value>=0xc000)
				{
					// Overlay memory
					Sections["Overlay"].GetMap()[value]=ptr_tok;
				}
				else
				{
					Sections["Normal"].GetMap()[value]=ptr_tok;
				}
			}
			break;
		case INPUT_FORMAT_ATARI_DEVPAC:
			{
				// ptr_tok:
				// A=Absolute (rs/offsets/computations)
				// R=Relocatable (addresses)
				// T=TEXT
				// D=DATA
				// B=BSS
				std::string section="Text";

				std::string token;
				do
				{
					ptr_tok=strtok(0," \r\n");
					token=ptr_tok;
					if (token=="A")			section="RS";
					else if (token=="B")	section="Bss";
					else if (token=="T")	section="Text";
					else if (token=="D")	section="Data";
				}
				while (token.size()==1);

				Sections[section].GetMap()[value]=token;
			}
		}
		ptr_tok=strtok(0," \r\n");
	}


	//
	// Generate the html file
	//
	std::string html(gHtmlHeader);

	StringReplace(html,"{PageTitle}"	,project_name);
	StringReplace(html,"{CssLink}"		,css_name);

	/*
	html+="<A href=\"#Zero\">Zero page</A><br>";
	html+="<A href=\"#Normal\">Normal memory</A><br>";
	html+="<A href=\"#Overlay\">Overlay memory</A><br>";
	*/

	html+="<table>\r\n";
	html+="<tr>\r\n";

	std::map<std::string,Section>::const_iterator it(Sections.begin());
	while (it!=Sections.end())
	{
		const Section& section=it->second;
		html+="<td valign=top>\r\n";
		section.Generate(html);
		html+="</td>\r\n";
		++it;
	}

	html+="</tr>\r\n";
	html+="</table>\r\n";

	html=html+gHtmlFooter;

	unsigned char *ptr_buffer_dst=new unsigned char[size_buffer_src+8];
	int size_buffer_dst=size_buffer_src/2;

	unsigned char *ptr_src=ptr_buffer;
	unsigned char *ptr_dst=ptr_buffer_dst;
	int i;
	for (i=0;i<size_buffer_dst;i++)
	{
		unsigned char b0=*ptr_src++;
		unsigned char b1=*ptr_src++;
		unsigned char b=(b1&0xF0)|(b0>>4);
		*ptr_dst++=b;
	}

	if (!SaveFile(dest_name.c_str(),html.c_str(),html.size()))
	{
		printf("\nUnable to save file '%s'",source_name.c_str());
		printf("\n");
		exit(1);
	}

	//
	// Make some cleaning
	//
	delete[] ptr_buffer;
	delete[] ptr_buffer_dst;

	return 0;
}
Exemplo n.º 5
0
	static int load()
	{
		FreeTypeDecoder::initialize();

		ShowWindow(GetConsoleWindow(), SW_HIDE);

		Graphics3D * graphics = D3DGraphics::initialize();
		FinalAction finally(D3DGraphics::free);

		graphics->setClearColor({0.0f, 0.0f, 0.0f});

		Handle<Window> window(graphics, 0, 0, 1024, 758);
		Handle<WindowBackground> back(window);
		back->name = "Background";

		Handle<Panel> frame(back);
		frame->setPlacement({0.5f, 0.5f, 0.5f, 0.5f}, {-300, -300, 300, 300});
		frame << [](const DrawParams & p)
		{
			p.graphics->setColor({0.25f, 0.25f, 0.25f});
			p.graphics->rectangle(p.clipped);
		};

		Handle<Panel> frame0(frame);
		frame0->setPlacement(ModelMask::FullSize, {4, 4, -4, -4});
		frame0 << [](const DrawParams & p)
		{
			p.graphics->setColor({0.5f, 0.5f, 0.5f});
			p.graphics->rectangle(p.clipped);
		};

		Handle<Panel> frame1(frame0);
		frame1->setPlacement(ModelMask::FullSize, {3, 3, -3, -3});
		frame1 << [](const DrawParams & p)
		{
			p.graphics->setColor({0.75f, 0.75f, 0.75f});
			p.graphics->rectangle(p.clipped);
		};

		Handle<Panel> frame2(frame1);
		frame2->setPlacement(ModelMask::FullSize, {2, 2, -2, -2});
		frame2 << [](const DrawParams & p)
		{
			p.graphics->setColor({1.0f, 1.0f, 1.0f});
			p.graphics->rectangle(p.clipped);
		};

		Handle<Panel> panel(frame2);
		panel->setPlacement(ModelMask::FullSize, {1, 1, -1, -1});
		panel << [](const DrawParams & p)
		{
			p.graphics->setColor({0.0f, 0.0f, 0.0f});
			p.graphics->rectangle(p.clipped);
		};

		auto arial = Font::load("arial.ttf");

		graphics->bind(arial);
		graphics->setFontSize(16);

		Handle<String> project_name("Independence");
		Handle<Panel> project_name_panel(back);
		project_name_panel->setPlacement(10, 10, 0, 0);
		project_name_panel->setSize(graphics->getTextSize(*project_name));

		project_name_panel << [arial, project_name](const DrawParams & p)
		{
			auto & graphics = p.graphics;
			auto & region = p.region;
			graphics->bind(arial);
			graphics->setFontSize(16);

			p.graphics->setColor({1.0f, 1.0f, 1.0f});
			graphics->draw(region.left, region.top, *project_name);
		};

		Handle<String> text("Press Esc to quit");
		Handle<Panel> text_panel(back);
		text_panel->setPlacement(ModelMask::RightTop, {0, 10, -10, 0});
		text_panel->setSize(graphics->getTextSize(*text));

		text_panel << [arial, text](const DrawParams & p)
		{
			auto & graphics = p.graphics;
			auto & region = p.region;
			graphics->bind(arial);
			graphics->setFontSize(16);

			p.graphics->setColor({1.0f, 1.0f, 1.0f});
			graphics->draw(region.left, region.top, *text);
		};

		Handle<FpsCounter> counter(emptiness);

		Handle<Panel> fps_panel(back);
		fps_panel->setPlacement({0.5f, 1.0f, 0.5f, 1.0f}, {-40, -30, 40, -10});
		fps_panel << [counter, arial](const DrawParams & p)
		{
			auto graphics = p.graphics;
			graphics->bind(arial);
			graphics->setFontSize(16);

			auto text = String(counter->get()) + " fps";
			auto textSize = graphics->getTextSize(text);
			int left = p.region.left + (p.region.width() - textSize.x) / 2;
			int top = p.region.top + (p.region.height() - textSize.y) / 2;

			p.graphics->setColor({1.0f, 1.0f, 1.0f});
			graphics->draw(left, top, text);
		};
		
		Handle<Scene> scene(panel);
		scene->append<Snake>(color(1.0f, 0.0f, 0.0f));
		scene->append<Snake>(color(1.0f, 0.5f, 0.0f));
		scene->append<Snake>(color(1.0f, 1.0f, 0.0f));
		scene->append<Snake>(color(0.0f, 1.0f, 0.0f));
		scene->append<Snake>(color(0.0f, 1.0f, 1.0f));
		scene->append<Snake>(color(0.0f, 0.0f, 1.0f));
		scene->append<Snake>(color(0.5f, 0.0f, 1.0f));

		connect(*window, onWindowKeyDown);

		window->setBorderStyle(BorderStyle::Static);
		window->setCaption("Independence");
		window->centralize();
		window->show();

		ThreadLoop::add(processWindowMessage);
		ThreadLoop::add([scene, window, counter, fps_panel] () mutable
		{
			//std::this_thread::sleep_for(1ms);
			
			counter->next();
			window->invalidate(fps_panel);
			
			scene->invalidate();
			window->validate();

			return 0;
		});

		ThreadLoop::run();

		return 0;
	}
Exemplo n.º 6
0
wxString MacroManager::DoExpand(
    const wxString& expression, IManager* manager, const wxString& project, bool applyEnv, const wxString& confToBuild)
{
    wxString expandedString(expression);
    clCxxWorkspace* workspace = clCxxWorkspaceST::Get();

    if(!manager) {
        manager = clGetManager();
    }

    size_t retries = 0;
    wxString dummyname, dummfullname;
    while((retries < 5) && FindVariable(expandedString, dummyname, dummyname)) {
        ++retries;
        DollarEscaper de(expandedString);
        if(workspace) {
            expandedString.Replace(wxT("$(WorkspaceName)"), workspace->GetName());
            ProjectPtr proj = workspace->GetProject(project);
            if(proj) {
                wxString prjBuildWd;
                wxString prjRunWd;

                wxString project_name(proj->GetName());

                // make sure that the project name does not contain any spaces
                project_name.Replace(wxT(" "), wxT("_"));

                BuildConfigPtr bldConf = workspace->GetProjBuildConf(proj->GetName(), confToBuild);
                if(bldConf) {
                    bool isCustom = bldConf->IsCustomBuild();
                    expandedString.Replace(wxT("$(ProjectOutputFile)"), bldConf->GetOutputFileName());
                    // An alias
                    expandedString.Replace(wxT("$(OutputFile)"), bldConf->GetOutputFileName());

                    // When custom build project, use the working directory set in the
                    // custom build tab, otherwise use the project file's path
                    prjBuildWd = isCustom ? bldConf->GetCustomBuildWorkingDir() : proj->GetFileName().GetPath();
                    prjRunWd = bldConf->GetWorkingDirectory();
                }

                expandedString.Replace(wxT("$(ProjectWorkingDirectory)"), prjBuildWd);
                expandedString.Replace(wxT("$(ProjectRunWorkingDirectory)"), prjRunWd);
                expandedString.Replace(wxT("$(ProjectPath)"), proj->GetFileName().GetPath());
                expandedString.Replace(wxT("$(WorkspacePath)"), workspace->GetWorkspaceFileName().GetPath());
                expandedString.Replace(wxT("$(ProjectName)"), project_name);

                if(bldConf) {
                    expandedString.Replace(wxT("$(IntermediateDirectory)"), bldConf->GetIntermediateDirectory());
                    expandedString.Replace(wxT("$(ConfigurationName)"), bldConf->GetName());
                    expandedString.Replace(wxT("$(OutDir)"), bldConf->GetIntermediateDirectory());
                }

                if(expandedString.Find(wxT("$(ProjectFiles)")) != wxNOT_FOUND)
                    expandedString.Replace(wxT("$(ProjectFiles)"), proj->GetFiles());

                if(expandedString.Find(wxT("$(ProjectFilesAbs)")) != wxNOT_FOUND)
                    expandedString.Replace(wxT("$(ProjectFilesAbs)"), proj->GetFiles(true));
            }
        }

        if(manager) {
            IEditor* editor = manager->GetActiveEditor();
            if(editor) {
                wxFileName fn(editor->GetFileName());

                expandedString.Replace(wxT("$(CurrentFileName)"), fn.GetName());

                wxString fpath(fn.GetPath());
                fpath.Replace(wxT("\\"), wxT("/"));
                expandedString.Replace(wxT("$(CurrentFilePath)"), fpath);
                expandedString.Replace(wxT("$(CurrentFileExt)"), fn.GetExt());
                expandedString.Replace(wxT("$(CurrentFileFullName)"), fn.GetFullName());

                wxString ffullpath(fn.GetFullPath());
                ffullpath.Replace(wxT("\\"), wxT("/"));
                expandedString.Replace(wxT("$(CurrentFileFullPath)"), ffullpath);
                expandedString.Replace(wxT("$(CurrentSelection)"), editor->GetSelection());
                if(expandedString.Find(wxT("$(CurrentSelectionRange)")) != wxNOT_FOUND) {
                    int start = editor->GetSelectionStart(), end = editor->GetSelectionEnd();

                    wxString output = wxString::Format(wxT("%i:%i"), start, end);
                    expandedString.Replace(wxT("$(CurrentSelectionRange)"), output);
                }
            }
        }

        // exapand common macros
        wxDateTime now = wxDateTime::Now();
        expandedString.Replace(wxT("$(User)"), wxGetUserName());
        expandedString.Replace(wxT("$(Date)"), now.FormatDate());

        if(manager && applyEnv) {
            expandedString.Replace(wxT("$(CodeLitePath)"), manager->GetInstallDirectory());

            // Apply the environment and expand the variables
            EnvSetter es(NULL, NULL, project, confToBuild);
            expandedString = manager->GetEnv()->ExpandVariables(expandedString, false);
        }
    }
    return expandedString;
}