std::string format_paragraph(const std::string &text_to_wrap, int indent_column, const std::string &indent_first_line, std::string indent_following_lines, int wrap_column, const char *break_chars) { return to_utf8(format_paragraph(to_wide(text_to_wrap), indent_column, to_wide(indent_first_line), to_wide(indent_following_lines), wrap_column, to_wide(break_chars))); }
additional_parts_dialog::additional_parts_dialog(wxWindow *parent, mmg_file_t const &file) : wxDialog(parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) , m_file{&file} , m_primary_file_name{m_file->file_name} , m_files{ m_file->is_playlist ? m_file->playlist_files : m_file->other_files } { SetTitle(m_file->is_playlist ? Z("View files in playlist") : Z("Additional source file parts")); // Create controls m_lv_files = new wxListView(this, ID_ADDPARTS_LV_FILES, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxSUNKEN_BORDER); m_b_add = new wxButton(this, ID_ADDPARTS_B_ADD, Z("&Add")); m_b_remove = new wxButton(this, ID_ADDPARTS_B_REMOVE, Z("&Remove")); m_b_up = new wxButton(this, ID_ADDPARTS_B_UP, Z("&Up")); m_b_down = new wxButton(this, ID_ADDPARTS_B_DOWN, Z("&Down")); m_b_sort = new wxButton(this, ID_ADDPARTS_B_SORT, Z("&Sort")); m_b_close = new wxButton(this, ID_ADDPARTS_B_CLOSE, Z("&Close")); auto *st_title = new wxStaticText(this, wxID_ANY, m_file->is_playlist ? Z("View files in playlist") : Z("Edit additional source file parts")); auto *st_primary_file_name = new wxStaticText(this, wxID_ANY, Z("Primary file name:")); auto *st_directory = new wxStaticText(this, wxID_ANY, Z("Directory:")); wxString text; if (m_file->is_playlist) { text = wxString( Z("The following list shows the files that make up this playlist.") ) + wxT(" ") + Z("This list is for informational purposes only and cannot be changed."); } else { text = wxString( Z("The following parts are read after the primary file as if they were all part of one big file.") ) + wxT(" ") + Z("Typical use cases include reading VOBs from a DVD (e.g. VTS_01_1.VOB, VTS_01_2.VOB, VTS_01_3.VOB)."); } auto *st_additional_parts = new wxStaticText(this, wxID_ANY, wxString{ format_paragraph(to_wide(text), 0, L"", L"", 80) }.Strip()); auto *sl_title = new wxStaticLine(this); auto *tc_primary_file_name = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); auto *tc_directory = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); // Setup controls wxListItem column_item; column_item.SetMask(wxLIST_MASK_TEXT); column_item.SetText(Z("File name")); m_lv_files->InsertColumn(0, column_item); column_item.SetText(Z("Directory")); m_lv_files->InsertColumn(1, column_item); auto dummy = m_lv_files->InsertItem(0, wxT("some long file name dummy.mkv")); m_lv_files->SetItem(dummy, 1, wxT("and the path is even longer but hey such is life")); m_lv_files->SetColumnWidth(0, wxLIST_AUTOSIZE); m_lv_files->SetColumnWidth(1, wxLIST_AUTOSIZE); m_lv_files->DeleteItem(0); repopulate(); tc_primary_file_name->SetValue(m_primary_file_name.GetFullName()); tc_directory->SetValue(m_primary_file_name.GetPath()); enable_buttons(); // Create layout auto *siz_all = new wxBoxSizer(wxVERTICAL); siz_all->Add(st_title, 0, wxALL, 5); siz_all->Add(sl_title, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5); auto *siz_primary_file_name = new wxFlexGridSizer(2, 2, 5, 5); siz_primary_file_name->AddGrowableCol(1); siz_primary_file_name->Add(st_primary_file_name); siz_primary_file_name->Add(tc_primary_file_name, 0, wxGROW); siz_primary_file_name->Add(st_directory); siz_primary_file_name->Add(tc_directory, 0, wxGROW); siz_all->Add(siz_primary_file_name, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5); siz_all->Add(st_additional_parts, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5); auto *siz_buttons = new wxBoxSizer(wxVERTICAL); siz_buttons->Add(m_b_add, 0, wxBOTTOM, 5); siz_buttons->Add(m_b_remove, 0, wxBOTTOM, 15); siz_buttons->Add(m_b_up, 0, wxBOTTOM, 5); siz_buttons->Add(m_b_down, 0, wxBOTTOM, 15); siz_buttons->Add(m_b_sort, 0, wxBOTTOM, 0); siz_buttons->AddStretchSpacer(); siz_buttons->Add(m_b_close); auto *siz_controls = new wxBoxSizer(wxHORIZONTAL); siz_controls->Add(m_lv_files, 1, wxGROW); siz_controls->Add(siz_buttons, 0, wxGROW | wxLEFT, 5); siz_all->Add(siz_controls, 1, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5); SetSizerAndFit(siz_all); siz_all->SetSizeHints(this); SetSize(wxSize(700, 400)); // Run ShowModal(); }
wxString format_tooltip(const wxString &s) { return format_paragraph(static_cast<const wchar_t *>(s.wc_str()), 0, L"", L"", 80); }