Use GetSizeFromText instead of GetSizeFromTextSize(GetTextExtent)

This commit is contained in:
wangqr 2019-11-07 16:06:53 -05:00
parent 557e81be1d
commit 1bda6052b6
4 changed files with 32 additions and 0 deletions

View file

@ -558,7 +558,11 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, agi::Color initial_color,
colorspace_choice = new wxChoice(this, -1, wxDefaultPosition, wxDefaultSize, 5, modes);
ass_input = new wxTextCtrl(this, -1);
#if wxCHECK_VERSION(3, 1, 3)
wxSize colorinput_size = ass_input->GetSizeFromText(wxS("&H10117B&"));
#else
wxSize colorinput_size = ass_input->GetSizeFromTextSize(GetTextExtent(wxS("&H10117B&")));
#endif
ass_input->SetInitialSize(colorinput_size);
wxSizer *rgb_box = new wxStaticBoxSizer(wxHORIZONTAL, this, _("RGB color"));

View file

@ -110,7 +110,11 @@ int ShowEbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s) {
wxRadioBox *tv_standard_box = new wxRadioBox(&d, -1, _("TV standard"), wxDefaultPosition, wxDefaultSize, 6, tv_standards, 0, wxRA_SPECIFY_ROWS);
wxTextCtrl *timecode_offset_entry = new wxTextCtrl(&d, -1, "00:00:00:00");
#if wxCHECK_VERSION(3, 1, 3)
timecode_offset_entry->SetInitialSize(timecode_offset_entry->GetSizeFromText(wxS("00:00:00:00")));
#else
timecode_offset_entry->SetInitialSize(timecode_offset_entry->GetSizeFromTextSize(timecode_offset_entry->GetTextExtent(wxS("00:00:00:00"))));
#endif
wxCheckBox *inclusive_end_times_check = new wxCheckBox(&d, -1, _("Out-times are inclusive"));
wxString text_encodings[] = {
@ -131,7 +135,11 @@ int ShowEbuExportConfigurationDialog(wxWindow *owner, EbuExportSettings &s) {
};
wxSpinCtrl *max_line_length_ctrl = new wxSpinCtrl(&d, -1, wxString());
#if wxCHECK_VERSION(3, 1, 3)
max_line_length_ctrl->SetInitialSize(max_line_length_ctrl->GetSizeFromText(wxS("00")));
#else
max_line_length_ctrl->SetInitialSize(max_line_length_ctrl->GetSizeFromTextSize(max_line_length_ctrl->GetTextExtent(wxS("00"))));
#endif
wxComboBox *wrap_mode_ctrl = new wxComboBox(&d, -1, wrap_modes[0], wxDefaultPosition, wxDefaultSize, 4, wrap_modes, wxCB_DROPDOWN | wxCB_READONLY);
wxCheckBox *translate_alignments_check = new wxCheckBox(&d, -1, _("Translate alignments"));

View file

@ -201,7 +201,11 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con
margin[i] = new wxSpinCtrl(this, -1, std::to_wstring(style->Margin[i]),
wxDefaultPosition, wxDefaultSize,
wxSP_ARROW_KEYS, 0, 9999, style->Margin[i]);
#if wxCHECK_VERSION(3, 1, 3)
margin[i]->SetInitialSize(margin[i]->GetSizeFromText(wxS("0000")));
#else
margin[i]->SetInitialSize(margin[i]->GetSizeFromTextSize(GetTextExtent(wxS("0000"))));
#endif
}
Alignment = new wxRadioBox(this, -1, _("Alignment"), wxDefaultPosition, wxDefaultSize, 9, alignValues, 3, wxRA_SPECIFY_COLS);

View file

@ -143,7 +143,11 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
top_sizer->Add(effect_box, 3, wxALIGN_CENTER, 5);
char_count = new wxTextCtrl(this, -1, "0", wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTER);
#if wxCHECK_VERSION(3, 1, 3)
char_count->SetInitialSize(char_count->GetSizeFromText(wxS("000")));
#else
char_count->SetInitialSize(char_count->GetSizeFromTextSize(GetTextExtent(wxS("000"))));
#endif
char_count->SetToolTip(_("Number of characters in the longest line of this subtitle."));
top_sizer->Add(char_count, 0, wxALIGN_CENTER, 5);
@ -151,7 +155,11 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
middle_left_sizer = new wxBoxSizer(wxHORIZONTAL);
layer = new wxSpinCtrl(this,-1,"",wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS | wxTE_PROCESS_ENTER,0,0x7FFFFFFF,0);
#if wxCHECK_VERSION(3, 1, 3)
layer->SetInitialSize(layer->GetSizeFromText(wxS("0")));
#else
layer->SetInitialSize(layer->GetSizeFromTextSize(GetTextExtent(wxS("0"))));
#endif
layer->SetToolTip(_("Layer number"));
middle_left_sizer->Add(layer, wxSizerFlags().Center());
middle_left_sizer->AddSpacer(5);
@ -255,7 +263,11 @@ SubsEditBox::~SubsEditBox() {
wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, int margin, wxString const& commit_msg) {
wxTextCtrl *ctrl = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxTE_CENTRE | wxTE_PROCESS_ENTER, IntValidator());
#if wxCHECK_VERSION(3, 1, 3)
ctrl->SetInitialSize(ctrl->GetSizeFromText(wxS("0000")));
#else
ctrl->SetInitialSize(ctrl->GetSizeFromTextSize(GetTextExtent(wxS("0000"))));
#endif
ctrl->SetMaxLength(4);
ctrl->SetToolTip(tooltip);
middle_left_sizer->Add(ctrl, wxSizerFlags().Center());
@ -271,7 +283,11 @@ wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, int margin, wxS
TimeEdit *SubsEditBox::MakeTimeCtrl(wxString const& tooltip, TimeField field) {
TimeEdit *ctrl = new TimeEdit(this, -1, c, "", wxDefaultSize, field == TIME_END);
#if wxCHECK_VERSION(3, 1, 3)
ctrl->SetInitialSize(ctrl->GetSizeFromText(wxS("0:00:00.000")));
#else
ctrl->SetInitialSize(ctrl->GetSizeFromTextSize(GetTextExtent(wxS("0:00:00.000"))));
#endif
ctrl->SetToolTip(tooltip);
Bind(wxEVT_TEXT, [=](wxCommandEvent&) { CommitTimes(field); }, ctrl->GetId());
ctrl->Bind(wxEVT_CHAR_HOOK, time_edit_char_hook);