|
49 | 49 | #include <wx/spinctrl.h> |
50 | 50 | #include <wx/textwrapper.h> |
51 | 51 | #include <wx/progdlg.h> |
52 | | -#include <wx/xrc/xmlres.h> |
53 | 52 | #include <wx/numformatter.h> |
54 | 53 |
|
55 | 54 | #ifdef __WXOSX__ |
@@ -853,32 +852,126 @@ class ExtractorsPageWindow : public PrefsPanel |
853 | 852 | class ExtractorEditDialog : public StandardDialog |
854 | 853 | { |
855 | 854 | public: |
856 | | - ExtractorEditDialog(wxWindow *parent) : StandardDialog(parent, _("Extractor setup")) |
| 855 | + ExtractorEditDialog(wxWindow *parent) |
| 856 | + : StandardDialog(parent, _("Extractor setup"), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) |
857 | 857 | { |
858 | 858 | auto sizer = ContentSizer(); |
| 859 | + sizer->SetMinSize(PX(520), -1); |
859 | 860 |
|
860 | | - auto panel = wxXmlResource::Get()->LoadPanel(this, "edit_extractor"); |
861 | | - sizer->Add(panel, wxSizerFlags(1).Expand()); |
| 861 | +#ifdef __WXOSX__ |
| 862 | + sizer->Add(new HeadingLabel(this, _("Extractor setup"))); |
| 863 | + sizer->AddSpacer(PX(16)); |
| 864 | +#endif |
862 | 865 |
|
863 | | - CreateButtons(wxOK | wxCANCEL); |
| 866 | + m_language = AddTextField(_("Language:")); |
| 867 | + m_extensions = AddTextField(_("List of extensions separated by semicolons (e.g. *.cpp;*.h):")); |
| 868 | + |
| 869 | + sizer->AddSpacer(PX(16)); |
| 870 | + //sizer->Add(new wxStaticLine(this, wxID_ANY), wxSizerFlags().Expand()); |
| 871 | + //sizer->AddSpacer(PX(8)); |
| 872 | + sizer->Add(new HeadingLabel(this, _("Invocation:"))); |
| 873 | + sizer->AddSpacer(PX(8)); |
| 874 | + |
| 875 | + m_command = AddTextField(_("Command to extract translations:"), |
| 876 | + "xgettext -L PHP --add-comments=TRANSLATORS: --force-po -o %o %C %K %F", |
| 877 | + LegacyXrcExplanation(_( |
| 878 | + "This is the command used to launch the extractor.\n" |
| 879 | + "%o expands to the name of output file, %K to list\n" |
| 880 | + "of keywords, %F to list of input files,\n" |
| 881 | + "%C to charset flag (see below)."))); |
| 882 | + m_keywords = AddTextField(_("An item in keywords list:"), |
| 883 | + "-k%k", |
| 884 | + LegacyXrcExplanation(_( |
| 885 | + "This will be attached to the command line once\n" |
| 886 | + "for each keyword. %k expands to the keyword."))); |
| 887 | + m_files = AddTextField(_("An item in input files list:"), |
| 888 | + "%f", |
| 889 | + LegacyXrcExplanation(_( |
| 890 | + "This will be attached to the command line once\n" |
| 891 | + "for each input file. %f expands to the filename."))); |
| 892 | + m_charset = AddTextField(_("Source code charset:"), |
| 893 | + "--from-code=%c", |
| 894 | + LegacyXrcExplanation(_( |
| 895 | + "This will be attached to the command line\n" |
| 896 | + "only if source code charset was given. %c expands to charset value."))); |
| 897 | + |
| 898 | + sizer->AddSpacer(PX(8)); |
| 899 | + |
| 900 | + CreateButtons() |
| 901 | + .Add(wxID_OK) |
| 902 | + .Add(wxID_CANCEL); |
864 | 903 |
|
865 | 904 | FitSizer(); |
866 | 905 | } |
| 906 | + |
| 907 | + wxTextCtrl *Language() const { return m_language; } |
| 908 | + wxTextCtrl *Extensions() const { return m_extensions; } |
| 909 | + wxTextCtrl *Command() const { return m_command; } |
| 910 | + wxTextCtrl *Keywords() const { return m_keywords; } |
| 911 | + wxTextCtrl *Files() const { return m_files; } |
| 912 | + wxTextCtrl *Charset() const { return m_charset; } |
| 913 | + |
| 914 | + private: |
| 915 | + wxTextCtrl *AddTextField(const wxString& label, const wxString& hint = wxEmptyString, const wxString& explanation = wxEmptyString) |
| 916 | + { |
| 917 | + auto sizer = ContentSizer(); |
| 918 | + |
| 919 | + auto labelCtrl = new wxStaticText(this, wxID_ANY, label); |
| 920 | + sizer->Add(labelCtrl, wxSizerFlags().Expand()); |
| 921 | + |
| 922 | + auto text = new wxTextCtrl(this, wxID_ANY); |
| 923 | + if (!hint.empty()) |
| 924 | + text->SetHint(hint); |
| 925 | + sizer->Add(text, wxSizerFlags().Expand().Border(wxTOP|wxBOTTOM, PX(4))); |
| 926 | + |
| 927 | + if (!explanation.empty()) |
| 928 | + { |
| 929 | + sizer->Add(new ExplanationLabel(this, explanation), wxSizerFlags().Expand().Border(wxBOTTOM, PX(8))); |
| 930 | + } |
| 931 | + else |
| 932 | + { |
| 933 | + sizer->AddSpacer(PX(8)); |
| 934 | + } |
| 935 | + |
| 936 | +#ifdef __WXOSX__ |
| 937 | + labelCtrl->SetWindowVariant(wxWINDOW_VARIANT_SMALL); |
| 938 | + text->SetWindowVariant(wxWINDOW_VARIANT_SMALL); |
| 939 | +#endif |
| 940 | + |
| 941 | + return text; |
| 942 | + } |
| 943 | + |
| 944 | + static wxString LegacyXrcExplanation(wxString text) |
| 945 | + { |
| 946 | + // This is done to preserve existing translations that were written with hardcoded newlines |
| 947 | + text.Replace("\n", " "); |
| 948 | + return text; |
| 949 | + } |
| 950 | + |
| 951 | + private: |
| 952 | + wxTextCtrl *m_language = nullptr; |
| 953 | + wxTextCtrl *m_extensions = nullptr; |
| 954 | + wxTextCtrl *m_command = nullptr; |
| 955 | + wxTextCtrl *m_keywords = nullptr; |
| 956 | + wxTextCtrl *m_files = nullptr; |
| 957 | + wxTextCtrl *m_charset = nullptr; |
867 | 958 | }; |
868 | 959 |
|
869 | 960 | /// Called to launch dialog for editing parser properties. |
870 | 961 | template<typename TFunctor> |
871 | 962 | void EditExtractor(int num, TFunctor completionHandler) |
872 | 963 | { |
873 | 964 | wxWindowPtr<ExtractorEditDialog> dlg(new ExtractorEditDialog(this)); |
874 | | - dlg->Centre(); |
875 | | - |
876 | | - auto extractor_language = XRCCTRL(*dlg, "extractor_language", wxTextCtrl); |
877 | | - auto extractor_extensions = XRCCTRL(*dlg, "extractor_extensions", wxTextCtrl); |
878 | | - auto extractor_command = XRCCTRL(*dlg, "extractor_command", wxTextCtrl); |
879 | | - auto extractor_keywords = XRCCTRL(*dlg, "extractor_keywords", wxTextCtrl); |
880 | | - auto extractor_files = XRCCTRL(*dlg, "extractor_files", wxTextCtrl); |
881 | | - auto extractor_charset = XRCCTRL(*dlg, "extractor_charset", wxTextCtrl); |
| 965 | +#ifndef __WXOSX__ |
| 966 | + dlg->CenterOnParent(); |
| 967 | +#endif |
| 968 | + |
| 969 | + auto extractor_language = dlg->Language(); |
| 970 | + auto extractor_extensions = dlg->Extensions(); |
| 971 | + auto extractor_command = dlg->Command(); |
| 972 | + auto extractor_keywords = dlg->Keywords(); |
| 973 | + auto extractor_files = dlg->Files(); |
| 974 | + auto extractor_charset = dlg->Charset(); |
882 | 975 |
|
883 | 976 | { |
884 | 977 | const LegacyExtractorSpec& nfo = m_extractors.Data[num]; |
|
0 commit comments