2006-01-16 22:02:54 +01:00
// Copyright (c) 2005, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
2009-07-29 07:43:02 +02:00
// Aegisub Project http://www.aegisub.org/
2006-01-16 22:02:54 +01:00
//
2009-07-29 07:43:02 +02:00
// $Id$
/// @file dialog_style_manager.cpp
/// @brief Style Manager dialogue box and partial logic
/// @ingroup style_editor
2006-01-16 22:02:54 +01:00
2009-01-04 07:31:48 +01:00
# include "config.h"
2009-09-10 15:06:40 +02:00
# ifndef AGI_PRE
2011-10-10 21:30:11 +02:00
# include <wx/bmpbuttn.h>
2007-09-12 01:22:26 +02:00
# include <wx/clipbrd.h>
2009-09-10 15:06:40 +02:00
# include <wx/filedlg.h>
# include <wx/filename.h>
# include <wx/intl.h>
2011-07-16 08:42:55 +02:00
# include <wx/msgdlg.h>
# include <wx/textdlg.h>
2007-09-12 01:22:26 +02:00
# include <wx/tokenzr.h>
2009-09-11 00:48:29 +02:00
# include <wx/choicdlg.h> // Keep this last so wxUSE_CHOICEDLG is set.
2009-09-10 15:06:40 +02:00
# endif
2006-10-20 00:53:06 +02:00
# include "ass_dialogue.h"
2009-09-10 15:06:40 +02:00
# include "ass_file.h"
# include "ass_style.h"
2010-05-21 03:13:36 +02:00
# include "compat.h"
2010-08-10 03:47:29 +02:00
# include "dialog_selected_choices.h"
2009-09-10 15:06:40 +02:00
# include "dialog_style_editor.h"
# include "dialog_style_manager.h"
2011-01-16 08:17:36 +01:00
# include "include/aegisub/context.h"
2009-09-10 15:06:40 +02:00
# include "help_button.h"
# include "libresrc/libresrc.h"
2010-05-21 03:13:36 +02:00
# include "main.h"
2011-07-27 07:36:24 +02:00
# include "persist_location.h"
2010-12-08 04:36:10 +01:00
# include "selection_controller.h"
2009-09-10 15:06:40 +02:00
# include "standard_paths.h"
2007-07-05 01:09:40 +02:00
# include "utils.h"
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
2010-10-11 22:05:52 +02:00
/// IDs
enum {
BUTTON_CATALOG_NEW = 1000 ,
BUTTON_CATALOG_DELETE ,
BUTTON_STORAGE_COPYTO ,
BUTTON_STORAGE_NEW ,
BUTTON_STORAGE_EDIT ,
BUTTON_STORAGE_COPY ,
BUTTON_STORAGE_DELETE ,
BUTTON_STORAGE_UP ,
BUTTON_STORAGE_DOWN ,
BUTTON_STORAGE_TOP ,
BUTTON_STORAGE_BOTTOM ,
BUTTON_STORAGE_SORT ,
BUTTON_CURRENT_COPYTO ,
BUTTON_CURRENT_NEW ,
BUTTON_CURRENT_EDIT ,
BUTTON_CURRENT_COPY ,
BUTTON_CURRENT_DELETE ,
BUTTON_CURRENT_IMPORT ,
BUTTON_CURRENT_UP ,
BUTTON_CURRENT_DOWN ,
BUTTON_CURRENT_TOP ,
BUTTON_CURRENT_BOTTOM ,
BUTTON_CURRENT_SORT ,
LIST_CATALOG ,
LIST_STORAGE ,
LIST_CURRENT
} ;
2011-01-16 08:17:36 +01:00
DialogStyleManager : : DialogStyleManager ( agi : : Context * context )
2011-09-28 21:43:11 +02:00
: wxDialog ( context - > parent , - 1 , _ ( " Styles Manager " ) , wxDefaultPosition , wxDefaultSize , wxDEFAULT_DIALOG_STYLE , " DialogStylesManager " )
2011-01-16 08:17:36 +01:00
, c ( context )
2006-01-16 22:02:54 +01:00
{
2009-07-25 06:49:59 +02:00
SetIcon ( BitmapToIcon ( GETIMAGE ( style_toolbutton_24 ) ) ) ;
2007-06-28 22:29:56 +02:00
2006-01-16 22:02:54 +01:00
// Catalog
wxSizer * CatalogBox = new wxStaticBoxSizer ( wxHORIZONTAL , this , _ ( " Catalog of available storages " ) ) ;
2011-09-28 21:43:11 +02:00
CatalogList = new wxComboBox ( this , LIST_CATALOG , " " , wxDefaultPosition , wxSize ( - 1 , - 1 ) , 0 , NULL , wxCB_READONLY | wxCB_READONLY , wxDefaultValidator , " Catalog List " ) ;
2010-05-17 21:48:17 +02:00
wxButton * CatalogNew = new wxButton ( this , BUTTON_CATALOG_NEW , _ ( " New " ) ) ;
wxButton * CatalogDelete = new wxButton ( this , BUTTON_CATALOG_DELETE , _ ( " Delete " ) ) ;
2006-01-16 22:02:54 +01:00
CatalogBox - > Add ( CatalogList , 1 , wxEXPAND | wxRIGHT | wxALIGN_RIGHT , 5 ) ;
CatalogBox - > Add ( CatalogNew , 0 , wxRIGHT , 5 ) ;
CatalogBox - > Add ( CatalogDelete , 0 , 0 , 0 ) ;
// Storage styles list
2007-07-02 08:18:28 +02:00
StorageList = new wxListBox ( this , LIST_STORAGE , wxDefaultPosition , wxSize ( 240 , 250 ) , 0 , NULL , wxLB_EXTENDED ) ;
2006-01-16 22:02:54 +01:00
wxSizer * StorageBox = new wxStaticBoxSizer ( wxVERTICAL , this , _ ( " Storage " ) ) ;
wxSizer * StorageButtons = new wxBoxSizer ( wxHORIZONTAL ) ;
2007-07-02 08:18:28 +02:00
wxSizer * StorageButtonsLow = new wxBoxSizer ( wxVERTICAL ) ;
wxSizer * StorageListSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2011-11-18 19:49:09 +01:00
MoveToLocal = new wxButton ( this , BUTTON_STORAGE_COPYTO , _ ( " Copy to ¤t script -> " ) ) ;
StorageNew = new wxButton ( this , BUTTON_STORAGE_NEW , _ ( " Ne&w " ) ) ;
StorageEdit = new wxButton ( this , BUTTON_STORAGE_EDIT , _ ( " Ed&it " ) ) ;
StorageCopy = new wxButton ( this , BUTTON_STORAGE_COPY , _ ( " C&opy " ) ) ;
StorageDelete = new wxButton ( this , BUTTON_STORAGE_DELETE , _ ( " De&lete " ) ) ;
2007-07-02 08:18:28 +02:00
StorageButtons - > Add ( StorageNew , 1 , wxEXPAND | wxRIGHT , 5 ) ;
StorageButtons - > Add ( StorageEdit , 1 , wxEXPAND | wxRIGHT , 5 ) ;
StorageButtons - > Add ( StorageCopy , 1 , wxEXPAND | wxRIGHT , 5 ) ;
2006-01-16 22:02:54 +01:00
StorageButtons - > Add ( StorageDelete , 1 , wxEXPAND | wxALL , 0 ) ;
2009-07-25 06:49:59 +02:00
StorageMoveUp = new wxBitmapButton ( this , BUTTON_STORAGE_UP , GETIMAGE ( arrow_up_24 ) ) ;
StorageMoveDown = new wxBitmapButton ( this , BUTTON_STORAGE_DOWN , GETIMAGE ( arrow_down_24 ) ) ;
StorageMoveTop = new wxBitmapButton ( this , BUTTON_STORAGE_TOP , GETIMAGE ( arrow_up_stop_24 ) ) ;
StorageMoveBottom = new wxBitmapButton ( this , BUTTON_STORAGE_BOTTOM , GETIMAGE ( arrow_down_stop_24 ) ) ;
StorageSort = new wxBitmapButton ( this , BUTTON_STORAGE_SORT , GETIMAGE ( arrow_sort_24 ) ) ;
2007-07-02 08:18:28 +02:00
StorageMoveUp - > SetToolTip ( _ ( " Move style up. " ) ) ;
StorageMoveDown - > SetToolTip ( _ ( " Move style down. " ) ) ;
StorageMoveTop - > SetToolTip ( _ ( " Move style to top. " ) ) ;
StorageMoveBottom - > SetToolTip ( _ ( " Move style to bottom. " ) ) ;
StorageSort - > SetToolTip ( _ ( " Sort styles alphabetically. " ) ) ;
StorageButtonsLow - > AddStretchSpacer ( 1 ) ;
StorageButtonsLow - > Add ( StorageMoveTop , 0 , wxEXPAND | wxALL , 0 ) ;
StorageButtonsLow - > Add ( StorageMoveUp , 0 , wxEXPAND | wxALL , 0 ) ;
StorageButtonsLow - > Add ( StorageMoveDown , 0 , wxEXPAND | wxALL , 0 ) ;
StorageButtonsLow - > Add ( StorageMoveBottom , 0 , wxEXPAND | wxALL , 0 ) ;
StorageButtonsLow - > Add ( StorageSort , 0 , wxEXPAND | wxALL , 0 ) ;
StorageButtonsLow - > AddStretchSpacer ( 1 ) ;
StorageListSizer - > Add ( StorageList , 1 , wxEXPAND | wxRIGHT , 0 ) ;
StorageListSizer - > Add ( StorageButtonsLow , 0 , wxEXPAND | wxALL , 0 ) ;
StorageBox - > Add ( StorageListSizer , 1 , wxEXPAND | wxBOTTOM , 5 ) ;
StorageBox - > Add ( MoveToLocal , 0 , wxEXPAND | wxBOTTOM , 5 ) ;
StorageBox - > Add ( StorageButtons , 0 , wxEXPAND | wxBOTTOM , 0 ) ;
2006-01-16 22:02:54 +01:00
MoveToLocal - > Disable ( ) ;
2006-10-20 00:53:06 +02:00
StorageEdit - > Disable ( ) ;
2006-01-16 22:02:54 +01:00
StorageCopy - > Disable ( ) ;
StorageDelete - > Disable ( ) ;
// Local styles list
2007-07-02 08:18:28 +02:00
CurrentList = new wxListBox ( this , LIST_CURRENT , wxDefaultPosition , wxSize ( 240 , 250 ) , 0 , NULL , wxLB_EXTENDED ) ;
2006-01-16 22:02:54 +01:00
wxSizer * CurrentBox = new wxStaticBoxSizer ( wxVERTICAL , this , _ ( " Current script " ) ) ;
wxSizer * CurrentButtons = new wxBoxSizer ( wxHORIZONTAL ) ;
2007-07-02 08:18:28 +02:00
wxSizer * CurrentButtonsLow = new wxBoxSizer ( wxVERTICAL ) ;
wxSizer * CurrentListSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
wxSizer * MoveImportSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2011-11-18 19:49:09 +01:00
MoveToStorage = new wxButton ( this , BUTTON_CURRENT_COPYTO , _ ( " <- Copy to &storage " ) ) ;
2007-08-16 01:17:42 +02:00
MoveImportSizer - > Add ( MoveToStorage , 1 , wxEXPAND | wxRIGHT , 5 ) ;
2011-11-18 19:49:09 +01:00
MoveImportSizer - > Add ( new wxButton ( this , BUTTON_CURRENT_IMPORT , _ ( " &Import from script... " ) ) , 1 , wxEXPAND , 0 ) ;
CurrentNew = new wxButton ( this , BUTTON_CURRENT_NEW , _ ( " &New " ) ) ;
CurrentEdit = new wxButton ( this , BUTTON_CURRENT_EDIT , _ ( " &Edit " ) ) ;
CurrentCopy = new wxButton ( this , BUTTON_CURRENT_COPY , _ ( " &Copy " ) ) ;
CurrentDelete = new wxButton ( this , BUTTON_CURRENT_DELETE , _ ( " &Delete " ) ) ;
2007-07-02 08:18:28 +02:00
CurrentButtons - > Add ( CurrentNew , 1 , wxEXPAND | wxRIGHT , 5 ) ;
CurrentButtons - > Add ( CurrentEdit , 1 , wxEXPAND | wxRIGHT , 5 ) ;
CurrentButtons - > Add ( CurrentCopy , 1 , wxEXPAND | wxRIGHT , 5 ) ;
2006-01-16 22:02:54 +01:00
CurrentButtons - > Add ( CurrentDelete , 1 , wxEXPAND | wxALL , 0 ) ;
2009-07-25 06:49:59 +02:00
CurrentMoveUp = new wxBitmapButton ( this , BUTTON_CURRENT_UP , GETIMAGE ( arrow_up_24 ) ) ;
CurrentMoveDown = new wxBitmapButton ( this , BUTTON_CURRENT_DOWN , GETIMAGE ( arrow_down_24 ) ) ;
CurrentMoveTop = new wxBitmapButton ( this , BUTTON_CURRENT_TOP , GETIMAGE ( arrow_up_stop_24 ) ) ;
CurrentMoveBottom = new wxBitmapButton ( this , BUTTON_CURRENT_BOTTOM , GETIMAGE ( arrow_down_stop_24 ) ) ;
CurrentSort = new wxBitmapButton ( this , BUTTON_CURRENT_SORT , GETIMAGE ( arrow_sort_24 ) ) ;
2007-07-02 08:18:28 +02:00
CurrentMoveUp - > SetToolTip ( _ ( " Move style up. " ) ) ;
CurrentMoveDown - > SetToolTip ( _ ( " Move style down. " ) ) ;
CurrentMoveTop - > SetToolTip ( _ ( " Move style to top. " ) ) ;
CurrentMoveBottom - > SetToolTip ( _ ( " Move style to bottom. " ) ) ;
CurrentSort - > SetToolTip ( _ ( " Sort styles alphabetically. " ) ) ;
CurrentButtonsLow - > AddStretchSpacer ( 1 ) ;
CurrentButtonsLow - > Add ( CurrentMoveTop , 0 , wxEXPAND | wxALL , 0 ) ;
CurrentButtonsLow - > Add ( CurrentMoveUp , 0 , wxEXPAND | wxALL , 0 ) ;
CurrentButtonsLow - > Add ( CurrentMoveDown , 0 , wxEXPAND | wxALL , 0 ) ;
CurrentButtonsLow - > Add ( CurrentMoveBottom , 0 , wxEXPAND | wxALL , 0 ) ;
CurrentButtonsLow - > Add ( CurrentSort , 0 , wxEXPAND | wxALL , 0 ) ;
CurrentButtonsLow - > AddStretchSpacer ( 1 ) ;
CurrentListSizer - > Add ( CurrentList , 1 , wxEXPAND | wxRIGHT , 0 ) ;
CurrentListSizer - > Add ( CurrentButtonsLow , 0 , wxEXPAND | wxALL , 0 ) ;
CurrentBox - > Add ( CurrentListSizer , 1 , wxEXPAND | wxBOTTOM , 5 ) ;
CurrentBox - > Add ( MoveImportSizer , 0 , wxEXPAND | wxBOTTOM , 5 ) ;
CurrentBox - > Add ( CurrentButtons , 0 , wxEXPAND | wxBOTTOM , 0 ) ;
2006-01-16 22:02:54 +01:00
MoveToStorage - > Disable ( ) ;
2006-10-20 00:53:06 +02:00
CurrentEdit - > Disable ( ) ;
2006-01-16 22:02:54 +01:00
CurrentCopy - > Disable ( ) ;
CurrentDelete - > Disable ( ) ;
2007-06-23 09:27:09 +02:00
// Buttons
wxStdDialogButtonSizer * buttonSizer = new wxStdDialogButtonSizer ( ) ;
buttonSizer - > SetCancelButton ( new wxButton ( this , wxID_CLOSE ) ) ;
2011-09-28 21:43:11 +02:00
buttonSizer - > AddButton ( new HelpButton ( this , " Styles Manager " ) ) ;
2007-06-23 09:27:09 +02:00
buttonSizer - > Realize ( ) ;
2006-01-16 22:02:54 +01:00
// General layout
wxSizer * StylesSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2006-12-26 05:48:53 +01:00
StylesSizer - > Add ( StorageBox , 0 , wxRIGHT | wxEXPAND , 5 ) ;
StylesSizer - > Add ( CurrentBox , 0 , wxLEFT | wxEXPAND , 0 ) ;
2006-01-16 22:02:54 +01:00
MainSizer = new wxBoxSizer ( wxVERTICAL ) ;
MainSizer - > Add ( CatalogBox , 0 , wxEXPAND | wxLEFT | wxRIGHT | wxTOP , 5 ) ;
2007-06-23 09:27:09 +02:00
MainSizer - > Add ( StylesSizer , 1 , wxEXPAND | wxALL , 5 ) ;
MainSizer - > Add ( buttonSizer , 0 , wxBOTTOM | wxEXPAND , 5 ) ;
2006-01-16 22:02:54 +01:00
// Set sizer
SetSizer ( MainSizer ) ;
MainSizer - > SetSizeHints ( this ) ;
// Position window
2011-07-27 07:36:24 +02:00
persist . reset ( new PersistLocation ( this , " Tool/Style Manager " ) ) ;
2006-01-16 22:02:54 +01:00
// Populate lists
LoadCatalog ( ) ;
2011-01-16 08:17:36 +01:00
LoadCurrentStyles ( c - > ass ) ;
2006-10-20 00:53:06 +02:00
2007-02-05 20:09:45 +01:00
//Set key handlers for lists
2011-01-16 08:17:36 +01:00
CatalogList - > Bind ( wxEVT_KEY_DOWN , & DialogStyleManager : : OnKeyDown , this ) ;
StorageList - > Bind ( wxEVT_KEY_DOWN , & DialogStyleManager : : OnKeyDown , this ) ;
CurrentList - > Bind ( wxEVT_KEY_DOWN , & DialogStyleManager : : OnKeyDown , this ) ;
2007-02-05 20:09:45 +01:00
2006-10-20 00:53:06 +02:00
// Select default item
wxString selected_style ;
2011-01-16 08:17:36 +01:00
if ( AssDialogue * dia = context - > selectionController - > GetActiveLine ( ) ) {
selected_style = dia - > Style ;
2006-10-20 00:53:06 +02:00
}
2006-12-01 00:37:34 +01:00
if ( StorageList - > GetCount ( ) & & StorageList - > SetStringSelection ( selected_style ) ) {
2006-10-20 00:53:06 +02:00
StorageEdit - > Enable ( ) ;
StorageCopy - > Enable ( ) ;
StorageDelete - > Enable ( ) ;
MoveToLocal - > Enable ( ) ;
}
2006-12-01 00:37:34 +01:00
if ( CurrentList - > GetCount ( ) & & CurrentList - > SetStringSelection ( selected_style ) ) {
2006-10-20 00:53:06 +02:00
CurrentEdit - > Enable ( ) ;
CurrentCopy - > Enable ( ) ;
CurrentDelete - > Enable ( ) ;
MoveToStorage - > Enable ( ) ;
}
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Destructor
2006-01-16 22:02:54 +01:00
DialogStyleManager : : ~ DialogStyleManager ( ) {
int sel = CatalogList - > GetSelection ( ) ;
if ( sel ! = wxNOT_FOUND ) {
2011-01-16 08:17:36 +01:00
c - > ass - > SetScriptInfo ( " Last Style Storage " , CatalogList - > GetString ( sel ) ) ;
2006-01-16 22:02:54 +01:00
}
2009-05-22 00:24:52 +02:00
Store . Clear ( ) ;
2006-01-16 22:02:54 +01:00
}
2010-04-24 23:48:06 +02:00
/// @brief Load the catalog of stored styles
2006-01-16 22:02:54 +01:00
void DialogStyleManager : : LoadCatalog ( ) {
CatalogList - > Clear ( ) ;
// Create catalog if it doesn't exist
2011-09-28 21:43:11 +02:00
wxString dirname = StandardPaths : : DecodePath ( " ?user/catalog/ " ) ;
2006-01-16 22:02:54 +01:00
if ( ! wxDirExists ( dirname ) ) {
if ( ! wxMkdir ( dirname ) ) {
2011-09-28 21:43:11 +02:00
throw " Failed creating directory for style catalogues " ;
2006-01-16 22:02:54 +01:00
}
else {
// Create default style
Store . Clear ( ) ;
AssStyle * defstyle = new AssStyle ;
Store . style . push_back ( defstyle ) ;
2011-09-28 21:43:11 +02:00
Store . Save ( " Default " ) ;
2006-01-16 22:02:54 +01:00
}
}
// Get dir
2011-09-28 21:43:11 +02:00
dirname = StandardPaths : : DecodePath ( " ?user/catalog/*.sty " ) ;
2006-01-16 22:02:54 +01:00
// Populate
wxString curfile = wxFindFirstFile ( dirname , wxFILE ) ;
wxString path , name , ext ;
while ( ! curfile . empty ( ) ) {
wxFileName : : SplitPath ( curfile , & path , & name , & ext ) ;
CatalogList - > Append ( name ) ;
curfile = wxFindNextFile ( ) ;
}
// Set to default if available
StorageActions ( false ) ;
2011-09-28 21:43:11 +02:00
wxString pickStyle = c - > ass - > GetScriptInfo ( " Last Style Storage " ) ;
if ( pickStyle . IsEmpty ( ) ) pickStyle = " Default " ;
2008-09-06 13:35:36 +02:00
int opt = CatalogList - > FindString ( pickStyle , false ) ;
2006-01-16 22:02:54 +01:00
if ( opt ! = wxNOT_FOUND ) {
CatalogList - > SetSelection ( opt ) ;
wxCommandEvent dummy ;
OnChangeCatalog ( dummy ) ;
}
}
2010-04-24 23:48:06 +02:00
/// @brief Load the list of styles from a subtitle file
2006-01-16 22:02:54 +01:00
void DialogStyleManager : : LoadCurrentStyles ( AssFile * subs ) {
CurrentList - > Clear ( ) ;
styleMap . clear ( ) ;
2011-12-22 22:14:51 +01:00
for ( std : : list < AssEntry * > : : iterator cur = subs - > Line . begin ( ) ; cur ! = subs - > Line . end ( ) ; cur + + ) {
if ( AssStyle * style = dynamic_cast < AssStyle * > ( * cur ) ) {
2010-04-24 23:48:06 +02:00
CurrentList - > Append ( style - > name ) ;
styleMap . push_back ( style ) ;
2006-01-16 22:02:54 +01:00
}
}
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
2010-04-24 23:48:06 +02:00
/// @brief Load the list of styles from the currently active storage
2006-01-16 22:02:54 +01:00
void DialogStyleManager : : LoadStorageStyles ( ) {
StorageList - > Clear ( ) ;
styleStorageMap . clear ( ) ;
2011-12-22 22:14:51 +01:00
for ( std : : list < AssStyle * > : : iterator cur = Store . style . begin ( ) ; cur ! = Store . style . end ( ) ; cur + + ) {
if ( AssStyle * style = * cur ) {
2010-04-24 23:48:06 +02:00
StorageList - > Append ( style - > name ) ;
styleStorageMap . push_back ( style ) ;
2006-01-16 22:02:54 +01:00
}
}
// Flag change
wxCommandEvent dummy ;
OnStorageChange ( dummy ) ;
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Enables or disables storage actions
2006-01-16 22:02:54 +01:00
void DialogStyleManager : : StorageActions ( bool state ) {
StorageList - > Enable ( state ) ;
MoveToLocal - > Enable ( state ) ;
StorageNew - > Enable ( state ) ;
StorageCopy - > Enable ( state ) ;
StorageDelete - > Enable ( state ) ;
wxCommandEvent dummy ;
OnStorageChange ( dummy ) ;
wxArrayInt selections ;
if ( CurrentList - > GetSelections ( selections ) ! = 0 ) MoveToStorage - > Enable ( state ) ;
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
///////////////
// Event table
BEGIN_EVENT_TABLE ( DialogStyleManager , wxDialog )
EVT_BUTTON ( wxID_CLOSE , DialogStyleManager : : OnClose )
EVT_BUTTON ( BUTTON_CATALOG_NEW , DialogStyleManager : : OnCatalogNew )
EVT_BUTTON ( BUTTON_CATALOG_DELETE , DialogStyleManager : : OnCatalogDelete )
EVT_COMBOBOX ( LIST_CATALOG , DialogStyleManager : : OnChangeCatalog )
EVT_LISTBOX ( LIST_CURRENT , DialogStyleManager : : OnCurrentChange )
EVT_LISTBOX ( LIST_STORAGE , DialogStyleManager : : OnStorageChange )
EVT_LISTBOX_DCLICK ( LIST_STORAGE , DialogStyleManager : : OnStorageEdit )
EVT_LISTBOX_DCLICK ( LIST_CURRENT , DialogStyleManager : : OnCurrentEdit )
EVT_BUTTON ( BUTTON_CURRENT_COPYTO , DialogStyleManager : : OnCopyToStorage )
EVT_BUTTON ( BUTTON_STORAGE_COPYTO , DialogStyleManager : : OnCopyToCurrent )
2006-10-20 00:53:06 +02:00
EVT_BUTTON ( BUTTON_CURRENT_EDIT , DialogStyleManager : : OnCurrentEdit )
EVT_BUTTON ( BUTTON_STORAGE_EDIT , DialogStyleManager : : OnStorageEdit )
2006-01-16 22:02:54 +01:00
EVT_BUTTON ( BUTTON_CURRENT_COPY , DialogStyleManager : : OnCurrentCopy )
EVT_BUTTON ( BUTTON_STORAGE_COPY , DialogStyleManager : : OnStorageCopy )
EVT_BUTTON ( BUTTON_CURRENT_NEW , DialogStyleManager : : OnCurrentNew )
EVT_BUTTON ( BUTTON_STORAGE_NEW , DialogStyleManager : : OnStorageNew )
EVT_BUTTON ( BUTTON_CURRENT_DELETE , DialogStyleManager : : OnCurrentDelete )
EVT_BUTTON ( BUTTON_STORAGE_DELETE , DialogStyleManager : : OnStorageDelete )
2006-12-26 05:48:53 +01:00
EVT_BUTTON ( BUTTON_CURRENT_IMPORT , DialogStyleManager : : OnCurrentImport )
2006-12-26 22:45:23 +01:00
EVT_BUTTON ( BUTTON_CURRENT_UP , DialogStyleManager : : OnCurrentMoveUp )
EVT_BUTTON ( BUTTON_CURRENT_TOP , DialogStyleManager : : OnCurrentMoveTop )
EVT_BUTTON ( BUTTON_CURRENT_DOWN , DialogStyleManager : : OnCurrentMoveDown )
EVT_BUTTON ( BUTTON_CURRENT_BOTTOM , DialogStyleManager : : OnCurrentMoveBottom )
2006-12-26 23:28:44 +01:00
EVT_BUTTON ( BUTTON_CURRENT_SORT , DialogStyleManager : : OnCurrentSort )
2006-12-26 22:45:23 +01:00
EVT_BUTTON ( BUTTON_STORAGE_UP , DialogStyleManager : : OnStorageMoveUp )
EVT_BUTTON ( BUTTON_STORAGE_TOP , DialogStyleManager : : OnStorageMoveTop )
EVT_BUTTON ( BUTTON_STORAGE_DOWN , DialogStyleManager : : OnStorageMoveDown )
EVT_BUTTON ( BUTTON_STORAGE_BOTTOM , DialogStyleManager : : OnStorageMoveBottom )
2006-12-26 23:28:44 +01:00
EVT_BUTTON ( BUTTON_STORAGE_SORT , DialogStyleManager : : OnStorageSort )
2006-01-16 22:02:54 +01:00
END_EVENT_TABLE ( )
//////////
// Events
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Close
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnClose ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
Close ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Change catalog entry
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnChangeCatalog ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
int sel = CatalogList - > GetSelection ( ) ;
if ( sel ! = wxNOT_FOUND ) {
StorageActions ( true ) ;
Store . Load ( CatalogList - > GetString ( sel ) ) ;
LoadStorageStyles ( ) ;
}
else {
StorageActions ( false ) ;
Store . Clear ( ) ;
LoadStorageStyles ( ) ;
}
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
2010-04-24 23:48:06 +02:00
/// @brief New catalog entry button
void DialogStyleManager : : OnCatalogNew ( wxCommandEvent & ) {
2011-09-28 21:43:11 +02:00
wxString name = wxGetTextFromUser ( _ ( " New storage name: " ) , _ ( " New catalog entry " ) , " " , this ) ;
2006-01-16 22:02:54 +01:00
if ( ! name . empty ( ) ) {
2006-11-23 20:08:46 +01:00
// Remove bad characters from the name
wxString badchars = wxFileName : : GetForbiddenChars ( ) ;
int badchars_removed = 0 ;
for ( size_t i = 0 ; i < name . Length ( ) ; + + i ) {
for ( size_t j = 0 ; j < badchars . Length ( ) ; + + j ) {
if ( name [ i ] = = badchars [ j ] ) {
2011-09-28 21:43:11 +02:00
name [ i ] = ' _ ' ;
2006-11-23 20:08:46 +01:00
+ + badchars_removed ;
}
}
}
2007-04-08 02:10:42 +02:00
2008-09-06 13:35:36 +02:00
// Make sure that there is no storage with the same name (case insensitive search since Windows filenames are case insensitive)
if ( CatalogList - > FindString ( name , false ) ! = wxNOT_FOUND ) {
2009-07-24 04:10:41 +02:00
wxMessageBox ( _ ( " A catalog with that name already exists. " ) , _ ( " Catalog name conflict " ) , wxICON_ERROR | wxOK ) ;
2007-04-08 02:10:42 +02:00
return ;
}
// Warn about bad characters
2006-11-23 20:08:46 +01:00
if ( badchars_removed > 0 ) {
2011-09-28 21:43:48 +02:00
wxMessageBox ( wxString : : Format ( _ ( " The specified catalog name contains one or more illegal characters. They have been replaced with underscores instead. \n The catalog has been renamed to \" %s \" . " ) , name ) , _ ( " Invalid characters " ) ) ;
2006-11-23 20:08:46 +01:00
}
2007-04-08 02:10:42 +02:00
// Add to list of storages
2006-01-16 22:02:54 +01:00
Store . Clear ( ) ;
StorageList - > Clear ( ) ;
CatalogList - > Append ( name ) ;
CatalogList - > SetStringSelection ( name ) ;
StorageActions ( true ) ;
2007-04-08 02:10:42 +02:00
// Save
2011-09-28 21:43:11 +02:00
wxString dirname = StandardPaths : : DecodePath ( " ?user/catalog/ " ) ;
2006-01-16 22:02:54 +01:00
if ( ! wxDirExists ( dirname ) ) {
if ( ! wxMkdir ( dirname ) ) {
2011-09-28 21:43:11 +02:00
throw " Failed creating directory for style catalogues " ;
2006-01-16 22:02:54 +01:00
}
}
Store . Save ( name ) ;
}
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Catalog delete
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnCatalogDelete ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
int sel = CatalogList - > GetSelection ( ) ;
if ( sel ! = wxNOT_FOUND ) {
wxString name = CatalogList - > GetString ( sel ) ;
2011-09-28 21:43:48 +02:00
wxString message = wxString : : Format ( _ ( " Are you sure you want to delete the storage \" %s \" from the catalog? " ) , name ) ;
2006-01-16 22:02:54 +01:00
int option = wxMessageBox ( message , _ ( " Confirm delete " ) , wxYES_NO | wxICON_EXCLAMATION , this ) ;
if ( option = = wxYES ) {
2011-09-28 21:43:11 +02:00
wxRemoveFile ( StandardPaths : : DecodePath ( " ?user/catalog/ " + name + " .sty " ) ) ;
2006-01-16 22:02:54 +01:00
CatalogList - > Delete ( sel ) ;
StorageList - > Clear ( ) ;
StorageActions ( false ) ;
}
}
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Edit style on storage
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnStorageEdit ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
wxArrayInt selections ;
int n = StorageList - > GetSelections ( selections ) ;
if ( n = = 1 ) {
2010-04-24 23:48:06 +02:00
AssStyle * selStyle = styleStorageMap [ selections [ 0 ] ] ;
2011-10-18 00:00:58 +02:00
DialogStyleEditor ( this , selStyle , c , & Store , false ) . ShowModal ( ) ;
StorageList - > SetString ( selections [ 0 ] , selStyle - > name ) ;
Store . Save ( CatalogList - > GetString ( CatalogList - > GetSelection ( ) ) ) ;
2006-01-16 22:02:54 +01:00
}
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Edit style on current script
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnCurrentEdit ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
wxArrayInt selections ;
int n = CurrentList - > GetSelections ( selections ) ;
if ( n = = 1 ) {
2010-04-24 23:48:06 +02:00
AssStyle * selStyle = styleMap [ selections [ 0 ] ] ;
2011-10-18 00:00:58 +02:00
DialogStyleEditor ( this , selStyle , c , 0 , false ) . ShowModal ( ) ;
CurrentList - > SetString ( selections [ 0 ] , selStyle - > name ) ;
2006-01-16 22:02:54 +01:00
}
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Selection on current script changed
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnCurrentChange ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
wxArrayInt selections ;
int n = CurrentList - > GetSelections ( selections ) ;
2006-10-20 00:53:06 +02:00
CurrentEdit - > Enable ( n = = 1 ) ;
CurrentCopy - > Enable ( n = = 1 ) ;
CurrentDelete - > Enable ( n > 0 ) ;
MoveToStorage - > Enable ( n > 0 ) ;
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Selection on storage changed
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnStorageChange ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
wxArrayInt selections ;
int n = StorageList - > GetSelections ( selections ) ;
2006-10-20 00:53:06 +02:00
StorageEdit - > Enable ( n = = 1 ) ;
StorageCopy - > Enable ( n = = 1 ) ;
StorageDelete - > Enable ( n > 0 ) ;
MoveToLocal - > Enable ( n > 0 ) ;
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Copy to Storage
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnCopyToStorage ( wxCommandEvent & ) {
using std : : list ;
2006-01-16 22:02:54 +01:00
// Check if there is actually a storage
2010-04-24 23:48:06 +02:00
if ( ! StorageNew - > IsEnabled ( ) ) return ;
2006-01-16 22:02:54 +01:00
2010-04-24 23:48:06 +02:00
list < wxString > copied ;
2006-01-16 22:02:54 +01:00
wxArrayInt selections ;
int n = CurrentList - > GetSelections ( selections ) ;
2009-07-18 04:52:46 +02:00
for ( int i = 0 ; i < n ; i + + ) {
wxString styleName = CurrentList - > GetString ( selections [ i ] ) ;
bool addStyle = true ;
2010-04-24 23:48:06 +02:00
for ( list < AssStyle * > : : iterator style = Store . style . begin ( ) ; style ! = Store . style . end ( ) ; + + style ) {
2009-07-18 04:52:46 +02:00
if ( ( * style ) - > name . CmpNoCase ( styleName ) = = 0 ) {
addStyle = false ;
2011-09-28 21:43:48 +02:00
if ( wxYES = = wxMessageBox ( wxString : : Format ( " There is already a style with the name \" %s \" on the current storage. Proceed and overwrite anyway? " , styleName ) , " Style name collision. " , wxYES_NO ) ) {
2009-07-18 04:52:46 +02:00
* * style = * styleMap . at ( selections [ i ] ) ;
2010-04-24 23:48:06 +02:00
copied . push_back ( styleName ) ;
2009-07-18 04:52:46 +02:00
}
break ;
2008-01-13 07:42:34 +01:00
}
2009-07-18 04:52:46 +02:00
}
if ( addStyle ) {
AssStyle * temp = new AssStyle ( * styleMap . at ( selections [ i ] ) ) ;
Store . style . push_back ( temp ) ;
2010-04-24 23:48:06 +02:00
copied . push_back ( styleName ) ;
2006-01-16 22:02:54 +01:00
}
}
Store . Save ( CatalogList - > GetString ( CatalogList - > GetSelection ( ) ) ) ;
LoadStorageStyles ( ) ;
2010-04-24 23:48:06 +02:00
for ( list < wxString > : : iterator name = copied . begin ( ) ; name ! = copied . end ( ) ; + + name ) {
StorageList - > SetStringSelection ( * name , true ) ;
}
wxCommandEvent dummy ;
OnStorageChange ( dummy ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Copy to Current
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnCopyToCurrent ( wxCommandEvent & ) {
using std : : list ;
list < wxString > copied ;
2006-01-16 22:02:54 +01:00
wxArrayInt selections ;
int n = StorageList - > GetSelections ( selections ) ;
2009-07-18 04:52:46 +02:00
for ( int i = 0 ; i < n ; i + + ) {
wxString styleName = StorageList - > GetString ( selections [ i ] ) ;
bool addStyle = true ;
for ( std : : vector < AssStyle * > : : iterator style = styleMap . begin ( ) ; style ! = styleMap . end ( ) ; + + style ) {
if ( ( * style ) - > name . CmpNoCase ( styleName ) = = 0 ) {
addStyle = false ;
2011-09-28 21:43:48 +02:00
if ( wxYES = = wxMessageBox ( wxString : : Format ( " There is already a style with the name \" %s \" on the current script. Proceed and overwrite anyway? " , styleName ) , " Style name collision. " , wxYES_NO ) ) {
2009-07-18 04:52:46 +02:00
* * style = * styleStorageMap . at ( selections [ i ] ) ;
2010-04-24 23:48:06 +02:00
copied . push_back ( styleName ) ;
2009-07-18 04:52:46 +02:00
}
break ;
}
2006-12-17 21:30:59 +01:00
}
2009-07-18 04:52:46 +02:00
if ( addStyle ) {
AssStyle * temp = new AssStyle ( * styleStorageMap . at ( selections [ i ] ) ) ;
2011-01-16 08:17:36 +01:00
c - > ass - > InsertStyle ( temp ) ;
2010-04-24 23:48:06 +02:00
copied . push_back ( styleName ) ;
2006-01-16 22:02:54 +01:00
}
}
2011-01-16 08:17:36 +01:00
LoadCurrentStyles ( c - > ass ) ;
2010-04-24 23:48:06 +02:00
for ( list < wxString > : : iterator name = copied . begin ( ) ; name ! = copied . end ( ) ; + + name ) {
CurrentList - > SetStringSelection ( * name , true ) ;
}
2011-09-15 07:16:32 +02:00
c - > ass - > Commit ( _ ( " style copy " ) , AssFile : : COMMIT_STYLES ) ;
2010-04-24 23:48:06 +02:00
wxCommandEvent dummy ;
OnCurrentChange ( dummy ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Storage make copy
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnStorageCopy ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
wxArrayInt selections ;
2007-01-27 00:42:19 +01:00
StorageList - > GetSelections ( selections ) ;
2010-02-14 23:44:29 +01:00
if ( selections . size ( ) = = 0 ) return ;
2006-01-16 22:02:54 +01:00
2011-10-18 00:00:58 +02:00
DialogStyleEditor ( this , styleStorageMap [ selections [ 0 ] ] , c , & Store , true ) . ShowModal ( ) ;
Store . Save ( CatalogList - > GetString ( CatalogList - > GetSelection ( ) ) ) ;
LoadStorageStyles ( ) ;
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Current make copy
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnCurrentCopy ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
wxArrayInt selections ;
2007-01-27 00:42:19 +01:00
CurrentList - > GetSelections ( selections ) ;
2010-02-14 23:44:29 +01:00
if ( selections . size ( ) = = 0 ) return ;
2006-01-16 22:02:54 +01:00
2011-10-18 00:00:58 +02:00
DialogStyleEditor ( this , styleMap [ selections [ 0 ] ] , c , 0 , true ) . ShowModal ( ) ;
LoadCurrentStyles ( c - > ass ) ;
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Copy to clipboard
/// @param list
/// @param v
2007-02-06 04:25:14 +01:00
void DialogStyleManager : : CopyToClipboard ( wxListBox * list , std : : vector < AssStyle * > v ) {
2012-01-31 01:44:43 +01:00
wxString data ;
2007-02-06 04:25:14 +01:00
AssStyle * s ;
wxArrayInt selections ;
list - > GetSelections ( selections ) ;
for ( int unsigned i = 0 ; i < selections . size ( ) ; i + + ) {
2011-09-28 21:43:11 +02:00
if ( i ! = 0 ) data + = " \r \n " ;
2007-02-06 04:25:14 +01:00
s = v . at ( selections [ i ] ) ;
s - > UpdateData ( ) ;
data + = s - > GetEntryData ( ) ;
}
if ( wxTheClipboard - > Open ( ) ) {
wxTheClipboard - > SetData ( new wxTextDataObject ( data ) ) ;
wxTheClipboard - > Close ( ) ;
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Paste from clipboard
2007-02-06 04:25:14 +01:00
void DialogStyleManager : : PasteToCurrent ( ) {
2012-01-31 01:44:43 +01:00
wxString data ;
2007-02-06 04:25:14 +01:00
if ( wxTheClipboard - > Open ( ) ) {
if ( wxTheClipboard - > IsSupported ( wxDF_TEXT ) ) {
wxTextDataObject rawdata ;
wxTheClipboard - > GetData ( rawdata ) ;
data = rawdata . GetText ( ) ;
}
wxTheClipboard - > Close ( ) ;
}
2011-09-28 21:43:11 +02:00
wxStringTokenizer st ( data , ' \n ' ) ;
2007-02-06 04:25:14 +01:00
while ( st . HasMoreTokens ( ) ) {
2007-09-02 21:31:17 +02:00
try {
2011-12-22 22:14:51 +01:00
AssStyle * s = new AssStyle ( st . GetNextToken ( ) . Trim ( true ) ) ;
while ( c - > ass - > GetStyle ( s - > name ) ! = NULL )
s - > name = " Copy of " + s - > name ;
2007-09-02 21:31:17 +02:00
2011-12-22 22:14:51 +01:00
c - > ass - > InsertStyle ( s ) ;
LoadCurrentStyles ( c - > ass ) ;
2007-09-02 21:31:17 +02:00
2011-12-22 22:14:51 +01:00
c - > ass - > Commit ( _ ( " style paste " ) , AssFile : : COMMIT_STYLES ) ;
2007-09-02 21:31:17 +02:00
}
catch ( . . . ) {
wxMessageBox ( _ ( " Could not parse style " ) , _ ( " Could not parse style " ) , wxOK | wxICON_EXCLAMATION , this ) ;
2007-02-06 04:25:14 +01:00
}
2007-09-02 21:31:17 +02:00
2007-02-06 04:25:14 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief DOCME
2007-02-06 04:25:14 +01:00
void DialogStyleManager : : PasteToStorage ( ) {
2012-01-31 01:44:43 +01:00
wxString data ;
2007-02-06 04:25:14 +01:00
if ( wxTheClipboard - > Open ( ) ) {
if ( wxTheClipboard - > IsSupported ( wxDF_TEXT ) ) {
wxTextDataObject rawdata ;
wxTheClipboard - > GetData ( rawdata ) ;
data = rawdata . GetText ( ) ;
}
wxTheClipboard - > Close ( ) ;
}
2011-09-28 21:43:11 +02:00
wxStringTokenizer st ( data , ' \n ' ) ;
2007-02-06 04:25:14 +01:00
while ( st . HasMoreTokens ( ) ) {
2007-09-02 21:31:17 +02:00
try {
2011-12-22 22:14:51 +01:00
AssStyle * s = new AssStyle ( st . GetNextToken ( ) . Trim ( true ) ) ;
while ( Store . GetStyle ( s - > name ) ! = NULL )
s - > name = " Copy of " + s - > name ;
2007-09-02 21:31:17 +02:00
2011-12-22 22:14:51 +01:00
Store . style . push_back ( s ) ;
Store . Save ( CatalogList - > GetString ( CatalogList - > GetSelection ( ) ) ) ;
2007-09-02 21:31:17 +02:00
2011-12-22 22:14:51 +01:00
LoadStorageStyles ( ) ;
StorageList - > SetStringSelection ( s - > name ) ;
2007-02-06 04:25:14 +01:00
}
2007-09-02 21:31:17 +02:00
catch ( . . . ) {
wxMessageBox ( _ ( " Could not parse style " ) , _ ( " Could not parse style " ) , wxOK | wxICON_EXCLAMATION , this ) ;
}
2007-02-06 04:25:14 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Storage new
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnStorageNew ( wxCommandEvent & ) {
2011-10-18 00:00:58 +02:00
DialogStyleEditor ( this , 0 , c , & Store , false ) . ShowModal ( ) ;
Store . Save ( CatalogList - > GetString ( CatalogList - > GetSelection ( ) ) ) ;
LoadStorageStyles ( ) ;
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Current new
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnCurrentNew ( wxCommandEvent & ) {
2011-10-18 00:00:58 +02:00
DialogStyleEditor ( this , 0 , c , 0 , false ) . ShowModal ( ) ;
LoadCurrentStyles ( c - > ass ) ;
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Storage delete
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnStorageDelete ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
wxArrayInt selections ;
int n = StorageList - > GetSelections ( selections ) ;
2011-11-25 20:26:48 +01:00
wxString message = n = = 1 ?
_ ( " Are you sure you want to delete this style? " ) :
wxString : : Format ( _ ( " Are you sure you want to delete these %d styles? " ) , n ) ;
2007-02-05 20:09:45 +01:00
int option = wxMessageBox ( message , _ ( " Confirm delete from storage " ) , wxYES_NO | wxICON_EXCLAMATION , this ) ;
2006-01-16 22:02:54 +01:00
if ( option = = wxYES ) {
for ( int i = 0 ; i < n ; i + + ) {
2011-11-25 20:26:48 +01:00
AssStyle * temp = styleStorageMap . at ( selections [ i ] ) ;
2006-01-16 22:02:54 +01:00
Store . style . remove ( temp ) ;
delete temp ;
}
Store . Save ( CatalogList - > GetString ( CatalogList - > GetSelection ( ) ) ) ;
LoadStorageStyles ( ) ;
// Set buttons
MoveToLocal - > Enable ( false ) ;
2010-04-24 23:48:06 +02:00
StorageEdit - > Enable ( false ) ;
2006-01-16 22:02:54 +01:00
StorageCopy - > Enable ( false ) ;
StorageDelete - > Enable ( false ) ;
}
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Current delete
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnCurrentDelete ( wxCommandEvent & ) {
2006-01-16 22:02:54 +01:00
wxArrayInt selections ;
int n = CurrentList - > GetSelections ( selections ) ;
2011-11-25 20:26:48 +01:00
wxString message = n = = 1 ?
_ ( " Are you sure you want to delete this style? " ) :
wxString : : Format ( _ ( " Are you sure you want to delete these %d styles? " ) , n ) ;
2007-02-05 20:09:45 +01:00
int option = wxMessageBox ( message , _ ( " Confirm delete from current " ) , wxYES_NO | wxICON_EXCLAMATION , this ) ;
2006-01-16 22:02:54 +01:00
if ( option = = wxYES ) {
for ( int i = 0 ; i < n ; i + + ) {
2011-11-25 20:26:48 +01:00
AssStyle * temp = styleMap . at ( selections [ i ] ) ;
2011-01-16 08:17:36 +01:00
c - > ass - > Line . remove ( temp ) ;
2006-01-16 22:02:54 +01:00
delete temp ;
}
2011-01-16 08:17:36 +01:00
LoadCurrentStyles ( c - > ass ) ;
2006-01-16 22:02:54 +01:00
// Set buttons
MoveToStorage - > Enable ( false ) ;
2010-04-24 23:48:06 +02:00
CurrentEdit - > Enable ( false ) ;
2006-01-16 22:02:54 +01:00
CurrentCopy - > Enable ( false ) ;
CurrentDelete - > Enable ( false ) ;
2011-09-15 07:16:32 +02:00
c - > ass - > Commit ( _ ( " style delete " ) , AssFile : : COMMIT_STYLES ) ;
2006-01-16 22:02:54 +01:00
}
2006-12-26 22:45:23 +01:00
UpdateMoveButtons ( ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Import styles from another script
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnCurrentImport ( wxCommandEvent & ) {
2006-12-26 05:48:53 +01:00
// Get file name
2010-05-21 03:13:36 +02:00
wxString path = lagi_wxString ( OPT_GET ( " Path/Last/Subtitles " ) - > GetString ( ) ) ;
2011-09-28 21:43:11 +02:00
wxString filename = wxFileSelector ( _ ( " Open subtitles file " ) , path , " " , " " , AssFile : : GetWildcardList ( 0 ) , wxFD_OPEN | wxFD_FILE_MUST_EXIST ) ;
2006-12-26 05:48:53 +01:00
if ( ! filename . IsEmpty ( ) ) {
// Save path
wxFileName filepath ( filename ) ;
2010-05-21 03:13:36 +02:00
OPT_SET ( " Path/Last/Subtitles " ) - > SetString ( STD_STR ( filepath . GetPath ( ) ) ) ;
2006-12-26 05:48:53 +01:00
try {
// Load file
AssFile temp ;
2011-09-28 21:43:11 +02:00
temp . Load ( filename , " " , false ) ;
2006-12-26 05:48:53 +01:00
// Get styles
wxArrayString styles = temp . GetStyles ( ) ;
2011-12-22 22:25:00 +01:00
if ( styles . empty ( ) ) {
2008-01-17 21:30:44 +01:00
wxMessageBox ( _ ( " The selected file has no available styles. " ) , _ ( " Error Importing Styles " ) , wxOK ) ;
2006-12-26 05:48:53 +01:00
return ;
}
// Get selection
wxArrayInt selections ;
2010-08-10 03:47:29 +02:00
int res = GetSelectedChoices ( this , selections , _ ( " Choose styles to import: " ) , _ ( " Import Styles " ) , styles ) ;
2006-12-26 05:48:53 +01:00
if ( res = = - 1 | | selections . Count ( ) = = 0 ) return ;
bool modified = false ;
// Loop through selection
for ( unsigned int i = 0 ; i < selections . Count ( ) ; i + + ) {
// Check if there is already a style with that name
2008-09-06 13:35:36 +02:00
int test = CurrentList - > FindString ( styles [ selections [ i ] ] , false ) ;
2006-12-26 05:48:53 +01:00
if ( test ! = wxNOT_FOUND ) {
2011-09-28 21:43:48 +02:00
int answer = wxMessageBox ( wxString : : Format ( " There is already a style with the name \" %s \" on the current script. Overwrite? " , styles [ selections [ i ] ] ) , " Style name collision. " , wxYES_NO ) ;
2007-07-27 07:58:55 +02:00
if ( answer = = wxYES ) {
// Overwrite
modified = true ;
2008-09-06 13:35:36 +02:00
// The GetString->FindString mess is a silly workaround for the fact that to vsfilter
// (and the duplicate check a few lines above), style names aren't case sensitive, but to the
// rest of Aegisub they are.
2011-01-16 08:17:36 +01:00
* ( c - > ass - > GetStyle ( CurrentList - > GetString ( CurrentList - > FindString ( styles [ selections [ i ] ] , false ) ) ) ) = * temp . GetStyle ( styles [ selections [ i ] ] ) ;
2007-07-27 07:58:55 +02:00
}
continue ;
2006-12-26 05:48:53 +01:00
}
// Copy
modified = true ;
AssStyle * tempStyle = new AssStyle ;
* tempStyle = * temp . GetStyle ( styles [ selections [ i ] ] ) ;
2011-01-16 08:17:36 +01:00
c - > ass - > InsertStyle ( tempStyle ) ;
2006-12-26 05:48:53 +01:00
}
// Update
if ( modified ) {
2011-01-16 08:17:36 +01:00
LoadCurrentStyles ( c - > ass ) ;
2011-09-15 07:16:32 +02:00
c - > ass - > Commit ( _ ( " style import " ) , AssFile : : COMMIT_STYLES ) ;
2006-12-26 05:48:53 +01:00
}
}
catch ( . . . ) {
}
}
}
2010-04-24 23:48:06 +02:00
/// @brief Enable or disable the move buttons
2006-12-26 22:45:23 +01:00
void DialogStyleManager : : UpdateMoveButtons ( ) {
// Get storage selection
wxArrayInt sels ;
int n = StorageList - > GetSelections ( sels ) ;
int firstStor = - 1 ;
int lastStor = - 1 ;
if ( n ) {
firstStor = sels [ 0 ] ;
lastStor = sels [ n - 1 ] ;
}
int itemsStor = StorageList - > GetCount ( ) ;
2006-12-26 23:02:17 +01:00
// Check if selection is continuous
bool contStor = true ;
2010-04-24 23:48:06 +02:00
for ( int i = 1 ; i < n ; + + i ) {
if ( sels [ i ] ! = sels [ i - 1 ] + 1 ) {
contStor = false ;
break ;
2006-12-26 23:02:17 +01:00
}
}
2006-12-26 22:45:23 +01:00
// Get current selection
n = CurrentList - > GetSelections ( sels ) ;
int firstCurr = - 1 ;
int lastCurr = - 1 ;
if ( n ) {
firstCurr = sels [ 0 ] ;
lastCurr = sels [ n - 1 ] ;
}
int itemsCurr = CurrentList - > GetCount ( ) ;
2006-12-26 23:02:17 +01:00
// Check if selection is continuous
bool contCurr = true ;
2010-04-24 23:48:06 +02:00
for ( int i = 1 ; i < n ; + + i ) {
if ( sels [ i ] ! = sels [ i - 1 ] + 1 ) {
contCurr = false ;
break ;
2006-12-26 23:02:17 +01:00
}
}
2006-12-26 22:45:23 +01:00
// Set values
2006-12-26 23:02:17 +01:00
StorageMoveUp - > Enable ( contStor & & firstStor > 0 ) ;
StorageMoveTop - > Enable ( contStor & & firstStor > 0 ) ;
StorageMoveDown - > Enable ( contStor & & lastStor ! = - 1 & & lastStor < itemsStor - 1 ) ;
StorageMoveBottom - > Enable ( contStor & & lastStor ! = - 1 & & lastStor < itemsStor - 1 ) ;
2006-12-26 23:28:44 +01:00
StorageSort - > Enable ( itemsStor > 1 ) ;
2006-12-26 23:02:17 +01:00
CurrentMoveUp - > Enable ( contCurr & & firstCurr > 0 ) ;
CurrentMoveTop - > Enable ( contCurr & & firstCurr > 0 ) ;
CurrentMoveDown - > Enable ( contCurr & & lastCurr ! = - 1 & & lastCurr < itemsCurr - 1 ) ;
CurrentMoveBottom - > Enable ( contCurr & & lastCurr ! = - 1 & & lastCurr < itemsCurr - 1 ) ;
2006-12-26 23:28:44 +01:00
CurrentSort - > Enable ( itemsCurr > 1 ) ;
2006-12-26 22:45:23 +01:00
}
2010-04-24 23:48:06 +02:00
void DialogStyleManager : : OnStorageMoveUp ( wxCommandEvent & ) { MoveStyles ( true , 0 ) ; }
void DialogStyleManager : : OnStorageMoveTop ( wxCommandEvent & ) { MoveStyles ( true , 1 ) ; }
void DialogStyleManager : : OnStorageMoveDown ( wxCommandEvent & ) { MoveStyles ( true , 2 ) ; }
void DialogStyleManager : : OnStorageMoveBottom ( wxCommandEvent & ) { MoveStyles ( true , 3 ) ; }
void DialogStyleManager : : OnStorageSort ( wxCommandEvent & ) { MoveStyles ( true , 4 ) ; }
void DialogStyleManager : : OnCurrentMoveUp ( wxCommandEvent & ) { MoveStyles ( false , 0 ) ; }
void DialogStyleManager : : OnCurrentMoveTop ( wxCommandEvent & ) { MoveStyles ( false , 1 ) ; }
void DialogStyleManager : : OnCurrentMoveDown ( wxCommandEvent & ) { MoveStyles ( false , 2 ) ; }
void DialogStyleManager : : OnCurrentMoveBottom ( wxCommandEvent & ) { MoveStyles ( false , 3 ) ; }
void DialogStyleManager : : OnCurrentSort ( wxCommandEvent & ) { MoveStyles ( false , 4 ) ; }
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Move function
/// @param storage
/// @param type
2006-12-26 22:45:23 +01:00
void DialogStyleManager : : MoveStyles ( bool storage , int type ) {
wxListBox * list ;
if ( storage ) list = StorageList ;
else list = CurrentList ;
// Get selection
wxArrayInt sels ;
int n = list - > GetSelections ( sels ) ;
2006-12-26 23:28:44 +01:00
int first = - 1 ; ;
int last = - 1 ;
if ( n ) {
first = sels [ 0 ] ;
last = sels [ n - 1 ] ;
}
2006-12-26 22:45:23 +01:00
// Get total style count
int nStyles = list - > GetCount ( ) ;
// Get styles
std : : vector < AssStyle * > styls ;
std : : vector < AssStyle * > * srcStyls ;
if ( storage ) srcStyls = & styleStorageMap ;
else srcStyls = & styleMap ;
// Move up
if ( type = = 0 ) {
for ( int i = 0 ; i < first - 1 ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
for ( int i = first ; i < = last ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
styls . push_back ( srcStyls - > at ( first - 1 ) ) ;
for ( int i = last + 1 ; i < nStyles ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
first - - ;
last - - ;
}
// Move to top
if ( type = = 1 ) {
for ( int i = first ; i < = last ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
for ( int i = 0 ; i < first ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
for ( int i = last + 1 ; i < nStyles ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
last = last - first ;
first = 0 ;
}
// Move down
if ( type = = 2 ) {
for ( int i = 0 ; i < first ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
styls . push_back ( srcStyls - > at ( last + 1 ) ) ;
for ( int i = first ; i < = last ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
for ( int i = last + 2 ; i < nStyles ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
first + + ;
last + + ;
}
// Move to bottom
if ( type = = 3 ) {
for ( int i = 0 ; i < first ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
for ( int i = last + 1 ; i < nStyles ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
for ( int i = first ; i < = last ; i + + ) styls . push_back ( srcStyls - > at ( i ) ) ;
first = nStyles - ( last - first + 1 ) ;
last = nStyles - 1 ;
}
2006-12-26 23:28:44 +01:00
// Sort
if ( type = = 4 ) {
// Get confirmation
if ( storage ) {
int res = wxMessageBox ( _ ( " Are you sure? This cannot be undone! " ) , _ ( " Sort styles " ) , wxYES_NO ) ;
if ( res = = wxNO ) return ;
}
// Get sorted list
2009-07-18 06:37:43 +02:00
wxArrayString styleNames ;
for ( int i = 0 ; i < nStyles ; i + + ) styleNames . Add ( srcStyls - > at ( i ) - > name ) ;
styleNames . Sort ( ) ;
std : : list < AssStyle * > styles ( srcStyls - > begin ( ) , srcStyls - > end ( ) ) ;
for ( int i = 0 ; i < nStyles ; i + + ) {
for ( std : : list < AssStyle * > : : iterator style = styles . begin ( ) ; style ! = styles . end ( ) ; style + + ) {
if ( ( * style ) - > name = = styleNames [ i ] ) {
styls . push_back ( * style ) ;
styles . erase ( style ) ;
break ;
2006-12-26 23:28:44 +01:00
}
}
}
// Zero selection
first = 0 ;
last = 0 ;
}
2006-12-26 22:45:23 +01:00
// Storage
if ( storage ) {
// Rewrite storage
Store . style . clear ( ) ;
for ( unsigned int i = 0 ; i < styls . size ( ) ; i + + ) Store . style . push_back ( styls [ i ] ) ;
// Save storage
Store . Save ( CatalogList - > GetString ( CatalogList - > GetSelection ( ) ) ) ;
}
// Current
else {
// Replace styles
entryIter next ;
int curn = 0 ;
2011-01-16 08:17:36 +01:00
for ( entryIter cur = c - > ass - > Line . begin ( ) ; cur ! = c - > ass - > Line . end ( ) ; cur = next ) {
2006-12-26 22:45:23 +01:00
next = cur ;
next + + ;
2010-05-19 02:44:52 +02:00
AssStyle * style = dynamic_cast < AssStyle * > ( * cur ) ;
2006-12-26 22:45:23 +01:00
if ( style ) {
2011-01-16 08:17:36 +01:00
c - > ass - > Line . insert ( cur , styls [ curn ] ) ;
c - > ass - > Line . erase ( cur ) ;
2006-12-26 22:45:23 +01:00
curn + + ;
}
}
// Flag as modified
2011-09-15 07:16:32 +02:00
c - > ass - > Commit ( _ ( " style move " ) , AssFile : : COMMIT_STYLES ) ;
2006-12-26 22:45:23 +01:00
}
// Update
for ( int i = 0 ; i < nStyles ; i + + ) {
list - > SetString ( i , styls [ i ] - > name ) ;
if ( i < first | | i > last ) list - > Deselect ( i ) ;
else list - > Select ( i ) ;
}
// Set map
* srcStyls = styls ;
// Update buttons
UpdateMoveButtons ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Keydown event
2007-02-05 20:09:45 +01:00
void DialogStyleManager : : OnKeyDown ( wxKeyEvent & event ) {
wxCommandEvent evt ;
switch ( event . GetKeyCode ( ) ) {
case WXK_ESCAPE :
OnClose ( evt ) ;
break ;
case WXK_DELETE :
if ( wxWindow : : FindFocus ( ) = = StorageList ) {
OnStorageDelete ( evt ) ;
}
else if ( wxWindow : : FindFocus ( ) = = CurrentList ) {
OnCurrentDelete ( evt ) ;
}
break ;
2007-02-06 04:25:14 +01:00
case ' C ' :
case ' c ' :
2007-09-22 00:56:44 +02:00
if ( event . CmdDown ( ) ) {
2007-02-06 04:25:14 +01:00
if ( wxWindow : : FindFocus ( ) = = CurrentList ) {
CopyToClipboard ( CurrentList , styleMap ) ;
}
else if ( wxWindow : : FindFocus ( ) = = StorageList ) {
CopyToClipboard ( StorageList , styleStorageMap ) ;
}
}
break ;
case ' V ' :
case ' v ' :
2007-09-22 00:56:44 +02:00
if ( event . CmdDown ( ) ) {
2007-02-06 04:25:14 +01:00
if ( wxWindow : : FindFocus ( ) = = CurrentList ) {
PasteToCurrent ( ) ;
}
else if ( wxWindow : : FindFocus ( ) = = StorageList ) {
PasteToStorage ( ) ;
}
}
break ;
2007-02-05 20:09:45 +01:00
}
}