void ecConfigToolView::OnChangeFilename() { if (wxGetApp().GetTopWindow() && GetDocument()) { wxString docTitle(wxFileNameFromPath(GetDocument()->GetFilename())); wxStripExtension(docTitle); GetDocument()->SetTitle(docTitle); wxString name(GetDocument()->GetFilename()); wxStripExtension(name); ((ecConfigToolDoc*) GetDocument())->SetInstallTree(name + wxT("_install")); ((ecConfigToolDoc*) GetDocument())->SetBuildTree(name + wxT("_build")); wxString title; wxString modifiedMarker; if (GetDocument()->IsModified()) modifiedMarker = wxT("*"); title = docTitle + modifiedMarker + wxString(wxT(" - ")) + wxGetApp().GetSettings().GetAppName(); ((wxFrame*) wxGetApp().GetTopWindow())->SetTitle(title); } }
// Create the document bool ctConfigToolDoc::OnCreate(const wxString& path, long flags) { GetCommandProcessor()->SetEditMenu(wxGetApp().GetMainFrame()->GetEditMenu()); GetCommandProcessor()->Initialize(); GetCommandProcessor()->ClearCommands(); // wxGetApp().m_currentDoc = this; if (flags & wxDOC_NEW) { ctConfigItem* rootItem = new ctConfigItem(NULL, ctTypeGroup, _T("Configuration")); //rootItem->InitProperties(); rootItem->GetProperties().AddProperty( new ctProperty( wxT("The item description."), wxVariant(wxT(""), wxT("description")), wxT("multiline"))); rootItem->SetPropertyString(_T("description"), _T("<B>This is the top-level configuration item.</B>")); SetTopItem(rootItem); Modify(false); SetDocumentSaved(false); wxString rootName(wxT("untitled")); wxStripExtension(rootName); SetFilename(wxGetApp().GetSettings().GenerateFilename(rootName)); } // Creates the view, so do any view updating after this bool success = wxDocument::OnCreate(path, flags); if (success) { if (flags & wxDOC_NEW) { wxBusyCursor wait; ctConfigToolHint hint(NULL, ctInitialUpdate); UpdateAllViews (NULL, & hint); SetFilename(GetFilename(), true); } } return success; }
wxString wxCmdLineParser::GetUsageString() { wxString appname = wxTheApp->GetAppName(); if ( !appname ) { wxCHECK_MSG( m_data->m_arguments.size() != 0, wxEmptyString, _T("no program name") ); appname = wxFileNameFromPath(m_data->m_arguments[0]); wxStripExtension(appname); } // we construct the brief cmd line desc on the fly, but not the detailed // help message below because we want to align the options descriptions // and for this we must first know the longest one of them wxString usage; wxArrayString namesOptions, descOptions; if ( !m_data->m_logo.empty() ) { usage << m_data->m_logo << _T('\n'); } usage << wxString::Format(_("Usage: %s"), appname.c_str()); // the switch char is usually '-' but this can be changed with // SetSwitchChars() and then the first one of possible chars is used wxChar chSwitch = !m_data->m_switchChars ? _T('-') : m_data->m_switchChars[0u]; bool areLongOptionsEnabled = AreLongOptionsEnabled(); size_t n, count = m_data->m_options.GetCount(); for ( n = 0; n < count; n++ ) { wxCmdLineOption& opt = m_data->m_options[n]; usage << _T(' '); if ( !(opt.flags & wxCMD_LINE_OPTION_MANDATORY) ) { usage << _T('['); } if ( !opt.shortName.empty() ) { usage << chSwitch << opt.shortName; } else if ( areLongOptionsEnabled && !opt.longName.empty() ) { usage << _T("--") << opt.longName; } else { if (!opt.longName.empty()) { wxFAIL_MSG( wxT("option with only a long name while long ") wxT("options are disabled") ); } else { wxFAIL_MSG( _T("option without neither short nor long name") ); } } wxString option; if ( !opt.shortName.empty() ) { option << _T(" ") << chSwitch << opt.shortName; } if ( areLongOptionsEnabled && !opt.longName.empty() ) { option << (option.empty() ? _T(" ") : _T(", ")) << _T("--") << opt.longName; } if ( opt.kind != wxCMD_LINE_SWITCH ) { wxString val; val << _T('<') << GetTypeName(opt.type) << _T('>'); usage << _T(' ') << val; option << (!opt.longName ? _T(':') : _T('=')) << val; } if ( !(opt.flags & wxCMD_LINE_OPTION_MANDATORY) ) { usage << _T(']'); } namesOptions.push_back(option); descOptions.push_back(opt.description); } count = m_data->m_paramDesc.GetCount(); for ( n = 0; n < count; n++ ) { wxCmdLineParam& param = m_data->m_paramDesc[n]; usage << _T(' '); if ( param.flags & wxCMD_LINE_PARAM_OPTIONAL ) { usage << _T('['); } usage << param.description; if ( param.flags & wxCMD_LINE_PARAM_MULTIPLE ) { usage << _T("..."); } if ( param.flags & wxCMD_LINE_PARAM_OPTIONAL ) { usage << _T(']'); } } usage << _T('\n'); // now construct the detailed help message size_t len, lenMax = 0; count = namesOptions.size(); for ( n = 0; n < count; n++ ) { len = namesOptions[n].length(); if ( len > lenMax ) lenMax = len; } for ( n = 0; n < count; n++ ) { len = namesOptions[n].length(); usage << namesOptions[n] << wxString(_T(' '), lenMax - len) << _T('\t') << descOptions[n] << _T('\n'); } return usage; }