MCPcopy Create free account
hub / github.com/audacity/audacity / OnFileButton

Method OnFileButton

src/effects/nyquist/Nyquist.cpp:742–828  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

740}
741
742void NyquistEffect::OnFileButton(wxCommandEvent& evt)
743{
744 int i = evt.GetId() - ID_FILE;
745 NyqControl & ctrl = mControls[i];
746
747 // Get style flags:
748 // Ensure legal combinations so that wxWidgets does not throw an assert error.
749 unsigned int flags = 0;
750 if (!ctrl.highStr.empty())
751 {
752 wxStringTokenizer tokenizer(ctrl.highStr, ",");
753 while ( tokenizer.HasMoreTokens() )
754 {
755 wxString token = tokenizer.GetNextToken().Trim(true).Trim(false);
756 if (token.IsSameAs("open", false))
757 {
758 flags |= wxFD_OPEN;
759 flags &= ~wxFD_SAVE;
760 flags &= ~wxFD_OVERWRITE_PROMPT;
761 }
762 else if (token.IsSameAs("save", false))
763 {
764 flags |= wxFD_SAVE;
765 flags &= ~wxFD_OPEN;
766 flags &= ~wxFD_MULTIPLE;
767 flags &= ~wxFD_FILE_MUST_EXIST;
768 }
769 else if (token.IsSameAs("overwrite", false) && !(flags & wxFD_OPEN))
770 {
771 flags |= wxFD_OVERWRITE_PROMPT;
772 }
773 else if (token.IsSameAs("exists", false) && !(flags & wxFD_SAVE))
774 {
775 flags |= wxFD_FILE_MUST_EXIST;
776 }
777 else if (token.IsSameAs("multiple", false) && !(flags & wxFD_SAVE))
778 {
779 flags |= wxFD_MULTIPLE;
780 }
781 }
782 }
783
784 resolveFilePath(ctrl.valStr);
785
786 wxFileName fname = ctrl.valStr;
787 wxString defaultDir = fname.GetPath();
788 wxString defaultFile = fname.GetName();
789 auto message = XO("Select a file");
790
791 if (flags & wxFD_MULTIPLE)
792 message = XO("Select one or more files");
793 else if (flags & wxFD_SAVE)
794 message = XO("Save file as");
795
796 FileDialogWrapper openFileDialog(mUIParent->FindWindow(ID_FILE + i),
797 message,
798 defaultDir,
799 defaultFile,

Callers

nothing calls this directly

Calls 10

GetIdMethod · 0.80
emptyMethod · 0.45
TrimMethod · 0.45
IsSameAsMethod · 0.45
GetPathMethod · 0.45
GetNameMethod · 0.45
ShowModalMethod · 0.45
GetPathsMethod · 0.45
sizeMethod · 0.45
TransferToWindowMethod · 0.45

Tested by

no test coverage detected