wxImage ToolBar::GetImage(wxString name) { Dirstructure dirstructure; wxImage img = wxImage(dirstructure.ConfigToolbarDir() + name + wxT(".png")); // We want to scale the images according to the display's resolution. // But we want to do so in discrete steps as scaling bitmaps by odd // factors will add visible antialiassing to things that are clearly // meant to be sharp lines. int resolutionMultiplier = wxGetDisplayPPI().x/72; int imgWidth = 24 * resolutionMultiplier; int width,height; wxDisplaySize(&width,&height); if(width <= 800) imgWidth = 24; if(imgWidth < 24) imgWidth = 24; double scaleFactor = (double)imgWidth / img.GetWidth(); img.Rescale(imgWidth,img.GetHeight()*scaleFactor,wxIMAGE_QUALITY_HIGH ); return img; }
bool MyApp::OnInit() { m_frame = NULL; // atexit(Cleanup_Static); int lang = wxLANGUAGE_UNKNOWN; bool batchmode = false; wxCmdLineParser cmdLineParser(argc, argv); static const wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_SWITCH, "v", "version", "Output the version info" }, /* Usually wxCMD_LINE_OPTION_HELP is used with the following option, but that displays a message * using a own window and we want the message on the command line. If a user enters a command * line option, he expects probably a answer just on the command line... */ { wxCMD_LINE_SWITCH, "h", "help", "show this help message", wxCMD_LINE_VAL_NONE}, { wxCMD_LINE_OPTION, "o", "open", "open a file" }, { wxCMD_LINE_SWITCH, "b", "batch","run the file and exit afterwards. Halts on questions and stops on errors." }, #if defined __WXMSW__ { wxCMD_LINE_OPTION, "f", "ini", "open an input file" }, #endif { wxCMD_LINE_PARAM, NULL, NULL, "input file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE } }; cmdLineParser.SetDesc(cmdLineDesc); cmdLineParser.Parse(); wxString ini, file; #if defined __WXMSW__ if (cmdLineParser.Found(wxT("f"),&ini)) wxConfig::Set(new wxFileConfig(ini)); else wxConfig::Set(new wxConfig(wxT("wxMaxima"))); #else wxConfig::Set(new wxConfig(wxT("wxMaxima"))); #endif wxImage::AddHandler(new wxPNGHandler); wxImage::AddHandler(new wxXPMHandler); wxImage::AddHandler(new wxJPEGHandler); wxFileSystem::AddHandler(new wxZipFSHandler); Dirstructure dirstructure; wxConfigBase *config = wxConfig::Get(); config->Read(wxT("language"), &lang); if (lang == wxLANGUAGE_UNKNOWN) lang = wxLocale::GetSystemLanguage(); { wxLogNull disableErrors; m_locale.Init(lang); } #if defined (__WXMSW__) wxSetEnv(wxT("LANG"), m_locale.GetName()); if (!wxGetEnv(wxT("BUILD_DIR"), NULL)) wxSetWorkingDirectory(wxPathOnly(wxString(argv[0]))); /* Add private jsMath fonts, if they exist */ if (wxFileExists("fonts/jsMath-cmex10.ttf")) AddFontResource(wxT("fonts/jsMath-cmex10.ttf")); if (wxFileExists("fonts/jsMath-cmsy10.ttf")) AddFontResource(wxT("fonts/jsMath-cmsy10.ttf")); if (wxFileExists("fonts/jsMath-cmr10.ttf")) AddFontResource(wxT("fonts/jsMath-cmr10.ttf")); if (wxFileExists("fonts/jsMath-cmmi10.ttf")) AddFontResource(wxT("fonts/jsMath-cmmi10.ttf")); if (wxFileExists("fonts/jsMath-cmti10.ttf")) AddFontResource(wxT("fonts/jsMath-cmti10.ttf")); #endif m_locale.AddCatalogLookupPathPrefix(dirstructure.LocaleDir()); m_locale.AddCatalog(wxT("wxMaxima")); m_locale.AddCatalog(wxT("wxMaxima-wxstd")); #if defined __WXMAC__ wxString path; wxGetEnv(wxT("PATH"), &path); wxSetEnv(wxT("PATH"), path << wxT(":/usr/local/bin")); #endif #if defined (__WXMAC__) wxApp::SetExitOnFrameDelete(false); wxMenuBar *menuBar = new wxMenuBar; wxMenu *fileMenu = new wxMenu; fileMenu->Append(wxMaxima::mac_newId, _("&New\tCtrl-N")); fileMenu->Append(wxMaxima::mac_openId, _("&Open\tCtrl-O")); menuBar->Append(fileMenu, _("File")); wxMenuBar::MacSetCommonMenuBar(menuBar); Connect(wxMaxima::mac_newId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyApp::OnFileMenu)); Connect(wxMaxima::mac_openId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyApp::OnFileMenu)); Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyApp::OnFileMenu)); #endif if (cmdLineParser.Found(wxT("v"))) { std::cout<<"wxMaxima "; std::cout << VERSION; std::cout<<"\n"; wxExit(); } if (cmdLineParser.Found(wxT("h"))) { std::cout<<"A feature-rich graphical user interface for the computer algebra system maxima\n"; std::cout<<cmdLineParser.GetUsageString(); wxExit(); } if (cmdLineParser.Found(wxT("b"))) { batchmode = true; } if (cmdLineParser.Found(wxT("o"), &file)) { wxFileName FileName=file; FileName.MakeAbsolute(); wxString CanonicalFilename=FileName.GetFullPath(); NewWindow(wxString(CanonicalFilename),batchmode); return true; } else { if (cmdLineParser.GetParamCount()>0) { wxFileName FileName=cmdLineParser.GetParam(); FileName.MakeAbsolute(); wxString CanonicalFilename=FileName.GetFullPath(); NewWindow(CanonicalFilename,batchmode); } else NewWindow(); } return true; }
ToolBar::ToolBar(wxWindow* parent, int id) { m_toolBar = new wxToolBar(parent,id); m_needsInformation = false; m_AnimationStartStopState=Inactive; m_toolBar->SetToolBitmapSize(wxSize(24, 24)); #if defined __WXMSW__ // If there are packaging issues we want to have a detailed error message. Dirstructure dirstructure; wxFileName test(dirstructure.ConfigToolbarDir() + wxT("gtk-new.png")); wxASSERT_MSG(test.IsFileReadable(),_(wxT("Expected the icon files to be found at"))+dirstructure.ConfigToolbarDir()); m_toolBar->AddTool(tb_new, _("New"), GetImage(wxT("gtk-new")), _("New document")); #endif m_toolBar->AddTool(tb_open, _("Open"), GetImage(wxT("gtk-open")), _("Open document")); m_toolBar->AddTool(tb_save, _("Save"), GetImage(wxT("gtk-save")), _("Save document")); #ifndef __WXMAC__ m_toolBar->AddSeparator(); #endif m_toolBar->AddTool(tb_print, _("Print"), GetImage(wxT("gtk-print")), _("Print document")); m_toolBar->AddTool(tb_pref, _("Options"), GetImage(wxT("gtk-preferences")), _("Configure wxMaxima")); #ifndef __WXMAC__ m_toolBar->AddSeparator(); #endif m_toolBar->AddTool(tb_cut, _("Cut"), GetImage(wxT("gtk-cut")), _("Cut selection")); m_toolBar->AddTool(tb_copy, _("Copy"), GetImage(wxT("gtk-copy")), _("Copy selection")); m_toolBar->AddTool(tb_paste, _("Paste"), GetImage(wxT("gtk-paste")), _("Paste from clipboard")); m_toolBar->AddTool(tb_select_all, _("Select all"), GetImage(wxT("gtk-select-all")), _("Select all")); #ifndef __WXMAC__ m_toolBar->AddSeparator(); #endif m_toolBar->AddTool(tb_find, _("Find"), GetImage(wxT("gtk-find")), _("Find and replace")); #ifndef __WXMAC__ m_toolBar->AddSeparator(); #endif m_toolBar->AddTool(menu_restart_id, _("Restart maxima"), GetImage(wxT("view-refresh")), _("Completely stop maxima and restart it")); m_toolBar->AddTool(tb_interrupt, _("Interrupt"), GetImage(wxT("gtk-stop")), _("Interrupt current computation. To completely restart maxima press the button left to this one.")); m_followIcon = GetImage(wxT("weather-clear")); m_needsInformationIcon = GetImage(wxT("software-update-urgent")); m_toolBar->AddTool(tb_follow, _("Follow"),m_followIcon, _("Return to the cell that is currently being evaluated")); m_toolBar->EnableTool(tb_follow,false); m_toolBar->AddTool(tb_evaltillhere, _("Evaluate to point"), GetImage(wxT("go-bottom")), _("Evaluate the file from its beginning to the cell above the cursor")); #ifndef __WXMAC__ m_toolBar->AddSeparator(); #endif // Seems like on MSW changing the image of this button has strange side-effects // so we combine both images into one for this OS. #if defined __WXMSW__ m_PlayButton = GetImage(wxT("media-playback-startstop")); #else m_PlayButton = GetImage(wxT("media-playback-start")); #endif m_StopButton = GetImage(wxT("media-playback-stop")); // It felt like a good idea to combine the play and the stop button. // On windows changing a button seems to somehow stop the animation, though, so // this OS requires the buttons to be separate. m_toolBar->AddTool(tb_animation_startStop, _("Start or Stop animation"), m_PlayButton, _("Start or stop the currently selected animation that has been created with the with_slider class of commands")); m_toolBar->EnableTool(tb_animation_startStop,false); m_plotSlider = new wxSlider(m_toolBar, plot_slider_id, 0, 0, 10, wxDefaultPosition, wxSize(200, -1), wxSL_HORIZONTAL | !wxSL_AUTOTICKS); m_toolBar->AddControl(m_plotSlider); #ifndef __WXMAC__ m_toolBar->AddSeparator(); #endif m_toolBar->AddTool(tb_help, _("Help"), GetImage(wxT("gtk-help")), _("Show Maxima help")); m_toolBar->Realize(); }
wxImage ToolBar::GetImage(wxString img) { Dirstructure dirstructure; return wxImage(dirstructure.ConfigToolbarDir() + img + wxT(".png")); }