1 // Copyright(c) 2005, Rodrigo Braz Monteiro 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions are met: 6 // 7 // * Redistributions of source code must retain the above copyright notice, 8 // this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above copyright notice, 10 // this list of conditions and the following disclaimer in the documentation 11 // and/or other materials provided with the distribution. 12 // * Neither the name of the Aegisub Group nor the names of its contributors 13 // may be used to endorse or promote products derived from this software 14 // without specific prior written permission. 15 // 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 // CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 // CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) 25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 // POSSIBILITY OF SUCH DAMAGE. 27 // 28 // Aegisub Project http://www.aegisub.org/ 29 30 #include <memory> 31 #include <string> 32 #include <wx/dialog.h> 33 34 class AssStyle; 35 class AssStyleStorage; 36 class PersistLocation; 37 class SubtitlesPreview; 38 class wxArrayString; 39 class wxCheckBox; 40 class wxChildFocusEvent; 41 class wxComboBox; 42 class wxCommandEvent; 43 class wxRadioBox; 44 class wxSpinCtrl; 45 class wxTextCtrl; 46 class wxThreadEvent; 47 class wxWindow; 48 namespace agi { struct Context; } 49 50 class DialogStyleEditor final : public wxDialog { 51 agi::Context *c; 52 std::unique_ptr<PersistLocation> persist; 53 54 /// If true, the style was just created and so the user should not be 55 /// asked if they want to change any existing lines should they rename 56 /// the style 57 bool is_new = false; 58 59 bool updating = false; 60 61 /// The style currently being edited 62 AssStyle *style; 63 64 /// Copy of style passed to the subtitles preview to avoid making changes 65 /// before Apply is clicked 66 std::unique_ptr<AssStyle> work; 67 68 /// The style storage style is in, if applicable 69 AssStyleStorage *store; 70 71 wxTextCtrl *StyleName; 72 wxComboBox *FontName; 73 wxCheckBox *BoxBold; 74 wxCheckBox *BoxItalic; 75 wxCheckBox *BoxUnderline; 76 wxCheckBox *BoxStrikeout; 77 wxSpinCtrl *margin[3]; 78 wxRadioBox *Alignment; 79 wxCheckBox *OutlineType; 80 wxComboBox *Encoding; 81 wxTextCtrl *PreviewText; 82 SubtitlesPreview *SubsPreview; 83 84 void SetBitmapColor(int n,wxColour color); 85 int AlignToControl(int n); 86 int ControlToAlign(int n); 87 void UpdateWorkStyle(); 88 89 void OnChildFocus(wxChildFocusEvent &event); 90 void OnCommandPreviewUpdate(wxCommandEvent &event); 91 92 void OnPreviewTextChange(wxCommandEvent &event); 93 void OnPreviewColourChange(wxThreadEvent &event); 94 95 /// @brief Maybe apply changes and maybe close the dialog 96 /// @param apply Should changes be applied? 97 /// @param close Should the dialog be closed? 98 void Apply(bool apply,bool close); 99 /// @brief Sets color for one of the four color buttons 100 void OnSetColor(wxThreadEvent& evt); 101 102 public: 103 DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Context *c, AssStyleStorage *store, std::string const& new_name, wxArrayString const& font_list); 104 ~DialogStyleEditor(); 105 106 std::string GetStyleName() const; 107 }; 108