Clean up DialogStyleManager a bit, eliminating a decent amount of duplicated code and fixing issues with the logic for enabling and disabling the buttons.

Originally committed to SVN as r6416.
This commit is contained in:
Thomas Goyne 2012-02-01 00:48:50 +00:00
parent c6ac746215
commit 98b51e2c23
2 changed files with 305 additions and 512 deletions

File diff suppressed because it is too large Load diff

View file

@ -57,19 +57,25 @@ class PersistLocation;
/// ///
/// DOCME /// DOCME
class DialogStyleManager : public wxDialog { class DialogStyleManager : public wxDialog {
agi::Context *c; agi::Context *c; ///< Project context
agi::scoped_ptr<PersistLocation> persist; agi::scoped_ptr<PersistLocation> persist;
/// DOCME /// Styles in the current subtitle file
std::vector<AssStyle*> styleMap; std::vector<AssStyle*> styleMap;
/// DOCME /// Styles in the currently selected style storage
std::vector<AssStyle*> styleStorageMap; std::vector<AssStyle*> styleStorageMap;
/// Style storage manager
AssStyleStorage Store;
wxComboBox *CatalogList; wxComboBox *CatalogList;
wxListBox *StorageList; wxListBox *StorageList;
wxListBox *CurrentList; wxListBox *CurrentList;
wxButton *MoveToLocal; wxButton *MoveToLocal;
wxButton *MoveToStorage;
wxButton *StorageNew; wxButton *StorageNew;
wxButton *StorageEdit; wxButton *StorageEdit;
wxButton *StorageCopy; wxButton *StorageCopy;
@ -79,7 +85,7 @@ class DialogStyleManager : public wxDialog {
wxButton *StorageMoveTop; wxButton *StorageMoveTop;
wxButton *StorageMoveBottom; wxButton *StorageMoveBottom;
wxButton *StorageSort; wxButton *StorageSort;
wxButton *MoveToStorage;
wxButton *CurrentNew; wxButton *CurrentNew;
wxButton *CurrentEdit; wxButton *CurrentEdit;
wxButton *CurrentCopy; wxButton *CurrentCopy;
@ -90,54 +96,41 @@ class DialogStyleManager : public wxDialog {
wxButton *CurrentMoveBottom; wxButton *CurrentMoveBottom;
wxButton *CurrentSort; wxButton *CurrentSort;
/// Enable or disable the storage buttons
void StorageActions(bool state);
/// Load the list of available storages
void LoadCatalog();
/// Load the style list from the subtitles file
void LoadCurrentStyles(AssFile *subs);
/// Load the style list from the current storage
void LoadStorageStyles();
/// Enable/disable all of the buttons as appropriate
void UpdateButtons();
/// Move styles up or down
/// @param storage Storage or current file styles
/// @param type 0: up; 1: top; 2: down; 3: bottom; 4: sort
void MoveStyles(bool storage, int type);
/// DOCME void OnChangeCatalog();
AssStyleStorage Store; void OnCatalogNew();
void OnCatalogDelete();
void StorageActions (bool state); void OnStorageEdit();
void LoadCatalog (); void OnCurrentEdit();
void LoadCurrentStyles (AssFile *subs); void OnCopyToStorage();
void LoadStorageStyles (); void OnCopyToCurrent();
void UpdateMoveButtons(); void OnStorageCopy();
void MoveStyles(bool storage,int type); void OnCurrentCopy();
void OnStorageNew();
/// DOCME void OnCurrentNew();
wxSizer *MainSizer; void OnStorageDelete();
void OnCurrentDelete();
void OnChangeCatalog (wxCommandEvent &event); void OnCurrentImport();
void OnCatalogNew (wxCommandEvent &event); void OnKeyDown(wxKeyEvent &event);
void OnCatalogDelete (wxCommandEvent &event); void CopyToClipboard(wxListBox *list, std::vector<AssStyle*> v);
void OnStorageEdit (wxCommandEvent &event);
void OnCurrentEdit (wxCommandEvent &event);
void OnCurrentMoveUp (wxCommandEvent &event);
void OnCurrentMoveDown (wxCommandEvent &event);
void OnCurrentMoveTop (wxCommandEvent &event);
void OnCurrentMoveBottom (wxCommandEvent &event);
void OnCurrentSort (wxCommandEvent &event);
void OnStorageChange (wxCommandEvent &event);
void OnCurrentChange (wxCommandEvent &event);
void OnCopyToStorage (wxCommandEvent &event);
void OnCopyToCurrent (wxCommandEvent &event);
void OnStorageCopy (wxCommandEvent &event);
void OnCurrentCopy (wxCommandEvent &event);
void OnStorageNew (wxCommandEvent &event);
void OnCurrentNew (wxCommandEvent &event);
void OnStorageMoveUp (wxCommandEvent &event);
void OnStorageMoveDown (wxCommandEvent &event);
void OnStorageMoveTop (wxCommandEvent &event);
void OnStorageMoveBottom (wxCommandEvent &event);
void OnStorageSort (wxCommandEvent &event);
void OnStorageDelete (wxCommandEvent &event);
void OnCurrentDelete (wxCommandEvent &event);
void OnCurrentImport (wxCommandEvent &event);
void OnKeyDown (wxKeyEvent &event);
void CopyToClipboard (wxListBox *list, std::vector<AssStyle*> v);
void PasteToCurrent(); void PasteToCurrent();
void PasteToStorage(); void PasteToStorage();
public: public:
DialogStyleManager(agi::Context *context); DialogStyleManager(agi::Context *context);
~DialogStyleManager(); ~DialogStyleManager();
DECLARE_EVENT_TABLE()
}; };