diff --git a/.clang-format b/.clang-format index bdcf10faf5..85391e6149 100644 --- a/.clang-format +++ b/.clang-format @@ -21,6 +21,16 @@ DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeCategories: + - Regex: '^' + Priority: -1 + SortPriority: 0 + - Regex: '^".*"' + Priority: 1 + SortPriority: 0 + - Regex: '^<.*>' + Priority: 2 + SortPriority: 0 IndentCaseLabels: false IndentWidth: 4 IndentWrappedFunctionNames: false diff --git a/Outline/outline.cpp b/Outline/outline.cpp index d4d9e93563..fb7bcff406 100644 --- a/Outline/outline.cpp +++ b/Outline/outline.cpp @@ -51,10 +51,7 @@ //-------------------------------------------- // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new SymbolViewPlugin(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new SymbolViewPlugin(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { diff --git a/PCH/dummy.cpp b/PCH/dummy.cpp index 8c9e7c7511..5ceea38aaf 100644 --- a/PCH/dummy.cpp +++ b/PCH/dummy.cpp @@ -22,5 +22,3 @@ // ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - - diff --git a/PCH/precompiled_header_dbg.h b/PCH/precompiled_header_dbg.h index 0e70edc860..5547fd172d 100644 --- a/PCH/precompiled_header_dbg.h +++ b/PCH/precompiled_header_dbg.h @@ -1,31 +1,31 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : precompiled_header.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2008 by Eran Ifrah +// file name : precompiled_header.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// #ifndef CODELITE_PRECOMPILED_HEADER_DEBUG_H #define CODELITE_PRECOMPILED_HEADER_DEBUG_H - -#ifdef __cplusplus + +#ifdef __cplusplus // Only include the headers we need here #include "../CodeLite/MSWPrivate.h" @@ -84,7 +84,7 @@ #include #include #include -#endif // #if wxUSE_GUI +#endif // #if wxUSE_GUI ///////////////////////////////////////////////////////////////////////////// // Unicode: @@ -96,36 +96,36 @@ ///////////////////////////////////////////////////////////////////////////// #if defined(__APPLE__) || defined(__CYGWIN__) - #include - #undef _C /* _CTYPE_C */ - #undef _U /* _CTYPE_U */ +#include +#undef _C /* _CTYPE_C */ +#undef _U /* _CTYPE_U */ #endif #ifdef wxUSE_UNICODE - #ifndef _U - #define _U(x) wxString((x),wxConvUTF8) - #endif - #ifndef _UU - #define _UU(x,y) wxString((x),y) - #endif - #ifndef _CC - #define _CC(x,y) (x).mb_str((y)) - #endif +#ifndef _U +#define _U(x) wxString((x), wxConvUTF8) +#endif +#ifndef _UU +#define _UU(x, y) wxString((x), y) +#endif +#ifndef _CC +#define _CC(x, y) (x).mb_str((y)) +#endif #else - #ifndef _U - #define _U(x) (x) - #endif - #ifndef _UU - #define _UU(x,y) (x) - #endif - #ifndef _CC - #define _CC(x,y) (x) - #endif +#ifndef _U +#define _U(x) (x) +#endif +#ifndef _UU +#define _UU(x, y) (x) +#endif +#ifndef _CC +#define _CC(x, y) (x) +#endif #endif #ifndef _C - #define _C(x) _CC((x),wxConvUTF8) +#define _C(x) _CC((x), wxConvUTF8) #endif - + #endif // __cplusplus #endif // CODELITE_PRECOMPILED_HEADER_DEBUG_H diff --git a/PCH/precompiled_header_release.h b/PCH/precompiled_header_release.h index 2e444562f9..e4f9577244 100644 --- a/PCH/precompiled_header_release.h +++ b/PCH/precompiled_header_release.h @@ -22,9 +22,8 @@ // ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef CODELITE_PRECOMPILED_HEADER_RELEASE_H -#define CODELITE_PRECOMPILED_HEADER_RELEASE_H - +#ifndef CODELITE_PRECOMPILED_HEADER_RELEASE_H +#define CODELITE_PRECOMPILED_HEADER_RELEASE_H #ifdef __cplusplus @@ -96,37 +95,37 @@ // 3. To convert literal strings, use _T() ///////////////////////////////////////////////////////////////////////////// -#if defined(__APPLE__) || defined(__CYGWIN__) - #include - #undef _C /* _CTYPE_C */ - #undef _U /* _CTYPE_U */ +#if defined(__APPLE__) || defined(__CYGWIN__) +#include +#undef _C /* _CTYPE_C */ +#undef _U /* _CTYPE_U */ #endif #ifdef wxUSE_UNICODE - #ifndef _U - #define _U(x) wxString((x),wxConvUTF8) - #endif - #ifndef _UU - #define _UU(x,y) wxString((x),y) - #endif - #ifndef _CC - #define _CC(x,y) (x).mb_str((y)) - #endif +#ifndef _U +#define _U(x) wxString((x), wxConvUTF8) +#endif +#ifndef _UU +#define _UU(x, y) wxString((x), y) +#endif +#ifndef _CC +#define _CC(x, y) (x).mb_str((y)) +#endif #else - #ifndef _U - #define _U(x) (x) - #endif - #ifndef _UU - #define _UU(x,y) (x) - #endif - #ifndef _CC - #define _CC(x,y) (x) - #endif +#ifndef _U +#define _U(x) (x) +#endif +#ifndef _UU +#define _UU(x, y) (x) +#endif +#ifndef _CC +#define _CC(x, y) (x) +#endif #endif #ifndef _C - #define _C(x) _CC((x),wxConvUTF8) +#define _C(x) _CC((x), wxConvUTF8) #endif #endif // __cplusplus -#endif // CODELITE_PRECOMPILED_HEADER_RELEASE_H +#endif // CODELITE_PRECOMPILED_HEADER_RELEASE_H diff --git a/PCH/precompiled_header_release_32.h b/PCH/precompiled_header_release_32.h index 2e444562f9..e4f9577244 100644 --- a/PCH/precompiled_header_release_32.h +++ b/PCH/precompiled_header_release_32.h @@ -22,9 +22,8 @@ // ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef CODELITE_PRECOMPILED_HEADER_RELEASE_H -#define CODELITE_PRECOMPILED_HEADER_RELEASE_H - +#ifndef CODELITE_PRECOMPILED_HEADER_RELEASE_H +#define CODELITE_PRECOMPILED_HEADER_RELEASE_H #ifdef __cplusplus @@ -96,37 +95,37 @@ // 3. To convert literal strings, use _T() ///////////////////////////////////////////////////////////////////////////// -#if defined(__APPLE__) || defined(__CYGWIN__) - #include - #undef _C /* _CTYPE_C */ - #undef _U /* _CTYPE_U */ +#if defined(__APPLE__) || defined(__CYGWIN__) +#include +#undef _C /* _CTYPE_C */ +#undef _U /* _CTYPE_U */ #endif #ifdef wxUSE_UNICODE - #ifndef _U - #define _U(x) wxString((x),wxConvUTF8) - #endif - #ifndef _UU - #define _UU(x,y) wxString((x),y) - #endif - #ifndef _CC - #define _CC(x,y) (x).mb_str((y)) - #endif +#ifndef _U +#define _U(x) wxString((x), wxConvUTF8) +#endif +#ifndef _UU +#define _UU(x, y) wxString((x), y) +#endif +#ifndef _CC +#define _CC(x, y) (x).mb_str((y)) +#endif #else - #ifndef _U - #define _U(x) (x) - #endif - #ifndef _UU - #define _UU(x,y) (x) - #endif - #ifndef _CC - #define _CC(x,y) (x) - #endif +#ifndef _U +#define _U(x) (x) +#endif +#ifndef _UU +#define _UU(x, y) (x) +#endif +#ifndef _CC +#define _CC(x, y) (x) +#endif #endif #ifndef _C - #define _C(x) _CC((x),wxConvUTF8) +#define _C(x) _CC((x), wxConvUTF8) #endif #endif // __cplusplus -#endif // CODELITE_PRECOMPILED_HEADER_RELEASE_H +#endif // CODELITE_PRECOMPILED_HEADER_RELEASE_H diff --git a/PHPLint/lintoptions.cpp b/PHPLint/lintoptions.cpp index 4eb5e86eaa..0ae65db102 100644 --- a/PHPLint/lintoptions.cpp +++ b/PHPLint/lintoptions.cpp @@ -1,5 +1,6 @@ -#include "cl_standard_paths.h" #include "lintoptions.h" + +#include "cl_standard_paths.h" #include "fileutils.h" #ifndef __WXMSW__ #include "globals.h" @@ -16,17 +17,19 @@ LintOptions::LintOptions() { wxFileName newConfigFile = clStandardPaths::Get().GetUserDataDir() + wxFileName::GetPathSeparator() + "config" + wxFileName::GetPathSeparator() + "phplint.conf"; - if(!newConfigFile.FileExists()) { + if (!newConfigFile.FileExists()) { wxFileName oldConfigFile = clStandardPaths::Get().GetUserDataDir() + wxFileName::GetPathSeparator() + "config" + wxFileName::GetPathSeparator() + "php.conf"; // If the file does not exist, create a new one wxString buf; - if(FileUtils::ReadBufferFromFile(newConfigFile, buf, 1) && (buf == "[")) { + if (FileUtils::ReadBufferFromFile(newConfigFile, buf, 1) && (buf == "[")) { + FileUtils::WriteFileContent(newConfigFile, "{}"); + } + + if (!newConfigFile.FileExists()) { FileUtils::WriteFileContent(newConfigFile, "{}"); } - - if(!newConfigFile.FileExists()) { FileUtils::WriteFileContent(newConfigFile, "{}"); } // Save it JSON newRoot(newConfigFile); @@ -49,21 +52,21 @@ void LintOptions::FromJSON(const JSONItem& json) #ifndef __WXMSW__ // Find an installed version of phpcs - if(m_phpcsPhar.IsEmpty()) { + if (m_phpcsPhar.IsEmpty()) { wxFileName phpcsFile; ::FileUtils::FindExe("phpcs", phpcsFile); SetPhpcsPhar(phpcsFile); } // Find an installed version of phpmd - if(m_phpmdPhar.IsEmpty()) { + if (m_phpmdPhar.IsEmpty()) { wxFileName phpmdFile; ::FileUtils::FindExe("phpmd", phpmdFile); SetPhpmdPhar(phpmdFile); } // Find an installed version of phpstan - if(m_phpstanPhar.IsEmpty()) { + if (m_phpstanPhar.IsEmpty()) { wxFileName phpstanFile; ::FileUtils::FindExe("phpstan", phpstanFile); SetPhpstanPhar(phpstanFile); diff --git a/PHPLint/phplint.cpp b/PHPLint/phplint.cpp index d56326a38a..1972a4c718 100644 --- a/PHPLint/phplint.cpp +++ b/PHPLint/phplint.cpp @@ -14,10 +14,7 @@ #include // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new PHPLint(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new PHPLint(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -71,7 +68,7 @@ void PHPLint::OnMenuCommand(wxCommandEvent& e) wxUnusedVar(e); PHPLintDlg dlg(EventNotifier::Get()->TopFrame()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { // Store the settings m_settings.SetLintOnFileLoad(dlg.GetCheckBoxLintOnLoad()->IsChecked()) .SetLintOnFileSave(dlg.GetCheckBoxLintOnSave()->IsChecked()) @@ -103,7 +100,9 @@ void PHPLint::OnLoadFile(clCommandEvent& e) { e.Skip(); - if(!m_settings.IsLintOnFileLoad()) { return; } + if (!m_settings.IsLintOnFileLoad()) { + return; + } RunLint(); } @@ -112,7 +111,9 @@ void PHPLint::OnSaveFile(clCommandEvent& e) { e.Skip(); - if(!m_settings.IsLintOnFileSave()) { return; } + if (!m_settings.IsLintOnFileSave()) { + return; + } RunLint(); } @@ -122,8 +123,10 @@ void PHPLint::RunLint() IEditor* editor = m_mgr->GetActiveEditor(); CHECK_PTR_RET(editor); - if(FileExtManager::IsPHPFile(editor->GetFileName())) { - if(m_mgr->GetActiveEditor()) { m_mgr->GetActiveEditor()->DelAllCompilerMarkers(); } + if (FileExtManager::IsPHPFile(editor->GetFileName())) { + if (m_mgr->GetActiveEditor()) { + m_mgr->GetActiveEditor()->DelAllCompilerMarkers(); + } PHPLint::DoCheckFile(editor->GetFileName()); } } @@ -134,7 +137,7 @@ void PHPLint::DoCheckFile(const wxFileName& filename) StringUtils::WrapWithQuotes(file); wxFileName php(m_settingsPhp.GetPhpExe()); - if(!php.Exists()) { + if (!php.Exists()) { clGetManager()->SetStatusMessage(_("PHPLint: can not lint file. Missing PHP executable path"), 5); return; } @@ -153,7 +156,7 @@ void PHPLint::DoCheckFile(const wxFileName& filename) void PHPLint::QueuePhpcsCommand(const wxString& phpPath, const wxString& file) { wxFileName phpcs(m_settings.GetPhpcsPhar()); - if(!phpcs.Exists()) { + if (!phpcs.Exists()) { clDEBUG() << "PHPLint: Could not find the PHP-CS application. Ignoring" << clEndl; return; } @@ -167,7 +170,7 @@ void PHPLint::QueuePhpcsCommand(const wxString& phpPath, const wxString& file) void PHPLint::QueuePhpmdCommand(const wxString& phpPath, const wxString& file) { wxFileName phpmd(m_settings.GetPhpmdPhar()); - if(!phpmd.Exists()) { + if (!phpmd.Exists()) { clDEBUG() << "PHPLint: Could not find the PHPMD application. Ignoring" << clEndl; return; } @@ -176,7 +179,9 @@ void PHPLint::QueuePhpmdCommand(const wxString& phpPath, const wxString& file) StringUtils::WrapWithQuotes(phpmdPath); wxString phpmdRules(m_settings.GetPhpmdRules()); - if(phpmdRules.IsEmpty()) { phpmdRules = "cleancode,codesize,controversial,design,naming,unusedcode"; } + if (phpmdRules.IsEmpty()) { + phpmdRules = "cleancode,codesize,controversial,design,naming,unusedcode"; + } StringUtils::WrapWithQuotes(phpmdRules); m_queue.push_back(phpPath + " " + phpmdPath + " " + file + " xml " + phpmdRules); @@ -185,7 +190,7 @@ void PHPLint::QueuePhpmdCommand(const wxString& phpPath, const wxString& file) void PHPLint::QueuePhpstanCommand(const wxString& phpPath, const wxString& file) { wxFileName phpstan(m_settings.GetPhpstanPhar()); - if(!phpstan.Exists()) { + if (!phpstan.Exists()) { clDEBUG() << "PHPLint: Could not find the Phpstan application. Ignoring" << clEndl; return; } @@ -199,7 +204,7 @@ void PHPLint::QueuePhpstanCommand(const wxString& phpPath, const wxString& file) void PHPLint::DoProcessQueue() { - if(!m_process && !m_queue.empty()) { + if (!m_process && !m_queue.empty()) { wxString command = m_queue.front(); m_queue.pop_front(); DispatchCommand(command); @@ -211,7 +216,7 @@ void PHPLint::DispatchCommand(const wxString& command) // Run the check command m_output.clear(); m_process = ::CreateAsyncProcess(this, command); - if(!m_process) { + if (!m_process) { // failed to run the command clWARNING() << "PHPLint: Could not run command:" << command << clEndl; DoProcessQueue(); @@ -231,7 +236,7 @@ void PHPLint::OnProcessOutput(clProcessEvent& event) { m_output << event.GetOutp void PHPLint::OnLintingDone(const wxString& lintOutput) { - if(lintOutput.Contains("Errors parsing ")) { + if (lintOutput.Contains("Errors parsing ")) { ProcessPhpError(lintOutput); return; } @@ -243,7 +248,7 @@ void PHPLint::ProcessPhpError(const wxString& lintOutput) { wxRegEx reLine("[ \t]*on line ([0-9]+)"); // get the line number - if(reLine.Matches(lintOutput)) { + if (reLine.Matches(lintOutput)) { wxString strLine = reLine.GetMatch(lintOutput, 1); strLine.Trim().Trim(false); @@ -269,14 +274,16 @@ void PHPLint::ProcessXML(const wxString& lintOutput) { wxStringInputStream lintOutputStream(lintOutput); wxXmlDocument doc; - if(!doc.Load(lintOutputStream)) return; + if (!doc.Load(lintOutputStream)) + return; wxXmlNode* file = doc.GetRoot()->GetChildren(); - if(!file) return; + if (!file) + return; // Find the editor wxString filename = file->GetAttribute("name"); - if(!wxFileName(filename).IsAbsolute()) { + if (!wxFileName(filename).IsAbsolute()) { // relative path filename.Prepend(wxGetCwd() + "/"); } @@ -288,9 +295,11 @@ void PHPLint::ProcessXML(const wxString& lintOutput) wxString linter = doc.GetRoot()->GetName(); wxXmlNode* violation = file->GetChildren(); - while(violation) { + while (violation) { wxString errorMessage = violation->GetNodeContent(); - if(errorMessage.IsEmpty()) { errorMessage = violation->GetAttribute("message"); } + if (errorMessage.IsEmpty()) { + errorMessage = violation->GetAttribute("message"); + } wxString strLine = violation->GetAttribute(linter == "pmd" ? "beginline" : "line"); bool isWarning = IsWarning(violation, linter); MarkError(errorMessage, strLine, editor, isWarning); @@ -301,14 +310,14 @@ void PHPLint::ProcessXML(const wxString& lintOutput) bool PHPLint::IsWarning(wxXmlNode* violation, const wxString& linter) { - if(linter == "pmd") { + if (linter == "pmd") { wxString priority = violation->GetAttribute("priority", "1"); long nPriority(wxNOT_FOUND); priority.ToCLong(&nPriority); return (nPriority > 2); } - if(linter == "checkstyle") { + if (linter == "checkstyle") { wxString priority = violation->GetAttribute("severity"); return priority != "error"; } @@ -321,10 +330,10 @@ void PHPLint::MarkError(wxString& errorMessage, const wxString& strLine, IEditor errorMessage = errorMessage.Trim().Trim(false); long nLine(wxNOT_FOUND); - if(strLine.ToCLong(&nLine)) { + if (strLine.ToCLong(&nLine)) { clDEBUG() << "PHPLint: adding error marker @%d" << (nLine - 1) << clEndl; - if(isWarning) { + if (isWarning) { editor->SetWarningMarker(nLine - 1, errorMessage); return; } diff --git a/PHPLint/phplintdlg.cpp b/PHPLint/phplintdlg.cpp index 930ac5aef1..9fbd0aa0f5 100644 --- a/PHPLint/phplintdlg.cpp +++ b/PHPLint/phplintdlg.cpp @@ -1,4 +1,5 @@ #include "phplintdlg.h" + #include "lintoptions.h" #include "windowattrmanager.h" diff --git a/PHPRefactoring/PHPRefactoringPreviewDlg.cpp b/PHPRefactoring/PHPRefactoringPreviewDlg.cpp index c546a4e90b..1654bc4f7c 100644 --- a/PHPRefactoring/PHPRefactoringPreviewDlg.cpp +++ b/PHPRefactoring/PHPRefactoringPreviewDlg.cpp @@ -10,7 +10,7 @@ PHPRefactoringPreviewDlg::PHPRefactoringPreviewDlg(wxWindow* parent, const wxStr : PHPRefactoringPreviewBaseDlg(parent) { LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexer("diff"); - if(lexer) { + if (lexer) { lexer->Apply(m_stcPreview, true); } m_stcPreview->SetText(patchContent); diff --git a/PHPRefactoring/phprefactoring.cpp b/PHPRefactoring/phprefactoring.cpp index 718aeab144..36f8b4538a 100644 --- a/PHPRefactoring/phprefactoring.cpp +++ b/PHPRefactoring/phprefactoring.cpp @@ -21,10 +21,7 @@ #include // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new PHPRefactoring(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new PHPRefactoring(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -62,11 +59,14 @@ void PHPRefactoring::CreatePluginMenu(wxMenu* pluginsMenu) wxTheApp->Bind(wxEVT_MENU, &PHPRefactoring::OnExtractMethod, this, wxID_EXTRACT_METHOD); wxTheApp->Bind(wxEVT_MENU, &PHPRefactoring::OnRenameLocalVariable, this, wxID_RENAME_LOCAL_VARIABLE); wxTheApp->Bind(wxEVT_MENU, &PHPRefactoring::OnRenameClassProperty, this, wxID_RENAME_CLASS_PROPERTY); - wxTheApp->Bind(wxEVT_MENU, &PHPRefactoring::OnConvertLocalToInstanceVariable, this, - wxID_CONVERT_LOCAL_TO_INSTANCE_VARIABLE); + wxTheApp->Bind( + wxEVT_MENU, &PHPRefactoring::OnConvertLocalToInstanceVariable, this, wxID_CONVERT_LOCAL_TO_INSTANCE_VARIABLE); wxTheApp->Bind(wxEVT_MENU, &PHPRefactoring::OnOptimizeUseStatements, this, wxID_OPTIMIZE_USE_STATEMENTS); - wxTheApp->Connect(wxID_RENAME_CLASS_AND_NAMESPACES, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(PHPRefactoring::OnRenameClassAndNamespaces), NULL, this); + wxTheApp->Connect(wxID_RENAME_CLASS_AND_NAMESPACES, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(PHPRefactoring::OnRenameClassAndNamespaces), + NULL, + this); EventNotifier::Get()->Bind(wxEVT_CONTEXT_MENU_EDITOR, &PHPRefactoring::OnEditorContextMenu, this); EventNotifier::Get()->Bind(wxEVT_PHP_SETTINGS_CHANGED, &PHPRefactoring::OnPhpSettingsChanged, this); EventNotifier::Get()->Bind(wxEVT_CONTEXT_MENU_FOLDER, &PHPRefactoring::OnContextMenu, this); @@ -78,11 +78,14 @@ void PHPRefactoring::UnPlug() wxTheApp->Unbind(wxEVT_MENU, &PHPRefactoring::OnExtractMethod, this, wxID_EXTRACT_METHOD); wxTheApp->Unbind(wxEVT_MENU, &PHPRefactoring::OnRenameLocalVariable, this, wxID_RENAME_LOCAL_VARIABLE); wxTheApp->Unbind(wxEVT_MENU, &PHPRefactoring::OnRenameClassProperty, this, wxID_RENAME_CLASS_PROPERTY); - wxTheApp->Unbind(wxEVT_MENU, &PHPRefactoring::OnConvertLocalToInstanceVariable, this, - wxID_CONVERT_LOCAL_TO_INSTANCE_VARIABLE); + wxTheApp->Unbind( + wxEVT_MENU, &PHPRefactoring::OnConvertLocalToInstanceVariable, this, wxID_CONVERT_LOCAL_TO_INSTANCE_VARIABLE); wxTheApp->Unbind(wxEVT_MENU, &PHPRefactoring::OnOptimizeUseStatements, this, wxID_OPTIMIZE_USE_STATEMENTS); - wxTheApp->Disconnect(wxID_RENAME_CLASS_AND_NAMESPACES, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(PHPRefactoring::OnRenameClassAndNamespaces), NULL, this); + wxTheApp->Disconnect(wxID_RENAME_CLASS_AND_NAMESPACES, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(PHPRefactoring::OnRenameClassAndNamespaces), + NULL, + this); EventNotifier::Get()->Unbind(wxEVT_CONTEXT_MENU_EDITOR, &PHPRefactoring::OnEditorContextMenu, this); EventNotifier::Get()->Unbind(wxEVT_PHP_SETTINGS_CHANGED, &PHPRefactoring::OnPhpSettingsChanged, this); EventNotifier::Get()->Unbind(wxEVT_CONTEXT_MENU_FOLDER, &PHPRefactoring::OnContextMenu, this); @@ -93,7 +96,7 @@ void PHPRefactoring::OnEditorContextMenu(clContextMenuEvent& event) event.Skip(); IEditor* editor = m_manager->GetActiveEditor(); - if(!editor || !FileExtManager::IsPHPFile(editor->GetFileName())) { + if (!editor || !FileExtManager::IsPHPFile(editor->GetFileName())) { return; // Not in php file, do not add options to context menu } @@ -113,7 +116,7 @@ void PHPRefactoring::OnMenuCommand(wxCommandEvent& e) wxUnusedVar(e); PHPRefactoringDlg dlg(EventNotifier::Get()->TopFrame()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { // Store the settings m_settings.SetPhprefactoringPhar(dlg.GetFilePickerPhprefactoringPhar()->GetFileName()) .SetSkipPreview(dlg.GetCheckBoxSkipPreview()->GetValue()) @@ -124,18 +127,18 @@ void PHPRefactoring::OnMenuCommand(wxCommandEvent& e) void PHPRefactoring::OnExtractMethod(wxCommandEvent& e) { IEditor* editor = m_manager->GetActiveEditor(); - if(!editor) { + if (!editor) { return; } int startLine = editor->LineFromPos(editor->GetSelectionStart()) + 1; int endLine = editor->LineFromPos(editor->GetSelectionEnd()) + 1; wxString method = wxGetTextFromUser(_("Name the new method")); - if(method.IsEmpty()) { + if (method.IsEmpty()) { return; } - if(method.Contains(" ")) { + if (method.Contains(" ")) { ::wxMessageBox(_("Method name may not contain spaces"), "PHPRefactoring", wxICON_ERROR | wxOK | wxCENTER); return; } @@ -154,17 +157,17 @@ void PHPRefactoring::OnRenameClassProperty(wxCommandEvent& e) { RenameVariable(" void PHPRefactoring::RenameVariable(const wxString& action) { IEditor* editor = m_manager->GetActiveEditor(); - if(!editor) { + if (!editor) { return; } wxString line; line << (editor->GetCurrentLine() + 1); wxString oldName = editor->GetWordAtCaret(); - if(oldName.StartsWith("$")) { + if (oldName.StartsWith("$")) { oldName = oldName.Mid(1); } - if(oldName.IsEmpty()) { + if (oldName.IsEmpty()) { return; } @@ -172,12 +175,12 @@ void PHPRefactoring::RenameVariable(const wxString& action) newName.Trim().Trim(false); // If it starts with $ sign, remove it - if(newName.StartsWith("$")) { + if (newName.StartsWith("$")) { newName = newName.Mid(1); } // Sanity - if(newName.IsEmpty()) { + if (newName.IsEmpty()) { return; } @@ -188,17 +191,17 @@ void PHPRefactoring::RenameVariable(const wxString& action) void PHPRefactoring::OnConvertLocalToInstanceVariable(wxCommandEvent& e) { IEditor* editor = m_manager->GetActiveEditor(); - if(!editor) { + if (!editor) { return; } wxString line; line << (editor->GetCurrentLine() + 1); wxString oldName = editor->GetWordAtCaret(); - if(oldName.StartsWith("$")) { + if (oldName.StartsWith("$")) { oldName = oldName.Mid(1); } - if(oldName.IsEmpty()) { + if (oldName.IsEmpty()) { return; } @@ -211,7 +214,7 @@ void PHPRefactoring::OnRenameClassAndNamespaces(wxCommandEvent& e) wxString msg; msg << _("This will sync namespaces and classes with folder and filenames, for all files in the selected folder, " "to comply with psr-0\nContinue?"); - if(wxYES != ::wxMessageBox(msg, _("PHP Refactoring"), wxYES_NO | wxCANCEL | wxCENTER)) { + if (wxYES != ::wxMessageBox(msg, _("PHP Refactoring"), wxYES_NO | wxCANCEL | wxCENTER)) { return; } @@ -223,7 +226,7 @@ void PHPRefactoring::OnRenameClassAndNamespaces(wxCommandEvent& e) void PHPRefactoring::OnOptimizeUseStatements(wxCommandEvent& e) { IEditor* editor = m_manager->GetActiveEditor(); - if(!editor) { + if (!editor) { return; } @@ -236,8 +239,9 @@ void PHPRefactoring::RefactorFile(const wxString& action, const wxString& extraP filePath = editor->GetFileName().GetFullPath(); tmpfile << filePath << "-refactoring-browser.php"; wxString oldContent = editor->GetEditorText(); - if(!FileUtils::WriteFileContent(tmpfile, oldContent)) { - ::wxMessageBox(_("Can not refactor file:\nFailed to write temporary file"), _("PHP Refactoring"), + if (!FileUtils::WriteFileContent(tmpfile, oldContent)) { + ::wxMessageBox(_("Can not refactor file:\nFailed to write temporary file"), + _("PHP Refactoring"), wxICON_ERROR | wxOK | wxCENTER); return; } @@ -257,13 +261,14 @@ void PHPRefactoring::RefactorFile(const wxString& action, const wxString& extraP RunCommand(parameters); - if(!FileUtils::ReadFileContent(tmpfile, output)) { - ::wxMessageBox(_("Can not refactor file:\nfailed to read temporary file content"), _("PHP Refactoring"), + if (!FileUtils::ReadFileContent(tmpfile, output)) { + ::wxMessageBox(_("Can not refactor file:\nfailed to read temporary file content"), + _("PHP Refactoring"), wxICON_ERROR | wxOK | wxCENTER); return; } - if(!oldContent.IsSameAs(output)) { + if (!oldContent.IsSameAs(output)) { // Update the editor clEditorStateLocker lk(editor->GetCtrl()); editor->GetCtrl()->BeginUndoAction(); @@ -284,8 +289,9 @@ void PHPRefactoring::RunCommand(const wxString& parameters, const wxString& work wxString phpPath, refactorPath, command; wxFileName php(m_settingsPhp.GetPhpExe()); - if(!php.Exists()) { - ::wxMessageBox(_("Can not refactor file: Missing PHP executable path"), _("PHP Refactoring"), + if (!php.Exists()) { + ::wxMessageBox(_("Can not refactor file: Missing PHP executable path"), + _("PHP Refactoring"), wxICON_ERROR | wxOK | wxCENTER); return; } @@ -293,8 +299,9 @@ void PHPRefactoring::RunCommand(const wxString& parameters, const wxString& work StringUtils::WrapWithQuotes(phpPath); wxFileName refactor(m_settings.GetPhprefactoringPhar()); - if(!refactor.Exists()) { - ::wxMessageBox(_("Can not refactor file: Missing PHP Refactoring Browser path"), _("PHP Refactoring"), + if (!refactor.Exists()) { + ::wxMessageBox(_("Can not refactor file: Missing PHP Refactoring Browser path"), + _("PHP Refactoring"), wxICON_ERROR | wxOK | wxCENTER); return; } @@ -311,14 +318,14 @@ void PHPRefactoring::RunCommand(const wxString& parameters, const wxString& work process->WaitForTerminate(patch); clDEBUG() << "PHPRefactoring output:" << patch << clEndl; - if(!patch.StartsWith("--- a/")) { // not a patch + if (!patch.StartsWith("--- a/")) { // not a patch wxString errorMessage = "Refactoring failed!"; wxRegEx reLine("[ \t]*on line ([0-9]+)"); - if(patch.Contains("Exception]")) { // has an error exception + if (patch.Contains("Exception]")) { // has an error exception int start = patch.Find("Exception]"); errorMessage = patch.Mid(start).AfterFirst('\n').BeforeFirst('\n'); errorMessage = errorMessage.Trim().Trim(false); - } else if(reLine.Matches(patch)) { + } else if (reLine.Matches(patch)) { wxString strLine = reLine.GetMatch(patch, 1); int start = patch.Find("error:") + 6; @@ -330,7 +337,7 @@ void PHPRefactoring::RunCommand(const wxString& parameters, const wxString& work } // Truncate the message to something readable - if(errorMessage.length() > 500) { + if (errorMessage.length() > 500) { errorMessage = errorMessage.Mid(0, 500); errorMessage << "..."; } @@ -340,8 +347,9 @@ void PHPRefactoring::RunCommand(const wxString& parameters, const wxString& work wxFileName fnTmpFile(wxFileName::CreateTempFileName("diff-XXXXXX")); tmpfile = fnTmpFile.GetFullPath(); - if(!FileUtils::WriteFileContent(tmpfile, patch)) { - ::wxMessageBox(_("Can not refactor file:\nFailed to write temporary file"), _("PHP Refactoring"), + if (!FileUtils::WriteFileContent(tmpfile, patch)) { + ::wxMessageBox(_("Can not refactor file:\nFailed to write temporary file"), + _("PHP Refactoring"), wxICON_ERROR | wxOK | wxCENTER); return; } @@ -349,7 +357,7 @@ void PHPRefactoring::RunCommand(const wxString& parameters, const wxString& work // Load the changes into the preview dialog PHPRefactoringPreviewDlg dlg(EventNotifier::Get()->TopFrame(), patch); - if(m_settings.GetSkipPreview() || dlg.ShowModal() == wxID_OK) { + if (m_settings.GetSkipPreview() || dlg.ShowModal() == wxID_OK) { // Apply the patch try { clPatch patcher; diff --git a/PHPRefactoring/phprefactoringdlg.cpp b/PHPRefactoring/phprefactoringdlg.cpp index 23b1d999a8..12c4a31860 100644 --- a/PHPRefactoring/phprefactoringdlg.cpp +++ b/PHPRefactoring/phprefactoringdlg.cpp @@ -1,4 +1,5 @@ #include "phprefactoringdlg.h" + #include "phprefactoringoptions.h" #include "windowattrmanager.h" diff --git a/PHPRefactoring/phprefactoringoptions.cpp b/PHPRefactoring/phprefactoringoptions.cpp index 5f8af5a16e..3cc35f0b74 100644 --- a/PHPRefactoring/phprefactoringoptions.cpp +++ b/PHPRefactoring/phprefactoringoptions.cpp @@ -1,5 +1,7 @@ #include "phprefactoringoptions.h" + #include "cl_standard_paths.h" + #include PHPRefactoringOptions::PHPRefactoringOptions() @@ -9,7 +11,7 @@ PHPRefactoringOptions::PHPRefactoringOptions() { // Set default PHAR file wxFileName pharFile(clStandardPaths::Get().GetDataDir(), "phprefactor.phar"); - if(pharFile.FileExists()) { + if (pharFile.FileExists()) { m_phprefactoringPhar = pharFile.GetFullPath(); } } diff --git a/Plugin/CustomControls/clStyledTextCtrlMiniMap.cpp b/Plugin/CustomControls/clStyledTextCtrlMiniMap.cpp index 3d52cc2e71..b29437eacc 100644 --- a/Plugin/CustomControls/clStyledTextCtrlMiniMap.cpp +++ b/Plugin/CustomControls/clStyledTextCtrlMiniMap.cpp @@ -16,7 +16,9 @@ // ---------------------------------------------------------------------------- // for compilers that support precompilation, includes "wx.h". -#include "CustomControls/clStyledTextCtrlMiniMap.hpp" +#include + +#include "clStyledTextCtrlMiniMap.hpp" #if wxCHECK_VERSION(3, 3, 2) @@ -25,7 +27,6 @@ #include #include #include -#include // ---------------------------------------------------------------------------- // constants diff --git a/Plugin/clLocaleManager.cpp b/Plugin/clLocaleManager.cpp index e183895771..36a35075ba 100644 --- a/Plugin/clLocaleManager.cpp +++ b/Plugin/clLocaleManager.cpp @@ -1,10 +1,11 @@ +#include + #include "clLocaleManager.hpp" #include #include #include #include -#include using namespace std; diff --git a/Plugin/clThemedTextCtrl.cpp b/Plugin/clThemedTextCtrl.cpp index 526ec1971d..705c9ff8e9 100644 --- a/Plugin/clThemedTextCtrl.cpp +++ b/Plugin/clThemedTextCtrl.cpp @@ -1,3 +1,5 @@ +#include + #include "clThemedTextCtrl.hpp" #include "ColoursAndFontsManager.h" @@ -12,7 +14,6 @@ #include #include #include -#include #ifndef wxSTC_MAX_MARGIN #define wxSTC_MAX_MARGIN 4 diff --git a/QmakePlugin/newqtprojdlg.cpp b/QmakePlugin/newqtprojdlg.cpp index 83b95dda1d..ab25a9b7da 100644 --- a/QmakePlugin/newqtprojdlg.cpp +++ b/QmakePlugin/newqtprojdlg.cpp @@ -24,11 +24,13 @@ ////////////////////////////////////////////////////////////////////////////// #include "newqtprojdlg.h" -#include "qmakesettingsdlg.h" -#include "qmakeconf.h" + #include "imanager.h" +#include "qmakeconf.h" +#include "qmakesettingsdlg.h" #include "windowattrmanager.h" #include "workspace.h" + #include NewQtProjDlg::NewQtProjDlg(wxWindow* parent, QmakeConf* conf, IManager* mgr) @@ -36,18 +38,18 @@ NewQtProjDlg::NewQtProjDlg(wxWindow* parent, QmakeConf* conf, IManager* mgr) , m_conf(conf) , m_mgr(mgr) { - const wxString ProjKinds[] = { wxT("Console"), wxT("GUI"), wxT("Static Library"), wxT("Dynamic Library") }; + const wxString ProjKinds[] = {wxT("Console"), wxT("GUI"), wxT("Static Library"), wxT("Dynamic Library")}; wxArrayString choices(4, ProjKinds); m_choiceProjKind->Clear(); m_choiceProjKind->Append(choices); m_choiceProjKind->SetSelection(1); m_choiceQmake->Append(m_conf->GetAllConfigurations()); - if(m_choiceQmake->IsEmpty() == false) { + if (m_choiceQmake->IsEmpty() == false) { m_choiceQmake->SetSelection(0); } - if(m_mgr->IsWorkspaceOpen()) { + if (m_mgr->IsWorkspaceOpen()) { m_dirPicker4->SetPath(m_mgr->GetWorkspace()->GetWorkspaceFileName().GetPath()); } SetName("NewQtProjDlg"); @@ -59,10 +61,10 @@ NewQtProjDlg::~NewQtProjDlg() {} void NewQtProjDlg::OnNewQmakeSettings(wxCommandEvent& event) { QMakeSettingsDlg dlg(this, m_mgr, m_conf); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { m_choiceQmake->Clear(); m_choiceQmake->Append(m_conf->GetAllConfigurations()); - if(m_choiceQmake->IsEmpty() == false) { + if (m_choiceQmake->IsEmpty() == false) { m_choiceQmake->SetSelection(0); } } diff --git a/QmakePlugin/newqtprojdlg.h b/QmakePlugin/newqtprojdlg.h index ee8d3b148c..372e3b1028 100644 --- a/QmakePlugin/newqtprojdlg.h +++ b/QmakePlugin/newqtprojdlg.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2014 Eran Ifrah -// file name : newqtprojdlg.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2014 Eran Ifrah +// file name : newqtprojdlg.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #ifndef __newqtprojdlg__ #define __newqtprojdlg__ @@ -39,24 +39,24 @@ class IManager; /** Implementing NewQtProjBaseDlg */ class NewQtProjDlg : public NewQtProjBaseDlg { - QmakeConf *m_conf; - IManager *m_mgr; + QmakeConf* m_conf; + IManager* m_mgr; protected: virtual void OnOKUI(wxUpdateUIEvent& event); // Handlers for NewQtProjBaseDlg events. - void OnNewQmakeSettings( wxCommandEvent& event ); + void OnNewQmakeSettings(wxCommandEvent& event); public: /** Constructor */ - NewQtProjDlg( wxWindow* parent, QmakeConf *conf, IManager *mgr ); + NewQtProjDlg(wxWindow* parent, QmakeConf* conf, IManager* mgr); virtual ~NewQtProjDlg(); - wxString GetProjectName () const; - wxString GetProjectPath () const; - wxString GetProjectKind () const; - wxString GetQmake () const; - bool GetCreateDirectory() const; + wxString GetProjectName() const; + wxString GetProjectPath() const; + wxString GetProjectKind() const; + wxString GetQmake() const; + bool GetCreateDirectory() const; }; -#endif // __newqtprojdlg__ +#endif // __newqtprojdlg__ diff --git a/QmakePlugin/qmakeconf.cpp b/QmakePlugin/qmakeconf.cpp index af5d791338..271e3b17f3 100644 --- a/QmakePlugin/qmakeconf.cpp +++ b/QmakePlugin/qmakeconf.cpp @@ -25,25 +25,22 @@ #include "qmakeconf.h" -QmakeConf::QmakeConf(const wxString &confPath) +QmakeConf::QmakeConf(const wxString& confPath) : wxFileConfig(wxEmptyString, wxEmptyString, confPath, wxEmptyString, wxCONFIG_USE_LOCAL_FILE) { } -QmakeConf::~QmakeConf() -{ - Flush(); -} +QmakeConf::~QmakeConf() { Flush(); } wxArrayString QmakeConf::GetAllConfigurations() const { wxArrayString configs; - wxString group; - long idx; + wxString group; + long idx; bool cont = GetFirstGroup(group, idx); while (cont) { - configs.Add( group ); + configs.Add(group); cont = GetNextGroup(group, idx); } diff --git a/QmakePlugin/qmakeconf.h b/QmakePlugin/qmakeconf.h index b86a234324..8258bdc842 100644 --- a/QmakePlugin/qmakeconf.h +++ b/QmakePlugin/qmakeconf.h @@ -26,13 +26,13 @@ #ifndef __qmakeconf__ #define __qmakeconf__ -#include #include +#include class QmakeConf : public wxFileConfig { public: - QmakeConf(const wxString &confPath); + QmakeConf(const wxString& confPath); virtual ~QmakeConf(); wxArrayString GetAllConfigurations() const; }; diff --git a/QmakePlugin/qmakegenerator.cpp b/QmakePlugin/qmakegenerator.cpp index 37b0126f8d..181c070970 100644 --- a/QmakePlugin/qmakegenerator.cpp +++ b/QmakePlugin/qmakegenerator.cpp @@ -61,16 +61,22 @@ bool QMakeProFileGenerator::Generate() bool needRegenration(true); ProjectPtr p = m_manager->GetWorkspace()->FindProjectByName(m_project, errMsg); - if(!p) { return false; } + if (!p) { + return false; + } wxString rawData = p->GetPluginData(wxT("qmake")); QmakePluginData pd(rawData); - if(!pd.GetDataForBuildConf(m_configuration, bcpd)) { return false; } + if (!pd.GetDataForBuildConf(m_configuration, bcpd)) { + return false; + } // Get CodeLite's build configuration ProjectSettingsPtr settings = p->GetSettings(); BuildConfigPtr bldConf = settings->GetBuildConfiguration(m_configuration); - if(!bldConf) { return false; } + if (!bldConf) { + return false; + } m_makefilePath = p->GetFileName().GetPath(wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME); m_makefilePath += p->GetName(); @@ -97,26 +103,26 @@ bool QMakeProFileGenerator::Generate() // incase we are building library, set the template back the lib wxString type = p->GetSettings()->GetProjectType(bldConf->GetName()); - if(type == PROJECT_TYPE_DYNAMIC_LIBRARY || type == PROJECT_TYPE_STATIC_LIBRARY) { + if (type == PROJECT_TYPE_DYNAMIC_LIBRARY || type == PROJECT_TYPE_STATIC_LIBRARY) { pro_file << wxT("TEMPLATE = lib\n"); } // Optimization: check to see if we really need to run qmake - if(wxFileName::FileExists(m_makefilePath) == false) { + if (wxFileName::FileExists(m_makefilePath) == false) { needRegenration = true; - } else if(wxFileName::FileExists(GetProFileName()) == false) { + } else if (wxFileName::FileExists(GetProFileName()) == false) { needRegenration = true; } else { // both files exists, compare the MD5 of the pro file on the disk with the wxString content; - if(!ReadFileWithConversion(GetProFileName(), content)) { + if (!ReadFileWithConversion(GetProFileName(), content)) { needRegenration = true; } else { wxString diskMD5 = wxMD5::GetDigest(content); wxString mem_MD5 = wxMD5::GetDigest(pro_file); - if(diskMD5 != mem_MD5) { + if (diskMD5 != mem_MD5) { needRegenration = true; } else { needRegenration = false; @@ -127,7 +133,7 @@ bool QMakeProFileGenerator::Generate() // dump the content to a file wxFFile output; output.Open(GetProFileName(), wxT("w+b")); - if(output.IsOpened()) { + if (output.IsOpened()) { output.Write(pro_file); output.Close(); } @@ -145,11 +151,11 @@ void QMakeProFileGenerator::SetVariables(wxString& pro_file, BuildConfigPtr bldC // since LIBS does not add the -L, we need to add it ourselves here CompilerPtr cmp = m_manager->GetBuildSettingsConfigManager()->GetCompiler(bldConf->GetCompilerType()); - if(type == PROJECT_TYPE_EXECUTABLE) { + if (type == PROJECT_TYPE_EXECUTABLE) { pro_file << wxT("TEMPLATE = app\n"); pro_file << wxT("CONFIG = release qt lex yacc uic resources warn_on precompile_header\n"); - } else if(type == PROJECT_TYPE_DYNAMIC_LIBRARY) { + } else if (type == PROJECT_TYPE_DYNAMIC_LIBRARY) { pro_file << wxT("TEMPLATE = lib\n"); pro_file << wxT("CONFIG = release qt dll lex yacc uic resources warn_on precompile_header\n"); @@ -177,10 +183,10 @@ void QMakeProFileGenerator::SetVariables(wxString& pro_file, BuildConfigPtr bldC // Add the global include path wxArrayString includes_list; includes.Clear(); - if(cmp) { + if (cmp) { includes = cmp->GetGlobalIncludePath(); includes.Trim().Trim(false); - if(includes.IsEmpty() == false) { + if (includes.IsEmpty() == false) { // Get list of include paths includes_list = wxStringTokenize(includes, ";", wxTOKEN_STRTOK); /* includes.Replace(wxT(";"), wxT(" ")); @@ -191,7 +197,7 @@ void QMakeProFileGenerator::SetVariables(wxString& pro_file, BuildConfigPtr bldC includes.Clear(); // Append modified values includes << wxT("INCLUDEPATH += "); - for(size_t i = 0; i < includes_list.GetCount(); ++i) { + for (size_t i = 0; i < includes_list.GetCount(); ++i) { includes << "\"" << includes_list.Item(i) << "\" "; } pro_file << includes << wxT("\n"); @@ -224,11 +230,13 @@ void QMakeProFileGenerator::SetVariables(wxString& pro_file, BuildConfigPtr bldC //-------------------------------------------- wxString libPaths = bldConf->GetLibPath(); wxString librarySwitch(wxT("-L")); // by default set it to '-L' - if(cmp) { librarySwitch = cmp->GetSwitch(wxT("LibraryPath")); } + if (cmp) { + librarySwitch = cmp->GetSwitch(wxT("LibraryPath")); + } wxArrayString libPathsArr = wxStringTokenize(libPaths, wxT(";"), wxTOKEN_STRTOK); libPaths.Clear(); - for(size_t i = 0; i < libPathsArr.GetCount(); i++) { + for (size_t i = 0; i < libPathsArr.GetCount(); i++) { libPaths << librarySwitch << wxT("\"") << libPathsArr.Item(i) << wxT("\" "); } @@ -236,12 +244,12 @@ void QMakeProFileGenerator::SetVariables(wxString& pro_file, BuildConfigPtr bldC // Add the global library path libPaths.Clear(); - if(cmp) { + if (cmp) { libPaths = cmp->GetGlobalLibPath(); libPaths.Trim().Trim(false); libPathsArr = wxStringTokenize(libPaths, wxT(";"), wxTOKEN_STRTOK); libPaths.Clear(); - for(size_t i = 0; i < libPathsArr.GetCount(); i++) { + for (size_t i = 0; i < libPathsArr.GetCount(); i++) { libPaths << librarySwitch << wxT("\"") << libPathsArr.Item(i) << wxT("\" "); } pro_file << wxT("LIBS += ") << libPaths << wxT("\n"); @@ -251,12 +259,12 @@ void QMakeProFileGenerator::SetVariables(wxString& pro_file, BuildConfigPtr bldC // Libraries //-------------------------------------------- wxString libs = bldConf->GetLibraries(); - if(cmp) { + if (cmp) { wxString libSwitch = cmp->GetSwitch(wxT("Library")); wxArrayString libsArr = wxStringTokenize(libs, wxT(";"), wxTOKEN_STRTOK); libs.Clear(); - for(size_t i = 0; i < libsArr.GetCount(); i++) { + for (size_t i = 0; i < libsArr.GetCount(); i++) { libs << libSwitch << libsArr.Item(i) << wxT(" "); } pro_file << wxT("LIBS += ") << libs << wxT("\n"); @@ -279,7 +287,7 @@ void QMakeProFileGenerator::SetFiles(wxString& pro_file, ProjectPtr proj) wxString BUFF(wxT(" ")); for (wxFileName fn : files) { - switch(FileExtManager::GetType(fn.GetFullName())) { + switch (FileExtManager::GetType(fn.GetFullName())) { case FileExtManager::TypeSourceC: case FileExtManager::TypeSourceCpp: sources << BUFF << fn.GetFullPath() << wxT("\\\n"); @@ -316,7 +324,7 @@ wxString QMakeProFileGenerator::GetProFileName() { wxString errMsg; ProjectPtr p = m_manager->GetWorkspace()->FindProjectByName(m_project, errMsg); - if(p) { + if (p) { wxFileName fn(wxString::Format(wxT("%s/%s.pro"), p->GetFileName().GetPath(wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME).c_str(), m_project.c_str())); diff --git a/QmakePlugin/qmakegenerator.h b/QmakePlugin/qmakegenerator.h index 705d02a4d6..1ae05c3a12 100644 --- a/QmakePlugin/qmakegenerator.h +++ b/QmakePlugin/qmakegenerator.h @@ -26,39 +26,41 @@ #ifndef __qmakegenerator__ #define __qmakegenerator__ -#include -#include "qmakeplugindata.h" -#include "project_settings.h" #include "build_config.h" #include "project.h" +#include "project_settings.h" +#include "qmakeplugindata.h" + +#include class IManager; -class QMakeProFileGenerator { - IManager* m_manager; - wxString m_project; - wxString m_configuration; - wxString m_makefilePath; +class QMakeProFileGenerator +{ + IManager* m_manager; + wxString m_project; + wxString m_configuration; + wxString m_makefilePath; - void SetVariables ( wxString &pro_file, BuildConfigPtr bldConf, ProjectSettingsPtr settings); - void SetFiles ( wxString &pro_file, ProjectPtr proj); - wxString prepareVariable( const wxString &variable ); + void SetVariables(wxString& pro_file, BuildConfigPtr bldConf, ProjectSettingsPtr settings); + void SetFiles(wxString& pro_file, ProjectPtr proj); + wxString prepareVariable(const wxString& variable); public: - QMakeProFileGenerator(IManager *manager, const wxString &project, const wxString &configuration); + QMakeProFileGenerator(IManager* manager, const wxString& project, const wxString& configuration); virtual ~QMakeProFileGenerator() = default; - /** - * @brief generate .pro file to build the project with its dependencies - * @param project project name - * @param configuration the selected configuration - * @return true on success - */ - bool Generate(); + /** + * @brief generate .pro file to build the project with its dependencies + * @param project project name + * @param configuration the selected configuration + * @return true on success + */ + bool Generate(); - /** - * @brief return the name of the generated pro file - */ - wxString GetProFileName(); + /** + * @brief return the name of the generated pro file + */ + wxString GetProFileName(); }; #endif // __qmakegenerator__ diff --git a/QmakePlugin/qmakeplugin.cpp b/QmakePlugin/qmakeplugin.cpp index 98d2550533..565b00e357 100644 --- a/QmakePlugin/qmakeplugin.cpp +++ b/QmakePlugin/qmakeplugin.cpp @@ -49,10 +49,7 @@ #include // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new QMakePlugin(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new QMakePlugin(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -78,17 +75,17 @@ QMakePlugin::QMakePlugin(IManager* manager) Bind(wxEVT_ASYNC_PROCESS_OUTPUT, &QMakePlugin::OnQmakeOutput, this); Bind(wxEVT_ASYNC_PROCESS_TERMINATED, &QMakePlugin::OnQmakeTerminated, this); // Connect items - EventNotifier::Get()->Connect(wxEVT_CMD_PROJ_SETTINGS_SAVED, - clProjectSettingsEventHandler(QMakePlugin::OnSaveConfig), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_CMD_PROJ_SETTINGS_SAVED, clProjectSettingsEventHandler(QMakePlugin::OnSaveConfig), NULL, this); EventNotifier::Get()->Connect(wxEVT_BUILD_STARTING, clBuildEventHandler(QMakePlugin::OnBuildStarting), NULL, this); - EventNotifier::Get()->Connect(wxEVT_GET_PROJECT_BUILD_CMD, clBuildEventHandler(QMakePlugin::OnGetBuildCommand), - NULL, this); - EventNotifier::Get()->Connect(wxEVT_GET_PROJECT_CLEAN_CMD, clBuildEventHandler(QMakePlugin::OnGetCleanCommand), - NULL, this); - EventNotifier::Get()->Connect(wxEVT_GET_IS_PLUGIN_MAKEFILE, clBuildEventHandler(QMakePlugin::OnGetIsPluginMakefile), - NULL, this); - EventNotifier::Get()->Connect(wxEVT_TREE_ITEM_FILE_ACTIVATED, clCommandEventHandler(QMakePlugin::OnOpenFile), NULL, - this); + EventNotifier::Get()->Connect( + wxEVT_GET_PROJECT_BUILD_CMD, clBuildEventHandler(QMakePlugin::OnGetBuildCommand), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_GET_PROJECT_CLEAN_CMD, clBuildEventHandler(QMakePlugin::OnGetCleanCommand), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_GET_IS_PLUGIN_MAKEFILE, clBuildEventHandler(QMakePlugin::OnGetIsPluginMakefile), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_TREE_ITEM_FILE_ACTIVATED, clCommandEventHandler(QMakePlugin::OnOpenFile), NULL, this); } QMakePlugin::~QMakePlugin() { delete m_conf; } @@ -98,7 +95,9 @@ void QMakePlugin::CreateToolBar(clToolBarGeneric* toolbar) // Support both toolbars icon size int size = m_mgr->GetToolbarIconSize(); auto images = toolbar->GetBitmapsCreateIfNeeded(); - toolbar->AddTool(XRCID("new_qmake_project"), _("Create new qmake based project"), images->Add("qt", size), + toolbar->AddTool(XRCID("new_qmake_project"), + _("Create new qmake based project"), + images->Add("qt", size), _("Create new qmake based project")); } @@ -116,18 +115,27 @@ void QMakePlugin::CreatePluginMenu(wxMenu* pluginsMenu) pluginsMenu->Append(wxID_ANY, _("QMake"), menu); - wxTheApp->Connect(XRCID("new_qmake_project"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(QMakePlugin::OnNewQmakeBasedProject), NULL, (wxEvtHandler*)this); - wxTheApp->Connect(XRCID("qmake_settings"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(QMakePlugin::OnSettings), NULL, (wxEvtHandler*)this); - wxTheApp->Connect(XRCID("qmake_run_qmake"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(QMakePlugin::OnExportMakefile), NULL, this); + wxTheApp->Connect(XRCID("new_qmake_project"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(QMakePlugin::OnNewQmakeBasedProject), + NULL, + (wxEvtHandler*)this); + wxTheApp->Connect(XRCID("qmake_settings"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(QMakePlugin::OnSettings), + NULL, + (wxEvtHandler*)this); + wxTheApp->Connect(XRCID("qmake_run_qmake"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(QMakePlugin::OnExportMakefile), + NULL, + this); } void QMakePlugin::HookPopupMenu(wxMenu* menu, MenuType type) { - if(type == MenuTypeFileView_Project) { - if(!menu->FindItem(XRCID("qmake_run_qmake"))) { + if (type == MenuTypeFileView_Project) { + if (!menu->FindItem(XRCID("qmake_run_qmake"))) { menu->PrependSeparator(); menu->Prepend(XRCID("qmake_run_qmake"), _("Run qmake..."), _("Run qmake...")); } @@ -136,35 +144,44 @@ void QMakePlugin::HookPopupMenu(wxMenu* menu, MenuType type) void QMakePlugin::UnPlug() { - EventNotifier::Get()->Disconnect(wxEVT_CMD_PROJ_SETTINGS_SAVED, - clProjectSettingsEventHandler(QMakePlugin::OnSaveConfig), NULL, this); - EventNotifier::Get()->Disconnect(wxEVT_BUILD_STARTING, clBuildEventHandler(QMakePlugin::OnBuildStarting), NULL, - this); - EventNotifier::Get()->Disconnect(wxEVT_GET_PROJECT_BUILD_CMD, clBuildEventHandler(QMakePlugin::OnGetBuildCommand), - NULL, this); - EventNotifier::Get()->Disconnect(wxEVT_GET_PROJECT_CLEAN_CMD, clBuildEventHandler(QMakePlugin::OnGetCleanCommand), - NULL, this); - EventNotifier::Get()->Disconnect(wxEVT_GET_IS_PLUGIN_MAKEFILE, - clBuildEventHandler(QMakePlugin::OnGetIsPluginMakefile), NULL, this); - EventNotifier::Get()->Disconnect(wxEVT_TREE_ITEM_FILE_ACTIVATED, clCommandEventHandler(QMakePlugin::OnOpenFile), - NULL, this); - wxTheApp->Disconnect(XRCID("new_qmake_project"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(QMakePlugin::OnNewQmakeBasedProject), NULL, (wxEvtHandler*)this); - wxTheApp->Disconnect(XRCID("qmake_settings"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(QMakePlugin::OnSettings), NULL, (wxEvtHandler*)this); - wxTheApp->Disconnect(XRCID("qmake_run_qmake"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(QMakePlugin::OnExportMakefile), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_CMD_PROJ_SETTINGS_SAVED, clProjectSettingsEventHandler(QMakePlugin::OnSaveConfig), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_BUILD_STARTING, clBuildEventHandler(QMakePlugin::OnBuildStarting), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_GET_PROJECT_BUILD_CMD, clBuildEventHandler(QMakePlugin::OnGetBuildCommand), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_GET_PROJECT_CLEAN_CMD, clBuildEventHandler(QMakePlugin::OnGetCleanCommand), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_GET_IS_PLUGIN_MAKEFILE, clBuildEventHandler(QMakePlugin::OnGetIsPluginMakefile), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_TREE_ITEM_FILE_ACTIVATED, clCommandEventHandler(QMakePlugin::OnOpenFile), NULL, this); + wxTheApp->Disconnect(XRCID("new_qmake_project"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(QMakePlugin::OnNewQmakeBasedProject), + NULL, + (wxEvtHandler*)this); + wxTheApp->Disconnect(XRCID("qmake_settings"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(QMakePlugin::OnSettings), + NULL, + (wxEvtHandler*)this); + wxTheApp->Disconnect(XRCID("qmake_run_qmake"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(QMakePlugin::OnExportMakefile), + NULL, + this); } void QMakePlugin::HookProjectSettingsTab(wxBookCtrlBase* book, const wxString& projectName, const wxString& configName) { - if(!book) + if (!book) return; DoUnHookAllTabs(book); QMakeTab* page = DoGetQmakeTab(configName); - if(!page) { + if (!page) { page = new QMakeTab(book, m_conf); page->Load(m_mgr, projectName, configName); m_pages[configName] = page; @@ -172,7 +189,8 @@ void QMakePlugin::HookProjectSettingsTab(wxBookCtrlBase* book, const wxString& p book->AddPage(page, wxT("QMake"), true, wxNOT_FOUND); } -void QMakePlugin::UnHookProjectSettingsTab(wxBookCtrlBase* book, const wxString& projectName, +void QMakePlugin::UnHookProjectSettingsTab(wxBookCtrlBase* book, + const wxString& projectName, const wxString& configName) { wxUnusedVar(configName); @@ -188,7 +206,7 @@ void QMakePlugin::OnSaveConfig(clProjectSettingsEvent& event) conf = event.GetConfigName(); QMakeTab* tab = DoGetQmakeTab(conf); - if(!tab) { + if (!tab) { return; } tab->Save(m_mgr, project, conf); @@ -197,7 +215,7 @@ void QMakePlugin::OnSaveConfig(clProjectSettingsEvent& event) QMakeTab* QMakePlugin::DoGetQmakeTab(const wxString& config) { std::map::iterator iter = m_pages.find(config); - if(iter == m_pages.end()) { + if (iter == m_pages.end()) { return NULL; } return iter->second; @@ -205,14 +223,14 @@ QMakeTab* QMakePlugin::DoGetQmakeTab(const wxString& config) void QMakePlugin::DoUnHookAllTabs(wxBookCtrlBase* book) { - if(!book) { + if (!book) { return; } - for(size_t i = 0; i < book->GetPageCount(); i++) { + for (size_t i = 0; i < book->GetPageCount(); i++) { std::map::iterator iter = m_pages.begin(); - for(; iter != m_pages.end(); iter++) { - if(book->GetPage(i) == iter->second) { + for (; iter != m_pages.end(); iter++) { + if (book->GetPage(i) == iter->second) { book->RemovePage(i); iter->second->Destroy(); m_pages.erase(iter); @@ -238,11 +256,11 @@ void QMakePlugin::OnBuildStarting(clBuildEvent& event) wxString project = event.GetProjectName(); wxString config = event.GetConfigurationName(); - if(!DoGetData(project, config, bcpd)) { + if (!DoGetData(project, config, bcpd)) { return; } - if(!bcpd.m_enabled) { + if (!bcpd.m_enabled) { return; } @@ -251,14 +269,15 @@ void QMakePlugin::OnBuildStarting(clBuildEvent& event) wxString errMsg; ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project, errMsg); - if(!p) { + if (!p) { return; } QMakeProFileGenerator generator(m_mgr, project, config); - if(!wxFileName::Exists(generator.GetProFileName())) { + if (!wxFileName::Exists(generator.GetProFileName())) { // alert and return ::wxMessageBox(_("Could not locate pro file.\nDid you remember to run qmake? (right click on the project)"), - "QMake", wxICON_WARNING | wxCENTER); + "QMake", + wxICON_WARNING | wxCENTER); return; } else { event.Skip(); @@ -269,7 +288,7 @@ bool QMakePlugin::DoGetData(const wxString& project, const wxString& conf, Qmake { wxString errMsg; ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project, errMsg); - if(p) { + if (p) { wxString rawData = p->GetPluginData(wxT("qmake")); QmakePluginData pd(rawData); return pd.GetDataForBuildConf(conf, bcpd); @@ -284,12 +303,12 @@ void QMakePlugin::OnGetCleanCommand(clBuildEvent& event) wxString project = event.GetProjectName(); wxString config = event.GetConfigurationName(); - if(!DoGetData(project, config, bcpd)) { + if (!DoGetData(project, config, bcpd)) { event.Skip(); return; } - if(!bcpd.m_enabled) { + if (!bcpd.m_enabled) { event.Skip(); return; } @@ -304,12 +323,12 @@ void QMakePlugin::OnGetBuildCommand(clBuildEvent& event) wxString project = event.GetProjectName(); wxString config = event.GetConfigurationName(); - if(!DoGetData(project, config, bcpd)) { + if (!DoGetData(project, config, bcpd)) { event.Skip(); return; } - if(!bcpd.m_enabled) { + if (!bcpd.m_enabled) { event.Skip(); return; } @@ -325,12 +344,12 @@ void QMakePlugin::OnGetIsPluginMakefile(clBuildEvent& event) wxString project = event.GetProjectName(); wxString config = event.GetConfigurationName(); - if(!DoGetData(project, config, bcpd)) { + if (!DoGetData(project, config, bcpd)) { event.Skip(); return; } - if(bcpd.m_enabled) { + if (bcpd.m_enabled) { // return without calling event.Skip() return; } @@ -343,7 +362,7 @@ wxString QMakePlugin::DoGetBuildCommand(const wxString& project, const wxString& wxString errMsg; ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project, errMsg); - if(!p) { + if (!p) { return wxEmptyString; } @@ -356,14 +375,14 @@ wxString QMakePlugin::DoGetBuildCommand(const wxString& project, const wxString& StringUtils::WrapWithQuotes(projectMakefile); projectMakefile.Replace("\\", "/"); - if(!projectOnly) { + if (!projectOnly) { // part of a greater makefile, use $(MAKE) cmd << wxT("@cd \"") << p->GetFileName().GetPath() << wxT("\" && "); cmd << "$(MAKE) -f " << projectMakefile; } else { // project only cmd = bldConf->GetCompiler()->GetTool("MAKE"); - if(!cmd.Contains("-f")) { + if (!cmd.Contains("-f")) { cmd << " -f "; } cmd << " " << projectMakefile; @@ -374,14 +393,16 @@ wxString QMakePlugin::DoGetBuildCommand(const wxString& project, const wxString& void QMakePlugin::OnNewQmakeBasedProject(wxCommandEvent& event) { wxUnusedVar(event); - if(m_conf->GetAllConfigurations().IsEmpty()) { + if (m_conf->GetAllConfigurations().IsEmpty()) { wxMessageBox(_("There is no qmake defined, please define one from 'Plugins -> Qmake -> Settings'"), - wxT("CodeLite"), wxOK | wxICON_WARNING | wxCENTER, m_mgr->GetTheApp()->GetTopWindow()); + wxT("CodeLite"), + wxOK | wxICON_WARNING | wxCENTER, + m_mgr->GetTheApp()->GetTopWindow()); return; } NewQtProjDlg dlg(m_mgr->GetTheApp()->GetTopWindow(), m_conf, m_mgr); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxString kind = dlg.GetProjectKind(); wxString name = dlg.GetProjectName(); wxString path = dlg.GetProjectPath(); @@ -393,15 +414,15 @@ void QMakePlugin::OnNewQmakeBasedProject(wxCommandEvent& event) wxString qmake; wxString content; - if(kind == wxT("Static Library")) { + if (kind == wxT("Static Library")) { type = PROJECT_TYPE_STATIC_LIBRARY; - } else if(kind == wxT("Dynamic Library")) { + } else if (kind == wxT("Dynamic Library")) { type = PROJECT_TYPE_DYNAMIC_LIBRARY; - } else if(kind == wxT("Console")) { + } else if (kind == wxT("Console")) { type = PROJECT_TYPE_EXECUTABLE; configRelease = wxT("0017CONFIG += console"); @@ -415,7 +436,7 @@ void QMakePlugin::OnNewQmakeBasedProject(wxCommandEvent& event) } wxString filename(m_mgr->GetStartupDirectory() + wxT("/templates/qmake/qmake.project")); - if(!ReadFileWithConversion(filename, content)) { + if (!ReadFileWithConversion(filename, content)) { return; } @@ -431,20 +452,21 @@ void QMakePlugin::OnNewQmakeBasedProject(wxCommandEvent& event) // save the file to the disk { DirSaver ds; - if(!wxSetWorkingDirectory(path)) { + if (!wxSetWorkingDirectory(path)) { wxMessageBox(_("Invalid project path!"), wxT("CodeLite"), wxOK | wxCENTER | wxICON_WARNING); return; } - if(dlg.GetCreateDirectory()) { + if (dlg.GetCreateDirectory()) { wxMkdir(name); wxSetWorkingDirectory(name); } - if(!WriteFileWithBackup(name + wxT(".project"), content, false)) { - wxMessageBox(wxString::Format(_("Failed to create .project file '%s'"), - wxString(name + wxT(".project")).c_str()), - wxT("CodeLite"), wxOK | wxCENTER | wxICON_WARNING); + if (!WriteFileWithBackup(name + wxT(".project"), content, false)) { + wxMessageBox(wxString::Format( + _("Failed to create .project file '%s'"), wxString(name + wxT(".project")).c_str()), + wxT("CodeLite"), + wxOK | wxCENTER | wxICON_WARNING); return; } @@ -462,17 +484,17 @@ void QMakePlugin::OnOpenFile(clCommandEvent& event) // launch it with the default application wxFileName fullpath(event.GetFileName()); - if(fullpath.GetExt().MakeLower() != wxT("ui")) { + if (fullpath.GetExt().MakeLower() != wxT("ui")) { return; } wxMimeTypesManager* mgr = wxTheMimeTypesManager; wxFileType* type = mgr->GetFileTypeFromExtension(fullpath.GetExt()); - if(type) { + if (type) { wxString cmd = type->GetOpenCommand(fullpath.GetFullPath()); delete type; - if(cmd.IsEmpty() == false) { + if (cmd.IsEmpty() == false) { event.Skip(false); ::wxExecute(cmd); } @@ -481,7 +503,7 @@ void QMakePlugin::OnOpenFile(clCommandEvent& event) void QMakePlugin::OnExportMakefile(wxCommandEvent& event) { - if(m_qmakeProcess) + if (m_qmakeProcess) return; QmakePluginData::BuildConfPluginData bcpd; @@ -495,12 +517,12 @@ void QMakePlugin::OnExportMakefile(wxCommandEvent& event) wxString project = pProj->GetName(); wxString config = bldConf->GetName(); - if(!DoGetData(project, config, bcpd)) { + if (!DoGetData(project, config, bcpd)) { event.Skip(); return; } - if(bcpd.m_enabled) { + if (bcpd.m_enabled) { // This project/configuration is qmake project QMakeProFileGenerator generator(m_mgr, project, config); @@ -522,23 +544,23 @@ void QMakePlugin::OnExportMakefile(wxCommandEvent& event) { wxString errMsg; ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project, errMsg); - if(!p) { + if (!p) { return; } StringUtils::WrapWithQuotes(qmake_exe); qmake_exe_line << qmake_exe << wxT(" -spec ") << qmakespec << wxT(" ") << generator.GetProFileName(); wxStringMap_t om; - om.insert({ "QTDIR", qtdir }); + om.insert({"QTDIR", qtdir}); // Add the bin folder of the compiler (so qmakw will be able to find g++ or whatever compiler) wxString cxx = bldConf->GetCompiler()->GetTool("CXX"); wxFileName fnCxx(cxx); wxString curpath; wxString updatedPath = fnCxx.GetPath(); - if(::wxGetEnv("PATH", &curpath)) { + if (::wxGetEnv("PATH", &curpath)) { updatedPath << clPATH_SEPARATOR << curpath; } - om.insert({ "PATH", updatedPath }); + om.insert({"PATH", updatedPath}); EnvSetter envGuard(NULL, &om, project, config); m_mgr->ClearOutputTab(kOutputTab_Build); diff --git a/QmakePlugin/qmakeplugin.h b/QmakePlugin/qmakeplugin.h index 9f5346e49c..682456d4e8 100644 --- a/QmakePlugin/qmakeplugin.h +++ b/QmakePlugin/qmakeplugin.h @@ -56,7 +56,8 @@ class QMakePlugin : public IPlugin void CreatePluginMenu(wxMenu* pluginsMenu) override; void HookPopupMenu(wxMenu* menu, MenuType type) override; void HookProjectSettingsTab(wxBookCtrlBase* book, const wxString& projectName, const wxString& configName) override; - void UnHookProjectSettingsTab(wxBookCtrlBase* book, const wxString& projectName, const wxString& configName) override; + void + UnHookProjectSettingsTab(wxBookCtrlBase* book, const wxString& projectName, const wxString& configName) override; void UnPlug() override; // event handlers diff --git a/QmakePlugin/qmakeplugindata.cpp b/QmakePlugin/qmakeplugindata.cpp index c43310c192..4b47bb220a 100644 --- a/QmakePlugin/qmakeplugindata.cpp +++ b/QmakePlugin/qmakeplugindata.cpp @@ -1,102 +1,104 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2014 Eran Ifrah -// file name : qmakeplugindata.cpp -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2014 Eran Ifrah +// file name : qmakeplugindata.cpp +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #include "qmakeplugindata.h" -#include + #include +#include -static wxString readString(wxString &str) { +static wxString readString(wxString& str) +{ - wxString sLen = str.Mid(0, 4); - str = str.Mid(4); + wxString sLen = str.Mid(0, 4); + str = str.Mid(4); - long nLen( 0 ); - sLen.ToLong( &nLen ); + long nLen(0); + sLen.ToLong(&nLen); - wxString s = str.Mid(0, nLen); - str = str.Mid( nLen ); + wxString s = str.Mid(0, nLen); + str = str.Mid(nLen); - return s; + return s; } -static void writeString(wxString &str, const wxString &srcToWrite) { - if(srcToWrite.IsEmpty()) { - str << wxT("0000"); - } else { - str << wxString::Format(wxT("%04u"), (unsigned int)srcToWrite.Len()) << srcToWrite; - } +static void writeString(wxString& str, const wxString& srcToWrite) +{ + if (srcToWrite.IsEmpty()) { + str << wxT("0000"); + } else { + str << wxString::Format(wxT("%04u"), (unsigned int)srcToWrite.Len()) << srcToWrite; + } } -QmakePluginData::QmakePluginData(const wxString &data) +QmakePluginData::QmakePluginData(const wxString& data) { - wxString num = data.Mid(0, 4); - wxString rest = data.Mid(4); + wxString num = data.Mid(0, 4); + wxString rest = data.Mid(4); - long nCount( 0 ); - num.ToLong( &nCount ); + long nCount(0); + num.ToLong(&nCount); - for(long i=0; i::iterator iter = m_pluginsData.find(configName); - if(iter == m_pluginsData.end()) { - return false; - } + std::map::iterator iter = m_pluginsData.find(configName); + if (iter == m_pluginsData.end()) { + return false; + } - bcpd = iter->second; - return true; + bcpd = iter->second; + return true; } void QmakePluginData::SetDataForBuildConf(const wxString& configName, const BuildConfPluginData& cd) { - m_pluginsData[configName] = cd; + m_pluginsData[configName] = cd; } - diff --git a/QmakePlugin/qmakeplugindata.h b/QmakePlugin/qmakeplugindata.h index ea551676b2..7c47678ec5 100644 --- a/QmakePlugin/qmakeplugindata.h +++ b/QmakePlugin/qmakeplugindata.h @@ -26,35 +26,38 @@ #ifndef __qmakeplugindata__ #define __qmakeplugindata__ -#include #include +#include class QmakePluginData { public: - class BuildConfPluginData - { - public: - bool m_enabled; - wxString m_buildConfName; - wxString m_qmakeConfig; - wxString m_qmakeExecutionLine; - wxString m_freeText; - - public: - BuildConfPluginData() : m_enabled (false), m_qmakeExecutionLine(wxT("$(QMAKE)")) {} - - }; + class BuildConfPluginData + { + public: + bool m_enabled; + wxString m_buildConfName; + wxString m_qmakeConfig; + wxString m_qmakeExecutionLine; + wxString m_freeText; + + public: + BuildConfPluginData() + : m_enabled(false) + , m_qmakeExecutionLine(wxT("$(QMAKE)")) + { + } + }; private: - std::map m_pluginsData; + std::map m_pluginsData; public: - QmakePluginData(const wxString &data); - ~QmakePluginData() = default; + QmakePluginData(const wxString& data); + ~QmakePluginData() = default; - wxString ToString(); - bool GetDataForBuildConf(const wxString &configName, BuildConfPluginData &bcpd ); - void SetDataForBuildConf(const wxString &configName, const BuildConfPluginData &cd); + wxString ToString(); + bool GetDataForBuildConf(const wxString& configName, BuildConfPluginData& bcpd); + void SetDataForBuildConf(const wxString& configName, const BuildConfPluginData& cd); }; #endif // __qmakeplugindata__ diff --git a/QmakePlugin/qmakesettingstab.cpp b/QmakePlugin/qmakesettingstab.cpp index 7d75b7847f..bdeb545c54 100644 --- a/QmakePlugin/qmakesettingstab.cpp +++ b/QmakePlugin/qmakesettingstab.cpp @@ -24,13 +24,15 @@ ////////////////////////////////////////////////////////////////////////////// #include "qmakesettingstab.h" -#include + #include "procutils.h" -#include #include "qmakeconf.h" -QmakeSettingsTab::QmakeSettingsTab( wxWindow* parent, const wxString &name, QmakeConf* conf) - : QmakeSettingsTabBase( parent ) +#include +#include + +QmakeSettingsTab::QmakeSettingsTab(wxWindow* parent, const wxString& name, QmakeConf* conf) + : QmakeSettingsTabBase(parent) , m_name(name) { Load(conf); @@ -38,11 +40,11 @@ QmakeSettingsTab::QmakeSettingsTab( wxWindow* parent, const wxString &name, Qmak void QmakeSettingsTab::Load(QmakeConf* conf) { - if ( conf ) { + if (conf) { wxString qmakePath(conf->Read(m_name + wxT("/qmake"))); - m_filePickerQmakeExec->SetFileName( wxFileName(qmakePath) ); - - m_comboBoxQmakespec->Append( GetSpecList(conf->Read(m_name + wxT("/qmake")) ) ); + m_filePickerQmakeExec->SetFileName(wxFileName(qmakePath)); + + m_comboBoxQmakespec->Append(GetSpecList(conf->Read(m_name + wxT("/qmake")))); m_comboBoxQmakespec->SetValue(conf->Read(m_name + wxT("/qmakespec"))); m_textCtrlQtdir->SetValue(conf->Read(m_name + wxT("/qtdir"))); } @@ -50,9 +52,9 @@ void QmakeSettingsTab::Load(QmakeConf* conf) void QmakeSettingsTab::Save(QmakeConf* conf) { - conf->Write(m_name + wxT("/qmake"), m_filePickerQmakeExec->GetPath()); + conf->Write(m_name + wxT("/qmake"), m_filePickerQmakeExec->GetPath()); conf->Write(m_name + wxT("/qmakespec"), m_comboBoxQmakespec->GetValue()); - conf->Write(m_name + wxT("/qtdir"), m_textCtrlQtdir->GetValue()); + conf->Write(m_name + wxT("/qtdir"), m_textCtrlQtdir->GetValue()); conf->Flush(); } @@ -60,22 +62,23 @@ wxArrayString QmakeSettingsTab::GetSpecList(const wxString& qmakePath) { wxArrayString specs; - if ( qmakePath.IsEmpty() == false && wxFileName::FileExists(qmakePath) ) { + if (qmakePath.IsEmpty() == false && wxFileName::FileExists(qmakePath)) { wxArrayString cmdOutput; - ProcUtils::SafeExecuteCommand(wxString::Format(wxT("\"%s\" -query QT_INSTALL_DATA"), qmakePath.c_str()), cmdOutput); - if ( cmdOutput.IsEmpty() == false ) { - wxFileName installData ( cmdOutput.Item(0).Trim().Trim(false), wxEmptyString ); + ProcUtils::SafeExecuteCommand( + wxString::Format(wxT("\"%s\" -query QT_INSTALL_DATA"), qmakePath.c_str()), cmdOutput); + if (cmdOutput.IsEmpty() == false) { + wxFileName installData(cmdOutput.Item(0).Trim().Trim(false), wxEmptyString); wxArrayString files; installData.AppendDir(wxT("mkspecs")); wxDir::GetAllFiles(installData.GetFullPath(), &files, wxT("*.conf"), wxDIR_DEFAULT); - for ( size_t i=0; iClear(); - m_comboBoxQmakespec->Append( GetSpecList(m_filePickerQmakeExec->GetPath()) ); + m_comboBoxQmakespec->Append(GetSpecList(m_filePickerQmakeExec->GetPath())); } diff --git a/QmakePlugin/qmakesettingstab.h b/QmakePlugin/qmakesettingstab.h index 99626b2067..671dd21c67 100644 --- a/QmakePlugin/qmakesettingstab.h +++ b/QmakePlugin/qmakesettingstab.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2014 Eran Ifrah -// file name : qmakesettingstab.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2014 Eran Ifrah +// file name : qmakesettingstab.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #ifndef __qmakesettingstab__ #define __qmakesettingstab__ @@ -37,23 +37,19 @@ class QmakeConf; /** Implementing QmakeSettingsTabBase */ class QmakeSettingsTab : public QmakeSettingsTabBase { - wxString m_name; - wxArrayString GetSpecList(const wxString &qmakePath); + wxString m_name; + wxArrayString GetSpecList(const wxString& qmakePath); public: /** Constructor */ - QmakeSettingsTab(wxWindow* parent, const wxString &name, QmakeConf* conf); - - void Load(QmakeConf *conf); - void Save(QmakeConf *conf); - void OnFileSelected(wxFileDirPickerEvent &event); - - void SetTabName(const wxString& name) { - this->m_name = name; - } - const wxString& GetTabName() const { - return m_name; - } + QmakeSettingsTab(wxWindow* parent, const wxString& name, QmakeConf* conf); + + void Load(QmakeConf* conf); + void Save(QmakeConf* conf); + void OnFileSelected(wxFileDirPickerEvent& event); + + void SetTabName(const wxString& name) { this->m_name = name; } + const wxString& GetTabName() const { return m_name; } }; #endif // __qmakesettingstab__ diff --git a/QmakePlugin/qmaketab.cpp b/QmakePlugin/qmaketab.cpp index 1cad93799e..ebfbee6929 100644 --- a/QmakePlugin/qmaketab.cpp +++ b/QmakePlugin/qmaketab.cpp @@ -1,87 +1,86 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2014 Eran Ifrah -// file name : qmaketab.cpp -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2014 Eran Ifrah +// file name : qmaketab.cpp +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #include "qmaketab.h" + #include "imanager.h" -#include #include "project.h" -#include "workspace.h" #include "qmakeplugindata.h" +#include "workspace.h" -QMakeTab::QMakeTab( wxWindow* parent, QmakeConf *conf ) - : QMakeTabBase( parent ) - , m_conf(conf) +#include + +QMakeTab::QMakeTab(wxWindow* parent, QmakeConf* conf) + : QMakeTabBase(parent) + , m_conf(conf) { - m_choiceQmakeSettings->Clear(); - m_choiceQmakeSettings->Append( m_conf->GetAllConfigurations() ); + m_choiceQmakeSettings->Clear(); + m_choiceQmakeSettings->Append(m_conf->GetAllConfigurations()); } -void QMakeTab::Save(IManager *manager, const wxString& projectName, const wxString& confgName) +void QMakeTab::Save(IManager* manager, const wxString& projectName, const wxString& confgName) { - wxString errMsg; - ProjectPtr p = manager->GetWorkspace()->FindProjectByName(projectName, errMsg); - if ( p ) { - wxString data = p->GetPluginData(wxT("qmake")); - QmakePluginData pd( data ); - QmakePluginData::BuildConfPluginData bcpd; + wxString errMsg; + ProjectPtr p = manager->GetWorkspace()->FindProjectByName(projectName, errMsg); + if (p) { + wxString data = p->GetPluginData(wxT("qmake")); + QmakePluginData pd(data); + QmakePluginData::BuildConfPluginData bcpd; - bcpd.m_buildConfName = confgName; - bcpd.m_enabled = m_checkBoxUseQmake->IsChecked(); - bcpd.m_freeText = m_textCtrlFreeText->GetValue(); - bcpd.m_qmakeConfig = m_choiceQmakeSettings->GetStringSelection(); - bcpd.m_qmakeExecutionLine = m_textCtrlQmakeExeLine->GetValue(); + bcpd.m_buildConfName = confgName; + bcpd.m_enabled = m_checkBoxUseQmake->IsChecked(); + bcpd.m_freeText = m_textCtrlFreeText->GetValue(); + bcpd.m_qmakeConfig = m_choiceQmakeSettings->GetStringSelection(); + bcpd.m_qmakeExecutionLine = m_textCtrlQmakeExeLine->GetValue(); - pd.SetDataForBuildConf(confgName, bcpd); + pd.SetDataForBuildConf(confgName, bcpd); - p->SetPluginData(wxT("qmake"), pd.ToString()); - } + p->SetPluginData(wxT("qmake"), pd.ToString()); + } } void QMakeTab::Load(IManager* manager, const wxString& projectName, const wxString& confgName) { - wxString errMsg; - ProjectPtr p = manager->GetWorkspace()->FindProjectByName(projectName, errMsg); - if ( p ) { - wxString data = p->GetPluginData(wxT("qmake")); - QmakePluginData pd( data ); - QmakePluginData::BuildConfPluginData bcpd; + wxString errMsg; + ProjectPtr p = manager->GetWorkspace()->FindProjectByName(projectName, errMsg); + if (p) { + wxString data = p->GetPluginData(wxT("qmake")); + QmakePluginData pd(data); + QmakePluginData::BuildConfPluginData bcpd; - if (pd.GetDataForBuildConf(confgName, bcpd)) { + if (pd.GetDataForBuildConf(confgName, bcpd)) { - m_textCtrlQmakeExeLine->SetValue( bcpd.m_qmakeExecutionLine ); - int where = m_choiceQmakeSettings->FindString( bcpd.m_qmakeConfig ); - if ( where != wxNOT_FOUND ) { - m_choiceQmakeSettings->SetSelection(where); - } - m_textCtrlFreeText->SetValue( bcpd.m_freeText ); - m_checkBoxUseQmake->SetValue( bcpd.m_enabled ); - } - } + m_textCtrlQmakeExeLine->SetValue(bcpd.m_qmakeExecutionLine); + int where = m_choiceQmakeSettings->FindString(bcpd.m_qmakeConfig); + if (where != wxNOT_FOUND) { + m_choiceQmakeSettings->SetSelection(where); + } + m_textCtrlFreeText->SetValue(bcpd.m_freeText); + m_checkBoxUseQmake->SetValue(bcpd.m_enabled); + } + } } -void QMakeTab::OnUseQmake(wxUpdateUIEvent& e) -{ - e.Enable( m_checkBoxUseQmake->IsChecked() ); -} +void QMakeTab::OnUseQmake(wxUpdateUIEvent& e) { e.Enable(m_checkBoxUseQmake->IsChecked()); } diff --git a/QmakePlugin/qmaketab.h b/QmakePlugin/qmaketab.h index 96eebf8683..d7dd79bd80 100644 --- a/QmakePlugin/qmaketab.h +++ b/QmakePlugin/qmaketab.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2014 Eran Ifrah -// file name : qmaketab.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2014 Eran Ifrah +// file name : qmaketab.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #ifndef __qmaketab__ #define __qmaketab__ @@ -31,21 +31,22 @@ Subclass of QMakeTabBase, which is generated by wxFormBuilder. */ -#include "qmaketabbase.h" #include "qmakeconf.h" +#include "qmaketabbase.h" class IManager; /** Implementing QMakeTabBase */ class QMakeTab : public QMakeTabBase { - QmakeConf *m_conf; + QmakeConf* m_conf; + + void OnUseQmake(wxUpdateUIEvent& e); - void OnUseQmake(wxUpdateUIEvent &e); public: - /** Constructor */ - QMakeTab( wxWindow* parent, QmakeConf *conf ); - void Load(IManager* manager, const wxString &projectName, const wxString &confgName); - void Save(IManager *manager, const wxString& projectName, const wxString& confgName); + /** Constructor */ + QMakeTab(wxWindow* parent, QmakeConf* conf); + void Load(IManager* manager, const wxString& projectName, const wxString& confgName); + void Save(IManager* manager, const wxString& projectName, const wxString& confgName); }; #endif // __qmaketab__ diff --git a/Remoty/RemotyConfig.cpp b/Remoty/RemotyConfig.cpp index 9540b9fa7e..0144d2054f 100644 --- a/Remoty/RemotyConfig.cpp +++ b/Remoty/RemotyConfig.cpp @@ -16,10 +16,10 @@ std::vector RemotyConfig::GetRecentWorkspaces() const std::vector res; clConfig::Get().Read(REMOTY_RECENT_WORKSPACES, [&res](const JSONItem& item) { size_t count = item.arraySize(); - if(count) { + if (count) { res.reserve(count); } - for(size_t i = 0; i < count; ++i) { + for (size_t i = 0; i < count; ++i) { JSONItem n = item.arrayItem(i); RemoteWorkspaceInfo d; d.account = n["account"].toString(); @@ -32,7 +32,7 @@ std::vector RemotyConfig::GetRecentWorkspaces() const void RemotyConfig::UpdateRecentWorkspaces(const RemoteWorkspaceInfo& workspaceInfo) { - if(workspaceInfo.path.empty() || workspaceInfo.account.empty()) { + if (workspaceInfo.path.empty() || workspaceInfo.account.empty()) { return; } @@ -40,12 +40,12 @@ void RemotyConfig::UpdateRecentWorkspaces(const RemoteWorkspaceInfo& workspaceIn auto where = find_if(curitems.begin(), curitems.end(), [&workspaceInfo](const RemoteWorkspaceInfo& d) { return d.path == workspaceInfo.path && d.account == workspaceInfo.account; }); - if(where != curitems.end()) { + if (where != curitems.end()) { curitems.erase(where); } curitems.insert(curitems.begin(), std::move(workspaceInfo)); - if(curitems.size() > MAX_ITEMS) { + if (curitems.size() > MAX_ITEMS) { // shrink the list curitems.resize(MAX_ITEMS); } @@ -53,7 +53,7 @@ void RemotyConfig::UpdateRecentWorkspaces(const RemoteWorkspaceInfo& workspaceIn // serialise the items clConfig::Get().Write(REMOTY_RECENT_WORKSPACES, [&curitems]() -> JSONItem { JSONItem arr = JSONItem::createArray(); - for(const auto& wi : curitems) { + for (const auto& wi : curitems) { auto d = arr.AddObject(wxEmptyString); d.addProperty("account", wi.account); d.addProperty("path", wi.path); diff --git a/Remoty/RemotyNewWorkspaceDlg.cpp b/Remoty/RemotyNewWorkspaceDlg.cpp index 5095074601..9f51f44af8 100644 --- a/Remoty/RemotyNewWorkspaceDlg.cpp +++ b/Remoty/RemotyNewWorkspaceDlg.cpp @@ -16,7 +16,7 @@ RemotyNewWorkspaceDlg::~RemotyNewWorkspaceDlg() {} void RemotyNewWorkspaceDlg::OnBrowse(wxCommandEvent& event) { auto result = ::clRemoteFileSelector(_("Seelct a folder")); - if(result.first.empty() || result.second.empty()) { + if (result.first.empty() || result.second.empty()) { return; } m_textCtrlPath->SetEditable(true); diff --git a/Remoty/RemotyPlugin.cpp b/Remoty/RemotyPlugin.cpp index c6a6fa53a9..7c97a7892b 100644 --- a/Remoty/RemotyPlugin.cpp +++ b/Remoty/RemotyPlugin.cpp @@ -40,10 +40,7 @@ #include // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new RemotyPlugin(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new RemotyPlugin(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -94,7 +91,7 @@ void RemotyPlugin::OnFolderContextMenu(clContextMenuEvent& event) { event.Skip() void RemotyPlugin::OnNewWorkspace(clCommandEvent& e) { e.Skip(); - if(e.GetString() == WORKSPACE_TYPE_NAME) { + if (e.GetString() == WORKSPACE_TYPE_NAME) { e.Skip(false); } } @@ -103,7 +100,7 @@ void RemotyPlugin::OnRecentWorkspaces(clRecentWorkspaceEvent& event) { event.Skip(); RemotyConfig config; - for(const auto& recent_workspace : config.GetRecentWorkspaces()) { + for (const auto& recent_workspace : config.GetRecentWorkspaces()) { RecentWorkspace rw; rw.path = recent_workspace.path; rw.m_account = recent_workspace.account; @@ -115,7 +112,7 @@ void RemotyPlugin::OnRecentWorkspaces(clRecentWorkspaceEvent& event) void RemotyPlugin::OnPluginOpenWorkspace(clWorkspaceEvent& event) { event.Skip(); - if(!event.IsRemote()) { + if (!event.IsRemote()) { return; } diff --git a/Remoty/RemotySwitchToWorkspaceDlg.cpp b/Remoty/RemotySwitchToWorkspaceDlg.cpp index 3ee0841a26..8580e7e2f4 100644 --- a/Remoty/RemotySwitchToWorkspaceDlg.cpp +++ b/Remoty/RemotySwitchToWorkspaceDlg.cpp @@ -41,7 +41,7 @@ RemotySwitchToWorkspaceDlg::~RemotySwitchToWorkspaceDlg() { RemotyConfig config; if (IsRemote()) { - RemoteWorkspaceInfo wi{ m_choiceAccount->GetStringSelection(), m_comboBoxPath->GetStringSelection() }; + RemoteWorkspaceInfo wi{m_choiceAccount->GetStringSelection(), m_comboBoxPath->GetStringSelection()}; config.UpdateRecentWorkspaces(wi); } config.SetOpenWorkspaceTypeLocal(m_choiceWorkspaceType->GetStringSelection() == "Local"); @@ -63,7 +63,10 @@ void RemotySwitchToWorkspaceDlg::OnBrowse(wxCommandEvent& event) // update the path UpdateSelection(m_comboBoxPath, path); } else { - wxString path = ::wxFileSelector(_("Choose a file"), wxEmptyString, wxEmptyString, wxEmptyString, + wxString path = ::wxFileSelector(_("Choose a file"), + wxEmptyString, + wxEmptyString, + wxEmptyString, "CodeLite Workspace files (*.workspace)|*.workspace"); if (path.empty()) { return; diff --git a/Remoty/clRemoteTerminal.cpp b/Remoty/clRemoteTerminal.cpp index 47dce97f92..fc77cf25d5 100644 --- a/Remoty/clRemoteTerminal.cpp +++ b/Remoty/clRemoteTerminal.cpp @@ -19,7 +19,7 @@ clRemoteTerminal::~clRemoteTerminal() { wxDELETE(m_proc); } bool clRemoteTerminal::Start() { - if(m_proc) { + if (m_proc) { return true; } @@ -30,7 +30,7 @@ bool clRemoteTerminal::Start() return false; } - std::vector command = { "ssh", "-o", "ServerAliveInterval=10", "-o", "StrictHostKeyChecking=no" }; + std::vector command = {"ssh", "-o", "ServerAliveInterval=10", "-o", "StrictHostKeyChecking=no"}; command.push_back(m_account.GetUsername() + "@" + m_account.GetHost()); command.push_back("-t"); command.push_back("-p"); @@ -56,17 +56,17 @@ const wxString& clRemoteTerminal::ReadTty() // wrap the command in ssh wxFileName ssh_exe; EnvSetter setter; - if(!FileUtils::FindExe("ssh", ssh_exe)) { + if (!FileUtils::FindExe("ssh", ssh_exe)) { clERROR() << "Could not locate ssh executable in your PATH!" << endl; return empty_string; } - std::vector command = { "cat", m_tty_file }; - IProcess::Ptr_t proc(::CreateAsyncProcess(this, command, IProcessCreateSSH | IProcessCreateSync, wxEmptyString, - nullptr, m_account.GetAccountName())); + std::vector command = {"cat", m_tty_file}; + IProcess::Ptr_t proc(::CreateAsyncProcess( + this, command, IProcessCreateSSH | IProcessCreateSync, wxEmptyString, nullptr, m_account.GetAccountName())); wxString output; - if(!proc) { + if (!proc) { m_tty.Clear(); return m_tty; } @@ -74,9 +74,9 @@ const wxString& clRemoteTerminal::ReadTty() m_tty.clear(); auto arr = ::wxStringTokenize(output, "\n", wxTOKEN_STRTOK); - for(auto s : arr) { + for (auto s : arr) { s.Trim().Trim(false); - if(s.StartsWith("/dev")) { + if (s.StartsWith("/dev")) { m_tty = s; break; } diff --git a/Rust/CargoToml.cpp b/Rust/CargoToml.cpp index 1b5e2bcc7e..064397be46 100644 --- a/Rust/CargoToml.cpp +++ b/Rust/CargoToml.cpp @@ -1,4 +1,5 @@ #include "CargoToml.hpp" + #include CargoToml& CargoToml::Load(const wxFileName& fn) diff --git a/SFTP/SFTPBookmark.cpp b/SFTP/SFTPBookmark.cpp index 3b75a9c978..071dd2394e 100644 --- a/SFTP/SFTPBookmark.cpp +++ b/SFTP/SFTPBookmark.cpp @@ -27,9 +27,9 @@ void SFTPBookmark::FromJSON(const JSONItem& json) { - m_account.FromJSON( json.namedObject("m_account") ); - m_name = json.namedObject("m_name").toString(); - m_folder = json.namedObject("m_folder").toString(); + m_account.FromJSON(json.namedObject("m_account")); + m_name = json.namedObject("m_name").toString(); + m_folder = json.namedObject("m_folder").toString(); } JSONItem SFTPBookmark::ToJSON() const diff --git a/SFTP/SFTPGrep.cpp b/SFTP/SFTPGrep.cpp index c9ebc5caf1..8b29a0b995 100644 --- a/SFTP/SFTPGrep.cpp +++ b/SFTP/SFTPGrep.cpp @@ -1,4 +1,5 @@ #include "SFTPGrep.h" + #include "cl_config.h" SFTPGrep::SFTPGrep(wxWindow* parent) @@ -40,10 +41,10 @@ wxString GrepData::GetGrepCommand(const wxString& path) const wxString command; // use -n -H to include the file:line command << "find " << path << " -name \"" << GetSearchIn() << "\" | xargs grep -n -H "; - if(IsIgnoreCase()) { + if (IsIgnoreCase()) { command << " -i "; } - if(IsWholeWord()) { + if (IsWholeWord()) { command << " -w "; } command << " \"" << GetFindWhat() << "\""; diff --git a/SFTP/SFTPGrep.h b/SFTP/SFTPGrep.h index 788a39a256..7c109efa4a 100644 --- a/SFTP/SFTPGrep.h +++ b/SFTP/SFTPGrep.h @@ -21,7 +21,7 @@ class GrepData bool IsIgnoreCase() const { return m_ignoreCase; } const wxString& GetSearchIn() const { return m_searchIn; } bool IsWholeWord() const { return m_wholeWord; } - + wxString GetGrepCommand(const wxString& path) const; }; diff --git a/SFTP/SFTPManageBookmarkDlg.cpp b/SFTP/SFTPManageBookmarkDlg.cpp index dbc5164cd5..d361cbb3d8 100644 --- a/SFTP/SFTPManageBookmarkDlg.cpp +++ b/SFTP/SFTPManageBookmarkDlg.cpp @@ -24,6 +24,7 @@ ////////////////////////////////////////////////////////////////////////////// #include "SFTPManageBookmarkDlg.h" + #include "globals.h" #include "windowattrmanager.h" @@ -38,7 +39,7 @@ SFTPManageBookmarkDlg::SFTPManageBookmarkDlg(wxWindow* parent, const wxArrayStri void SFTPManageBookmarkDlg::OnDelete(wxCommandEvent& event) { int sel = m_listBoxBookmarks->GetSelection(); - if(sel == wxNOT_FOUND) + if (sel == wxNOT_FOUND) return; m_listBoxBookmarks->Delete(sel); @@ -52,7 +53,7 @@ void SFTPManageBookmarkDlg::OnDeleteUI(wxUpdateUIEvent& event) wxArrayString SFTPManageBookmarkDlg::GetBookmarks() const { wxArrayString bookmarks; - for(unsigned int i = 0; i < m_listBoxBookmarks->GetCount(); ++i) { + for (unsigned int i = 0; i < m_listBoxBookmarks->GetCount(); ++i) { bookmarks.Add(m_listBoxBookmarks->GetString(i)); } return bookmarks; diff --git a/SFTP/SFTPQuickConnectDlg.cpp b/SFTP/SFTPQuickConnectDlg.cpp index 73bc876c59..35f7d59af7 100644 --- a/SFTP/SFTPQuickConnectDlg.cpp +++ b/SFTP/SFTPQuickConnectDlg.cpp @@ -1,4 +1,5 @@ #include "SFTPQuickConnectDlg.h" + #include "cl_config.h" #include "sftp_settings.h" #include "windowattrmanager.h" @@ -26,7 +27,9 @@ SFTPQuickConnectDlg::SFTPQuickConnectDlg(wxWindow* parent) m_choiceAccount->Append(account.GetAccountName()); } int where = m_choiceAccount->FindString(selectedAccount); - if(where != wxNOT_FOUND) { m_choiceAccount->SetSelection(where); } + if (where != wxNOT_FOUND) { + m_choiceAccount->SetSelection(where); + } m_checkBoxChooseAccount->SetValue(selecteExistingAccount); m_checkBoxQuickConnect->SetValue(!selecteExistingAccount); @@ -70,7 +73,7 @@ void SFTPQuickConnectDlg::OnQuickConnectUI(wxUpdateUIEvent& event) SSHAccountInfo SFTPQuickConnectDlg::GetSelectedAccount() const { SSHAccountInfo acc; - if(m_checkBoxChooseAccount->IsChecked()) { + if (m_checkBoxChooseAccount->IsChecked()) { SFTPSettings settings; settings.Load(); settings.GetAccount(m_choiceAccount->GetStringSelection(), acc); @@ -81,7 +84,9 @@ SSHAccountInfo SFTPQuickConnectDlg::GetSelectedAccount() const acc.SetPassword(m_textCtrlPassword->GetValue()); acc.SetHost(m_textCtrlHost->GetValue()); long nPort = 22; // Default is 22 - if(!m_textCtrlPort->GetValue().ToCLong(&nPort)) { nPort = 22; } + if (!m_textCtrlPort->GetValue().ToCLong(&nPort)) { + nPort = 22; + } acc.SetPort(nPort); } return acc; diff --git a/SFTP/SFTPSettingsDialog.cpp b/SFTP/SFTPSettingsDialog.cpp index db61f33e42..2bc7216859 100644 --- a/SFTP/SFTPSettingsDialog.cpp +++ b/SFTP/SFTPSettingsDialog.cpp @@ -1,6 +1,7 @@ #include "SFTPSettingsDialog.h" -#include "windowattrmanager.h" + #include "sftp_settings.h" +#include "windowattrmanager.h" SFTPSettingsDialog::SFTPSettingsDialog(wxWindow* parent) : SFTPSettingsDialogBase(parent) diff --git a/SFTP/SFTPStatusPage.cpp b/SFTP/SFTPStatusPage.cpp index 993a2e597e..a6661f75e5 100644 --- a/SFTP/SFTPStatusPage.cpp +++ b/SFTP/SFTPStatusPage.cpp @@ -23,19 +23,21 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#include "ColoursAndFontsManager.h" #include "SFTPStatusPage.h" + +#include "ColoursAndFontsManager.h" #include "SFTPTreeView.h" #include "clSSHChannel.hpp" #include "event_notifier.h" +#include "file_logger.h" #include "lexer_configuration.h" #include "remote_file_info.h" #include "sftp.h" #include "sftp_item_comparator.hpp" #include "sftp_worker_thread.h" + #include #include -#include "file_logger.h" SFTPStatusPage::SFTPStatusPage(wxWindow* parent, SFTP* plugin) : SFTPStatusPageBase(parent) @@ -81,7 +83,7 @@ void SFTPStatusPage::AddLine(SFTPThreadMessage* message) wxString msg; msg << "[ " << wxDateTime::Now().FormatISOTime() << " ]"; wxBitmap bmp; - switch(message->GetStatus()) { + switch (message->GetStatus()) { case SFTPThreadMessage::STATUS_ERROR: msg << " [ERR]"; break; @@ -126,7 +128,7 @@ void SFTPStatusPage::OnThemeChanged(wxCommandEvent& event) { event.Skip(); LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexer("text"); - if(lexer) { + if (lexer) { lexer->Apply(m_stcOutput); lexer->Apply(m_stcSearch); } @@ -136,7 +138,7 @@ void SFTPStatusPage::OnThemeChanged(wxCommandEvent& event) void SFTPStatusPage::OnCopy(wxCommandEvent& event) { wxUnusedVar(event); - if(m_stcOutput->CanCopy()) { + if (m_stcOutput->CanCopy()) { m_stcOutput->Copy(); } } @@ -205,8 +207,8 @@ void SFTPStatusPage::AddSearchText(const wxString& text) int SFTPStatusPage::GetTabIndex(const wxString& name) const { - for(size_t i = 0; i < m_notebook->GetPageCount(); ++i) { - if(name == m_notebook->GetPageText(i)) { + for (size_t i = 0; i < m_notebook->GetPageCount(); ++i) { + if (name == m_notebook->GetPageText(i)) { return i; } } diff --git a/SFTP/SFTPStatusPage.h b/SFTP/SFTPStatusPage.h index 83347bcaf6..9ce9ae7a30 100644 --- a/SFTP/SFTPStatusPage.h +++ b/SFTP/SFTPStatusPage.h @@ -26,10 +26,11 @@ #ifndef SFTPSTATUSPAGE_H #define SFTPSTATUSPAGE_H +#include "SFTPGrepStyler.h" #include "UI.h" -#include #include "cl_command_event.h" -#include "SFTPGrepStyler.h" + +#include #include class SFTPThreadMessage; @@ -51,7 +52,7 @@ class SFTPStatusPage : public SFTPStatusPageBase void ClearSearchOutput(); void ShowSearchTab(); void AddSearchText(const wxString& text); - + protected: virtual void OnContentMenu(wxContextMenuEvent& event); virtual void OnClearLog(wxCommandEvent& event); diff --git a/SFTP/SFTPUploadDialog.cpp b/SFTP/SFTPUploadDialog.cpp index b5719341f9..0462c63331 100644 --- a/SFTP/SFTPUploadDialog.cpp +++ b/SFTP/SFTPUploadDialog.cpp @@ -5,6 +5,4 @@ SFTPUploadDialog::SFTPUploadDialog(wxWindow* parent) { } -void SFTPUploadDialog::OnOKUI(wxUpdateUIEvent& event) -{ -} +void SFTPUploadDialog::OnOKUI(wxUpdateUIEvent& event) {} diff --git a/SFTP/sftp.cpp b/SFTP/sftp.cpp index b649d392f5..53eb59350b 100644 --- a/SFTP/sftp.cpp +++ b/SFTP/sftp.cpp @@ -69,10 +69,7 @@ const wxEventType wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING = ::wxNewEventType(); // } // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new SFTP(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new SFTP(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -92,15 +89,24 @@ SFTP::SFTP(IManager* manager) m_longName = _("SFTP plugin for codelite IDE"); m_shortName = wxT("SFTP"); - wxTheApp->Connect(wxEVT_SFTP_OPEN_SSH_ACCOUNT_MANAGER, wxEVT_MENU, wxCommandEventHandler(SFTP::OnAccountManager), - NULL, this); + wxTheApp->Connect( + wxEVT_SFTP_OPEN_SSH_ACCOUNT_MANAGER, wxEVT_MENU, wxCommandEventHandler(SFTP::OnAccountManager), NULL, this); wxTheApp->Connect(wxEVT_SFTP_SETTINGS, wxEVT_MENU, wxCommandEventHandler(SFTP::OnSettings), NULL, this); - wxTheApp->Connect(wxEVT_SFTP_SETUP_WORKSPACE_MIRRORING, wxEVT_MENU, - wxCommandEventHandler(SFTP::OnSetupWorkspaceMirroring), NULL, this); - wxTheApp->Connect(wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING, wxEVT_MENU, - wxCommandEventHandler(SFTP::OnDisableWorkspaceMirroring), NULL, this); - wxTheApp->Connect(wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING, wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(SFTP::OnDisableWorkspaceMirroringUI), NULL, this); + wxTheApp->Connect(wxEVT_SFTP_SETUP_WORKSPACE_MIRRORING, + wxEVT_MENU, + wxCommandEventHandler(SFTP::OnSetupWorkspaceMirroring), + NULL, + this); + wxTheApp->Connect(wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING, + wxEVT_MENU, + wxCommandEventHandler(SFTP::OnDisableWorkspaceMirroring), + NULL, + this); + wxTheApp->Connect(wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING, + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(SFTP::OnDisableWorkspaceMirroringUI), + NULL, + this); EventNotifier::Get()->Bind(wxEVT_WORKSPACE_LOADED, &SFTP::OnWorkspaceOpened, this); EventNotifier::Get()->Bind(wxEVT_WORKSPACE_CLOSED, &SFTP::OnWorkspaceClosed, this); @@ -159,8 +165,11 @@ void SFTP::CreatePluginMenu(wxMenu* pluginsMenu) wxMenu* menu = new wxMenu(); wxMenuItem* item(NULL); - item = new wxMenuItem(menu, wxEVT_SFTP_OPEN_SSH_ACCOUNT_MANAGER, _("Open SSH Account Manager"), - _("Open SSH Account Manager"), wxITEM_NORMAL); + item = new wxMenuItem(menu, + wxEVT_SFTP_OPEN_SSH_ACCOUNT_MANAGER, + _("Open SSH Account Manager"), + _("Open SSH Account Manager"), + wxITEM_NORMAL); menu->Append(item); menu->AppendSeparator(); item = new wxMenuItem(menu, wxEVT_SFTP_SETTINGS, _("Settings..."), _("Settings..."), wxITEM_NORMAL); @@ -175,12 +184,12 @@ void SFTP::HookPopupMenu(wxMenu* menu, MenuType type) wxMenuItem* item(NULL); wxMenu* sftpMenu = new wxMenu(); - item = new wxMenuItem(sftpMenu, wxEVT_SFTP_SETUP_WORKSPACE_MIRRORING, _("&Setup..."), wxEmptyString, - wxITEM_NORMAL); + item = new wxMenuItem( + sftpMenu, wxEVT_SFTP_SETUP_WORKSPACE_MIRRORING, _("&Setup..."), wxEmptyString, wxITEM_NORMAL); sftpMenu->Append(item); - item = new wxMenuItem(sftpMenu, wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING, _("&Disable"), wxEmptyString, - wxITEM_NORMAL); + item = new wxMenuItem( + sftpMenu, wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING, _("&Disable"), wxEmptyString, wxITEM_NORMAL); sftpMenu->Append(item); item = new wxMenuItem(menu, wxID_SEPARATOR); @@ -209,15 +218,24 @@ void SFTP::UnPlug() m_logView = nullptr; SFTPWorkerThread::Release(); - wxTheApp->Disconnect(wxEVT_SFTP_OPEN_SSH_ACCOUNT_MANAGER, wxEVT_MENU, wxCommandEventHandler(SFTP::OnAccountManager), - NULL, this); + wxTheApp->Disconnect( + wxEVT_SFTP_OPEN_SSH_ACCOUNT_MANAGER, wxEVT_MENU, wxCommandEventHandler(SFTP::OnAccountManager), NULL, this); wxTheApp->Disconnect(wxEVT_SFTP_SETTINGS, wxEVT_MENU, wxCommandEventHandler(SFTP::OnSettings), NULL, this); - wxTheApp->Disconnect(wxEVT_SFTP_SETUP_WORKSPACE_MIRRORING, wxEVT_MENU, - wxCommandEventHandler(SFTP::OnSetupWorkspaceMirroring), NULL, this); - wxTheApp->Disconnect(wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING, wxEVT_MENU, - wxCommandEventHandler(SFTP::OnDisableWorkspaceMirroring), NULL, this); - wxTheApp->Disconnect(wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING, wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(SFTP::OnDisableWorkspaceMirroringUI), NULL, this); + wxTheApp->Disconnect(wxEVT_SFTP_SETUP_WORKSPACE_MIRRORING, + wxEVT_MENU, + wxCommandEventHandler(SFTP::OnSetupWorkspaceMirroring), + NULL, + this); + wxTheApp->Disconnect(wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING, + wxEVT_MENU, + wxCommandEventHandler(SFTP::OnDisableWorkspaceMirroring), + NULL, + this); + wxTheApp->Disconnect(wxEVT_SFTP_DISABLE_WORKSPACE_MIRRORING, + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(SFTP::OnDisableWorkspaceMirroringUI), + NULL, + this); EventNotifier::Get()->Unbind(wxEVT_WORKSPACE_LOADED, &SFTP::OnWorkspaceOpened, this); EventNotifier::Get()->Unbind(wxEVT_WORKSPACE_CLOSED, &SFTP::OnWorkspaceClosed, this); diff --git a/SFTP/sftp_worker_thread.cpp b/SFTP/sftp_worker_thread.cpp index ab35182a68..2209bf815e 100644 --- a/SFTP/sftp_worker_thread.cpp +++ b/SFTP/sftp_worker_thread.cpp @@ -172,8 +172,10 @@ void SFTPWorkerThread::ProcessRequest(ThreadRequest* request) void SFTPWorkerThread::DoConnect(SFTPThreadRequest* req) { wxString accountName = req->GetAccount().GetAccountName(); - clSSH::Ptr_t ssh(new clSSH(req->GetAccount().GetHost(), req->GetAccount().GetUsername(), - req->GetAccount().GetPassword(), req->GetAccount().GetKeyFile(), + clSSH::Ptr_t ssh(new clSSH(req->GetAccount().GetHost(), + req->GetAccount().GetUsername(), + req->GetAccount().GetPassword(), + req->GetAccount().GetKeyFile(), req->GetAccount().GetPort())); try { wxString message; diff --git a/SFTP/sftp_worker_thread.h b/SFTP/sftp_worker_thread.h index 8e63147b0e..5e8411bbb9 100644 --- a/SFTP/sftp_worker_thread.h +++ b/SFTP/sftp_worker_thread.h @@ -56,8 +56,10 @@ class SFTPThreadRequest : public ThreadRequest int m_lineNumber = wxNOT_FOUND; public: - SFTPThreadRequest(const SSHAccountInfo& accountInfo, const wxString& remoteFile, const wxString& localFile, - size_t permissions); + SFTPThreadRequest(const SSHAccountInfo& accountInfo, + const wxString& remoteFile, + const wxString& localFile, + size_t permissions); SFTPThreadRequest(const SSHAccountInfo& accountInfo, const wxString& oldName, const wxString& newName); SFTPThreadRequest(const SSHAccountInfo& accountInfo, const wxString& fileToDelete); explicit SFTPThreadRequest(const RemoteFileInfo& remoteFile); diff --git a/SFTP/sftp_workspace_settings.cpp b/SFTP/sftp_workspace_settings.cpp index c0d0ecc528..ac63f5a2a8 100644 --- a/SFTP/sftp_workspace_settings.cpp +++ b/SFTP/sftp_workspace_settings.cpp @@ -47,7 +47,7 @@ JSONItem SFTPWorkspaceSettings::ToJSON() const void SFTPWorkspaceSettings::Load(SFTPWorkspaceSettings& settings, const wxFileName& workspaceFile) { wxFileName fn(workspaceFile); - if(fn.IsOk() && fn.FileExists()) { + if (fn.IsOk() && fn.FileExists()) { fn.SetName("sftp-workspace-settings"); fn.SetExt("conf"); fn.AppendDir(".codelite"); diff --git a/SFTP/sftp_workspace_settings.h b/SFTP/sftp_workspace_settings.h index b2ae52afef..c97ab6df9b 100644 --- a/SFTP/sftp_workspace_settings.h +++ b/SFTP/sftp_workspace_settings.h @@ -40,28 +40,21 @@ class SFTPWorkspaceSettings : public clConfigItem static void Load(SFTPWorkspaceSettings& settings, const wxFileName& workspaceFile); static void Save(const SFTPWorkspaceSettings& settings, const wxFileName& workspaceFile); - void SetAccount(const wxString& account) { - this->m_account = account; - } - void SetRemoteWorkspacePath(const wxString& remoteWorkspacePath) { + void SetAccount(const wxString& account) { this->m_account = account; } + void SetRemoteWorkspacePath(const wxString& remoteWorkspacePath) + { this->m_remoteWorkspacePath = remoteWorkspacePath; } - const wxString& GetAccount() const { - return m_account; - } - const wxString& GetRemoteWorkspacePath() const { - return m_remoteWorkspacePath; - } - + const wxString& GetAccount() const { return m_account; } + const wxString& GetRemoteWorkspacePath() const { return m_remoteWorkspacePath; } + void Clear(); - - bool IsOk() const { - return !m_account.IsEmpty() && !m_remoteWorkspacePath.IsEmpty(); - } - + + bool IsOk() const { return !m_account.IsEmpty() && !m_remoteWorkspacePath.IsEmpty(); } + public: virtual void FromJSON(const JSONItem& json); virtual JSONItem ToJSON() const; }; -#endif // SFTPWORKSPACESETTINGS_H +#endif // SFTPWORKSPACESETTINGS_H diff --git a/SmartCompletion/SmartCompletionUsageDB.cpp b/SmartCompletion/SmartCompletionUsageDB.cpp index 9638e9085d..825055dffc 100644 --- a/SmartCompletion/SmartCompletionUsageDB.cpp +++ b/SmartCompletion/SmartCompletionUsageDB.cpp @@ -1,6 +1,8 @@ #include "SmartCompletionUsageDB.h" + #include "cl_standard_paths.h" #include "file_logger.h" + #include SmartCompletionUsageDB::~SmartCompletionUsageDB() { Close(); } @@ -8,7 +10,8 @@ SmartCompletionUsageDB::~SmartCompletionUsageDB() { Close(); } void SmartCompletionUsageDB::Open() { try { - if(m_db.IsOpen()) return; + if (m_db.IsOpen()) + return; wxFileName fn(clStandardPaths::Get().GetUserDataDir(), "SmartCompletions.db"); fn.AppendDir("config"); @@ -62,7 +65,7 @@ void SmartCompletionUsageDB::LoadCCUsageTable(std::unordered_map& try { weightTable.clear(); wxSQLite3ResultSet res = m_db.ExecuteQuery("select NAME,WEIGHT from CC_USAGE"); - while(res.NextRow()) { + while (res.NextRow()) { wxString k = res.GetString(0); int v = res.GetInt(1); weightTable[k] = v; @@ -77,7 +80,7 @@ void SmartCompletionUsageDB::LoadGTAUsageTable(std::unordered_map try { weightTable.clear(); wxSQLite3ResultSet res = m_db.ExecuteQuery("select NAME,WEIGHT from GOTO_ANYTHING_USAGE"); - while(res.NextRow()) { + while (res.NextRow()) { wxString k = res.GetString(0); int v = res.GetInt(1); weightTable[k] = v; @@ -103,7 +106,7 @@ void SmartCompletionUsageDB::StoreCCUsage(const wxString& key, int weight) void SmartCompletionUsageDB::Close() { - if(m_db.IsOpen()) { + if (m_db.IsOpen()) { try { m_db.Close(); } catch (const wxSQLite3Exception& e) { diff --git a/SmartCompletion/SmartCompletionUsageDB.h b/SmartCompletion/SmartCompletionUsageDB.h index e9eb027d7f..a3b025a4c9 100644 --- a/SmartCompletion/SmartCompletionUsageDB.h +++ b/SmartCompletion/SmartCompletionUsageDB.h @@ -39,12 +39,12 @@ class SmartCompletionUsageDB * @brief write the CC usage to the database */ void StoreCCUsage(const wxString& key, int weight); - + /** * @brief write the GTA usage to the database */ void StoreGTAUsage(const wxString& key, int weight); - + /** * @brief clear the content of the database */ diff --git a/SmartCompletion/SmartCompletionsSettingsDlg.cpp b/SmartCompletion/SmartCompletionsSettingsDlg.cpp index ad5838432f..17f71a622e 100644 --- a/SmartCompletion/SmartCompletionsSettingsDlg.cpp +++ b/SmartCompletion/SmartCompletionsSettingsDlg.cpp @@ -1,4 +1,5 @@ #include "SmartCompletionsSettingsDlg.h" + #include "SmartCompletionsConfig.h" #include "windowattrmanager.h" diff --git a/SmartCompletion/SmartCompletionsSettingsDlg.h b/SmartCompletion/SmartCompletionsSettingsDlg.h index 2d1b016d37..a967980605 100644 --- a/SmartCompletion/SmartCompletionsSettingsDlg.h +++ b/SmartCompletion/SmartCompletionsSettingsDlg.h @@ -1,7 +1,7 @@ #ifndef SMARTCOMPLETIONSSETTINGSDLG_H #define SMARTCOMPLETIONSSETTINGSDLG_H -#include "SmartCompletionsUI.h" #include "SmartCompletionsConfig.h" +#include "SmartCompletionsUI.h" class SmartCompletionsSettingsDlg : public SmartCompletionsSettingsBaseDlg { diff --git a/SmartCompletion/smartcompletion.cpp b/SmartCompletion/smartcompletion.cpp index d133668150..ffefc9ce10 100644 --- a/SmartCompletion/smartcompletion.cpp +++ b/SmartCompletion/smartcompletion.cpp @@ -1,18 +1,17 @@ #include "smartcompletion.h" + #include "SmartCompletionsSettingsDlg.h" #include "codelite_events.h" #include "event_notifier.h" #include "macros.h" + #include #include #include #include // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new SmartCompletion(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new SmartCompletion(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -68,7 +67,7 @@ void SmartCompletion::UnPlug() void SmartCompletion::OnCodeCompletionSelectionMade(clCodeCompletionEvent& event) { event.Skip(); - if(!m_config.IsEnabled()) + if (!m_config.IsEnabled()) return; CHECK_PTR_RET(event.GetEntry()); @@ -77,7 +76,7 @@ void SmartCompletion::OnCodeCompletionSelectionMade(clCodeCompletionEvent& event WeightTable_t& T = *m_pCCWeight; // we have an associated tag wxString k = event.GetEntry()->GetText(); - if(T.count(k) == 0) { + if (T.count(k) == 0) { T[k] = 1; } else { T[k]++; @@ -88,7 +87,7 @@ void SmartCompletion::OnCodeCompletionSelectionMade(clCodeCompletionEvent& event void SmartCompletion::OnCodeCompletionShowing(clCodeCompletionEvent& event) { event.Skip(); - if(!m_config.IsEnabled()) + if (!m_config.IsEnabled()) return; // Sort the entries by their weight @@ -110,7 +109,8 @@ void SmartCompletion::OnCodeCompletionShowing(clCodeCompletionEvent& event) entries.swap(normalEntries); // Step 2: sort the important entries, based on their weight - std::sort(importantEntries.begin(), importantEntries.end(), + std::sort(importantEntries.begin(), + importantEntries.end(), [&](wxCodeCompletionBoxEntry::Ptr_t a, wxCodeCompletionBoxEntry::Ptr_t b) { // Sort in descending order return a->GetWeight() > b->GetWeight(); @@ -129,7 +129,7 @@ void SmartCompletion::OnSettings(wxCommandEvent& e) void SmartCompletion::OnGotoAnythingSort(clGotoEvent& event) { event.Skip(); - if(!m_config.IsEnabled()) + if (!m_config.IsEnabled()) return; // Sort the entries by their weight @@ -143,7 +143,7 @@ void SmartCompletion::OnGotoAnythingSort(clGotoEvent& event) if (T.count(entry.GetDesc())) { // This item has weight int weight = T[entry.GetDesc()]; - importantEntries.push_back({ weight, entry }); + importantEntries.push_back({weight, entry}); } else { normalEntries.push_back(entry); } @@ -154,7 +154,8 @@ void SmartCompletion::OnGotoAnythingSort(clGotoEvent& event) // Step 2: sort the important entries - the sorting is DESC (lower first) std::sort( - importantEntries.begin(), importantEntries.end(), + importantEntries.begin(), + importantEntries.end(), [&](const std::pair& a, const std::pair& b) { return a.first < b.first; }); // Step 3: prepend the important entries (it actually reverse the sorting) @@ -166,14 +167,14 @@ void SmartCompletion::OnGotoAnythingSort(clGotoEvent& event) void SmartCompletion::OnGotoAnythingSelectionMade(clGotoEvent& event) { event.Skip(); - if(!m_config.IsEnabled()) + if (!m_config.IsEnabled()) return; // Collect info about this match WeightTable_t& T = *m_pGTAWeight; const wxString& key = event.GetEntry().GetDesc(); - if(T.count(key) == 0) { + if (T.count(key) == 0) { T[key] = 1; } else { T[key]++; diff --git a/SnipWiz/AboutHtml.h b/SnipWiz/AboutHtml.h index dcd8b3cb5b..a222d6a9ef 100644 --- a/SnipWiz/AboutHtml.h +++ b/SnipWiz/AboutHtml.h @@ -1,157 +1,122 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : AboutHtml.h -// +// copyright : (C) 2008 by Eran Ifrah +// file name : AboutHtml.h +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -const char snipwizhtml_txt[] ={ - 0x3C,0x48,0x54,0x4D,0x4C,0x3E,0x3C,0x42,0x4F,0x44,0x59,0x20,0x42,0x47, - 0x43,0x4F,0x4C,0x4F,0x52,0x3D,0x22,0x23,0x46,0x46,0x46,0x46,0x45,0x36, - 0x22,0x20,0x54,0x45,0x58,0x54,0x3D,0x22,0x23,0x30,0x30,0x30,0x30,0x30, - 0x30,0x22,0x20,0x4C,0x49,0x4E,0x4B,0x3D,0x22,0x23,0x30,0x30,0x30,0x30, - 0x46,0x46,0x22,0x20,0x56,0x4C,0x49,0x4E,0x4B,0x3D,0x22,0x23,0x34,0x30, - 0x30,0x30,0x34,0x30,0x22,0x20,0x41,0x4C,0x49,0x4E,0x4B,0x3D,0x22,0x23, - 0x46,0x46,0x30,0x30,0x30,0x30,0x22,0x20,0x54,0x4F,0x50,0x4D,0x41,0x52, - 0x47,0x49,0x4E,0x3D,0x22,0x35,0x22,0x20,0x4C,0x45,0x46,0x54,0x4D,0x41, - 0x52,0x47,0x49,0x4E,0x3D,0x22,0x35,0x22,0x3E,0x0A,0x3C,0x46,0x4F,0x4E, - 0x54,0x20,0x43,0x4F,0x4C,0x4F,0x52,0x3D,0x22,0x22,0x20,0x53,0x49,0x5A, - 0x45,0x3D,0x22,0x32,0x22,0x20,0x46,0x41,0x43,0x45,0x3D,0x22,0x41,0x72, - 0x69,0x61,0x6C,0x2C,0x20,0x4C,0x75,0x63,0x69,0x64,0x61,0x20,0x53,0x61, - 0x6E,0x73,0x22,0x3E,0x0A,0x3C,0x42,0x3E,0x53,0x6E,0x69,0x70,0x57,0x69, - 0x7A,0x3C,0x2F,0x42,0x3E,0x20,0x69,0x73,0x20,0x61,0x20,0x6C,0x69,0x74, - 0x74,0x6C,0x65,0x20,0x74,0x6F,0x6F,0x6C,0x20,0x74,0x6F,0x20,0x6D,0x61, - 0x6B,0x65,0x20,0x70,0x72,0x6F,0x67,0x72,0x61,0x6D,0x6D,0x65,0x72,0x73, - 0x27,0x20,0x6C,0x69,0x76,0x65,0x73,0x20,0x61,0x20,0x62,0x69,0x74,0x20, - 0x65,0x61,0x73,0x69,0x65,0x72,0x2E,0x20,0x49,0x74,0x20,0x63,0x6F,0x6E, - 0x73,0x69,0x73,0x74,0x73,0x20,0x6F,0x66,0x20,0x74,0x77,0x6F,0x20,0x70, - 0x61,0x72,0x74,0x73,0x2C,0x20,0x74,0x68,0x65,0x20,0x27,0x3C,0x42,0x3E, - 0x3C,0x49,0x3E,0x53,0x6E,0x69,0x70,0x70,0x65,0x74,0x20,0x57,0x69,0x7A, - 0x61,0x72,0x64,0x3C,0x2F,0x49,0x3E,0x3C,0x2F,0x42,0x3E,0x27,0x20,0x61, - 0x6E,0x64,0x20,0x74,0x68,0x65,0x20,0x27,0x3C,0x42,0x3E,0x3C,0x49,0x3E, - 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65,0x20,0x43,0x6C,0x61,0x73,0x73, - 0x20,0x57,0x69,0x7A,0x61,0x72,0x64,0x3C,0x2F,0x49,0x3E,0x3C,0x2F,0x42, - 0x3E,0x27,0x2E,0x3C,0x50,0x3E,0x0A,0x0A,0x3C,0x42,0x3E,0x53,0x6E,0x69, - 0x70,0x70,0x65,0x74,0x20,0x57,0x69,0x7A,0x61,0x72,0x64,0x3A,0x3C,0x2F, - 0x42,0x3E,0x3C,0x42,0x52,0x3E,0x0A,0x54,0x68,0x69,0x73,0x20,0x68,0x6F, - 0x6C,0x64,0x73,0x20,0x73,0x6E,0x69,0x70,0x70,0x65,0x74,0x73,0x20,0x6F, - 0x66,0x20,0x63,0x6F,0x64,0x65,0x20,0x74,0x68,0x61,0x74,0x20,0x79,0x6F, - 0x75,0x20,0x6D,0x69,0x67,0x68,0x74,0x20,0x63,0x6F,0x6D,0x6D,0x6F,0x6E, - 0x6C,0x79,0x20,0x75,0x73,0x65,0x2E,0x20,0x41,0x20,0x73,0x6E,0x69,0x70, - 0x70,0x65,0x74,0x20,0x63,0x61,0x6E,0x20,0x62,0x65,0x20,0x69,0x6E,0x73, - 0x65,0x72,0x74,0x65,0x64,0x20,0x69,0x6E,0x74,0x6F,0x20,0x61,0x20,0x64, - 0x6F,0x63,0x75,0x6D,0x65,0x6E,0x74,0x20,0x66,0x72,0x6F,0x6D,0x20,0x74, - 0x68,0x65,0x20,0x63,0x6F,0x6E,0x74,0x65,0x78,0x74,0x20,0x6D,0x65,0x6E, - 0x75,0x2C,0x20,0x3C,0x50,0x3E,0x0A,0x20,0x0A,0x54,0x68,0x65,0x72,0x65, - 0x20,0x61,0x72,0x65,0x20,0x74,0x77,0x6F,0x20,0x70,0x6C,0x61,0x63,0x65, - 0x68,0x6F,0x6C,0x64,0x65,0x72,0x73,0x20,0x77,0x68,0x69,0x63,0x68,0x20, - 0x63,0x61,0x6E,0x20,0x62,0x65,0x20,0x75,0x73,0x65,0x64,0x20,0x61,0x73, - 0x20,0x70,0x61,0x72,0x61,0x6D,0x65,0x74,0x65,0x72,0x73,0x20,0x69,0x6E, - 0x20,0x61,0x20,0x73,0x6E,0x69,0x70,0x70,0x65,0x74,0x2E,0x3C,0x42,0x52, - 0x3E,0x0A,0x3C,0x44,0x44,0x3E,0x3C,0x42,0x3E,0x24,0x3C,0x2F,0x42,0x3E, - 0x20,0x77,0x69,0x6C,0x6C,0x20,0x62,0x65,0x20,0x72,0x65,0x70,0x6C,0x61, - 0x63,0x65,0x64,0x20,0x62,0x79,0x20,0x74,0x68,0x65,0x20,0x73,0x65,0x6C, - 0x65,0x63,0x74,0x69,0x6F,0x6E,0x2C,0x20,0x69,0x66,0x20,0x61,0x6E,0x79, - 0x2E,0x0A,0x3C,0x44,0x44,0x3E,0x3C,0x42,0x3E,0x40,0x3C,0x2F,0x42,0x3E, - 0x20,0x77,0x69,0x6C,0x6C,0x20,0x73,0x65,0x74,0x20,0x74,0x68,0x65,0x20, - 0x70,0x6F,0x73,0x69,0x74,0x69,0x6F,0x6E,0x20,0x77,0x68,0x65,0x72,0x65, - 0x20,0x74,0x68,0x65,0x20,0x63,0x61,0x72,0x65,0x74,0x20,0x73,0x68,0x6F, - 0x75,0x6C,0x64,0x20,0x62,0x65,0x20,0x61,0x66,0x74,0x65,0x72,0x20,0x74, - 0x68,0x65,0x20,0x73,0x6E,0x69,0x70,0x70,0x65,0x74,0x20,0x68,0x61,0x73, - 0x20,0x62,0x65,0x65,0x6E,0x20,0x69,0x6E,0x73,0x65,0x72,0x74,0x65,0x64, - 0x2E,0x3C,0x50,0x3E,0x0A,0x0A,0x3C,0x44,0x44,0x3E,0x3C,0x55,0x3E,0x45, - 0x78,0x61,0x6D,0x70,0x6C,0x65,0x3A,0x3C,0x2F,0x55,0x3E,0x0A,0x3C,0x44, - 0x44,0x3E,0x3C,0x43,0x4F,0x44,0x45,0x3E,0x66,0x6F,0x72,0x28,0x24,0x20, - 0x3D,0x20,0x30,0x3B,0x20,0x24,0x20,0x26,0x6C,0x74,0x3B,0x20,0x40,0x3B, - 0x20,0x24,0x2B,0x2B,0x29,0x3C,0x2F,0x43,0x4F,0x44,0x45,0x3E,0x0A,0x3C, - 0x44,0x44,0x3E,0x4C,0x65,0x74,0x27,0x73,0x20,0x73,0x61,0x79,0x20,0x79, - 0x6F,0x75,0x20,0x68,0x61,0x64,0x20,0x73,0x65,0x6C,0x65,0x63,0x74,0x65, - 0x64,0x20,0x74,0x68,0x65,0x20,0x77,0x6F,0x72,0x64,0x20,0x27,0x3C,0x43, - 0x4F,0x44,0x45,0x3E,0x63,0x6F,0x75,0x6E,0x74,0x65,0x72,0x3C,0x2F,0x43, - 0x4F,0x44,0x45,0x3E,0x27,0x20,0x54,0x68,0x69,0x73,0x20,0x77,0x69,0x6C, - 0x6C,0x20,0x65,0x78,0x70,0x61,0x6E,0x64,0x20,0x74,0x6F,0x0A,0x3C,0x44, - 0x44,0x3E,0x3C,0x43,0x4F,0x44,0x45,0x3E,0x66,0x6F,0x72,0x28,0x63,0x6F, - 0x75,0x6E,0x74,0x65,0x72,0x20,0x3D,0x20,0x30,0x3B,0x20,0x63,0x6F,0x75, - 0x6E,0x74,0x65,0x72,0x20,0x26,0x6C,0x74,0x3B,0x20,0x7C,0x3B,0x20,0x63, - 0x6F,0x75,0x6E,0x74,0x65,0x72,0x2B,0x2B,0x29,0x3C,0x2F,0x43,0x4F,0x44, - 0x45,0x3E,0x2E,0x3C,0x42,0x52,0x3E,0x0A,0x3C,0x44,0x44,0x3E,0x77,0x68, - 0x65,0x72,0x65,0x20,0x74,0x68,0x65,0x20,0x27,0x7C,0x27,0x20,0x73,0x79, - 0x6D,0x62,0x6F,0x6C,0x20,0x72,0x65,0x70,0x72,0x65,0x73,0x65,0x6E,0x74, - 0x73,0x20,0x74,0x68,0x65,0x20,0x63,0x61,0x72,0x65,0x74,0x20,0x70,0x6F, - 0x73,0x69,0x74,0x69,0x6F,0x6E,0x2C,0x20,0x69,0x6E,0x20,0x74,0x68,0x65, - 0x20,0x72,0x69,0x67,0x68,0x74,0x20,0x70,0x6C,0x61,0x63,0x65,0x20,0x66, - 0x6F,0x72,0x20,0x79,0x6F,0x75,0x20,0x74,0x6F,0x20,0x61,0x64,0x64,0x20, - 0x74,0x68,0x65,0x20,0x6D,0x61,0x78,0x69,0x6D,0x75,0x6D,0x2D,0x63,0x6F, - 0x75,0x6E,0x74,0x20,0x66,0x69,0x67,0x75,0x72,0x65,0x2E,0x3C,0x50,0x3E, - 0x0A,0x0A,0x49,0x66,0x20,0x79,0x6F,0x75,0x20,0x70,0x72,0x65,0x73,0x73, - 0x20,0x74,0x68,0x65,0x20,0x27,0x3C,0x49,0x3E,0x43,0x74,0x72,0x6C,0x3C, - 0x2F,0x49,0x3E,0x27,0x20,0x6B,0x65,0x79,0x20,0x77,0x68,0x69,0x6C,0x65, - 0x20,0x63,0x6C,0x69,0x63,0x6B,0x69,0x6E,0x67,0x20,0x6F,0x6E,0x20,0x74, - 0x68,0x65,0x20,0x73,0x6E,0x69,0x70,0x70,0x65,0x74,0x20,0x6D,0x65,0x6E, - 0x75,0x2C,0x20,0x74,0x68,0x65,0x20,0x73,0x6E,0x69,0x70,0x70,0x65,0x74, - 0x20,0x69,0x73,0x20,0x6E,0x6F,0x74,0x20,0x69,0x6E,0x73,0x65,0x72,0x74, - 0x65,0x64,0x20,0x61,0x74,0x20,0x74,0x68,0x65,0x20,0x63,0x75,0x72,0x72, - 0x65,0x6E,0x74,0x20,0x63,0x61,0x72,0x65,0x74,0x20,0x70,0x6F,0x73,0x69, - 0x74,0x69,0x6F,0x6E,0x2C,0x20,0x62,0x75,0x74,0x20,0x69,0x73,0x20,0x63, - 0x6F,0x70,0x69,0x65,0x64,0x20,0x74,0x6F,0x20,0x74,0x68,0x65,0x20,0x63, - 0x6C,0x69,0x70,0x62,0x6F,0x61,0x72,0x64,0x20,0x61,0x6E,0x64,0x20,0x74, - 0x6F,0x20,0x61,0x6E,0x20,0x69,0x6E,0x74,0x65,0x72,0x6E,0x61,0x6C,0x20, - 0x62,0x75,0x66,0x66,0x65,0x72,0x3B,0x20,0x73,0x6F,0x20,0x79,0x6F,0x75, - 0x20,0x63,0x61,0x6E,0x20,0x64,0x6F,0x20,0x74,0x68,0x65,0x20,0x69,0x6E, - 0x73,0x65,0x72,0x74,0x69,0x6F,0x6E,0x20,0x65,0x6C,0x73,0x65,0x77,0x68, - 0x65,0x72,0x65,0x2C,0x20,0x70,0x65,0x72,0x68,0x61,0x70,0x73,0x20,0x72, - 0x65,0x70,0x65,0x61,0x74,0x65,0x64,0x6C,0x79,0x2E,0x20,0x49,0x66,0x20,0x79,0x6F, - 0x75,0x20,0x68,0x61,0x76,0x65,0x20,0x61,0x20,0x6D,0x75,0x6C,0x74,0x69, - 0x2D,0x6C,0x69,0x6E,0x65,0x20,0x73,0x6E,0x69,0x70,0x70,0x65,0x74,0x2C, - 0x20,0x79,0x6F,0x75,0x20,0x73,0x68,0x6F,0x75,0x6C,0x64,0x20,0x70,0x61, - 0x73,0x74,0x65,0x20,0x66,0x72,0x6F,0x6D,0x20,0x74,0x68,0x65,0x20,0x69, - 0x6E,0x74,0x65,0x72,0x6E,0x61,0x6C,0x20,0x62,0x75,0x66,0x66,0x65,0x72, - 0x20,0x28,0x76,0x69,0x61,0x20,0x74,0x68,0x65,0x20,0x63,0x6F,0x6E,0x74, - 0x65,0x78,0x74,0x20,0x6D,0x65,0x6E,0x75,0x29,0x2C,0x20,0x73,0x69,0x6E, - 0x63,0x65,0x20,0x74,0x68,0x69,0x73,0x20,0x77,0x69,0x6C,0x6C,0x20,0x72, - 0x65,0x74,0x61,0x69,0x6E,0x20,0x74,0x68,0x65,0x20,0x63,0x6F,0x72,0x72, - 0x65,0x63,0x74,0x20,0x69,0x6E,0x64,0x65,0x6E,0x74,0x61,0x74,0x69,0x6F, - 0x6E,0x2E,0x3C,0x50,0x3E,0x20,0x0A,0x0A,0x3C,0x42,0x3E,0x54,0x65,0x6D, - 0x70,0x6C,0x61,0x74,0x65,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x57,0x69, - 0x7A,0x61,0x72,0x64,0x3A,0x3C,0x2F,0x42,0x3E,0x3C,0x42,0x52,0x3E,0x0A, - 0x48,0x65,0x72,0x65,0x20,0x79,0x6F,0x75,0x20,0x63,0x61,0x6E,0x20,0x63, - 0x72,0x65,0x61,0x74,0x65,0x20,0x74,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, - 0x73,0x20,0x6F,0x66,0x20,0x63,0x6C,0x61,0x73,0x73,0x65,0x73,0x20,0x74, - 0x68,0x61,0x74,0x20,0x79,0x6F,0x75,0x20,0x6F,0x66,0x74,0x65,0x6E,0x20, - 0x75,0x73,0x65,0x2E,0x20,0x57,0x68,0x65,0x6E,0x20,0x79,0x6F,0x75,0x20, - 0x69,0x6E,0x73,0x65,0x72,0x74,0x20,0x6F,0x6E,0x65,0x20,0x69,0x6E,0x74, - 0x6F,0x20,0x79,0x6F,0x75,0x72,0x20,0x63,0x6F,0x64,0x65,0x2C,0x20,0x61, - 0x6C,0x6C,0x20,0x6F,0x63,0x63,0x75,0x72,0x72,0x65,0x6E,0x63,0x65,0x73, - 0x20,0x6F,0x66,0x20,0x74,0x68,0x65,0x20,0x6B,0x65,0x79,0x77,0x6F,0x72, - 0x64,0x20,0x3C,0x43,0x4F,0x44,0x45,0x3E,0x25,0x43,0x4C,0x41,0x53,0x53, - 0x25,0x3C,0x2F,0x43,0x4F,0x44,0x45,0x3E,0x20,0x61,0x72,0x65,0x20,0x72, - 0x65,0x70,0x6C,0x61,0x63,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x61, - 0x20,0x63,0x6C,0x61,0x73,0x73,0x20,0x6E,0x61,0x6D,0x65,0x20,0x74,0x68, - 0x61,0x74,0x20,0x79,0x6F,0x75,0x20,0x65,0x6E,0x74,0x65,0x72,0x3B,0x20, - 0x74,0x68,0x65,0x6E,0x20,0x61,0x70,0x70,0x72,0x6F,0x70,0x72,0x69,0x61, - 0x74,0x65,0x6C,0x79,0x2D,0x6E,0x61,0x6D,0x65,0x64,0x20,0x63,0x70,0x70, - 0x20,0x61,0x6E,0x64,0x20,0x68,0x65,0x61,0x64,0x65,0x72,0x20,0x66,0x69, - 0x6C,0x65,0x73,0x20,0x61,0x72,0x65,0x20,0x63,0x72,0x65,0x61,0x74,0x65, - 0x64,0x2C,0x20,0x63,0x6F,0x6E,0x74,0x61,0x69,0x6E,0x69,0x6E,0x67,0x20, - 0x74,0x68,0x65,0x20,0x63,0x6F,0x64,0x65,0x2E,0x3C,0x42,0x52,0x3E,0x3C, - 0x2F,0x46,0x4F,0x4E,0x54,0x3E,0x0A,0x3C,0x2F,0x42,0x4F,0x44,0x59,0x3E, - 0x3C,0x2F,0x48,0x54,0x4D,0x4C,0x3E,0x00 -}; +const char snipwizhtml_txt[] = { + 0x3C, 0x48, 0x54, 0x4D, 0x4C, 0x3E, 0x3C, 0x42, 0x4F, 0x44, 0x59, 0x20, 0x42, 0x47, 0x43, 0x4F, 0x4C, 0x4F, 0x52, + 0x3D, 0x22, 0x23, 0x46, 0x46, 0x46, 0x46, 0x45, 0x36, 0x22, 0x20, 0x54, 0x45, 0x58, 0x54, 0x3D, 0x22, 0x23, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x20, 0x4C, 0x49, 0x4E, 0x4B, 0x3D, 0x22, 0x23, 0x30, 0x30, 0x30, 0x30, 0x46, + 0x46, 0x22, 0x20, 0x56, 0x4C, 0x49, 0x4E, 0x4B, 0x3D, 0x22, 0x23, 0x34, 0x30, 0x30, 0x30, 0x34, 0x30, 0x22, 0x20, + 0x41, 0x4C, 0x49, 0x4E, 0x4B, 0x3D, 0x22, 0x23, 0x46, 0x46, 0x30, 0x30, 0x30, 0x30, 0x22, 0x20, 0x54, 0x4F, 0x50, + 0x4D, 0x41, 0x52, 0x47, 0x49, 0x4E, 0x3D, 0x22, 0x35, 0x22, 0x20, 0x4C, 0x45, 0x46, 0x54, 0x4D, 0x41, 0x52, 0x47, + 0x49, 0x4E, 0x3D, 0x22, 0x35, 0x22, 0x3E, 0x0A, 0x3C, 0x46, 0x4F, 0x4E, 0x54, 0x20, 0x43, 0x4F, 0x4C, 0x4F, 0x52, + 0x3D, 0x22, 0x22, 0x20, 0x53, 0x49, 0x5A, 0x45, 0x3D, 0x22, 0x32, 0x22, 0x20, 0x46, 0x41, 0x43, 0x45, 0x3D, 0x22, + 0x41, 0x72, 0x69, 0x61, 0x6C, 0x2C, 0x20, 0x4C, 0x75, 0x63, 0x69, 0x64, 0x61, 0x20, 0x53, 0x61, 0x6E, 0x73, 0x22, + 0x3E, 0x0A, 0x3C, 0x42, 0x3E, 0x53, 0x6E, 0x69, 0x70, 0x57, 0x69, 0x7A, 0x3C, 0x2F, 0x42, 0x3E, 0x20, 0x69, 0x73, + 0x20, 0x61, 0x20, 0x6C, 0x69, 0x74, 0x74, 0x6C, 0x65, 0x20, 0x74, 0x6F, 0x6F, 0x6C, 0x20, 0x74, 0x6F, 0x20, 0x6D, + 0x61, 0x6B, 0x65, 0x20, 0x70, 0x72, 0x6F, 0x67, 0x72, 0x61, 0x6D, 0x6D, 0x65, 0x72, 0x73, 0x27, 0x20, 0x6C, 0x69, + 0x76, 0x65, 0x73, 0x20, 0x61, 0x20, 0x62, 0x69, 0x74, 0x20, 0x65, 0x61, 0x73, 0x69, 0x65, 0x72, 0x2E, 0x20, 0x49, + 0x74, 0x20, 0x63, 0x6F, 0x6E, 0x73, 0x69, 0x73, 0x74, 0x73, 0x20, 0x6F, 0x66, 0x20, 0x74, 0x77, 0x6F, 0x20, 0x70, + 0x61, 0x72, 0x74, 0x73, 0x2C, 0x20, 0x74, 0x68, 0x65, 0x20, 0x27, 0x3C, 0x42, 0x3E, 0x3C, 0x49, 0x3E, 0x53, 0x6E, + 0x69, 0x70, 0x70, 0x65, 0x74, 0x20, 0x57, 0x69, 0x7A, 0x61, 0x72, 0x64, 0x3C, 0x2F, 0x49, 0x3E, 0x3C, 0x2F, 0x42, + 0x3E, 0x27, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x27, 0x3C, 0x42, 0x3E, 0x3C, 0x49, 0x3E, 0x54, + 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65, 0x20, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x20, 0x57, 0x69, 0x7A, 0x61, 0x72, + 0x64, 0x3C, 0x2F, 0x49, 0x3E, 0x3C, 0x2F, 0x42, 0x3E, 0x27, 0x2E, 0x3C, 0x50, 0x3E, 0x0A, 0x0A, 0x3C, 0x42, 0x3E, + 0x53, 0x6E, 0x69, 0x70, 0x70, 0x65, 0x74, 0x20, 0x57, 0x69, 0x7A, 0x61, 0x72, 0x64, 0x3A, 0x3C, 0x2F, 0x42, 0x3E, + 0x3C, 0x42, 0x52, 0x3E, 0x0A, 0x54, 0x68, 0x69, 0x73, 0x20, 0x68, 0x6F, 0x6C, 0x64, 0x73, 0x20, 0x73, 0x6E, 0x69, + 0x70, 0x70, 0x65, 0x74, 0x73, 0x20, 0x6F, 0x66, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, + 0x79, 0x6F, 0x75, 0x20, 0x6D, 0x69, 0x67, 0x68, 0x74, 0x20, 0x63, 0x6F, 0x6D, 0x6D, 0x6F, 0x6E, 0x6C, 0x79, 0x20, + 0x75, 0x73, 0x65, 0x2E, 0x20, 0x41, 0x20, 0x73, 0x6E, 0x69, 0x70, 0x70, 0x65, 0x74, 0x20, 0x63, 0x61, 0x6E, 0x20, + 0x62, 0x65, 0x20, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x74, 0x65, 0x64, 0x20, 0x69, 0x6E, 0x74, 0x6F, 0x20, 0x61, 0x20, + 0x64, 0x6F, 0x63, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x20, 0x66, 0x72, 0x6F, 0x6D, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, + 0x6F, 0x6E, 0x74, 0x65, 0x78, 0x74, 0x20, 0x6D, 0x65, 0x6E, 0x75, 0x2C, 0x20, 0x3C, 0x50, 0x3E, 0x0A, 0x20, 0x0A, + 0x54, 0x68, 0x65, 0x72, 0x65, 0x20, 0x61, 0x72, 0x65, 0x20, 0x74, 0x77, 0x6F, 0x20, 0x70, 0x6C, 0x61, 0x63, 0x65, + 0x68, 0x6F, 0x6C, 0x64, 0x65, 0x72, 0x73, 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x62, + 0x65, 0x20, 0x75, 0x73, 0x65, 0x64, 0x20, 0x61, 0x73, 0x20, 0x70, 0x61, 0x72, 0x61, 0x6D, 0x65, 0x74, 0x65, 0x72, + 0x73, 0x20, 0x69, 0x6E, 0x20, 0x61, 0x20, 0x73, 0x6E, 0x69, 0x70, 0x70, 0x65, 0x74, 0x2E, 0x3C, 0x42, 0x52, 0x3E, + 0x0A, 0x3C, 0x44, 0x44, 0x3E, 0x3C, 0x42, 0x3E, 0x24, 0x3C, 0x2F, 0x42, 0x3E, 0x20, 0x77, 0x69, 0x6C, 0x6C, 0x20, + 0x62, 0x65, 0x20, 0x72, 0x65, 0x70, 0x6C, 0x61, 0x63, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65, 0x20, + 0x73, 0x65, 0x6C, 0x65, 0x63, 0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x20, 0x69, 0x66, 0x20, 0x61, 0x6E, 0x79, 0x2E, 0x0A, + 0x3C, 0x44, 0x44, 0x3E, 0x3C, 0x42, 0x3E, 0x40, 0x3C, 0x2F, 0x42, 0x3E, 0x20, 0x77, 0x69, 0x6C, 0x6C, 0x20, 0x73, + 0x65, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x77, 0x68, 0x65, + 0x72, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x61, 0x72, 0x65, 0x74, 0x20, 0x73, 0x68, 0x6F, 0x75, 0x6C, 0x64, + 0x20, 0x62, 0x65, 0x20, 0x61, 0x66, 0x74, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x6E, 0x69, 0x70, 0x70, + 0x65, 0x74, 0x20, 0x68, 0x61, 0x73, 0x20, 0x62, 0x65, 0x65, 0x6E, 0x20, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x74, 0x65, + 0x64, 0x2E, 0x3C, 0x50, 0x3E, 0x0A, 0x0A, 0x3C, 0x44, 0x44, 0x3E, 0x3C, 0x55, 0x3E, 0x45, 0x78, 0x61, 0x6D, 0x70, + 0x6C, 0x65, 0x3A, 0x3C, 0x2F, 0x55, 0x3E, 0x0A, 0x3C, 0x44, 0x44, 0x3E, 0x3C, 0x43, 0x4F, 0x44, 0x45, 0x3E, 0x66, + 0x6F, 0x72, 0x28, 0x24, 0x20, 0x3D, 0x20, 0x30, 0x3B, 0x20, 0x24, 0x20, 0x26, 0x6C, 0x74, 0x3B, 0x20, 0x40, 0x3B, + 0x20, 0x24, 0x2B, 0x2B, 0x29, 0x3C, 0x2F, 0x43, 0x4F, 0x44, 0x45, 0x3E, 0x0A, 0x3C, 0x44, 0x44, 0x3E, 0x4C, 0x65, + 0x74, 0x27, 0x73, 0x20, 0x73, 0x61, 0x79, 0x20, 0x79, 0x6F, 0x75, 0x20, 0x68, 0x61, 0x64, 0x20, 0x73, 0x65, 0x6C, + 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77, 0x6F, 0x72, 0x64, 0x20, 0x27, 0x3C, 0x43, 0x4F, + 0x44, 0x45, 0x3E, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x65, 0x72, 0x3C, 0x2F, 0x43, 0x4F, 0x44, 0x45, 0x3E, 0x27, 0x20, + 0x54, 0x68, 0x69, 0x73, 0x20, 0x77, 0x69, 0x6C, 0x6C, 0x20, 0x65, 0x78, 0x70, 0x61, 0x6E, 0x64, 0x20, 0x74, 0x6F, + 0x0A, 0x3C, 0x44, 0x44, 0x3E, 0x3C, 0x43, 0x4F, 0x44, 0x45, 0x3E, 0x66, 0x6F, 0x72, 0x28, 0x63, 0x6F, 0x75, 0x6E, + 0x74, 0x65, 0x72, 0x20, 0x3D, 0x20, 0x30, 0x3B, 0x20, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x65, 0x72, 0x20, 0x26, 0x6C, + 0x74, 0x3B, 0x20, 0x7C, 0x3B, 0x20, 0x63, 0x6F, 0x75, 0x6E, 0x74, 0x65, 0x72, 0x2B, 0x2B, 0x29, 0x3C, 0x2F, 0x43, + 0x4F, 0x44, 0x45, 0x3E, 0x2E, 0x3C, 0x42, 0x52, 0x3E, 0x0A, 0x3C, 0x44, 0x44, 0x3E, 0x77, 0x68, 0x65, 0x72, 0x65, + 0x20, 0x74, 0x68, 0x65, 0x20, 0x27, 0x7C, 0x27, 0x20, 0x73, 0x79, 0x6D, 0x62, 0x6F, 0x6C, 0x20, 0x72, 0x65, 0x70, + 0x72, 0x65, 0x73, 0x65, 0x6E, 0x74, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x61, 0x72, 0x65, 0x74, 0x20, 0x70, + 0x6F, 0x73, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x20, 0x69, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x69, 0x67, + 0x68, 0x74, 0x20, 0x70, 0x6C, 0x61, 0x63, 0x65, 0x20, 0x66, 0x6F, 0x72, 0x20, 0x79, 0x6F, 0x75, 0x20, 0x74, 0x6F, + 0x20, 0x61, 0x64, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6D, 0x61, 0x78, 0x69, 0x6D, 0x75, 0x6D, 0x2D, 0x63, 0x6F, + 0x75, 0x6E, 0x74, 0x20, 0x66, 0x69, 0x67, 0x75, 0x72, 0x65, 0x2E, 0x3C, 0x50, 0x3E, 0x0A, 0x0A, 0x49, 0x66, 0x20, + 0x79, 0x6F, 0x75, 0x20, 0x70, 0x72, 0x65, 0x73, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x27, 0x3C, 0x49, 0x3E, 0x43, + 0x74, 0x72, 0x6C, 0x3C, 0x2F, 0x49, 0x3E, 0x27, 0x20, 0x6B, 0x65, 0x79, 0x20, 0x77, 0x68, 0x69, 0x6C, 0x65, 0x20, + 0x63, 0x6C, 0x69, 0x63, 0x6B, 0x69, 0x6E, 0x67, 0x20, 0x6F, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x6E, 0x69, + 0x70, 0x70, 0x65, 0x74, 0x20, 0x6D, 0x65, 0x6E, 0x75, 0x2C, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x6E, 0x69, 0x70, + 0x70, 0x65, 0x74, 0x20, 0x69, 0x73, 0x20, 0x6E, 0x6F, 0x74, 0x20, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x74, 0x65, 0x64, + 0x20, 0x61, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6E, 0x74, 0x20, 0x63, 0x61, 0x72, + 0x65, 0x74, 0x20, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x69, 0x6F, 0x6E, 0x2C, 0x20, 0x62, 0x75, 0x74, 0x20, 0x69, 0x73, + 0x20, 0x63, 0x6F, 0x70, 0x69, 0x65, 0x64, 0x20, 0x74, 0x6F, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6C, 0x69, 0x70, + 0x62, 0x6F, 0x61, 0x72, 0x64, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x74, 0x6F, 0x20, 0x61, 0x6E, 0x20, 0x69, 0x6E, 0x74, + 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x20, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x3B, 0x20, 0x73, 0x6F, 0x20, 0x79, 0x6F, + 0x75, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x64, 0x6F, 0x20, 0x74, 0x68, 0x65, 0x20, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x74, + 0x69, 0x6F, 0x6E, 0x20, 0x65, 0x6C, 0x73, 0x65, 0x77, 0x68, 0x65, 0x72, 0x65, 0x2C, 0x20, 0x70, 0x65, 0x72, 0x68, + 0x61, 0x70, 0x73, 0x20, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x6C, 0x79, 0x2E, 0x20, 0x49, 0x66, 0x20, + 0x79, 0x6F, 0x75, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x61, 0x20, 0x6D, 0x75, 0x6C, 0x74, 0x69, 0x2D, 0x6C, 0x69, + 0x6E, 0x65, 0x20, 0x73, 0x6E, 0x69, 0x70, 0x70, 0x65, 0x74, 0x2C, 0x20, 0x79, 0x6F, 0x75, 0x20, 0x73, 0x68, 0x6F, + 0x75, 0x6C, 0x64, 0x20, 0x70, 0x61, 0x73, 0x74, 0x65, 0x20, 0x66, 0x72, 0x6F, 0x6D, 0x20, 0x74, 0x68, 0x65, 0x20, + 0x69, 0x6E, 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x20, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x20, 0x28, 0x76, 0x69, + 0x61, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6F, 0x6E, 0x74, 0x65, 0x78, 0x74, 0x20, 0x6D, 0x65, 0x6E, 0x75, 0x29, + 0x2C, 0x20, 0x73, 0x69, 0x6E, 0x63, 0x65, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x77, 0x69, 0x6C, 0x6C, 0x20, 0x72, + 0x65, 0x74, 0x61, 0x69, 0x6E, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6F, 0x72, 0x72, 0x65, 0x63, 0x74, 0x20, 0x69, + 0x6E, 0x64, 0x65, 0x6E, 0x74, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2E, 0x3C, 0x50, 0x3E, 0x20, 0x0A, 0x0A, 0x3C, 0x42, + 0x3E, 0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65, 0x20, 0x43, 0x6C, 0x61, 0x73, 0x73, 0x20, 0x57, 0x69, 0x7A, + 0x61, 0x72, 0x64, 0x3A, 0x3C, 0x2F, 0x42, 0x3E, 0x3C, 0x42, 0x52, 0x3E, 0x0A, 0x48, 0x65, 0x72, 0x65, 0x20, 0x79, + 0x6F, 0x75, 0x20, 0x63, 0x61, 0x6E, 0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x74, 0x65, 0x6D, 0x70, 0x6C, + 0x61, 0x74, 0x65, 0x73, 0x20, 0x6F, 0x66, 0x20, 0x63, 0x6C, 0x61, 0x73, 0x73, 0x65, 0x73, 0x20, 0x74, 0x68, 0x61, + 0x74, 0x20, 0x79, 0x6F, 0x75, 0x20, 0x6F, 0x66, 0x74, 0x65, 0x6E, 0x20, 0x75, 0x73, 0x65, 0x2E, 0x20, 0x57, 0x68, + 0x65, 0x6E, 0x20, 0x79, 0x6F, 0x75, 0x20, 0x69, 0x6E, 0x73, 0x65, 0x72, 0x74, 0x20, 0x6F, 0x6E, 0x65, 0x20, 0x69, + 0x6E, 0x74, 0x6F, 0x20, 0x79, 0x6F, 0x75, 0x72, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x2C, 0x20, 0x61, 0x6C, 0x6C, 0x20, + 0x6F, 0x63, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6E, 0x63, 0x65, 0x73, 0x20, 0x6F, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, + 0x6B, 0x65, 0x79, 0x77, 0x6F, 0x72, 0x64, 0x20, 0x3C, 0x43, 0x4F, 0x44, 0x45, 0x3E, 0x25, 0x43, 0x4C, 0x41, 0x53, + 0x53, 0x25, 0x3C, 0x2F, 0x43, 0x4F, 0x44, 0x45, 0x3E, 0x20, 0x61, 0x72, 0x65, 0x20, 0x72, 0x65, 0x70, 0x6C, 0x61, + 0x63, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x61, 0x20, 0x63, 0x6C, 0x61, 0x73, 0x73, 0x20, 0x6E, 0x61, + 0x6D, 0x65, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x79, 0x6F, 0x75, 0x20, 0x65, 0x6E, 0x74, 0x65, 0x72, 0x3B, 0x20, + 0x74, 0x68, 0x65, 0x6E, 0x20, 0x61, 0x70, 0x70, 0x72, 0x6F, 0x70, 0x72, 0x69, 0x61, 0x74, 0x65, 0x6C, 0x79, 0x2D, + 0x6E, 0x61, 0x6D, 0x65, 0x64, 0x20, 0x63, 0x70, 0x70, 0x20, 0x61, 0x6E, 0x64, 0x20, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, + 0x2C, 0x20, 0x63, 0x6F, 0x6E, 0x74, 0x61, 0x69, 0x6E, 0x69, 0x6E, 0x67, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6F, + 0x64, 0x65, 0x2E, 0x3C, 0x42, 0x52, 0x3E, 0x3C, 0x2F, 0x46, 0x4F, 0x4E, 0x54, 0x3E, 0x0A, 0x3C, 0x2F, 0x42, 0x4F, + 0x44, 0x59, 0x3E, 0x3C, 0x2F, 0x48, 0x54, 0x4D, 0x4C, 0x3E, 0x00}; diff --git a/SnipWiz/snipwiz.cpp b/SnipWiz/snipwiz.cpp index e2e086db2d..a4b8bd9150 100644 --- a/SnipWiz/snipwiz.cpp +++ b/SnipWiz/snipwiz.cpp @@ -33,10 +33,10 @@ // Copyright: 2008 Frank Lichtner // Licence: GNU General Public Licence ///////////////////////////////////////////////////////////////////////////// -#include "event_notifier.h" - #include +#include "event_notifier.h" + #ifndef WX_PRECOMP #include #endif @@ -69,10 +69,7 @@ //------------------------------------------------------------ // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new SnipWiz(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new SnipWiz(manager); } //------------------------------------------------------------ CL_PLUGIN_API PluginInfo* GetPluginInfo() @@ -119,20 +116,20 @@ SnipWiz::SnipWiz(IManager* manager) m_modified = false; m_StringDb.SetCompress(true); - if(!m_StringDb.Load(m_configPath + defaultTmplFile)) { + if (!m_StringDb.Load(m_configPath + defaultTmplFile)) { // For compatibility with CodeLite < 15.0.6: // we don't use this directory for storing templates anymore. wxString pluginPath = m_mgr->GetStartupDirectory(); pluginPath += wxFILE_SEP_PATH; pluginPath += wxT("templates"); pluginPath += wxFILE_SEP_PATH; - if(m_StringDb.Load(pluginPath + defaultTmplFile)) { + if (m_StringDb.Load(pluginPath + defaultTmplFile)) { m_modified = true; } } m_StringDb.GetAllSnippetKeys(m_snippets); - if(!m_snippets.GetCount()) { + if (!m_snippets.GetCount()) { IntSnippets(); m_StringDb.GetAllSnippetKeys(m_snippets); } @@ -145,7 +142,7 @@ SnipWiz::SnipWiz(IManager* manager) //------------------------------------------------------------ SnipWiz::~SnipWiz() { - if(m_modified) + if (m_modified) m_StringDb.Save(m_configPath + defaultTmplFile); } //------------------------------------------------------------ @@ -165,13 +162,13 @@ void SnipWiz::CreatePluginMenu(wxMenu* pluginsMenu) pluginsMenu->Append(wxID_ANY, _("SnipWiz"), menu); - m_topWin->Connect(IDM_SETTINGS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnSettings), NULL, - this); - m_topWin->Connect(IDM_CLASS_WIZ, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnClassWizard), NULL, - this); + m_topWin->Connect( + IDM_SETTINGS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnSettings), NULL, this); + m_topWin->Connect( + IDM_CLASS_WIZ, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnClassWizard), NULL, this); - m_topWin->Connect(IDM_EXP_SWITCH, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnMenuExpandSwitch), - NULL, this); + m_topWin->Connect( + IDM_EXP_SWITCH, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnMenuExpandSwitch), NULL, this); m_topWin->Connect(IDM_PASTE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnMenuPaste), NULL, this); AttachDynMenus(); } @@ -179,7 +176,7 @@ void SnipWiz::CreatePluginMenu(wxMenu* pluginsMenu) //------------------------------------------------------------ void SnipWiz::HookPopupMenu(wxMenu* menu, MenuType type) { - if(type == MenuTypeFileView_Folder) { + if (type == MenuTypeFileView_Folder) { // Create the popup menu for the virtual folders wxMenuItem* item(NULL); @@ -197,15 +194,15 @@ void SnipWiz::HookPopupMenu(wxMenu* menu, MenuType type) void SnipWiz::UnPlug() { - m_topWin->Disconnect(IDM_SETTINGS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnSettings), NULL, - this); - m_topWin->Disconnect(IDM_CLASS_WIZ, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnClassWizard), - NULL, this); - - m_topWin->Disconnect(IDM_EXP_SWITCH, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(SnipWiz::OnMenuExpandSwitch), NULL, this); - m_topWin->Disconnect(IDM_PASTE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnMenuPaste), NULL, - this); + m_topWin->Disconnect( + IDM_SETTINGS, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnSettings), NULL, this); + m_topWin->Disconnect( + IDM_CLASS_WIZ, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnClassWizard), NULL, this); + + m_topWin->Disconnect( + IDM_EXP_SWITCH, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnMenuExpandSwitch), NULL, this); + m_topWin->Disconnect( + IDM_PASTE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SnipWiz::OnMenuPaste), NULL, this); EventNotifier::Get()->Unbind(wxEVT_CONTEXT_MENU_FOLDER, &SnipWiz::OnFolderContextMenu, this); EventNotifier::Get()->Unbind(wxEVT_CONTEXT_MENU_EDITOR, &SnipWiz::OnEditorContextMenu, this); DetachDynMenus(); @@ -215,33 +212,33 @@ void SnipWiz::UnPlug() void SnipWiz::OnMenuExpandSwitch(wxCommandEvent& e) { IEditor* editor = GetEditor(); - if(!editor) + if (!editor) return; bool isSelection = false; wxString var = editor->GetSelection(); - if(!var.IsEmpty()) + if (!var.IsEmpty()) isSelection = true; var = ::wxGetTextFromUser(_("Enter identifier name"), _("switch(...)"), var); - if(var.IsEmpty()) + if (var.IsEmpty()) return; long count = ::wxGetNumberFromUser(_("Enter number of cases"), _("Cases:"), _("switch(...)"), 1, 1, 20); - if(count < 1) + if (count < 1) return; int curEol = editor->GetEOL(); int curPos = editor->GetCurrentPosition(); wxString tabs = GetTabs(editor, curPos); - wxString output = wxString::Format(wxT("switch( %s )%s%s{%s"), var.c_str(), eol[curEol].c_str(), tabs.c_str(), - eol[curEol].c_str()); - for(long i = 0; i < count; i++) - output += wxString::Format(wxT("%scase :%s%sbreak;%s"), tabs.c_str(), eol[curEol].c_str(), tabs.c_str(), - eol[curEol].c_str()); + wxString output = wxString::Format( + wxT("switch( %s )%s%s{%s"), var.c_str(), eol[curEol].c_str(), tabs.c_str(), eol[curEol].c_str()); + for (long i = 0; i < count; i++) + output += wxString::Format( + wxT("%scase :%s%sbreak;%s"), tabs.c_str(), eol[curEol].c_str(), tabs.c_str(), eol[curEol].c_str()); output += tabs.c_str(); output += wxT("}"); - if(isSelection) + if (isSelection) editor->ReplaceSelection(output); else editor->InsertText(curPos, output); @@ -251,25 +248,25 @@ void SnipWiz::OnMenuExpandSwitch(wxCommandEvent& e) void SnipWiz::OnMenuSnippets(wxCommandEvent& e) { IEditor* editor = GetEditor(); - if(!editor) + if (!editor) return; bool crtl = ::wxGetKeyState(WXK_CONTROL); bool sourceIsMenu(false); wxMenu* m = dynamic_cast(e.GetEventObject()); - if(m) { + if (m) { sourceIsMenu = true; } - if(e.GetId() >= IDM_ADDSTART && e.GetId() < (IDM_ADDSTART + (int)m_snippets.GetCount())) { + if (e.GetId() >= IDM_ADDSTART && e.GetId() < (IDM_ADDSTART + (int)m_snippets.GetCount())) { wxString key = m_snippets.Item(e.GetId() - IDM_ADDSTART); wxString srText = m_StringDb.GetSnippetString(key); wxString selection = editor->GetSelection(); // replace template eols with current int curEol = editor->GetEOL(); - if(srText.Find(eol[2]) != wxNOT_FOUND) + if (srText.Find(eol[2]) != wxNOT_FOUND) srText.Replace(eol[2], eol[curEol].c_str()); // Replace any escaped carets/selection strings @@ -279,7 +276,7 @@ void SnipWiz::OnMenuSnippets(wxCommandEvent& e) srText.Replace(SELECTION, REAL_SELECTION_STR); // selection ? - if(srText.Find(REAL_SELECTION_STR) != wxNOT_FOUND) + if (srText.Find(REAL_SELECTION_STR) != wxNOT_FOUND) srText.Replace(REAL_SELECTION_STR, selection.c_str()); // restore the escaped selection, this time without the escaping backslash @@ -289,13 +286,13 @@ void SnipWiz::OnMenuSnippets(wxCommandEvent& e) srText.Replace(TMP_ESC_CARET_STR, CARET); // if the user pressed control while clicking - if(crtl && sourceIsMenu) { + if (crtl && sourceIsMenu) { m_clipboard = srText; // remove caret mark if there srText.Replace(REAL_CARET_STR, wxT("")); // copy text to clipboard - if(wxTheClipboard->Open()) { + if (wxTheClipboard->Open()) { wxTheClipboard->SetData(new wxTextDataObject(srText)); wxTheClipboard->Close(); } @@ -306,17 +303,17 @@ void SnipWiz::OnMenuSnippets(wxCommandEvent& e) wxString output = FormatOutput(editor, srText); int curPos = editor->GetCurrentPosition(); - if(selection.Len() != 0) { + if (selection.Len() != 0) { curPos = editor->GetSelectionStart(); } // get caret position long cursorPos = output.Find(REAL_CARET_STR); - if(cursorPos != wxNOT_FOUND) + if (cursorPos != wxNOT_FOUND) output.Remove(cursorPos, wxStrlen(REAL_CARET_STR)); editor->ReplaceSelection(output); // set caret - if(cursorPos != wxNOT_FOUND) + if (cursorPos != wxNOT_FOUND) editor->SetCaretAt(curPos + cursorPos); else editor->SetCaretAt(curPos + output.Len()); @@ -328,10 +325,10 @@ void SnipWiz::OnMenuPaste(wxCommandEvent& e) { wxUnusedVar(e); IEditor* editor = GetEditor(); - if(!editor) + if (!editor) return; - if(m_clipboard.IsEmpty()) + if (m_clipboard.IsEmpty()) return; // otherwise insert text wxString output = FormatOutput(editor, m_clipboard); @@ -339,11 +336,11 @@ void SnipWiz::OnMenuPaste(wxCommandEvent& e) int curPos = editor->GetCurrentPosition() - selection.Len(); // get caret position long cursorPos = output.Find(REAL_CARET_STR); - if(cursorPos != wxNOT_FOUND) + if (cursorPos != wxNOT_FOUND) output.Remove(cursorPos, wxStrlen(REAL_CARET_STR)); editor->ReplaceSelection(output); // set caret - if(cursorPos != wxNOT_FOUND) + if (cursorPos != wxNOT_FOUND) editor->SetCaretAt(curPos + cursorPos); else editor->SetCaretAt(curPos + output.Len()); @@ -365,7 +362,7 @@ wxMenu* SnipWiz::CreateSubMenu() wxMenu* parentMenu = new wxMenu(); wxMenuItem* item(NULL); - if(!m_clipboard.IsEmpty()) { + if (!m_clipboard.IsEmpty()) { item = new wxMenuItem(parentMenu, IDM_PASTE, _("Paste buffer"), _("Paste buffer"), wxITEM_NORMAL); parentMenu->Append(item); parentMenu->AppendSeparator(); @@ -374,7 +371,7 @@ wxMenu* SnipWiz::CreateSubMenu() parentMenu->Append(item); parentMenu->AppendSeparator(); - for(wxUint32 i = 0; i < m_snippets.GetCount(); i++) { + for (wxUint32 i = 0; i < m_snippets.GetCount(); i++) { item = new wxMenuItem(parentMenu, IDM_ADDSTART + i, m_snippets.Item(i), m_snippets.Item(i), wxITEM_NORMAL); parentMenu->Append(item); } @@ -388,7 +385,7 @@ void SnipWiz::OnSettings(wxCommandEvent& e) EditSnippetsDlg dlg(m_mgr->GetTheApp()->GetTopWindow(), this, m_mgr); dlg.ShowModal(); - if(dlg.GetModified()) { + if (dlg.GetModified()) { m_snippets.Clear(); m_StringDb.GetAllSnippetKeys(m_snippets); m_snippets.Sort(); @@ -421,15 +418,23 @@ void SnipWiz::IntSnippets() // detach dynamic menus void SnipWiz::DetachDynMenus() { - m_topWin->Disconnect(IDM_ADDSTART, IDM_ADDSTART + m_snippets.GetCount() - 1, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(SnipWiz::OnMenuSnippets), NULL, this); + m_topWin->Disconnect(IDM_ADDSTART, + IDM_ADDSTART + m_snippets.GetCount() - 1, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(SnipWiz::OnMenuSnippets), + NULL, + this); } //------------------------------------------------------------ // attach dynamic menus void SnipWiz::AttachDynMenus() { - m_topWin->Connect(IDM_ADDSTART, IDM_ADDSTART + m_snippets.GetCount() - 1, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(SnipWiz::OnMenuSnippets), NULL, this); + m_topWin->Connect(IDM_ADDSTART, + IDM_ADDSTART + m_snippets.GetCount() - 1, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(SnipWiz::OnMenuSnippets), + NULL, + this); } //------------------------------------------------------------ // find current indentation @@ -439,8 +444,8 @@ long SnipWiz::GetCurrentIndentation(IEditor* pEditor, long pos) long tabCount = 0; wxChar ch = (pEditor->GetEOL() == 1) ? wxT('\r') : wxT('\n'); buffer = buffer.AfterLast(ch); - for(long i = 0; i < (long)buffer.Len(); i++) - if(buffer.GetChar(i) == wxT('\t')) + for (long i = 0; i < (long)buffer.Len(); i++) + if (buffer.GetChar(i) == wxT('\t')) tabCount++; return tabCount; @@ -451,7 +456,7 @@ wxString SnipWiz::GetTabs(IEditor* pEditor, long pos) { long indent = GetCurrentIndentation(pEditor, pos); wxString tabs = wxT(""); - for(long i = 0; i < indent; i++) + for (long i = 0; i < indent; i++) tabs += wxT("\t"); return tabs; } @@ -461,7 +466,7 @@ wxString SnipWiz::GetTabs(IEditor* pEditor, long pos) IEditor* SnipWiz::GetEditor() { IEditor* editor = m_mgr->GetActiveEditor(); - if(!editor) { + if (!editor) { ::wxMessageBox(noEditor, codeLite, wxICON_WARNING | wxOK); return NULL; } @@ -476,7 +481,7 @@ void SnipWiz::OnClassWizard(wxCommandEvent& e) dlg.SetCurEol(GetEOLByOS()); dlg.SetConfigPath(m_configPath); dlg.ShowModal(); - if(dlg.GetModified()) { + if (dlg.GetModified()) { m_modified = true; } } @@ -487,7 +492,7 @@ void SnipWiz::OnEditorContextMenu(clContextMenuEvent& event) IEditor* editor = m_mgr->GetActiveEditor(); CHECK_PTR_RET(editor); - if(FileExtManager::IsCxxFile(editor->GetFileName())) { + if (FileExtManager::IsCxxFile(editor->GetFileName())) { wxMenu* newMenu = CreateSubMenu(); event.GetMenu()->Append(wxID_ANY, _("Snippets"), newMenu); } diff --git a/SnipWiz/snipwiz.h b/SnipWiz/snipwiz.h index 67a1dff956..08e3d5165d 100644 --- a/SnipWiz/snipwiz.h +++ b/SnipWiz/snipwiz.h @@ -40,6 +40,7 @@ #include "cl_command_event.h" #include "plugin.h" #include "swStringDb.h" + #include class wxMenuItem; diff --git a/SnipWiz/swGlobals.h b/SnipWiz/swGlobals.h index ddb41d047d..78457036a4 100644 --- a/SnipWiz/swGlobals.h +++ b/SnipWiz/swGlobals.h @@ -1,50 +1,50 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : swGlobals.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////////////////////////////////////// -// Name: swGlobals.h -// Purpose: -// Author: Frank Lichtner -// Modified by: -// Created: 09/02/08 -// RCS-ID: -// Copyright: 2008 Frank Lichtner -// Licence: GNU General Public Licence -///////////////////////////////////////////////////////////////////////////// -//------------------------------------------------------------ - -#define FRLSNIPWIZ_VERSION 1000 -#define FRLSNIPWIZ_HEADER _T("Code snippet wizard file") -//------------------------------------------------------------ -static const wxString snippetSet = wxT( "Snippets" ); -static const wxString surroundSet = wxT( "Surrounds" ); - -static const wxString eol[3] = { wxT( "\r\n" ), wxT( "\r" ), wxT( "\n" ) }; -static const wxString defaultFile = wxT( "SnipWiz.snip" ); -static const wxString defaultTmplFile = wxT( "SnipWiz.tmpl" ); -static const wxString plugName = wxT( "SnipWiz" ); - -static const wxString noEditor = _("There is no active editor\n"); -static const wxString codeLite = wxT("CodeLite"); +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2008 by Eran Ifrah +// file name : swGlobals.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// +// Name: swGlobals.h +// Purpose: +// Author: Frank Lichtner +// Modified by: +// Created: 09/02/08 +// RCS-ID: +// Copyright: 2008 Frank Lichtner +// Licence: GNU General Public Licence +///////////////////////////////////////////////////////////////////////////// +//------------------------------------------------------------ + +#define FRLSNIPWIZ_VERSION 1000 +#define FRLSNIPWIZ_HEADER _T("Code snippet wizard file") +//------------------------------------------------------------ +static const wxString snippetSet = wxT("Snippets"); +static const wxString surroundSet = wxT("Surrounds"); + +static const wxString eol[3] = {wxT("\r\n"), wxT("\r"), wxT("\n")}; +static const wxString defaultFile = wxT("SnipWiz.snip"); +static const wxString defaultTmplFile = wxT("SnipWiz.tmpl"); +static const wxString plugName = wxT("SnipWiz"); + +static const wxString noEditor = _("There is no active editor\n"); +static const wxString codeLite = wxT("CodeLite"); diff --git a/SnipWiz/swStringDb.cpp b/SnipWiz/swStringDb.cpp index ac78b5933c..35b2814723 100644 --- a/SnipWiz/swStringDb.cpp +++ b/SnipWiz/swStringDb.cpp @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : swStringDb.cpp -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2008 by Eran Ifrah +// file name : swStringDb.cpp +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// // Name: swStringDb.cpp // Purpose: @@ -34,11 +34,11 @@ // License: GNU General Public Licence ///////////////////////////////////////////////////////////////////////////// - // For compilers that support precompilation, includes "wx/wx.h". +#include + #include #include -#include #ifdef __BORLANDC__ #pragma hdrstop @@ -54,368 +54,322 @@ #include //------------------------------------------------------------ -#define FRLSWTMPL_VERSION 1000 -#define FRLSWTMPL_HEADER wxT("SnipWiz string db") +#define FRLSWTMPL_VERSION 1000 +#define FRLSWTMPL_HEADER wxT("SnipWiz string db") //------------------------------------------------------------ -IMPLEMENT_DYNAMIC_CLASS(swBase,wxObject) -IMPLEMENT_DYNAMIC_CLASS(swString,swBase) -IMPLEMENT_DYNAMIC_CLASS(swStringSet,wxObject) -IMPLEMENT_DYNAMIC_CLASS(swStringDb,wxObject) +IMPLEMENT_DYNAMIC_CLASS(swBase, wxObject) +IMPLEMENT_DYNAMIC_CLASS(swString, swBase) +IMPLEMENT_DYNAMIC_CLASS(swStringSet, wxObject) +IMPLEMENT_DYNAMIC_CLASS(swStringDb, wxObject) //------------------------------------------------------------ //------------------------------------------------------------ // Destructor -swStringSet::~swStringSet() -{ - DeleteAll(); -} +swStringSet::~swStringSet() { DeleteAll(); } //------------------------------------------------------------ // save list void swStringSet::Serialize(wxSerialize& ar) { - swString* pObj = NULL; - wxUint32 size; - wxString classname; - - if (ar.IsStoring()) - { // storing - size = m_list.size(); - ar << size; - for (const auto& [key, base] : m_list) - { - ar << key; - pObj = wxDynamicCast(base, swString); - classname = pObj->GetClassInfo()->GetClassName(); - ar << classname; - pObj->Serialize(ar); - } - } - else - { // loading - DeleteAll(); - ar >> size; - for(wxUint32 i = 0;i < size;i++) - { - wxString key; - ar >> key; - ar >> classname; - pObj = wxDynamicCast(::wxCreateDynamicObject(classname), swString); - if(pObj != NULL) - { - pObj->Serialize(ar); - m_list[key] = pObj; - } - } - } + swString* pObj = NULL; + wxUint32 size; + wxString classname; + + if (ar.IsStoring()) { // storing + size = m_list.size(); + ar << size; + for (const auto& [key, base] : m_list) { + ar << key; + pObj = wxDynamicCast(base, swString); + classname = pObj->GetClassInfo()->GetClassName(); + ar << classname; + pObj->Serialize(ar); + } + } else { // loading + DeleteAll(); + ar >> size; + for (wxUint32 i = 0; i < size; i++) { + wxString key; + ar >> key; + ar >> classname; + pObj = wxDynamicCast(::wxCreateDynamicObject(classname), swString); + if (pObj != NULL) { + pObj->Serialize(ar); + m_list[key] = pObj; + } + } + } } //------------------------------------------------------------ // deletes all entries from list void swStringSet::DeleteAll() { - wxArrayString keys; + wxArrayString keys; - for (const auto& [name, _] : m_list) - keys.Add(name); - for (const auto& key : keys) - DeleteKey(key); + for (const auto& [name, _] : m_list) + keys.Add(name); + for (const auto& key : keys) + DeleteKey(key); } //------------------------------------------------------------ // deletes one key void swStringSet::DeleteKey(const wxString& key) { - - swString* pObj = NULL; - swStringList::iterator it = m_list.find(key); - if(it == m_list.end()) - return; - pObj = (swString*)m_list[key]; - delete pObj; - m_list.erase(key); + + swString* pObj = NULL; + swStringList::iterator it = m_list.find(key); + if (it == m_list.end()) + return; + pObj = (swString*)m_list[key]; + delete pObj; + m_list.erase(key); } //------------------------------------------------------------ // return string found for key wxString swStringSet::GetString(const wxString& key) { - swString* pObj = NULL; - - swStringList::iterator it = m_list.find(key); - if(it == m_list.end()) - { - return wxEmptyString; - } - else - { - pObj = wxDynamicCast(m_list[key],swString); - if(pObj != NULL) - return pObj->m_string; - else - return wxEmptyString; - } + swString* pObj = NULL; + + swStringList::iterator it = m_list.find(key); + if (it == m_list.end()) { + return wxEmptyString; + } else { + pObj = wxDynamicCast(m_list[key], swString); + if (pObj != NULL) + return pObj->m_string; + else + return wxEmptyString; + } } //------------------------------------------------------------ // writes string with key bool swStringSet::SetString(const wxString& key, const wxString& value) { - swString* pObj = NULL; + swString* pObj = NULL; + + swStringList::iterator it = m_list.find(key); + + if (it == m_list.end()) + m_list[key] = new swString; - swStringList::iterator it = m_list.find(key); + pObj = wxDynamicCast(m_list[key], swString); + if (!pObj) + return false; - if(it == m_list.end()) - m_list[key] = new swString; - - pObj = wxDynamicCast(m_list[key],swString); - if(!pObj) - return false; - - pObj->m_string = value; - m_list[key] = pObj; + pObj->m_string = value; + m_list[key] = pObj; - return true; + return true; } //------------------------------------------------------------ // checks if key exists -bool swStringSet::IsKey(const wxString & key) +bool swStringSet::IsKey(const wxString& key) { - bool found; - - if(m_list.find(key) == m_list.end()) - found = false; - else - found = true; - return found; + bool found; + + if (m_list.find(key) == m_list.end()) + found = false; + else + found = true; + return found; } //------------------------------------------------------------ // returns a list with all keys -void swStringSet::GetAllKeys(wxArrayString &keys) +void swStringSet::GetAllKeys(wxArrayString& keys) { - keys.Clear(); - for (const auto& [key, _] : m_list) - { - keys.Add(key); - } + keys.Clear(); + for (const auto& [key, _] : m_list) { + keys.Add(key); + } } //------------------------------------------------------------ // string database //------------------------------------------------------------ -swStringDb::swStringDb() -{ - m_compress = false; -} +swStringDb::swStringDb() { m_compress = false; } //------------------------------------------------------------ -swStringDb::~swStringDb() -{ -} +swStringDb::~swStringDb() {} //------------------------------------------------------------ void swStringDb::DeleteAll() { - for (const auto& [_, pObj] : m_list) - { - pObj->DeleteAll(); - delete pObj; - } - m_list.clear(); + for (const auto& [_, pObj] : m_list) { + pObj->DeleteAll(); + delete pObj; + } + m_list.clear(); } //------------------------------------------------------------ void swStringDb::DeleteKey(const wxString& set, const wxString& key) { - swStringSet* pSet = NULL; - - pSet = m_list[set]; - if(pSet != NULL) - pSet->DeleteKey(key); - // if set is empty, remove it - if(pSet->m_list.size() == 0) - { - swStringSetList::iterator it = m_list.find(set); - delete (swStringSet*) pSet; - m_list.erase(it); - } + swStringSet* pSet = NULL; + + pSet = m_list[set]; + if (pSet != NULL) + pSet->DeleteKey(key); + // if set is empty, remove it + if (pSet->m_list.size() == 0) { + swStringSetList::iterator it = m_list.find(set); + delete (swStringSet*)pSet; + m_list.erase(it); + } } //------------------------------------------------------------ wxString swStringDb::GetString(const wxString& set, const wxString& key) { - swStringSet* pSet = NULL; + swStringSet* pSet = NULL; - pSet = m_list[set]; - if(pSet != NULL) - return pSet->GetString(key); - else - return wxEmptyString; + pSet = m_list[set]; + if (pSet != NULL) + return pSet->GetString(key); + else + return wxEmptyString; } //------------------------------------------------------------ bool swStringDb::SetString(const wxString& set, const wxString& key, const wxString& value) { - swStringSet* pSet = NULL; - - pSet = m_list[set]; - if(pSet == NULL) - pSet = new swStringSet; - - pSet->SetString(key,value); - m_list[set] = pSet; - - return true; + swStringSet* pSet = NULL; + + pSet = m_list[set]; + if (pSet == NULL) + pSet = new swStringSet; + + pSet->SetString(key, value); + m_list[set] = pSet; + + return true; } //------------------------------------------------------------ bool swStringDb::Load(const wxString& filename) { - wxFileName fullname(filename); - if(!fullname.FileExists()) - return false; - wxFileInputStream infile(filename); - wxZlibInputStream infile1(infile); - if(!infile.Ok()) - return false; - - if(m_compress) - { - wxSerialize ar(infile1, FRLSWTMPL_VERSION, FRLSWTMPL_HEADER); - if(ar.IsOk()) - Serialize(ar); - else - return false; - } - else - { - wxSerialize ar(infile, FRLSWTMPL_VERSION, FRLSWTMPL_HEADER); - if(ar.IsOk()) - Serialize(ar); - else - return false; - } - return true; + wxFileName fullname(filename); + if (!fullname.FileExists()) + return false; + wxFileInputStream infile(filename); + wxZlibInputStream infile1(infile); + if (!infile.Ok()) + return false; + + if (m_compress) { + wxSerialize ar(infile1, FRLSWTMPL_VERSION, FRLSWTMPL_HEADER); + if (ar.IsOk()) + Serialize(ar); + else + return false; + } else { + wxSerialize ar(infile, FRLSWTMPL_VERSION, FRLSWTMPL_HEADER); + if (ar.IsOk()) + Serialize(ar); + else + return false; + } + return true; } //------------------------------------------------------------ bool swStringDb::Save(const wxString& filename) { - wxFileOutputStream outfile(filename); - wxZlibOutputStream outfile1(outfile); - if(!outfile.Ok()) - return false; - - if(m_compress) - { - wxSerialize ar(outfile1, FRLSWTMPL_VERSION, FRLSWTMPL_HEADER); - if(ar.IsOk()) - Serialize(ar); - else - return false; - } - else - { - wxSerialize ar(outfile, FRLSWTMPL_VERSION, FRLSWTMPL_HEADER); - if(ar.IsOk()) - Serialize(ar); - else - return false; - } - - return true; + wxFileOutputStream outfile(filename); + wxZlibOutputStream outfile1(outfile); + if (!outfile.Ok()) + return false; + + if (m_compress) { + wxSerialize ar(outfile1, FRLSWTMPL_VERSION, FRLSWTMPL_HEADER); + if (ar.IsOk()) + Serialize(ar); + else + return false; + } else { + wxSerialize ar(outfile, FRLSWTMPL_VERSION, FRLSWTMPL_HEADER); + if (ar.IsOk()) + Serialize(ar); + else + return false; + } + + return true; } //------------------------------------------------------------ void swStringDb::Serialize(wxSerialize& ar) { - swStringSetList::iterator it; - - wxUint32 size; - wxString classname, dummy; - - if (ar.IsStoring()) - { // storing - size = m_list.size(); - ar << size; - for (const auto& [key, pObj] : m_list) - { - ar << key; - classname = pObj->GetClassInfo()->GetClassName(); - ar << classname; - pObj->Serialize(ar); - } - ar << m_keyOrder; - m_snippetSet.Serialize(ar); - } - else - { // loading - DeleteAll(); - ar >> size; - for(wxUint32 i = 0;i < size;i++) - { - wxString key; - ar >> key; - ar >> classname; - auto pObj = wxDynamicCast(::wxCreateDynamicObject(classname), swStringSet); - if(pObj != NULL) - { - pObj->Serialize(ar); - m_list[key] = pObj; - } - } - ar >> m_keyOrder; - m_snippetSet.DeleteAll(); - m_snippetSet.Serialize(ar); - } - + swStringSetList::iterator it; + + wxUint32 size; + wxString classname, dummy; + + if (ar.IsStoring()) { // storing + size = m_list.size(); + ar << size; + for (const auto& [key, pObj] : m_list) { + ar << key; + classname = pObj->GetClassInfo()->GetClassName(); + ar << classname; + pObj->Serialize(ar); + } + ar << m_keyOrder; + m_snippetSet.Serialize(ar); + } else { // loading + DeleteAll(); + ar >> size; + for (wxUint32 i = 0; i < size; i++) { + wxString key; + ar >> key; + ar >> classname; + auto pObj = wxDynamicCast(::wxCreateDynamicObject(classname), swStringSet); + if (pObj != NULL) { + pObj->Serialize(ar); + m_list[key] = pObj; + } + } + ar >> m_keyOrder; + m_snippetSet.DeleteAll(); + m_snippetSet.Serialize(ar); + } } //------------------------------------------------------------ void swStringDb::GetAllSets(wxArrayString& sets) { - sets.Clear(); - for (const auto& [set, _] : m_list) - { - sets.Add(set); - } + sets.Clear(); + for (const auto& [set, _] : m_list) { + sets.Add(set); + } } //------------------------------------------------------------ bool swStringDb::IsSet(const wxString& set) { - if(m_list.find(set)== m_list.end()) - return false; - return true; + if (m_list.find(set) == m_list.end()) + return false; + return true; } //------------------------------------------------------------ -void swStringDb::DeleteSnippetKey(const wxString& key) -{ - m_snippetSet.DeleteKey(key); -} +void swStringDb::DeleteSnippetKey(const wxString& key) { m_snippetSet.DeleteKey(key); } //------------------------------------------------------------ -void swStringDb::GetAllSnippetKeys(wxArrayString& keys) -{ - m_snippetSet.GetAllKeys(keys); -} +void swStringDb::GetAllSnippetKeys(wxArrayString& keys) { m_snippetSet.GetAllKeys(keys); } //------------------------------------------------------------ -wxString swStringDb::GetSnippetString(const wxString& key) -{ - return m_snippetSet.GetString(key); -} +wxString swStringDb::GetSnippetString(const wxString& key) { return m_snippetSet.GetString(key); } //------------------------------------------------------------ -bool swStringDb::IsSnippetKey(const wxString& key) -{ - return m_snippetSet.IsKey(key); -} +bool swStringDb::IsSnippetKey(const wxString& key) { return m_snippetSet.IsKey(key); } //------------------------------------------------------------ bool swStringDb::SetSnippetString(const wxString& key, const wxString& value) { - return m_snippetSet.SetString(key, value); + return m_snippetSet.SetString(key, value); } //------------------------------------------------------------ diff --git a/SnipWiz/swStringDb.h b/SnipWiz/swStringDb.h index d3f4e80638..6f42672ed8 100644 --- a/SnipWiz/swStringDb.h +++ b/SnipWiz/swStringDb.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : swStringDb.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2008 by Eran Ifrah +// file name : swStringDb.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////////////////// // Name: swStringDb.h // Purpose: @@ -42,115 +42,116 @@ // base class for one entry class swBase : public wxObject { - DECLARE_DYNAMIC_CLASS( swBase ); + DECLARE_DYNAMIC_CLASS(swBase); public: - swBase() = default; - virtual ~swBase() = default; + swBase() = default; + virtual ~swBase() = default; - virtual void Serialize( wxSerialize& ar ) { wxUnusedVar( ar ); } + virtual void Serialize(wxSerialize& ar) { wxUnusedVar(ar); } }; //------------------------------------------------------------ -WX_DECLARE_STRING_HASH_MAP( swBase*, swStringList ); +WX_DECLARE_STRING_HASH_MAP(swBase*, swStringList); //------------------------------------------------------------ // one single string entry class swString : public swBase { - DECLARE_DYNAMIC_CLASS( swString ); - friend class swStringSet; + DECLARE_DYNAMIC_CLASS(swString); + friend class swStringSet; + public: - swString() = default; - virtual ~swString() = default; + swString() = default; + virtual ~swString() = default; - void Serialize( wxSerialize& ar ) - { - if ( ar.IsStoring() ) - ar << m_string; - else - ar >> m_string; - } + void Serialize(wxSerialize& ar) + { + if (ar.IsStoring()) + ar << m_string; + else + ar >> m_string; + } protected: - wxString m_string; + wxString m_string; }; //------------------------------------------------------------ // one set of swStrings class swStringSet : public wxObject { - friend class swStringDb; - DECLARE_DYNAMIC_CLASS( swStringSet ); + friend class swStringDb; + DECLARE_DYNAMIC_CLASS(swStringSet); public: - /// check if it is existing key - bool IsKey( const wxString & key ); - /// returns all keys - void GetAllKeys( wxArrayString &keys ); - /// set string value at key - bool SetString( const wxString& key, const wxString& value ); - /// get string value at key - wxString GetString( const wxString& key ); - /// delete single key - void DeleteKey( const wxString& key ); - /// delete all keys - void DeleteAll(); - - swStringSet() = default; - virtual ~swStringSet(); - - void Serialize( wxSerialize& ar ); + /// check if it is existing key + bool IsKey(const wxString& key); + /// returns all keys + void GetAllKeys(wxArrayString& keys); + /// set string value at key + bool SetString(const wxString& key, const wxString& value); + /// get string value at key + wxString GetString(const wxString& key); + /// delete single key + void DeleteKey(const wxString& key); + /// delete all keys + void DeleteAll(); + + swStringSet() = default; + virtual ~swStringSet(); + + void Serialize(wxSerialize& ar); protected: - swStringList m_list; // string set + swStringList m_list; // string set }; //------------------------------------------------------------ -WX_DECLARE_STRING_HASH_MAP( swStringSet*, swStringSetList ); +WX_DECLARE_STRING_HASH_MAP(swStringSet*, swStringSetList); //------------------------------------------------------------ class swStringDb : public wxObject { - DECLARE_DYNAMIC_CLASS( swStringDb ); + DECLARE_DYNAMIC_CLASS(swStringDb); public: -// template access - /// if true, the file will be compressed - void SetCompress( bool compress ) { m_compress = compress; } - /// save StringDb - bool Save( const wxString& filename ); - /// load StringDb - bool Load( const wxString& filename ); - /// check if set exists - bool IsSet( const wxString & set ); - /// returns all sets - void GetAllSets( wxArrayString &sets ); - /// sets string at set, key - bool SetString( const wxString & set, const wxString& key, const wxString& value ); - /// gets string at set, key - wxString GetString( const wxString & set, const wxString& key ); - /// deletes single key - void DeleteKey( const wxString & set, const wxString& key ); - /// deletes all - void DeleteAll(); - -// snippet access - /// checks if key exists - bool IsSnippetKey( const wxString & key ); - /// eturns all keys - void GetAllSnippetKeys( wxArrayString &keys ); - /// sets string at key - bool SetSnippetString( const wxString& key, const wxString& value ); - /// gets string at key - wxString GetSnippetString( const wxString& key ); - /// deletes single key - void DeleteSnippetKey( const wxString& key ); - - swStringDb(); - virtual ~swStringDb(); - void Serialize( wxSerialize& ar ); + // template access + /// if true, the file will be compressed + void SetCompress(bool compress) { m_compress = compress; } + /// save StringDb + bool Save(const wxString& filename); + /// load StringDb + bool Load(const wxString& filename); + /// check if set exists + bool IsSet(const wxString& set); + /// returns all sets + void GetAllSets(wxArrayString& sets); + /// sets string at set, key + bool SetString(const wxString& set, const wxString& key, const wxString& value); + /// gets string at set, key + wxString GetString(const wxString& set, const wxString& key); + /// deletes single key + void DeleteKey(const wxString& set, const wxString& key); + /// deletes all + void DeleteAll(); + + // snippet access + /// checks if key exists + bool IsSnippetKey(const wxString& key); + /// eturns all keys + void GetAllSnippetKeys(wxArrayString& keys); + /// sets string at key + bool SetSnippetString(const wxString& key, const wxString& value); + /// gets string at key + wxString GetSnippetString(const wxString& key); + /// deletes single key + void DeleteSnippetKey(const wxString& key); + + swStringDb(); + virtual ~swStringDb(); + void Serialize(wxSerialize& ar); protected: - swStringSetList m_list; // template list - swStringSet m_snippetSet; // snippet list - bool m_compress; // compress flag - wxArrayString m_keyOrder; // array to sort snippets menu by user (future) + swStringSetList m_list; // template list + swStringSet m_snippetSet; // snippet list + bool m_compress; // compress flag + wxArrayString m_keyOrder; // array to sort snippets menu by user (future) }; -#endif //SWTEMPLATEFILE_H +#endif // SWTEMPLATEFILE_H diff --git a/SnipWiz/templateclassdlg.cpp b/SnipWiz/templateclassdlg.cpp index 5fc6488d7b..826639e7a1 100644 --- a/SnipWiz/templateclassdlg.cpp +++ b/SnipWiz/templateclassdlg.cpp @@ -58,7 +58,7 @@ TemplateClassDlg::TemplateClassDlg(wxWindow* parent, SnipWiz* plugin, IManager* void TemplateClassDlg::Initialize() { LexerConf::Ptr_t cppLexer = ColoursAndFontsManager::Get().GetLexer("c++"); - if(cppLexer) { + if (cppLexer) { cppLexer->Apply(m_textCtrlHeader, true); cppLexer->Apply(m_textCtrlImpl, true); } @@ -67,11 +67,11 @@ void TemplateClassDlg::Initialize() wxArrayString templates; GetStringDb()->GetAllSets(templates); - for(wxUint32 i = 0; i < templates.GetCount(); i++) { + for (wxUint32 i = 0; i < templates.GetCount(); i++) { m_comboxTemplates->AppendString(templates[i]); m_comboxCurrentTemplate->AppendString(templates[i]); } - if(templates.GetCount()) { + if (templates.GetCount()) { m_comboxTemplates->Select(0); wxString set = m_comboxTemplates->GetValue(); m_textCtrlHeader->SetValue(GetStringDb()->GetString(set, swHeader)); @@ -79,24 +79,24 @@ void TemplateClassDlg::Initialize() m_comboxCurrentTemplate->Select(0); } TreeItemInfo item = m_pManager->GetSelectedTreeItemInfo(TreeFileView); - if(item.m_item.IsOk() && item.m_itemType == ProjectItem::TypeVirtualDirectory) { + if (item.m_item.IsOk() && item.m_itemType == ProjectItem::TypeVirtualDirectory) { m_virtualFolder = VirtualDirectorySelectorDlg::DoGetPath(m_pManager->GetWorkspaceTree(), item.m_item, false); m_projectPath = item.m_fileName.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR); } m_textCtrlVD->SetValue(m_virtualFolder); - if(clCxxWorkspaceST::Get()->IsOpen()) { + if (clCxxWorkspaceST::Get()->IsOpen()) { wxString project, vd; project = m_virtualFolder.BeforeFirst(wxT(':')); vd = m_virtualFolder.AfterFirst(wxT(':')); ProjectPtr proj = clCxxWorkspaceST::Get()->GetProject(project); - if(proj) { + if (proj) { m_projectPath = proj->GetBestPathForVD(vd); } } - if(m_virtualFolder.IsEmpty() == false) { + if (m_virtualFolder.IsEmpty() == false) { m_staticProjectTreeFolder->SetForegroundColour(wxColour(0, 128, 0)); } m_textCtrlFilePath->SetValue(m_projectPath); @@ -107,7 +107,7 @@ void TemplateClassDlg::OnClassNameEntered(wxCommandEvent& event) { wxUnusedVar(event); wxString buffer = m_textCtrlClassName->GetValue(); - if(buffer.IsEmpty()) { + if (buffer.IsEmpty()) { m_textCtrlHeaderFile->SetValue(wxT("")); m_textCtrlCppFile->SetValue(wxT("")); return; @@ -121,7 +121,7 @@ void TemplateClassDlg::OnBrowseVD(wxCommandEvent& event) { wxUnusedVar(event); VirtualDirectorySelectorDlg dlg(this, m_pManager->GetWorkspace(), m_textCtrlVD->GetValue()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { m_textCtrlVD->SetValue(dlg.GetVirtualDirectoryPath()); m_staticProjectTreeFolder->SetForegroundColour(wxColour(0, 128, 0)); m_staticProjectTreeFolder->Refresh(); @@ -132,12 +132,12 @@ void TemplateClassDlg::OnBrowseFilePath(wxCommandEvent& event) { wxUnusedVar(event); wxString dir = wxT(""); - if(wxFileName::DirExists(m_projectPath)) { + if (wxFileName::DirExists(m_projectPath)) { dir = m_projectPath; } dir = wxDirSelector(_("Select output folder"), dir, wxDD_DEFAULT_STYLE, wxDefaultPosition, this); - if(!dir.IsEmpty()) { + if (!dir.IsEmpty()) { m_projectPath = dir; m_textCtrlFilePath->SetValue(m_projectPath); } @@ -150,7 +150,7 @@ void TemplateClassDlg::OnGenerate(wxCommandEvent& event) wxString newClassName = m_textCtrlClassName->GetValue(); wxString baseClass = m_comboxCurrentTemplate->GetValue(); - if(!wxEndsWithPathSeparator(m_projectPath)) + if (!wxEndsWithPathSeparator(m_projectPath)) m_projectPath += wxFILE_SEP_PATH; wxString header_file_name = m_textCtrlHeaderFile->GetValue(); @@ -172,7 +172,7 @@ void TemplateClassDlg::OnGenerate(wxCommandEvent& event) // prepare the implementation file content + name // and save it to disk - if(!impl_file_content.empty()) { + if (!impl_file_content.empty()) { buffer = wxString::Format(wxT("#include \"%s\"%s%s"), header_file_name, eol[m_curEol], eol[m_curEol]); buffer += impl_file_content; buffer.Replace(swPhClass, newClassName); @@ -182,7 +182,7 @@ void TemplateClassDlg::OnGenerate(wxCommandEvent& event) } // if virtual directory is provided, add the files there - if(!vdpath.empty()) { + if (!vdpath.empty()) { // Create the Success message first, as 'files' may be altered during creation wxString msg; msg << wxString::Format(wxT("%s%s"), files.Item(0), eol[m_curEol]) @@ -193,8 +193,8 @@ void TemplateClassDlg::OnGenerate(wxCommandEvent& event) // So try to place the files appropriately. If that fails, dump both in the selected folder bool smartAddFiles = true; - if((smartAddFiles && m_pManager->AddFilesToVirtualFolderIntelligently(m_textCtrlVD->GetValue(), files)) || - m_pManager->AddFilesToVirtualFolder(m_textCtrlVD->GetValue(), files)) { + if ((smartAddFiles && m_pManager->AddFilesToVirtualFolderIntelligently(m_textCtrlVD->GetValue(), files)) || + m_pManager->AddFilesToVirtualFolder(m_textCtrlVD->GetValue(), files)) { wxMessageBox(msg, _("Add template class"), wxOK | wxCENTER | wxICON_INFORMATION, this); } else { EndModal(wxID_CANCEL); @@ -213,7 +213,7 @@ void TemplateClassDlg::OnGenerateUI(wxUpdateUIEvent& event) bool has_path = !m_textCtrlFilePath->GetValue().empty(); bool has_vd_path = !m_textCtrlVD->GetValue().empty(); bool enable_cond = has_name && has_header_name && has_template && has_path; - if(clCxxWorkspaceST::Get()->IsOpen()) { + if (clCxxWorkspaceST::Get()->IsOpen()) { enable_cond = enable_cond && has_vd_path; } event.Enable(enable_cond); @@ -230,7 +230,7 @@ void TemplateClassDlg::OnTemplateClassSelected(wxCommandEvent& event) { wxUnusedVar(event); wxString set = m_comboxTemplates->GetValue(); - if(GetStringDb()->IsSet(set)) { + if (GetStringDb()->IsSet(set)) { m_textCtrlHeader->SetValue(GetStringDb()->GetString(set, swHeader)); m_textCtrlImpl->SetValue(GetStringDb()->GetString(set, swSource)); } @@ -241,14 +241,14 @@ void TemplateClassDlg::OnButtonAdd(wxCommandEvent& event) wxUnusedVar(event); wxString set = m_comboxTemplates->GetValue(); bool isSet = GetStringDb()->IsSet(set); - if(isSet) { + if (isSet) { int ret = wxMessageBox(_("Class exists!\nOverwrite?"), _("Add class"), wxYES_NO | wxICON_QUESTION); - if(ret == wxNO) + if (ret == wxNO) return; } GetStringDb()->SetString(set, swHeader, m_textCtrlHeader->GetValue()); GetStringDb()->SetString(set, swSource, m_textCtrlImpl->GetValue()); - if(!isSet) { + if (!isSet) { m_comboxTemplates->AppendString(set); } @@ -267,15 +267,15 @@ void TemplateClassDlg::OnButtonChange(wxCommandEvent& event) wxUnusedVar(event); wxString set = m_comboxTemplates->GetValue(); bool isSet = GetStringDb()->IsSet(set); - if(!isSet) { + if (!isSet) { int ret = ::wxMessageBox(_("That class doesn't exist!\nTry again?"), _("Change class"), wxYES_NO | wxICON_QUESTION); - if(ret == wxNO) + if (ret == wxNO) return; } GetStringDb()->SetString(set, swHeader, m_textCtrlHeader->GetValue()); GetStringDb()->SetString(set, swSource, m_textCtrlImpl->GetValue()); - if(!isSet) + if (!isSet) m_comboxTemplates->AppendString(set); RefreshTemplateList(); m_modified = true; @@ -283,11 +283,11 @@ void TemplateClassDlg::OnButtonChange(wxCommandEvent& event) void TemplateClassDlg::OnButtonChangeUI(wxUpdateUIEvent& event) { - if(m_comboxTemplates->GetSelection() == wxNOT_FOUND) + if (m_comboxTemplates->GetSelection() == wxNOT_FOUND) event.Enable(false); else event.Enable(true); - if(m_textCtrlHeader->IsModified() == false && m_textCtrlImpl->IsModified() == false) + if (m_textCtrlHeader->IsModified() == false && m_textCtrlImpl->IsModified() == false) event.Enable(false); } @@ -296,7 +296,7 @@ void TemplateClassDlg::OnButtonRemove(wxCommandEvent& event) wxUnusedVar(event); wxString set = m_comboxTemplates->GetValue(); bool isSet = GetStringDb()->IsSet(set); - if(!isSet) { + if (!isSet) { ::wxMessageBox(wxT("Class not found!\nNothing to remove."), wxT("Remove class")); return; } @@ -311,7 +311,7 @@ void TemplateClassDlg::OnButtonRemove(wxCommandEvent& event) void TemplateClassDlg::OnButtonRemoveUI(wxUpdateUIEvent& event) { - if(m_comboxTemplates->GetSelection() == wxNOT_FOUND) + if (m_comboxTemplates->GetSelection() == wxNOT_FOUND) event.Enable(false); else event.Enable(true); @@ -331,7 +331,7 @@ void TemplateClassDlg::OnInsertClassKeyword(wxCommandEvent& event) wxUnusedVar(event); long from, to; - if(m_notebookFiles->GetSelection() == 0) { + if (m_notebookFiles->GetSelection() == 0) { m_textCtrlHeader->GetSelection(&from, &to); m_textCtrlHeader->Replace(from, to, swPhClass); m_textCtrlHeader->SetFocus(); @@ -352,11 +352,11 @@ void TemplateClassDlg::RefreshTemplateList() GetStringDb()->GetAllSets(templates); m_comboxCurrentTemplate->Clear(); - for(wxUint32 i = 0; i < templates.GetCount(); i++) { + for (wxUint32 i = 0; i < templates.GetCount(); i++) { m_comboxCurrentTemplate->AppendString(templates[i]); } - if(templates.GetCount()) { + if (templates.GetCount()) { m_comboxCurrentTemplate->Select(0); } } @@ -365,13 +365,14 @@ bool TemplateClassDlg::SaveBufferToFile(const wxString filename, const wxString { wxTextFile file(filename); wxTextFileType tft = wxTextFileType_Dos; - if(file.Exists()) { - int ret = wxMessageBox(_("File already exists!\n\n Overwrite?"), _("Generate class files"), + if (file.Exists()) { + int ret = wxMessageBox(_("File already exists!\n\n Overwrite?"), + _("Generate class files"), wxYES_NO | wxYES_DEFAULT | wxICON_EXCLAMATION); - if(ret == wxID_NO) + if (ret == wxID_NO) return false; } - switch(m_curEol) { + switch (m_curEol) { case 0: tft = wxTextFileType_Dos; break; diff --git a/SnipWiz/templateclassdlg.h b/SnipWiz/templateclassdlg.h index 912a4c2bca..0702c94038 100644 --- a/SnipWiz/templateclassdlg.h +++ b/SnipWiz/templateclassdlg.h @@ -26,7 +26,7 @@ #ifndef __templateclassdlg__ #define __templateclassdlg__ -#include "templateclassbasedlg.h" +#include "templateclassbasedlg.h" class SnipWiz; class swStringDb; @@ -43,9 +43,9 @@ class TemplateClassDlg : public TemplateClassBaseDlg IManager* m_pManager; protected: - virtual void OnVirtualDirUI(wxUpdateUIEvent& event); - virtual void OnStcHeaderFileContentChnaged(wxStyledTextEvent& event); - virtual void OnStcImplFileContentChnaged(wxStyledTextEvent& event); + virtual void OnVirtualDirUI(wxUpdateUIEvent& event); + virtual void OnStcHeaderFileContentChnaged(wxStyledTextEvent& event); + virtual void OnStcImplFileContentChnaged(wxStyledTextEvent& event); void OnClassNameEntered(wxCommandEvent& event); void OnBrowseVD(wxCommandEvent& event); void OnBrowseFilePath(wxCommandEvent& event); diff --git a/SnipWiz/wxSerialize.cpp b/SnipWiz/wxSerialize.cpp index 70fc44a851..26f23e59b1 100644 --- a/SnipWiz/wxSerialize.cpp +++ b/SnipWiz/wxSerialize.cpp @@ -1,25 +1,25 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : wxSerialize.cpp -// +// copyright : (C) 2008 by Eran Ifrah +// file name : wxSerialize.cpp +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -38,128 +38,113 @@ #undef wxUSE_APPLE_IEEE #ifdef __BORLANDC__ - #pragma hdrstop +#pragma hdrstop #endif -#include #include "wxSerialize.h" -wxSerialize::wxSerialize(wxInputStream &stream, size_t version, const wxString &header, bool partialMode) - : m_partialMode(partialMode) - , m_writeMode(false) - , m_odstr(m_otmp) - , m_idstr(stream) - , m_otmp(&m_tmpostr) - , m_itmp(m_tmpistr) +#include + +wxSerialize::wxSerialize(wxInputStream& stream, size_t version, const wxString& header, bool partialMode) + : m_partialMode(partialMode) + , m_writeMode(false) + , m_odstr(m_otmp) + , m_idstr(stream) + , m_otmp(&m_tmpostr) + , m_itmp(m_tmpistr) { InitAll(); // all ok, use this stream - if(stream.IsOk()) - { - // now we need to reset the code for - // reading to work - m_errorCode = wxSERIALIZE_ERR_OK; - m_opened = true; - - // load header - wxString hdr = LoadString(); - - if(IsOk()) - { - // when we have a header to check else ignore and store - // for future reference (and writing back maybe?) - if(header.IsEmpty() || header.IsSameAs(hdr)) - { - // store header for consulting later - m_headerStr = header; + if (stream.IsOk()) { + // now we need to reset the code for + // reading to work + m_errorCode = wxSERIALIZE_ERR_OK; + m_opened = true; + + // load header + wxString hdr = LoadString(); + + if (IsOk()) { + // when we have a header to check else ignore and store + // for future reference (and writing back maybe?) + if (header.IsEmpty() || header.IsSameAs(hdr)) { + // store header for consulting later + m_headerStr = header; // check the version number size_t ver = LoadUint32(); - if(IsOk()) - { + if (IsOk()) { // if version is 0, we accept any version if higher, we // need to see if this stream does not exceed the expected version - if(!version || ver <=version) - { + if (!version || ver <= version) { // this is the point where all is // approved. We can start reading m_version = ver; - m_status = wxSerializeStatus(m_version, m_headerStr); - } - else - { + m_status = wxSerializeStatus(m_version, m_headerStr); + } else { wxString v1, v2; v1 << version; v2 << ver; LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_WRONGVERSION_s1_s2, v1, v2); } - } - else + } else LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_NOVERSION); - } - else - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_HEADER_s1_s2, header, hdr); - } - else - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_NOHEADER_s1, header); - } - else - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_BADISTREAM); + } else + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_HEADER_s1_s2, header, hdr); + } else + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_NOHEADER_s1, header); + } else + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_BADISTREAM); } -wxSerialize::wxSerialize(wxOutputStream &stream, size_t version, const wxString &header, bool partialMode) - : m_headerStr(header) - , m_version(version) - , m_partialMode(partialMode) - , m_writeMode(true) - , m_odstr(stream) - , m_idstr(m_itmp) - , m_otmp(&m_tmpostr) - , m_itmp(m_tmpistr) +wxSerialize::wxSerialize(wxOutputStream& stream, size_t version, const wxString& header, bool partialMode) + : m_headerStr(header) + , m_version(version) + , m_partialMode(partialMode) + , m_writeMode(true) + , m_odstr(stream) + , m_idstr(m_itmp) + , m_otmp(&m_tmpostr) + , m_itmp(m_tmpistr) { InitAll(); // all ok, use this stream - if(stream.IsOk()) - { - m_opened = true; - m_errorCode = wxSERIALIZE_ERR_OK; - - // write information - SaveString(header); - SaveUint32(version); - - m_status = wxSerializeStatus(version, header); - - // when we are ok, start saving - if(!IsOk()) - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_NOVERHDR); - } - else - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_BADOSTREAM); + if (stream.IsOk()) { + m_opened = true; + m_errorCode = wxSERIALIZE_ERR_OK; + + // write information + SaveString(header); + SaveUint32(version); + + m_status = wxSerializeStatus(version, header); + + // when we are ok, start saving + if (!IsOk()) + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_NOVERHDR); + } else + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_BADOSTREAM); } void wxSerialize::InitAll() { m_opened = false; m_errorCode = wxSERIALIZE_ERR_ILL; - m_objectLevel = 0; - m_haveBoundary = false; + m_objectLevel = 0; + m_haveBoundary = false; } -wxSerialize::~wxSerialize() -{ - Close(); -} +wxSerialize::~wxSerialize() { Close(); } bool wxSerialize::Eof() { // only when we are input (reading) we have // something to tell about EOF - if(!m_writeMode) + if (!m_writeMode) return m_idstr.Eof(); return false; @@ -168,12 +153,10 @@ bool wxSerialize::Eof() bool wxSerialize::CanStore() { // are we in an ok state? - if(m_writeMode) - { - if(IsOpen()) + if (m_writeMode) { + if (IsOpen()) return (m_errorCode == wxSERIALIZE_ERR_OK); - } - else + } else LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_NOREAD); return false; @@ -182,17 +165,14 @@ bool wxSerialize::CanStore() bool wxSerialize::CanLoad() { // are we in an ok state? - if(!m_writeMode) - { - if(IsOpen()) - { - if(!Eof()) + if (!m_writeMode) { + if (IsOpen()) { + if (!Eof()) return (m_errorCode == wxSERIALIZE_ERR_OK); else LogError(wxSERIALIZE_ERR_EOF, wxSERIALIZE_ERR_STR_EOF); } - } - else + } else LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_NOWRITE); return false; @@ -200,201 +180,174 @@ bool wxSerialize::CanLoad() bool wxSerialize::EnterObject() { - // increments the level. This will also mean - // that with reading we expect to read this level. We skip all - // headers until we get this level. - - if(IsOk()) - { - if(!m_writeMode) - { - if(CanLoad()) - { - m_objectLevel ++; - FindCurrentEnterLevel(); - } - else - return false; // we did not enter - } - else - { - if(CanStore()) - { - m_objectLevel++; - SaveChar(wxSERIALIZE_HDR_ENTER); - } - else - return false; // we did not enter - } - } - - return IsOk(); + // increments the level. This will also mean + // that with reading we expect to read this level. We skip all + // headers until we get this level. + + if (IsOk()) { + if (!m_writeMode) { + if (CanLoad()) { + m_objectLevel++; + FindCurrentEnterLevel(); + } else + return false; // we did not enter + } else { + if (CanStore()) { + m_objectLevel++; + SaveChar(wxSERIALIZE_HDR_ENTER); + } else + return false; // we did not enter + } + } + + return IsOk(); } bool wxSerialize::LeaveObject() { - // increments the level. This will also mean - // that with reading we expect to read this level. We skip all - // headers until we get this level. - - if(IsOk()) - { - if(!m_writeMode) - { - if(CanLoad()) - { - m_objectLevel --; - if(m_objectLevel < 0) - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_ILL_LEVEL); - else - FindCurrentLeaveLevel(); - } - else - return false; // we did not enter - } - else - { - if(CanStore()) - { - m_objectLevel--; - if(m_objectLevel < 0) - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_ILL_LEVEL); - else - SaveChar(wxSERIALIZE_HDR_LEAVE); - } - else - return false; // we did not enter - } - } - - return IsOk(); + // increments the level. This will also mean + // that with reading we expect to read this level. We skip all + // headers until we get this level. + + if (IsOk()) { + if (!m_writeMode) { + if (CanLoad()) { + m_objectLevel--; + if (m_objectLevel < 0) + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_ILL_LEVEL); + else + FindCurrentLeaveLevel(); + } else + return false; // we did not enter + } else { + if (CanStore()) { + m_objectLevel--; + if (m_objectLevel < 0) + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_ILL_LEVEL); + else + SaveChar(wxSERIALIZE_HDR_LEAVE); + } else + return false; // we did not enter + } + } + + return IsOk(); } void wxSerialize::FindCurrentEnterLevel() { - // the next read should be the begin marker. If not, we search for the - // begin marker - - if(m_haveBoundary && m_lastBoundary == wxSERIALIZE_HDR_ENTER) - { - m_haveBoundary = false; - return; - } - - wxUint8 hdr = LoadChar(); // we do not care about the header - while(IsOk() && hdr != wxSERIALIZE_HDR_ENTER) - { - // here we have data loss, as we need to look for our marker - m_status.SetNewDataLoss(); - - // we should find the enter level, not leave - if(hdr == wxSERIALIZE_HDR_LEAVE) - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_ILL_LEAVE); - - SkipData(hdr); - hdr = LoadChar(); - } + // the next read should be the begin marker. If not, we search for the + // begin marker + + if (m_haveBoundary && m_lastBoundary == wxSERIALIZE_HDR_ENTER) { + m_haveBoundary = false; + return; + } + + wxUint8 hdr = LoadChar(); // we do not care about the header + while (IsOk() && hdr != wxSERIALIZE_HDR_ENTER) { + // here we have data loss, as we need to look for our marker + m_status.SetNewDataLoss(); + + // we should find the enter level, not leave + if (hdr == wxSERIALIZE_HDR_LEAVE) + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_ILL_LEAVE); + + SkipData(hdr); + hdr = LoadChar(); + } } void wxSerialize::FindCurrentLeaveLevel() { - bool firstHdr = true; - unsigned char hdr = 0; - // the next read should be the leave marker. If not, we search for the - // leave marker that belongs to our current state (this means skipping - // data that we cannot read, and potential enter and leave markers - // that we do not read anyway - - int foundLevel = 1; - if(m_haveBoundary) - { - // reset the boundary scan - m_haveBoundary = false; - - // determine what to do - if(m_lastBoundary == wxSERIALIZE_HDR_ENTER) - foundLevel++; - else if(m_lastBoundary == wxSERIALIZE_HDR_LEAVE) - return; - } - - while(IsOk() && foundLevel > 0) - { - if(hdr == wxSERIALIZE_HDR_ENTER) - foundLevel++; - else if(hdr == wxSERIALIZE_HDR_LEAVE) - { - foundLevel--; - if(foundLevel < 0) - { - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_ILL_LEAVE); - return; - } - } - - if(foundLevel > 0) - { - hdr = LoadChar(); - - // here we have data loss, as we need to look for our marker - // the first header should have been the proper marker (if in sync) - if(!firstHdr) - m_status.SetNewDataLoss(); - - SkipData(hdr); - } - - firstHdr = false; - } -} + bool firstHdr = true; + unsigned char hdr = 0; + // the next read should be the leave marker. If not, we search for the + // leave marker that belongs to our current state (this means skipping + // data that we cannot read, and potential enter and leave markers + // that we do not read anyway + + int foundLevel = 1; + if (m_haveBoundary) { + // reset the boundary scan + m_haveBoundary = false; + + // determine what to do + if (m_lastBoundary == wxSERIALIZE_HDR_ENTER) + foundLevel++; + else if (m_lastBoundary == wxSERIALIZE_HDR_LEAVE) + return; + } + + while (IsOk() && foundLevel > 0) { + if (hdr == wxSERIALIZE_HDR_ENTER) + foundLevel++; + else if (hdr == wxSERIALIZE_HDR_LEAVE) { + foundLevel--; + if (foundLevel < 0) { + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_ILL_LEAVE); + return; + } + } + if (foundLevel > 0) { + hdr = LoadChar(); + + // here we have data loss, as we need to look for our marker + // the first header should have been the proper marker (if in sync) + if (!firstHdr) + m_status.SetNewDataLoss(); + + SkipData(hdr); + } + + firstHdr = false; + } +} void wxSerialize::SkipData(wxUint8 hdr) { - switch(hdr) - { - case wxSERIALIZE_HDR_BOOL: - LoadBool(); - break; - - case wxSERIALIZE_HDR_INT8: - LoadChar(); - break; - - case wxSERIALIZE_HDR_INT16: - LoadUint16(); - break; - - case wxSERIALIZE_HDR_INT32: - LoadUint32(); - break; - - case wxSERIALIZE_HDR_INT64: - LoadUint64(); - break; - - case wxSERIALIZE_HDR_DOUBLE: - LoadDouble(); - break; - - case wxSERIALIZE_HDR_STRING: - LoadString(); - break; - - case wxSERIALIZE_HDR_ARRSTRING: - LoadArrayString(); - break; - - case wxSERIALIZE_HDR_RECORD: - { - wxMemoryBuffer buf; - Load(buf); - } - break; - - case wxSERIALIZE_HDR_INT: - LoadInt(); - break; + switch (hdr) { + case wxSERIALIZE_HDR_BOOL: + LoadBool(); + break; + + case wxSERIALIZE_HDR_INT8: + LoadChar(); + break; + + case wxSERIALIZE_HDR_INT16: + LoadUint16(); + break; + + case wxSERIALIZE_HDR_INT32: + LoadUint32(); + break; + + case wxSERIALIZE_HDR_INT64: + LoadUint64(); + break; + + case wxSERIALIZE_HDR_DOUBLE: + LoadDouble(); + break; + + case wxSERIALIZE_HDR_STRING: + LoadString(); + break; + + case wxSERIALIZE_HDR_ARRSTRING: + LoadArrayString(); + break; + + case wxSERIALIZE_HDR_RECORD: { + wxMemoryBuffer buf; + Load(buf); + } break; + + case wxSERIALIZE_HDR_INT: + LoadInt(); + break; case wxSERIALIZE_HDR_INTINT: int val1, val2; @@ -405,29 +358,27 @@ void wxSerialize::SkipData(wxUint8 hdr) LoadDateTime(); break; - case wxSERIALIZE_HDR_ENTER: - break; + case wxSERIALIZE_HDR_ENTER: + break; - case wxSERIALIZE_HDR_LEAVE: - break; - default: - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_ILL_UNKNOWN_HDR_s1, GetHeaderName(hdr)); - break; - } + case wxSERIALIZE_HDR_LEAVE: + break; + default: + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_ILL_UNKNOWN_HDR_s1, GetHeaderName(hdr)); + break; + } } bool wxSerialize::ReadBool(bool& value) { // load boolean value - if(LoadChunkHeader(wxSERIALIZE_HDR_BOOL)) - { + if (LoadChunkHeader(wxSERIALIZE_HDR_BOOL)) { bool tmpvalue = LoadBool(); - if(IsOk()) - { + if (IsOk()) { value = tmpvalue; - return true; - } + return true; + } } return false; @@ -436,15 +387,13 @@ bool wxSerialize::ReadBool(bool& value) bool wxSerialize::ReadUint8(wxUint8& value) { // load integer value - if(LoadChunkHeader(wxSERIALIZE_HDR_INT8)) - { + if (LoadChunkHeader(wxSERIALIZE_HDR_INT8)) { wxUint8 tmpvalue = LoadChar(); - if(IsOk()) - { + if (IsOk()) { value = tmpvalue; - return true; - } + return true; + } } return false; @@ -453,15 +402,13 @@ bool wxSerialize::ReadUint8(wxUint8& value) bool wxSerialize::ReadUint16(wxUint16& value) { // load integer value - if(LoadChunkHeader(wxSERIALIZE_HDR_INT16)) - { + if (LoadChunkHeader(wxSERIALIZE_HDR_INT16)) { wxUint16 tmpvalue = LoadUint16(); - if(IsOk()) - { + if (IsOk()) { value = tmpvalue; - return true; - } + return true; + } } return false; @@ -470,15 +417,13 @@ bool wxSerialize::ReadUint16(wxUint16& value) bool wxSerialize::ReadUint32(wxUint32& value) { // load integer value - if(LoadChunkHeader(wxSERIALIZE_HDR_INT32)) - { + if (LoadChunkHeader(wxSERIALIZE_HDR_INT32)) { wxUint32 tmpvalue = LoadUint32(); - if(IsOk()) - { + if (IsOk()) { value = tmpvalue; - return true; - } + return true; + } } return false; @@ -487,15 +432,13 @@ bool wxSerialize::ReadUint32(wxUint32& value) bool wxSerialize::ReadUint64(wxUint64& value) { // load integer value - if(LoadChunkHeader(wxSERIALIZE_HDR_INT64)) - { + if (LoadChunkHeader(wxSERIALIZE_HDR_INT64)) { wxUint64 tmpvalue = LoadUint64(); - if(IsOk()) - { + if (IsOk()) { value = tmpvalue; - return true; - } + return true; + } } return false; @@ -503,55 +446,49 @@ bool wxSerialize::ReadUint64(wxUint64& value) bool wxSerialize::ReadInt(int& value) { - if(LoadChunkHeader(wxSERIALIZE_HDR_INT)) - { - int tmpval = LoadInt(); - - // assign value - if(IsOk()) - { - value = tmpval; - return true; - } - } - - return false; + if (LoadChunkHeader(wxSERIALIZE_HDR_INT)) { + int tmpval = LoadInt(); + + // assign value + if (IsOk()) { + value = tmpval; + return true; + } + } + + return false; } bool wxSerialize::ReadIntInt(int& value1, int& value2) { value1 = 0; value2 = 0; - if(LoadChunkHeader(wxSERIALIZE_HDR_INTINT)) - { - int tmpval1, tmpval2; - LoadIntInt(tmpval1, tmpval2); - - // assign value - if(IsOk()) - { - value1 = tmpval1; - value2 = tmpval2; - return true; - } - } - - return false; + if (LoadChunkHeader(wxSERIALIZE_HDR_INTINT)) { + int tmpval1, tmpval2; + LoadIntInt(tmpval1, tmpval2); + + // assign value + if (IsOk()) { + value1 = tmpval1; + value2 = tmpval2; + return true; + } + } + + return false; } bool wxSerialize::ReadDouble(wxFloat64& value) { // load wxFloat64 value - if(LoadChunkHeader(wxSERIALIZE_HDR_DOUBLE)) - { + if (LoadChunkHeader(wxSERIALIZE_HDR_DOUBLE)) { wxFloat64 tmpvalue = LoadDouble(); - // when all is ok, assign - if(IsOk()) - { + // when all is ok, assign + if (IsOk()) { value = tmpvalue; - return true; - } + return true; + } } return false; @@ -559,15 +496,13 @@ bool wxSerialize::ReadDouble(wxFloat64& value) bool wxSerialize::ReadString(wxString& value) { - if(LoadChunkHeader(wxSERIALIZE_HDR_STRING)) - { + if (LoadChunkHeader(wxSERIALIZE_HDR_STRING)) { wxString tmpvalue = LoadString(); - if(IsOk()) - { + if (IsOk()) { value = tmpvalue; - return true; - } + return true; + } } return false; @@ -575,15 +510,13 @@ bool wxSerialize::ReadString(wxString& value) bool wxSerialize::ReadArrayString(wxArrayString& value) { - if(LoadChunkHeader(wxSERIALIZE_HDR_ARRSTRING)) - { + if (LoadChunkHeader(wxSERIALIZE_HDR_ARRSTRING)) { wxArrayString tmpvalue = LoadArrayString(); - if(IsOk()) - { + if (IsOk()) { value = tmpvalue; - return true; - } + return true; + } } return false; @@ -591,70 +524,63 @@ bool wxSerialize::ReadArrayString(wxArrayString& value) bool wxSerialize::ReadDateTime(wxDateTime& value) { - if(LoadChunkHeader(wxSERIALIZE_HDR_DATETIME)) - { + if (LoadChunkHeader(wxSERIALIZE_HDR_DATETIME)) { wxDateTime tmpvalue = LoadDateTime(); - if(IsOk()) - { + if (IsOk()) { value = tmpvalue; - return true; - } + return true; + } } return false; } - -bool wxSerialize::Read(wxMemoryBuffer &buf) +bool wxSerialize::Read(wxMemoryBuffer& buf) { // load record value - if(LoadChunkHeader(wxSERIALIZE_HDR_RECORD)) - { - Load(buf); + if (LoadChunkHeader(wxSERIALIZE_HDR_RECORD)) { + Load(buf); return true; - } + } return false; } -void wxSerialize::Load(wxMemoryBuffer &buf) +void wxSerialize::Load(wxMemoryBuffer& buf) { - if(CanLoad()) - { - wxUint32 size = LoadUint32(); - if(size > 0) - { - m_idstr.Read(buf.GetWriteBuf(size), size); + if (CanLoad()) { + wxUint32 size = LoadUint32(); + if (size > 0) { + m_idstr.Read(buf.GetWriteBuf(size), size); buf.UngetWriteBuf(size); } - } + } } int wxSerialize::LoadChunkHeader(int expheader) { - int hdr = 0; - - if(CanLoad()) - { - if(m_haveBoundary) - return 0; - - hdr = (int)LoadChar(); - if(hdr == wxSERIALIZE_HDR_ENTER || hdr == wxSERIALIZE_HDR_LEAVE) - { - // remember this state - m_lastBoundary = hdr; - m_haveBoundary = true; - return 0; - } + int hdr = 0; + + if (CanLoad()) { + if (m_haveBoundary) + return 0; + + hdr = (int)LoadChar(); + if (hdr == wxSERIALIZE_HDR_ENTER || hdr == wxSERIALIZE_HDR_LEAVE) { + // remember this state + m_lastBoundary = hdr; + m_haveBoundary = true; + return 0; + } // when header is not ok - if(hdr != expheader) - { - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_WRONGCHUNK_s1_s2, - GetHeaderName(expheader), GetHeaderName(hdr)); - return -1; + if (hdr != expheader) { + LogError(wxSERIALIZE_ERR_ILL, + wxSERIALIZE_ERR_STR_WRONGCHUNK_s1_s2, + GetHeaderName(expheader), + GetHeaderName(hdr)); + return -1; } } @@ -663,106 +589,98 @@ int wxSerialize::LoadChunkHeader(int expheader) wxUint8 wxSerialize::LoadChar() { - wxUint8 value = '\0'; + wxUint8 value = '\0'; - // reads a character from the stream - if(CanLoad()) - { - // load unsigned char through ptr to - // make sure we have no signed / unsigned crap - m_idstr.Read((void *)&value, sizeof(wxUint8)); - } + // reads a character from the stream + if (CanLoad()) { + // load unsigned char through ptr to + // make sure we have no signed / unsigned crap + m_idstr.Read((void*)&value, sizeof(wxUint8)); + } - return value; + return value; } int wxSerialize::LoadInt() { - wxUint8 intsize = 0; - int tmpval = 0; - - if(CanLoad()) - { - // get size - intsize = LoadChar(); - switch(intsize) - { - case 1: // 8 bits - tmpval = (int)LoadChar(); - break; - case 2: // 16 bits - tmpval = (int)LoadUint16(); - break; - case 4: // 32 bits - tmpval = (int)LoadUint32(); - break; - case 8: // 64 bits - tmpval = (int)LoadUint64(); - break; - - default: - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_RINTSIZE); - break; - } - } - - return tmpval; + wxUint8 intsize = 0; + int tmpval = 0; + + if (CanLoad()) { + // get size + intsize = LoadChar(); + switch (intsize) { + case 1: // 8 bits + tmpval = (int)LoadChar(); + break; + case 2: // 16 bits + tmpval = (int)LoadUint16(); + break; + case 4: // 32 bits + tmpval = (int)LoadUint32(); + break; + case 8: // 64 bits + tmpval = (int)LoadUint64(); + break; + + default: + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_RINTSIZE); + break; + } + } + + return tmpval; } -void wxSerialize::LoadIntInt (int& value1, int& value2) +void wxSerialize::LoadIntInt(int& value1, int& value2) { - wxUint8 intsize = 0; - - if(CanLoad()) - { - // get size - intsize = LoadChar(); - switch(intsize) - { - case 1: // 8 bits - value1 = (int)LoadChar(); - value2 = (int)LoadChar(); - break; - case 2: // 16 bits - value1 = (int)LoadUint16(); - value2 = (int)LoadUint16(); - break; - case 4: // 32 bits - value1 = (int)LoadUint32(); - value2 = (int)LoadUint32(); - break; - case 8: // 64 bits - value1 = (int)LoadUint64(); - value2 = (int)LoadUint64(); - break; - - default: - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_RINTSIZE); - break; - } - } + wxUint8 intsize = 0; + + if (CanLoad()) { + // get size + intsize = LoadChar(); + switch (intsize) { + case 1: // 8 bits + value1 = (int)LoadChar(); + value2 = (int)LoadChar(); + break; + case 2: // 16 bits + value1 = (int)LoadUint16(); + value2 = (int)LoadUint16(); + break; + case 4: // 32 bits + value1 = (int)LoadUint32(); + value2 = (int)LoadUint32(); + break; + case 8: // 64 bits + value1 = (int)LoadUint64(); + value2 = (int)LoadUint64(); + break; + + default: + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_RINTSIZE); + break; + } + } } wxString wxSerialize::LoadString() { wxString str; - if(CanLoad()) - { - size_t len = LoadUint32(); + if (CanLoad()) { + size_t len = LoadUint32(); - //wxLogDebug(wxString::Format(wxT("LoadString len %i"), len)); + // wxLogDebug(wxString::Format(wxT("LoadString len %i"), len)); - if (len > 0) - { + if (len > 0) { // embarassing how I am doing this, but I cannot be certain which // unicode method reads a multibyte array and converts it so I will // do it per wxInt16 converted to wxChar. When bytes get lost in the // conversion then it's tough luck as this build is not unicode then - str.Alloc(len+1); - wxInt16 *buf = new wxInt16[len+1]; - for(int i = 0; i < (int)len; i++) - { + str.Alloc(len + 1); + wxInt16* buf = new wxInt16[len + 1]; + for (int i = 0; i < (int)len; i++) { // we need to load per 16 bits because they // need to optionally be swapped to convert buf[i] = LoadUint16(); @@ -770,33 +688,31 @@ wxString wxSerialize::LoadString() } delete[] buf; - } - } - return str; + } + } + return str; } wxArrayString wxSerialize::LoadArrayString() { - wxArrayString str; + wxArrayString str; - if(CanLoad()) - { - wxUint32 count = LoadUint32(); + if (CanLoad()) { + wxUint32 count = LoadUint32(); - for(wxUint32 i = 0; i < count; i++) - str.Add(LoadString()); - } + for (wxUint32 i = 0; i < count; i++) + str.Add(LoadString()); + } - return str; + return str; } wxDateTime wxSerialize::LoadDateTime() { - wxDateTime dt; + wxDateTime dt; - if(CanLoad()) - { - // load date + if (CanLoad()) { + // load date wxUint8 day = LoadUint8(); wxUint8 month = LoadUint8(); wxUint16 year = LoadUint16(); @@ -806,237 +722,220 @@ wxDateTime wxSerialize::LoadDateTime() wxUint8 sec = LoadUint8(); // load millisecs wxUint16 msec = LoadUint16(); - + dt = wxDateTime(day, (wxDateTime::Month)month, year, hour, min, sec, msec); - } + } - return dt; + return dt; } -wxUint8 wxSerialize::LoadUint8() -{ - return LoadChar(); -} +wxUint8 wxSerialize::LoadUint8() { return LoadChar(); } wxUint16 wxSerialize::LoadUint16() { - wxUint16 value = 0; + wxUint16 value = 0; - // reads a 16bits from the stream - if(CanLoad()) - { - m_idstr.Read((void *)&value, sizeof(wxUint16)); - return wxUINT16_SWAP_ON_LE(value); - } + // reads a 16bits from the stream + if (CanLoad()) { + m_idstr.Read((void*)&value, sizeof(wxUint16)); + return wxUINT16_SWAP_ON_LE(value); + } - return value; + return value; } wxUint32 wxSerialize::LoadUint32() { - wxUint32 value = 0; + wxUint32 value = 0; - // reads a 32bits from the stream - if(CanLoad()) - { - m_idstr.Read((void *)&value, sizeof(wxUint32)); - return wxUINT32_SWAP_ON_LE(value); - } + // reads a 32bits from the stream + if (CanLoad()) { + m_idstr.Read((void*)&value, sizeof(wxUint32)); + return wxUINT32_SWAP_ON_LE(value); + } - return value; + return value; } wxUint64 wxSerialize::LoadUint64() { - wxUint64 value = 0; + wxUint64 value = 0; - // reads a character from the stream - if(CanLoad()) - { - m_idstr.Read((void *)&value, sizeof(wxUint64)); - return wxUINT64_SWAP_ON_LE(value); - } + // reads a character from the stream + if (CanLoad()) { + m_idstr.Read((void*)&value, sizeof(wxUint64)); + return wxUINT64_SWAP_ON_LE(value); + } - return value; + return value; } bool wxSerialize::WriteInt(int value) { - if(CanStore()) - { - SaveChar(wxSERIALIZE_HDR_INT); - - // save the size of the int - SaveChar(sizeof(int)); - - // save int itself by proper casting - switch(sizeof(int)) - { - case 1: - SaveChar(value); - break; - case 2: - SaveUint16(value); - break; - case 4: - SaveUint32(value); - break; - case 8: - SaveUint64(value); - break; - - default: - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_SINTSIZE); - break; - - } - } - - return IsOk(); + if (CanStore()) { + SaveChar(wxSERIALIZE_HDR_INT); + + // save the size of the int + SaveChar(sizeof(int)); + + // save int itself by proper casting + switch (sizeof(int)) { + case 1: + SaveChar(value); + break; + case 2: + SaveUint16(value); + break; + case 4: + SaveUint32(value); + break; + case 8: + SaveUint64(value); + break; + + default: + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_SINTSIZE); + break; + } + } + + return IsOk(); } bool wxSerialize::WriteIntInt(int value1, int value2) { - if(CanStore()) - { - SaveChar(wxSERIALIZE_HDR_INTINT); - - // save the size of the int - SaveChar(sizeof(int)); - - // save int itself by proper casting - switch(sizeof(int)) - { - case 1: - SaveChar(value1); - SaveChar(value2); - break; - case 2: - SaveUint16(value1); - SaveUint16(value2); - break; - case 4: - SaveUint32(value1); - SaveUint32(value2); - break; - case 8: - SaveUint64(value1); - SaveUint64(value2); - break; - - default: - LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_SINTSIZE); - break; - - } - } - - return IsOk(); + if (CanStore()) { + SaveChar(wxSERIALIZE_HDR_INTINT); + + // save the size of the int + SaveChar(sizeof(int)); + + // save int itself by proper casting + switch (sizeof(int)) { + case 1: + SaveChar(value1); + SaveChar(value2); + break; + case 2: + SaveUint16(value1); + SaveUint16(value2); + break; + case 4: + SaveUint32(value1); + SaveUint32(value2); + break; + case 8: + SaveUint64(value1); + SaveUint64(value2); + break; + + default: + LogError(wxSERIALIZE_ERR_ILL, wxSERIALIZE_ERR_STR_SINTSIZE); + break; + } + } + + return IsOk(); } -bool wxSerialize::Write(const wxMemoryBuffer &buffer) +bool wxSerialize::Write(const wxMemoryBuffer& buffer) { - wxUint32 size = 0; - - if(CanStore()) - { - // save header to the stream + wxUint32 size = 0; + + if (CanStore()) { + // save header to the stream SaveChar(wxSERIALIZE_HDR_RECORD); // save the record count size = buffer.GetDataLen(); SaveUint32(size); - + // write data if there is any - if(size > 0) + if (size > 0) m_odstr.Write(buffer.GetData(), size); } - return IsOk(); + return IsOk(); } // ATTN:: uncomment for static build // Must be at global scope for VC++ 5 (ripped from wxDataInputStream) -//extern "C" wxFloat64 ConvertFromIeeeExtended(const wxInt8 *bytes); +// extern "C" wxFloat64 ConvertFromIeeeExtended(const wxInt8 *bytes); wxFloat64 wxSerialize::LoadDouble() { - wxFloat64 value = 0; - - // reads a character from the stream - if(CanLoad()) - { -//ATTN:: uncomment for static build -//#if wxUSE_APPLE_IEEE -// wxInt8 buf[10]; -// -// m_idstr.Read((void *)buf, 10); -// value = ConvertFromIeeeExtended(buf); -//#else -// #pragma warning "wxSerialize::LoadDouble() not using IeeeExtended - will not work!" -//#endif - } - - return value; + wxFloat64 value = 0; + + // reads a character from the stream + if (CanLoad()) { + // ATTN:: uncomment for static build + // #if wxUSE_APPLE_IEEE + // wxInt8 buf[10]; + // + // m_idstr.Read((void *)buf, 10); + // value = ConvertFromIeeeExtended(buf); + // #else + // #pragma warning "wxSerialize::LoadDouble() not using IeeeExtended - will not work!" + // #endif + } + + return value; } bool wxSerialize::LoadBool() { - bool value = false; - wxUint8 chr; + bool value = false; + wxUint8 chr; - if(CanLoad()) - { - chr = LoadChar(); - if(IsOk()) - value = (chr != 0); - } + if (CanLoad()) { + chr = LoadChar(); + if (IsOk()) + value = (chr != 0); + } - return value; + return value; } void wxSerialize::SaveChar(wxUint8 value) { - if(CanStore()) - m_odstr.Write((void *)&value, sizeof(wxUint8)); + if (CanStore()) + m_odstr.Write((void*)&value, sizeof(wxUint8)); } bool wxSerialize::WriteBool(bool value) { wxUint8 nval = 0; - if(CanStore()) - { + if (CanStore()) { // set to boolean - if(value) + if (value) nval = 1; - SaveChar(wxSERIALIZE_HDR_BOOL); + SaveChar(wxSERIALIZE_HDR_BOOL); SaveChar(nval); } return IsOk(); } -//ATTN:: uncomment for static build -// Must be at global scope for VC++ 5 -//extern "C" void ConvertToIeeeExtended(wxFloat64, wxInt8 *bytes); +// ATTN:: uncomment for static build +// Must be at global scope for VC++ 5 +// extern "C" void ConvertToIeeeExtended(wxFloat64, wxInt8 *bytes); bool wxSerialize::WriteDouble(wxFloat64 value) { - if(CanStore()) - { + if (CanStore()) { SaveChar(wxSERIALIZE_HDR_DOUBLE); - wxInt8 buf[10]; -//ATTN:: uncomment for static build -//#if wxUSE_APPLE_IEEE -// ConvertToIeeeExtended(value, buf); -//#else -// #if !defined(__VMS__) && !defined(__GNUG__) -// #pragma warning "wxSerialize::WriteDouble() not using IeeeExtended - will not work!" -// #endif -// // fill with zeros when writing -// memset(buf, 0, 10); -//#endif - m_odstr.Write(buf, 10); + wxInt8 buf[10]; + // ATTN:: uncomment for static build + // #if wxUSE_APPLE_IEEE + // ConvertToIeeeExtended(value, buf); + // #else + // #if !defined(__VMS__) && !defined(__GNUG__) + // #pragma warning "wxSerialize::WriteDouble() not using IeeeExtended - will not work!" + // #endif + // // fill with zeros when writing + // memset(buf, 0, 10); + // #endif + m_odstr.Write(buf, 10); } return IsOk(); @@ -1044,11 +943,10 @@ bool wxSerialize::WriteDouble(wxFloat64 value) bool wxSerialize::WriteString(const wxString& value) { - if(CanStore()) - { - // write header + string - SaveChar(wxSERIALIZE_HDR_STRING); - SaveString(value); + if (CanStore()) { + // write header + string + SaveChar(wxSERIALIZE_HDR_STRING); + SaveString(value); } return IsOk(); @@ -1056,13 +954,12 @@ bool wxSerialize::WriteString(const wxString& value) bool wxSerialize::WriteArrayString(const wxArrayString& value) { - if(CanStore()) - { - // write header + string - SaveChar(wxSERIALIZE_HDR_ARRSTRING); - SaveUint32(value.Count()); - for(size_t i = 0; i < value.Count(); i++) - SaveString(value[i]); + if (CanStore()) { + // write header + string + SaveChar(wxSERIALIZE_HDR_ARRSTRING); + SaveUint32(value.Count()); + for (size_t i = 0; i < value.Count(); i++) + SaveString(value[i]); } return IsOk(); @@ -1070,118 +967,107 @@ bool wxSerialize::WriteArrayString(const wxArrayString& value) bool wxSerialize::WriteDateTime(const wxDateTime& value) { - if(CanStore()) - { - // write header - SaveChar(wxSERIALIZE_HDR_DATETIME); - - // decompose - wxUint8 day = value.GetDay(); - wxUint8 month = value.GetMonth(); - wxUint16 year = value.GetYear(); - wxUint8 hour = value.GetHour(); - wxUint8 min = value.GetMinute(); - wxUint8 sec = value.GetSecond(); - wxUint16 msec = value.GetMillisecond(); - - // serialize - SaveChar(day); - SaveChar(month); - SaveUint16(year); - SaveChar(hour); - SaveChar(min); - SaveChar(sec); - SaveUint16(msec); + if (CanStore()) { + // write header + SaveChar(wxSERIALIZE_HDR_DATETIME); + + // decompose + wxUint8 day = value.GetDay(); + wxUint8 month = value.GetMonth(); + wxUint16 year = value.GetYear(); + wxUint8 hour = value.GetHour(); + wxUint8 min = value.GetMinute(); + wxUint8 sec = value.GetSecond(); + wxUint16 msec = value.GetMillisecond(); + + // serialize + SaveChar(day); + SaveChar(month); + SaveUint16(year); + SaveChar(hour); + SaveChar(min); + SaveChar(sec); + SaveUint16(msec); } return IsOk(); } - -void wxSerialize::SaveString(const wxString &value) +void wxSerialize::SaveString(const wxString& value) { - if(CanStore()) - { - size_t len = value.Len(); - SaveUint32(len); - if(len > 0) - { - // we write in unicode even when we are not compiled - // in unicode. This means writing pairs of wxInt16 - // bytes. We need optional conversion in wxUint16 - for(int i = 0; i < (int)len; i++) + if (CanStore()) { + size_t len = value.Len(); + SaveUint32(len); + if (len > 0) { + // we write in unicode even when we are not compiled + // in unicode. This means writing pairs of wxInt16 + // bytes. We need optional conversion in wxUint16 + for (int i = 0; i < (int)len; i++) SaveUint16((wxUint16)value.GetChar(i)); - } - } + } + } } bool wxSerialize::WriteUint8(wxUint8 value) { - if(CanStore()) - { - SaveChar(wxSERIALIZE_HDR_INT8); - SaveChar(value); - } + if (CanStore()) { + SaveChar(wxSERIALIZE_HDR_INT8); + SaveChar(value); + } return IsOk(); } bool wxSerialize::WriteUint16(wxUint16 value) { - if(CanStore()) - { - SaveChar(wxSERIALIZE_HDR_INT16); - SaveUint16(value); - } + if (CanStore()) { + SaveChar(wxSERIALIZE_HDR_INT16); + SaveUint16(value); + } return IsOk(); } bool wxSerialize::WriteUint32(wxUint32 value) { - if(CanStore()) - { - SaveChar(wxSERIALIZE_HDR_INT32); - SaveUint32(value); - } + if (CanStore()) { + SaveChar(wxSERIALIZE_HDR_INT32); + SaveUint32(value); + } return IsOk(); } bool wxSerialize::WriteUint64(wxUint64 value) { - if(CanStore()) - { - SaveChar(wxSERIALIZE_HDR_INT64); - SaveUint64(value); - } + if (CanStore()) { + SaveChar(wxSERIALIZE_HDR_INT64); + SaveUint64(value); + } return IsOk(); } -void wxSerialize::SaveUint8(wxUint8 value) -{ - SaveChar(value); -} +void wxSerialize::SaveUint8(wxUint8 value) { SaveChar(value); } void wxSerialize::SaveUint16(wxUint16 value) { - wxUint16 tmpval = wxUINT16_SWAP_ON_LE(value); - if(CanStore()) + wxUint16 tmpval = wxUINT16_SWAP_ON_LE(value); + if (CanStore()) m_odstr.Write(&tmpval, sizeof(wxUint16)); } void wxSerialize::SaveUint32(wxUint32 value) { - wxUint32 tmpval = wxUINT32_SWAP_ON_LE(value); - if(CanStore()) + wxUint32 tmpval = wxUINT32_SWAP_ON_LE(value); + if (CanStore()) m_odstr.Write(&tmpval, sizeof(wxUint32)); } void wxSerialize::SaveUint64(wxUint64 value) { - wxUint64 tmpval = wxUINT64_SWAP_ON_LE(value); - if(CanStore()) + wxUint64 tmpval = wxUINT64_SWAP_ON_LE(value); + if (CanStore()) m_odstr.Write(&tmpval, sizeof(wxUint64)); } @@ -1189,172 +1075,157 @@ void wxSerialize::SaveUint64(wxUint64 value) wxString wxSerialize::GetHeaderName(int headername) { - wxString desc; + wxString desc; - switch(headername) - { - case wxSERIALIZE_HDR_STRING: - desc = wxT("string"); - break; + switch (headername) { + case wxSERIALIZE_HDR_STRING: + desc = wxT("string"); + break; - case wxSERIALIZE_HDR_INT8: - desc = wxT("8bits uint"); - break; + case wxSERIALIZE_HDR_INT8: + desc = wxT("8bits uint"); + break; - case wxSERIALIZE_HDR_INT16: - desc = wxT("16bits uint"); - break; + case wxSERIALIZE_HDR_INT16: + desc = wxT("16bits uint"); + break; - case wxSERIALIZE_HDR_INT32: - desc = wxT("32bits uint"); - break; + case wxSERIALIZE_HDR_INT32: + desc = wxT("32bits uint"); + break; - case wxSERIALIZE_HDR_INT64: - desc = wxT("64bits uint"); - break; + case wxSERIALIZE_HDR_INT64: + desc = wxT("64bits uint"); + break; - case wxSERIALIZE_HDR_DOUBLE: - desc = wxT("double"); - break; + case wxSERIALIZE_HDR_DOUBLE: + desc = wxT("double"); + break; - case wxSERIALIZE_HDR_BOOL: - desc = wxT("bool"); - break; + case wxSERIALIZE_HDR_BOOL: + desc = wxT("bool"); + break; - case wxSERIALIZE_HDR_RECORD: - desc = wxT("data record"); - break; + case wxSERIALIZE_HDR_RECORD: + desc = wxT("data record"); + break; - default: - if(headername < 0x30 || headername > 0x7f) - desc = wxString::Format(wxT("0x%02X"), headername); - else - desc = wxString::Format(wxT("%c"), headername); - break; + default: + if (headername < 0x30 || headername > 0x7f) + desc = wxString::Format(wxT("0x%02X"), headername); + else + desc = wxString::Format(wxT("%c"), headername); + break; } return desc; } -int wxSerialize::LogError(int err, int msgcode, const wxString &s1, const wxString &s2) +int wxSerialize::LogError(int err, int msgcode, const wxString& s1, const wxString& s2) { - wxString error; - - // make sure we only report one error. When we already have errors - // we ignore this one - if(m_errorCode == wxSERIALIZE_ERR_OK && err != wxSERIALIZE_ERR_OK) - { - // close writing and reading - Close(); - - // assign our new error - m_errorCode = err; - - switch(msgcode) - { - case wxSERIALIZE_ERR_STR_HEADER_s1_s2: - error << wxT("Wrong header in start of stream, expected header '") << s1 << - wxT(" and got '") << s2 << wxT("'"); - break; - - case wxSERIALIZE_ERR_STR_WRONGVERSION_s1_s2: - error << wxT("Invalid version in stream, got v") << s1 << wxT(" but expected v") - << s2 << wxT(" or higher"); - break; - - case wxSERIALIZE_ERR_STR_BADISTREAM: - error << wxT("Bad input stream"); - break; - - case wxSERIALIZE_ERR_STR_BADOSTREAM: - error << wxT("Bad output stream"); - break; - - case wxSERIALIZE_ERR_STR_NOHEADER_s1: - error << wxT("No valid header found in stream but expected header '") << s1 - << wxT("'"); - break; - - case wxSERIALIZE_ERR_STR_NOVERSION: - error << wxT("No version information found in stream"); - break; - - case wxSERIALIZE_ERR_STR_NOVERHDR: - error << wxT("Cannot write version and/or header information to stream"); - break; - - case wxSERIALIZE_ERR_STR_NOWRITE: - error << wxT("Cannot write while in read mode!"); - break; - - case wxSERIALIZE_ERR_STR_NOREAD: - error << wxT("Cannot read while in write mode!"); - break; - - case wxSERIALIZE_ERR_STR_EOF: - error << wxT("End of stream error while reading!"); - break; - - case wxSERIALIZE_ERR_STR_WRONGCHUNK_s1_s2: - error << wxT("Expected chunk item of type '") << s1 - << wxT("' but got type '") << s2 << wxT("'"); - break; - - case wxSERIALIZE_ERR_STR_MEMORY_s1: - error << wxT("Memory allocation error. Cannot allocate ") << s1 - << wxT(" bytes"); - break; - - case wxSERIALIZE_ERR_STR_READSIZE: - error << wxT("Record to read is 0 bytes or larger then expected (does not fit maxcount)"); - break; - - case wxSERIALIZE_ERR_STR_RINTSIZE: - error << wxT("Cannot read back 'int' value because it's of unknown size (need 1, 2, 4 or 8)"); - break; - - case wxSERIALIZE_ERR_STR_SINTSIZE: - error << wxT("Cannot save 'int' value because it's of unknown size (need 1, 2, 4 or 8)"); - break; - - case wxSERIALIZE_ERR_STR_ILL_LEAVE: - error << wxT("Sync Error: Illegal LeaveObject() header encountered, expected EnterObject()"); - break; - - case wxSERIALIZE_ERR_STR_ILL_UNKNOWN_HDR_s1: - error << wxT("Unknown '") << s1 << wxT("' header in stream"); - break; - - case wxSERIALIZE_ERR_STR_ILL_LEVEL: - error << wxT("Sync Error: Level dropped below 0, too much LeaveObject() calls ?"); - break; - - default: - error << wxT("Unknown error error (aint that something ...)"); - break; - } + wxString error; - // log error to user - m_errMsg = error; - wxLogError(m_errMsg); - } + // make sure we only report one error. When we already have errors + // we ignore this one + if (m_errorCode == wxSERIALIZE_ERR_OK && err != wxSERIALIZE_ERR_OK) { + // close writing and reading + Close(); - return m_errorCode; + // assign our new error + m_errorCode = err; -} + switch (msgcode) { + case wxSERIALIZE_ERR_STR_HEADER_s1_s2: + error << wxT("Wrong header in start of stream, expected header '") << s1 << wxT(" and got '") << s2 + << wxT("'"); + break; + case wxSERIALIZE_ERR_STR_WRONGVERSION_s1_s2: + error << wxT("Invalid version in stream, got v") << s1 << wxT(" but expected v") << s2 << wxT(" or higher"); + break; -/*static*/ wxString wxSerialize::GetLibVersionString () -{ - return wxString::Format(_T("wxSerialize v%d.%d"), GetLibVersionMajor(), GetLibVersionMinor()); -} + case wxSERIALIZE_ERR_STR_BADISTREAM: + error << wxT("Bad input stream"); + break; -/*static*/ long wxSerialize::GetLibVersionMajor () -{ - return WXSERIALIZE_MAJOR_VERSION; + case wxSERIALIZE_ERR_STR_BADOSTREAM: + error << wxT("Bad output stream"); + break; + + case wxSERIALIZE_ERR_STR_NOHEADER_s1: + error << wxT("No valid header found in stream but expected header '") << s1 << wxT("'"); + break; + + case wxSERIALIZE_ERR_STR_NOVERSION: + error << wxT("No version information found in stream"); + break; + + case wxSERIALIZE_ERR_STR_NOVERHDR: + error << wxT("Cannot write version and/or header information to stream"); + break; + + case wxSERIALIZE_ERR_STR_NOWRITE: + error << wxT("Cannot write while in read mode!"); + break; + + case wxSERIALIZE_ERR_STR_NOREAD: + error << wxT("Cannot read while in write mode!"); + break; + + case wxSERIALIZE_ERR_STR_EOF: + error << wxT("End of stream error while reading!"); + break; + + case wxSERIALIZE_ERR_STR_WRONGCHUNK_s1_s2: + error << wxT("Expected chunk item of type '") << s1 << wxT("' but got type '") << s2 << wxT("'"); + break; + + case wxSERIALIZE_ERR_STR_MEMORY_s1: + error << wxT("Memory allocation error. Cannot allocate ") << s1 << wxT(" bytes"); + break; + + case wxSERIALIZE_ERR_STR_READSIZE: + error << wxT("Record to read is 0 bytes or larger then expected (does not fit maxcount)"); + break; + + case wxSERIALIZE_ERR_STR_RINTSIZE: + error << wxT("Cannot read back 'int' value because it's of unknown size (need 1, 2, 4 or 8)"); + break; + + case wxSERIALIZE_ERR_STR_SINTSIZE: + error << wxT("Cannot save 'int' value because it's of unknown size (need 1, 2, 4 or 8)"); + break; + + case wxSERIALIZE_ERR_STR_ILL_LEAVE: + error << wxT("Sync Error: Illegal LeaveObject() header encountered, expected EnterObject()"); + break; + + case wxSERIALIZE_ERR_STR_ILL_UNKNOWN_HDR_s1: + error << wxT("Unknown '") << s1 << wxT("' header in stream"); + break; + + case wxSERIALIZE_ERR_STR_ILL_LEVEL: + error << wxT("Sync Error: Level dropped below 0, too much LeaveObject() calls ?"); + break; + + default: + error << wxT("Unknown error error (aint that something ...)"); + break; + } + + // log error to user + m_errMsg = error; + wxLogError(m_errMsg); + } + + return m_errorCode; } -/*static*/ long wxSerialize::GetLibVersionMinor () +/*static*/ wxString wxSerialize::GetLibVersionString() { - return WXSERIALIZE_MINOR_VERSION; + return wxString::Format(_T("wxSerialize v%d.%d"), GetLibVersionMajor(), GetLibVersionMinor()); } + +/*static*/ long wxSerialize::GetLibVersionMajor() { return WXSERIALIZE_MAJOR_VERSION; } + +/*static*/ long wxSerialize::GetLibVersionMinor() { return WXSERIALIZE_MINOR_VERSION; } diff --git a/SnipWiz/wxSerialize.h b/SnipWiz/wxSerialize.h index 7cbaea99aa..fabb3c7d41 100644 --- a/SnipWiz/wxSerialize.h +++ b/SnipWiz/wxSerialize.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : wxSerialize.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2008 by Eran Ifrah +// file name : wxSerialize.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + //--------------------------------------------------------------------------- // $RCSfile: wxSerialize.h $ // $Source: include/wx/wxSerialize.h $ @@ -38,11 +38,11 @@ #ifndef _WXSERIALIZE_H_ #define _WXSERIALIZE_H_ -#include #include -#include #include -#include // for wxSize, wxPoint +#include // for wxSize, wxPoint +#include +#include #define WXSERIALIZE_MAJOR_VERSION 1 #define WXSERIALIZE_MINOR_VERSION 1 @@ -50,468 +50,454 @@ /** \author Jorgen Bodde \mainpage - This is the wxSerialize documentation guide. wxSerialize is a serializing class meant for serializing / de-serializing - a complete (or partial) object model to a stream. The streaming is made type safe and reliable. This means when an - error occurs (wrong data read back or unexpected end of file) the wxSerialize class logs an error, and refuses to - read from the stream, leaving all variables that follow the error untouched, or in a default state. + This is the wxSerialize documentation guide. wxSerialize is a serializing class meant for serializing / + de-serializing a complete (or partial) object model to a stream. The streaming is made type safe and reliable. This + means when an error occurs (wrong data read back or unexpected end of file) the wxSerialize class logs an error, and + refuses to read from the stream, leaving all variables that follow the error untouched, or in a default state. - With the use of a version number and a header, the stream is checked when reading it back. When, for example you - wrote a stream with version 1000, and upon reading you expect version 900, the wxSerialize class logs an error that - the expected version is lower then the encountered version, avoiding a mis-read of data that is not supported in the - code. With the use of a header string, you can double check if the stream offered is really recognised by the - application. + With the use of a version number and a header, the stream is checked when reading it back. When, for example you + wrote a stream with version 1000, and upon reading you expect version 900, the wxSerialize class logs an error that + the expected version is lower then the encountered version, avoiding a mis-read of data that is not supported in the + code. With the use of a header string, you can double check if the stream offered is really recognised by the + application. - Because wxSerialize uses wxInputStream and wxOutputStream for reading and writing, the contents of the serialization - can be written to a memory based stream, a compression stream (like wxZLibOutputStream), a tcp/ip socket, from - an wxURL (from the internet, handy for updates), or any other stream based upon wxInputStream / wxOutputStream. + Because wxSerialize uses wxInputStream and wxOutputStream for reading and writing, the contents of the serialization + can be written to a memory based stream, a compression stream (like wxZLibOutputStream), a tcp/ip socket, from + an wxURL (from the internet, handy for updates), or any other stream based upon wxInputStream / wxOutputStream. - The streaming is binary compatible on Linux / Windows and MacOSX which means that if you read back the binary data - from disk, the same results are read back, the values are properly converted from little to big endian. + The streaming is binary compatible on Linux / Windows and MacOSX which means that if you read back the binary data + from disk, the same results are read back, the values are properly converted from little to big endian. - \section serializing_exactly Ok but what is serializing exactly? + \section serializing_exactly Ok but what is serializing exactly? - Serializing is putting the contents of a class to an output file. Microsoft's MFC used CArchive (which I attempted - to keep as API compatible as possible) and boost now also has a binary serializer. So, how does it work? Well it - is really simple. The power of the serializing lies in the fact that the classes themselves are responsible for - serializing their data. It is very short in code, and the destination of the serialization stream doesn't really - matter. + Serializing is putting the contents of a class to an output file. Microsoft's MFC used CArchive (which I attempted + to keep as API compatible as possible) and boost now also has a binary serializer. So, how does it work? Well it + is really simple. The power of the serializing lies in the fact that the classes themselves are responsible for + serializing their data. It is very short in code, and the destination of the serialization stream doesn't really + matter. \section how_work So how does it work? - Consider the following class: - - \code - class MyDataClass - { - public: - // the serialization class, that streams from and to the - // specified stream. - Serialize(wxSerialize &a); - - private: - wxString m_name; - wxString m_address; - wxUint8 m_age; - wxArrayString m_siblings; - }; - \endcode - How does the serializing work .. We simply implement the Serialize method: - \code - bool MyDataClass::Serialize(wxSerialize &a) - { - if(a.IsStoring()) - { - a << m_name << m_address << m_age; - a << m_siblings; - } - else - { - a >> m_name >> m_address >> m_age; - a >> m_siblings; - } - - // return false when the archive encountered an error - return a.IsOk(); - } - \endcode - - This is all there is to it! This small piece of code, serializes the 4 used member vars to the stream, on disk - or where it needs to go. The following code shows how the class is serialized. First when it is saved to disk: - - \code - wxFileOutputStream file("somefile.dat"); - wxSerialize a(file); - - m_ourClass->Serialize(a); - \endcode - - That's all! When the file and archive are out of scope, the file is closed and the object is persistent on disk. - Now to read the data back: - - \code - wxFileInputStream file("somefile.dat"); - wxSerialize a(file); - - // let's say we just create it and initialize it - m_ourClass = new MyDataClass(); - m_ourClass->Serialize(a); - \endcode - - Nearly identical code isn't it ? Even the new MyDataClass() is not needed, it is simply there to illustrate how - newly created objects can be serialized back into. Only one method is needed, I called it Serialize() but the - name does not matter. - - \section why_using So why not write using wxConfig, wxFFile, XML or use XTI? - - This serializer class was designed, keeping in mind a small footprint in memory and disk. When serializing to XML - you gain flexibility and even can hand-edit it, but the overhead in the class is enormous. You have to figure out - how the data needs to be stored, attribute names, nested hierarchies, handle errors, etc. XML is basically better - to write to, if user editing or portability is a big issue. - - Serializing to a binary file can be more useful in the following situations: - - - Writing cache data (e.g. an object model that represents a state in memory). By writing this in a serialized - stream to disk, the object model can be quickly read back between sessions, or heavy preprocessing (e.g storing - a directory structure to disk) can be avoided. - - Undo / Redo mechanism. Usually undo / redo mechanisms require a lot of overhead in the object model. For example - when the user deletes a data item in a GUI window, this item should not be really deleted, only taken apart from the - object model. When using a serializer class, the object can be removed, and later on re-created back on it's - rightful place. The good thing is that the serialize methods can both handle undo / redo, but also save the - data to disk. + Consider the following class: + + \code + class MyDataClass + { + public: + // the serialization class, that streams from and to the + // specified stream. + Serialize(wxSerialize &a); + + private: + wxString m_name; + wxString m_address; + wxUint8 m_age; + wxArrayString m_siblings; + }; + \endcode + How does the serializing work .. We simply implement the Serialize method: + \code + bool MyDataClass::Serialize(wxSerialize &a) + { + if(a.IsStoring()) + { + a << m_name << m_address << m_age; + a << m_siblings; + } + else + { + a >> m_name >> m_address >> m_age; + a >> m_siblings; + } + + // return false when the archive encountered an error + return a.IsOk(); + } + \endcode + + This is all there is to it! This small piece of code, serializes the 4 used member vars to the stream, on disk + or where it needs to go. The following code shows how the class is serialized. First when it is saved to disk: + + \code + wxFileOutputStream file("somefile.dat"); + wxSerialize a(file); + + m_ourClass->Serialize(a); + \endcode + + That's all! When the file and archive are out of scope, the file is closed and the object is persistent on disk. + Now to read the data back: + + \code + wxFileInputStream file("somefile.dat"); + wxSerialize a(file); + + // let's say we just create it and initialize it + m_ourClass = new MyDataClass(); + m_ourClass->Serialize(a); + \endcode + + Nearly identical code isn't it ? Even the new MyDataClass() is not needed, it is simply there to illustrate how + newly created objects can be serialized back into. Only one method is needed, I called it Serialize() but the + name does not matter. + + \section why_using So why not write using wxConfig, wxFFile, XML or use XTI? + + This serializer class was designed, keeping in mind a small footprint in memory and disk. When serializing to XML + you gain flexibility and even can hand-edit it, but the overhead in the class is enormous. You have to figure out + how the data needs to be stored, attribute names, nested hierarchies, handle errors, etc. XML is basically better + to write to, if user editing or portability is a big issue. + + Serializing to a binary file can be more useful in the following situations: + + - Writing cache data (e.g. an object model that represents a state in memory). By writing this in a serialized + stream to disk, the object model can be quickly read back between sessions, or heavy preprocessing (e.g storing + a directory structure to disk) can be avoided. + - Undo / Redo mechanism. Usually undo / redo mechanisms require a lot of overhead in the object model. For example + when the user deletes a data item in a GUI window, this item should not be really deleted, only taken apart from + the object model. When using a serializer class, the object can be removed, and later on re-created back on it's + rightful place. The good thing is that the serialize methods can both handle undo / redo, but also save the + data to disk. - Small applications that do not require overhead of XML, SQL, or use wxConfig because these all need name / value - conventions. With very small applications that only perform minor tasks, the developer is more distracted by - the writing to disk then it's really needed. + conventions. With very small applications that only perform minor tasks, the developer is more distracted by + the writing to disk then it's really needed. - Writing config. This sounds odd, but when you have a global config object, and it is not really necessary to - keep all that data in a text file, serializing the object containing the config is rather easy. + keep all that data in a text file, serializing the object containing the config is rather easy. - So when is it not useful? + So when is it not useful? - - Ofcourse when people want to edit the data afterwards. - - When the data needs to be exchanged between applications using a standard format - - When the application needs to process huge data, or store entered data on disk to be queried later on (SQL or - XML). + - Ofcourse when people want to edit the data afterwards. + - When the data needs to be exchanged between applications using a standard format + - When the application needs to process huge data, or store entered data on disk to be queried later on (SQL or + XML). \section what_dp What about data flexibility? - People who spent some time serializing data, know that when for example a binary serialized file is written to disk - and the object is extended with more data, you have a problem with serializing it back. - Why? The data in the stream is only compatible with the old data makeup, and when adding new member vars how are - you going to read them back? They are not in the stream to begin with, and you don't even know if they are or not. - Well I deviced two ways of doing this. Let's for example extend our rather trivial MyDataClass class: - - \code - class MyDataClass - { - public: - // the serialization class, that streams from and to the - // specified stream. - Serialize(wxSerialize &a); - - private: - wxString m_name; - wxString m_address; - wxUint8 m_age; - wxArrayString m_siblings; - - // NEW DATA ADDED, THIS NEEDS SERIALIZING TOO! - wxUint32 m_monthlyPay; - bool m_healthInsurance; - }; - \endcode - - - \subsection version_number Using a version number - - The version number you can give to the stream when you write it back. This version number is stored and checked upon - reading. When creating the stream you specify the version of the stream. You increment this version when there will - be binary incompatibility with older streams: - - \code - wxFileOutputStream file("somefile.dat"); - wxSerialize a(file, 1001); // latest version is 1001 (was 1000) - - m_ourClass->Serialize(a); - \endcode - - Now in the code we can take this in account when reading. When we save, we simply save our new data back. And - as you guessed the drawback, older applications still in the field cannot read the newer stream: - - \code - bool MyDataClass::Serialize(wxSerialize &a) - { - if(a.IsStoring()) - { - // simply write all - a << m_name << m_address << m_age; - a << m_siblings; - - // always append new data here, so reading back goes in - // the same exact order as it is written - a << m_monthlyPay << m_healthInsurance; - } - else - { - a >> m_name >> m_address >> m_age; - a >> m_siblings; - - // reading back poses a problem. We can have the data but in - // an older stream we have not. So we need the version check: - if(a.GetVersion() > 1000) - { - a >> m_monthlyPay >> m_healthInsurance; - } - } - - // return false when the archive encountered an error - return a.IsOk(); - } - \endcode - - As you might have guessed, this can be some overhead. While developing the app, this can happen a lot - as the classes grow. So the disadvantages are: - - - Older releases you wrote (and are in the field) cannot read the newer data back. So when you use serialization - as part of packages or updates, people are obliged to update, or you must provide multiple versions) - - All the newer data require a version check at read time, and will bloat your application as you must take in - account all older streams. A small overhead, but lots of changes will simply bloat your code with GetVersion() - checks which is not really elegant. - - \subsection enter_leave Using EnterObject() and LeaveObject() - - To reduce the code overhead, and maintain binary read compatiblity between older and newer releases of your - application, I deviced a way which allows you to add member data to your serializing routines and not break - the reading of older or even newer streams. This is how it works; - - \code - bool MyDataClass::Serialize(wxSerialize &a) - { - a.EnterObject(); - if(a.IsStoring()) - { - // simply write all - a << m_name << m_address << m_age; - a << m_siblings; - a << m_monthlyPay << m_healthInsurance; - } - else - { - a >> m_name >> m_address >> m_age; - a >> m_siblings; - a >> m_monthlyPay >> m_healthInsurance; - } - a.LeaveObject(); - - return a.IsOk(); - } - \endcode - - Done! These two powerful boundaries (EnterObject() and LeaveObject()) tackle two situations: - - - Reading an old stream in a newer application. So what happens, when for example the older stream does not contain the - m_monthlyPay and m_healthInsurance, the LeaveObject() boundary was already written in the old code. The stream - recognises this, and refuses to read data into m_monthlyPay and m_healthInsurance. In these cases the default - value will be kept in these members. Data that follows after the boundary when LeaveObject was not called, - will be kept default. - - Reading a newer stream with an older application. When the application you released in the field is older then the stream - being written by the newer release, more data is present in the stream then the old application knows about. - Here the same situation applies. The LeaveObject() in the old code comes sooner then the expected leave boundary - in the stream, so wxSerialize will go look for the boundary and ignore all data that is newer. - - The EnterObject() and LeaveObject() construction keeps the stream in sync. The only important thing to remember is - that you MUST USE these boundaries from the first moment and not when you are adding new member objects later on. - It is a small sacrifice to gain a lot of flexibility! The overhead in the stream is also very small, because the - footprint of the boundaries is exactly 1 byte for the enter and 1 byte for the leave marker. - - EnterObject() and LeaveObject() can be used multiple times after eachother, and also nested. So when you serialize - a class hierarchy and in one of your child objects also data changes, this will be possible. - - The only drawback that is left with this approach (but is also present in all data writing when older applications - write back data that contained newer information) is that newer data is being overwritten. You must take special - caution (for example using the version tag or wxSerializeStatus object) in your application to warn the user that - the data being written will destroy newer information in the serializing stream. The newer release of your - application can still read this stream, but newer data is defaulted again. - - Also another caveat is that when you replace data being read back it will not work, not with EnterObject() / + People who spent some time serializing data, know that when for example a binary serialized file is written to disk + and the object is extended with more data, you have a problem with serializing it back. + Why? The data in the stream is only compatible with the old data makeup, and when adding new member vars how are + you going to read them back? They are not in the stream to begin with, and you don't even know if they are or not. + Well I deviced two ways of doing this. Let's for example extend our rather trivial MyDataClass class: + + \code + class MyDataClass + { + public: + // the serialization class, that streams from and to the + // specified stream. + Serialize(wxSerialize &a); + + private: + wxString m_name; + wxString m_address; + wxUint8 m_age; + wxArrayString m_siblings; + + // NEW DATA ADDED, THIS NEEDS SERIALIZING TOO! + wxUint32 m_monthlyPay; + bool m_healthInsurance; + }; + \endcode + + + \subsection version_number Using a version number + + The version number you can give to the stream when you write it back. This version number is stored and checked upon + reading. When creating the stream you specify the version of the stream. You increment this version when there will + be binary incompatibility with older streams: + + \code + wxFileOutputStream file("somefile.dat"); + wxSerialize a(file, 1001); // latest version is 1001 (was 1000) + + m_ourClass->Serialize(a); + \endcode + + Now in the code we can take this in account when reading. When we save, we simply save our new data back. And + as you guessed the drawback, older applications still in the field cannot read the newer stream: + + \code + bool MyDataClass::Serialize(wxSerialize &a) + { + if(a.IsStoring()) + { + // simply write all + a << m_name << m_address << m_age; + a << m_siblings; + + // always append new data here, so reading back goes in + // the same exact order as it is written + a << m_monthlyPay << m_healthInsurance; + } + else + { + a >> m_name >> m_address >> m_age; + a >> m_siblings; + + // reading back poses a problem. We can have the data but in + // an older stream we have not. So we need the version check: + if(a.GetVersion() > 1000) + { + a >> m_monthlyPay >> m_healthInsurance; + } + } + + // return false when the archive encountered an error + return a.IsOk(); + } + \endcode + + As you might have guessed, this can be some overhead. While developing the app, this can happen a lot + as the classes grow. So the disadvantages are: + + - Older releases you wrote (and are in the field) cannot read the newer data back. So when you use serialization + as part of packages or updates, people are obliged to update, or you must provide multiple versions) + - All the newer data require a version check at read time, and will bloat your application as you must take in + account all older streams. A small overhead, but lots of changes will simply bloat your code with GetVersion() + checks which is not really elegant. + + \subsection enter_leave Using EnterObject() and LeaveObject() + + To reduce the code overhead, and maintain binary read compatiblity between older and newer releases of your + application, I deviced a way which allows you to add member data to your serializing routines and not break + the reading of older or even newer streams. This is how it works; + + \code + bool MyDataClass::Serialize(wxSerialize &a) + { + a.EnterObject(); + if(a.IsStoring()) + { + // simply write all + a << m_name << m_address << m_age; + a << m_siblings; + a << m_monthlyPay << m_healthInsurance; + } + else + { + a >> m_name >> m_address >> m_age; + a >> m_siblings; + a >> m_monthlyPay >> m_healthInsurance; + } + a.LeaveObject(); + + return a.IsOk(); + } + \endcode + + Done! These two powerful boundaries (EnterObject() and LeaveObject()) tackle two situations: + + - Reading an old stream in a newer application. So what happens, when for example the older stream does not + contain the m_monthlyPay and m_healthInsurance, the LeaveObject() boundary was already written in the old code. The + stream recognises this, and refuses to read data into m_monthlyPay and m_healthInsurance. In these cases the default + value will be kept in these members. Data that follows after the boundary when LeaveObject was not called, + will be kept default. + - Reading a newer stream with an older application. When the application you released in the field is older + then the stream being written by the newer release, more data is present in the stream then the old application knows + about. Here the same situation applies. The LeaveObject() in the old code comes sooner then the expected leave + boundary in the stream, so wxSerialize will go look for the boundary and ignore all data that is newer. + + The EnterObject() and LeaveObject() construction keeps the stream in sync. The only important thing to remember is + that you MUST USE these boundaries from the first moment and not when you are adding new member objects later on. + It is a small sacrifice to gain a lot of flexibility! The overhead in the stream is also very small, because the + footprint of the boundaries is exactly 1 byte for the enter and 1 byte for the leave marker. + + EnterObject() and LeaveObject() can be used multiple times after eachother, and also nested. So when you serialize + a class hierarchy and in one of your child objects also data changes, this will be possible. + + The only drawback that is left with this approach (but is also present in all data writing when older + applications write back data that contained newer information) is that newer data is being overwritten. You must take + special caution (for example using the version tag or wxSerializeStatus object) in your application to warn the user + that the data being written will destroy newer information in the serializing stream. The newer release of your + application can still read this stream, but newer data is defaulted again. + + Also another caveat is that when you replace data being read back it will not work, not with EnterObject() / LeaveObject() but also not with a versioned stream. Consider this example: - \code - bool MyDataClass::Serialize(wxSerialize &a) - { - a.EnterObject(); - if(a.IsStoring()) - { - // simply write all - a << m_name << m_address << m_age; - a << m_siblings; + \code + bool MyDataClass::Serialize(wxSerialize &a) + { + a.EnterObject(); + if(a.IsStoring()) + { + // simply write all + a << m_name << m_address << m_age; + a << m_siblings; //a << m_monthlyPay << m_healthInsurance; // REPLACED NOW with: a << m_surName << m_middleName; - } - else - { - a >> m_name >> m_address >> m_age; - a >> m_siblings; - // WON'T WORK! In older versions the two vars m_monthlypay and m_healthInsurance + } + else + { + a >> m_name >> m_address >> m_age; + a >> m_siblings; + // WON'T WORK! In older versions the two vars m_monthlypay and m_healthInsurance // were stored here, instead we read back this. If the stream we read back do not - // contain these new replaced variables yet, we are hitting an error state. + // contain these new replaced variables yet, we are hitting an error state. a >> m_surName >> m_middleName; - } - a.LeaveObject(); - - return a.IsOk(); - } - \endcode - - \subsection archive_status wxSerializeStatus Helper Class - - This class is especially designed to keep the status of the stream between reading and writing. It contains the - last version being written or read, the header, and more important, an NewDataLoss() flag. This flag will be set - when the stream being read back is newer then the data model it's beaing serialized into. Writing the data back - using the wxSerializeStatus object earlier retrieved when reading will prevent the write if the flag NewDataLoss() - is not reset using OverwriteNew() flag. How is the flag determined? Well, if one time in the data serializing - process the LeaveObject() method needs to search for the marker (thus skipping newer data in the stream) this - flag is set. - - This wxSerializeStatus class will also remove the need of writing the same header back as being specified when - reading, and also the version will be preserved. The member wxSerializeStatus::SetVersion() can be used to specify - a newer version. Here is an example, first when reading we store the last status and keep it: - - \code - wxFileInputStream file("somefile.dat"); - wxSerialize a(file); - - // let's say we just create it and initialize it - m_ourClass = new MyDataClass(); - m_ourClass->Serialize(a); - - // store the status (copy class) - m_ourStatus = a.GetArchiveStatus(); - \endcode - - When writing back, and this application is older then the newer application, thus an overwrite will result - in newer information loss: - - - \code - // if the last time we read a newer stream, tell the user - if(m_ourStatus.NewDataLoss()) - { - if(::wxMessageDialog( ... "ask if we should overwrite, it will result in dataloss" ...) == wxID_YES) - m_ourStatus.OverwriteNew(); // reset the flag - } - - // if the flag is reset we continue else we skip - if(!m_ourStatus.NewDataLoss()) - { - wxFileOutputStream file("somefile.dat"); - wxSerialize a(file, m_ourStatus.GetVersion(), m_ourStatus.GetHeader()); - // serialize data - m_ourClass->Serialize(a); - } - else - { - wxLogError("Data is not saved!"); - } - \endcode - - This construction prevents the application of accidentally writing data back and destroying newer serialized data. - The user must explicitly agree upon this, or the developer must provide a mechanism to backup the old file so that - newer data is not lost when reading it back in the newer application. + } + a.LeaveObject(); + + return a.IsOk(); + } + \endcode + + \subsection archive_status wxSerializeStatus Helper Class + + This class is especially designed to keep the status of the stream between reading and writing. It contains the + last version being written or read, the header, and more important, an NewDataLoss() flag. This flag will be set + when the stream being read back is newer then the data model it's beaing serialized into. Writing the data back + using the wxSerializeStatus object earlier retrieved when reading will prevent the write if the flag NewDataLoss() + is not reset using OverwriteNew() flag. How is the flag determined? Well, if one time in the data serializing + process the LeaveObject() method needs to search for the marker (thus skipping newer data in the stream) this + flag is set. + + This wxSerializeStatus class will also remove the need of writing the same header back as being specified when + reading, and also the version will be preserved. The member wxSerializeStatus::SetVersion() can be used to specify + a newer version. Here is an example, first when reading we store the last status and keep it: + + \code + wxFileInputStream file("somefile.dat"); + wxSerialize a(file); + + // let's say we just create it and initialize it + m_ourClass = new MyDataClass(); + m_ourClass->Serialize(a); + + // store the status (copy class) + m_ourStatus = a.GetArchiveStatus(); + \endcode + + When writing back, and this application is older then the newer application, thus an overwrite will result + in newer information loss: + + + \code + // if the last time we read a newer stream, tell the user + if(m_ourStatus.NewDataLoss()) + { + if(::wxMessageDialog( ... "ask if we should overwrite, it will result in dataloss" ...) == wxID_YES) + m_ourStatus.OverwriteNew(); // reset the flag + } + + // if the flag is reset we continue else we skip + if(!m_ourStatus.NewDataLoss()) + { + wxFileOutputStream file("somefile.dat"); + wxSerialize a(file, m_ourStatus.GetVersion(), m_ourStatus.GetHeader()); + // serialize data + m_ourClass->Serialize(a); + } + else + { + wxLogError("Data is not saved!"); + } + \endcode + + This construction prevents the application of accidentally writing data back and destroying newer serialized data. + The user must explicitly agree upon this, or the developer must provide a mechanism to backup the old file so that + newer data is not lost when reading it back in the newer application. */ /** \class wxSerializeStatus - \brief A simple helper class that keeps track of the current version of the archive, the header and - more important, when at reading time it appears the stream contains newer data then expected. - It will help the developer in asking the user if the stream might be saved back or not. See - \ref archive_status overview for more information. + \brief A simple helper class that keeps track of the current version of the archive, the header and + more important, when at reading time it appears the stream contains newer data then expected. + It will help the developer in asking the user if the stream might be saved back or not. See + \ref archive_status overview for more information. */ class wxSerializeStatus { public: - /** Constructor of the wxSerializeStatus object. This is the default constructor so you can - define it in the class itself without having to do anything for it */ - wxSerializeStatus() - : m_version(0) - , m_header(wxT("")) - , m_newDataLoss(false) - { - }; - - /** Constructor initializer of the wxSerializeStatus object. Used by wxSerialize to fill in the goods - so they can be used later */ - wxSerializeStatus(size_t version, const wxString &header) - : m_version(version) - , m_header(header) - , m_newDataLoss(false) - { - }; - - ~wxSerializeStatus() { - }; - - /** Copy operator to get the latest copy of it from the wxSerialize class, and assign it to your copy */ - void operator=(const wxSerializeStatus &s) { - m_version = s.m_version; - m_header = s.m_header; - m_newDataLoss = s.m_newDataLoss; - }; - - /** With this method you tell wxSerialize that it is ok to overwrite the newer data stream with an older - version of it. This needs to be set implicitly. Check out \ref archive_status for more information. - */ - void OverwriteNew() { - m_newDataLoss = false; - }; - - /** This method returns the flag of the current NewDataLoss status. It will be set when the wxSerialize - encounters an out of sync where there is more data then can be read back. See \ref enter_leave - */ - bool NewDataLoss() const { - return m_newDataLoss; - }; - - /** Sets the NewDataLoss flag again. This is used by wxSerialize only, or you can use it to prevent other - parts of the your code to be executed later when new data loss still occurs. The counterpart of this - flag is OverwriteNew() */ - void SetNewDataLoss() { - m_newDataLoss = true; - }; - - /** Returns the version of the last read archive */ - size_t GetVersion() const { - return m_version; - }; - - /** Returns the header of the last read archive */ - const wxString &GetHeader() const { - return m_header; - }; + /** Constructor of the wxSerializeStatus object. This is the default constructor so you can + define it in the class itself without having to do anything for it */ + wxSerializeStatus() + : m_version(0) + , m_header(wxT("")) + , m_newDataLoss(false) {}; + + /** Constructor initializer of the wxSerializeStatus object. Used by wxSerialize to fill in the goods + so they can be used later */ + wxSerializeStatus(size_t version, const wxString& header) + : m_version(version) + , m_header(header) + , m_newDataLoss(false) {}; + + ~wxSerializeStatus() {}; + + /** Copy operator to get the latest copy of it from the wxSerialize class, and assign it to your copy */ + void operator=(const wxSerializeStatus& s) + { + m_version = s.m_version; + m_header = s.m_header; + m_newDataLoss = s.m_newDataLoss; + }; + + /** With this method you tell wxSerialize that it is ok to overwrite the newer data stream with an older + version of it. This needs to be set implicitly. Check out \ref archive_status for more information. + */ + void OverwriteNew() { m_newDataLoss = false; }; + + /** This method returns the flag of the current NewDataLoss status. It will be set when the wxSerialize + encounters an out of sync where there is more data then can be read back. See \ref enter_leave + */ + bool NewDataLoss() const { return m_newDataLoss; }; + + /** Sets the NewDataLoss flag again. This is used by wxSerialize only, or you can use it to prevent other + parts of the your code to be executed later when new data loss still occurs. The counterpart of this + flag is OverwriteNew() */ + void SetNewDataLoss() { m_newDataLoss = true; }; + + /** Returns the version of the last read archive */ + size_t GetVersion() const { return m_version; }; + + /** Returns the header of the last read archive */ + const wxString& GetHeader() const { return m_header; }; private: - size_t m_version; - wxString m_header; - bool m_newDataLoss; + size_t m_version; + wxString m_header; + bool m_newDataLoss; }; /** \class wxSerialize - \brief A serializer class that can serialize the contents of your class to or from a stream. It uses wxInputStream - and wxOutputStream derived classes for input and output. + \brief A serializer class that can serialize the contents of your class to or from a stream. It uses wxInputStream + and wxOutputStream derived classes for input and output. - See the \ref mainpage for more information + See the \ref mainpage for more information */ class wxSerialize { public: /** Construct an input stream archive. The stream will be used to retrieve the data from, which can be any - derived stream like a file, zip stream etc. When constructed as input, the wxSerialize object cannot - be written to. + derived stream like a file, zip stream etc. When constructed as input, the wxSerialize object cannot + be written to. The first integer and string are always read from the stream. This contains the version number (or 0 when - not used) and the header which is empty if not used. + not used) and the header which is empty if not used. When setting the version parameter, wxSerialize will check if the version read back is at least the expected - version. For example, when version argument is set to 1000, wxSerialize will accept versions 0 .. 1000 for reading - but will give an error if version 1001 and up is read from the stream. You can use this to set the version to - at least the supported version for your code. When extending the serialization routines after your app has - been deployed, the version info can be used to dynamically skip parts while loading from an older stream, - and warn users that the version of the read stream is older which means incompatibility with - the older application will occur. This is not the recommended method though, see EnterObject() and LeaveObject() - for a more flexible solution. + version. For example, when version argument is set to 1000, wxSerialize will accept versions 0 .. 1000 for + reading but will give an error if version 1001 and up is read from the stream. You can use this to set the + version to at least the supported version for your code. When extending the serialization routines after your app + has been deployed, the version info can be used to dynamically skip parts while loading from an older stream, and + warn users that the version of the read stream is older which means incompatibility with the older application + will occur. This is not the recommended method though, see EnterObject() and LeaveObject() for a more flexible + solution. The header tag will also be compared when it is not empty. When an empty header is passed as parameter, the read - back header tag is ignored. When the header argument is set, and the read back header is empty or different, - an error will occur and the stream cannot be read back from. This can provide an extra check if the stream - will contain the data needed. + back header tag is ignored. When the header argument is set, and the read back header is empty or different, + an error will occur and the stream cannot be read back from. This can provide an extra check if the stream + will contain the data needed. The partialMode flag will do nothing else but setting a flag (IsFullSerialize()) which can be used in - serializing to skip some relational hierarchies and stuff not needed when the object is only partially - serialized to the stream (handy for undo / redo mechanisms). When set to true, IsFullSerialize() will - return false. + serializing to skip some relational hierarchies and stuff not needed when the object is only partially + serialized to the stream (handy for undo / redo mechanisms). When set to true, IsFullSerialize() will + return false. \code // open and write wxFileInputStream in_stream("somefile.dat"); - wxSerialize a(in_stream, 1000, _T("My Stream")); + wxSerialize a(in_stream, 1000, _T("My Stream")); if(a.IsOk()) { a >> m_name; @@ -525,20 +511,23 @@ class wxSerialize a.Close(); \endcode - See also \ref enter_leave and read about data flexibility. + See also \ref enter_leave and read about data flexibility. - \sa IsFullSerialize(), wxSerializeStatus + \sa IsFullSerialize(), wxSerializeStatus */ - wxSerialize(wxInputStream &stream, size_t version = 0, const wxString &header = wxEmptyString, bool partialMode = false); + wxSerialize(wxInputStream& stream, + size_t version = 0, + const wxString& header = wxEmptyString, + bool partialMode = false); /** Construct an output stream object. The stream will be used to save the data to, which can be any derived - stream like a file, zip stream etc. When constructed as output, the wxSerialize object cannot be read from. + stream like a file, zip stream etc. When constructed as output, the wxSerialize object cannot be read from. \code // open and write wxFileOutputStream out_file("somefile.dat"); - wxSerialize a(out_file, 1000, _T("My Stream")); + wxSerialize a(out_file, 1000, _T("My Stream")); a << m_name; a << m_age; a << m_string << m_count; @@ -548,57 +537,59 @@ class wxSerialize \endcode The version (1000 in example) is saved in the stream, also the header. At reading time these two are checked - against what the expected version and header are, so that you can be sure the stream is recognised and - supported. + against what the expected version and header are, so that you can be sure the stream is recognised and + supported. Always save your latest supported version here. This means when you extended your application's serialization, - increment the version. This will allow you to read back older streams and save them with newer information. - See \ref enter_leave for more ways to make your serialization more flexible. + increment the version. This will allow you to read back older streams and save them with newer information. + See \ref enter_leave for more ways to make your serialization more flexible. */ - wxSerialize(wxOutputStream &stream, size_t version = 1, const wxString &header = wxEmptyString, bool partialMode = false); + wxSerialize(wxOutputStream& stream, + size_t version = 1, + const wxString& header = wxEmptyString, + bool partialMode = false); /** Destructor. The passed stream ombject will not be destroyed, because it is used by reference */ virtual ~wxSerialize(); /** Closes the archive. This means all writing or reading done to it will not affect the archive or variables - passed by reference. A closed archive will not produce any errors when read from and will not advance in - searching. A closed archive can be re-opened with Open() to allow reading or writing again. */ - void Close() { - m_opened = false; - }; + passed by reference. A closed archive will not produce any errors when read from and will not advance in + searching. A closed archive can be re-opened with Open() to allow reading or writing again. */ + void Close() { m_opened = false; }; /** Re-opens the archive. But only when the archive is in OK state (IsOk() == true). By default the archive is - opened when the constructor is created and everything went ok */ - void Open() { + opened when the constructor is created and everything went ok */ + void Open() + { // it can be as simple as this m_opened = IsOk(); }; /** In reading mode, it returns true when the stream we are reading from returns true on Eof(). It means that it returns true AFTER an attempt has been made to read past the end of the stream. - In writing mode Eof() returns always false. When the stream is closed, true is always returned, - we can't read or write anymore in that case anyway. Reading more from a stream that is at it's + In writing mode Eof() returns always false. When the stream is closed, true is always returned, + we can't read or write anymore in that case anyway. Reading more from a stream that is at it's end will produce errors. - */ + */ bool Eof(); - /** Returns true when the wxSerialize is in OK condition. This means no error occurred. Errors that can occur are - for example: - - The underlying stream reports that it is not OK (not able to write, not able to read) - - Reading an unexpected type of variable (e.g. expecting int and reading back string) - - Reading from a wxSerialize with a higher version then supported - - Reading from a wxSerialize with a wrong header - - Writing to the wxSerialize when we are in reading mode - - Reading from the wxSerialize when we are in writing mode + /** Returns true when the wxSerialize is in OK condition. This means no error occurred. Errors that can occur are + for example: + - The underlying stream reports that it is not OK (not able to write, not able to read) + - Reading an unexpected type of variable (e.g. expecting int and reading back string) + - Reading from a wxSerialize with a higher version then supported + - Reading from a wxSerialize with a wrong header + - Writing to the wxSerialize when we are in reading mode + - Reading from the wxSerialize when we are in writing mode - See GetLastError() to retrieve the error, and GetLastErrorString() for an explanation. When the wxSerialize - encountered errors, it will remain in an error state, subsequent reads and writes will not have effect to - either the member variables to read to, or write anything to the stream when writing, for example: + See GetLastError() to retrieve the error, and GetLastErrorString() for an explanation. When the wxSerialize + encountered errors, it will remain in an error state, subsequent reads and writes will not have effect to + either the member variables to read to, or write anything to the stream when writing, for example: - \code - wxSerialize a(in_stream); + \code + wxSerialize a(in_stream); - // .. some code + // .. some code if(a.IsStoring()) { @@ -628,96 +619,95 @@ class wxSerialize a >> m_name >> m_address >> m_age; // be careful here, because count is not set by default - // so we set it to 0. Now the for loop will quit right away + // so we set it to 0. Now the for loop will quit right away int count = 0; a >> count; for(int i = 0; i < count; i++) a >> m_value; } - // return status to lower part - return a.IsOk(); - \endcode - */ - bool IsOk() { - bool noerr = (m_errorCode == wxSERIALIZE_ERR_OK); - if(m_writeMode) - return m_odstr.IsOk() && noerr; - else - return m_idstr.IsOk() && noerr; - }; - - /** Returns the last error set in this string. */ - const wxString &GetLastErrorStr() const { - return m_errMsg; - }; - - /** This method allows you to specify regions of an object that wxSerialize can identify. This allows - you to read back old streams, and still serialize all data back from the stream. All the data that - is not present in the stream reading back is skipped. This will reduce the problem that old streams - do not contain all data that is needed, it will simply be skipped. See \ref enter_leave for a bigger - explanation, basically when using this, you ensure older applications can read newer streams, and - newer applications can also read older streams. - - The only restriction is that you keep the data in the same order. This means the new added data - always needs to be read and written at the end of the original data. - - The method returns false when the object entering did not work (always returns true in write mode - but can return false plus an error when the current level could not be found. If this is the case - the wxSerialize class stays in an error state so it won't be harmful trying to read or write anyway. - - For example: - - \code - wxSerialize a(in_stream); - - if(a.EnterObject()) - { - // we succesfully entered the object level - if(a.IsLoading()) - { - a >> m_name; - a >> m_age; - - // these vars are not present in the older stream. At this point, - // all serializing into the variables will not take place. They will - // be left default, so initializing before the construction gives them - // a default value, but the stream reader does not give errors, here - // it is best to use the ReadInt and ReadString directly with a default - // specifier: - - a.ReadInt(m_peopeCount, 0); // default no people when not present - a.ReadUint8(m_numberOfPersons, 1); // default 1 person - } - else - { - // save the stream back, now all vars can be read back. The interesting - // thing is that older programs can still read the streams back as they - // scan for the LeaveObject() marker at the end of their serializing round - - a << m_name; - a << m_age; - - a << m_peopeCount; - a << m_numberOfPersons; - } - a.LeaveObject(); - } - \endcode - */ - bool EnterObject(); - - /** This the leave method that belongs to the EnterObject() method. Please always close the - section with the LeaveObject() when an EnterObject() is used. These two constructions can - be nested also. See \ref enter_leave for more information. - - \sa EnterObject() - */ - bool LeaveObject(); - - /** Indicates current state is writing. This flag will always be true if wxSerialize is constructed with a - wxOutputStream. The IsStoring() does not check wether the state of the stream is ok or not, - to prevent problems do: + // return status to lower part + return a.IsOk(); + \endcode + */ + bool IsOk() + { + bool noerr = (m_errorCode == wxSERIALIZE_ERR_OK); + if (m_writeMode) + return m_odstr.IsOk() && noerr; + else + return m_idstr.IsOk() && noerr; + }; + + /** Returns the last error set in this string. */ + const wxString& GetLastErrorStr() const { return m_errMsg; }; + + /** This method allows you to specify regions of an object that wxSerialize can identify. This allows + you to read back old streams, and still serialize all data back from the stream. All the data that + is not present in the stream reading back is skipped. This will reduce the problem that old streams + do not contain all data that is needed, it will simply be skipped. See \ref enter_leave for a bigger + explanation, basically when using this, you ensure older applications can read newer streams, and + newer applications can also read older streams. + + The only restriction is that you keep the data in the same order. This means the new added data + always needs to be read and written at the end of the original data. + + The method returns false when the object entering did not work (always returns true in write mode + but can return false plus an error when the current level could not be found. If this is the case + the wxSerialize class stays in an error state so it won't be harmful trying to read or write anyway. + + For example: + + \code + wxSerialize a(in_stream); + + if(a.EnterObject()) + { + // we succesfully entered the object level + if(a.IsLoading()) + { + a >> m_name; + a >> m_age; + + // these vars are not present in the older stream. At this point, + // all serializing into the variables will not take place. They will + // be left default, so initializing before the construction gives them + // a default value, but the stream reader does not give errors, here + // it is best to use the ReadInt and ReadString directly with a default + // specifier: + + a.ReadInt(m_peopeCount, 0); // default no people when not present + a.ReadUint8(m_numberOfPersons, 1); // default 1 person + } + else + { + // save the stream back, now all vars can be read back. The interesting + // thing is that older programs can still read the streams back as they + // scan for the LeaveObject() marker at the end of their serializing round + + a << m_name; + a << m_age; + + a << m_peopeCount; + a << m_numberOfPersons; + } + a.LeaveObject(); + } + \endcode + */ + bool EnterObject(); + + /** This the leave method that belongs to the EnterObject() method. Please always close the + section with the LeaveObject() when an EnterObject() is used. These two constructions can + be nested also. See \ref enter_leave for more information. + + \sa EnterObject() + */ + bool LeaveObject(); + + /** Indicates current state is writing. This flag will always be true if wxSerialize is constructed with a + wxOutputStream. The IsStoring() does not check wether the state of the stream is ok or not, + to prevent problems do: \code wxSerialize a(stream); @@ -738,13 +728,11 @@ class wxSerialize } \endcode */ - bool IsStoring() const { - return m_writeMode; - }; + bool IsStoring() const { return m_writeMode; }; /** Indicates current state is reading. This flag will always be true if wxSerialize is constructed with a - wxInputStream. The IsLoading() does not check wether the state of the stream is ok or not, to prevent - problems do: + wxInputStream. The IsLoading() does not check wether the state of the stream is ok or not, to prevent + problems do: \code wxSerialize a(stream); @@ -765,14 +753,12 @@ class wxSerialize } \endcode */ - bool IsLoading() const { - return !m_writeMode; - }; + bool IsLoading() const { return !m_writeMode; }; /** This is an extra flag independent of IsStoring() or IsLoading(). It can be set to indicate that certain - parts of the serialized objects must be omitted, can be useful when not the complete hierarchy needs - serializing, but only a single object, for example to a temporary stream (undo / redo mechanism). See - the argument 'partialMode' at the constructors for this class. + parts of the serialized objects must be omitted, can be useful when not the complete hierarchy needs + serializing, but only a single object, for example to a temporary stream (undo / redo mechanism). See + the argument 'partialMode' at the constructors for this class. \code bool SomeObject::Serialize(wxSerialize &a) @@ -816,423 +802,452 @@ class wxSerialize } \endcode */ - bool IsFullSerialize() const { - return !m_partialMode; - }; + bool IsFullSerialize() const { return !m_partialMode; }; /** Returns true when the stream is open. When opened, reading and writing can take place. When closed, - no reading and writing can occur, but also no error will be reported when tried anyway */ - bool IsOpen() const { - return m_opened; - }; + no reading and writing can occur, but also no error will be reported when tried anyway */ + bool IsOpen() const { return m_opened; }; // -- saving serializers -- /** Convenience operator for serializing. See WriteUInt8() */ - virtual wxSerialize &operator <<(wxUint8 value) { + virtual wxSerialize& operator<<(wxUint8 value) + { WriteUint8(value); - return *this; + return *this; }; /** Convenience operator for serializing. See WriteUInt16() */ - virtual wxSerialize &operator <<(wxUint16 value) { + virtual wxSerialize& operator<<(wxUint16 value) + { WriteUint16(value); - return *this; + return *this; }; /** Convenience operator for serializing. See WriteUInt32() */ - virtual wxSerialize &operator <<(wxUint32 value) { + virtual wxSerialize& operator<<(wxUint32 value) + { WriteUint32(value); - return *this; + return *this; }; /** Convenience operator for serializing. See WriteUInt64() */ - virtual wxSerialize &operator <<(wxUint64 value) { + virtual wxSerialize& operator<<(wxUint64 value) + { WriteUint64(value); - return *this; + return *this; }; /** Convenience operator for serializing. See WriteInt() */ - virtual wxSerialize &operator <<(int value) { + virtual wxSerialize& operator<<(int value) + { WriteInt(value); - return *this; + return *this; }; - /** Convenience operator for serializing. See WriteString() */ - virtual wxSerialize &operator <<(const wxString& value) { + /** Convenience operator for serializing. See WriteString() */ + virtual wxSerialize& operator<<(const wxString& value) + { WriteString(value); - return *this; + return *this; }; - /** Convenience operator for serializing. See WriteArrayString() */ - virtual wxSerialize &operator <<(const wxArrayString& value) { + /** Convenience operator for serializing. See WriteArrayString() */ + virtual wxSerialize& operator<<(const wxArrayString& value) + { WriteArrayString(value); - return *this; + return *this; }; /** Convenience operator for serializing. See WriteString() */ - virtual wxSerialize &operator <<(const wxChar* pvalue) { + virtual wxSerialize& operator<<(const wxChar* pvalue) + { wxString value(pvalue); WriteString(value); - return *this; + return *this; }; /** Convenience operator for serializing. See WriteBool() */ - virtual wxSerialize &operator <<(bool value) { + virtual wxSerialize& operator<<(bool value) + { WriteBool(value); - return *this; + return *this; }; /** Convenience operator for serializing. See WriteDouble() */ - virtual wxSerialize &operator <<(wxFloat64 value) { + virtual wxSerialize& operator<<(wxFloat64 value) + { WriteDouble(value); - return *this; + return *this; }; /** Convenience operator for serializing. See WriteDateTime() */ - virtual wxSerialize &operator <<(const wxDateTime &value) { + virtual wxSerialize& operator<<(const wxDateTime& value) + { WriteDateTime(value); - return *this; + return *this; }; - /** Convenience operator for serializing. See WriteIntInt() */ - virtual wxSerialize &operator <<(const wxSize& value) { + /** Convenience operator for serializing. See WriteIntInt() */ + virtual wxSerialize& operator<<(const wxSize& value) + { WriteIntInt(value.GetWidth(), value.GetHeight()); - return *this; + return *this; }; - /** Convenience operator for serializing. See WriteIntInt() */ - virtual wxSerialize &operator <<(const wxPoint& value) { + /** Convenience operator for serializing. See WriteIntInt() */ + virtual wxSerialize& operator<<(const wxPoint& value) + { WriteIntInt(value.x, value.y); - return *this; + return *this; }; // -- loading serializers -- /** Convenience operator for serializing. See ReadUint8() */ - virtual wxSerialize &operator >>(wxUint8& value) { + virtual wxSerialize& operator>>(wxUint8& value) + { ReadUint8(value); - return *this; + return *this; }; /** Convenience operator for serializing. See ReadUint16() */ - virtual wxSerialize &operator >>(wxUint16& value) { + virtual wxSerialize& operator>>(wxUint16& value) + { ReadUint16(value); - return *this; + return *this; }; /** Convenience operator for serializing. See ReadUInt32() */ - virtual wxSerialize &operator >>(wxUint32& value) { + virtual wxSerialize& operator>>(wxUint32& value) + { ReadUint32(value); - return *this; + return *this; }; /** Convenience operator for serializing. See ReadUInt64() */ - virtual wxSerialize &operator >>(wxUint64& value) { + virtual wxSerialize& operator>>(wxUint64& value) + { ReadUint64(value); - return *this; + return *this; }; /** Convenience operator for serializing. See ReadInt() */ - virtual wxSerialize &operator >>(int &value) { + virtual wxSerialize& operator>>(int& value) + { ReadInt(value); - return *this; + return *this; }; /** Convenience operator for serializing. See ReadString() */ - virtual wxSerialize &operator >>(wxString& value) { + virtual wxSerialize& operator>>(wxString& value) + { ReadString(value); - return *this; + return *this; }; - /** Convenience operator for serializing. See ReadArrayString() */ - virtual wxSerialize &operator >>(wxArrayString& value) { + /** Convenience operator for serializing. See ReadArrayString() */ + virtual wxSerialize& operator>>(wxArrayString& value) + { ReadArrayString(value); - return *this; + return *this; }; /** Convenience operator for serializing. See ReadBool() */ - virtual wxSerialize &operator >>(bool& value) { + virtual wxSerialize& operator>>(bool& value) + { ReadBool(value); - return *this; + return *this; }; /** Convenience operator for serializing. See ReadDouble() */ - virtual wxSerialize &operator >>(wxFloat64& value) { + virtual wxSerialize& operator>>(wxFloat64& value) + { ReadDouble(value); - return *this; + return *this; }; /** Convenience operator for serializing. See ReadDateTime() */ - virtual wxSerialize &operator >>(wxDateTime& value) { + virtual wxSerialize& operator>>(wxDateTime& value) + { ReadDateTime(value); - return *this; + return *this; }; /** Convenience operator for serializing. See ReadIntInt() */ - virtual wxSerialize &operator >>(wxSize& value) { + virtual wxSerialize& operator>>(wxSize& value) + { int iWidth, iHeight; if (ReadIntInt(iWidth, iHeight)) { value.SetWidth(iWidth); value.SetHeight(iHeight); } - return *this; + return *this; }; /** Convenience operator for serializing. See ReadIntInt() */ - virtual wxSerialize &operator >>(wxPoint& value) { + virtual wxSerialize& operator>>(wxPoint& value) + { ReadIntInt(value.x, value.y); - return *this; + return *this; }; - /** Loads a boolean from stream. When the next record to be read is not a bool, an error will occur. - When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Loads a boolean from stream. When the next record to be read is not a bool, an error will occur. + When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. - The value returned is true when the read was succesful, false when nothing was read. + The value returned is true when the read was succesful, false when nothing was read. */ bool ReadBool(bool& value); - /** Variant of ReadBool() that will provide a default if the read was not succesful */ - bool ReadBool(bool& value, bool defval) { - bool val = ReadBool(value); - if(!val) - value = defval; - return val; - - }; + /** Variant of ReadBool() that will provide a default if the read was not succesful */ + bool ReadBool(bool& value, bool defval) + { + bool val = ReadBool(value); + if (!val) + value = defval; + return val; + }; - /** Loads a wxUint8 from stream. When the next record to be read is not a wxUint8, an error will occur. - When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Loads a wxUint8 from stream. When the next record to be read is not a wxUint8, an error will occur. + When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. - The value returned is true when the read was succesful, false when nothing was read. + The value returned is true when the read was succesful, false when nothing was read. */ bool ReadUint8(wxUint8& value); - /** Variant of ReadUint8() that will provide a default if the read was not succesful */ - bool ReadUint8(wxUint8& value, wxUint8 defval) { - bool val = ReadUint8(value); - if(!val) - value = defval; - return val; - }; + /** Variant of ReadUint8() that will provide a default if the read was not succesful */ + bool ReadUint8(wxUint8& value, wxUint8 defval) + { + bool val = ReadUint8(value); + if (!val) + value = defval; + return val; + }; - /** Loads a wxUint16 from stream. When the next record to be read is not a wxUint16, an error will occur. - When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Loads a wxUint16 from stream. When the next record to be read is not a wxUint16, an error will occur. + When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. - The value returned is true when the read was succesful, false when nothing was read. + The value returned is true when the read was succesful, false when nothing was read. */ bool ReadUint16(wxUint16& value); - /** Variant of ReadUint16() that will provide a default if the read was not succesful */ - bool ReadUint16(wxUint16& value, wxUint16 defval) { - bool val = ReadUint16(value); - if(!val) - value = defval; - return val; - }; + /** Variant of ReadUint16() that will provide a default if the read was not succesful */ + bool ReadUint16(wxUint16& value, wxUint16 defval) + { + bool val = ReadUint16(value); + if (!val) + value = defval; + return val; + }; - /** Loads a wxUint32 from stream. When the next record to be read is not a wxUint32, an error will occur. - When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Loads a wxUint32 from stream. When the next record to be read is not a wxUint32, an error will occur. + When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. - The value returned is true when the read was succesful, false when nothing was read. + The value returned is true when the read was succesful, false when nothing was read. */ - bool ReadUint32(wxUint32& value); - - /** Variant of ReadUint32() that will provide a default if the read was not succesful */ - bool ReadUint32(wxUint32& value, wxUint32 defval) { - bool val = ReadUint32(value); - if(!val) - value = defval; - return val; - }; + bool ReadUint32(wxUint32& value); + + /** Variant of ReadUint32() that will provide a default if the read was not succesful */ + bool ReadUint32(wxUint32& value, wxUint32 defval) + { + bool val = ReadUint32(value); + if (!val) + value = defval; + return val; + }; - /** Loads a wxUint64 from stream. When the next record to be read is not a wxUint64, an error will occur. - When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Loads a wxUint64 from stream. When the next record to be read is not a wxUint64, an error will occur. + When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. - The value returned is true when the read was succesful, false when nothing was read. + The value returned is true when the read was succesful, false when nothing was read. */ bool ReadUint64(wxUint64& value); - /** Variant of ReadUint64() that will provide a default if the read was not succesful */ - bool ReadUint64(wxUint64& value, wxUint64 defval) { - bool val = ReadUint64(value); - if(!val) - value = defval; - return val; - }; + /** Variant of ReadUint64() that will provide a default if the read was not succesful */ + bool ReadUint64(wxUint64& value, wxUint64 defval) + { + bool val = ReadUint64(value); + if (!val) + value = defval; + return val; + }; - /** Loads an int from stream. When the next record to be read is not an int, an error will occur. - When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Loads an int from stream. When the next record to be read is not an int, an error will occur. + When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. - - The value returned is true when the read was succesful, false when nothing was read. - - SPECIAL CARE ABOUT THIS FUNCTION MUST BE TAKEN: - Reading an integer x-platform is potentially unsafe. The size of the integer may vary from 16 bits - to 64 bits depending on the platform. When sharing data streams, the preferred way of streaming is - using the wxUint16, wxUint32, wxUint64 data types. However, this method is made as safe as possible - by also storing the size of the int on the stream. This means reading a stored integer of 4 bytes - (32 bits) it will be read back as 32 bits, and casted to a 64 bits integer. In theory, this should - work as the sign flag for a 32 bits container will be extended to match the 64 bits container. The - only worst case scenario that exists is when an 64 bits int is written, and it needs to be casted - to a 32 bits integer, problems can occur because the destination container may be too small. No error - will be logged so be careful storing extreme values that might not fit in smaller integers. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. + + The value returned is true when the read was succesful, false when nothing was read. + + SPECIAL CARE ABOUT THIS FUNCTION MUST BE TAKEN: + Reading an integer x-platform is potentially unsafe. The size of the integer may vary from 16 bits + to 64 bits depending on the platform. When sharing data streams, the preferred way of streaming is + using the wxUint16, wxUint32, wxUint64 data types. However, this method is made as safe as possible + by also storing the size of the int on the stream. This means reading a stored integer of 4 bytes + (32 bits) it will be read back as 32 bits, and casted to a 64 bits integer. In theory, this should + work as the sign flag for a 32 bits container will be extended to match the 64 bits container. The + only worst case scenario that exists is when an 64 bits int is written, and it needs to be casted + to a 32 bits integer, problems can occur because the destination container may be too small. No error + will be logged so be careful storing extreme values that might not fit in smaller integers. */ bool ReadInt(int& value); - /** Loads an pair of ints from stream. When the next record to be read is not an int, an error will occur. - When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Loads an pair of ints from stream. When the next record to be read is not an int, an error will occur. + When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. - - The value returned is true when the read was succesful, false when nothing was read. - - SPECIAL CARE ABOUT THIS FUNCTION MUST BE TAKEN: - Reading an integer x-platform is potentially unsafe. The size of the integer may vary from 16 bits - to 64 bits depending on the platform. When sharing data streams, the preferred way of streaming is - using the wxUint16, wxUint32, wxUint64 data types. However, this method is made as safe as possible - by also storing the size of the int on the stream. This means reading a stored integer of 4 bytes - (32 bits) it will be read back as 32 bits, and casted to a 64 bits integer. In theory, this should - work as the sign flag for a 32 bits container will be extended to match the 64 bits container. The - only worst case scenario that exists is when an 64 bits int is written, and it needs to be casted - to a 32 bits integer, problems can occur because the destination container may be too small. No error - will be logged so be careful storing extreme values that might not fit in smaller integers. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. + + The value returned is true when the read was succesful, false when nothing was read. + + SPECIAL CARE ABOUT THIS FUNCTION MUST BE TAKEN: + Reading an integer x-platform is potentially unsafe. The size of the integer may vary from 16 bits + to 64 bits depending on the platform. When sharing data streams, the preferred way of streaming is + using the wxUint16, wxUint32, wxUint64 data types. However, this method is made as safe as possible + by also storing the size of the int on the stream. This means reading a stored integer of 4 bytes + (32 bits) it will be read back as 32 bits, and casted to a 64 bits integer. In theory, this should + work as the sign flag for a 32 bits container will be extended to match the 64 bits container. The + only worst case scenario that exists is when an 64 bits int is written, and it needs to be casted + to a 32 bits integer, problems can occur because the destination container may be too small. No error + will be logged so be careful storing extreme values that might not fit in smaller integers. */ bool ReadIntInt(int& value1, int& value2); - /** Variant of ReadIntInt() that will provide a default if the read was not succesful */ - bool ReadIntInt(int& value1, int& value2, int defval1, int defval2) { - bool val = ReadIntInt(value1, value2); - if(!val) { - value1 = defval1; - value2 = defval2; - } - return val; - }; - - /** Variant of ReadInt() that will provide a default if the read was not succesful */ - bool ReadInt(int& value, int defval) { - bool val = ReadInt(value); - if(!val) - value = defval; - return val; - }; - - - /** Loads a wxFloat64 from stream. When the next record to be read is not a wxFloat64, an error will occur. - When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Variant of ReadIntInt() that will provide a default if the read was not succesful */ + bool ReadIntInt(int& value1, int& value2, int defval1, int defval2) + { + bool val = ReadIntInt(value1, value2); + if (!val) { + value1 = defval1; + value2 = defval2; + } + return val; + }; + + /** Variant of ReadInt() that will provide a default if the read was not succesful */ + bool ReadInt(int& value, int defval) + { + bool val = ReadInt(value); + if (!val) + value = defval; + return val; + }; + + /** Loads a wxFloat64 from stream. When the next record to be read is not a wxFloat64, an error will occur. + When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. - The value returned is true when the read was succesful, false when nothing was read. The wxFloat64 is - stored as a IEEE converted standard wxFloat64, and is x-platform so it can be shared between other os'es + The value returned is true when the read was succesful, false when nothing was read. The wxFloat64 is + stored as a IEEE converted standard wxFloat64, and is x-platform so it can be shared between other os'es */ bool ReadDouble(wxFloat64& value); - /** Variant of ReadDouble() that will provide a default if the read was not succesful */ - bool ReadDouble(wxFloat64& value, wxFloat64 defval) { - bool val = ReadDouble(value); - if(!val) - value = defval; - return val; - }; + /** Variant of ReadDouble() that will provide a default if the read was not succesful */ + bool ReadDouble(wxFloat64& value, wxFloat64 defval) + { + bool val = ReadDouble(value); + if (!val) + value = defval; + return val; + }; - /** Loads a wxString from stream. When the next record to be read is not a wxString, an error will occur. - When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Loads a wxString from stream. When the next record to be read is not a wxString, an error will occur. + When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. - The value returned is true when the read was succesful, false when nothing was read. For the string - first the count is stored and then the string itself. When storing an empty string, only a 0 count is - stored. + The value returned is true when the read was succesful, false when nothing was read. For the string + first the count is stored and then the string itself. When storing an empty string, only a 0 count is + stored. */ - bool ReadString(wxString& value); - - /** Variant of ReadString() that will provide a default if the read was not succesful */ - bool ReadString(wxString& value, const wxString &defval) { - bool val = ReadString(value); - if(!val) - value = defval; - return val; - }; + bool ReadString(wxString& value); + + /** Variant of ReadString() that will provide a default if the read was not succesful */ + bool ReadString(wxString& value, const wxString& defval) + { + bool val = ReadString(value); + if (!val) + value = defval; + return val; + }; - /** Loads a wxArrayString from stream. When the next record to be read is not a wxArrayString, an error - will occur. When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Loads a wxArrayString from stream. When the next record to be read is not a wxArrayString, an error + will occur. When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. - The value returned is true when the read was succesful, false when nothing was read. For the string - first the count is stored and then the string itself. When storing an empty string, only a 0 count is - stored. + The value returned is true when the read was succesful, false when nothing was read. For the string + first the count is stored and then the string itself. When storing an empty string, only a 0 count is + stored. */ - bool ReadArrayString(wxArrayString& value); - - /** Variant of ReadArrayString() that will provide a default if the read was not succesful */ - bool ReadString(wxArrayString& value, const wxArrayString &defval) { - bool val = ReadArrayString(value); - if(!val) - value = defval; - return val; - }; + bool ReadArrayString(wxArrayString& value); + + /** Variant of ReadArrayString() that will provide a default if the read was not succesful */ + bool ReadString(wxArrayString& value, const wxArrayString& defval) + { + bool val = ReadArrayString(value); + if (!val) + value = defval; + return val; + }; - /** Loads a wxDateTime from stream. When the next record to be read is not a wxDateTime, an error - will occur. When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is - in an error state, the value is not touched. + /** Loads a wxDateTime from stream. When the next record to be read is not a wxDateTime, an error + will occur. When wxSerialize encountered the end of object boundary (see \ref enter_leave) or the archive is + in an error state, the value is not touched. Please note that when an error occurs, all subsequent loading from the stream will result in an - error. This is to provide a save mechanism out of a read error. So instead of checking every value - you read back yourself, they can be default and won't produce erratic behaviour. + error. This is to provide a save mechanism out of a read error. So instead of checking every value + you read back yourself, they can be default and won't produce erratic behaviour. - The value returned is true when the read was succesful, false when nothing was read. For the string - first the count is stored and then the string itself. When storing an empty string, only a 0 count is - stored. + The value returned is true when the read was succesful, false when nothing was read. For the string + first the count is stored and then the string itself. When storing an empty string, only a 0 count is + stored. */ - bool ReadDateTime(wxDateTime& value); + bool ReadDateTime(wxDateTime& value); /** Reads a record from the stream. The wxMemoryBuffer is a growable buffer class, which will contain the data - being read. The length of the buffer will be the length present so there is no need to define a - pre-allocated buffer. When the referenced buffer runs out of scope in your code, it is destroyed safely. + being read. The length of the buffer will be the length present so there is no need to define a + pre-allocated buffer. When the referenced buffer runs out of scope in your code, it is destroyed safely. The read buffer can be up to 4 Gb (count is 32 bits). The buffer will be considered an atomic element so when the read fails for the specified number of counts, the buffer is corrupted. This will ofcourse only @@ -1240,140 +1255,141 @@ class wxSerialize an integer etc. NOTICE FOR PLATFORM BINARY COMPATIBILITY: No conversion takes place when writing the buffer. It is written as - a sequence of bytes to the stream. So be careful storing the whole data back into a structure (little to big endian) - */ - bool Read(wxMemoryBuffer &buffer); + a sequence of bytes to the stream. So be careful storing the whole data back into a structure (little to big + endian) + */ + bool Read(wxMemoryBuffer& buffer); /** Saves a bool to stream. It writes a header type first, and after that the value. This means when the boolean - is read back when it is not expected, an error occurs and the program can terminate gracefully because no - bogus values are read back. True is returned when the value is saved properly, and false when it's not. + is read back when it is not expected, an error occurs and the program can terminate gracefully because no + bogus values are read back. True is returned when the value is saved properly, and false when it's not. */ bool WriteBool(bool value); - /** Saves a double as a wxFloat64 to stream. It writes a header type first, and after that the value. This means when the wxFloat64 - is read back when it is not expected, an error occurs and the program can terminate gracefully because no - bogus values are read back. True is returned when the value is saved properly, and false when it's not. + /** Saves a double as a wxFloat64 to stream. It writes a header type first, and after that the value. This means + when the wxFloat64 is read back when it is not expected, an error occurs and the program can terminate gracefully + because no bogus values are read back. True is returned when the value is saved properly, and false when it's + not. The wxFloat64 is saved in a cross platform compatible mode, which means the streams can be interchanged between - MacOS, Linux and Windows without problems. + MacOS, Linux and Windows without problems. */ bool WriteDouble(wxFloat64 value); /** Saves a wxUint8 to stream. It writes a header type first, and after that the value. This means when the wxUint8 - is read back when it is not expected, an error occurs and the program can terminate gracefully because no - bogus values are read back. True is returned when the value is saved properly, and false when it's not. + is read back when it is not expected, an error occurs and the program can terminate gracefully because no + bogus values are read back. True is returned when the value is saved properly, and false when it's not. The wxUint8 is saved in a cross platform compatible mode, which means the streams can be interchanged between - MacOS, Linux and Windows without problems. + MacOS, Linux and Windows without problems. */ bool WriteUint8(wxUint8 value); - /** Saves a wxUint16 to stream. It writes a header type first, and after that the value. This means when the wxUint16 - is read back when it is not expected, an error occurs and the program can terminate gracefully because no - bogus values are read back. True is returned when the value is saved properly, and false when it's not. + /** Saves a wxUint16 to stream. It writes a header type first, and after that the value. This means when the + wxUint16 is read back when it is not expected, an error occurs and the program can terminate gracefully because + no bogus values are read back. True is returned when the value is saved properly, and false when it's not. The wxUint16 is saved in a cross platform compatible mode, which means the streams can be interchanged between - MacOS, Linux and Windows without problems. + MacOS, Linux and Windows without problems. */ bool WriteUint16(wxUint16 value); - /** Saves a wxUint32 to stream. It writes a header type first, and after that the value. This means when the wxUint32 - is read back when it is not expected, an error occurs and the program can terminate gracefully because no - bogus values are read back. True is returned when the value is saved properly, and false when it's not. + /** Saves a wxUint32 to stream. It writes a header type first, and after that the value. This means when the + wxUint32 is read back when it is not expected, an error occurs and the program can terminate gracefully because + no bogus values are read back. True is returned when the value is saved properly, and false when it's not. The wxUint32 is saved in a cross platform compatible mode, which means the streams can be interchanged between - MacOS, Linux and Windows without problems. + MacOS, Linux and Windows without problems. */ bool WriteUint32(wxUint32 value); - /** Saves a wxUint64 to stream. It writes a header type first, and after that the value. This means when the wxUint64 - is read back when it is not expected, an error occurs and the program can terminate gracefully because no - bogus values are read back. True is returned when the value is saved properly, and false when it's not. + /** Saves a wxUint64 to stream. It writes a header type first, and after that the value. This means when the + wxUint64 is read back when it is not expected, an error occurs and the program can terminate gracefully because + no bogus values are read back. True is returned when the value is saved properly, and false when it's not. The wxUint64 is saved in a cross platform compatible mode, which means the streams can be interchanged between - MacOS, Linux and Windows without problems. + MacOS, Linux and Windows without problems. */ bool WriteUint64(wxUint64 value); /** Saves an int to stream. It writes a header type first, and after that the value. This means when the int - is read back when it is not expected, an error occurs and the program can terminate gracefully because no - bogus values are read back. True is returned when the value is saved properly, and false when it's not. + is read back when it is not expected, an error occurs and the program can terminate gracefully because no + bogus values are read back. True is returned when the value is saved properly, and false when it's not. - SPECIAL CARE ABOUT THIS FUNCTION MUST BE TAKEN: - Writing an integer x-platform is potentially unsafe. The size of the integer may vary from 16 bits - to 64 bits depending on the platform. When sharing data streams, the preferred way of streaming is - using the wxUint16, wxUint32, wxUint64 data types. See ReadInt() for more information. - */ - bool WriteInt(int value); + SPECIAL CARE ABOUT THIS FUNCTION MUST BE TAKEN: + Writing an integer x-platform is potentially unsafe. The size of the integer may vary from 16 bits + to 64 bits depending on the platform. When sharing data streams, the preferred way of streaming is + using the wxUint16, wxUint32, wxUint64 data types. See ReadInt() for more information. + */ + bool WriteInt(int value); /** Saves a pair of ints to a stream. It is used for wxSize and wxPoint. It writes a header type first, and after that the value. This means when the int is read back when it is not expected, an error occurs and the program can terminate gracefully because no bogus values are read back. True is returned when the value is saved properly, and false when it's not. - SPECIAL CARE ABOUT THIS FUNCTION MUST BE TAKEN: - Writing an integer x-platform is potentially unsafe. The size of the integer may vary from 16 bits - to 64 bits depending on the platform. When sharing data streams, the preferred way of streaming is - using the wxUint16, wxUint32, wxUint64 data types. See ReadInt() for more information. + SPECIAL CARE ABOUT THIS FUNCTION MUST BE TAKEN: + Writing an integer x-platform is potentially unsafe. The size of the integer may vary from 16 bits + to 64 bits depending on the platform. When sharing data streams, the preferred way of streaming is + using the wxUint16, wxUint32, wxUint64 data types. See ReadInt() for more information. */ bool WriteIntInt(int value1, int value2); - /** Saves a wxString to stream. It writes a header type first, and after that the value. This means when the wxString - is read back when it is not expected, an error occurs and the program can terminate gracefully because no - bogus values are read back. True is returned when the value is saved properly, and false when it's not. + /** Saves a wxString to stream. It writes a header type first, and after that the value. This means when the + wxString is read back when it is not expected, an error occurs and the program can terminate gracefully because + no bogus values are read back. True is returned when the value is saved properly, and false when it's not. The wxString is saved in a cross platform compatible mode, which means the streams can be interchanged between - MacOS, Linux and Windows without problems. First the count is stored, then the string. With an empty string only - the 0 count is stored. + MacOS, Linux and Windows without problems. First the count is stored, then the string. With an empty string only + the 0 count is stored. */ bool WriteString(const wxString& value); /** Saves a wxArrayString to stream. It writes a header type first, and after that the value. This means when - the wxArrayString is read back when it is not expected, an error occurs and the program can terminate - gracefully because no bogus values are read back. True is returned when the value is saved properly, and - false when it's not. + the wxArrayString is read back when it is not expected, an error occurs and the program can terminate + gracefully because no bogus values are read back. True is returned when the value is saved properly, and + false when it's not. The wxString is saved in a cross platform compatible mode, which means the streams can be interchanged between - MacOS, Linux and Windows without problems. First the count is stored, then the string. With an empty string only - the 0 count is stored. + MacOS, Linux and Windows without problems. First the count is stored, then the string. With an empty string only + the 0 count is stored. */ bool WriteArrayString(const wxArrayString& value); /** Saves a wxDateTime to stream. It writes a header type first, and after that the value. This means when - the wxDateTime is read back when it is not expected, an error occurs and the program can terminate - gracefully because no bogus values are read back. True is returned when the value is saved properly, and - false when it's not. + the wxDateTime is read back when it is not expected, an error occurs and the program can terminate + gracefully because no bogus values are read back. True is returned when the value is saved properly, and + false when it's not. The wxDateTime is saved in a cross platform compatible mode (e.g. the number of ticks). Please be aware that no - timezone information or daylight saving information is stored. So if the date read back on a different PC is + timezone information or daylight saving information is stored. So if the date read back on a different PC is mis interpreted because the PC is in a different time zone you must find other means of syncing them. */ bool WriteDateTime(const wxDateTime& value); - /** Saves an arbitrary amount of bytes to the stream using wxMemoryBuffer. It writes a header type first, and after + /** Saves an arbitrary amount of bytes to the stream using wxMemoryBuffer. It writes a header type first, and after that the count to be saved and the bytes in the wxMemoryBuffer. This means when the data is read back when it is not expected, an error occurs and the program can terminate gracefully because no bogus values are read back. True is returned when the value is saved properly, and false when it's not. - Data can be saved up to 4Gb. This is not recommended (nor physically possible I think) but the limit is 32 bits for - the count. + Data can be saved up to 4Gb. This is not recommended (nor physically possible I think) but the limit is 32 bits + for the count. NOTICE FOR PLATFORM BINARY COMPATIBILITY: No conversion takes place when writing the buffer. It is written as - a sequence of bytes to the stream. So be careful storing the whole data back into a structure (little to big endian) + a sequence of bytes to the stream. So be careful storing the whole data back into a structure (little to big + endian) */ - bool Write(const wxMemoryBuffer &buffer); + bool Write(const wxMemoryBuffer& buffer); // -- arbitrary functions -- /** Returns the header that was read by this stream. When writing, the header string contains the passed header by the constructor. See GetArchiveStatus() for more information. */ - wxString GetHeaderString() const { - return m_headerStr; - }; + wxString GetHeaderString() const { return m_headerStr; }; /** Returns the version of the stream currently beaing read, or else the version of the stream when it - was created. This can be used to exclude parts while reading, if the stream version does not + was created. This can be used to exclude parts while reading, if the stream version does not support newly added veriables like; \code @@ -1397,74 +1413,62 @@ class wxSerialize } \endcode */ - size_t GetVersion() const { - return m_version; - }; + size_t GetVersion() const { return m_version; }; - /** Returns the wxSerializeStatus object. You usually do this when you just read a stream, to get more - information about it later, like the version, header, and if the stream contained newer data which - means writing it back with the older data model you might be using, you destroy information */ - const wxSerializeStatus &GetArchiveStatus() const { - return m_status; - }; + /** Returns the wxSerializeStatus object. You usually do this when you just read a stream, to get more + information about it later, like the version, header, and if the stream contained newer data which + means writing it back with the older data model you might be using, you destroy information */ + const wxSerializeStatus& GetArchiveStatus() const { return m_status; }; /// return the version string of the class wxSerialize - static wxString GetLibVersionString (); + static wxString GetLibVersionString(); /// return the major version number of the class wxSerialize - static long GetLibVersionMajor (); + static long GetLibVersionMajor(); /// return the minor version number of the class wxSerialize - static long GetLibVersionMinor (); + static long GetLibVersionMinor(); private: // error types - enum - { - wxSERIALIZE_ERR_OK = 0, - wxSERIALIZE_ERR_EOF = -1, - wxSERIALIZE_ERR_ILL = -2, - wxSERIALIZE_ERR_MEM = -3 - }; - - // all errors that can occur - enum - { - wxSERIALIZE_ERR_STR_HEADER_s1_s2, /// Illegal header in start of stream - wxSERIALIZE_ERR_STR_WRONGVERSION_s1_s2, /// Not a proper version - wxSERIALIZE_ERR_STR_BADISTREAM, /// Bad input stream - wxSERIALIZE_ERR_STR_BADOSTREAM, /// Bad output stream - wxSERIALIZE_ERR_STR_NOVERHDR, /// Cannot write version or header info to stream - wxSERIALIZE_ERR_STR_NOHEADER_s1, /// Header expected but not found - wxSERIALIZE_ERR_STR_NOVERSION, /// No version found in stream - wxSERIALIZE_ERR_STR_NOWRITE, /// Cannot write in read mode - wxSERIALIZE_ERR_STR_NOREAD, /// Cannot read in write mode - wxSERIALIZE_ERR_STR_EOF, /// End of file error in read mode - wxSERIALIZE_ERR_STR_WRONGCHUNK_s1_s2, /// Expected header x but got y - wxSERIALIZE_ERR_STR_MEMORY_s1, /// Cannot allocate x bytes of memory - wxSERIALIZE_ERR_STR_READSIZE, /// Read size mismatch - wxSERIALIZE_ERR_STR_RINTSIZE, /// Integer size mismatch - wxSERIALIZE_ERR_STR_SINTSIZE, /// Ditto - wxSERIALIZE_ERR_STR_ILL_LEAVE, /// Illegal leave marker found - wxSERIALIZE_ERR_STR_ILL_UNKNOWN_HDR_s1, /// Unknown header error - wxSERIALIZE_ERR_STR_ILL_LEVEL /// Sync level failure! - }; - - // headers - enum - { - wxSERIALIZE_HDR_BOOL = 'b', - wxSERIALIZE_HDR_INT8 = 'c', - wxSERIALIZE_HDR_INT16 = 'w', - wxSERIALIZE_HDR_INT32 = 'l', - wxSERIALIZE_HDR_INT64 = 'q', - wxSERIALIZE_HDR_DOUBLE = 'd', - wxSERIALIZE_HDR_STRING = 's', - wxSERIALIZE_HDR_RECORD = 'r', - wxSERIALIZE_HDR_INT = 'i', - wxSERIALIZE_HDR_ARRSTRING = 'a', - wxSERIALIZE_HDR_DATETIME = 't', - wxSERIALIZE_HDR_ENTER = '<', - wxSERIALIZE_HDR_LEAVE = '>', - wxSERIALIZE_HDR_INTINT = 'I' - }; + enum { wxSERIALIZE_ERR_OK = 0, wxSERIALIZE_ERR_EOF = -1, wxSERIALIZE_ERR_ILL = -2, wxSERIALIZE_ERR_MEM = -3 }; + + // all errors that can occur + enum { + wxSERIALIZE_ERR_STR_HEADER_s1_s2, /// Illegal header in start of stream + wxSERIALIZE_ERR_STR_WRONGVERSION_s1_s2, /// Not a proper version + wxSERIALIZE_ERR_STR_BADISTREAM, /// Bad input stream + wxSERIALIZE_ERR_STR_BADOSTREAM, /// Bad output stream + wxSERIALIZE_ERR_STR_NOVERHDR, /// Cannot write version or header info to stream + wxSERIALIZE_ERR_STR_NOHEADER_s1, /// Header expected but not found + wxSERIALIZE_ERR_STR_NOVERSION, /// No version found in stream + wxSERIALIZE_ERR_STR_NOWRITE, /// Cannot write in read mode + wxSERIALIZE_ERR_STR_NOREAD, /// Cannot read in write mode + wxSERIALIZE_ERR_STR_EOF, /// End of file error in read mode + wxSERIALIZE_ERR_STR_WRONGCHUNK_s1_s2, /// Expected header x but got y + wxSERIALIZE_ERR_STR_MEMORY_s1, /// Cannot allocate x bytes of memory + wxSERIALIZE_ERR_STR_READSIZE, /// Read size mismatch + wxSERIALIZE_ERR_STR_RINTSIZE, /// Integer size mismatch + wxSERIALIZE_ERR_STR_SINTSIZE, /// Ditto + wxSERIALIZE_ERR_STR_ILL_LEAVE, /// Illegal leave marker found + wxSERIALIZE_ERR_STR_ILL_UNKNOWN_HDR_s1, /// Unknown header error + wxSERIALIZE_ERR_STR_ILL_LEVEL /// Sync level failure! + }; + + // headers + enum { + wxSERIALIZE_HDR_BOOL = 'b', + wxSERIALIZE_HDR_INT8 = 'c', + wxSERIALIZE_HDR_INT16 = 'w', + wxSERIALIZE_HDR_INT32 = 'l', + wxSERIALIZE_HDR_INT64 = 'q', + wxSERIALIZE_HDR_DOUBLE = 'd', + wxSERIALIZE_HDR_STRING = 's', + wxSERIALIZE_HDR_RECORD = 'r', + wxSERIALIZE_HDR_INT = 'i', + wxSERIALIZE_HDR_ARRSTRING = 'a', + wxSERIALIZE_HDR_DATETIME = 't', + wxSERIALIZE_HDR_ENTER = '<', + wxSERIALIZE_HDR_LEAVE = '>', + wxSERIALIZE_HDR_INTINT = 'I' + }; // pre-check if stream is capable of writing, returns errors // when condition is not good (like input stream is defined @@ -1476,67 +1480,66 @@ class wxSerialize // instead of input) bool CanLoad(); - // loads the header, and sets an error when the expected header is not the same - // as the header given - int LoadChunkHeader(int expheader); + // loads the header, and sets an error when the expected header is not the same + // as the header given + int LoadChunkHeader(int expheader); // writes a single char to the stream - void WriteChar(wxUint8 value); + void WriteChar(wxUint8 value); - // sets an error with arbitrary message using wxLogError - int LogError(int err, int msgcode, const wxString &s1 = wxEmptyString, - const wxString &s2 = wxEmptyString); + // sets an error with arbitrary message using wxLogError + int LogError(int err, int msgcode, const wxString& s1 = wxEmptyString, const wxString& s2 = wxEmptyString); - // attempts to find the marker that belongs to this - // current level. We assume the current count but increment when we - // find one, decrement when we find another .. - void FindCurrentEnterLevel(); + // attempts to find the marker that belongs to this + // current level. We assume the current count but increment when we + // find one, decrement when we find another .. + void FindCurrentEnterLevel(); - // finds current leave level. This means all enter levels we encounter - // we will skip, until we have the level of our object - 1 - void FindCurrentLeaveLevel(); + // finds current leave level. This means all enter levels we encounter + // we will skip, until we have the level of our object - 1 + void FindCurrentLeaveLevel(); - // skip the data belonging by the header - void SkipData(wxUint8 hdr); + // skip the data belonging by the header + void SkipData(wxUint8 hdr); - // load the buffer from a stream - void Load(wxMemoryBuffer &buf); + // load the buffer from a stream + void Load(wxMemoryBuffer& buf); // reads a string (without header) - wxString LoadString(); + wxString LoadString(); // reads an array string without header - wxArrayString LoadArrayString(); + wxArrayString LoadArrayString(); // reads a datetime without header - wxDateTime LoadDateTime(); + wxDateTime LoadDateTime(); // reads a single char from the stream, returns '\0' when none can be read - wxUint8 LoadChar(); + wxUint8 LoadChar(); // see wxUint8 LoadChar() wxUint8 LoadUint8(); - // reads a wxUint16 (without header) - wxUint16 LoadUint16(); + // reads a wxUint16 (without header) + wxUint16 LoadUint16(); - // reads a wxUint32 (without header) - wxUint32 LoadUint32(); + // reads a wxUint32 (without header) + wxUint32 LoadUint32(); - // reads a wxUint64 (without header) - wxUint64 LoadUint64(); + // reads a wxUint64 (without header) + wxUint64 LoadUint64(); // reads a wxFloat64 (without header) - wxFloat64 LoadDouble(); + wxFloat64 LoadDouble(); - // loads integer - int LoadInt(); + // loads integer + int LoadInt(); // loads pair of integers - void LoadIntInt (int& value1, int& value2); + void LoadIntInt(int& value1, int& value2); - // reads a bool (without header) - bool LoadBool(); + // reads a bool (without header) + bool LoadBool(); // writes a wxUint8 without header void SaveChar(wxUint8 value); @@ -1544,77 +1547,77 @@ class wxSerialize // see SaveChar(wxUint8) void SaveUint8(wxUint8 value); - // writes a wxUint16 (without header) - void SaveUint16(wxUint16 value); + // writes a wxUint16 (without header) + void SaveUint16(wxUint16 value); - // writes a wxUint32 (without header) - void SaveUint32(wxUint32 value); + // writes a wxUint32 (without header) + void SaveUint32(wxUint32 value); - // writes a wxUint64 (without header) - void SaveUint64(wxUint64 value); + // writes a wxUint64 (without header) + void SaveUint64(wxUint64 value); // writes a string (without header) - void SaveString(const wxString &str); + void SaveString(const wxString& str); // translates header name to something readable for errors - wxString GetHeaderName(int headername); - - /** Sets the error to a specific condition. Valid error conditions are - - wxSERIALIZE_OK - - wxSERIALIZE_ERR_EOF - - wxSERIALIZE_ERR_ILL - - wxSERIALIZE_ERR_MEM - - The error will not change from the last error condition when it is - already set. Meaning it will keep the last error, even when others - follow. - */ - void SetError(int err) { - // only set error when we are still ok - if(m_errorCode == wxSERIALIZE_ERR_OK) - m_errorCode = err; - }; - - // initialize function - void InitAll(); + wxString GetHeaderName(int headername); + + /** Sets the error to a specific condition. Valid error conditions are + - wxSERIALIZE_OK + - wxSERIALIZE_ERR_EOF + - wxSERIALIZE_ERR_ILL + - wxSERIALIZE_ERR_MEM + + The error will not change from the last error condition when it is + already set. Meaning it will keep the last error, even when others + follow. + */ + void SetError(int err) + { + // only set error when we are still ok + if (m_errorCode == wxSERIALIZE_ERR_OK) + m_errorCode = err; + }; + + // initialize function + void InitAll(); private: - // last error code issued in wxSerialize - int m_errorCode; - // the last logged error message - wxString m_errMsg; - // the header received - wxString m_headerStr; - // The version written or read - size_t m_version; - // opened status (true if open) Close() will close it - bool m_opened; - // partial save or load mode - bool m_partialMode; - // write or read mode of the stream - bool m_writeMode; - // under the hood output data stream (this stream is maintained by us) - wxOutputStream &m_odstr; - // under the hood output data stream (this stream is maintained by us) - wxInputStream &m_idstr; - // object marker level. Any level above 0 means we have encountered - // an EnterObject and LeaveObject. - int m_objectLevel; - // flag to indicate that we encountered a LEAVE or ENTER marker. This means - // no read should be done until we reached the LeaveObject() that - // belongs to our level. - bool m_haveBoundary; - // last boundary encountered - unsigned char m_lastBoundary; - // temp vars that have only the purpose to initialize streams that - // need to be initialized by ref. By using wxStringStream variants - // we can safely read and load from them when this error might occur - wxString m_tmpostr, m_tmpistr; - wxStringOutputStream m_otmp; - wxStringInputStream m_itmp; - // The archive status object - wxSerializeStatus m_status; + // last error code issued in wxSerialize + int m_errorCode; + // the last logged error message + wxString m_errMsg; + // the header received + wxString m_headerStr; + // The version written or read + size_t m_version; + // opened status (true if open) Close() will close it + bool m_opened; + // partial save or load mode + bool m_partialMode; + // write or read mode of the stream + bool m_writeMode; + // under the hood output data stream (this stream is maintained by us) + wxOutputStream& m_odstr; + // under the hood output data stream (this stream is maintained by us) + wxInputStream& m_idstr; + // object marker level. Any level above 0 means we have encountered + // an EnterObject and LeaveObject. + int m_objectLevel; + // flag to indicate that we encountered a LEAVE or ENTER marker. This means + // no read should be done until we reached the LeaveObject() that + // belongs to our level. + bool m_haveBoundary; + // last boundary encountered + unsigned char m_lastBoundary; + // temp vars that have only the purpose to initialize streams that + // need to be initialized by ref. By using wxStringStream variants + // we can safely read and load from them when this error might occur + wxString m_tmpostr, m_tmpistr; + wxStringOutputStream m_otmp; + wxStringInputStream m_itmp; + // The archive status object + wxSerializeStatus m_status; }; #endif - diff --git a/SpellChecker/CorrectSpellingDlg.cpp b/SpellChecker/CorrectSpellingDlg.cpp index 80f4fafc78..9129cd0c61 100644 --- a/SpellChecker/CorrectSpellingDlg.cpp +++ b/SpellChecker/CorrectSpellingDlg.cpp @@ -34,6 +34,7 @@ // License: ///////////////////////////////////////////////////////////////////////////// #include "CorrectSpellingDlg.h" + #include "IHunSpell.h" // ------------------------------------------------------------ CorrectSpellingDlg::CorrectSpellingDlg(wxWindow* parent) @@ -57,7 +58,8 @@ void CorrectSpellingDlg::OnInitDialog(wxInitDialogEvent& event) event.Skip(); m_pMisspelling->SetValue(m_misspelled); - if(m_currentPosition.x != -1) Move(m_currentPosition); + if (m_currentPosition.x != -1) + Move(m_currentPosition); } // ------------------------------------------------------------ void CorrectSpellingDlg::OnSuggestionSelected(wxCommandEvent& event) @@ -86,11 +88,12 @@ void CorrectSpellingDlg::OnSuggestClick(wxCommandEvent& event) { wxUnusedVar(event); - if(m_pHs) { + if (m_pHs) { m_pSuggestions->Clear(); wxArrayString suggests = m_pHs->GetSuggestions(m_pMisspelling->GetValue()); - for(wxUint32 i = 0; i < suggests.GetCount(); i++) m_pSuggestions->Append(suggests[i]); + for (wxUint32 i = 0; i < suggests.GetCount(); i++) + m_pSuggestions->Append(suggests[i]); } } // ------------------------------------------------------------ @@ -98,7 +101,8 @@ void CorrectSpellingDlg::SetSuggestions(wxArrayString suggests) { m_pSuggestions->Clear(); - for(wxUint32 i = 0; i < suggests.GetCount(); i++) m_pSuggestions->Append(suggests[i]); + for (wxUint32 i = 0; i < suggests.GetCount(); i++) + m_pSuggestions->Append(suggests[i]); } // ------------------------------------------------------------ void CorrectSpellingDlg::OnMove(wxMoveEvent& event) { m_currentPosition = GetPosition(); } diff --git a/SpellChecker/IHunSpell.cpp b/SpellChecker/IHunSpell.cpp index b6f0378b08..d85913251f 100644 --- a/SpellChecker/IHunSpell.cpp +++ b/SpellChecker/IHunSpell.cpp @@ -34,6 +34,7 @@ // License: ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx/wx.h". +#include #ifndef WX_PRECOMP #include #endif @@ -54,7 +55,6 @@ #include #include #include -#include namespace { @@ -62,97 +62,97 @@ namespace /// Only STRING styles std::unordered_map> ALLOWED_STYLES_STRINGS = { - { wxSTC_LEX_ASM, { wxSTC_ASM_STRING } }, - { wxSTC_LEX_BASH, { wxSTC_SH_STRING } }, - { wxSTC_LEX_CMAKE, { wxSTC_CMAKE_STRINGDQ, wxSTC_CMAKE_STRINGLQ, wxSTC_CMAKE_STRINGRQ } }, - { wxSTC_LEX_CSS, { wxSTC_CSS_DOUBLESTRING, wxSTC_CSS_SINGLESTRING } }, - { wxSTC_LEX_CPP, { wxSTC_C_STRING, wxSTC_C_STRINGRAW, wxSTC_C_STRINGEOL } }, - { wxSTC_LEX_FORTRAN, { wxSTC_F_STRING1, wxSTC_F_STRING2 } }, - { wxSTC_LEX_INNOSETUP, { wxSTC_INNO_STRING_DOUBLE, wxSTC_INNO_STRING_SINGLE } }, - { wxSTC_LEX_JSON, { wxSTC_JSON_STRING, wxSTC_JSON_STRINGEOL } }, - { wxSTC_LEX_LUA, { wxSTC_LUA_STRING, wxSTC_LUA_LITERALSTRING, wxSTC_LUA_STRINGEOL } }, - { wxSTC_LEX_MARKDOWN, { wxSTC_MARKDOWN_DEFAULT } }, - { wxSTC_LEX_HTML, - { - wxSTC_H_DOUBLESTRING, - wxSTC_H_SINGLESTRING, - wxSTC_HJ_DOUBLESTRING, - wxSTC_HJ_SINGLESTRING, - wxSTC_HJ_STRINGEOL, - wxSTC_HPHP_HSTRING, - wxSTC_HPHP_SIMPLESTRING, - } }, - { wxSTC_LEX_PYTHON, - { - wxSTC_P_STRING, - wxSTC_P_STRINGEOL, - wxSTC_P_TRIPLE, - wxSTC_P_TRIPLEDOUBLE, + {wxSTC_LEX_ASM, {wxSTC_ASM_STRING}}, + {wxSTC_LEX_BASH, {wxSTC_SH_STRING}}, + {wxSTC_LEX_CMAKE, {wxSTC_CMAKE_STRINGDQ, wxSTC_CMAKE_STRINGLQ, wxSTC_CMAKE_STRINGRQ}}, + {wxSTC_LEX_CSS, {wxSTC_CSS_DOUBLESTRING, wxSTC_CSS_SINGLESTRING}}, + {wxSTC_LEX_CPP, {wxSTC_C_STRING, wxSTC_C_STRINGRAW, wxSTC_C_STRINGEOL}}, + {wxSTC_LEX_FORTRAN, {wxSTC_F_STRING1, wxSTC_F_STRING2}}, + {wxSTC_LEX_INNOSETUP, {wxSTC_INNO_STRING_DOUBLE, wxSTC_INNO_STRING_SINGLE}}, + {wxSTC_LEX_JSON, {wxSTC_JSON_STRING, wxSTC_JSON_STRINGEOL}}, + {wxSTC_LEX_LUA, {wxSTC_LUA_STRING, wxSTC_LUA_LITERALSTRING, wxSTC_LUA_STRINGEOL}}, + {wxSTC_LEX_MARKDOWN, {wxSTC_MARKDOWN_DEFAULT}}, + {wxSTC_LEX_HTML, + { + wxSTC_H_DOUBLESTRING, + wxSTC_H_SINGLESTRING, + wxSTC_HJ_DOUBLESTRING, + wxSTC_HJ_SINGLESTRING, + wxSTC_HJ_STRINGEOL, + wxSTC_HPHP_HSTRING, + wxSTC_HPHP_SIMPLESTRING, + }}, + {wxSTC_LEX_PYTHON, + { + wxSTC_P_STRING, + wxSTC_P_STRINGEOL, + wxSTC_P_TRIPLE, + wxSTC_P_TRIPLEDOUBLE, #if wxCHECK_VERSION(3, 3, 0) - wxSTC_P_FSTRING, - wxSTC_P_FCHARACTER, - wxSTC_P_FTRIPLE, - wxSTC_P_FTRIPLEDOUBLE, + wxSTC_P_FSTRING, + wxSTC_P_FCHARACTER, + wxSTC_P_FTRIPLE, + wxSTC_P_FTRIPLEDOUBLE, #endif - } }, - { wxSTC_LEX_RUBY, - { - wxSTC_RB_STRING, - wxSTC_RB_STRING_Q, - wxSTC_RB_STRING_QQ, - wxSTC_RB_STRING_QX, - wxSTC_RB_STRING_QR, - wxSTC_RB_STRING_QW, - } }, - { wxSTC_LEX_RUST, - { - wxSTC_RUST_STRING, - wxSTC_RUST_STRINGR, - wxSTC_RUST_BYTESTRING, - wxSTC_RUST_BYTESTRINGR, - } }, - { wxSTC_LEX_NULL, { 0 } }, + }}, + {wxSTC_LEX_RUBY, + { + wxSTC_RB_STRING, + wxSTC_RB_STRING_Q, + wxSTC_RB_STRING_QQ, + wxSTC_RB_STRING_QX, + wxSTC_RB_STRING_QR, + wxSTC_RB_STRING_QW, + }}, + {wxSTC_LEX_RUST, + { + wxSTC_RUST_STRING, + wxSTC_RUST_STRINGR, + wxSTC_RUST_BYTESTRING, + wxSTC_RUST_BYTESTRINGR, + }}, + {wxSTC_LEX_NULL, {0}}, }; /// Only COMMENT styles std::unordered_map> ALLOWED_STYLES_COMMENTS = { - { wxSTC_LEX_ASM, { wxSTC_ASM_COMMENT, wxSTC_ASM_COMMENTBLOCK, wxSTC_ASM_COMMENTDIRECTIVE } }, - { wxSTC_LEX_BASH, { wxSTC_SH_COMMENTLINE } }, - { wxSTC_LEX_BATCH, { wxSTC_BAT_COMMENT } }, - { wxSTC_LEX_CMAKE, { wxSTC_CMAKE_COMMENT } }, - { wxSTC_LEX_CSS, { wxSTC_CSS_COMMENT } }, - { wxSTC_LEX_CPP, { wxSTC_C_COMMENT, wxSTC_C_COMMENTDOC, wxSTC_C_COMMENTLINE, wxSTC_C_COMMENTLINEDOC } }, - { wxSTC_LEX_DIFF, { wxSTC_DIFF_COMMENT } }, - { wxSTC_LEX_FORTRAN, { wxSTC_F_COMMENT } }, - { wxSTC_LEX_PROPERTIES, { wxSTC_PROPS_COMMENT } }, - { wxSTC_LEX_INNOSETUP, { wxSTC_INNO_COMMENT } }, - { wxSTC_LEX_JSON, { wxSTC_JSON_LINECOMMENT, wxSTC_JSON_BLOCKCOMMENT } }, - { wxSTC_LEX_LUA, { wxSTC_LUA_COMMENT, wxSTC_LUA_COMMENTLINE, wxSTC_LUA_COMMENTDOC } }, - { wxSTC_LEX_MAKEFILE, { wxSTC_MAKE_COMMENT } }, - { wxSTC_LEX_MARKDOWN, { wxSTC_MARKDOWN_DEFAULT } }, - { wxSTC_LEX_HTML, - { - wxSTC_H_COMMENT, - wxSTC_HJ_COMMENT, - wxSTC_HJ_COMMENTLINE, - wxSTC_HJ_COMMENTDOC, - wxSTC_HPHP_COMMENTLINE, - wxSTC_HPHP_COMMENT, - } }, - { wxSTC_LEX_PYTHON, { wxSTC_P_COMMENTLINE, wxSTC_P_COMMENTBLOCK } }, - { wxSTC_LEX_RUBY, { wxSTC_RB_COMMENTLINE } }, - { wxSTC_LEX_RUST, - { - wxSTC_RUST_COMMENTBLOCK, - wxSTC_RUST_COMMENTLINE, - wxSTC_RUST_COMMENTBLOCKDOC, - wxSTC_RUST_COMMENTLINEDOC, - } }, - { wxSTC_LEX_SQL, { wxSTC_SQL_COMMENT, wxSTC_SQL_COMMENTLINE, wxSTC_SQL_COMMENTDOC } }, - { wxSTC_LEX_TCL, { wxSTC_TCL_COMMENT, wxSTC_TCL_COMMENTLINE, wxSTC_TCL_BLOCK_COMMENT, wxSTC_TCL_COMMENT_BOX } }, - { wxSTC_LEX_NULL, { 0 } }, - { wxSTC_LEX_XML, { wxSTC_H_COMMENT } }, - { wxSTC_LEX_YAML, { wxSTC_YAML_COMMENT } }, + {wxSTC_LEX_ASM, {wxSTC_ASM_COMMENT, wxSTC_ASM_COMMENTBLOCK, wxSTC_ASM_COMMENTDIRECTIVE}}, + {wxSTC_LEX_BASH, {wxSTC_SH_COMMENTLINE}}, + {wxSTC_LEX_BATCH, {wxSTC_BAT_COMMENT}}, + {wxSTC_LEX_CMAKE, {wxSTC_CMAKE_COMMENT}}, + {wxSTC_LEX_CSS, {wxSTC_CSS_COMMENT}}, + {wxSTC_LEX_CPP, {wxSTC_C_COMMENT, wxSTC_C_COMMENTDOC, wxSTC_C_COMMENTLINE, wxSTC_C_COMMENTLINEDOC}}, + {wxSTC_LEX_DIFF, {wxSTC_DIFF_COMMENT}}, + {wxSTC_LEX_FORTRAN, {wxSTC_F_COMMENT}}, + {wxSTC_LEX_PROPERTIES, {wxSTC_PROPS_COMMENT}}, + {wxSTC_LEX_INNOSETUP, {wxSTC_INNO_COMMENT}}, + {wxSTC_LEX_JSON, {wxSTC_JSON_LINECOMMENT, wxSTC_JSON_BLOCKCOMMENT}}, + {wxSTC_LEX_LUA, {wxSTC_LUA_COMMENT, wxSTC_LUA_COMMENTLINE, wxSTC_LUA_COMMENTDOC}}, + {wxSTC_LEX_MAKEFILE, {wxSTC_MAKE_COMMENT}}, + {wxSTC_LEX_MARKDOWN, {wxSTC_MARKDOWN_DEFAULT}}, + {wxSTC_LEX_HTML, + { + wxSTC_H_COMMENT, + wxSTC_HJ_COMMENT, + wxSTC_HJ_COMMENTLINE, + wxSTC_HJ_COMMENTDOC, + wxSTC_HPHP_COMMENTLINE, + wxSTC_HPHP_COMMENT, + }}, + {wxSTC_LEX_PYTHON, {wxSTC_P_COMMENTLINE, wxSTC_P_COMMENTBLOCK}}, + {wxSTC_LEX_RUBY, {wxSTC_RB_COMMENTLINE}}, + {wxSTC_LEX_RUST, + { + wxSTC_RUST_COMMENTBLOCK, + wxSTC_RUST_COMMENTLINE, + wxSTC_RUST_COMMENTBLOCKDOC, + wxSTC_RUST_COMMENTLINEDOC, + }}, + {wxSTC_LEX_SQL, {wxSTC_SQL_COMMENT, wxSTC_SQL_COMMENTLINE, wxSTC_SQL_COMMENTDOC}}, + {wxSTC_LEX_TCL, {wxSTC_TCL_COMMENT, wxSTC_TCL_COMMENTLINE, wxSTC_TCL_BLOCK_COMMENT, wxSTC_TCL_COMMENT_BOX}}, + {wxSTC_LEX_NULL, {0}}, + {wxSTC_LEX_XML, {wxSTC_H_COMMENT}}, + {wxSTC_LEX_YAML, {wxSTC_YAML_COMMENT}}, }; void HighlightWord(IEditor* editor, int pos) @@ -193,9 +193,11 @@ bool IHunSpell::InitEngine() if (m_pSpell != NULL) return true; - m_ignoreList = CustomDictionary(0, StringHashOptionalCase(m_caseSensitiveUserDictionary), + m_ignoreList = CustomDictionary(0, + StringHashOptionalCase(m_caseSensitiveUserDictionary), StringCompareOptionalCase(m_caseSensitiveUserDictionary)); - m_userDict = CustomDictionary(0, StringHashOptionalCase(m_caseSensitiveUserDictionary), + m_userDict = CustomDictionary(0, + StringHashOptionalCase(m_caseSensitiveUserDictionary), StringCompareOptionalCase(m_caseSensitiveUserDictionary)); // check base path @@ -560,12 +562,16 @@ void IHunSpell::SetCaseSensitiveUserDictionary(const bool caseSensitiveUserDicti m_caseSensitiveUserDictionary = caseSensitiveUserDictionary; // Re-order user dictionary and ignores. - CustomDictionary userDict(m_userDict.begin(), m_userDict.end(), 0, + CustomDictionary userDict(m_userDict.begin(), + m_userDict.end(), + 0, StringHashOptionalCase(caseSensitiveUserDictionary), StringCompareOptionalCase(caseSensitiveUserDictionary)); m_userDict.swap(userDict); - CustomDictionary ignoreList(m_ignoreList.begin(), m_ignoreList.end(), 0, + CustomDictionary ignoreList(m_ignoreList.begin(), + m_ignoreList.end(), + 0, StringHashOptionalCase(caseSensitiveUserDictionary), StringCompareOptionalCase(caseSensitiveUserDictionary)); m_ignoreList.swap(ignoreList); diff --git a/SpellChecker/IHunSpell.h b/SpellChecker/IHunSpell.h index 3d5cece19a..0faa185799 100644 --- a/SpellChecker/IHunSpell.h +++ b/SpellChecker/IHunSpell.h @@ -63,7 +63,7 @@ class StringHashOptionalCase size_t operator()(const wxString& str) const { - if(m_isCaseSensitive) { + if (m_isCaseSensitive) { return std::hash()(str); } else { return std::hash()(str.Upper()); @@ -84,7 +84,7 @@ class StringCompareOptionalCase bool operator()(const wxString& lhs, const wxString& rhs) const { - if(m_isCaseSensitive) + if (m_isCaseSensitive) return (0 == lhs.Cmp(rhs)); else return (0 == lhs.CmpNoCase(rhs)); diff --git a/SpellChecker/SpellCheckerSettings.cpp b/SpellChecker/SpellCheckerSettings.cpp index ddc0e9cd7b..654ef941be 100644 --- a/SpellChecker/SpellCheckerSettings.cpp +++ b/SpellChecker/SpellCheckerSettings.cpp @@ -61,17 +61,17 @@ void SpellCheckerSettings::OnInitDialog(wxInitDialogEvent& event) m_pCaseSensitiveUserDictionary->SetValue(m_caseSensitiveUserDictionary); - if(m_pHunspell) { + if (m_pHunspell) { m_pDirPicker->SetPath(m_dictionaryPath); - if(!m_dictionaryPath.IsEmpty()) + if (!m_dictionaryPath.IsEmpty()) FillLanguageList(); } } // ------------------------------------------------------------ void SpellCheckerSettings::OnLanguageSelected(wxCommandEvent& event) { - if(m_pHunspell) { + if (m_pHunspell) { wxString key = m_pLanguageList->GetString(event.GetInt()); m_pCurrentLanguage->SetValue(m_pHunspell->GetLanguageShort(key)); } @@ -79,7 +79,7 @@ void SpellCheckerSettings::OnLanguageSelected(wxCommandEvent& event) // ------------------------------------------------------------ void SpellCheckerSettings::OnUpdateOk(wxUpdateUIEvent& event) { - if(!m_pCurrentLanguage->GetValue().IsEmpty()) + if (!m_pCurrentLanguage->GetValue().IsEmpty()) event.Enable(true); else event.Enable(false); @@ -92,7 +92,7 @@ void SpellCheckerSettings::OnOk(wxCommandEvent& event) m_dictionaryPath = m_pDirPicker->GetPath(); m_caseSensitiveUserDictionary = m_pCaseSensitiveUserDictionary->GetValue(); - if(!wxEndsWithPathSeparator(m_dictionaryPath)) + if (!wxEndsWithPathSeparator(m_dictionaryPath)) m_dictionaryPath += wxFILE_SEP_PATH; } @@ -101,7 +101,7 @@ void SpellCheckerSettings::OnDirChanged(wxFileDirPickerEvent& event) { m_dictionaryPath = m_pDirPicker->GetPath(); - if(!wxEndsWithPathSeparator(m_dictionaryPath)) + if (!wxEndsWithPathSeparator(m_dictionaryPath)) m_dictionaryPath += wxFILE_SEP_PATH; m_pLanguageList->Clear(); m_pCurrentLanguage->SetValue(wxT("")); @@ -111,7 +111,7 @@ void SpellCheckerSettings::OnDirChanged(wxFileDirPickerEvent& event) // ------------------------------------------------------------ void SpellCheckerSettings::FillLanguageList() { - if(!m_dictionaryPath.IsEmpty()) { + if (!m_dictionaryPath.IsEmpty()) { wxArrayString lang; m_pHunspell->GetAvailableLanguageKeyNames(m_dictionaryPath, lang); m_pLanguageList->Clear(); diff --git a/SpellChecker/SpellCheckerSettings.h b/SpellChecker/SpellCheckerSettings.h index f569720e02..1fd5bfc4eb 100644 --- a/SpellChecker/SpellCheckerSettings.h +++ b/SpellChecker/SpellCheckerSettings.h @@ -45,40 +45,32 @@ class SpellCheckerSettings : public SpellCheckerSettings_base { protected: // Handlers for SpellCheckerSettings_base events. - void OnInitDialog( wxInitDialogEvent& event ); - void OnLanguageSelected( wxCommandEvent& event ); - void OnUpdateOk( wxUpdateUIEvent& event ); - void OnOk( wxCommandEvent& event ); - void OnDirChanged( wxFileDirPickerEvent& event ); - void OnClearIgnoreList( wxCommandEvent& event ); + void OnInitDialog(wxInitDialogEvent& event); + void OnLanguageSelected(wxCommandEvent& event); + void OnUpdateOk(wxUpdateUIEvent& event); + void OnOk(wxCommandEvent& event); + void OnDirChanged(wxFileDirPickerEvent& event); + void OnClearIgnoreList(wxCommandEvent& event); void FillLanguageList(); IHunSpell* m_pHunspell; - wxString m_dictionaryFileName; - wxString m_dictionaryPath; - bool m_scanStrings; - bool m_scanCPP; - bool m_scanC; - bool m_scanD1; - bool m_scanD2; - bool m_caseSensitiveUserDictionary; - bool m_ignoreSymbolsInTagsDatabase; + wxString m_dictionaryFileName; + wxString m_dictionaryPath; + bool m_scanStrings; + bool m_scanCPP; + bool m_scanC; + bool m_scanD1; + bool m_scanD2; + bool m_caseSensitiveUserDictionary; + bool m_ignoreSymbolsInTagsDatabase; public: - const wxString& GetDictionaryPath() const { - return m_dictionaryPath; - } - const wxString& GetDictionaryFileName() const { - return m_dictionaryFileName; - } - void SetDictionaryFileName( const wxString& dictionaryFileName ) { - this->m_dictionaryFileName = dictionaryFileName; - } - void SetDictionaryPath( const wxString& dictionaryPath ); - void SetHunspell( IHunSpell* pHunspell ) { - this->m_pHunspell = pHunspell; - } + const wxString& GetDictionaryPath() const { return m_dictionaryPath; } + const wxString& GetDictionaryFileName() const { return m_dictionaryFileName; } + void SetDictionaryFileName(const wxString& dictionaryFileName) { this->m_dictionaryFileName = dictionaryFileName; } + void SetDictionaryPath(const wxString& dictionaryPath); + void SetHunspell(IHunSpell* pHunspell) { this->m_pHunspell = pHunspell; } void SetScanC(bool scanC) { this->m_scanC = scanC; } void SetScanCPP(bool scanCPP) { this->m_scanCPP = scanCPP; } void SetScanD1(bool scanD1) { this->m_scanD1 = scanD1; } @@ -93,29 +85,15 @@ class SpellCheckerSettings : public SpellCheckerSettings_base this->m_ignoreSymbolsInTagsDatabase = ignoreSymbolsInTagsDatabase; } - bool GetScanC() const { - return m_scanC; - } - bool GetScanCPP() const { - return m_scanCPP; - } - bool GetScanD1() const { - return m_scanD1; - } - bool GetScanD2() const { - return m_scanD2; - } - bool GetScanStrings() const { - return m_scanStrings; - } - bool GetCaseSensitiveUserDictionary() const { - return m_caseSensitiveUserDictionary; - } - bool GetIgnoreSymbolsInTagsDatabase() const { - return m_ignoreSymbolsInTagsDatabase; - } + bool GetScanC() const { return m_scanC; } + bool GetScanCPP() const { return m_scanCPP; } + bool GetScanD1() const { return m_scanD1; } + bool GetScanD2() const { return m_scanD2; } + bool GetScanStrings() const { return m_scanStrings; } + bool GetCaseSensitiveUserDictionary() const { return m_caseSensitiveUserDictionary; } + bool GetIgnoreSymbolsInTagsDatabase() const { return m_ignoreSymbolsInTagsDatabase; } /** Constructor */ - SpellCheckerSettings( wxWindow* parent ); + SpellCheckerSettings(wxWindow* parent); virtual ~SpellCheckerSettings() = default; }; diff --git a/SpellChecker/spellcheck.cpp b/SpellChecker/spellcheck.cpp index 658f0c0e8b..88926d15c6 100644 --- a/SpellChecker/spellcheck.cpp +++ b/SpellChecker/spellcheck.cpp @@ -33,6 +33,11 @@ // Copyright: 2014 Frank Lichtner // License: ///////////////////////////////////////////////////////////////////////////// +#include +#ifndef WX_PRECOMP +#include +#endif + #include "spellcheck.h" #include "IHunSpell.h" @@ -46,10 +51,6 @@ #include "workspace.h" #include "wxCustomControls.hpp" -#include -#ifndef WX_PRECOMP -#include -#endif #include #include #include @@ -78,10 +79,7 @@ constexpr int PARSE_TIME = 500; // ------------------------------------------------------------ // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new SpellCheck(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new SpellCheck(manager); } // ------------------------------------------------------------ CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -113,12 +111,12 @@ SpellCheck::~SpellCheck() m_topWin->Unbind(wxEVT_WORKSPACE_LOADED, &SpellCheck::OnWspLoaded, this); m_topWin->Unbind(wxEVT_WORKSPACE_CLOSED, &SpellCheck::OnWspClosed, this); - m_topWin->Unbind(wxEVT_MENU, &SpellCheck::OnSuggestion, this, SPC_SUGGESTION_ID, - SPC_SUGGESTION_ID + maxSuggestions - 1); + m_topWin->Unbind( + wxEVT_MENU, &SpellCheck::OnSuggestion, this, SPC_SUGGESTION_ID, SPC_SUGGESTION_ID + maxSuggestions - 1); m_topWin->Unbind(wxEVT_MENU, &SpellCheck::OnAddWord, this, SPC_ADD_WORD); m_topWin->Unbind(wxEVT_MENU, &SpellCheck::OnIgnoreWord, this, SPC_IGNORE_WORD); - if(m_pEngine != NULL) { + if (m_pEngine != NULL) { SaveSettings(); wxDELETE(m_pEngine); } @@ -136,19 +134,19 @@ void SpellCheck::Init() m_pEngine = new IHunSpell(); m_currentWspPath = wxEmptyString; - if(m_pEngine) { + if (m_pEngine) { LoadSettings(); wxString userDictPath = clStandardPaths::Get().GetUserDataDir(); userDictPath << wxFILE_SEP_PATH << "spellcheck" << wxFILE_SEP_PATH; - if(!wxFileName::DirExists(userDictPath)) { + if (!wxFileName::DirExists(userDictPath)) { wxFileName::Mkdir(userDictPath); } m_pEngine->SetUserDictPath(userDictPath); m_pEngine->SetPlugIn(this); - if(!m_options.GetDictionaryFileName().IsEmpty()) { + if (!m_options.GetDictionaryFileName().IsEmpty()) { m_pEngine->InitEngine(); } } @@ -158,8 +156,8 @@ void SpellCheck::Init() m_topWin->Bind(wxEVT_WORKSPACE_LOADED, &SpellCheck::OnWspLoaded, this); m_topWin->Bind(wxEVT_WORKSPACE_CLOSED, &SpellCheck::OnWspClosed, this); - m_topWin->Bind(wxEVT_MENU, &SpellCheck::OnSuggestion, this, SPC_SUGGESTION_ID, - SPC_SUGGESTION_ID + maxSuggestions - 1); + m_topWin->Bind( + wxEVT_MENU, &SpellCheck::OnSuggestion, this, SPC_SUGGESTION_ID, SPC_SUGGESTION_ID + maxSuggestions - 1); m_topWin->Bind(wxEVT_MENU, &SpellCheck::OnAddWord, this, SPC_ADD_WORD); m_topWin->Bind(wxEVT_MENU, &SpellCheck::OnIgnoreWord, this, SPC_IGNORE_WORD); } @@ -169,8 +167,8 @@ void SpellCheck::CreateToolBar(clToolBarGeneric* toolbar) int size = m_mgr->GetToolbarIconSize(); auto images = toolbar->GetBitmapsCreateIfNeeded(); toolbar->AddSpacer(); - toolbar->AddTool(XRCID(s_doCheckID.ToUTF8()), _("Check spelling..."), images->Add("spellcheck", size), - _("Run spell-checker")); + toolbar->AddTool( + XRCID(s_doCheckID.ToUTF8()), _("Check spelling..."), images->Add("spellcheck", size), _("Run spell-checker")); toolbar->AddToggleButton(XRCID(s_contCheckID.ToUTF8()), images->Add("repeat", size), _("Check continuous")); wxTheApp->Bind(wxEVT_MENU, &SpellCheck::OnCheck, this, XRCID(s_doCheckID.ToUTF8())); wxTheApp->Bind(wxEVT_MENU, &SpellCheck::OnContinuousCheck, this, XRCID(s_contCheckID.ToUTF8())); @@ -194,7 +192,7 @@ void SpellCheck::OnContextMenu(clContextMenuEvent& e) { const auto editor = GetEditor(); const auto menu = e.GetMenu(); - if(!editor || !menu) { + if (!editor || !menu) { return; } @@ -205,7 +203,7 @@ void SpellCheck::OnContextMenu(clContextMenuEvent& e) pt = editor->GetCtrl()->ScreenToClient(pt); const int pos = editor->GetCtrl()->PositionFromPoint(pt); - if(editor->GetCtrl()->IndicatorValueAt(3, pos) == 1) { + if (editor->GetCtrl()->IndicatorValueAt(3, pos) == 1) { m_pLastEditor = nullptr; int start = editor->WordStartPos(pos, true); @@ -213,11 +211,11 @@ void SpellCheck::OnContextMenu(clContextMenuEvent& e) wxString sel = editor->GetSelection(); wxArrayString sugg = m_pEngine->GetSuggestions(sel); - for(size_t i = 0; i < std::min<>(sugg.GetCount(), size_t(maxSuggestions)); i++) { + for (size_t i = 0; i < std::min<>(sugg.GetCount(), size_t(maxSuggestions)); i++) { pSubMenu->Append(SPC_SUGGESTION_ID + i, sugg[i], ""); } - if(sugg.GetCount() != 0) { + if (sugg.GetCount() != 0) { pSubMenu->AppendSeparator(); } @@ -246,7 +244,7 @@ void SpellCheck::AppendSubMenuItems(wxMenu& subMenu) // ------------------------------------------------------------ void SpellCheck::UnPlug() { - if(m_timer.IsRunning()) { + if (m_timer.IsRunning()) { m_timer.Stop(); } } @@ -257,7 +255,7 @@ IEditor* SpellCheck::GetEditor() { IEditor* editor = m_mgr->GetActiveEditor(); - if(!editor) { + if (!editor) { ::wxMessageBox(::wxGetTranslation(s_noEditor), s_codeLite, wxICON_WARNING | wxOK); return NULL; } @@ -280,7 +278,7 @@ void SpellCheck::OnSettings(wxCommandEvent& e) dlg.SetCaseSensitiveUserDictionary(m_pEngine->GetCaseSensitiveUserDictionary()); dlg.SetIgnoreSymbolsInTagsDatabase(m_pEngine->GetIgnoreSymbolsInTagsDatabase()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { m_pEngine->EnableScannerType(IHunSpell::kString, dlg.GetScanStrings()); m_pEngine->EnableScannerType(IHunSpell::kCppComment, dlg.GetScanCPP()); m_pEngine->EnableScannerType(IHunSpell::kCComment, dlg.GetScanC()); @@ -302,23 +300,23 @@ void SpellCheck::OnCheck(wxCommandEvent& e) CHECK_PTR_RET(editor); bool old_continuous_value = GetCheckContinuous(); - if(GetCheckContinuous()) { + if (GetCheckContinuous()) { // switch continuous search off if running SetCheckContinuous(false); } // if we don't have a dictionary yet, open settings - if(!m_pEngine->GetDictionary()) { + if (!m_pEngine->GetDictionary()) { OnSettings(e); return; } m_pEngine->CheckSpelling(); - if(!GetCheckContinuous()) { + if (!GetCheckContinuous()) { editor->ClearUserIndicators(); } - if(old_continuous_value) { + if (old_continuous_value) { SetCheckContinuous(true); } } @@ -356,7 +354,7 @@ void SpellCheck::OnContinuousCheck(wxCommandEvent& e) { CHECK_PTR_RET(m_pEngine); - if(!e.IsChecked()) { + if (!e.IsChecked()) { SetCheckContinuous(false); ClearIndicatorsFromEditors(); return; @@ -365,7 +363,7 @@ void SpellCheck::OnContinuousCheck(wxCommandEvent& e) SetCheckContinuous(true); // if we don't have a dictionary yet, open settings - if(!m_pEngine->GetDictionary()) { + if (!m_pEngine->GetDictionary()) { OnSettings(e); return; } @@ -374,7 +372,7 @@ void SpellCheck::OnContinuousCheck(wxCommandEvent& e) CHECK_PTR_RET(editor); m_pEngine->CheckSpelling(); - if(!GetCheckContinuous()) { + if (!GetCheckContinuous()) { editor->ClearUserIndicators(); } m_timer.Start(PARSE_TIME); @@ -385,7 +383,7 @@ void SpellCheck::OnTimer(wxTimerEvent& e) { wxTopLevelWindow* pWnd = dynamic_cast(GetTopWnd()); - if(!pWnd->IsActive()) { + if (!pWnd->IsActive()) { return; } @@ -395,7 +393,7 @@ void SpellCheck::OnTimer(wxTimerEvent& e) // Only run the checks if we've not run them or the file is modified. const auto modificationCount(editor->GetModificationCount()); - if(!m_forceCheck && ((editor == m_pLastEditor) && (m_lastModificationCount == modificationCount))) { + if (!m_forceCheck && ((editor == m_pLastEditor) && (m_lastModificationCount == modificationCount))) { return; } @@ -412,19 +410,19 @@ void SpellCheck::SetCheckContinuous(bool value) m_options.SetCheckContinuous(value); auto btn = clGetManager()->GetToolBar()->FindById(XRCID(s_contCheckID.ToUTF8())); - if(value) { + if (value) { m_pLastEditor = nullptr; m_timer.Start(PARSE_TIME); - if(btn) { + if (btn) { btn->Check(true); clGetManager()->GetToolBar()->Refresh(); } } else { - if(m_timer.IsRunning()) { + if (m_timer.IsRunning()) { m_timer.Stop(); } - if(btn) { + if (btn) { btn->Check(false); clGetManager()->GetToolBar()->Refresh(); } @@ -444,17 +442,17 @@ void SpellCheck::OnWspClosed(clWorkspaceEvent& e) { e.Skip(); } void SpellCheck::OnSuggestion(wxCommandEvent& e) { const auto editor = GetEditor(); - if(!editor) { + if (!editor) { return; } const auto pMenu = dynamic_cast(e.GetEventObject()); - if(!pMenu) { + if (!pMenu) { return; } const auto pMenuItem = pMenu->FindItem(e.GetId()); - if(!pMenuItem) { + if (!pMenuItem) { return; } @@ -464,12 +462,12 @@ void SpellCheck::OnSuggestion(wxCommandEvent& e) void SpellCheck::OnIgnoreWord(wxCommandEvent& e) { const auto editor = GetEditor(); - if(!editor) { + if (!editor) { return; } const auto selection = editor->GetSelection(); - if(selection.IsEmpty()) { + if (selection.IsEmpty()) { return; } @@ -480,12 +478,12 @@ void SpellCheck::OnIgnoreWord(wxCommandEvent& e) void SpellCheck::OnAddWord(wxCommandEvent& e) { const auto editor = GetEditor(); - if(!editor) { + if (!editor) { return; } const auto selection = editor->GetSelection(); - if(selection.IsEmpty()) { + if (selection.IsEmpty()) { return; } diff --git a/SpellChecker/spellcheckeroptions.cpp b/SpellChecker/spellcheckeroptions.cpp index fd8b2fa0ba..a6eb728d17 100644 --- a/SpellChecker/spellcheckeroptions.cpp +++ b/SpellChecker/spellcheckeroptions.cpp @@ -42,9 +42,9 @@ SpellCheckerOptions::SpellCheckerOptions() m_dictionaryPath.Empty(); m_scanStr = true; m_scanCPP = false; - m_scanC = false; - m_scanD1 = false; - m_scanD2 = false; + m_scanC = false; + m_scanD1 = false; + m_scanD2 = false; m_checkContinuous = false; m_caseSensitiveUserDictionary = true; m_ignoreSymbolsInTagsDatabase = false; @@ -55,32 +55,32 @@ SpellCheckerOptions::SpellCheckerOptions() } // ------------------------------------------------------------ -void SpellCheckerOptions::DeSerialize( Archive& arch ) +void SpellCheckerOptions::DeSerialize(Archive& arch) { - arch.Read( wxT( "m_dictionary" ), m_dictionary ); - arch.Read( wxT( "m_dictionaryPath" ), m_dictionaryPath ); - arch.Read( wxT( "m_scanStr" ), m_scanStr ); - arch.Read( wxT( "m_scanCPP" ), m_scanCPP ); - arch.Read( wxT( "m_scanC" ), m_scanC ); - arch.Read( wxT( "m_scanD1" ), m_scanD1 ); - arch.Read( wxT( "m_scanD2" ), m_scanD2 ); - arch.Read( wxT( "m_checkContinuous" ), m_checkContinuous ); - arch.Read( wxT( "m_caseSensitiveUserDictionary" ), m_caseSensitiveUserDictionary ); - arch.Read( wxT( "m_ignoreSymbolsInTagsDatabase" ), m_ignoreSymbolsInTagsDatabase ); + arch.Read(wxT("m_dictionary"), m_dictionary); + arch.Read(wxT("m_dictionaryPath"), m_dictionaryPath); + arch.Read(wxT("m_scanStr"), m_scanStr); + arch.Read(wxT("m_scanCPP"), m_scanCPP); + arch.Read(wxT("m_scanC"), m_scanC); + arch.Read(wxT("m_scanD1"), m_scanD1); + arch.Read(wxT("m_scanD2"), m_scanD2); + arch.Read(wxT("m_checkContinuous"), m_checkContinuous); + arch.Read(wxT("m_caseSensitiveUserDictionary"), m_caseSensitiveUserDictionary); + arch.Read(wxT("m_ignoreSymbolsInTagsDatabase"), m_ignoreSymbolsInTagsDatabase); } // ------------------------------------------------------------ -void SpellCheckerOptions::Serialize( Archive& arch ) +void SpellCheckerOptions::Serialize(Archive& arch) { - arch.Write( wxT( "m_dictionary" ), m_dictionary ); - arch.Write( wxT( "m_dictionaryPath" ), m_dictionaryPath ); - arch.Write( wxT( "m_scanStr" ), m_scanStr ); - arch.Write( wxT( "m_scanCPP" ), m_scanCPP ); - arch.Write( wxT( "m_scanC" ), m_scanC ); - arch.Write( wxT( "m_scanD1" ), m_scanD1 ); - arch.Write( wxT( "m_scanD2" ), m_scanD2 ); - arch.Write( wxT( "m_checkContinuous" ), m_checkContinuous ); - arch.Write( wxT( "m_caseSensitiveUserDictionary" ), m_caseSensitiveUserDictionary ); - arch.Write( wxT( "m_ignoreSymbolsInTagsDatabase" ), m_ignoreSymbolsInTagsDatabase ); + arch.Write(wxT("m_dictionary"), m_dictionary); + arch.Write(wxT("m_dictionaryPath"), m_dictionaryPath); + arch.Write(wxT("m_scanStr"), m_scanStr); + arch.Write(wxT("m_scanCPP"), m_scanCPP); + arch.Write(wxT("m_scanC"), m_scanC); + arch.Write(wxT("m_scanD1"), m_scanD1); + arch.Write(wxT("m_scanD2"), m_scanD2); + arch.Write(wxT("m_checkContinuous"), m_checkContinuous); + arch.Write(wxT("m_caseSensitiveUserDictionary"), m_caseSensitiveUserDictionary); + arch.Write(wxT("m_ignoreSymbolsInTagsDatabase"), m_ignoreSymbolsInTagsDatabase); } // ------------------------------------------------------------ diff --git a/SpellChecker/spellcheckeroptions.h b/SpellChecker/spellcheckeroptions.h index 97da0e2085..68b364b020 100644 --- a/SpellChecker/spellcheckeroptions.h +++ b/SpellChecker/spellcheckeroptions.h @@ -41,14 +41,14 @@ class SpellCheckerOptions : public SerializedObject { public: - SpellCheckerOptions(); - virtual ~SpellCheckerOptions() = default; + SpellCheckerOptions(); + virtual ~SpellCheckerOptions() = default; - void DeSerialize( Archive& arch ); - void Serialize( Archive& arch ); + void DeSerialize(Archive& arch); + void Serialize(Archive& arch); - void SetDictionaryPath( const wxString& dictionaryPath ) { this->m_dictionaryPath = dictionaryPath; } - void SetDictionaryFileName( const wxString& dictionary ) { this->m_dictionary = dictionary; } + void SetDictionaryPath(const wxString& dictionaryPath) { this->m_dictionaryPath = dictionaryPath; } + void SetDictionaryFileName(const wxString& dictionary) { this->m_dictionary = dictionary; } void SetScanC(bool scanC) { this->m_scanC = scanC; } void SetScanCPP(bool scanCPP) { this->m_scanCPP = scanCPP; } void SetScanD1(bool scanD1) { this->m_scanD1 = scanD1; } @@ -63,28 +63,28 @@ class SpellCheckerOptions : public SerializedObject { this->m_ignoreSymbolsInTagsDatabase = ignoreSymbolsInTagsDatabase; } - bool GetScanC() const { return m_scanC; } - bool GetScanCPP() const { return m_scanCPP; } - bool GetScanD1() const { return m_scanD1; } - bool GetScanD2() const { return m_scanD2; } - bool GetScanStr() const { return m_scanStr; } - const wxString& GetDictionaryPath() const { return m_dictionaryPath; } - const wxString& GetDictionaryFileName() const { return m_dictionary; } - bool GetCheckContinuous() const { return m_checkContinuous; } - bool GetCaseSensitiveUserDictionary() const { return m_caseSensitiveUserDictionary; } - bool GetIgnoreSymbolsInTagsDatabase() const { return m_ignoreSymbolsInTagsDatabase; } + bool GetScanC() const { return m_scanC; } + bool GetScanCPP() const { return m_scanCPP; } + bool GetScanD1() const { return m_scanD1; } + bool GetScanD2() const { return m_scanD2; } + bool GetScanStr() const { return m_scanStr; } + const wxString& GetDictionaryPath() const { return m_dictionaryPath; } + const wxString& GetDictionaryFileName() const { return m_dictionary; } + bool GetCheckContinuous() const { return m_checkContinuous; } + bool GetCaseSensitiveUserDictionary() const { return m_caseSensitiveUserDictionary; } + bool GetIgnoreSymbolsInTagsDatabase() const { return m_ignoreSymbolsInTagsDatabase; } protected: - wxString m_dictionary; - wxString m_dictionaryPath; - bool m_scanStr; - bool m_scanCPP; - bool m_scanC; - bool m_scanD1; - bool m_scanD2; - bool m_checkContinuous; - bool m_caseSensitiveUserDictionary; - bool m_ignoreSymbolsInTagsDatabase; + wxString m_dictionary; + wxString m_dictionaryPath; + bool m_scanStr; + bool m_scanCPP; + bool m_scanC; + bool m_scanD1; + bool m_scanD2; + bool m_checkContinuous; + bool m_caseSensitiveUserDictionary; + bool m_ignoreSymbolsInTagsDatabase; }; //------------------------------------------------------------ #endif // __spellcheckeroptions__ diff --git a/Subversion2/SvnBlameFrame.cpp b/Subversion2/SvnBlameFrame.cpp index 2acb622287..ce1cfa4fe4 100644 --- a/Subversion2/SvnBlameFrame.cpp +++ b/Subversion2/SvnBlameFrame.cpp @@ -39,7 +39,7 @@ SvnBlameFrame::SvnBlameFrame(wxWindow* parent, const wxFileName& filename, const m_stc->SetText(content); m_stc->SetReadOnly(true); LexerConf::Ptr_t lexer = EditorConfigST::Get()->GetLexerForFile(filename.GetFullName()); - if(lexer) { + if (lexer) { lexer->Apply(m_stc, true); } m_stc->Initialize(); diff --git a/Subversion2/SvnBlameFrame.h b/Subversion2/SvnBlameFrame.h index fc45eb85f2..fd56d75103 100644 --- a/Subversion2/SvnBlameFrame.h +++ b/Subversion2/SvnBlameFrame.h @@ -27,6 +27,7 @@ #define SVNBLAMEFRAME_H #include "subversion2_ui.h" + #include class SvnBlameFrame : public SvnBlameFrameBase @@ -34,7 +35,7 @@ class SvnBlameFrame : public SvnBlameFrameBase wxFileName m_filename; public: - SvnBlameFrame(wxWindow* parent, const wxFileName& filename, const wxString &content); + SvnBlameFrame(wxWindow* parent, const wxFileName& filename, const wxString& content); virtual ~SvnBlameFrame() = default; }; #endif // SVNBLAMEFRAME_H diff --git a/Subversion2/SvnCommitDialog.cpp b/Subversion2/SvnCommitDialog.cpp index ee77858817..82184bbb98 100644 --- a/Subversion2/SvnCommitDialog.cpp +++ b/Subversion2/SvnCommitDialog.cpp @@ -74,8 +74,8 @@ SvnCommitDialog::SvnCommitDialog(wxWindow* parent, Subversion2* plugin) DoCommonInit(); } -SvnCommitDialog::SvnCommitDialog(wxWindow* parent, const wxArrayString& paths, const wxString& url, Subversion2* plugin, - const wxString& repoPath) +SvnCommitDialog::SvnCommitDialog( + wxWindow* parent, const wxArrayString& paths, const wxString& url, Subversion2* plugin, const wxString& repoPath) : SvnCommitDialogBaseClass(parent) , m_plugin(plugin) , m_url(url) @@ -83,14 +83,14 @@ SvnCommitDialog::SvnCommitDialog(wxWindow* parent, const wxArrayString& paths, c , m_process(NULL) { wxString title = GetTitle(); - if(!url.empty()) { + if (!url.empty()) { title << wxT(" - ") << url; } SetTitle(title); DoCommonInit(); - if(!paths.empty()) { - for(size_t i = 0; i < paths.GetCount(); ++i) { + if (!paths.empty()) { + for (size_t i = 0; i < paths.GetCount(); ++i) { int index = m_checkListFiles->Append(paths.Item(i)); m_checkListFiles->Check((unsigned int)index); } @@ -112,23 +112,23 @@ void SvnCommitDialog::DoCommonInit() m_stcDiffHelper = std::make_unique(m_stcDiff); DoCreateToolbar(); int sashPos = m_plugin->GetSettings().GetCommitDlgSashPos(); - if(sashPos != wxNOT_FOUND) { + if (sashPos != wxNOT_FOUND) { m_splitterH->SetSashPosition(sashPos); } int sashHPos = m_plugin->GetSettings().GetCommitDlgHSashPos(); - if(sashHPos != wxNOT_FOUND) { + if (sashHPos != wxNOT_FOUND) { m_splitterV->SetSashPosition(sashHPos); } LexerConf::Ptr_t diffLexer = EditorConfigST::Get()->GetLexer("Diff"); - if(diffLexer) { + if (diffLexer) { m_stcDiff->SetLexer(wxSTC_LEX_DIFF); diffLexer->Apply(m_stcDiff); } LexerConf::Ptr_t textLexer = EditorConfigST::Get()->GetLexer("text"); - if(textLexer) { + if (textLexer) { textLexer->Apply(m_stcMessage); } ::clSetTLWindowBestSizeAndPosition(this); @@ -156,13 +156,13 @@ wxString SvnCommitDialog::GetMesasge() msg << wxT("\n"); // Append any bug URLs to the commit message - if(m_textCtrlBugID->IsShown()) { + if (m_textCtrlBugID->IsShown()) { wxString bugTrackerMsg = props.ReadProperty(SubversionLocalProperties::BUG_TRACKER_MESSAGE); wxString bugTrackerUrl = props.ReadProperty(SubversionLocalProperties::BUG_TRACKER_URL); wxString bugId = m_textCtrlBugID->GetValue(); bugId.Trim().Trim(false); - if(bugId.IsEmpty() == false) { + if (bugId.IsEmpty() == false) { // Loop over the bug IDs and append message for each bug wxArrayString bugs = wxStringTokenize(bugId, wxT(","), wxTOKEN_STRTOK); for (auto& bug : bugs) { @@ -183,19 +183,19 @@ wxString SvnCommitDialog::GetMesasge() } // Append any FR URLs to the commit message - if(m_textCtrlFrID->IsShown()) { + if (m_textCtrlFrID->IsShown()) { wxString frTrackerMsg = props.ReadProperty(SubversionLocalProperties::FR_TRACKER_MESSAGE); wxString frTrackerUrl = props.ReadProperty(SubversionLocalProperties::FR_TRACKER_URL); wxString frId = m_textCtrlFrID->GetValue(); frId.Trim().Trim(false); - if(frId.IsEmpty() == false) { + if (frId.IsEmpty() == false) { // Loop over the bug IDs and append message for each bug wxArrayString frs = wxStringTokenize(frId, wxT(","), wxTOKEN_STRTOK); - for(size_t i = 0; i < frs.size(); i++) { + for (size_t i = 0; i < frs.size(); i++) { frs[i].Trim().Trim(false); - if(frs[i].IsEmpty()) + if (frs[i].IsEmpty()) continue; wxString tmpMsg = frTrackerMsg; @@ -226,8 +226,8 @@ wxString SvnCommitDialog::NormalizeMessage(const wxString& message) wxArrayString SvnCommitDialog::GetPaths() { wxArrayString paths; - for(size_t i = 0; i < m_checkListFiles->GetCount(); i++) { - if(m_checkListFiles->IsChecked(i)) { + for (size_t i = 0; i < m_checkListFiles->GetCount(); i++) { + if (m_checkListFiles->IsChecked(i)) { paths.Add(m_checkListFiles->GetString(i)); } } @@ -252,16 +252,16 @@ void SvnCommitDialog::OnProcessTerminatd(clProcessEvent& e) void SvnCommitDialog::DoShowDiff(int selection) { - if(m_repoPath.IsEmpty()) + if (m_repoPath.IsEmpty()) return; wxString filename = m_checkListFiles->GetString(selection); - if(filename.Contains(" ")) { + if (filename.Contains(" ")) { filename.Prepend("\"").Append("\""); } - if(m_cache.count(filename)) { + if (m_cache.count(filename)) { m_stcDiff->SetReadOnly(false); m_stcDiff->SetText(m_cache[filename]); m_stcDiff->SetReadOnly(true); @@ -284,7 +284,7 @@ void SvnCommitDialog::OnShowCommitHistory(wxCommandEvent& event) m_plugin->GetCommitMessagesCache().GetMessages(lastMessages, previews); clSingleChoiceDialog dlg(this, lastMessages); dlg.SetLabel(_("Choose a commit")); - if(dlg.ShowModal() != wxID_OK) + if (dlg.ShowModal() != wxID_OK) return; m_stcMessage->SetText(dlg.GetSelection()); } @@ -297,8 +297,10 @@ void SvnCommitDialog::OnShowCommitHistoryUI(wxUpdateUIEvent& event) } void SvnCommitDialog::OnClearHistory(wxCommandEvent& event) { - if(::wxMessageBox(_("This will clear the message history\nContinue?"), "CodeLite", - wxICON_WARNING | wxCENTER | wxYES_NO | wxCANCEL | wxCANCEL_DEFAULT, this) == wxYES) { + if (::wxMessageBox(_("This will clear the message history\nContinue?"), + "CodeLite", + wxICON_WARNING | wxCENTER | wxYES_NO | wxCANCEL | wxCANCEL_DEFAULT, + this) == wxYES) { m_plugin->GetCommitMessagesCache().Clear(); } } @@ -331,7 +333,7 @@ void SvnCommitDialog::OnShowCommitHistoryDropDown(wxCommandEvent& event) [&](wxCommandEvent& event) { wxArrayString lastMessages, previews; m_plugin->GetCommitMessagesCache().GetMessages(lastMessages, previews); - if(!lastMessages.empty()) { + if (!lastMessages.empty()) { m_stcMessage->SetText(lastMessages.Item(0)); } }, diff --git a/Subversion2/SvnCommitDialog.h b/Subversion2/SvnCommitDialog.h index 71a90b518d..ca034e8e2c 100644 --- a/Subversion2/SvnCommitDialog.h +++ b/Subversion2/SvnCommitDialog.h @@ -51,7 +51,10 @@ class SvnCommitDialog : public SvnCommitDialogBaseClass public: SvnCommitDialog(wxWindow* parent, Subversion2* plugin); - SvnCommitDialog(wxWindow* parent, const wxArrayString& paths, const wxString& url, Subversion2* plugin, + SvnCommitDialog(wxWindow* parent, + const wxArrayString& paths, + const wxString& url, + Subversion2* plugin, const wxString& repoPath); virtual ~SvnCommitDialog(); diff --git a/Subversion2/SvnInfoDialog.h b/Subversion2/SvnInfoDialog.h index 353ff24cb3..946d0f1d89 100644 --- a/Subversion2/SvnInfoDialog.h +++ b/Subversion2/SvnInfoDialog.h @@ -32,20 +32,10 @@ class SvnInfoDialog : public SvnInfoDialogBase public: SvnInfoDialog(wxWindow* parent); virtual ~SvnInfoDialog() = default; - wxTextCtrl* GetTextCtrlAuthor() { - return m_textCtrlAuthor; - } - wxTextCtrl* GetTextCtrlDate() { - return m_textCtrlDate; - } - wxTextCtrl* GetTextCtrlRevision() { - return m_textCtrlRevision; - } - wxTextCtrl* GetTextCtrlRootURL() { - return m_textCtrlRootURL; - } - wxTextCtrl* GetTextCtrlURL() { - return m_textCtrlURL; - } + wxTextCtrl* GetTextCtrlAuthor() { return m_textCtrlAuthor; } + wxTextCtrl* GetTextCtrlDate() { return m_textCtrlDate; } + wxTextCtrl* GetTextCtrlRevision() { return m_textCtrlRevision; } + wxTextCtrl* GetTextCtrlRootURL() { return m_textCtrlRootURL; } + wxTextCtrl* GetTextCtrlURL() { return m_textCtrlURL; } }; -#endif // SVNINFODIALOG_H +#endif // SVNINFODIALOG_H diff --git a/Subversion2/SvnLogDialog.h b/Subversion2/SvnLogDialog.h index 2986284738..9227dd8ee5 100644 --- a/Subversion2/SvnLogDialog.h +++ b/Subversion2/SvnLogDialog.h @@ -33,23 +33,11 @@ class SvnLogDialog : public SvnLogDialogBase SvnLogDialog(wxWindow* parent); virtual ~SvnLogDialog() = default; - void SetCompact(wxCheckBox* compact) { - this->m_compact = compact; - } - void SetFrom(wxTextCtrl* from) { - this->m_from = from; - } - void SetTo(wxTextCtrl* to) { - this->m_to = to; - } - wxCheckBox* GetCompact() { - return m_compact; - } - wxTextCtrl* GetFrom() { - return m_from; - } - wxTextCtrl* GetTo() { - return m_to; - } + void SetCompact(wxCheckBox* compact) { this->m_compact = compact; } + void SetFrom(wxTextCtrl* from) { this->m_from = from; } + void SetTo(wxTextCtrl* to) { this->m_to = to; } + wxCheckBox* GetCompact() { return m_compact; } + wxTextCtrl* GetFrom() { return m_from; } + wxTextCtrl* GetTo() { return m_to; } }; -#endif // SVNLOGDIALOG_H +#endif // SVNLOGDIALOG_H diff --git a/Subversion2/SvnShowFileChangesHandler.cpp b/Subversion2/SvnShowFileChangesHandler.cpp index ee4014957a..5b24ac694e 100644 --- a/Subversion2/SvnShowFileChangesHandler.cpp +++ b/Subversion2/SvnShowFileChangesHandler.cpp @@ -1,8 +1,10 @@ #include "SvnShowFileChangesHandler.h" + #include "file_logger.h" -#include #include "subversion2.h" +#include + SvnShowFileChangesHandler::SvnShowFileChangesHandler(Subversion2* plugin, int cmdid, wxEvtHandler* owner) : SvnCommandHandler(plugin, cmdid, owner) { @@ -16,22 +18,23 @@ void SvnShowFileChangesHandler::Process(const wxString& output) SvnShowDiffChunk::List_t changes; SvnShowDiffChunk curchange; wxArrayString lines = ::wxStringTokenize(output, "\n", wxTOKEN_RET_DELIMS); - if(lines.IsEmpty()) return; - + if (lines.IsEmpty()) + return; + // Remove everything until we find the first line that starts with "---------..." // Remove it and then break the loop - while(!lines.IsEmpty()) { + while (!lines.IsEmpty()) { wxString firstLine = lines.Item(0); lines.RemoveAt(0); - if(firstLine.StartsWith("------")) { + if (firstLine.StartsWith("------")) { break; } } eState state = kWaitingHeader; - while(!lines.IsEmpty()) { + while (!lines.IsEmpty()) { wxString curline = lines.Item(0); - switch(state) { + switch (state) { case kWaitingHeader: curchange.description = curline.Trim().Trim(false); lines.RemoveAt(0); @@ -39,9 +42,9 @@ void SvnShowFileChangesHandler::Process(const wxString& output) break; case kWaitingDiffBlock: - if(curline.StartsWith("======")) { + if (curline.StartsWith("======")) { // the line above us was the file name of the diff, restore it - if(!curchange.commentArr.IsEmpty()) { + if (!curchange.commentArr.IsEmpty()) { wxString fileNameLine = curchange.commentArr.Last(); curchange.commentArr.RemoveAt(curchange.commentArr.size() - 1); // Remove the last line lines.Insert(fileNameLine, 0); @@ -54,7 +57,7 @@ void SvnShowFileChangesHandler::Process(const wxString& output) break; case kWaitingSeparator: - if(curline.StartsWith("---------")) { + if (curline.StartsWith("---------")) { // our chunk is complete, add it curchange.Finalize(); changes.push_back(curchange); diff --git a/Subversion2/SvnShowFileChangesHandler.h b/Subversion2/SvnShowFileChangesHandler.h index 2a7b604c05..f0a1570b52 100644 --- a/Subversion2/SvnShowFileChangesHandler.h +++ b/Subversion2/SvnShowFileChangesHandler.h @@ -2,6 +2,7 @@ #define SVNSHOWFILECHANGESHANDLER_H #include "svncommandhandler.h" // Base class: SvnCommandHandler + #include #include @@ -24,7 +25,7 @@ struct SvnShowDiffChunk { commentArr.Clear(); // Extract the revision number revision = description.BeforeFirst('|').Trim().Trim(false); - + description.Trim().Trim(false); } diff --git a/Subversion2/SvnShowRecentChangesDlg.cpp b/Subversion2/SvnShowRecentChangesDlg.cpp index a583f76090..e1c4e92bcd 100644 --- a/Subversion2/SvnShowRecentChangesDlg.cpp +++ b/Subversion2/SvnShowRecentChangesDlg.cpp @@ -1,7 +1,8 @@ #include "SvnShowRecentChangesDlg.h" -#include "macros.h" + #include "ColoursAndFontsManager.h" #include "lexer_configuration.h" +#include "macros.h" struct SvnShowDiffChunkUI : public wxClientData { SvnShowDiffChunk m_chunk; @@ -22,12 +23,12 @@ SvnShowRecentChangesDlg::SvnShowRecentChangesDlg(wxWindow* parent, const SvnShow m_listBoxRevisions->Select(0); LexerConf::Ptr_t diffLexer = ColoursAndFontsManager::Get().GetLexer("diff"); - if(diffLexer) { + if (diffLexer) { diffLexer->Apply(m_stcDiff); } LexerConf::Ptr_t textLexer = ColoursAndFontsManager::Get().GetLexer("text"); - if(textLexer) { + if (textLexer) { textLexer->Apply(m_stcComment); } DoSelectRevision(0); @@ -36,7 +37,8 @@ SvnShowRecentChangesDlg::SvnShowRecentChangesDlg(wxWindow* parent, const SvnShow void SvnShowRecentChangesDlg::OnRevisionSelected(wxCommandEvent& event) { int where = event.GetSelection(); - if(where == wxNOT_FOUND) return; + if (where == wxNOT_FOUND) + return; DoSelectRevision(where); } @@ -52,6 +54,6 @@ void SvnShowRecentChangesDlg::DoSelectRevision(int index) m_stcDiff->SetReadOnly(false); m_stcDiff->SetText(chunk->m_chunk.diff); m_stcDiff->SetReadOnly(true); - + m_staticTextDesc->SetLabel(chunk->m_chunk.description); } diff --git a/Subversion2/SvnShowRecentChangesDlg.h b/Subversion2/SvnShowRecentChangesDlg.h index 1815224a0f..b3b2f87fbf 100644 --- a/Subversion2/SvnShowRecentChangesDlg.h +++ b/Subversion2/SvnShowRecentChangesDlg.h @@ -1,7 +1,7 @@ #ifndef SVNSHOWRECENTCHANGESDLG_H #define SVNSHOWRECENTCHANGESDLG_H -#include "subversion2_ui.h" #include "SvnShowFileChangesHandler.h" +#include "subversion2_ui.h" class SvnShowRecentChangesDlg : public SvnShowRecentChangesBaseDlg { diff --git a/Subversion2/clcommandlineparser.cpp b/Subversion2/clcommandlineparser.cpp index d55a64660d..384a3a1475 100644 --- a/Subversion2/clcommandlineparser.cpp +++ b/Subversion2/clcommandlineparser.cpp @@ -35,8 +35,10 @@ clCommandLineParser::clCommandLineParser(const wxString& str) #define STATE_IN_SINGLE_QUOTES 1 #define STATE_IN_DOUBLE_QUOTES 2 -#define PUSH_TOKEN() \ - if(!curtoken.IsEmpty()) { m_tokens.Add(curtoken); } \ +#define PUSH_TOKEN() \ + if (!curtoken.IsEmpty()) { \ + m_tokens.Add(curtoken); \ + } \ curtoken.Clear(); void clCommandLineParser::DoParse() @@ -45,11 +47,11 @@ void clCommandLineParser::DoParse() wxString curtoken; int state = STATE_NORMAL; - for(size_t i = 0; i < tmpstr.length(); ++i) { + for (size_t i = 0; i < tmpstr.length(); ++i) { wxChar ch = tmpstr.at(i); - switch(state) { + switch (state) { case STATE_NORMAL: { - switch(ch) { + switch (ch) { case '\n': case '\r': break; @@ -75,7 +77,7 @@ void clCommandLineParser::DoParse() break; } case STATE_IN_DOUBLE_QUOTES: - if(ch == '"') { + if (ch == '"') { PUSH_TOKEN(); state = STATE_NORMAL; } else { @@ -83,7 +85,7 @@ void clCommandLineParser::DoParse() } break; case STATE_IN_SINGLE_QUOTES: - if(ch == '\'') { + if (ch == '\'') { PUSH_TOKEN(); state = STATE_NORMAL; } else { diff --git a/Subversion2/clcommandlineparser.h b/Subversion2/clcommandlineparser.h index 5530bc193b..de68a3a720 100644 --- a/Subversion2/clcommandlineparser.h +++ b/Subversion2/clcommandlineparser.h @@ -26,8 +26,8 @@ #ifndef CLCOMMANDLINEPARSER_H #define CLCOMMANDLINEPARSER_H -#include #include +#include class clCommandLineParser { diff --git a/Subversion2/commitmessagescache.cpp b/Subversion2/commitmessagescache.cpp index b5dc70d936..15ddc1f596 100644 --- a/Subversion2/commitmessagescache.cpp +++ b/Subversion2/commitmessagescache.cpp @@ -24,6 +24,7 @@ ////////////////////////////////////////////////////////////////////////////// #include "commitmessagescache.h" + #include "cl_config.h" CommitMessagesCache::CommitMessagesCache() @@ -40,7 +41,7 @@ CommitMessagesCache::~CommitMessagesCache() void CommitMessagesCache::GetMessages(wxArrayString& messages, wxArrayString& previews) { - for(size_t i = 0; i < m_messages.GetCount(); i++) { + for (size_t i = 0; i < m_messages.GetCount(); i++) { messages.Add(m_messages.Item(i)); previews.Add(m_messages.Item(i).BeforeFirst(wxT('\n'))); } @@ -49,10 +50,11 @@ void CommitMessagesCache::GetMessages(wxArrayString& messages, wxArrayString& pr void CommitMessagesCache::AddMessage(const wxString& message) { wxString formattedMessage = FormatMessage(message); - if(formattedMessage.IsEmpty()) return; + if (formattedMessage.IsEmpty()) + return; int where = m_messages.Index(formattedMessage); - if(where != wxNOT_FOUND) { + if (where != wxNOT_FOUND) { m_messages.RemoveAt(where); } // Place the new message at the top of the message list diff --git a/Subversion2/commitmessagescache.h b/Subversion2/commitmessagescache.h index 82f9bd6477..a1f226d761 100644 --- a/Subversion2/commitmessagescache.h +++ b/Subversion2/commitmessagescache.h @@ -50,7 +50,7 @@ class CommitMessagesCache * @param message */ void AddMessage(const wxString& message); - + /** * @brief is the cache empty? */ diff --git a/Subversion2/diff_dialog.cpp b/Subversion2/diff_dialog.cpp index 48a6eb4c77..7baa751d27 100644 --- a/Subversion2/diff_dialog.cpp +++ b/Subversion2/diff_dialog.cpp @@ -23,39 +23,37 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#include "diff_dialog.h" -#include "windowattrmanager.h" -#include "imanager.h" - -DiffDialog::DiffDialog( wxWindow* parent, IManager *manager ) - : DiffDialogBase( parent ) - , m_manager(manager) -{ +#include "diff_dialog.h" + +#include "imanager.h" +#include "windowattrmanager.h" + +DiffDialog::DiffDialog(wxWindow* parent, IManager* manager) + : DiffDialogBase(parent) + , m_manager(manager) +{ m_textCtrlFromRev->SetFocus(); - SetName("DiffDialog"); - WindowAttrManager::Load(this); -} - -wxString DiffDialog::GetFromRevision() const -{ - wxString from = m_textCtrlFromRev->GetValue(); - from.Trim().Trim(false); - - if(from.IsEmpty()) { - return wxT("BASE"); - } else { - return from; - } -} - -wxString DiffDialog::GetToRevision() const -{ - wxString to = m_textCtrlToRev->GetValue(); - to.Trim().Trim(false); - return to; -} + SetName("DiffDialog"); + WindowAttrManager::Load(this); +} + +wxString DiffDialog::GetFromRevision() const +{ + wxString from = m_textCtrlFromRev->GetValue(); + from.Trim().Trim(false); -bool DiffDialog::IgnoreWhitespaces() const -{ - return m_checkBoxIgnoreWhitespace->IsChecked(); + if (from.IsEmpty()) { + return wxT("BASE"); + } else { + return from; + } } + +wxString DiffDialog::GetToRevision() const +{ + wxString to = m_textCtrlToRev->GetValue(); + to.Trim().Trim(false); + return to; +} + +bool DiffDialog::IgnoreWhitespaces() const { return m_checkBoxIgnoreWhitespace->IsChecked(); } diff --git a/Subversion2/diff_dialog.h b/Subversion2/diff_dialog.h index 29f3b391af..bcbf51e925 100644 --- a/Subversion2/diff_dialog.h +++ b/Subversion2/diff_dialog.h @@ -39,17 +39,17 @@ class IManager; class DiffDialog : public DiffDialogBase { protected: - IManager *m_manager; + IManager* m_manager; public: /** Constructor */ - DiffDialog( wxWindow* parent, IManager *manager ); + DiffDialog(wxWindow* parent, IManager* manager); //// end generated class members - virtual ~DiffDialog() = default; - wxString GetFromRevision() const; + virtual ~DiffDialog() = default; + wxString GetFromRevision() const; wxString GetToRevision() const; - bool IgnoreWhitespaces() const; -}; - + bool IgnoreWhitespaces() const; +}; + #endif // __diff_dialog__ diff --git a/Subversion2/subversion2.cpp b/Subversion2/subversion2.cpp index 1a4385c953..943425c366 100644 --- a/Subversion2/subversion2.cpp +++ b/Subversion2/subversion2.cpp @@ -71,21 +71,21 @@ static void ConvertToWindowsEOL(wxString& str) wxString newBuffer; newBuffer.Alloc(str.Len()); - for(size_t i = 0; i < str.Len(); i++) { + for (size_t i = 0; i < str.Len(); i++) { wxChar nextChar = '\0'; wxChar ch = str.GetChar(i); - if((i + 1) < str.Len()) { + if ((i + 1) < str.Len()) { nextChar = str.GetChar(i + 1); } - if(ch == '\r' && nextChar == '\n') { + if (ch == '\r' && nextChar == '\n') { newBuffer << "\r\n"; i++; - } else if(ch == '\n') { + } else if (ch == '\n') { newBuffer << "\r\n"; - } else if(ch == '\r' && nextChar != '\n') { + } else if (ch == '\r' && nextChar != '\n') { newBuffer << "\r\n"; } else { @@ -101,18 +101,18 @@ static void ConvertToUnixEOL(wxString& str) wxString newBuffer; newBuffer.Alloc(str.Len()); - for(size_t i = 0; i < str.Len(); i++) { + for (size_t i = 0; i < str.Len(); i++) { wxChar nextChar = '\0'; wxChar ch = str.GetChar(i); - if((i + 1) < str.Len()) { + if ((i + 1) < str.Len()) { nextChar = str.GetChar(i + 1); } - if(ch == '\r' && nextChar == '\n') { + if (ch == '\r' && nextChar == '\n') { newBuffer << "\n"; i++; - } else if(ch == '\r' && nextChar != '\n') { + } else if (ch == '\r' && nextChar != '\n') { newBuffer << "\n"; } else { @@ -123,10 +123,7 @@ static void ConvertToUnixEOL(wxString& str) } // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new Subversion2(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new Subversion2(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -155,49 +152,100 @@ Subversion2::Subversion2(IManager* manager) DoInitialize(); - GetManager()->GetTheApp()->Connect(XRCID("subversion2_settings"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnSettings), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_commit"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnCommit), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_update"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnUpdate), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_add"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnFolderAdd), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_delete"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnDeleteFolder), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_rename"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnFileExplorerRenameItem), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_revert"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnFileExplorerRevertItem), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_revert_to_revision"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnRevertToRevision), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_diff"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnFileExplorerDiff), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_log"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnLog), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_blame"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnBlame), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_ignore_file"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnIgnoreFile), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_ignore_file_pattern"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnIgnoreFilePattern), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_set_as_view"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnSelectAsView), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_unlock"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnUnLockFile), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_lock"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnLockFile), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_workspace_sync"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnSync), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_show_changes"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnShowFileChanges), NULL, this); - - EventNotifier::Get()->Connect(wxEVT_GET_ADDITIONAL_COMPILEFLAGS, clBuildEventHandler(Subversion2::OnGetCompileLine), - NULL, this); - EventNotifier::Get()->Connect(wxEVT_WORKSPACE_CONFIG_CHANGED, - wxCommandEventHandler(Subversion2::OnWorkspaceConfigChanged), NULL, this); - EventNotifier::Get()->Connect(wxEVT_PROJ_FILE_REMOVED, clCommandEventHandler(Subversion2::OnProjectFileRemoved), - NULL, this); + GetManager()->GetTheApp()->Connect(XRCID("subversion2_settings"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnSettings), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_commit"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnCommit), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_update"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnUpdate), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_add"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnFolderAdd), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_delete"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnDeleteFolder), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_rename"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnFileExplorerRenameItem), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_revert"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnFileExplorerRevertItem), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_revert_to_revision"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnRevertToRevision), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_diff"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnFileExplorerDiff), + NULL, + this); + GetManager()->GetTheApp()->Connect( + XRCID("svn_explorer_log"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(Subversion2::OnLog), NULL, this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_blame"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnBlame), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_ignore_file"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnIgnoreFile), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_ignore_file_pattern"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnIgnoreFilePattern), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_set_as_view"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnSelectAsView), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_unlock"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnUnLockFile), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_lock"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnLockFile), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_workspace_sync"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnSync), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_show_changes"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnShowFileChanges), + NULL, + this); + + EventNotifier::Get()->Connect( + wxEVT_GET_ADDITIONAL_COMPILEFLAGS, clBuildEventHandler(Subversion2::OnGetCompileLine), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_WORKSPACE_CONFIG_CHANGED, wxCommandEventHandler(Subversion2::OnWorkspaceConfigChanged), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_PROJ_FILE_REMOVED, clCommandEventHandler(Subversion2::OnProjectFileRemoved), NULL, this); EventNotifier::Get()->Bind(wxEVT_CONTEXT_MENU_FOLDER, &Subversion2::OnFolderContextMenu, this); EventNotifier::Get()->Bind(wxEVT_CONTEXT_MENU_FILE, &Subversion2::OnFileContextMenu, this); EventNotifier::Get()->Bind(wxEVT_FILE_DELETED, &Subversion2::OnFileDeleted, this); @@ -238,8 +286,8 @@ wxMenu* Subversion2::CreateProjectPopMenu() void Subversion2::HookPopupMenu(wxMenu* menu, MenuType type) { - if(type == MenuTypeFileView_Project) { - if(!menu->FindItem(XRCID("SUBVERSION_PROJECT_POPUP"))) { + if (type == MenuTypeFileView_Project) { + if (!menu->FindItem(XRCID("SUBVERSION_PROJECT_POPUP"))) { m_projectSepItem = menu->PrependSeparator(); menu->Prepend(XRCID("SUBVERSION_PROJECT_POPUP"), "Subversion", CreateProjectPopMenu()); } @@ -253,9 +301,9 @@ wxMenu* Subversion2::CreateFileExplorerPopMenu(bool isFile) wxMenu* menu = new wxMenu(); wxMenuItem* item(NULL); - if(!isFile) { - item = new wxMenuItem(menu, XRCID("svn_explorer_set_as_view"), _("Watch this folder"), wxEmptyString, - wxITEM_NORMAL); + if (!isFile) { + item = new wxMenuItem( + menu, XRCID("svn_explorer_set_as_view"), _("Watch this folder"), wxEmptyString, wxITEM_NORMAL); menu->Append(item); menu->AppendSeparator(); } @@ -275,7 +323,7 @@ wxMenu* Subversion2::CreateFileExplorerPopMenu(bool isFile) menu->AppendSeparator(); - if(isFile) { + if (isFile) { item = new wxMenuItem(menu, XRCID("svn_explorer_lock"), _("Lock file"), wxEmptyString, wxITEM_NORMAL); menu->Append(item); @@ -284,8 +332,8 @@ wxMenu* Subversion2::CreateFileExplorerPopMenu(bool isFile) menu->AppendSeparator(); - item = new wxMenuItem(menu, XRCID("svn_explorer_show_changes"), _("Show Recent Changes"), wxEmptyString, - wxITEM_NORMAL); + item = new wxMenuItem( + menu, XRCID("svn_explorer_show_changes"), _("Show Recent Changes"), wxEmptyString, wxITEM_NORMAL); menu->Append(item); menu->AppendSeparator(); } @@ -298,8 +346,8 @@ wxMenu* Subversion2::CreateFileExplorerPopMenu(bool isFile) menu->AppendSeparator(); - item = new wxMenuItem(menu, XRCID("svn_explorer_revert_to_revision"), _("Revert to revision"), wxEmptyString, - wxITEM_NORMAL); + item = new wxMenuItem( + menu, XRCID("svn_explorer_revert_to_revision"), _("Revert to revision"), wxEmptyString, wxITEM_NORMAL); menu->Append(item); menu->AppendSeparator(); @@ -319,43 +367,85 @@ void Subversion2::UnPlug() EventNotifier::Get()->Unbind(wxEVT_GOTO_ANYTHING_SHOWING, &Subversion2::OnGotoAnythingShowing, this); m_tabToggler.reset(); - GetManager()->GetTheApp()->Disconnect(XRCID("subversion2_settings"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnSettings), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_commit"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnCommit), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_update"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnUpdate), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_add"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnFolderAdd), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_delete"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnDeleteFolder), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_rename"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnFileExplorerRenameItem), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_revert"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnFileExplorerRevertItem), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_diff"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnFileExplorerDiff), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_log"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnLog), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_blame"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnBlame), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_ignore_file"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnIgnoreFile), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_ignore_file_pattern"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnIgnoreFilePattern), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_set_as_view"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnSelectAsView), NULL, this); - GetManager()->GetTheApp()->Disconnect(XRCID("svn_workspace_sync"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnSync), NULL, this); - GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_show_changes"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Subversion2::OnShowFileChanges), NULL, this); - EventNotifier::Get()->Disconnect(wxEVT_GET_ADDITIONAL_COMPILEFLAGS, - clBuildEventHandler(Subversion2::OnGetCompileLine), NULL, this); + GetManager()->GetTheApp()->Disconnect(XRCID("subversion2_settings"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnSettings), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_commit"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnCommit), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_update"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnUpdate), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_add"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnFolderAdd), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_delete"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnDeleteFolder), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_rename"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnFileExplorerRenameItem), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_revert"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnFileExplorerRevertItem), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_diff"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnFileExplorerDiff), + NULL, + this); + GetManager()->GetTheApp()->Disconnect( + XRCID("svn_explorer_log"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(Subversion2::OnLog), NULL, this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_blame"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnBlame), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_ignore_file"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnIgnoreFile), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_ignore_file_pattern"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnIgnoreFilePattern), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_explorer_set_as_view"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnSelectAsView), + NULL, + this); + GetManager()->GetTheApp()->Disconnect(XRCID("svn_workspace_sync"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnSync), + NULL, + this); + GetManager()->GetTheApp()->Connect(XRCID("svn_explorer_show_changes"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Subversion2::OnShowFileChanges), + NULL, + this); + EventNotifier::Get()->Disconnect( + wxEVT_GET_ADDITIONAL_COMPILEFLAGS, clBuildEventHandler(Subversion2::OnGetCompileLine), NULL, this); m_subversionView->DisconnectEvents(); // Remove the tab if it's actually docked in the workspace pane - if(!m_mgr->BookDeletePage(PaneId::BOTTOM_BAR, m_subversionView)) { + if (!m_mgr->BookDeletePage(PaneId::BOTTOM_BAR, m_subversionView)) { m_subversionView->Destroy(); } m_subversionView = nullptr; @@ -365,7 +455,7 @@ void Subversion2::EnsureVisible() { // Ensure that the Output View is displayed wxAuiPaneInfo& pi = GetManager()->GetDockingManager()->GetPane("Output View"); - if(pi.IsOk() && !pi.IsShown()) { + if (pi.IsOk() && !pi.IsShown()) { pi.Show(true); GetManager()->GetDockingManager()->Update(); } @@ -377,7 +467,7 @@ void Subversion2::DoInitialize() m_svnBitmap = GetManager()->GetStdIcons()->LoadBitmap("subversion"); // create tab (possibly detached) - if(IsSubversionViewDetached()) { + if (IsSubversionViewDetached()) { // Make the window child of the main panel (which is the grand parent of the notebook) DockablePane* cp = new DockablePane(m_mgr->GetMainPanel(), PaneId::BOTTOM_BAR, svnCONSOLE_TEXT, false, wxSize(200, 200)); @@ -438,7 +528,7 @@ void Subversion2::DoSetSSH() // backward slashes sshClient.Replace("\\", "/"); - if(sshClient.IsEmpty() == false) { + if (sshClient.IsEmpty() == false) { wxString env_value(sshClient + " " + sshClientArgs); wxSetEnv("SVN_SSH", env_value.c_str()); } @@ -452,12 +542,12 @@ void Subversion2::OnFolderAdd(wxCommandEvent& event) { wxString command; wxString loginString; - if(LoginIfNeeded(event, DoGetFileExplorerItemPath(), loginString) == false) { + if (LoginIfNeeded(event, DoGetFileExplorerItemPath(), loginString) == false) { return; } wxFileName workingDirectory(m_selectedFolder, ""); - if(m_selectedFile.IsOk()) { + if (m_selectedFile.IsOk()) { command << GetSvnExeName() << loginString << " add " << m_selectedFile.GetFullName(); } else { wxString folderName = workingDirectory.GetDirs().Last(); @@ -472,7 +562,7 @@ void Subversion2::OnFolderAdd(wxCommandEvent& event) void Subversion2::OnCommit(wxCommandEvent& event) { // Coming from file explorer - const wxArrayString paths = StdToWX::ToArrayString({ m_selectedFile.IsOk() ? m_selectedFile.GetFullName() : "." }); + const wxArrayString paths = StdToWX::ToArrayString({m_selectedFile.IsOk() ? m_selectedFile.GetFullName() : "."}); DoCommit(paths, m_selectedFolder, event); } @@ -481,13 +571,13 @@ void Subversion2::OnDeleteFolder(wxCommandEvent& event) // Coming from file explorer wxString command; wxString loginString; - if(LoginIfNeeded(event, m_selectedFolder, loginString) == false) { + if (LoginIfNeeded(event, m_selectedFolder, loginString) == false) { return; } // svn delete --force wxFileName workingDirectory(m_selectedFolder, ""); - if(!m_selectedFile.IsOk()) { + if (!m_selectedFile.IsOk()) { wxString folderName = workingDirectory.GetDirs().Last(); StringUtils::WrapWithQuotes(folderName); @@ -503,13 +593,14 @@ void Subversion2::OnDeleteFolder(wxCommandEvent& event) void Subversion2::OnFileExplorerRevertItem(wxCommandEvent& event) { // Coming from the file explorer - if(wxMessageBox(_("You are about to revert all your changes\nAre you sure?"), "CodeLite", - wxICON_WARNING | wxYES_NO | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER) != wxYES) { + if (wxMessageBox(_("You are about to revert all your changes\nAre you sure?"), + "CodeLite", + wxICON_WARNING | wxYES_NO | wxCANCEL | wxCANCEL_DEFAULT | wxCENTER) != wxYES) { return; } wxString command; - if(m_selectedFile.FileExists()) { + if (m_selectedFile.FileExists()) { // Revert was called on a file, revert only the file command << GetSvnExeName() << " revert --recursive " << m_selectedFile.GetFullName(); } else { @@ -524,7 +615,7 @@ void Subversion2::OnUpdate(wxCommandEvent& event) // Coming from explorer view wxString command; wxString loginString; - if(LoginIfNeeded(event, m_selectedFolder, loginString) == false) { + if (LoginIfNeeded(event, m_selectedFolder, loginString) == false) { return; } // svn update . @@ -539,28 +630,31 @@ void Subversion2::OnUpdate(wxCommandEvent& event) void Subversion2::OnFileExplorerDiff(wxCommandEvent& event) { wxString diffAgainst("BASE"); - diffAgainst = clGetTextFromUser(_("Svn Diff"), _("Insert base revision to diff against:"), "BASE", wxNOT_FOUND, + diffAgainst = clGetTextFromUser(_("Svn Diff"), + _("Insert base revision to diff against:"), + "BASE", + wxNOT_FOUND, GetManager()->GetTheApp()->GetTopWindow()); - if(diffAgainst.empty()) { + if (diffAgainst.empty()) { return; } wxString command; wxString loginString; - if(LoginIfNeeded(event, m_selectedFolder, loginString) == false) { + if (LoginIfNeeded(event, m_selectedFolder, loginString) == false) { return; } command << GetSvnExeNameNoConfigDir() << loginString; SvnSettingsData ssd = GetSettings(); - if(ssd.GetFlags() & SvnUseExternalDiff) { + if (ssd.GetFlags() & SvnUseExternalDiff) { command << " --diff-cmd=\"" << ssd.GetExternalDiffViewer() << "\" "; } wxFileName workingDirectory(m_selectedFolder, ""); command << "diff -r" << diffAgainst; - if(m_selectedFile.IsOk()) { + if (m_selectedFile.IsOk()) { command << " " << m_selectedFile.GetFullName(); } else { command << " ."; @@ -594,7 +688,7 @@ wxArrayString Subversion2::DoGetFileExplorerFiles() wxString Subversion2::DoGetFileExplorerItemPath() { TreeItemInfo item = m_mgr->GetSelectedTreeItemInfo(TreeFileExplorer); - if(!item.m_paths.IsEmpty()) { + if (!item.m_paths.IsEmpty()) { return item.m_paths.Item(0); } else { return wxEmptyString; @@ -604,7 +698,7 @@ wxString Subversion2::DoGetFileExplorerItemPath() wxString Subversion2::GetUserConfigDir() { wxString configDir(clStandardPaths::Get().GetUserDataDir()); - if(wxFileName::DirExists(configDir) == false) { + if (wxFileName::DirExists(configDir) == false) { wxMkdir(configDir); } @@ -626,7 +720,7 @@ void Subversion2::RecreateLocalSvnConfigFile() ignorePatterns.Replace("\v", " "); wxString diffTool = GetSettings().GetExternalDiffViewer(); - if(!(GetSettings().GetFlags() & SvnUseExternalDiff)) { + if (!(GetSettings().GetFlags() & SvnUseExternalDiff)) { diffTool.Empty(); } @@ -646,7 +740,7 @@ void Subversion2::DoGetSvnVersion() void Subversion2::Patch(bool dryRun, const wxString& workingDirectory, wxEvtHandler* owner, int id) { PatchDlg dlg(GetManager()->GetTheApp()->GetTopWindow()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxBusyCursor cursor; wxString patchFile; @@ -654,11 +748,11 @@ void Subversion2::Patch(bool dryRun, const wxString& workingDirectory, wxEvtHand int eolPolicy = dlg.GetRadioBoxPolicy()->GetSelection(); bool removeFileWhenDone = false; - if(eolPolicy != 0) { + if (eolPolicy != 0) { // Read the file wxString fileContent; - if(ReadFileWithConversion(patchFile, fileContent)) { - switch(eolPolicy) { + if (ReadFileWithConversion(patchFile, fileContent)) { + switch (eolPolicy) { case 1: // Windows EOL ConvertToWindowsEOL(fileContent); break; @@ -670,8 +764,8 @@ void Subversion2::Patch(bool dryRun, const wxString& workingDirectory, wxEvtHand // Write the content to a new file wxFFile fileTemp; wxString tmpFile = wxFileName::CreateTempFileName("clsvn", &fileTemp); - if(fileTemp.IsOpened()) { - if(fileTemp.Write(fileContent)) { + if (fileTemp.IsOpened()) { + if (fileTemp.Write(fileContent)) { fileTemp.Close(); removeFileWhenDone = true; patchFile = tmpFile; @@ -680,18 +774,18 @@ void Subversion2::Patch(bool dryRun, const wxString& workingDirectory, wxEvtHand } } - if(patchFile.IsEmpty() == false) { + if (patchFile.IsEmpty() == false) { // execute the command wxString command; command << "patch -l -p0 "; - if(dryRun) { + if (dryRun) { command << " --dry-run "; } command << " -i \"" << patchFile << "\""; SvnCommandHandler* handler(NULL); - if(dryRun) { + if (dryRun) { handler = new SvnPatchDryRunHandler(this, id, owner, removeFileWhenDone, patchFile); } else { handler = new SvnPatchHandler(this, id, owner, removeFileWhenDone, patchFile); @@ -712,7 +806,7 @@ bool Subversion2::LoginIfNeeded(wxCommandEvent& event, const wxString& workingDi SvnInfo svnInfo; wxString repoUrl; - if(event.GetInt() == LOGIN_REQUIRES_URL) { + if (event.GetInt() == LOGIN_REQUIRES_URL) { repoUrl = event.GetString(); } else { @@ -725,22 +819,22 @@ bool Subversion2::LoginIfNeeded(wxCommandEvent& event, const wxString& workingDi SubversionPasswordDb db; wxString user, password; - if(loginFailed) { + if (loginFailed) { // if we got here, it means that we already tried to login with either user prompt / using the stored password // to prevent an endless loop, remove the old entry from the password db db.DeleteLogin(repoUrl); } - if(db.GetLogin(repoUrl, user, password)) { + if (db.GetLogin(repoUrl, user, password)) { loginString << " --username " << user << " --password \"" << password << "\" "; return true; } // Use the root URL as the key for the login here loginString.Empty(); - if(loginFailed) { + if (loginFailed) { SvnLoginDialog dlg(GetManager()->GetTheApp()->GetTopWindow()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { loginString << " --username " << dlg.GetUsername() << " --password \"" << dlg.GetPassword() << "\" "; // Store the user name and password db.SetLogin(repoUrl, dlg.GetUsername(), dlg.GetPassword()); @@ -757,22 +851,22 @@ void Subversion2::IgnoreFiles(const wxArrayString& files, bool pattern) SvnSettingsData ssd = GetSettings(); wxArrayString ignorePatternArr = wxStringTokenize(ssd.GetIgnoreFilePattern(), " \r\n\t\v", wxTOKEN_STRTOK); - for(size_t i = 0; i < files.GetCount(); i++) { + for (size_t i = 0; i < files.GetCount(); i++) { wxString entry; wxFileName fn(files.Item(i)); - if(pattern) { + if (pattern) { entry << "*." << fn.GetExt(); } else { entry << fn.GetFullName(); } - if(ignorePatternArr.Index(entry) == wxNOT_FOUND) { + if (ignorePatternArr.Index(entry) == wxNOT_FOUND) { ignorePatternArr.Add(entry); } } wxString ignorePatternStr; - for(size_t i = 0; i < ignorePatternArr.GetCount(); i++) { + for (size_t i = 0; i < ignorePatternArr.GetCount(); i++) { ignorePatternStr << ignorePatternArr.Item(i) << " "; } ignorePatternStr.RemoveLast(); @@ -795,7 +889,7 @@ void Subversion2::OnIgnoreFilePattern(wxCommandEvent& event) { IgnoreFiles(DoGet void Subversion2::EditSettings() { SvnPreferencesDialog dlg(GetManager()->GetTheApp()->GetTopWindow(), this); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { // Update the Subversion view GetSvnView()->BuildTree(); DoSetSSH(); @@ -824,41 +918,41 @@ void Subversion2::Blame(wxCommandEvent& event, const wxArrayString& files) wxString command; wxString loginString; - if(files.GetCount() == 0) { + if (files.GetCount() == 0) { return; } /*bool nonInteractive = unused var commented out*/ GetNonInteractiveMode(event); - if(LoginIfNeeded(event, files.Item(0), loginString) == false) { + if (LoginIfNeeded(event, files.Item(0), loginString) == false) { return; } - if(files.GetCount() != 1) { + if (files.GetCount() != 1) { return; } GetConsole()->EnsureVisible(); command << GetSvnExeName() << " blame " << loginString; - for(size_t i = 0; i < files.GetCount(); i++) { + for (size_t i = 0; i < files.GetCount(); i++) { command << "\"" << files.Item(i) << "\" "; } GetConsole()->AppendText(command + "\n"); - m_blameCommand.Execute(command, GetSvnView()->GetRootDir(), - new SvnBlameHandler(this, event.GetId(), this, files.Item(0)), this); + m_blameCommand.Execute( + command, GetSvnView()->GetRootDir(), new SvnBlameHandler(this, event.GetId(), this, files.Item(0)), this); } void Subversion2::OnGetCompileLine(clBuildEvent& event) { - if(!(GetSettings().GetFlags() & SvnExposeRevisionMacro)) { + if (!(GetSettings().GetFlags() & SvnExposeRevisionMacro)) { return; } wxString macroName(GetSettings().GetRevisionMacroName()); macroName.Trim().Trim(false); - if(macroName.IsEmpty()) { + if (macroName.IsEmpty()) { return; } @@ -882,7 +976,7 @@ void Subversion2::DoGetSvnInfoSync(SvnInfo& svnInfo, const wxString& workingDire wxString xmlStr; svnInfoCommand << GetSvnExeName() << " info --xml "; - if(workingDirectory.Find(" ")) { + if (workingDirectory.Find(" ")) { svnInfoCommand << "\"" << workingDirectory << "\""; } else { svnInfoCommand << workingDirectory; @@ -895,9 +989,9 @@ void Subversion2::DoGetSvnInfoSync(SvnInfo& svnInfo, const wxString& workingDire wxArrayString xmlArr; - IProcess::Ptr_t proc(::CreateSyncProcess(svnInfoCommand, IProcessCreateDefault | IProcessCreateWithHiddenConsole | - IProcessWrapInShell)); - if(proc) { + IProcess::Ptr_t proc(::CreateSyncProcess( + svnInfoCommand, IProcessCreateDefault | IProcessCreateWithHiddenConsole | IProcessWrapInShell)); + if (proc) { proc->WaitForTerminate(xmlStr); SvnXML::GetSvnInfo(xmlStr, svnInfo); } @@ -908,8 +1002,8 @@ bool Subversion2::IsPathUnderSvn(const wxString& path) wxFileName fn(path, ".svn"); // search until we find .svn folder - while(fn.GetDirCount()) { - if(wxFileName::DirExists(fn.GetFullPath())) { + while (fn.GetDirCount()) { + if (wxFileName::DirExists(fn.GetFullPath())) { return true; } fn.RemoveLastDir(); @@ -931,11 +1025,11 @@ void Subversion2::DoSwitchURL(const wxString& workingDirectory, const wxString& DoGetSvnInfoSync(svnInfo, workingDirectory); wxString loginString; - if(LoginIfNeeded(event, workingDirectory, loginString) == false) { + if (LoginIfNeeded(event, workingDirectory, loginString) == false) { return; } wxString targetUrl = wxGetTextFromUser(_("Enter new URL:"), _("Svn Switch..."), sourceUrl); - if(targetUrl.IsEmpty()) { + if (targetUrl.IsEmpty()) { return; } @@ -953,18 +1047,20 @@ void Subversion2::ChangeLog(const wxString& path, const wxString& fullpath, wxCo dlg.GetTo()->SetValue("BASE"); dlg.GetCompact()->SetValue(true); dlg.GetFrom()->SetFocus(); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxString command; wxString loginString; - if(LoginIfNeeded(event, path, loginString) == false) { + if (LoginIfNeeded(event, path, loginString) == false) { return; } command << GetSvnExeName() << loginString << " log -r" << dlg.GetFrom()->GetValue() << ":" << dlg.GetTo()->GetValue() << " \"" << fullpath << "\""; GetConsole()->Execute( - command, path, - new SvnLogHandler(this, info.m_sourceUrl, dlg.GetCompact()->IsChecked(), event.GetId(), this), false); + command, + path, + new SvnLogHandler(this, info.m_sourceUrl, dlg.GetCompact()->IsChecked(), event.GetId(), this), + false); } } @@ -978,28 +1074,30 @@ void Subversion2::OnUnLockFile(wxCommandEvent& event) DoLockFile(m_selectedFile.GetPath(), DoGetFileExplorerFiles(), event, false); } -void Subversion2::DoLockFile(const wxString& workingDirectory, const wxArrayString& fullpaths, wxCommandEvent& event, +void Subversion2::DoLockFile(const wxString& workingDirectory, + const wxArrayString& fullpaths, + wxCommandEvent& event, bool lock) { wxString command; wxString loginString; - if(fullpaths.empty()) { + if (fullpaths.empty()) { return; } - if(LoginIfNeeded(event, workingDirectory, loginString) == false) { + if (LoginIfNeeded(event, workingDirectory, loginString) == false) { return; } command << GetSvnExeName() << loginString; - if(lock) { + if (lock) { command << " lock "; } else { command << " unlock "; } - for(size_t i = 0; i < fullpaths.size(); i++) + for (size_t i = 0; i < fullpaths.size(); i++) command << "\"" << fullpaths.Item(i) << "\" "; GetConsole()->Execute(command, workingDirectory, new SvnDefaultCommandHandler(this, event.GetId(), this)); @@ -1014,7 +1112,7 @@ void Subversion2::OnWorkspaceConfigChanged(wxCommandEvent& event) void Subversion2::OnProjectFileRemoved(clCommandEvent& event) { event.Skip(); - if(m_skipRemoveFilesDlg) { + if (m_skipRemoveFilesDlg) { m_skipRemoveFilesDlg = false; return; } @@ -1024,19 +1122,19 @@ void Subversion2::OnProjectFileRemoved(clCommandEvent& event) void Subversion2::OnFileExplorerRenameItem(wxCommandEvent& event) { wxFileName workingDirectory(m_selectedFolder, ""); - if(!m_selectedFile.IsOk()) { + if (!m_selectedFile.IsOk()) { wxString folderName = workingDirectory.GetDirs().Last(); workingDirectory.RemoveLastDir(); wxString newname = ::clGetTextFromUser(_("Svn Rename"), _("New name:"), folderName, folderName.length()); - if(newname.IsEmpty() || newname == folderName) { + if (newname.IsEmpty() || newname == folderName) { return; } StringUtils::WrapWithQuotes(newname); DoRename(workingDirectory.GetPath(), folderName, newname, event); } else { - wxString newname = ::clGetTextFromUser(_("Svn Rename"), _("New name:"), m_selectedFile.GetFullName(), - m_selectedFile.GetName().length()); - if(newname.IsEmpty() || newname == m_selectedFile.GetFullName()) { + wxString newname = ::clGetTextFromUser( + _("Svn Rename"), _("New name:"), m_selectedFile.GetFullName(), m_selectedFile.GetName().length()); + if (newname.IsEmpty() || newname == m_selectedFile.GetFullName()) { return; } StringUtils::WrapWithQuotes(newname); @@ -1044,17 +1142,19 @@ void Subversion2::OnFileExplorerRenameItem(wxCommandEvent& event) } } -void Subversion2::DoRename(const wxString& workingDirectory, const wxString& oldname, const wxString& newname, +void Subversion2::DoRename(const wxString& workingDirectory, + const wxString& oldname, + const wxString& newname, wxCommandEvent& event) { wxString command; wxString loginString; - if(LoginIfNeeded(event, workingDirectory, loginString) == false) { + if (LoginIfNeeded(event, workingDirectory, loginString) == false) { return; } - if(oldname.IsEmpty() || newname.IsEmpty() || workingDirectory.IsEmpty()) { + if (oldname.IsEmpty() || newname.IsEmpty() || workingDirectory.IsEmpty()) { return; } @@ -1068,29 +1168,29 @@ void Subversion2::DoCommit(const wxArrayString& files, const wxString& workingDi { wxString command; wxString loginString; - if(LoginIfNeeded(event, workingDirectory, loginString) == false) { + if (LoginIfNeeded(event, workingDirectory, loginString) == false) { return; } SvnInfo svnInfo; - if(!workingDirectory.IsEmpty()) { + if (!workingDirectory.IsEmpty()) { DoGetSvnInfoSync(svnInfo, workingDirectory); } command << GetSvnExeName() << loginString << " commit "; SvnCommitDialog dlg(EventNotifier::Get()->TopFrame(), files, svnInfo.m_sourceUrl, this, workingDirectory); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxArrayString actualFiles = dlg.GetPaths(); - if(actualFiles.IsEmpty()) { + if (actualFiles.IsEmpty()) { return; } // Store the commit message into a temporary file wxFileName tmpFile(clStandardPaths::Get().GetTempDir(), ".svn-commit"); - if(!FileUtils::WriteFileContent(tmpFile, dlg.GetMesasge())) { - ::wxMessageBox(_("Fail to write commit message to a temporary file!"), "CodeLite", - wxOK | wxCENTER | wxICON_ERROR); + if (!FileUtils::WriteFileContent(tmpFile, dlg.GetMesasge())) { + ::wxMessageBox( + _("Fail to write commit message to a temporary file!"), "CodeLite", wxOK | wxCENTER | wxICON_ERROR); return; } @@ -1099,7 +1199,7 @@ void Subversion2::DoCommit(const wxArrayString& files, const wxString& workingDi command << " --file " << filepath << " "; // Add the changed files - for(size_t i = 0; i < actualFiles.GetCount(); ++i) { + for (size_t i = 0; i < actualFiles.GetCount(); ++i) { StringUtils::WrapWithQuotes(actualFiles.Item(i)); command << actualFiles.Item(i) << " "; } @@ -1119,13 +1219,13 @@ wxArrayString Subversion2::DoGetSvnStatusQuiet(const wxString& wd) ProcUtils::ExecuteCommand(command, lines); - for(size_t i = 0; i < lines.GetCount(); i++) { + for (size_t i = 0; i < lines.GetCount(); i++) { output << "\r\n" << lines.Item(i); } wxArrayString modFiles, conflictedFiles, unversionedFiles, newFiles, deletedFiles, lockedFiles, ignoredFiles; - SvnXML::GetFiles(output, modFiles, conflictedFiles, unversionedFiles, newFiles, deletedFiles, lockedFiles, - ignoredFiles); + SvnXML::GetFiles( + output, modFiles, conflictedFiles, unversionedFiles, newFiles, deletedFiles, lockedFiles, ignoredFiles); modFiles.insert(modFiles.end(), newFiles.begin(), newFiles.end()); modFiles.insert(modFiles.end(), deletedFiles.begin(), deletedFiles.end()); @@ -1135,7 +1235,7 @@ wxArrayString Subversion2::DoGetSvnStatusQuiet(const wxString& wd) bool Subversion2::NormalizeDir(wxString& wd) { - if(!wxFileName::DirExists(wd)) { + if (!wxFileName::DirExists(wd)) { return false; } @@ -1143,7 +1243,7 @@ bool Subversion2::NormalizeDir(wxString& wd) wxFileName fn(wd); fn.Normalize(); // wxPATH_NORM_CASE seems broken wd = fn.GetFullPath(); - if(wxPATH_DOS == wxFileName::GetFormat()) { + if (wxPATH_DOS == wxFileName::GetFormat()) { wd.LowerCase(); // Subversion *always* capitalizes Windows/Dos volume letters @@ -1152,7 +1252,7 @@ bool Subversion2::NormalizeDir(wxString& wd) wd.SetChar(0, volume); } // get rid of possible trailing slash/backslash - if(wd.Last() == wxFileName::GetPathSeparator()) { + if (wd.Last() == wxFileName::GetPathSeparator()) { wd.RemoveLast(); } return true; @@ -1171,13 +1271,13 @@ std::vector Subversion2::GetLocalAddsDels(const wxString& wd) ProcUtils::ExecuteCommand(command, lines); wxString fileName; - for(size_t i1 = 0; i1 < lines.GetCount(); i1++) { + for (size_t i1 = 0; i1 < lines.GetCount(); i1++) { wxChar stat = lines.Item(i1).GetChar(0); - if('A' == stat || 'D' == stat) { + if ('A' == stat || 'D' == stat) { fileName = lines.Item(i1).Mid(8); - if(!wxFileName::DirExists(fileName)) { + if (!wxFileName::DirExists(fileName)) { aryFiles.push_back(fileName); } } @@ -1199,9 +1299,9 @@ std::vector Subversion2::GetFilesMarkedBinary(const wxString& wd) ProcUtils::ExecuteCommand(command, lines); wxString fileName; - for(size_t i1 = 0; i1 < lines.GetCount(); i1++) { + for (size_t i1 = 0; i1 < lines.GetCount(); i1++) { lines.Item(i1).Trim(); // gets rid of \r\n, \n, etc. - if(lines.Item(i1).EndsWith(_(" - application/octet-stream"), &fileName)) { + if (lines.Item(i1).EndsWith(_(" - application/octet-stream"), &fileName)) { aryFiles.push_back(fileName); } } @@ -1216,10 +1316,10 @@ std::vector Subversion2::RemoveExcludeExts(const std::vector wxStringTokenizer tok(excludeExtensions, " ;"); std::set specMap; - while(tok.HasMoreTokens()) { + while (tok.HasMoreTokens()) { wxString v = tok.GetNextToken(); - if(v == "*.*") { + if (v == "*.*") { // Just ignore the request to not add any files continue; } @@ -1228,14 +1328,14 @@ std::vector Subversion2::RemoveExcludeExts(const std::vector specMap.insert(v); } - for(size_t i1 = 0; i1 < aryInFiles.size(); i1++) { - if(specMap.empty()) { + for (size_t i1 = 0; i1 < aryInFiles.size(); i1++) { + if (specMap.empty()) { aryOutFiles.push_back(aryInFiles[i1]); continue; } wxFileName fn(aryInFiles[i1]); - if(specMap.find(fn.GetExt().MakeLower()) == specMap.end()) { + if (specMap.find(fn.GetExt().MakeLower()) == specMap.end()) { aryOutFiles.push_back(aryInFiles[i1]); } } @@ -1245,12 +1345,12 @@ std::vector Subversion2::RemoveExcludeExts(const std::vector void Subversion2::OnSync(wxCommandEvent& event) { - if(!m_mgr->GetWorkspace() || !m_mgr->IsWorkspaceOpen()) { + if (!m_mgr->GetWorkspace() || !m_mgr->IsWorkspaceOpen()) { return; } TreeItemInfo item = m_mgr->GetSelectedTreeItemInfo(TreeFileView); - if(item.m_itemType != ProjectItem::TypeProject) { + if (item.m_itemType != ProjectItem::TypeProject) { return; // a project must be selected } @@ -1259,7 +1359,7 @@ void Subversion2::OnSync(wxCommandEvent& event) wxString err_msg; ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(project_name, err_msg); - if(!proj) { + if (!proj) { return; } @@ -1269,22 +1369,22 @@ void Subversion2::OnSync(wxCommandEvent& event) bool excludeBinary = true; wxString rootDir; wxString excludeExtensions; - if(options.GetCount() >= 1) { - if(options.Item(0) == _("false")) { + if (options.GetCount() >= 1) { + if (options.Item(0) == _("false")) { excludeBinary = false; } } - if(options.GetCount() >= 2) { + if (options.GetCount() >= 2) { rootDir = options.Item(1); } - if(options.GetCount() >= 3) { + if (options.GetCount() >= 3) { excludeExtensions = options.Item(2); } else { excludeExtensions << "*.dll *.so *.o *.obj *.workspace *.project *.exe *.dylib"; } SvnSyncDialog dlg(GetManager()->GetTheApp()->GetTopWindow(), this, rootDir, excludeBinary, excludeExtensions); - if(dlg.ShowModal() != wxID_OK) { + if (dlg.ShowModal() != wxID_OK) { return; } excludeExtensions = dlg.GetExcludeExtensions(); @@ -1303,12 +1403,16 @@ void Subversion2::OnSync(wxCommandEvent& event) // Calls FinishSyncProcess() // Get password/authentication, if required GetConsole()->Execute( - command, workDir, + command, + workDir, new SvnRepoListHandler(this, proj, workDir, excludeBinary, excludeExtensions, wxNOT_FOUND, NULL)); } -void Subversion2::FinishSyncProcess(ProjectPtr& proj, const wxString& workDir, bool excludeBin, - const wxString& excludeExtensions, const wxString& output) +void Subversion2::FinishSyncProcess(ProjectPtr& proj, + const wxString& workDir, + bool excludeBin, + const wxString& excludeExtensions, + const wxString& output) { // Convert output of "svn list" into a list of files // Note that svn list always uses '/' as path delimiter @@ -1316,8 +1420,8 @@ void Subversion2::FinishSyncProcess(ProjectPtr& proj, const wxString& workDir, b { wxArrayString repoListOutput = wxStringTokenize(output, "\r\n"); wxFileName fn; - for(size_t i1 = 0; i1 < repoListOutput.GetCount(); i1++) { - if(repoListOutput.Item(i1).Last() != '/') { + for (size_t i1 = 0; i1 < repoListOutput.GetCount(); i1++) { + if (repoListOutput.Item(i1).Last() != '/') { fn.Assign(workDir + wxFileName::GetPathSeparator() + repoListOutput.Item(i1)); aryRepoList.push_back(fn.GetFullPath()); } @@ -1326,11 +1430,14 @@ void Subversion2::FinishSyncProcess(ProjectPtr& proj, const wxString& workDir, b std::sort(aryRepoList.begin(), aryRepoList.end()); std::vector aryNoBins; - if(excludeBin) { + if (excludeBin) { std::vector aryBinaries = GetFilesMarkedBinary(workDir); std::sort(aryBinaries.begin(), aryBinaries.end()); - std::set_symmetric_difference(aryRepoList.begin(), aryRepoList.end(), aryBinaries.begin(), aryBinaries.end(), + std::set_symmetric_difference(aryRepoList.begin(), + aryRepoList.end(), + aryBinaries.begin(), + aryBinaries.end(), std::back_inserter(aryNoBins)); } std::vector& aryMaybeNoBins = excludeBin ? aryNoBins : aryRepoList; @@ -1341,8 +1448,11 @@ void Subversion2::FinishSyncProcess(ProjectPtr& proj, const wxString& workDir, b std::vector aryAddsDels = GetLocalAddsDels(workDir); std::sort(aryAddsDels.begin(), aryAddsDels.end()); - std::set_symmetric_difference(aryMaybeNoBins.begin(), aryMaybeNoBins.end(), aryAddsDels.begin(), - aryAddsDels.end(), std::back_inserter(aryUnfiltered)); + std::set_symmetric_difference(aryMaybeNoBins.begin(), + aryMaybeNoBins.end(), + aryAddsDels.begin(), + aryAddsDels.end(), + std::back_inserter(aryUnfiltered)); } std::vector aryFinal = RemoveExcludeExts(aryUnfiltered, excludeExtensions); @@ -1353,10 +1463,10 @@ void Subversion2::FinishSyncProcess(ProjectPtr& proj, const wxString& workDir, b wxString err_msg; ProjectPtr projRefreshed = m_mgr->GetWorkspace()->FindProjectByName(proj->GetName(), err_msg); - if(projRefreshed) { + if (projRefreshed) { wxChar delim = '\n'; wxString excludeBinTF; - if(excludeBin) { + if (excludeBin) { excludeBinTF = _("true"); } else { excludeBinTF = _("false"); @@ -1382,31 +1492,31 @@ void Subversion2::OnRevertToRevision(wxCommandEvent& event) wxString loginString; wxString revision = wxGetTextFromUser(_("Set the revision number:"), _("Revert to revision")); - if(revision.IsEmpty()) { + if (revision.IsEmpty()) { // user canceled return; } long nRevision; - if(!revision.ToCLong(&nRevision)) { + if (!revision.ToCLong(&nRevision)) { ::wxMessageBox(_("Invalid revision number"), "codelite", wxOK | wxICON_ERROR | wxCENTER); return; } wxFileName workingDirectory(m_selectedFolder, ""); - if(m_selectedFile.IsOk()) { + if (m_selectedFile.IsOk()) { command << GetSvnExeName() << loginString << " merge -r HEAD:" << nRevision << " " << m_selectedFile.GetFullName(); - GetConsole()->Execute(command, workingDirectory.GetPath(), - new SvnDefaultCommandHandler(this, event.GetId(), this)); + GetConsole()->Execute( + command, workingDirectory.GetPath(), new SvnDefaultCommandHandler(this, event.GetId(), this)); } else { wxString folderName = workingDirectory.GetDirs().Last(); workingDirectory.RemoveLastDir(); StringUtils::WrapWithQuotes(folderName); command << GetSvnExeName() << loginString << " merge -r HEAD:" << nRevision << " " << folderName; - GetConsole()->Execute(command, workingDirectory.GetPath(), - new SvnDefaultCommandHandler(this, event.GetId(), this)); + GetConsole()->Execute( + command, workingDirectory.GetPath(), new SvnDefaultCommandHandler(this, event.GetId(), this)); } } @@ -1422,12 +1532,12 @@ void Subversion2::DoGetSvnClientVersion() #endif wxString versionOutput = ProcUtils::SafeExecuteCommand(svnVersionCommand); - if(versionOutput.IsEmpty()) { + if (versionOutput.IsEmpty()) { return; } versionOutput = versionOutput.BeforeFirst('\n'); - if(reSvnClient.IsValid() && reSvnClient.Matches(versionOutput)) { + if (reSvnClient.IsValid() && reSvnClient.Matches(versionOutput)) { long major, minor, patch; wxString sMajor = reSvnClient.GetMatch(versionOutput, 1); wxString sMinor = reSvnClient.GetMatch(versionOutput, 2); @@ -1446,9 +1556,9 @@ void Subversion2::DoGetSvnClientVersion() void Subversion2::AddCommandLineOption(wxString& command, Subversion2::eCommandLineOption opt) { - switch(opt) { + switch (opt) { case kOpt_ForceInteractive: - if(m_clientVersion >= 1800) { + if (m_clientVersion >= 1800) { command << " --force-interactive "; } break; @@ -1469,7 +1579,7 @@ void Subversion2::OnFolderContextMenu(clContextMenuEvent& event) void Subversion2::OnFileContextMenu(clContextMenuEvent& event) { event.Skip(); - if(event.GetStrings().size() == 1) { + if (event.GetStrings().size() == 1) { m_selectedFile = event.GetStrings().Item(0); m_selectedFolder = wxFileName(m_selectedFile).GetPath(); @@ -1482,25 +1592,25 @@ void Subversion2::OnFileContextMenu(clContextMenuEvent& event) void Subversion2::DoFilesDeleted(const wxArrayString& files, bool isFolder) { - if(!files.IsEmpty()) { + if (!files.IsEmpty()) { // test the first file, see if it is under SVN wxFileName fn = isFolder ? wxFileName(files.Item(0), "") : wxFileName(files.Item(0)); - if(IsPathUnderSvn(fn.GetPath())) { + if (IsPathUnderSvn(fn.GetPath())) { // Build the message: // Limit the message to maximum of 10 files wxString filesString; wxString msg; - if(isFolder) { + if (isFolder) { msg << _("Would you like to remove the following folders from SVN?\n\n"); } else { msg << _("Would you like to remove the following files from SVN?\n\n"); } size_t fileCount = files.GetCount(); - for(size_t i = 0; i < files.GetCount(); i++) { - if(i < 10) { + for (size_t i = 0; i < files.GetCount(); i++) { + if (i < 10) { msg << files.Item(i) << "\n"; filesString << "\"" << files.Item(i) << "\" "; --fileCount; @@ -1509,22 +1619,24 @@ void Subversion2::DoFilesDeleted(const wxArrayString& files, bool isFolder) } } - if(fileCount) { - if(isFolder) { + if (fileCount) { + if (isFolder) { msg << _(".. and ") << fileCount << _(" more folders"); } else { msg << _(".. and ") << fileCount << _(" more files"); } } - if(wxMessageBox(msg, "Subversion", wxYES_NO | wxCANCEL | wxCENTER | wxNO_DEFAULT, - GetManager()->GetTheApp()->GetTopWindow()) == wxYES) { + if (wxMessageBox(msg, + "Subversion", + wxYES_NO | wxCANCEL | wxCENTER | wxNO_DEFAULT, + GetManager()->GetTheApp()->GetTopWindow()) == wxYES) { wxString command; RecreateLocalSvnConfigFile(); command << GetSvnExeName() << " delete --force " << filesString; - GetConsole()->Execute(command, m_subversionView->GetRootDir(), - new SvnDefaultCommandHandler(this, wxNOT_FOUND, this)); + GetConsole()->Execute( + command, m_subversionView->GetRootDir(), new SvnDefaultCommandHandler(this, wxNOT_FOUND, this)); } } } @@ -1550,27 +1662,27 @@ void Subversion2::OnShowFileChanges(wxCommandEvent& event) void Subversion2::ShowRecentChanges(const wxString& file) { - if(!wxFileName::FileExists(file)) { + if (!wxFileName::FileExists(file)) { return; } wxString filename(file); StringUtils::WrapWithQuotes(filename); - long numberOfChanges = wxGetNumberFromUser(_("How many recent changes you want to view?"), "", - _("Svn show recent changes"), 1, 1, 100); - if(numberOfChanges == wxNOT_FOUND) { + long numberOfChanges = wxGetNumberFromUser( + _("How many recent changes you want to view?"), "", _("Svn show recent changes"), 1, 1, 100); + if (numberOfChanges == wxNOT_FOUND) { return; // cancel } // Build the command wxString command; command << GetSvnExeNameNoConfigDir() << " log --diff -l " << numberOfChanges << " " << filename; - GetConsole()->Execute(command, m_subversionView->GetRootDir(), - new SvnShowFileChangesHandler(this, wxNOT_FOUND, this)); + GetConsole()->Execute( + command, m_subversionView->GetRootDir(), new SvnShowFileChangesHandler(this, wxNOT_FOUND, this)); } void Subversion2::ShowRecentChangesDialog(const SvnShowDiffChunk::List_t& changes) { - if(changes.empty()) { + if (changes.empty()) { return; } SvnShowRecentChangesDlg dlg(EventNotifier::Get()->TopFrame(), changes); diff --git a/Subversion2/subversion_password_db.cpp b/Subversion2/subversion_password_db.cpp index 3e904fc869..3459b09624 100644 --- a/Subversion2/subversion_password_db.cpp +++ b/Subversion2/subversion_password_db.cpp @@ -54,14 +54,14 @@ SubversionPasswordDb::~SubversionPasswordDb() bool SubversionPasswordDb::GetLogin(const wxString& url, wxString& user, wxString& password) { wxString escapedUrl(wxMD5::GetDigest(url)); - if(m_fileConfig->HasGroup(escapedUrl) == false) + if (m_fileConfig->HasGroup(escapedUrl) == false) return false; - + // read and decrypt the password/username m_fileConfig->Read(escapedUrl + wxT("/user"), &user); XORString userXor(user); user = userXor.Decrypt(); - + m_fileConfig->Read(escapedUrl + wxT("/password"), &password); XORString passXor(password); password = passXor.Decrypt(); @@ -71,7 +71,7 @@ bool SubversionPasswordDb::GetLogin(const wxString& url, wxString& user, wxStrin void SubversionPasswordDb::SetLogin(const wxString& url, const wxString& user, const wxString& password) { wxString escapedUrl(wxMD5::GetDigest(url)); - if(m_fileConfig->HasGroup(escapedUrl)) { + if (m_fileConfig->HasGroup(escapedUrl)) { m_fileConfig->DeleteGroup(escapedUrl); } @@ -83,7 +83,7 @@ void SubversionPasswordDb::SetLogin(const wxString& url, const wxString& user, c void SubversionPasswordDb::DeleteLogin(const wxString& url) { wxString escapedUrl(wxMD5::GetDigest(url)); - if(m_fileConfig->HasGroup(escapedUrl)) { + if (m_fileConfig->HasGroup(escapedUrl)) { m_fileConfig->DeleteGroup(escapedUrl); } m_fileConfig->Flush(); diff --git a/Subversion2/subversion_password_db.h b/Subversion2/subversion_password_db.h index 3ee1686651..140cf8800b 100644 --- a/Subversion2/subversion_password_db.h +++ b/Subversion2/subversion_password_db.h @@ -28,33 +28,35 @@ #include -class SubversionPasswordDb { - wxFileConfig *m_fileConfig; +class SubversionPasswordDb +{ + wxFileConfig* m_fileConfig; + public: - SubversionPasswordDb(); - virtual ~SubversionPasswordDb(); - - /** - * @brief find login details for given URL - * @param url repository URL - * @param user [output] - * @param password [output] - * @return true if the URL is found in the database, false otherwise - */ - bool GetLogin(const wxString &url, wxString &user, wxString &password); - /** - * @brief store login info for given url - * @param url url as key - * @param user user name - * @param password password - */ - void SetLogin(const wxString &url, const wxString &user, const wxString &password); - - /** - * @brief delete login details for the given URL - * @param url - */ - void DeleteLogin(const wxString &url); + SubversionPasswordDb(); + virtual ~SubversionPasswordDb(); + + /** + * @brief find login details for given URL + * @param url repository URL + * @param user [output] + * @param password [output] + * @return true if the URL is found in the database, false otherwise + */ + bool GetLogin(const wxString& url, wxString& user, wxString& password); + /** + * @brief store login info for given url + * @param url url as key + * @param user user name + * @param password password + */ + void SetLogin(const wxString& url, const wxString& user, const wxString& password); + + /** + * @brief delete login details for the given URL + * @param url + */ + void DeleteLogin(const wxString& url); }; #endif // SUBVERSIONPASSWORDDB_H diff --git a/Subversion2/subversion_strings.h b/Subversion2/subversion_strings.h index f91a8512f6..4de38f1350 100644 --- a/Subversion2/subversion_strings.h +++ b/Subversion2/subversion_strings.h @@ -26,13 +26,14 @@ #ifndef SVNSTRINGS_H #define SVNSTRINGS_H -const wxString svnNO_FILES_TO_DISPLAY = _("No Files to Display"); -const wxString svnMODIFIED_FILES = _("Modified Files"); -const wxString svnADDED_FILES = _("Added Files"); -const wxString svnDELETED_FILES = _("Deleted Files"); -const wxString svnCONFLICTED_FILES = _("Conflicted Files"); -const wxString svnLOCKED_FILES = _("Locked Files"); -const wxString svnUNVERSIONED_FILES = _("Unversioned Files"); -const wxString svnCONSOLE_TEXT = _("Svn"); -const wxString svnANOTHER_PROCESS_RUNNING = _("\nMESSAGE: Another process is already running.\nMESSAGE: Ignoring last command.\n"); +const wxString svnNO_FILES_TO_DISPLAY = _("No Files to Display"); +const wxString svnMODIFIED_FILES = _("Modified Files"); +const wxString svnADDED_FILES = _("Added Files"); +const wxString svnDELETED_FILES = _("Deleted Files"); +const wxString svnCONFLICTED_FILES = _("Conflicted Files"); +const wxString svnLOCKED_FILES = _("Locked Files"); +const wxString svnUNVERSIONED_FILES = _("Unversioned Files"); +const wxString svnCONSOLE_TEXT = _("Svn"); +const wxString svnANOTHER_PROCESS_RUNNING = + _("\nMESSAGE: Another process is already running.\nMESSAGE: Ignoring last command.\n"); #endif // SVNSTRINGS_H diff --git a/Subversion2/subversion_view.h b/Subversion2/subversion_view.h index 93aa4f5a0b..151494c98f 100644 --- a/Subversion2/subversion_view.h +++ b/Subversion2/subversion_view.h @@ -172,10 +172,15 @@ class SubversionView : public SubversionPageBase SvnConsole* GetSubversionConsole() { return m_subversionConsole; } void DisconnectEvents(); - void UpdateTree(const wxArrayString& modifiedFiles, const wxArrayString& conflictedFiles, - const wxArrayString& unversionedFiles, const wxArrayString& newFiles, - const wxArrayString& deletedFiles, const wxArrayString& lockedFiles, - const wxArrayString& ignoreFiles, bool fileExplorerOnly, const wxString& rootDir); + void UpdateTree(const wxArrayString& modifiedFiles, + const wxArrayString& conflictedFiles, + const wxArrayString& unversionedFiles, + const wxArrayString& newFiles, + const wxArrayString& deletedFiles, + const wxArrayString& lockedFiles, + const wxArrayString& ignoreFiles, + bool fileExplorerOnly, + const wxString& rootDir); void BuildTree(); void BuildTree(const wxString& root); diff --git a/Subversion2/svn_checkout_dialog.cpp b/Subversion2/svn_checkout_dialog.cpp index ebaaf670fe..f6eb0ca1a2 100644 --- a/Subversion2/svn_checkout_dialog.cpp +++ b/Subversion2/svn_checkout_dialog.cpp @@ -51,7 +51,7 @@ SvnCheckoutDialog::~SvnCheckoutDialog() urls = ssd.GetUrls(); selection.Trim().Trim(false); - if(urls.Index(selection) == wxNOT_FOUND && selection.IsEmpty() == false) { + if (urls.Index(selection) == wxNOT_FOUND && selection.IsEmpty() == false) { urls.Add(selection); } ssd.SetUrls(urls); @@ -62,7 +62,7 @@ void SvnCheckoutDialog::OnBrowseDirectory(wxCommandEvent& event) { wxUnusedVar(event); wxString new_path = wxDirSelector(wxT(""), wxT(""), wxDD_DEFAULT_STYLE, wxDefaultPosition, this); - if(new_path.IsEmpty() == false) { + if (new_path.IsEmpty() == false) { m_textCtrl20->SetValue(new_path); } } @@ -80,11 +80,11 @@ void SvnCheckoutDialog::OnOK(wxCommandEvent& event) { // Check the target directory wxString targetDir = GetTargetDir(); - if(wxFileName::DirExists(targetDir)) { - if(wxMessageBox(wxString::Format(_("The checkout directory '%s' already exists\ncontinue with the checkout?"), - targetDir.c_str()), - _("Confirm"), - wxYES_NO | wxICON_WARNING) == wxNO) { + if (wxFileName::DirExists(targetDir)) { + if (wxMessageBox(wxString::Format(_("The checkout directory '%s' already exists\ncontinue with the checkout?"), + targetDir.c_str()), + _("Confirm"), + wxYES_NO | wxICON_WARNING) == wxNO) { return; } } diff --git a/Subversion2/svn_checkout_dialog.h b/Subversion2/svn_checkout_dialog.h index c6a23e7be5..d950b3920f 100644 --- a/Subversion2/svn_checkout_dialog.h +++ b/Subversion2/svn_checkout_dialog.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2009 by Eran Ifrah -// file name : svn_checkout_dialog.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2009 by Eran Ifrah +// file name : svn_checkout_dialog.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #ifndef __svn_checkout_dialog__ #define __svn_checkout_dialog__ @@ -37,21 +37,22 @@ class Subversion2; /** Implementing SvnCheckoutDialogBase */ class SvnCheckoutDialog : public SvnCheckoutDialogBase { - Subversion2 *m_plugin; + Subversion2* m_plugin; + protected: - // Handlers for SvnCheckoutDialogBase events. - void OnBrowseDirectory ( wxCommandEvent &event ); - void OnOkUI ( wxUpdateUIEvent &event ); + // Handlers for SvnCheckoutDialogBase events. + void OnBrowseDirectory(wxCommandEvent& event); + void OnOkUI(wxUpdateUIEvent& event); - virtual void OnOK( wxCommandEvent& event ); + virtual void OnOK(wxCommandEvent& event); public: - /** Constructor */ - SvnCheckoutDialog( wxWindow* parent, Subversion2 *plugin ); - virtual ~SvnCheckoutDialog(); + /** Constructor */ + SvnCheckoutDialog(wxWindow* parent, Subversion2* plugin); + virtual ~SvnCheckoutDialog(); - wxString GetURL(); - wxString GetTargetDir(); + wxString GetURL(); + wxString GetTargetDir(); }; #endif // __svn_checkout_dialog__ diff --git a/Subversion2/svn_command_handlers.cpp b/Subversion2/svn_command_handlers.cpp index 7359b4cc0d..9360113d71 100644 --- a/Subversion2/svn_command_handlers.cpp +++ b/Subversion2/svn_command_handlers.cpp @@ -23,6 +23,8 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// +#include "svn_command_handlers.h" + #include "SvnBlameFrame.h" #include "changelogpage.h" #include "event_notifier.h" @@ -32,9 +34,9 @@ #include "imanager.h" #include "subversion2.h" #include "subversion_view.h" -#include "svn_command_handlers.h" #include "svn_console.h" #include "svnsettingsdata.h" + #include #include #include @@ -49,7 +51,7 @@ void SvnUpdateHandler::Process(const wxString& output) wxString svnOutput(output); svnOutput.MakeLower(); - if(svnOutput.Contains(wxT("summary of conflicts:"))) { + if (svnOutput.Contains(wxT("summary of conflicts:"))) { // A conflict was found conflictFound = true; } @@ -60,11 +62,11 @@ void SvnUpdateHandler::Process(const wxString& output) // After 'Update' we usually want to do the following: // Reload workspace (if a project file or the workspace were modified) // or retag the workspace - if(!conflictFound) { + if (!conflictFound) { // Retag workspace only if no conflict were found // send an event to the main frame indicating that a re-tag is required - if(GetPlugin()->GetSettings().GetFlags() & SvnRetagWorkspace) { + if (GetPlugin()->GetSettings().GetFlags() & SvnRetagWorkspace) { wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, XRCID("retag_workspace")); GetPlugin()->GetManager()->GetTheApp()->GetTopWindow()->GetEventHandler()->AddPendingEvent(e); } @@ -83,10 +85,11 @@ void SvnDiffHandler::Process(const wxString& output) { // Open the changes inside the editor only if we are not using an external // diff viewer - if(GetPlugin()->GetSettings().GetFlags() & SvnUseExternalDiff) return; + if (GetPlugin()->GetSettings().GetFlags() & SvnUseExternalDiff) + return; IEditor* editor = GetPlugin()->GetManager()->NewEditor(); - if(editor) { + if (editor) { // Set the lexer name to 'Diff' editor->SetLexerName(wxT("Diff")); editor->AppendText(output); @@ -100,11 +103,13 @@ void SvnPatchHandler::Process(const wxString& output) GetPlugin()->GetConsole()->AppendText(output); GetPlugin()->GetConsole()->AppendText(wxT("-----\n")); - if(delFileWhenDone) { clRemoveFile(patchFile); } + if (delFileWhenDone) { + clRemoveFile(patchFile); + } // Retag workspace only if no conflict were found // send an event to the main frame indicating that a re-tag is required - if(GetPlugin()->GetSettings().GetFlags() & SvnRetagWorkspace) { + if (GetPlugin()->GetSettings().GetFlags() & SvnRetagWorkspace) { wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, XRCID("retag_workspace")); GetPlugin()->GetManager()->GetTheApp()->GetTopWindow()->GetEventHandler()->AddPendingEvent(e); } @@ -120,7 +125,7 @@ void SvnPatchDryRunHandler::Process(const wxString& output) GetPlugin()->GetConsole()->AppendText(output); GetPlugin()->GetConsole()->AppendText(_("===== OUTPUT END =====\n")); - if(delFileWhenDone) { + if (delFileWhenDone) { // delete the patch file clRemoveFile(patchFile); } @@ -130,7 +135,7 @@ void SvnVersionHandler::Process(const wxString& output) { // GetPlugin()->GetConsole()->AppendText(output); wxRegEx reVersion(wxT("svn, version ([0-9]\\.[0-9])(\\.[0-9])")); - if(reVersion.Matches(output)) { + if (reVersion.Matches(output)) { wxString strVersion = reVersion.GetMatch(output, 1); double version(0.0); @@ -145,7 +150,7 @@ void SvnLogHandler::Process(const wxString& output) { // create new editor and set the output to it wxString changeLog(output); - if(m_compact) { + if (m_compact) { // remove non interesting lines changeLog = Compact(changeLog); } @@ -164,20 +169,29 @@ wxString SvnLogHandler::Compact(const wxString& message) compactMsg.Replace(wxT("\v"), wxT("\n")); wxArrayString lines = wxStringTokenize(compactMsg, wxT("\n"), wxTOKEN_STRTOK); compactMsg.Clear(); - for(size_t i = 0; i < lines.GetCount(); i++) { + for (size_t i = 0; i < lines.GetCount(); i++) { wxString line = lines.Item(i); line.Trim().Trim(false); - if(line.IsEmpty()) continue; + if (line.IsEmpty()) + continue; - if(line.StartsWith(wxT("----------"))) { continue; } + if (line.StartsWith(wxT("----------"))) { + continue; + } - if(line == wxT("\"")) { continue; } + if (line == wxT("\"")) { + continue; + } static wxRegEx reRevisionPrefix(wxT("^(r[0-9]+)")); - if(reRevisionPrefix.Matches(line)) { continue; } + if (reRevisionPrefix.Matches(line)) { + continue; + } compactMsg << line << wxT("\n"); } - if(compactMsg.IsEmpty() == false) { compactMsg.RemoveLast(); } + if (compactMsg.IsEmpty() == false) { + compactMsg.RemoveLast(); + } return compactMsg; } @@ -185,7 +199,7 @@ void SvnCheckoutHandler::Process(const wxString& output) { wxUnusedVar(output); void SvnBlameHandler::Process(const wxString& output) { - if(output.StartsWith(wxT("svn:"))) { + if (output.StartsWith(wxT("svn:"))) { // error occurred GetPlugin()->GetConsole()->AppendText(output); GetPlugin()->GetConsole()->AppendText(wxT("--------\n")); @@ -201,7 +215,7 @@ void SvnBlameHandler::Process(const wxString& output) void SvnRepoListHandler::Process(const wxString& output) { - if(output.StartsWith(wxT("svn:"))) { + if (output.StartsWith(wxT("svn:"))) { // error occurred GetPlugin()->GetConsole()->AppendText(output); GetPlugin()->GetConsole()->AppendText(wxT("--------\n")); diff --git a/Subversion2/svn_command_handlers.h b/Subversion2/svn_command_handlers.h index 2a44f3609d..123fe5f3db 100644 --- a/Subversion2/svn_command_handlers.h +++ b/Subversion2/svn_command_handlers.h @@ -26,8 +26,8 @@ #ifndef SVNCOMMITHANDLER_H #define SVNCOMMITHANDLER_H -#include "svn_default_command_handler.h" // Base class #include "project.h" +#include "svn_default_command_handler.h" // Base class //---------------------------------------------------- // Commit Handler @@ -88,8 +88,9 @@ class SvnDiffHandler : public SvnDefaultCommandHandler class SvnPatchHandler : public SvnDefaultCommandHandler { - bool delFileWhenDone; + bool delFileWhenDone; wxString patchFile; + public: SvnPatchHandler(Subversion2* plugin, int commandId, wxEvtHandler* owner, bool d, const wxString& pf) : SvnDefaultCommandHandler(plugin, commandId, owner) @@ -109,7 +110,7 @@ class SvnPatchHandler : public SvnDefaultCommandHandler class SvnPatchDryRunHandler : public SvnDefaultCommandHandler { - bool delFileWhenDone; + bool delFileWhenDone; wxString patchFile; public: @@ -126,7 +127,7 @@ class SvnPatchDryRunHandler : public SvnDefaultCommandHandler }; //---------------------------------------------------- -//Svn version handler +// Svn version handler //---------------------------------------------------- class SvnVersionHandler : public SvnDefaultCommandHandler @@ -144,22 +145,24 @@ class SvnVersionHandler : public SvnDefaultCommandHandler }; //---------------------------------------------------- -//Svn Log handler +// Svn Log handler //---------------------------------------------------- class SvnLogHandler : public SvnDefaultCommandHandler { - bool m_compact; + bool m_compact; wxString m_url; protected: - wxString Compact(const wxString &message); + wxString Compact(const wxString& message); + public: - SvnLogHandler(Subversion2 *plugin, const wxString &url, bool compact, int commandId, wxEvtHandler *owner) + SvnLogHandler(Subversion2* plugin, const wxString& url, bool compact, int commandId, wxEvtHandler* owner) : SvnDefaultCommandHandler(plugin, commandId, owner) , m_compact(compact) , m_url(url) - {} + { + } ~SvnLogHandler() override = default; @@ -191,6 +194,7 @@ class SvnCheckoutHandler : public SvnDefaultCommandHandler class SvnBlameHandler : public SvnCommandHandler { wxString m_filename; + public: SvnBlameHandler(Subversion2* plugin, int commandId, wxEvtHandler* owner, const wxString& filename) : SvnCommandHandler(plugin, commandId, owner) diff --git a/Subversion2/svn_console.cpp b/Subversion2/svn_console.cpp index 72a39c4d4f..c34552a725 100644 --- a/Subversion2/svn_console.cpp +++ b/Subversion2/svn_console.cpp @@ -66,20 +66,21 @@ void SvnConsole::OnReadProcessOutput(clProcessEvent& event) m_output.Append(event.GetOutput()); wxString s = event.GetOutput().Lower(); - if(m_currCmd.printProcessOutput) AppendText(event.GetOutput()); + if (m_currCmd.printProcessOutput) + AppendText(event.GetOutput()); static wxRegEx reUsername("username[ \t]*:", wxRE_DEFAULT | wxRE_ICASE); wxArrayString lines = wxStringTokenize(s, wxT("\n"), wxTOKEN_STRTOK); - if(!lines.IsEmpty() && lines.Last().StartsWith(wxT("password for '"))) { + if (!lines.IsEmpty() && lines.Last().StartsWith(wxT("password for '"))) { m_output.Clear(); wxString pass = wxGetPasswordFromUser(event.GetOutput(), wxT("Subversion")); - if(!pass.IsEmpty() && m_process) { + if (!pass.IsEmpty() && m_process) { m_process->WriteToConsole(pass); } - } else if(!lines.IsEmpty() && reUsername.IsValid() && reUsername.Matches(lines.Last())) { + } else if (!lines.IsEmpty() && reUsername.IsValid() && reUsername.Matches(lines.Last())) { // Prompt the user for "Username:" wxString username = ::wxGetTextFromUser(event.GetOutput(), "Subversion"); - if(!username.IsEmpty() && m_process) { + if (!username.IsEmpty() && m_process) { m_process->Write(username + "\n"); } } @@ -88,7 +89,7 @@ void SvnConsole::OnReadProcessOutput(clProcessEvent& event) void SvnConsole::OnProcessEnd(clProcessEvent& event) { wxDELETE(m_process); - if(m_currCmd.handler) { + if (m_currCmd.handler) { // command ended successfully, invoke the "success" callback m_currCmd.handler->Process(m_output); AppendText(wxT("-----\n")); @@ -96,7 +97,7 @@ void SvnConsole::OnProcessEnd(clProcessEvent& event) } // do we have more commands to process? - if(!m_queue.empty()) { + if (!m_queue.empty()) { DoProcessNextCommand(); } else { @@ -107,15 +108,20 @@ void SvnConsole::OnProcessEnd(clProcessEvent& event) } } -void SvnConsole::ExecuteURL(const wxString& cmd, const wxString& url, SvnCommandHandler* handler, +void SvnConsole::ExecuteURL(const wxString& cmd, + const wxString& url, + SvnCommandHandler* handler, bool printProcessOutput) { DoExecute(cmd, handler, wxT(""), printProcessOutput); m_url = url; } -void SvnConsole::Execute(const wxString& cmd, const wxString& workingDirectory, SvnCommandHandler* handler, - bool printProcessOutput, bool showConsole) +void SvnConsole::Execute(const wxString& cmd, + const wxString& workingDirectory, + SvnCommandHandler* handler, + bool printProcessOutput, + bool showConsole) { DoExecute(cmd, handler, workingDirectory, printProcessOutput, showConsole); } @@ -148,7 +154,7 @@ void SvnConsole::Clear() void SvnConsole::Stop() { - if(m_process) { + if (m_process) { delete m_process; m_process = NULL; } @@ -165,11 +171,12 @@ void SvnConsole::EnsureVisible() { m_plugin->EnsureVisible(); } void SvnConsole::DoProcessNextCommand() { // If another process is running, we try again when the process is terminated - if(m_process) { + if (m_process) { return; } - if(m_queue.empty()) return; + if (m_queue.empty()) + return; // Remove the command from the queue SvnConsoleCommand* command = m_queue.front(); @@ -199,18 +206,22 @@ void SvnConsole::DoProcessNextCommand() clDEBUG() << "Running svn command:" << cmdShell << clEndl; - m_process = CreateAsyncProcess(this, cmdShell, + m_process = CreateAsyncProcess(this, + cmdShell, m_currCmd.showConsole ? IProcessCreateConsole : IProcessCreateWithHiddenConsole, m_currCmd.workingDirectory); - if(!m_process) { + if (!m_process) { AppendText(_("Failed to launch Subversion client.\n")); return; } m_sci->SetFocus(); } -void SvnConsole::DoExecute(const wxString& cmd, SvnCommandHandler* handler, const wxString& workingDirectory, - bool printProcessOutput, bool showConsole) +void SvnConsole::DoExecute(const wxString& cmd, + SvnCommandHandler* handler, + const wxString& workingDirectory, + bool printProcessOutput, + bool showConsole) { SvnConsoleCommand* consoleCommand = new SvnConsoleCommand(); consoleCommand->cmd = cmd.c_str(); @@ -225,13 +236,13 @@ void SvnConsole::DoExecute(const wxString& cmd, SvnCommandHandler* handler, cons void SvnConsole::OnCharAdded(wxStyledTextEvent& event) { - if(event.GetKey() == '\n') { + if (event.GetKey() == '\n') { // an enter was inserted // take the last inserted line and send it to the m_process wxString line = m_sci->GetTextRange(m_inferiorEnd, m_sci->GetLength()); line.Trim(); - if(m_process) { + if (m_process) { m_process->Write(line); } } @@ -254,5 +265,7 @@ void SvnConsole::OnKeyDown(wxKeyEvent& event) { event.Skip(); } void SvnConsole::DoInitializeFontsAndColours() { LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexer("text"); - if(lexer) { lexer->Apply(m_sci); } + if (lexer) { + lexer->Apply(m_sci); + } } diff --git a/Subversion2/svn_console.h b/Subversion2/svn_console.h index 2d4d59ec23..3f7f04e67f 100644 --- a/Subversion2/svn_console.h +++ b/Subversion2/svn_console.h @@ -26,11 +26,12 @@ #ifndef SVNSHELL_H #define SVNSHELL_H +#include "cl_command_event.h" #include "svncommandhandler.h" + #include -#include #include -#include "cl_command_event.h" +#include class IProcess; class Subversion2; diff --git a/Subversion2/svn_copy_dialog.cpp b/Subversion2/svn_copy_dialog.cpp index c8cb926783..b62b2e9a3e 100644 --- a/Subversion2/svn_copy_dialog.cpp +++ b/Subversion2/svn_copy_dialog.cpp @@ -23,38 +23,24 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#include "svn_copy_dialog.h" -#include "SvnCommitDialog.h" - -SvnCopyDialog::SvnCopyDialog( wxWindow* parent ) -: SvnCopyDialogBase( parent ) -{ - m_textCtrlTargetURL->SetFocus(); - m_textCtrlTargetURL->SelectAll(); - m_textCtrlTargetURL->SetInsertionPointEnd(); -} - -void SvnCopyDialog::SetSourceURL(const wxString& url) -{ - m_textCtrlSourceURL->SetValue(url); -} +#include "svn_copy_dialog.h" -void SvnCopyDialog::SetTargetURL(const wxString& url) -{ - m_textCtrlTargetURL->SetValue(url); -} +#include "SvnCommitDialog.h" -wxString SvnCopyDialog::GetMessage() -{ - return SvnCommitDialog::NormalizeMessage(m_textCtrlComment->GetValue()); -} - -wxString SvnCopyDialog::GetSourceURL() -{ - return m_textCtrlSourceURL->GetValue(); +SvnCopyDialog::SvnCopyDialog(wxWindow* parent) + : SvnCopyDialogBase(parent) +{ + m_textCtrlTargetURL->SetFocus(); + m_textCtrlTargetURL->SelectAll(); + m_textCtrlTargetURL->SetInsertionPointEnd(); } -wxString SvnCopyDialog::GetTargetURL() -{ - return m_textCtrlTargetURL->GetValue(); -} +void SvnCopyDialog::SetSourceURL(const wxString& url) { m_textCtrlSourceURL->SetValue(url); } + +void SvnCopyDialog::SetTargetURL(const wxString& url) { m_textCtrlTargetURL->SetValue(url); } + +wxString SvnCopyDialog::GetMessage() { return SvnCommitDialog::NormalizeMessage(m_textCtrlComment->GetValue()); } + +wxString SvnCopyDialog::GetSourceURL() { return m_textCtrlSourceURL->GetValue(); } + +wxString SvnCopyDialog::GetTargetURL() { return m_textCtrlTargetURL->GetValue(); } diff --git a/Subversion2/svn_copy_dialog.h b/Subversion2/svn_copy_dialog.h index 5478a3de42..de7e1f5528 100644 --- a/Subversion2/svn_copy_dialog.h +++ b/Subversion2/svn_copy_dialog.h @@ -23,28 +23,28 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef __svn_copy_dialog__ -#define __svn_copy_dialog__ - -/** -@file -Subclass of SvnCopyDialogBase, which is generated by wxFormBuilder. -*/ - -#include "subversion2_ui.h" - -/** Implementing SvnCopyDialogBase */ -class SvnCopyDialog : public SvnCopyDialogBase -{ -public: - /** Constructor */ - SvnCopyDialog( wxWindow* parent ); - - void SetSourceURL(const wxString &url); - void SetTargetURL(const wxString &url); - wxString GetMessage(); - wxString GetSourceURL(); - wxString GetTargetURL(); -}; - -#endif // __svn_copy_dialog__ +#ifndef __svn_copy_dialog__ +#define __svn_copy_dialog__ + +/** +@file +Subclass of SvnCopyDialogBase, which is generated by wxFormBuilder. +*/ + +#include "subversion2_ui.h" + +/** Implementing SvnCopyDialogBase */ +class SvnCopyDialog : public SvnCopyDialogBase +{ +public: + /** Constructor */ + SvnCopyDialog(wxWindow* parent); + + void SetSourceURL(const wxString& url); + void SetTargetURL(const wxString& url); + wxString GetMessage(); + wxString GetSourceURL(); + wxString GetTargetURL(); +}; + +#endif // __svn_copy_dialog__ diff --git a/Subversion2/svn_default_command_handler.cpp b/Subversion2/svn_default_command_handler.cpp index c40d12275a..2a18e95929 100644 --- a/Subversion2/svn_default_command_handler.cpp +++ b/Subversion2/svn_default_command_handler.cpp @@ -24,19 +24,21 @@ ////////////////////////////////////////////////////////////////////////////// #include "svn_default_command_handler.h" + +#include "event_notifier.h" +#include "file_logger.h" +#include "fileutils.h" #include "subversion2.h" #include "subversion_view.h" -#include "event_notifier.h" + #include -#include "fileutils.h" -#include "file_logger.h" -SvnDefaultCommandHandler::SvnDefaultCommandHandler(Subversion2 *plugin, int commandId, wxEvtHandler *owner) +SvnDefaultCommandHandler::SvnDefaultCommandHandler(Subversion2* plugin, int commandId, wxEvtHandler* owner) : SvnCommandHandler(plugin, commandId, owner) { } -void SvnDefaultCommandHandler::Process(const wxString &output) +void SvnDefaultCommandHandler::Process(const wxString& output) { wxUnusedVar(output); @@ -45,7 +47,7 @@ void SvnDefaultCommandHandler::Process(const wxString &output) // Refresh the SVN output page GetPlugin()->GetSvnView()->BuildTree(); - + // Delete the commit message file wxFileName tmpFile(clStandardPaths::Get().GetTempDir(), ".svn-commit"); clDEBUG() << "Svn commit handler: deleting commit file" << tmpFile << clEndl; diff --git a/Subversion2/svn_default_command_handler.h b/Subversion2/svn_default_command_handler.h index 68e7c44336..5267fb60bd 100644 --- a/Subversion2/svn_default_command_handler.h +++ b/Subversion2/svn_default_command_handler.h @@ -30,13 +30,14 @@ class SubversionView; -class SvnDefaultCommandHandler : public SvnCommandHandler { +class SvnDefaultCommandHandler : public SvnCommandHandler +{ public: - SvnDefaultCommandHandler(Subversion2 *plugin, int commandId, wxEvtHandler *owner); - virtual ~SvnDefaultCommandHandler() = default; + SvnDefaultCommandHandler(Subversion2* plugin, int commandId, wxEvtHandler* owner); + virtual ~SvnDefaultCommandHandler() = default; public: - virtual void Process(const wxString &output); + virtual void Process(const wxString& output); }; #endif // SVN_DEFAULT_COMMAND_HANDLER_H diff --git a/Subversion2/svn_local_properties.cpp b/Subversion2/svn_local_properties.cpp index c08ae28a80..ed430e3883 100644 --- a/Subversion2/svn_local_properties.cpp +++ b/Subversion2/svn_local_properties.cpp @@ -24,13 +24,15 @@ ////////////////////////////////////////////////////////////////////////////// #include "svn_local_properties.h" + +#include "cl_standard_paths.h" +#include "fileutils.h" + +#include +#include #include #include #include -#include -#include -#include "cl_standard_paths.h" -#include "fileutils.h" wxString SubversionLocalProperties::BUG_TRACKER_URL = wxT("bug_tracker_url"); wxString SubversionLocalProperties::BUG_TRACKER_MESSAGE = wxT("bug_tracker_message"); @@ -48,10 +50,12 @@ wxString SubversionLocalProperties::ReadProperty(const wxString& propName) // find the relevant group GroupTable::const_iterator iter = m_values.find(m_url); - if(iter == m_values.end()) return wxT(""); + if (iter == m_values.end()) + return wxT(""); SimpleTable::const_iterator it = iter->second.find(propName); - if(it == iter->second.end()) return wxT(""); + if (it == iter->second.end()) + return wxT(""); return it->second; } @@ -61,7 +65,7 @@ void SubversionLocalProperties::WriteProperty(const wxString& name, const wxStri ReadProperties(); GroupTable::iterator iter = m_values.find(m_url); - if(iter == m_values.end()) { + if (iter == m_values.end()) { SimpleTable tb; tb[name] = val; m_values[m_url] = tb; @@ -77,9 +81,9 @@ wxString SubversionLocalProperties::GetConfigFile() { wxFileName fnConfig(clStandardPaths::Get().GetUserDataDir(), "codelite-properties.ini"); fnConfig.AppendDir("subversion"); - + fnConfig.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); - if(!fnConfig.Exists()) { + if (!fnConfig.Exists()) { // Create an empty file FileUtils::WriteFileContent(fnConfig, ""); } @@ -91,7 +95,7 @@ void SubversionLocalProperties::ReadProperties() m_values.clear(); wxString group; wxFFile fp(GetConfigFile(), wxT("rb")); - if(fp.IsOpened()) { + if (fp.IsOpened()) { wxString content; fp.ReadAll(&content); @@ -103,9 +107,10 @@ void SubversionLocalProperties::ReadProperties() // trim the string entry.Trim().Trim(false); - if(entry.IsEmpty()) continue; + if (entry.IsEmpty()) + continue; - if(entry.StartsWith(wxT("["))) { + if (entry.StartsWith(wxT("["))) { // found new group entry = entry.AfterFirst(wxT('[')); group = entry.BeforeFirst(wxT(']')); @@ -119,13 +124,13 @@ void SubversionLocalProperties::ReadProperties() key.Trim().Trim(false); value.Trim().Trim(false); - if(group.IsEmpty()) { + if (group.IsEmpty()) { // we don't have group yet - discard this entry continue; } GroupTable::iterator iter = m_values.find(group); - if(iter == m_values.end()) { + if (iter == m_values.end()) { // create new table and the value SimpleTable tb; tb[key] = value; diff --git a/Subversion2/svn_local_properties.h b/Subversion2/svn_local_properties.h index 325da1144c..505e50e28e 100644 --- a/Subversion2/svn_local_properties.h +++ b/Subversion2/svn_local_properties.h @@ -26,34 +26,34 @@ #ifndef SUBVERSIONLOCALPROPERTIES_H #define SUBVERSIONLOCALPROPERTIES_H -#include #include +#include using SimpleTable = std::map; using GroupTable = std::map; class SubversionLocalProperties { - wxString m_url; - GroupTable m_values; + wxString m_url; + GroupTable m_values; public: - static wxString BUG_TRACKER_URL; - static wxString BUG_TRACKER_MESSAGE; - static wxString FR_TRACKER_URL; - static wxString FR_TRACKER_MESSAGE; + static wxString BUG_TRACKER_URL; + static wxString BUG_TRACKER_MESSAGE; + static wxString FR_TRACKER_URL; + static wxString FR_TRACKER_MESSAGE; protected: - wxString GetConfigFile(); - void ReadProperties(); - void WriteProperties(); + wxString GetConfigFile(); + void ReadProperties(); + void WriteProperties(); public: - SubversionLocalProperties(const wxString &url); - virtual ~SubversionLocalProperties() = default; + SubversionLocalProperties(const wxString& url); + virtual ~SubversionLocalProperties() = default; - wxString ReadProperty (const wxString &propName); - void WriteProperty(const wxString &name, const wxString &val); + wxString ReadProperty(const wxString& propName); + void WriteProperty(const wxString& name, const wxString& val); }; #endif // SUBVERSIONLOCALPROPERTIES_H diff --git a/Subversion2/svn_login_dialog.cpp b/Subversion2/svn_login_dialog.cpp index 5844d336d6..755b38af15 100644 --- a/Subversion2/svn_login_dialog.cpp +++ b/Subversion2/svn_login_dialog.cpp @@ -23,11 +23,10 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#include "svn_login_dialog.h" - -SvnLoginDialog::SvnLoginDialog( wxWindow* parent ) -: -SvnLoginDialogBase( parent ) -{ - m_textCtrlUsername->SetFocus(); -} +#include "svn_login_dialog.h" + +SvnLoginDialog::SvnLoginDialog(wxWindow* parent) + : SvnLoginDialogBase(parent) +{ + m_textCtrlUsername->SetFocus(); +} diff --git a/Subversion2/svn_login_dialog.h b/Subversion2/svn_login_dialog.h index ca5aa376d0..e8017a92e2 100644 --- a/Subversion2/svn_login_dialog.h +++ b/Subversion2/svn_login_dialog.h @@ -23,25 +23,25 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef __svn_login_dialog__ -#define __svn_login_dialog__ - -/** -@file -Subclass of SvnLoginDialogBase, which is generated by wxFormBuilder. -*/ - -#include "subversion2_ui.h" - -/** Implementing SvnLoginDialogBase */ -class SvnLoginDialog : public SvnLoginDialogBase -{ -public: - /** Constructor */ - SvnLoginDialog( wxWindow* parent ); - - wxString GetUsername() {return m_textCtrlUsername->GetValue();} - wxString GetPassword() {return m_textCtrlPassword->GetValue();} -}; - -#endif // __svn_login_dialog__ +#ifndef __svn_login_dialog__ +#define __svn_login_dialog__ + +/** +@file +Subclass of SvnLoginDialogBase, which is generated by wxFormBuilder. +*/ + +#include "subversion2_ui.h" + +/** Implementing SvnLoginDialogBase */ +class SvnLoginDialog : public SvnLoginDialogBase +{ +public: + /** Constructor */ + SvnLoginDialog(wxWindow* parent); + + wxString GetUsername() { return m_textCtrlUsername->GetValue(); } + wxString GetPassword() { return m_textCtrlPassword->GetValue(); } +}; + +#endif // __svn_login_dialog__ diff --git a/Subversion2/svn_overlay_tool.cpp b/Subversion2/svn_overlay_tool.cpp index 6b8211d1b6..23607c875f 100644 --- a/Subversion2/svn_overlay_tool.cpp +++ b/Subversion2/svn_overlay_tool.cpp @@ -23,13 +23,15 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#include #include "svn_overlay_tool.h" -#include + #include "bitmap_loader.h" #include "globals.h" #include "imanager.h" +#include +#include + wxBitmap SvnOverlayTool::ms_bmpOK; wxBitmap SvnOverlayTool::ms_bmpConflict; wxBitmap SvnOverlayTool::ms_bmpModified; diff --git a/Subversion2/svn_overlay_tool.h b/Subversion2/svn_overlay_tool.h index 8dd248a9a4..7769477f2c 100644 --- a/Subversion2/svn_overlay_tool.h +++ b/Subversion2/svn_overlay_tool.h @@ -28,34 +28,34 @@ #include "precompiled_header.h" -class SvnOverlayTool { - - static wxBitmap ms_bmpOK; - static wxBitmap ms_bmpConflict; - static wxBitmap ms_bmpModified; - static wxBitmap ms_bmpLocked; - static wxBitmap ms_bmpUnversioned; - static wxBitmap ms_bmpNew; - static wxBitmap ms_bmpDeleted; - +class SvnOverlayTool +{ + + static wxBitmap ms_bmpOK; + static wxBitmap ms_bmpConflict; + static wxBitmap ms_bmpModified; + static wxBitmap ms_bmpLocked; + static wxBitmap ms_bmpUnversioned; + static wxBitmap ms_bmpNew; + static wxBitmap ms_bmpDeleted; + private: - SvnOverlayTool(); + SvnOverlayTool(); virtual ~SvnOverlayTool() = default; - + protected: - wxBitmap DoAddBitmap(const wxBitmap& bmp, const wxBitmap &overlayBmp); - + wxBitmap DoAddBitmap(const wxBitmap& bmp, const wxBitmap& overlayBmp); + public: - static SvnOverlayTool& Get(); - - wxBitmap OKIcon (const wxBitmap& bmp); - wxBitmap ConflictIcon (const wxBitmap& bmp); - wxBitmap ModifiedIcon (const wxBitmap& bmp); - wxBitmap NewIcon (const wxBitmap& bmp); - wxBitmap LockedIcon (const wxBitmap& bmp); - wxBitmap UnversionedIcon(const wxBitmap& bmp); - wxBitmap DeletedIcon (const wxBitmap& bmp); - + static SvnOverlayTool& Get(); + + wxBitmap OKIcon(const wxBitmap& bmp); + wxBitmap ConflictIcon(const wxBitmap& bmp); + wxBitmap ModifiedIcon(const wxBitmap& bmp); + wxBitmap NewIcon(const wxBitmap& bmp); + wxBitmap LockedIcon(const wxBitmap& bmp); + wxBitmap UnversionedIcon(const wxBitmap& bmp); + wxBitmap DeletedIcon(const wxBitmap& bmp); }; #endif // SVN_OVERLAY_TOOL_H diff --git a/Subversion2/svn_patch_dlg.cpp b/Subversion2/svn_patch_dlg.cpp index ed2765f9ff..3fa4d96136 100644 --- a/Subversion2/svn_patch_dlg.cpp +++ b/Subversion2/svn_patch_dlg.cpp @@ -24,8 +24,9 @@ ////////////////////////////////////////////////////////////////////////////// #include "svn_patch_dlg.h" -#include "windowattrmanager.h" + #include "editor_config.h" +#include "windowattrmanager.h" PatchDlg::PatchDlg(wxWindow* parent) : PatchDlgBase(parent) @@ -34,13 +35,13 @@ PatchDlg::PatchDlg(wxWindow* parent) WindowAttrManager::Load(this); long v = EditorConfigST::Get()->GetInteger(wxT("m_radioBoxEOLPolicy")); - if(v != wxNOT_FOUND) { + if (v != wxNOT_FOUND) { m_radioBoxEOLPolicy->SetSelection(v); } } PatchDlg::~PatchDlg() { - + EditorConfigST::Get()->SetInteger(wxT("m_radioBoxEOLPolicy"), m_radioBoxEOLPolicy->GetSelection()); } diff --git a/Subversion2/svn_patch_dlg.h b/Subversion2/svn_patch_dlg.h index 4ee068963b..5be3855c66 100644 --- a/Subversion2/svn_patch_dlg.h +++ b/Subversion2/svn_patch_dlg.h @@ -23,35 +23,31 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef __svn_patch_dlg__ -#define __svn_patch_dlg__ - -/** -@file -Subclass of PatchDlgBase, which is generated by wxFormBuilder. -*/ - -#include "subversion2_ui.h" - -//// end generated include - -/** Implementing PatchDlgBase */ -class PatchDlg : public PatchDlgBase -{ -public: - /** Constructor */ - PatchDlg( wxWindow* parent ); - //// end generated class members - - virtual ~PatchDlg(); - - wxFilePickerCtrl* GetFilePicker() const { - return m_filePicker; - } - - wxRadioBox* GetRadioBoxPolicy() const { - return m_radioBoxEOLPolicy; - } -}; - -#endif // __svn_patch_dlg__ +#ifndef __svn_patch_dlg__ +#define __svn_patch_dlg__ + +/** +@file +Subclass of PatchDlgBase, which is generated by wxFormBuilder. +*/ + +#include "subversion2_ui.h" + +//// end generated include + +/** Implementing PatchDlgBase */ +class PatchDlg : public PatchDlgBase +{ +public: + /** Constructor */ + PatchDlg(wxWindow* parent); + //// end generated class members + + virtual ~PatchDlg(); + + wxFilePickerCtrl* GetFilePicker() const { return m_filePicker; } + + wxRadioBox* GetRadioBoxPolicy() const { return m_radioBoxEOLPolicy; } +}; + +#endif // __svn_patch_dlg__ diff --git a/Subversion2/svn_preferences_dialog.cpp b/Subversion2/svn_preferences_dialog.cpp index bbe244ce3f..01560596dd 100644 --- a/Subversion2/svn_preferences_dialog.cpp +++ b/Subversion2/svn_preferences_dialog.cpp @@ -24,12 +24,14 @@ ////////////////////////////////////////////////////////////////////////////// #include "svn_preferences_dialog.h" -#include -#include "windowattrmanager.h" + #include "imanager.h" #include "subversion2.h" +#include "windowattrmanager.h" + #include #include +#include SvnPreferencesDialog::SvnPreferencesDialog(wxWindow* parent, Subversion2* plugin) : SvnPreferencesDialogBase(parent) @@ -60,7 +62,7 @@ void SvnPreferencesDialog::OnBrowseSvnExe(wxCommandEvent& event) { wxUnusedVar(event); wxString path = DoGetExecutable(m_textCtrlSvnExecutable->GetValue()); - if(path.IsEmpty() == false) { + if (path.IsEmpty() == false) { m_textCtrlSvnExecutable->SetValue(path); } } @@ -69,7 +71,7 @@ void SvnPreferencesDialog::OnBrowseDiffViewer(wxCommandEvent& event) { wxUnusedVar(event); wxString path = DoGetExecutable(m_textCtrlDiffViewer->GetValue()); - if(path.IsEmpty() == false) { + if (path.IsEmpty() == false) { m_textCtrlDiffViewer->SetValue(path); } } @@ -78,7 +80,7 @@ void SvnPreferencesDialog::OnBrowseSSHClient(wxCommandEvent& event) { wxUnusedVar(event); wxString path = DoGetExecutable(m_textCtrlSSHClient->GetValue()); - if(path.IsEmpty() == false) { + if (path.IsEmpty() == false) { m_textCtrlSSHClient->SetValue(path); } } @@ -86,9 +88,9 @@ void SvnPreferencesDialog::OnBrowseSSHClient(wxCommandEvent& event) wxString SvnPreferencesDialog::DoGetExecutable(const wxString& basePath) { wxString path; - if(basePath.IsEmpty() == false) { + if (basePath.IsEmpty() == false) { wxFileName fn(basePath); - if(fn.IsRelative() == false) { + if (fn.IsRelative() == false) { path = fn.GetPath(); } } @@ -113,29 +115,30 @@ void SvnPreferencesDialog::OnButtonOK(wxCommandEvent& event) // so read its current value before adding the other // flags size_t flags(0); - if(m_plugin->GetSettings().GetFlags() & SvnLinkEditor) flags = SvnLinkEditor; + if (m_plugin->GetSettings().GetFlags() & SvnLinkEditor) + flags = SvnLinkEditor; - if(m_checkBoxAddToSvn->IsChecked()) { + if (m_checkBoxAddToSvn->IsChecked()) { flags |= SvnAddFileToSvn; } - if(m_checkBoxRetag->IsChecked()) { + if (m_checkBoxRetag->IsChecked()) { flags |= SvnRetagWorkspace; } - if(m_checkBoxUseExternalDiff->IsChecked()) { + if (m_checkBoxUseExternalDiff->IsChecked()) { flags |= SvnUseExternalDiff; } - if(m_checkBoxExposeRevisionMacro->IsChecked()) { + if (m_checkBoxExposeRevisionMacro->IsChecked()) { flags |= SvnExposeRevisionMacro; } - if(m_checkBoxRenameFile->IsChecked()) { + if (m_checkBoxRenameFile->IsChecked()) { flags |= SvnRenameFileInRepo; } - if(m_checkBoxUsePosixLocale->IsChecked()) { + if (m_checkBoxUsePosixLocale->IsChecked()) { flags |= SvnUsePosixLocale; } diff --git a/Subversion2/svn_preferences_dialog.h b/Subversion2/svn_preferences_dialog.h index 3ec234f4e1..b8e17b860a 100644 --- a/Subversion2/svn_preferences_dialog.h +++ b/Subversion2/svn_preferences_dialog.h @@ -23,37 +23,38 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef __svn_preferences_dialog__ -#define __svn_preferences_dialog__ - -/** -@file -Subclass of SvnPreferencesDialogBase, which is generated by wxFormBuilder. -*/ - -#include "subversion2_ui.h" -class Subversion2; - -/** Implementing SvnPreferencesDialogBase */ -class SvnPreferencesDialog : public SvnPreferencesDialogBase -{ - Subversion2 *m_plugin; -protected: - // Handlers for SvnPreferencesDialogBase events. - void OnBrowseSvnExe ( wxCommandEvent& event ); - void OnBrowseDiffViewer( wxCommandEvent& event ); - void OnBrowseSSHClient ( wxCommandEvent& event ); - void OnButtonOK ( wxCommandEvent &event ); - void OnUseExternalDiffUI( wxUpdateUIEvent &event); - void OnAddRevisionMacroUI( wxUpdateUIEvent& event ); - -protected: - wxString DoGetExecutable(const wxString &basePath); - -public: - /** Constructor */ - SvnPreferencesDialog( wxWindow* parent, Subversion2 *plugin ); - virtual ~SvnPreferencesDialog() = default; -}; - -#endif // __svn_preferences_dialog__ +#ifndef __svn_preferences_dialog__ +#define __svn_preferences_dialog__ + +/** +@file +Subclass of SvnPreferencesDialogBase, which is generated by wxFormBuilder. +*/ + +#include "subversion2_ui.h" +class Subversion2; + +/** Implementing SvnPreferencesDialogBase */ +class SvnPreferencesDialog : public SvnPreferencesDialogBase +{ + Subversion2* m_plugin; + +protected: + // Handlers for SvnPreferencesDialogBase events. + void OnBrowseSvnExe(wxCommandEvent& event); + void OnBrowseDiffViewer(wxCommandEvent& event); + void OnBrowseSSHClient(wxCommandEvent& event); + void OnButtonOK(wxCommandEvent& event); + void OnUseExternalDiffUI(wxUpdateUIEvent& event); + void OnAddRevisionMacroUI(wxUpdateUIEvent& event); + +protected: + wxString DoGetExecutable(const wxString& basePath); + +public: + /** Constructor */ + SvnPreferencesDialog(wxWindow* parent, Subversion2* plugin); + virtual ~SvnPreferencesDialog() = default; +}; + +#endif // __svn_preferences_dialog__ diff --git a/Subversion2/svn_props_dialog.h b/Subversion2/svn_props_dialog.h index 54209fab7e..01c24af672 100644 --- a/Subversion2/svn_props_dialog.h +++ b/Subversion2/svn_props_dialog.h @@ -40,7 +40,7 @@ class SvnPropsDlg : public SvnPropsBaseDlg public: /** Constructor */ - SvnPropsDlg(wxWindow* parent, const wxString& url, Subversion2 *plugin); + SvnPropsDlg(wxWindow* parent, const wxString& url, Subversion2* plugin); virtual ~SvnPropsDlg() = default; wxString GetBugTrackerURL() const; diff --git a/Subversion2/svn_select_local_repo_dlg.cpp b/Subversion2/svn_select_local_repo_dlg.cpp index a6873e0bef..549d388bd9 100644 --- a/Subversion2/svn_select_local_repo_dlg.cpp +++ b/Subversion2/svn_select_local_repo_dlg.cpp @@ -1,26 +1,26 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2014 Eran Ifrah -// file name : svn_select_local_repo_dlg.cpp -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2014 Eran Ifrah +// file name : svn_select_local_repo_dlg.cpp +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// #include "svn_select_local_repo_dlg.h" @@ -30,86 +30,86 @@ #include -SvnSelectLocalRepoDlg::SvnSelectLocalRepoDlg( wxWindow* parent, Subversion2 *plugin, const wxString &curpath ) - : SvnSelectLocalRepoBase( parent ) - , m_svn(plugin) +SvnSelectLocalRepoDlg::SvnSelectLocalRepoDlg(wxWindow* parent, Subversion2* plugin, const wxString& curpath) + : SvnSelectLocalRepoBase(parent) + , m_svn(plugin) { - m_listBoxPaths->Clear(); - m_listBoxPaths->Append(m_svn->GetSettings().GetRepos()); - m_dirPicker1->SetPath(curpath); + m_listBoxPaths->Clear(); + m_listBoxPaths->Append(m_svn->GetSettings().GetRepos()); + m_dirPicker1->SetPath(curpath); SetName("SvnSelectLocalRepoDlg"); - WindowAttrManager::Load(this); + WindowAttrManager::Load(this); } -void SvnSelectLocalRepoDlg::OnPathSelected( wxCommandEvent& event ) +void SvnSelectLocalRepoDlg::OnPathSelected(wxCommandEvent& event) { - wxArrayInt selections; - m_listBoxPaths->GetSelections(selections); - if(selections.GetCount() == 1) { - m_dirPicker1->SetPath(m_listBoxPaths->GetString(selections.Item(0))); - } + wxArrayInt selections; + m_listBoxPaths->GetSelections(selections); + if (selections.GetCount() == 1) { + m_dirPicker1->SetPath(m_listBoxPaths->GetString(selections.Item(0))); + } } -void SvnSelectLocalRepoDlg::OnPathActivated( wxCommandEvent& event ) +void SvnSelectLocalRepoDlg::OnPathActivated(wxCommandEvent& event) { - wxArrayInt selections; - m_listBoxPaths->GetSelections(selections); - if(!selections.IsEmpty()) { - m_dirPicker1->SetPath(m_listBoxPaths->GetString(selections.Item(0))); - EndModal(wxID_OK); - } + wxArrayInt selections; + m_listBoxPaths->GetSelections(selections); + if (!selections.IsEmpty()) { + m_dirPicker1->SetPath(m_listBoxPaths->GetString(selections.Item(0))); + EndModal(wxID_OK); + } } -void SvnSelectLocalRepoDlg::OnMenu( wxMouseEvent& event ) +void SvnSelectLocalRepoDlg::OnMenu(wxMouseEvent& event) { - wxArrayInt selections; - m_listBoxPaths->GetSelections(selections); - if(!selections.IsEmpty()) { - wxMenu menu; - if(selections.GetCount() == 1) { - menu.Append(wxID_DELETE, _("Remove path"), _("Remove path"), wxITEM_NORMAL); - - } else { - menu.Append(wxID_DELETE, _("Remove paths"), _("Remove paths"), wxITEM_NORMAL); - } - - menu.Connect(wxID_DELETE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SvnSelectLocalRepoDlg::OnRemoveEntry), NULL, this); - m_listBoxPaths->PopupMenu(&menu); - } -} + wxArrayInt selections; + m_listBoxPaths->GetSelections(selections); + if (!selections.IsEmpty()) { + wxMenu menu; + if (selections.GetCount() == 1) { + menu.Append(wxID_DELETE, _("Remove path"), _("Remove path"), wxITEM_NORMAL); -wxString SvnSelectLocalRepoDlg::GetPath() const -{ - return m_dirPicker1->GetPath(); + } else { + menu.Append(wxID_DELETE, _("Remove paths"), _("Remove paths"), wxITEM_NORMAL); + } + + menu.Connect(wxID_DELETE, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(SvnSelectLocalRepoDlg::OnRemoveEntry), + NULL, + this); + m_listBoxPaths->PopupMenu(&menu); + } } +wxString SvnSelectLocalRepoDlg::GetPath() const { return m_dirPicker1->GetPath(); } void SvnSelectLocalRepoDlg::OnRemoveEntry(wxCommandEvent& e) { - wxArrayInt ids; - m_listBoxPaths->GetSelections(ids); - - if(ids.IsEmpty()) - return; - - SvnSettingsData ssd = m_svn->GetSettings(); - const wxArrayString &repos = ssd.GetRepos(); - wxArrayString modRepos = repos; - - for(size_t i=0; iGetString(id); - if(str.IsEmpty() == false && str != _("")) { - int where = modRepos.Index(str); - if(where != wxNOT_FOUND) { - modRepos.RemoveAt(where); - } - } - } - - ssd.SetRepos(modRepos); - m_svn->SetSettings(ssd); - - m_listBoxPaths->Clear(); - m_listBoxPaths->Append(m_svn->GetSettings().GetRepos()); + wxArrayInt ids; + m_listBoxPaths->GetSelections(ids); + + if (ids.IsEmpty()) + return; + + SvnSettingsData ssd = m_svn->GetSettings(); + const wxArrayString& repos = ssd.GetRepos(); + wxArrayString modRepos = repos; + + for (size_t i = 0; i < ids.GetCount(); i++) { + int id = ids.Item(i); + wxString str = m_listBoxPaths->GetString(id); + if (str.IsEmpty() == false && str != _("")) { + int where = modRepos.Index(str); + if (where != wxNOT_FOUND) { + modRepos.RemoveAt(where); + } + } + } + + ssd.SetRepos(modRepos); + m_svn->SetSettings(ssd); + + m_listBoxPaths->Clear(); + m_listBoxPaths->Append(m_svn->GetSettings().GetRepos()); } diff --git a/Subversion2/svn_select_local_repo_dlg.h b/Subversion2/svn_select_local_repo_dlg.h index 0d5ffe2d9c..cbcbd4785b 100644 --- a/Subversion2/svn_select_local_repo_dlg.h +++ b/Subversion2/svn_select_local_repo_dlg.h @@ -23,29 +23,29 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef __svn_select_local_repo_dlg__ -#define __svn_select_local_repo_dlg__ - -#include "subversion2_ui.h" - -class Subversion2; -class SvnSelectLocalRepoDlg : public SvnSelectLocalRepoBase -{ - Subversion2 *m_svn; - -protected: - // Handlers for SvnSelectLocalRepoBase events. - void OnPathSelected( wxCommandEvent& event ); - void OnPathActivated( wxCommandEvent& event ); - void OnMenu( wxMouseEvent& event ); - - void OnRemoveEntry(wxCommandEvent &e); - -public: - /** Constructor */ - SvnSelectLocalRepoDlg( wxWindow* parent, Subversion2* plugin, const wxString &curpath ); - virtual ~SvnSelectLocalRepoDlg() = default; - wxString GetPath() const; -}; - -#endif // __svn_select_local_repo_dlg__ +#ifndef __svn_select_local_repo_dlg__ +#define __svn_select_local_repo_dlg__ + +#include "subversion2_ui.h" + +class Subversion2; +class SvnSelectLocalRepoDlg : public SvnSelectLocalRepoBase +{ + Subversion2* m_svn; + +protected: + // Handlers for SvnSelectLocalRepoBase events. + void OnPathSelected(wxCommandEvent& event); + void OnPathActivated(wxCommandEvent& event); + void OnMenu(wxMouseEvent& event); + + void OnRemoveEntry(wxCommandEvent& e); + +public: + /** Constructor */ + SvnSelectLocalRepoDlg(wxWindow* parent, Subversion2* plugin, const wxString& curpath); + virtual ~SvnSelectLocalRepoDlg() = default; + wxString GetPath() const; +}; + +#endif // __svn_select_local_repo_dlg__ diff --git a/Subversion2/svn_sync_dialog.cpp b/Subversion2/svn_sync_dialog.cpp index 640fa746f2..b57af6d659 100644 --- a/Subversion2/svn_sync_dialog.cpp +++ b/Subversion2/svn_sync_dialog.cpp @@ -24,16 +24,15 @@ ////////////////////////////////////////////////////////////////////////////// #include "svn_sync_dialog.h" -#include -#include "subversion2.h" + #include "imanager.h" +#include "subversion2.h" #include "windowattrmanager.h" -SvnSyncDialog::SvnSyncDialog(wxWindow* parent, - Subversion2* plugin, - const wxString& rootDir, - bool excludeBin, - const wxString& excludeExtensions) +#include + +SvnSyncDialog::SvnSyncDialog( + wxWindow* parent, Subversion2* plugin, const wxString& rootDir, bool excludeBin, const wxString& excludeExtensions) : SvnSyncDialogBaseClass(parent) , m_plugin(plugin) , m_rootDir(rootDir) @@ -57,7 +56,7 @@ void SvnSyncDialog::UpdateUrl(const wxString& rootDir) m_plugin->DoGetSvnInfoSync(svnInfo, rootDir); wxString textLine(_("Root URL: ")); - if(svnInfo.m_sourceUrl.IsEmpty()) { + if (svnInfo.m_sourceUrl.IsEmpty()) { textLine += _(""); } else { textLine += svnInfo.m_sourceUrl; diff --git a/Subversion2/svn_sync_dialog.h b/Subversion2/svn_sync_dialog.h index 9160c57323..affa7ec6ca 100644 --- a/Subversion2/svn_sync_dialog.h +++ b/Subversion2/svn_sync_dialog.h @@ -23,42 +23,41 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef __svn_sync_dialog__ -#define __svn_sync_dialog__ - -#include "subversion2_ui.h" -#include "wxcrafter.h" - -class Subversion2; -class SvnSyncDialog : public SvnSyncDialogBaseClass -{ - Subversion2 *m_plugin; -private: - void UpdateUrl(const wxString& rootDir); - -protected: - virtual void OnOkUI(wxUpdateUIEvent& event); - virtual void OnButtonOK( wxCommandEvent& event ); - -public: - /** Constructor */ - SvnSyncDialog( wxWindow* parent, Subversion2 *plugin, const wxString& rootDir, bool excludeBin, const wxString& excludeExtensions ); - virtual ~SvnSyncDialog() = default; - - const wxString& GetRootDir() const { - return m_rootDir; - } - const wxString& GetExcludeExtensions() const { - return m_excludeExtensions; - } - bool GetExcludeBin() const { - return m_excludeBin; - } - -private: - wxString m_rootDir; - wxString m_excludeExtensions; - bool m_excludeBin; -}; - -#endif // __svn_sync_dialog__ +#ifndef __svn_sync_dialog__ +#define __svn_sync_dialog__ + +#include "subversion2_ui.h" +#include "wxcrafter.h" + +class Subversion2; +class SvnSyncDialog : public SvnSyncDialogBaseClass +{ + Subversion2* m_plugin; + +private: + void UpdateUrl(const wxString& rootDir); + +protected: + virtual void OnOkUI(wxUpdateUIEvent& event); + virtual void OnButtonOK(wxCommandEvent& event); + +public: + /** Constructor */ + SvnSyncDialog(wxWindow* parent, + Subversion2* plugin, + const wxString& rootDir, + bool excludeBin, + const wxString& excludeExtensions); + virtual ~SvnSyncDialog() = default; + + const wxString& GetRootDir() const { return m_rootDir; } + const wxString& GetExcludeExtensions() const { return m_excludeExtensions; } + bool GetExcludeBin() const { return m_excludeBin; } + +private: + wxString m_rootDir; + wxString m_excludeExtensions; + bool m_excludeBin; +}; + +#endif // __svn_sync_dialog__ diff --git a/Subversion2/svnblameeditor.cpp b/Subversion2/svnblameeditor.cpp index e1347834bd..5e8a3d42f2 100644 --- a/Subversion2/svnblameeditor.cpp +++ b/Subversion2/svnblameeditor.cpp @@ -1,48 +1,48 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2014 Eran Ifrah -// file name : svnblameeditor.cpp -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2014 Eran Ifrah +// file name : svnblameeditor.cpp +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #include "svnblameeditor.h" -#include -#include + #include "drawingutils.h" + #include -#include #include +#include #include +#include +#include BEGIN_EVENT_TABLE(SvnBlameEditor, wxStyledTextCtrl) - EVT_CONTEXT_MENU(SvnBlameEditor::OnContextMenu) +EVT_CONTEXT_MENU(SvnBlameEditor::OnContextMenu) END_EVENT_TABLE() #define MARGIN_STYLE_START 48 #define MARGIN_FIRST_STYLE 49 -SvnBlameEditor::SvnBlameEditor(wxWindow *parent, wxWindowID id, - const wxPoint& pos, - const wxSize& size, long style, - const wxString& name) +SvnBlameEditor::SvnBlameEditor( + wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxStyledTextCtrl(parent, id, pos, size, style, name) { Initialize(); @@ -51,24 +51,24 @@ SvnBlameEditor::SvnBlameEditor(wxWindow *parent, wxWindowID id, void SvnBlameEditor::Initialize() { // Initialize some styles - SetMarginType (0, wxSTC_MARGIN_TEXT ); - SetMarginType (1, wxSTC_MARGIN_NUMBER); - SetMarginWidth(1, 4 + 5*TextWidth(wxSTC_STYLE_LINENUMBER, wxT("9"))); + SetMarginType(0, wxSTC_MARGIN_TEXT); + SetMarginType(1, wxSTC_MARGIN_NUMBER); + SetMarginWidth(1, 4 + 5 * TextWidth(wxSTC_STYLE_LINENUMBER, wxT("9"))); SetMarginWidth(2, 0); SetMarginWidth(3, 0); SetMarginWidth(4, 0); SetTabWidth(4); - + // Define some colors to use - StyleSetBackground(MARGIN_STYLE_START + 1, DrawingUtils::LightColour(wxT("GREEN"), 7.0)); - StyleSetBackground(MARGIN_STYLE_START + 2, DrawingUtils::LightColour(wxT("BLUE"), 7.0)); - StyleSetBackground(MARGIN_STYLE_START + 3, DrawingUtils::LightColour(wxT("ORANGE"), 7.0)); - StyleSetBackground(MARGIN_STYLE_START + 4, DrawingUtils::LightColour(wxT("YELLOW"), 7.0)); - StyleSetBackground(MARGIN_STYLE_START + 5, DrawingUtils::LightColour(wxT("PURPLE"), 7.0)); - StyleSetBackground(MARGIN_STYLE_START + 6, DrawingUtils::LightColour(wxT("RED"), 7.0)); - StyleSetBackground(MARGIN_STYLE_START + 7, DrawingUtils::LightColour(wxT("BROWN"), 7.0)); - StyleSetBackground(MARGIN_STYLE_START + 8, DrawingUtils::LightColour(wxT("LIGHT GREY"), 7.0)); - StyleSetBackground(MARGIN_STYLE_START + 9, DrawingUtils::LightColour(wxT("SIENNA"), 7.0)); + StyleSetBackground(MARGIN_STYLE_START + 1, DrawingUtils::LightColour(wxT("GREEN"), 7.0)); + StyleSetBackground(MARGIN_STYLE_START + 2, DrawingUtils::LightColour(wxT("BLUE"), 7.0)); + StyleSetBackground(MARGIN_STYLE_START + 3, DrawingUtils::LightColour(wxT("ORANGE"), 7.0)); + StyleSetBackground(MARGIN_STYLE_START + 4, DrawingUtils::LightColour(wxT("YELLOW"), 7.0)); + StyleSetBackground(MARGIN_STYLE_START + 5, DrawingUtils::LightColour(wxT("PURPLE"), 7.0)); + StyleSetBackground(MARGIN_STYLE_START + 6, DrawingUtils::LightColour(wxT("RED"), 7.0)); + StyleSetBackground(MARGIN_STYLE_START + 7, DrawingUtils::LightColour(wxT("BROWN"), 7.0)); + StyleSetBackground(MARGIN_STYLE_START + 8, DrawingUtils::LightColour(wxT("LIGHT GREY"), 7.0)); + StyleSetBackground(MARGIN_STYLE_START + 9, DrawingUtils::LightColour(wxT("SIENNA"), 7.0)); StyleSetBackground(MARGIN_STYLE_START + 10, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); StyleSetForeground(MARGIN_STYLE_START + 10, wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); @@ -87,7 +87,7 @@ void SvnBlameEditor::SetText(const wxString& text) wxFont font(defFont.GetPointSize(), wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); wxArrayString lines = wxStringTokenize(text, wxT("\n"), wxTOKEN_RET_DELIMS); - for (size_t i=0; i (MARGIN_STYLE_START+9) ) + s_style++; + if (s_style > (MARGIN_STYLE_START + 9)) s_style = MARGIN_FIRST_STYLE; authorsColorsMap[author] = style; } @@ -129,7 +129,7 @@ void SvnBlameEditor::SetText(const wxString& text) // Keep the revision on in array BlameLineInfo info; info.revision = revision; - info.style = style; + info.style = style; m_lineInfo.push_back(info); } @@ -139,38 +139,41 @@ void SvnBlameEditor::SetText(const wxString& text) void SvnBlameEditor::OnContextMenu(wxContextMenuEvent& event) { - wxPoint pt = event.GetPosition(); + wxPoint pt = event.GetPosition(); wxPoint clientPt = ScreenToClient(pt); int margin = GetMarginWidth(0); // get the margin width - if ( clientPt.x < margin ) { + if (clientPt.x < margin) { - GotoPos( PositionFromPoint(clientPt) ); + GotoPos(PositionFromPoint(clientPt)); // Margin context menu wxMenu menu; - menu.Append( XRCID("svn_highlight_revision"), _("Highlight this revision"), _("Highlight this revision"), false); - menu.Connect(XRCID("svn_highlight_revision"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SvnBlameEditor::OnHighlightRevision), NULL, this); + menu.Append(XRCID("svn_highlight_revision"), _("Highlight this revision"), _("Highlight this revision"), false); + menu.Connect(XRCID("svn_highlight_revision"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(SvnBlameEditor::OnHighlightRevision), + NULL, + this); PopupMenu(&menu); } else { wxStyledTextCtrl::OnContextMenu(event); - } } void SvnBlameEditor::OnHighlightRevision(wxCommandEvent& event) { int line = GetCurrentLine(); - if(line < (int)m_lineInfo.size() && line >= 0) { + if (line < (int)m_lineInfo.size() && line >= 0) { - BlameLineInfo info = m_lineInfo.at(line); - wxString revision = info.revision; + BlameLineInfo info = m_lineInfo.at(line); + wxString revision = info.revision; // Loop over the lines and adjust the styles - for(size_t i=0; i SvnCommand::SvnCommand(Subversion2* plugin) @@ -44,11 +46,13 @@ SvnCommand::SvnCommand(Subversion2* plugin) SvnCommand::~SvnCommand() { ClearAll(); } -bool SvnCommand::Execute(const wxString& command, const wxString& workingDirectory, SvnCommandHandler* handler, +bool SvnCommand::Execute(const wxString& command, + const wxString& workingDirectory, + SvnCommandHandler* handler, Subversion2* plugin) { // Don't run 2 commands at the same time - if(m_process) { + if (m_process) { wxDELETE(handler); return false; } @@ -63,7 +67,7 @@ bool SvnCommand::Execute(const wxString& command, const wxString& workingDirecto EnvSetter env(m_plugin->GetManager()->GetEnv(), useOverrideMap ? &om : NULL); m_process = CreateAsyncProcess(this, command, IProcessCreateDefault | IProcessWrapInShell, workingDirectory); - if(!m_process) { + if (!m_process) { return false; } m_workingDirectory = workingDirectory.c_str(); @@ -80,14 +84,14 @@ void SvnCommand::OnProcessOutput(clProcessEvent& event) void SvnCommand::OnProcessTerminated(clProcessEvent& event) { - if(m_handler) { + if (m_handler) { LOG_IF_TRACE { clDEBUG1() << "Subversion:" << m_output << clEndl; } - if(m_handler->TestLoginRequired(m_output)) { + if (m_handler->TestLoginRequired(m_output)) { // re-issue the last command but this time with login dialog m_handler->GetPlugin()->GetConsole()->AppendText(_("Authentication failed. Retrying...\n")); m_handler->ProcessLoginRequired(m_workingDirectory); - } else if(m_handler->TestVerificationFailed(m_output)) { + } else if (m_handler->TestVerificationFailed(m_output)) { m_handler->GetPlugin()->GetConsole()->AppendText( _("Server certificate verification failed. Retrying...\n")); m_handler->ProcessVerificationRequired(); diff --git a/Subversion2/svncommandhandler.cpp b/Subversion2/svncommandhandler.cpp index 92e0da02b0..a993ae29ad 100644 --- a/Subversion2/svncommandhandler.cpp +++ b/Subversion2/svncommandhandler.cpp @@ -27,8 +27,8 @@ #include "AsyncProcess/asyncprocess.h" -void SvnCommandHandler::OnProcessOutput(IProcess *process, const wxString& output) +void SvnCommandHandler::OnProcessOutput(IProcess* process, const wxString& output) { - wxUnusedVar(process); - wxUnusedVar(output); + wxUnusedVar(process); + wxUnusedVar(output); } diff --git a/Subversion2/svncommandhandler.h b/Subversion2/svncommandhandler.h index 7ffef215b9..6daa08e4b2 100644 --- a/Subversion2/svncommandhandler.h +++ b/Subversion2/svncommandhandler.h @@ -26,10 +26,11 @@ #ifndef SVNCOMMANDHANDLER_H #define SVNCOMMANDHANDLER_H -#include +#include "file_logger.h" + #include #include -#include "file_logger.h" +#include class Subversion2; class IManager; @@ -71,8 +72,8 @@ class SvnCommandHandler wxString svnOutput(output); svnOutput.MakeLower(); - if(svnOutput.Contains(wxT("could not authenticate to server")) || - svnOutput.Contains(wxT(": authorization failed"))) { + if (svnOutput.Contains(wxT("could not authenticate to server")) || + svnOutput.Contains(wxT(": authorization failed"))) { // failed to login... return true; } @@ -83,7 +84,7 @@ class SvnCommandHandler { wxString svnOutput(output); svnOutput.MakeLower(); - if(svnOutput.Contains(wxT("certificate verification failed"))) { + if (svnOutput.Contains(wxT("certificate verification failed"))) { // failed to login... return true; } @@ -96,7 +97,7 @@ class SvnCommandHandler { wxString svnOutput(output); svnOutput.MakeLower(); - if(svnOutput.Contains(wxT("(r)eject, accept (t)emporarily or accept (p)ermanently"))) { + if (svnOutput.Contains(wxT("(r)eject, accept (t)emporarily or accept (p)ermanently"))) { // failed to login... return true; } @@ -116,7 +117,7 @@ class SvnCommandHandler */ virtual void ProcessLoginRequired(const wxString& workingDirectory) { - if((m_commandId != wxNOT_FOUND) && m_owner) { + if ((m_commandId != wxNOT_FOUND) && m_owner) { int eventId(m_commandId); wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, eventId); @@ -135,7 +136,7 @@ class SvnCommandHandler */ virtual void ProcessLoginRequiredForURL(const wxString& url) { - if(m_commandId != wxNOT_FOUND && m_owner) { + if (m_commandId != wxNOT_FOUND && m_owner) { int eventId(m_commandId); wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, eventId); @@ -147,10 +148,10 @@ class SvnCommandHandler m_owner->AddPendingEvent(event); } else { - if(m_commandId == wxNOT_FOUND) { + if (m_commandId == wxNOT_FOUND) { clLogMessage(wxT("svn: ProcessLoginRequired: passed m_commandId = wxNOT_FOUND")); - } else if(m_owner == NULL) { + } else if (m_owner == NULL) { clLogMessage(wxT("svn: ProcessLoginRequired: passed NULL m_owner")); } } @@ -162,7 +163,7 @@ class SvnCommandHandler */ virtual void ProcessVerificationRequired() { - if(m_commandId != wxNOT_FOUND && m_owner) { + if (m_commandId != wxNOT_FOUND && m_owner) { int eventId(m_commandId); wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, eventId); event.SetInt(INTERACTIVE_MODE); diff --git a/Subversion2/svninfo.h b/Subversion2/svninfo.h index 7075185cd0..be6944b566 100644 --- a/Subversion2/svninfo.h +++ b/Subversion2/svninfo.h @@ -31,15 +31,15 @@ class SvnInfo { public: - wxString m_url; - wxString m_sourceUrl; - wxString m_revision; - wxString m_author; - wxString m_date; + wxString m_url; + wxString m_sourceUrl; + wxString m_revision; + wxString m_author; + wxString m_date; public: - SvnInfo() {} - ~SvnInfo() {} + SvnInfo() {} + ~SvnInfo() {} }; #endif // SVNINFO_H diff --git a/Subversion2/svnsettingsdata.h b/Subversion2/svnsettingsdata.h index ce1828d7bd..99c316139f 100644 --- a/Subversion2/svnsettingsdata.h +++ b/Subversion2/svnsettingsdata.h @@ -26,8 +26,9 @@ #ifndef SVNSETTINGSDATA_H #define SVNSETTINGSDATA_H -#include "serialized_object.h" // Base class #include "Notebook.h" +#include "serialized_object.h" // Base class + #include enum SvnSettingsDataFlags { diff --git a/Subversion2/svnstatushandler.cpp b/Subversion2/svnstatushandler.cpp index 118f1ad9b6..87e7b983d6 100644 --- a/Subversion2/svnstatushandler.cpp +++ b/Subversion2/svnstatushandler.cpp @@ -24,13 +24,14 @@ ////////////////////////////////////////////////////////////////////////////// #include "svnstatushandler.h" -#include "svn_console.h" -#include "subversion_view.h" + #include "subversion2.h" +#include "subversion_view.h" +#include "svn_console.h" #include "svnxml.h" -SvnStatusHandler::SvnStatusHandler(Subversion2* plugin, int commandId, wxEvtHandler* owner, bool fileExplorerOnly, - const wxString& rootDir) +SvnStatusHandler::SvnStatusHandler( + Subversion2* plugin, int commandId, wxEvtHandler* owner, bool fileExplorerOnly, const wxString& rootDir) : SvnCommandHandler(plugin, commandId, owner) , m_fileExplorerOnly(fileExplorerOnly) , m_rootDir(rootDir) @@ -40,8 +41,8 @@ SvnStatusHandler::SvnStatusHandler(Subversion2* plugin, int commandId, wxEvtHand void SvnStatusHandler::Process(const wxString& output) { wxArrayString modFiles, conflictedFiles, unversionedFiles, newFiles, deletedFiles, lockedFiles, ignoredFiles; - SvnXML::GetFiles(output, modFiles, conflictedFiles, unversionedFiles, newFiles, deletedFiles, lockedFiles, - ignoredFiles); + SvnXML::GetFiles( + output, modFiles, conflictedFiles, unversionedFiles, newFiles, deletedFiles, lockedFiles, ignoredFiles); modFiles.Sort(); conflictedFiles.Sort(); @@ -50,6 +51,13 @@ void SvnStatusHandler::Process(const wxString& output) deletedFiles.Sort(); lockedFiles.Sort(); ignoredFiles.Sort(); - GetPlugin()->GetSvnView()->UpdateTree(modFiles, conflictedFiles, unversionedFiles, newFiles, deletedFiles, - lockedFiles, ignoredFiles, m_fileExplorerOnly, m_rootDir); + GetPlugin()->GetSvnView()->UpdateTree(modFiles, + conflictedFiles, + unversionedFiles, + newFiles, + deletedFiles, + lockedFiles, + ignoredFiles, + m_fileExplorerOnly, + m_rootDir); } diff --git a/Subversion2/svnstatushandler.h b/Subversion2/svnstatushandler.h index ca654e9a77..201fe69014 100644 --- a/Subversion2/svnstatushandler.h +++ b/Subversion2/svnstatushandler.h @@ -37,7 +37,10 @@ class SvnStatusHandler : public SvnCommandHandler wxString m_rootDir; public: - SvnStatusHandler(Subversion2* plugin, int commandId, wxEvtHandler* owner, bool fileExplorerOnly = false, + SvnStatusHandler(Subversion2* plugin, + int commandId, + wxEvtHandler* owner, + bool fileExplorerOnly = false, const wxString& rootDir = wxT("")); virtual ~SvnStatusHandler() = default; diff --git a/Subversion2/svntreedata.h b/Subversion2/svntreedata.h index a60b5b65a5..328b10413d 100644 --- a/Subversion2/svntreedata.h +++ b/Subversion2/svntreedata.h @@ -31,43 +31,35 @@ class SvnTreeData : public wxTreeItemData { public: - enum SvnNodeType { - SvnNodeTypeInvalid = -1, - SvnNodeTypeRoot, - SvnNodeTypeModifiedRoot, - SvnNodeTypeUnversionedRoot, - SvnNodeTypeDeletedRoot, - SvnNodeTypeAddedRoot, - SvnNodeTypeConflictRoot, - SvnNodeTypeFile, - SvnNodeTypeLockedRoot, - SvnNodeTypeFolder - }; + enum SvnNodeType { + SvnNodeTypeInvalid = -1, + SvnNodeTypeRoot, + SvnNodeTypeModifiedRoot, + SvnNodeTypeUnversionedRoot, + SvnNodeTypeDeletedRoot, + SvnNodeTypeAddedRoot, + SvnNodeTypeConflictRoot, + SvnNodeTypeFile, + SvnNodeTypeLockedRoot, + SvnNodeTypeFolder + }; - SvnNodeType m_type; - wxString m_filepath; + SvnNodeType m_type; + wxString m_filepath; public: - SvnTreeData(SvnNodeType type, const wxString &filepath) - : m_type(type) - , m_filepath(filepath) { - } + SvnTreeData(SvnNodeType type, const wxString& filepath) + : m_type(type) + , m_filepath(filepath) + { + } - virtual ~SvnTreeData() { - } + virtual ~SvnTreeData() {} - void SetType(const SvnNodeType& type) { - this->m_type = type; - } - const SvnNodeType& GetType() const { - return m_type; - } - void SetFilepath(const wxString& filepath) { - this->m_filepath = filepath; - } - const wxString& GetFilepath() const { - return m_filepath; - } + void SetType(const SvnNodeType& type) { this->m_type = type; } + const SvnNodeType& GetType() const { return m_type; } + void SetFilepath(const wxString& filepath) { this->m_filepath = filepath; } + const wxString& GetFilepath() const { return m_filepath; } }; #endif // SVNTREEDATA_H diff --git a/Subversion2/svnxml.cpp b/Subversion2/svnxml.cpp index f9119a31d4..7a3f42a7a2 100644 --- a/Subversion2/svnxml.cpp +++ b/Subversion2/svnxml.cpp @@ -32,9 +32,14 @@ #include #include -void SvnXML::GetFiles(const wxString& input, wxArrayString& modifiedFiles, wxArrayString& conflictedFiles, - wxArrayString& unversionedFiles, wxArrayString& newFiles, wxArrayString& deletedFiles, - wxArrayString& lockedFiles, wxArrayString& ignoredFiles) +void SvnXML::GetFiles(const wxString& input, + wxArrayString& modifiedFiles, + wxArrayString& conflictedFiles, + wxArrayString& unversionedFiles, + wxArrayString& newFiles, + wxArrayString& deletedFiles, + wxArrayString& lockedFiles, + wxArrayString& ignoredFiles) { // First column information: // @@ -62,9 +67,9 @@ void SvnXML::GetFiles(const wxString& input, wxArrayString& modifiedFiles, wxArr // 'B' not locked in repository, lock token present but Broken // wxArrayString lines = wxStringTokenize(input, wxT("\n\r"), wxTOKEN_STRTOK); - for(size_t i = 0; i < lines.GetCount(); i++) { + for (size_t i = 0; i < lines.GetCount(); i++) { wxString statusLine = lines.Item(i).Trim(); - if(statusLine.Len() < 7) { + if (statusLine.Len() < 7) { continue; } @@ -73,7 +78,7 @@ void SvnXML::GetFiles(const wxString& input, wxArrayString& modifiedFiles, wxArr wxChar ch1 = statusLine.GetChar(0); wxChar ch6 = statusLine.GetChar(5); - switch(ch1) { + switch (ch1) { case 'I': ignoredFiles.Add(filename); break; @@ -96,7 +101,7 @@ void SvnXML::GetFiles(const wxString& input, wxArrayString& modifiedFiles, wxArr break; } - switch(ch6) { + switch (ch6) { case 'K': lockedFiles.Add(filename); break; @@ -112,17 +117,17 @@ void SvnXML::GetFiles(const wxString& input, wxArrayString& modifiedFiles, wxArr void SvnXML::GetSvnInfo(const wxString& input, SvnInfo& svnInfo) { int start = input.Find(""); - if(start == wxNOT_FOUND) + if (start == wxNOT_FOUND) return; wxStringInputStream stream(input); wxXmlDocument doc(stream); - if(!doc.IsOk()) { + if (!doc.IsOk()) { return; } wxXmlNode* root = doc.GetRoot(); - if(root) { + if (root) { wxXmlNode* node = root->GetChildren(); // in newer versions of svn, there is another top level child named // @@ -130,36 +135,36 @@ void SvnXML::GetSvnInfo(const wxString& input, SvnInfo& svnInfo) // node = node->GetChildren(); //} - while(node) { - if(node->GetName() == wxT("entry")) { + while (node) { + if (node->GetName() == wxT("entry")) { node->GetAttribute(wxT("revision"), &svnInfo.m_revision); // Look for the URL wxXmlNode* child = node->GetChildren(); - while(child) { - if(child->GetName() == wxT("url")) { + while (child) { + if (child->GetName() == wxT("url")) { svnInfo.m_sourceUrl = child->GetNodeContent(); } // Last commit info - if(child->GetName() == wxT("commit")) { + if (child->GetName() == wxT("commit")) { wxXmlNode* gchild = child->GetChildren(); - while(gchild) { - if(gchild->GetName() == wxT("author")) { + while (gchild) { + if (gchild->GetName() == wxT("author")) { svnInfo.m_author = gchild->GetNodeContent(); } - if(gchild->GetName() == wxT("date")) { + if (gchild->GetName() == wxT("date")) { svnInfo.m_date = gchild->GetNodeContent(); } gchild = gchild->GetNext(); } } - if(child->GetName() == wxT("repository")) { + if (child->GetName() == wxT("repository")) { wxXmlNode* gchild = child->GetChildren(); - while(gchild) { - if(gchild->GetName() == wxT("root")) { + while (gchild) { + if (gchild->GetName() == wxT("root")) { svnInfo.m_url = gchild->GetNodeContent(); break; } diff --git a/Subversion2/svnxml.h b/Subversion2/svnxml.h index e4f9752015..8e6edae188 100644 --- a/Subversion2/svnxml.h +++ b/Subversion2/svnxml.h @@ -27,18 +27,25 @@ #include "svninfo.h" -#include #include +#include class SvnXML { public: - SvnXML() = default; - ~SvnXML() = default; + SvnXML() = default; + ~SvnXML() = default; - static void GetFiles(const wxString& input, wxArrayString& modifiedFiles, wxArrayString& conflictedFiles, wxArrayString& unversionedFiles, wxArrayString& newFiles, wxArrayString& deletedFiles, wxArrayString& lockedFiles, wxArrayString& ignoredFiles); + static void GetFiles(const wxString& input, + wxArrayString& modifiedFiles, + wxArrayString& conflictedFiles, + wxArrayString& unversionedFiles, + wxArrayString& newFiles, + wxArrayString& deletedFiles, + wxArrayString& lockedFiles, + wxArrayString& ignoredFiles); - static void GetSvnInfo(const wxString& input, SvnInfo &svnInfo); + static void GetSvnInfo(const wxString& input, SvnInfo& svnInfo); }; -#endif //SVNXMLPARSER_H +#endif // SVNXMLPARSER_H diff --git a/Subversion2/workspacesvnsettings.cpp b/Subversion2/workspacesvnsettings.cpp index 6134a25f99..d27db58d97 100644 --- a/Subversion2/workspacesvnsettings.cpp +++ b/Subversion2/workspacesvnsettings.cpp @@ -24,9 +24,10 @@ ////////////////////////////////////////////////////////////////////////////// #include "workspacesvnsettings.h" + +#include "cl_config.h" #include "cl_standard_paths.h" #include "workspace.h" -#include "cl_config.h" WorkspaceSvnSettings::WorkspaceSvnSettings() : clConfigItem("svn-settings") @@ -39,10 +40,7 @@ WorkspaceSvnSettings::WorkspaceSvnSettings(const wxFileName& fn) { } -void WorkspaceSvnSettings::FromJSON(const JSONItem& json) -{ - m_repoPath = json.namedObject("m_repoPath").toString(); -} +void WorkspaceSvnSettings::FromJSON(const JSONItem& json) { m_repoPath = json.namedObject("m_repoPath").toString(); } JSONItem WorkspaceSvnSettings::ToJSON() const { @@ -66,7 +64,7 @@ void WorkspaceSvnSettings::Save() wxFileName WorkspaceSvnSettings::GetLocalConfigFile() const { - if ( m_workspaceFileName.IsOk() && m_workspaceFileName.Exists() ) { + if (m_workspaceFileName.IsOk() && m_workspaceFileName.Exists()) { wxFileName fn(m_workspaceFileName.GetPath(), "subversion.conf"); fn.AppendDir(".codelite"); return fn; @@ -75,8 +73,5 @@ wxFileName WorkspaceSvnSettings::GetLocalConfigFile() const wxFileName fn(clStandardPaths::Get().GetUserDataDir(), "subversion.conf"); fn.AppendDir("config"); return fn; - } } - - diff --git a/Subversion2/workspacesvnsettings.h b/Subversion2/workspacesvnsettings.h index 03dcd6b571..2277c5e1e6 100644 --- a/Subversion2/workspacesvnsettings.h +++ b/Subversion2/workspacesvnsettings.h @@ -32,7 +32,7 @@ class WorkspaceSvnSettings : public clConfigItem { wxString m_repoPath; wxFileName m_workspaceFileName; - + public: WorkspaceSvnSettings(const wxFileName& fn); WorkspaceSvnSettings(); @@ -45,12 +45,8 @@ class WorkspaceSvnSettings : public clConfigItem WorkspaceSvnSettings& Load(); void Save(); - void SetRepoPath(const wxString& repoPath) { - this->m_repoPath = repoPath; - } - const wxString& GetRepoPath() const { - return m_repoPath; - } + void SetRepoPath(const wxString& repoPath) { this->m_repoPath = repoPath; } + const wxString& GetRepoPath() const { return m_repoPath; } wxFileName GetLocalConfigFile() const; }; diff --git a/Tail/TailFrame.cpp b/Tail/TailFrame.cpp index 5e07c07cbd..75b20d1672 100644 --- a/Tail/TailFrame.cpp +++ b/Tail/TailFrame.cpp @@ -1,4 +1,5 @@ #include "TailFrame.h" + #include "TailPanel.h" #include "codelite_events.h" #include "event_notifier.h" diff --git a/Tail/tail.cpp b/Tail/tail.cpp index 20de1aab85..fa87e59589 100644 --- a/Tail/tail.cpp +++ b/Tail/tail.cpp @@ -9,10 +9,7 @@ #include // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new Tail(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new Tail(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -41,7 +38,7 @@ Tail::Tail(IManager* manager) void Tail::OnInitDone(wxCommandEvent& event) { event.Skip(); - if(clConfig::Get().Read("force-show-tail-tab", true)) { + if (clConfig::Get().Read("force-show-tail-tab", true)) { clCommandEvent eventShow(wxEVT_SHOW_OUTPUT_TAB); eventShow.SetSelected(true).SetString("Tail"); EventNotifier::Get()->AddPendingEvent(eventShow); @@ -61,11 +58,11 @@ void Tail::UnPlug() // Remove our tab m_tabHelper.reset(); // before this plugin is un-plugged we must remove the tab we added - if(m_view && !m_view->IsDetached()) { + if (m_view && !m_view->IsDetached()) { DoDetachWindow(); m_view->Destroy(); m_view = NULL; - } else if(m_view && m_view->GetFrame()) { + } else if (m_view && m_view->GetFrame()) { m_view->GetFrame()->Destroy(); m_view->SetFrame(NULL); } @@ -97,7 +94,7 @@ void Tail::InitTailWindow(wxWindow* parent, bool isNotebook, const TailData& d, TailPanel* tmpView = new TailPanel(parent, this); tmpView->Initialize(d); - if(m_view) { + if (m_view) { // copy the settinhs from the current view DoDetachWindow(); m_view->Destroy(); @@ -107,7 +104,7 @@ void Tail::InitTailWindow(wxWindow* parent, bool isNotebook, const TailData& d, // Hook our output-pane panel m_view = tmpView; m_editEventsHandler = std::make_unique(m_view->GetStc()); - if(isNotebook) { + if (isNotebook) { m_mgr->BookAddPage(PaneId::BOTTOM_BAR, m_view, "Tail"); } else { m_tabHelper.reset(); diff --git a/Tail/tail.h b/Tail/tail.h index 9f590dcc0c..9c9655fae8 100644 --- a/Tail/tail.h +++ b/Tail/tail.h @@ -1,10 +1,10 @@ #ifndef __Tail__ #define __Tail__ -#include "plugin.h" -#include "clTabTogglerHelper.h" -#include "clEditorEditEventsHandler.h" #include "TailData.h" +#include "clEditorEditEventsHandler.h" +#include "clTabTogglerHelper.h" +#include "plugin.h" class TailPanel; class TailFrame; @@ -20,7 +20,7 @@ class Tail : public IPlugin void OnInitDone(wxCommandEvent& event); void DoDetachWindow(); void InitTailWindow(wxWindow* parent, bool isNotebook, const TailData& d, bool selectPage); - + public: Tail(IManager* manager); ~Tail() override = default; @@ -29,12 +29,12 @@ class Tail : public IPlugin * @brief detach the tail window from the output notebook */ void DetachTailWindow(const TailData& d); - + /** * @brief dock the tail window back to the output notebook */ void DockTailWindow(const TailData& d); - + //-------------------------------------------- // Abstract methods //-------------------------------------------- @@ -48,7 +48,7 @@ class Tail : public IPlugin * @brief Unplug the plugin. Perform here any cleanup needed (e.g. unbind events, destroy allocated windows) */ void UnPlug() override; - + TailPanel* GetView() const { return m_view; } }; diff --git a/UnitTestCPP/newunittestdlg.h b/UnitTestCPP/newunittestdlg.h index f2b78e5a56..25796fe130 100644 --- a/UnitTestCPP/newunittestdlg.h +++ b/UnitTestCPP/newunittestdlg.h @@ -45,7 +45,7 @@ class NewUnitTestDlg : public NewUnitTestBaseDlg public: /** Constructor */ - NewUnitTestDlg(wxWindow* parent, UnitTestPP* plugin, IConfigTool *conf); + NewUnitTestDlg(wxWindow* parent, UnitTestPP* plugin, IConfigTool* conf); virtual ~NewUnitTestDlg() = default; wxString GetTestName() { return m_textCtrlTestName->GetValue(); } diff --git a/UnitTestCPP/testclassdlg.cpp b/UnitTestCPP/testclassdlg.cpp index 52026ef2e1..f0038138bf 100644 --- a/UnitTestCPP/testclassdlg.cpp +++ b/UnitTestCPP/testclassdlg.cpp @@ -23,13 +23,15 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// +#include "testclassdlg.h" + #include "ctags_manager.h" #include "globals.h" #include "imanager.h" #include "open_resource_dialog.h" -#include "testclassdlg.h" #include "unittestpp.h" #include "windowattrmanager.h" + #include #include #include @@ -42,7 +44,7 @@ TestClassDlg::TestClassDlg(wxWindow* parent, IManager* mgr, UnitTestPP* plugin) { TagEntryPtrVector_t tags; m_manager->GetTagsManager()->GetClasses(tags); - for(auto tag : tags) { + for (auto tag : tags) { m_tags[tag->GetName()].push_back(tag); } @@ -52,7 +54,7 @@ TestClassDlg::TestClassDlg(wxWindow* parent, IManager* mgr, UnitTestPP* plugin) m_choiceProjects->Append(project->GetName()); } - if(m_choiceProjects->IsEmpty() == false) { + if (m_choiceProjects->IsEmpty() == false) { m_choiceProjects->SetSelection(0); } ::clSetSmallDialogBestSizeAndPosition(this); @@ -60,9 +62,9 @@ TestClassDlg::TestClassDlg(wxWindow* parent, IManager* mgr, UnitTestPP* plugin) void TestClassDlg::OnUseActiveEditor(wxCommandEvent& event) { - if(event.IsChecked()) { + if (event.IsChecked()) { IEditor* editor = m_manager->GetActiveEditor(); - if(editor) { + if (editor) { m_textCtrlFileName->SetValue(editor->GetFileName().GetFullPath()); } m_textCtrlFileName->Enable(true); @@ -74,7 +76,7 @@ void TestClassDlg::OnUseActiveEditor(wxCommandEvent& event) void TestClassDlg::OnCheckAll(wxCommandEvent& e) { // check all items - for(unsigned int idx = 0; idx < m_checkListMethods->GetCount(); idx++) { + for (unsigned int idx = 0; idx < m_checkListMethods->GetCount(); idx++) { m_checkListMethods->Check(idx, true); } } @@ -82,15 +84,15 @@ void TestClassDlg::OnCheckAll(wxCommandEvent& e) void TestClassDlg::OnUnCheckAll(wxCommandEvent& e) { // check all items - for(unsigned int idx = 0; idx < m_checkListMethods->GetCount(); idx++) { + for (unsigned int idx = 0; idx < m_checkListMethods->GetCount(); idx++) { m_checkListMethods->Check(idx, false); } } wxArrayString TestClassDlg::GetTestsList() { wxArrayString results; - for(unsigned int idx = 0; idx < m_checkListMethods->GetCount(); idx++) { - if(m_checkListMethods->IsChecked(idx)) { + for (unsigned int idx = 0; idx < m_checkListMethods->GetCount(); idx++) { + if (m_checkListMethods->IsChecked(idx)) { wxString str = m_checkListMethods->GetString(idx); str = str.BeforeFirst(wxT('(')); @@ -107,7 +109,7 @@ void TestClassDlg::OnUseFixture(wxCommandEvent& e) { m_textCtrlFixtureName->Enab void TestClassDlg::OnButtonOk(wxCommandEvent& e) { // validate the class name - if(m_checkListMethods->GetCount() == 0) { + if (m_checkListMethods->GetCount() == 0) { wxMessageBox(_("There are no tests to generate"), wxT("CodeLite"), wxICON_WARNING | wxOK); return; } @@ -118,7 +120,7 @@ void TestClassDlg::OnShowClassListDialog(wxCommandEvent& e) { m_textCtrlClassName->SetFocus(); OpenResourceDialog dlg(m_manager->GetTheApp()->GetTopWindow(), m_manager, ""); - if(dlg.ShowModal() == wxID_OK && !dlg.GetSelections().empty()) { + if (dlg.ShowModal() == wxID_OK && !dlg.GetSelections().empty()) { OpenResourceDialogItemData* item = dlg.GetSelections().at(0); // do something with the selected text m_textCtrlClassName->SetValue(item->m_name); @@ -130,10 +132,11 @@ void TestClassDlg::OnShowClassListDialog(wxCommandEvent& e) void TestClassDlg::DoRefreshFunctions(bool repportError) { - if(m_tags.count(m_textCtrlClassName->GetValue()) == 0) { - if(repportError) { + if (m_tags.count(m_textCtrlClassName->GetValue()) == 0) { + if (repportError) { wxMessageBox(_("Could not find match for class '") + m_textCtrlClassName->GetValue() + wxT("'"), - wxT("CodeLite"), wxICON_WARNING | wxOK); + wxT("CodeLite"), + wxICON_WARNING | wxOK); } m_checkListMethods->Clear(); return; @@ -141,7 +144,7 @@ void TestClassDlg::DoRefreshFunctions(bool repportError) std::vector matches = m_tags[m_textCtrlClassName->GetValue()]; wxString theClass; - if(matches.size() == 1) { + if (matches.size() == 1) { // single match we are good theClass = matches.at(0)->GetPath(); } else { @@ -155,7 +158,7 @@ void TestClassDlg::DoRefreshFunctions(bool repportError) theClass = wxGetSingleChoice(_("Select class:"), _("Select class:"), choices, this); } - if(theClass.empty()) { // user clicked 'Cancel' + if (theClass.empty()) { // user clicked 'Cancel' return; } @@ -169,7 +172,7 @@ void TestClassDlg::DoRefreshFunctions(bool repportError) wxStringSet_t uniqueNames; wxArrayString methods; for (const auto& m : matches) { - if(uniqueNames.count(m->GetName()) == 0) { + if (uniqueNames.count(m->GetName()) == 0) { methods.push_back(m->GetName()); uniqueNames.insert(m->GetName()); } @@ -179,7 +182,7 @@ void TestClassDlg::DoRefreshFunctions(bool repportError) m_checkListMethods->Append(methods); // check all items - for(unsigned int idx = 0; idx < m_checkListMethods->GetCount(); ++idx) { + for (unsigned int idx = 0; idx < m_checkListMethods->GetCount(); ++idx) { m_checkListMethods->Check(idx, true); } } diff --git a/UnitTestCPP/unittestcppoutputparser.cpp b/UnitTestCPP/unittestcppoutputparser.cpp index 9593456035..40212a8ac0 100644 --- a/UnitTestCPP/unittestcppoutputparser.cpp +++ b/UnitTestCPP/unittestcppoutputparser.cpp @@ -57,13 +57,13 @@ void UnitTestCppOutputParser::Parse(TestSummary* summary) // group2: total number of tests static wxRegEx reErrorSummary(wxT("FAILURE: ([0-9]*) out of ([0-9]*) tests failed")); - for(size_t i = 0; i < m_output.GetCount(); i++) { + for (size_t i = 0; i < m_output.GetCount(); i++) { wxString line = m_output.Item(i); - if(reSuccess.IsValid()) { + if (reSuccess.IsValid()) { // if the Summary line is in the format of: Success! ,,, // nothing is left to be checked - if(reSuccess.Matches(m_output.Item(i))) { + if (reSuccess.Matches(m_output.Item(i))) { size_t len(0); size_t start(0); wxString match; @@ -87,7 +87,7 @@ void UnitTestCppOutputParser::Parse(TestSummary* summary) infoPattern.lineNumberIndex.ToCLong(&nLineIndex); ErrorLineInfo info; wxString lineNumber, filename; - if(re.Matches(line)) { + if (re.Matches(line)) { // found an error info.file = nFileIndex == wxNOT_FOUND ? "" : re.GetMatch(line, nFileIndex); info.line = nLineIndex == wxNOT_FOUND ? "" : re.GetMatch(line, nLineIndex); @@ -99,7 +99,7 @@ void UnitTestCppOutputParser::Parse(TestSummary* summary) } } - if(!isAndErrorLine) { + if (!isAndErrorLine) { for (const auto& infoPattern : vcErrors) { wxRegEx re(infoPattern.pattern, wxRE_ADVANCED | wxRE_ICASE); long nFileIndex = wxNOT_FOUND; @@ -108,7 +108,7 @@ void UnitTestCppOutputParser::Parse(TestSummary* summary) infoPattern.lineNumberIndex.ToCLong(&nLineIndex); ErrorLineInfo info; wxString lineNumber, filename; - if(re.Matches(line)) { + if (re.Matches(line)) { // found an error info.file = nFileIndex == wxNOT_FOUND ? "" : re.GetMatch(line, nFileIndex); info.line = nLineIndex == wxNOT_FOUND ? "" : re.GetMatch(line, nLineIndex); @@ -122,13 +122,13 @@ void UnitTestCppOutputParser::Parse(TestSummary* summary) } // if this line is an error line, continue - if(isAndErrorLine) { + if (isAndErrorLine) { continue; } // test for error summary line - if(reErrorSummary.IsValid()) { - if(reErrorSummary.Matches(m_output.Item(i))) { + if (reErrorSummary.IsValid()) { + if (reErrorSummary.Matches(m_output.Item(i))) { // increase the error count size_t len(0); size_t start(0); diff --git a/UnitTestCPP/unittestdata.cpp b/UnitTestCPP/unittestdata.cpp index f59f506f42..1ec7ba0e33 100644 --- a/UnitTestCPP/unittestdata.cpp +++ b/UnitTestCPP/unittestdata.cpp @@ -25,9 +25,5 @@ #include "unittestdata.h" -void UnitTestData::DeSerialize(Archive& arch) -{ -} -void UnitTestData::Serialize(Archive& arch) -{ -} +void UnitTestData::DeSerialize(Archive& arch) {} +void UnitTestData::Serialize(Archive& arch) {} diff --git a/UnitTestCPP/unittestdata.h b/UnitTestCPP/unittestdata.h index a1539fc92a..4fff257411 100644 --- a/UnitTestCPP/unittestdata.h +++ b/UnitTestCPP/unittestdata.h @@ -28,14 +28,15 @@ #include "serialized_object.h" -class UnitTestData : public SerializedObject { +class UnitTestData : public SerializedObject +{ public: - UnitTestData() = default; - ~UnitTestData() = default; + UnitTestData() = default; + ~UnitTestData() = default; public: - virtual void DeSerialize(Archive &arch); - virtual void Serialize(Archive &arch); + virtual void DeSerialize(Archive& arch); + virtual void Serialize(Archive& arch); }; #endif // __unittestdata__ diff --git a/UnitTestCPP/unittestpp.cpp b/UnitTestCPP/unittestpp.cpp index 097eae57a9..2987807246 100644 --- a/UnitTestCPP/unittestpp.cpp +++ b/UnitTestCPP/unittestpp.cpp @@ -53,13 +53,10 @@ bool IsSourceFile(const wxString& ext) { return ext == wxT("cpp") || ext == wxT("cxx") || ext == wxT("c") || ext == wxT("c++") || ext == wxT("cc"); } -} +} // namespace // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new UnitTestPP(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new UnitTestPP(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -78,13 +75,19 @@ UnitTestPP::UnitTestPP(IManager* manager) , m_proc(NULL) { // Connect the events to us - wxTheApp->Connect(XRCID("run_unit_tests"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(UnitTestPP::OnRunUnitTests), NULL, (wxEvtHandler*)this); - wxTheApp->Connect(XRCID("run_unit_tests"), wxEVT_UPDATE_UI, wxUpdateUIEventHandler(UnitTestPP::OnRunUnitTestsUI), - NULL, (wxEvtHandler*)this); - - EventNotifier::Get()->Connect(wxEVT_CMD_EXECUTE_ACTIVE_PROJECT, clExecuteEventHandler(UnitTestPP::OnRunProject), - NULL, this); + wxTheApp->Connect(XRCID("run_unit_tests"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(UnitTestPP::OnRunUnitTests), + NULL, + (wxEvtHandler*)this); + wxTheApp->Connect(XRCID("run_unit_tests"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(UnitTestPP::OnRunUnitTestsUI), + NULL, + (wxEvtHandler*)this); + + EventNotifier::Get()->Connect( + wxEVT_CMD_EXECUTE_ACTIVE_PROJECT, clExecuteEventHandler(UnitTestPP::OnRunProject), NULL, this); m_outputPage = new UnitTestsPage(m_mgr->BookGet(PaneId::BOTTOM_BAR), m_mgr); m_mgr->BookAddPage(PaneId::BOTTOM_BAR, m_outputPage, _("UnitTest++")); @@ -98,10 +101,10 @@ UnitTestPP::UnitTestPP(IManager* manager) Bind(wxEVT_ASYNC_PROCESS_TERMINATED, &UnitTestPP::OnProcessTerminated, this); clKeyboardManager::Get()->AddAccelerator(_("UnitTest++"), - { { "unittestpp_new_simple_test", _("Create new test...") }, - { "unittestpp_new_class_test", _("Create tests for class...") }, - { "mark_project_as_ut", _("Mark this project as UnitTest++ project") }, - { "run_unit_tests", _("Run Project as UnitTest++ and report") } }); + {{"unittestpp_new_simple_test", _("Create new test...")}, + {"unittestpp_new_class_test", _("Create tests for class...")}, + {"mark_project_as_ut", _("Mark this project as UnitTest++ project")}, + {"run_unit_tests", _("Run Project as UnitTest++ and report")}}); } void UnitTestPP::CreateToolBar(clToolBarGeneric* toolbar) @@ -109,7 +112,9 @@ void UnitTestPP::CreateToolBar(clToolBarGeneric* toolbar) int size = m_mgr->GetToolbarIconSize(); auto images = toolbar->GetBitmapsCreateIfNeeded(); - toolbar->AddTool(XRCID("run_unit_tests"), _("Run Unit tests..."), images->Add("ok", size), + toolbar->AddTool(XRCID("run_unit_tests"), + _("Run Unit tests..."), + images->Add("ok", size), _("Run project as unit test project...")); } @@ -120,12 +125,12 @@ void UnitTestPP::CreatePluginMenu(wxMenu* pluginsMenu) wxMenu* menu = new wxMenu(); wxMenuItem* item(NULL); - item = new wxMenuItem(menu, XRCID("unittestpp_new_simple_test"), _("Create new &test..."), wxEmptyString, - wxITEM_NORMAL); + item = new wxMenuItem( + menu, XRCID("unittestpp_new_simple_test"), _("Create new &test..."), wxEmptyString, wxITEM_NORMAL); menu->Append(item); - item = new wxMenuItem(menu, XRCID("unittestpp_new_class_test"), _("Create tests for &class..."), wxEmptyString, - wxITEM_NORMAL); + item = new wxMenuItem( + menu, XRCID("unittestpp_new_class_test"), _("Create tests for &class..."), wxEmptyString, wxITEM_NORMAL); menu->Append(item); menu->AppendSeparator(); @@ -133,19 +138,28 @@ void UnitTestPP::CreatePluginMenu(wxMenu* pluginsMenu) item = new wxMenuItem(menu, XRCID("mark_project_as_ut"), _("Mark this project as UnitTest++ project")); menu->Append(item); - item = new wxMenuItem(menu, XRCID("run_unit_tests"), _("Run Project as UnitTest++ and report"), wxEmptyString, - wxITEM_NORMAL); + item = new wxMenuItem( + menu, XRCID("run_unit_tests"), _("Run Project as UnitTest++ and report"), wxEmptyString, wxITEM_NORMAL); menu->Append(item); pluginsMenu->Append(wxID_ANY, _("UnitTest++"), menu); // connect the events - wxTheApp->Connect(XRCID("unittestpp_new_simple_test"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(UnitTestPP::OnNewSimpleTest), NULL, (wxEvtHandler*)this); - wxTheApp->Connect(XRCID("unittestpp_new_class_test"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(UnitTestPP::OnNewClassTest), NULL, (wxEvtHandler*)this); - wxTheApp->Connect(XRCID("mark_project_as_ut"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(UnitTestPP::OnMarkProjectAsUT), NULL, (wxEvtHandler*)this); + wxTheApp->Connect(XRCID("unittestpp_new_simple_test"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(UnitTestPP::OnNewSimpleTest), + NULL, + (wxEvtHandler*)this); + wxTheApp->Connect(XRCID("unittestpp_new_class_test"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(UnitTestPP::OnNewClassTest), + NULL, + (wxEvtHandler*)this); + wxTheApp->Connect(XRCID("mark_project_as_ut"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(UnitTestPP::OnMarkProjectAsUT), + NULL, + (wxEvtHandler*)this); EventNotifier::Get()->Bind(wxEVT_CONTEXT_MENU_EDITOR, &UnitTestPP::OnEditorContextMenu, this); } @@ -154,11 +168,17 @@ void UnitTestPP::UnPlug() m_tabHelper.reset(); // Connect the events to us - wxTheApp->Disconnect(XRCID("run_unit_tests"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(UnitTestPP::OnRunUnitTests), NULL, (wxEvtHandler*)this); - - wxTheApp->Disconnect(XRCID("run_unit_tests"), wxEVT_UPDATE_UI, wxUpdateUIEventHandler(UnitTestPP::OnRunUnitTestsUI), - NULL, (wxEvtHandler*)this); + wxTheApp->Disconnect(XRCID("run_unit_tests"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(UnitTestPP::OnRunUnitTests), + NULL, + (wxEvtHandler*)this); + + wxTheApp->Disconnect(XRCID("run_unit_tests"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(UnitTestPP::OnRunUnitTestsUI), + NULL, + (wxEvtHandler*)this); Unbind(wxEVT_ASYNC_PROCESS_OUTPUT, &UnitTestPP::OnProcessRead, this); Unbind(wxEVT_ASYNC_PROCESS_TERMINATED, &UnitTestPP::OnProcessTerminated, this); @@ -175,12 +195,12 @@ wxMenu* UnitTestPP::CreateEditorPopMenu() wxMenu* menu = new wxMenu(); wxMenuItem* item(NULL); - item = new wxMenuItem(menu, XRCID("unittestpp_new_simple_test"), _("Create new &test..."), wxEmptyString, - wxITEM_NORMAL); + item = new wxMenuItem( + menu, XRCID("unittestpp_new_simple_test"), _("Create new &test..."), wxEmptyString, wxITEM_NORMAL); menu->Append(item); - item = new wxMenuItem(menu, XRCID("unittestpp_new_class_test"), _("Create tests for &class..."), wxEmptyString, - wxITEM_NORMAL); + item = new wxMenuItem( + menu, XRCID("unittestpp_new_class_test"), _("Create tests for &class..."), wxEmptyString, wxITEM_NORMAL); menu->Append(item); return menu; @@ -190,11 +210,12 @@ void UnitTestPP::OnNewClassTest(wxCommandEvent& e) { wxUnusedVar(e); - if(GetUnitTestProjects().empty()) { - if(wxMessageBox( - wxString::Format( - _("There are currently no UnitTest project in your workspace\nWould you like to create one now?")), - wxT("CodeLite"), wxYES_NO | wxCANCEL) == wxYES) { + if (GetUnitTestProjects().empty()) { + if (wxMessageBox( + wxString::Format( + _("There are currently no UnitTest project in your workspace\nWould you like to create one now?")), + wxT("CodeLite"), + wxYES_NO | wxCANCEL) == wxYES) { // add new UnitTest project wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, XRCID("new_project")); m_mgr->GetTheApp()->GetTopWindow()->GetEventHandler()->AddPendingEvent(event); @@ -205,10 +226,10 @@ void UnitTestPP::OnNewClassTest(wxCommandEvent& e) // position has changed, compare line numbers wxString clsName; IEditor* editor = m_mgr->GetActiveEditor(); - if(editor) { + if (editor) { int line = editor->GetCurrentLine(); TagEntryPtr tag = m_mgr->GetTagsManager()->FunctionFromFileLine(editor->GetFileName(), line + 1); - if(tag && tag->GetScope().IsEmpty() == false && tag->GetScope() != "") { + if (tag && tag->GetScope().IsEmpty() == false && tag->GetScope() != "") { clsName = tag->GetScope(); } } @@ -216,7 +237,7 @@ void UnitTestPP::OnNewClassTest(wxCommandEvent& e) TestClassDlg dlg(m_mgr->GetTheApp()->GetTopWindow(), m_mgr, this); dlg.SetClassName(clsName); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxArrayString arr = dlg.GetTestsList(); wxString fixture = dlg.GetFixtureName(); wxString filename = dlg.GetFileName(); @@ -227,10 +248,10 @@ void UnitTestPP::OnNewClassTest(wxCommandEvent& e) fixture.Trim().Trim(false); ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(projectName, err_msg); - if(p) { + if (p) { // incase a relative path was given, use the selected project path fn = FindBestSourceFile(p, fn); - for(size_t i = 0; i < arr.GetCount(); i++) { + for (size_t i = 0; i < arr.GetCount(); i++) { // Construct the test name in the format of: // Test @@ -244,7 +265,7 @@ void UnitTestPP::OnNewClassTest(wxCommandEvent& e) wxString testName; testName << "Test" << prefix; - if(!fixture.IsEmpty()) { + if (!fixture.IsEmpty()) { DoCreateFixtureTest(testName, fixture, projectName, fn.GetFullPath()); } else { DoCreateSimpleTest(testName, projectName, fn.GetFullPath()); @@ -258,11 +279,12 @@ void UnitTestPP::OnNewSimpleTest(wxCommandEvent& e) { wxUnusedVar(e); - if(GetUnitTestProjects().empty()) { - if(wxMessageBox( - wxString::Format( - _("There are currently no UnitTest project in your workspace\nWould you like to create one now?")), - wxT("CodeLite"), wxYES_NO | wxCANCEL) == wxYES) { + if (GetUnitTestProjects().empty()) { + if (wxMessageBox( + wxString::Format( + _("There are currently no UnitTest project in your workspace\nWould you like to create one now?")), + wxT("CodeLite"), + wxYES_NO | wxCANCEL) == wxYES) { // add new UnitTest project wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, XRCID("new_project")); m_mgr->GetTheApp()->GetTopWindow()->GetEventHandler()->AddPendingEvent(event); @@ -271,7 +293,7 @@ void UnitTestPP::OnNewSimpleTest(wxCommandEvent& e) } NewUnitTestDlg dlg(m_mgr->GetTheApp()->GetTopWindow(), this, m_mgr->GetConfigTool()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { // create the unit test wxString testName = dlg.GetTestName(); wxString fixture = dlg.GetFixtureName(); @@ -282,10 +304,10 @@ void UnitTestPP::OnNewSimpleTest(wxCommandEvent& e) wxFileName fn(filename); wxString err_msg; ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(projectName, err_msg); - if(p) { + if (p) { fn = FindBestSourceFile(p, fn); fixture.Trim().Trim(false); - if(!fixture.IsEmpty()) { + if (!fixture.IsEmpty()) { DoCreateFixtureTest(testName, fixture, projectName, fn.GetFullPath()); } else { DoCreateSimpleTest(testName, projectName, fn.GetFullPath()); @@ -294,7 +316,9 @@ void UnitTestPP::OnNewSimpleTest(wxCommandEvent& e) } } -void UnitTestPP::DoCreateFixtureTest(const wxString& name, const wxString& fixture, const wxString& projectName, +void UnitTestPP::DoCreateFixtureTest(const wxString& name, + const wxString& fixture, + const wxString& projectName, const wxString& filename) { wxString text; @@ -304,7 +328,7 @@ void UnitTestPP::DoCreateFixtureTest(const wxString& name, const wxString& fixtu text << "}\n"; IEditor* editor = DoAddTestFile(filename, projectName); - if(editor) { + if (editor) { editor->AppendText(text); } } @@ -314,7 +338,7 @@ void UnitTestPP::DoCreateSimpleTest(const wxString& name, const wxString& projec // try to locate the file wxString errMsg; ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(projectName, errMsg); - if(!proj) { + if (!proj) { // no such project! wxMessageBox(_("Could not find the target project"), wxT("CodeLite"), wxOK | wxICON_ERROR); return; @@ -327,7 +351,7 @@ void UnitTestPP::DoCreateSimpleTest(const wxString& name, const wxString& projec text << "{\n"; text << "}\n"; - if(editor) { + if (editor) { editor->AppendText(text); } } @@ -335,7 +359,7 @@ void UnitTestPP::DoCreateSimpleTest(const wxString& name, const wxString& projec void UnitTestPP::OnRunUnitTests(wxCommandEvent& e) { ProjectPtr p = m_mgr->GetSelectedProject(); - if(!p) { + if (!p) { return; } DoRunProject(p); @@ -344,7 +368,7 @@ void UnitTestPP::OnRunUnitTests(wxCommandEvent& e) void UnitTestPP::OnRunUnitTestsUI(wxUpdateUIEvent& e) { CHECK_CL_SHUTDOWN(); - if(m_proc) { + if (m_proc) { e.Enable(false); } else { @@ -358,10 +382,10 @@ std::vector UnitTestPP::GetUnitTestProjects() std::vector ut_projects; wxArrayString projects; m_mgr->GetWorkspace()->GetProjectList(projects); - for(size_t i = 0; i < projects.GetCount(); i++) { + for (size_t i = 0; i < projects.GetCount(); i++) { wxString err_msg; ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(projects.Item(i), err_msg); - if(proj && IsUnitTestProject(proj)) { + if (proj && IsUnitTestProject(proj)) { ut_projects.push_back(proj); } } @@ -370,7 +394,7 @@ std::vector UnitTestPP::GetUnitTestProjects() bool UnitTestPP::IsUnitTestProject(ProjectPtr p) { - if(!p) { + if (!p) { return false; } return p->GetProjectInternalType() == "UnitTest++"; @@ -380,11 +404,12 @@ IEditor* UnitTestPP::DoAddTestFile(const wxString& filename, const wxString& pro { // first open / create the target file wxFileName fn(filename); - if(wxFileName::FileExists(filename) == false) { + if (wxFileName::FileExists(filename) == false) { // the file does not exist! wxFFile file(filename, "wb"); - if(!file.IsOpened()) { - wxMessageBox(wxString::Format(_("Could not create target file '%s'"), filename.c_str()), wxT("CodeLite"), + if (!file.IsOpened()) { + wxMessageBox(wxString::Format(_("Could not create target file '%s'"), filename.c_str()), + wxT("CodeLite"), wxICON_WARNING | wxOK); return NULL; } @@ -399,7 +424,7 @@ IEditor* UnitTestPP::DoAddTestFile(const wxString& filename, const wxString& pro IEditor* editor(NULL); ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(projectName, errMsg); - if(proj) { + if (proj) { std::vector files; proj->GetFilesAsVectorOfFileName(files); @@ -409,7 +434,7 @@ IEditor* UnitTestPP::DoAddTestFile(const wxString& filename, const wxString& pro if (file == fn) { m_mgr->OpenFile(fn.GetFullPath()); editor = m_mgr->GetActiveEditor(); - if(editor && editor->GetFileName() == fn) { + if (editor && editor->GetFileName() == fn) { return editor; } else { return NULL; @@ -426,7 +451,7 @@ IEditor* UnitTestPP::DoAddTestFile(const wxString& filename, const wxString& pro // open the file m_mgr->OpenFile(fn.GetFullPath()); editor = m_mgr->GetActiveEditor(); - if(editor && editor->GetFileName() == fn) { + if (editor && editor->GetFileName() == fn) { return editor; } } @@ -435,7 +460,7 @@ IEditor* UnitTestPP::DoAddTestFile(const wxString& filename, const wxString& pro wxFileName UnitTestPP::FindBestSourceFile(ProjectPtr proj, const wxFileName& filename) { - if(filename.IsOk() == false) { + if (filename.IsOk() == false) { // no such file std::vector files; proj->GetFilesAsVectorOfFileName(files); @@ -453,7 +478,7 @@ wxFileName UnitTestPP::FindBestSourceFile(ProjectPtr proj, const wxFileName& fil wxFileName fn(proj->GetFileName()); fn.SetFullName("unit_tests.cpp"); return fn; - } else if(filename.IsAbsolute() == false) { + } else if (filename.IsAbsolute() == false) { // relative path was given, set the path to the project path wxFileName fn(filename); fn.SetPath(proj->GetFileName().GetPath()); @@ -466,7 +491,7 @@ wxFileName UnitTestPP::FindBestSourceFile(ProjectPtr proj, const wxFileName& fil void UnitTestPP::OnMarkProjectAsUT(wxCommandEvent& e) { ProjectPtr p = m_mgr->GetSelectedProject(); - if(!p) { + if (!p) { return; } @@ -487,7 +512,7 @@ void UnitTestPP::OnProcessTerminated(clProcessEvent& e) TestSummary summary; parser.Parse(&summary); - if(summary.totalTests == 0) { + if (summary.totalTests == 0) { ::wxMessageBox(_("Project contains 0 tests. Nothing to be done"), "CodeLite"); return; } @@ -516,17 +541,17 @@ void UnitTestPP::OnRunProject(clExecuteEvent& e) { e.Skip(); // Sanity - if(!clCxxWorkspaceST::Get()->IsOpen()) { + if (!clCxxWorkspaceST::Get()->IsOpen()) { return; } - if(e.GetTargetName().IsEmpty()) { + if (e.GetTargetName().IsEmpty()) { return; } ProjectPtr pProj = clCxxWorkspaceST::Get()->GetProject(e.GetTargetName()); CHECK_PTR_RET(pProj); - if(pProj->GetProjectInternalType() != "UnitTest++") { + if (pProj->GetProjectInternalType() != "UnitTest++") { return; } @@ -563,7 +588,7 @@ void UnitTestPP::OnEditorContextMenu(clContextMenuEvent& e) IEditor* editor = m_mgr->GetActiveEditor(); CHECK_PTR_RET(editor); - if(FileExtManager::IsCxxFile(editor->GetFileName())) { + if (FileExtManager::IsCxxFile(editor->GetFileName())) { e.GetMenu()->Append(wxID_ANY, "UnitTest++", CreateEditorPopMenu()); } } diff --git a/UnitTestCPP/unittestpp.h b/UnitTestCPP/unittestpp.h index 770e9ebb60..8f106cda36 100644 --- a/UnitTestCPP/unittestpp.h +++ b/UnitTestCPP/unittestpp.h @@ -26,12 +26,13 @@ #ifndef __UnitTestPP__ #define __UnitTestPP__ +#include "clTabTogglerHelper.h" +#include "cl_command_event.h" #include "plugin.h" -#include #include "project.h" + #include -#include "cl_command_event.h" -#include "clTabTogglerHelper.h" +#include class wxMenuItem; class IProcess; @@ -44,7 +45,7 @@ class UnitTestPP : public IPlugin wxString m_output; UnitTestsPage* m_outputPage; clTabTogglerHelper::Ptr_t m_tabHelper; - + public: UnitTestPP(IManager* manager); ~UnitTestPP() override = default; diff --git a/UnitTestCPP/unittestspage.cpp b/UnitTestCPP/unittestspage.cpp index e80a7e9704..f4caecda26 100644 --- a/UnitTestCPP/unittestspage.cpp +++ b/UnitTestCPP/unittestspage.cpp @@ -23,12 +23,14 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// +#include "unittestspage.h" + #include "event_notifier.h" #include "globals.h" #include "imanager.h" #include "plugin.h" -#include "unittestspage.h" #include "workspace.h" + #include class UTLineInfo : public wxClientData @@ -73,14 +75,14 @@ void UnitTestsPage::OnItemActivated(wxDataViewEvent& e) wxString proj = m_mgr->GetWorkspace()->GetActiveProjectName(); ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(proj, err_msg); - if(p) { + if (p) { cwd = p->GetFileName().GetPath(); } wxFileName fn(info->m_info.file); fn.MakeAbsolute(cwd); IEditor* editor = m_mgr->OpenFile(fn.GetFullPath(), wxEmptyString, (lineNumber - 1)); - if(editor) { + if (editor) { editor->SetActive(); } } @@ -106,7 +108,7 @@ void UnitTestsPage::Initialize(TestSummary* summary) msg << summary->totalTests - summary->errorCount; m_staticTextSuccessTestsNum->SetLabel(msg); - for(size_t i = 0; i < summary->errorLines.GetCount(); ++i) { + for (size_t i = 0; i < summary->errorLines.GetCount(); ++i) { const ErrorLineInfo& info = summary->errorLines.Item(i); wxVector cols; cols.push_back(info.file); @@ -118,7 +120,7 @@ void UnitTestsPage::Initialize(TestSummary* summary) void UnitTestsPage::Clear() { - for(size_t i = 0; i < m_dvListCtrlErrors->GetItemCount(); ++i) { + for (size_t i = 0; i < m_dvListCtrlErrors->GetItemCount(); ++i) { UTLineInfo* info = (UTLineInfo*)m_dvListCtrlErrors->GetItemData(m_dvListCtrlErrors->RowToItem(i)); wxDELETE(info); } diff --git a/WordCompletion/WordCompletionDictionary.cpp b/WordCompletion/WordCompletionDictionary.cpp index 08779a61ad..f8ddd7d871 100644 --- a/WordCompletion/WordCompletionDictionary.cpp +++ b/WordCompletion/WordCompletionDictionary.cpp @@ -1,10 +1,12 @@ #include "WordCompletionDictionary.h" -#include "event_notifier.h" + #include "codelite_events.h" -#include +#include "event_notifier.h" #include "globals.h" #include "ieditor.h" #include "imanager.h" + +#include #include WordCompletionDictionary::WordCompletionDictionary() @@ -70,7 +72,8 @@ void WordCompletionDictionary::OnSuggestThread(const WordCompletionThreadReply& { // Remove the current file's dictionary std::map::iterator iter = m_files.find(reply.filename.GetFullPath()); - if(iter != m_files.end()) m_files.erase(iter); + if (iter != m_files.end()) + m_files.erase(iter); // Keep the words m_files.insert(std::make_pair(reply.filename.GetFullPath(), reply.suggest)); @@ -88,17 +91,17 @@ void WordCompletionDictionary::DoCacheActiveEditor(bool overwrite) IEditor* activeEditor = ::clGetManager()->GetActiveEditor(); CHECK_PTR_RET(activeEditor); - if(!overwrite && m_files.count(activeEditor->GetFileName().GetFullPath())) + if (!overwrite && m_files.count(activeEditor->GetFileName().GetFullPath())) return; // we already have this file in the cache - + m_files.erase(activeEditor->GetFileName().GetFullPath()); - + // Insert a dummy entry, so we won't queue this file if not needed m_files.insert(std::make_pair(activeEditor->GetFileName().GetFullPath(), wxStringSet_t())); - + // Queue this file wxStyledTextCtrl* stc = activeEditor->GetCtrl(); - + // Invoke the thread to parse and suggest words for this file WordCompletionThreadRequest* req = new WordCompletionThreadRequest; req->buffer = stc->GetText(); diff --git a/WordCompletion/WordCompletionDictionary.h b/WordCompletion/WordCompletionDictionary.h index 21c31a294a..04c7535e54 100644 --- a/WordCompletion/WordCompletionDictionary.h +++ b/WordCompletion/WordCompletionDictionary.h @@ -26,12 +26,13 @@ #ifndef WORDCOMPLETIONDICTIONARY_H #define WORDCOMPLETIONDICTIONARY_H -#include "macros.h" -#include -#include -#include "WordCompletionThread.h" #include "WordCompletionRequestReply.h" +#include "WordCompletionThread.h" #include "cl_command_event.h" +#include "macros.h" + +#include +#include class WordCompletionDictionary : public wxEvtHandler { @@ -49,13 +50,13 @@ class WordCompletionDictionary : public wxEvtHandler public: WordCompletionDictionary(); virtual ~WordCompletionDictionary(); - + /** * @brief this function is called by the word completion thread when parsing phase is done * @param reply */ void OnSuggestThread(const WordCompletionThreadReply& reply); - + /** * @brief return a set of words from the current editors */ diff --git a/WordCompletion/WordCompletionRequestReply.h b/WordCompletion/WordCompletionRequestReply.h index 8c4548aa4f..33f9a2f28a 100644 --- a/WordCompletion/WordCompletionRequestReply.h +++ b/WordCompletion/WordCompletionRequestReply.h @@ -26,8 +26,12 @@ #ifndef WordCompletionRequestReply_H__ #define WordCompletionRequestReply_H__ +#include "macros.h" #include "worker_thread.h" +#include +#include + struct WordCompletionThreadRequest : public ThreadRequest { wxString buffer; wxString filter; diff --git a/WordCompletion/WordCompletionSettings.h b/WordCompletion/WordCompletionSettings.h index cc18db9656..67c20b5d05 100644 --- a/WordCompletion/WordCompletionSettings.h +++ b/WordCompletion/WordCompletionSettings.h @@ -53,7 +53,7 @@ class WordCompletionSettings : public clConfigItem void SetEnabled(bool enabled) { this->m_enabled = enabled; } bool IsEnabled() const { return m_enabled; } - + WordCompletionSettings& Load(); WordCompletionSettings& Save(); }; diff --git a/WordCompletion/WordCompletionSettingsDlg.cpp b/WordCompletion/WordCompletionSettingsDlg.cpp index 6544571e56..1c625ff1f7 100644 --- a/WordCompletion/WordCompletionSettingsDlg.cpp +++ b/WordCompletion/WordCompletionSettingsDlg.cpp @@ -1,6 +1,7 @@ #include "WordCompletionSettingsDlg.h" -#include "windowattrmanager.h" + #include "globals.h" +#include "windowattrmanager.h" WordCompletionSettingsDlg::WordCompletionSettingsDlg(wxWindow* parent) : WordCompletionSettingsBaseDlg(parent) diff --git a/WordCompletion/WordCompletionSettingsDlg.h b/WordCompletion/WordCompletionSettingsDlg.h index 53530b74da..6a7f68eb95 100644 --- a/WordCompletion/WordCompletionSettingsDlg.h +++ b/WordCompletion/WordCompletionSettingsDlg.h @@ -30,6 +30,7 @@ class WordCompletionSettingsDlg : public WordCompletionSettingsBaseDlg { bool m_modified; + public: WordCompletionSettingsDlg(wxWindow* parent); virtual ~WordCompletionSettingsDlg() = default; diff --git a/WordCompletion/WordCompletionThread.cpp b/WordCompletion/WordCompletionThread.cpp index 1bcea06407..5df1883f9b 100644 --- a/WordCompletion/WordCompletionThread.cpp +++ b/WordCompletion/WordCompletionThread.cpp @@ -43,21 +43,21 @@ void WordCompletionThread::ParseBuffer(const wxString& buffer, wxStringSet_t& su suggest.insert(filteredWords.begin(), filteredWords.end()); #else WordScanner_t scanner = ::WordLexerNew(buffer); - if(!scanner) + if (!scanner) return; WordLexerToken token; std::string curword; - while(::WordLexerNext(scanner, token)) { - switch(token.type) { + while (::WordLexerNext(scanner, token)) { + switch (token.type) { case kWordDelim: - if(!curword.empty()) { + if (!curword.empty()) { suggest.insert(wxString(curword.c_str(), wxConvUTF8, curword.length())); } curword.clear(); break; case kWordNumber: { - if(!curword.empty()) { + if (!curword.empty()) { curword += token.text; } break; diff --git a/WordCompletion/WordCompletionThread.h b/WordCompletion/WordCompletionThread.h index 1551b3d527..1a5b99e74f 100644 --- a/WordCompletion/WordCompletionThread.h +++ b/WordCompletion/WordCompletionThread.h @@ -26,24 +26,24 @@ #ifndef WORDCOMPLETIONTHREAD_H #define WORDCOMPLETIONTHREAD_H +#include "WordCompletionRequestReply.h" +#include "macros.h" #include "worker_thread.h" -#include + #include -#include "macros.h" -#include "WordCompletionRequestReply.h" +#include class WordCompletionDictionary; class WordCompletionThread : public WorkerThread { protected: WordCompletionDictionary* m_dict; - -public: +public: WordCompletionThread(WordCompletionDictionary* dict); ~WordCompletionThread() = default; virtual void ProcessRequest(ThreadRequest* request); - + /** * @brief parse 'buffer' and return set of words to complete */ diff --git a/WordCompletion/WordTokenizerAPI.h b/WordCompletion/WordTokenizerAPI.h index c282f7e962..94be5f4939 100644 --- a/WordCompletion/WordTokenizerAPI.h +++ b/WordCompletion/WordTokenizerAPI.h @@ -10,8 +10,7 @@ extern int isatty(int); using WordScanner_t = void*; -struct WordLexerToken -{ +struct WordLexerToken { char* text; int type; WordLexerToken() diff --git a/WordCompletion/wordcompletion.cpp b/WordCompletion/wordcompletion.cpp index 6b9d7de945..842c1d5bd1 100644 --- a/WordCompletion/wordcompletion.cpp +++ b/WordCompletion/wordcompletion.cpp @@ -16,10 +16,7 @@ #include // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new WordCompletionPlugin(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new WordCompletionPlugin(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -85,13 +82,13 @@ void WordCompletionPlugin::OnWordComplete(clCodeCompletionEvent& event) settings.Load(); // Enabled? - if(!settings.IsEnabled()) { + if (!settings.IsEnabled()) { return; } // Build the suggestion list static wxBitmap sBmp = wxNullBitmap; - if(!sBmp.IsOk()) { + if (!sBmp.IsOk()) { sBmp = m_mgr->GetStdIcons()->LoadBitmap("word"); } @@ -105,7 +102,7 @@ void WordCompletionPlugin::OnWordComplete(clCodeCompletionEvent& event) wxStringSet_t words = m_dictionary->GetWords(); // Parse the current buffer (if modified), to include non saved words - if(activeEditor->IsEditorModified()) { + if (activeEditor->IsEditorModified()) { // For performance (this parsing is done in the main thread) // only parse the visible area of the document wxStringSet_t unsavedBufferWords; @@ -122,9 +119,9 @@ void WordCompletionPlugin::OnWordComplete(clCodeCompletionEvent& event) // Get the editor keywords and add them LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexerForFile(activeEditor->GetFileName().GetFullName()); - if(lexer) { + if (lexer) { wxString keywords; - for(size_t i = 0; i < wxSTC_KEYWORDSET_MAX; ++i) { + for (size_t i = 0; i < wxSTC_KEYWORDSET_MAX; ++i) { keywords << lexer->GetKeyWords(i) << " "; } wxArrayString langWords = ::wxStringTokenize(keywords, "\n\t \r", wxTOKEN_STRTOK); @@ -132,17 +129,17 @@ void WordCompletionPlugin::OnWordComplete(clCodeCompletionEvent& event) } wxStringSet_t filteredSet; - if(filter.IsEmpty()) { + if (filter.IsEmpty()) { filteredSet.swap(words); } else { for (const auto& word : words) { wxString lcWord = word.Lower(); - if(settings.GetComparisonMethod() == WordCompletionSettings::kComparisonStartsWith) { - if(lcWord.StartsWith(filter) && filter != word) { + if (settings.GetComparisonMethod() == WordCompletionSettings::kComparisonStartsWith) { + if (lcWord.StartsWith(filter) && filter != word) { filteredSet.insert(word); } } else { - if(lcWord.Contains(filter) && filter != word) { + if (lcWord.Contains(filter) && filter != word) { filteredSet.insert(word); } } @@ -164,7 +161,7 @@ void WordCompletionPlugin::OnSettings(wxCommandEvent& event) IEditor* WordCompletionPlugin::GetEditor(const wxString& filepath) const { auto editor = clGetManager()->FindEditor(filepath); - if(editor && editor == clGetManager()->GetActiveEditor()) { + if (editor && editor == clGetManager()->GetActiveEditor()) { return editor; } return nullptr; diff --git a/ZoomNavigator/zoomnavigator.cpp b/ZoomNavigator/zoomnavigator.cpp index e8da26e1ef..8143b6736d 100755 --- a/ZoomNavigator/zoomnavigator.cpp +++ b/ZoomNavigator/zoomnavigator.cpp @@ -34,9 +34,9 @@ #include "bookmark_manager.h" #include "event_notifier.h" -#include "zoomtext.h" #include "znSettingsDlg.h" #include "zn_config_item.h" +#include "zoomtext.h" #include #include @@ -99,8 +99,11 @@ ZoomNavigator::ZoomNavigator(IManager* manager) EventNotifier::Get()->Bind(wxEVT_FILE_SAVED, &ZoomNavigator::OnFileSaved, this); EventNotifier::Get()->Bind(wxEVT_ZN_SETTINGS_UPDATED, &ZoomNavigator::OnSettingsChanged, this); - m_topWindow->Connect(XRCID("zn_settings"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(ZoomNavigator::OnSettings), nullptr, this); + m_topWindow->Connect(XRCID("zn_settings"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(ZoomNavigator::OnSettings), + nullptr, + this); m_timer = new wxTimer(this); Bind(wxEVT_TIMER, &ZoomNavigator::OnTimer, this, m_timer->GetId()); @@ -116,8 +119,11 @@ void ZoomNavigator::UnPlug() EventNotifier::Get()->Unbind(wxEVT_FILE_SAVED, &ZoomNavigator::OnFileSaved, this); m_topWindow->Disconnect(wxEVT_IDLE, wxIdleEventHandler(ZoomNavigator::OnIdle), nullptr, this); - m_topWindow->Disconnect(XRCID("zn_settings"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(ZoomNavigator::OnSettings), nullptr, this); + m_topWindow->Disconnect(XRCID("zn_settings"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(ZoomNavigator::OnSettings), + nullptr, + this); // cancel the timer Unbind(wxEVT_TIMER, &ZoomNavigator::OnTimer, this, m_timer->GetId()); m_timer->Stop(); diff --git a/ZoomNavigator/zoomtext.cpp b/ZoomNavigator/zoomtext.cpp index 92637ca40f..eaa2f1777f 100755 --- a/ZoomNavigator/zoomtext.cpp +++ b/ZoomNavigator/zoomtext.cpp @@ -68,8 +68,8 @@ sci_marker_types ToSciMarkerTypes(ZoomText::MarkerType type) } } // namespace -ZoomText::ZoomText(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, - const wxString& name) +ZoomText::ZoomText( + wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { Hide(); if (!wxStyledTextCtrl::Create(parent, id, pos, size, style | wxNO_BORDER, name)) { @@ -236,8 +236,8 @@ void ZoomText::OnTimer(wxTimerEvent& event) if (!editor->GetKeywordClasses().IsEmpty() && (editor->GetFileName().GetFullPath() == m_filename)) { // Sync between the keywords - SetSemanticTokens(editor->GetKeywordClasses(), editor->GetKeywordLocals(), editor->GetKeywordMethods(), - wxEmptyString); + SetSemanticTokens( + editor->GetKeywordClasses(), editor->GetKeywordLocals(), editor->GetKeywordMethods(), wxEmptyString); } m_timer->Start(TIMER_DELAY, true); } @@ -260,7 +260,9 @@ void ZoomText::UpdateMarkers(const std::vector& lines, MarkerType type) } } -void ZoomText::SetSemanticTokens(const wxString& classes, const wxString& variables, const wxString& methods, +void ZoomText::SetSemanticTokens(const wxString& classes, + const wxString& variables, + const wxString& methods, const wxString& others) { IEditor* editor = clGetManager()->GetActiveEditor(); diff --git a/ZoomNavigator/zoomtext.h b/ZoomNavigator/zoomtext.h index f187c718e0..eb6f20336f 100755 --- a/ZoomNavigator/zoomtext.h +++ b/ZoomNavigator/zoomtext.h @@ -57,12 +57,18 @@ class ZoomText : public wxStyledTextCtrl void OnThemeChanged(wxCommandEvent& e); void OnTimer(wxTimerEvent& event); void DoClear(); - void SetSemanticTokens(const wxString& classes, const wxString& variables, const wxString& methods, + void SetSemanticTokens(const wxString& classes, + const wxString& variables, + const wxString& methods, const wxString& others); public: - explicit ZoomText(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxSTCNameStr); + explicit ZoomText(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxSTCNameStr); ~ZoomText() override; void UpdateLexer(IEditor* editor); void OnSettingsChanged(wxCommandEvent& e); diff --git a/sdk/.clang-format b/sdk/.clang-format new file mode 100644 index 0000000000..15cb87dcb0 --- /dev/null +++ b/sdk/.clang-format @@ -0,0 +1 @@ +DisableFormat: true diff --git a/submodules/.clang-format b/submodules/.clang-format new file mode 100644 index 0000000000..15cb87dcb0 --- /dev/null +++ b/submodules/.clang-format @@ -0,0 +1 @@ +DisableFormat: true diff --git a/wxcrafter/Importer/import_dlg.cpp b/wxcrafter/Importer/import_dlg.cpp index bd8b5d949b..d8e1326001 100644 --- a/wxcrafter/Importer/import_dlg.cpp +++ b/wxcrafter/Importer/import_dlg.cpp @@ -14,9 +14,9 @@ ImportDlg::ImportDlg(IPD_ProjectType type, wxWindow* parent, const wxString& sou , m_Type(type) , m_modified(false) { - if(m_Type == IPD_FB) { + if (m_Type == IPD_FB) { SetLabel(_("Choose a wxFormBuilder project to import")); - } else if(m_Type == IPD_Smith) { + } else if (m_Type == IPD_Smith) { SetLabel(_("Choose a wxSmith project to import")); } @@ -37,23 +37,25 @@ void ImportDlg::OnBrowse(wxCommandEvent& event) wxUnusedVar(event); wxString title, ext; - if(m_Type == IPD_FB) { + if (m_Type == IPD_FB) { ext << (wxT("wxFB Project (*.fbp)|*.fbp|Any File (")) << wxFileSelectorDefaultWildcardStr << wxT(")|") << wxFileSelectorDefaultWildcardStr; title = _("Import a wxFormBuilder project"); } - if(m_Type == IPD_Smith) { + if (m_Type == IPD_Smith) { ext << (wxT("wxSmith Project (*.wxs)|*.wxs|Any File (")) << wxFileSelectorDefaultWildcardStr << wxT(")|") << wxFileSelectorDefaultWildcardStr; title = _("Import a wxSmith project"); } - if(m_Type == IPD_XRC) { + if (m_Type == IPD_XRC) { ext << (wxT("XRC File (*.xrc)|*.xrc|Any File (")) << wxFileSelectorDefaultWildcardStr << wxT(")|") << wxFileSelectorDefaultWildcardStr; title = _("Import an XRC file"); } wxString path = wxFileSelector(title, wxEmptyString, wxEmptyString, wxEmptyString, ext, wxFD_OPEN, this); - if(path.empty()) { return; } + if (path.empty()) { + return; + } m_filepathText->ChangeValue(path); // Use that filepath as the suggested destination, but using .wxcp as the ext @@ -72,7 +74,8 @@ void ImportDlg::OnBrowseForOutputFolder(wxCommandEvent& event) wxString curtext = m_textName->GetValue(); wxFileName fn(curtext); wxString dir = wxDirSelector(); - if(dir.IsEmpty()) return; + if (dir.IsEmpty()) + return; wxFileName newpath(dir, fn.GetFullName()); m_textName->ChangeValue(newpath.GetFullPath()); @@ -81,7 +84,7 @@ void ImportDlg::OnBrowseForOutputFolder(wxCommandEvent& event) void ImportDlg::OnBrowseForVirtualFolder(wxCommandEvent& event) { VirtualDirectorySelectorDlg vds(wxCrafter::TopFrame(), clCxxWorkspaceST::Get()); - if(vds.ShowModal() == wxID_OK) { + if (vds.ShowModal() == wxID_OK) { wxString vd = vds.GetVirtualDirectoryPath(); m_textCtrl1VirtualFolder->ChangeValue(vd); } @@ -107,7 +110,7 @@ void ImportDlg::OnAddToProjectUI(wxUpdateUIEvent& event) void ImportDlg::OnFileImportTextUpdated(wxCommandEvent& event) { - if(!m_modified) { + if (!m_modified) { wxFileName fnWXCPFile(m_filepathText->GetValue()); fnWXCPFile.SetExt("wxcp"); m_textName->ChangeValue(fnWXCPFile.GetFullPath()); diff --git a/wxcrafter/Importer/import_from_wxFB.cpp b/wxcrafter/Importer/import_from_wxFB.cpp index bebcba964a..0156cb5a46 100644 --- a/wxcrafter/Importer/import_from_wxFB.cpp +++ b/wxcrafter/Importer/import_from_wxFB.cpp @@ -24,23 +24,23 @@ bool ImportFromwxFB::ImportProject(ImportDlg::ImportFileData& data, const wxStri { ImportDlg dlg(ImportDlg::IPD_FB, m_Parent, sourceFile); - if(dlg.ShowModal() != wxID_OK) { + if (dlg.ShowModal() != wxID_OK) { return false; } wxString filepath = dlg.GetFilepath(); - if(filepath.empty() || !wxFileExists(filepath)) { + if (filepath.empty() || !wxFileExists(filepath)) { return false; } wxXmlDocument doc(filepath); - if(!doc.IsOk()) { + if (!doc.IsOk()) { wxMessageBox(_("Failed to load the file to import"), wxT("CodeLite"), wxICON_ERROR | wxOK, m_Parent); return false; } wxcWidget::List_t toplevels; - if(ParseFile(doc, toplevels) && !toplevels.empty()) { + if (ParseFile(doc, toplevels) && !toplevels.empty()) { wxcProjectMetadata::Get().Serialize(toplevels, wxFileName(dlg.GetOutputFilepath())); data = dlg.GetData(); return true; @@ -52,12 +52,12 @@ bool ImportFromwxFB::ParseFile(wxXmlDocument& doc, wxcWidget::List_t& toplevels) { wxString abortmsg(_("This doesn't seem to be a valid wxFormBuilder project file. Aborting.")); wxXmlNode* wxFBProj = XmlUtils::FindFirstByTagName(doc.GetRoot(), wxT("object")); - if(!wxFBProj) { + if (!wxFBProj) { wxMessageBox(abortmsg, wxT("CodeLite"), wxICON_ERROR | wxOK, m_Parent); return false; } - if(XmlUtils::ReadString(wxFBProj, wxT("class")) != "Project") { + if (XmlUtils::ReadString(wxFBProj, wxT("class")) != "Project") { wxMessageBox(abortmsg, wxT("CodeLite"), wxICON_ERROR | wxOK, m_Parent); return false; } @@ -75,21 +75,21 @@ bool ImportFromwxFB::ParseFile(wxXmlDocument& doc, wxcWidget::List_t& toplevels) // The first interesting thing is a child node of Project e.g. wxXmlNode* toplevelnode = XmlUtils::FindFirstByTagName(wxFBProj, wxT("object")); - if(!toplevelnode) { + if (!toplevelnode) { wxMessageBox(abortmsg, wxT("CodeLite"), wxICON_ERROR | wxOK, m_Parent); return false; } - while(toplevelnode) { + while (toplevelnode) { wxString tag = toplevelnode->GetName(); - if(tag != wxT("object")) { + if (tag != wxT("object")) { wxMessageBox(abortmsg, wxT("CodeLite"), wxICON_ERROR | wxOK, m_Parent); return false; } bool alreadyParented(false); wxcWidget* wrapper = ParseNode(toplevelnode, NULL, alreadyParented); - if(wrapper) { + if (wrapper) { toplevels.push_back(wrapper); } @@ -113,11 +113,11 @@ wxcWidget* ImportFromwxFB::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, wxXmlNode* gbsizeritemnode = node; wxXmlNode* booknode = NULL; - if(classname == wxT("sizeritem")) { + if (classname == wxT("sizeritem")) { // See the comment in import_from_xrc. Replace node with the contained object node // We'll process sizeritemnode node separately later node = XmlUtils::FindFirstByTagName(node, wxT("object")); - if(!node) { + if (!node) { // I don't think this can happen, but... return NULL; } @@ -126,12 +126,12 @@ wxcWidget* ImportFromwxFB::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, classname = XmlUtils::ReadString(node, wxT("class")); } - else if(classname == "gbsizeritem") { + else if (classname == "gbsizeritem") { // wxFB deals with this separately // We'll process gbsizeritem node separately later gbsizeritemnode = node; node = XmlUtils::FindFirstByTagName(node, wxT("object")); - if(!node) { + if (!node) { // I don't think this can happen, but... return NULL; } @@ -140,12 +140,12 @@ wxcWidget* ImportFromwxFB::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, classname = XmlUtils::ReadString(node, wxT("class")); } - else if(classname.Contains(wxT("bookpage"))) { + else if (classname.Contains(wxT("bookpage"))) { // See the above comment. Replace node with the contained object node // We'll process booknode node separately later booknode = node; node = XmlUtils::FindFirstByTagName(node, wxT("object")); - if(!node) { + if (!node) { // I don't think this can happen, but... return NULL; } @@ -154,11 +154,11 @@ wxcWidget* ImportFromwxFB::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, classname = XmlUtils::ReadString(node, wxT("class")); } - else if(classname == "splitteritem") { + else if (classname == "splitteritem") { // wxFB uses this for a splitterwindow page, but it holds no extra info :/ // so just substitute the contained object node = XmlUtils::FindFirstByTagName(node, wxT("object")); - if(!node) { + if (!node) { // I don't think this can happen, but... return NULL; } @@ -166,19 +166,19 @@ wxcWidget* ImportFromwxFB::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, } int Id = Allocator::StringToId(classname); - if(Id == wxNOT_FOUND) { + if (Id == wxNOT_FOUND) { wxLogWarning(wxString::Format(_("Can't import unknown class %s from wxFB"), classname)); return NULL; } - if((Id == ID_WXPANEL) && (parentwrapper == NULL)) { + if ((Id == ID_WXPANEL) && (parentwrapper == NULL)) { Id = ID_WXPANEL_TOPLEVEL; - } else if(Id == ID_WXPANEL && parentwrapper && parentwrapper->GetType() == ID_WXSPLITTERWINDOW) { + } else if (Id == ID_WXPANEL && parentwrapper && parentwrapper->GetType() == ID_WXSPLITTERWINDOW) { Id = ID_WXSPLITTERWINDOW_PAGE; } - if(booknode) { + if (booknode) { // Correctly label a wxPanel that's really a notebookpage Id = ID_WXPANEL_NOTEBOOK_PAGE; } @@ -192,7 +192,7 @@ wxcWidget* ImportFromwxFB::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, GetGridBagSizerItem(gbsizeritemnode, wrapper); // Similarly with these, which wxFB stores separately int depth = 0; - if(booknode) { + if (booknode) { // For book pages, extract any info from the node NotebookPageWrapper* nbwrapper = dynamic_cast(wrapper); wxCHECK_MSG(nbwrapper, NULL, wxT("A booknode which has no NotebookPageWrapper")); @@ -200,12 +200,12 @@ wxcWidget* ImportFromwxFB::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, // If this is a treebook subpage, it needs to be parented by a page, not the book // depth will only be >0 in that situation - if(depth) { + if (depth) { NotebookBaseWrapper* nb = dynamic_cast(parentwrapper); wxCHECK_MSG(nb, NULL, wxT("treebookpage 'parent' not a book")); wxcWidget* item = nb->GetChildPageAtDepth(depth - 1); - if(item) { + if (item) { item->AddChild(wrapper); alreadyParented = true; } else { @@ -217,12 +217,12 @@ wxcWidget* ImportFromwxFB::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, } wxXmlNode* child = node->GetChildren(); - while(child) { + while (child) { wxString childname(child->GetName()); - if(childname == wxT("object")) { + if (childname == wxT("object")) { bool alreadyParented(false); wxcWidget* childwrapper = ParseNode(child, wrapper, alreadyParented); - if(childwrapper && !alreadyParented) { + if (childwrapper && !alreadyParented) { wrapper->AddChild(childwrapper); } } @@ -239,25 +239,25 @@ void ImportFromwxFB::GetSizeritemContents(const wxXmlNode* node, wxcWidget* wrap // Unlike XRC, wxFB stores everything in value nodes wxXmlNode* child = node->GetChildren(); - while(child) { + while (child) { wxString childname(child->GetName()); - if(childname == wxT("property")) { + if (childname == wxT("property")) { - if(XmlUtils::ReadString(child, wxT("name")) == "flag") { + if (XmlUtils::ReadString(child, wxT("name")) == "flag") { wxString flags = child->GetNodeContent(); // We must cope with wxC's American misspellings... flags.Replace("wxALIGN_CENTRE", "wxALIGN_CENTER"); // if left|right|top|bottom add wxALL. Duplication does no harm here - if(flags.Contains("wxLEFT") && flags.Contains("wxRIGHT") && flags.Contains("wxTOP") && - flags.Contains("wxBOTTOM")) { + if (flags.Contains("wxLEFT") && flags.Contains("wxRIGHT") && flags.Contains("wxTOP") && + flags.Contains("wxBOTTOM")) { flags << "|wxALL"; } wxArrayString flagsarray = wxCrafter::Split(flags, "|"); // Eran: If flagsarray contains 'wxALL' - make sure all the other four stars are also there... - if(flagsarray.Index("wxALL") != wxNOT_FOUND) { + if (flagsarray.Index("wxALL") != wxNOT_FOUND) { flagsarray.Add("wxLEFT"); flagsarray.Add("wxRIGHT"); flagsarray.Add("wxTOP"); @@ -265,17 +265,17 @@ void ImportFromwxFB::GetSizeritemContents(const wxXmlNode* node, wxcWidget* wrap flagsarray = wxCrafter::MakeUnique(flagsarray); } - for(size_t n = 0; n < flagsarray.GetCount(); ++n) { + for (size_t n = 0; n < flagsarray.GetCount(); ++n) { wrapper->EnableSizerFlag(flagsarray.Item(n), true); } } - if(XmlUtils::ReadString(child, wxT("name")) == "proportion") { + if (XmlUtils::ReadString(child, wxT("name")) == "proportion") { wxString proportion = child->GetNodeContent(); wrapper->SizerItem().SetProportion(wxCrafter::ToNumber(proportion, 0)); } - if(XmlUtils::ReadString(child, wxT("name")) == "border") { + if (XmlUtils::ReadString(child, wxT("name")) == "border") { wxString border = child->GetNodeContent(); wrapper->SizerItem().SetBorder(wxCrafter::ToNumber(border, 0)); } @@ -294,21 +294,21 @@ void ImportFromwxFB::GetGridBagSizerItem(const wxXmlNode* node, wxcWidget* wrapp wxString row, column, rowspan, colspan; // wxFB holds these individually; wxC needs pairs wxXmlNode* child = node->GetChildren(); - while(child) { + while (child) { wxString childname(child->GetName()); - if(childname == wxT("property")) { - if(XmlUtils::ReadString(child, wxT("name")) == "row") { + if (childname == wxT("property")) { + if (XmlUtils::ReadString(child, wxT("name")) == "row") { row = child->GetNodeContent(); } - if(XmlUtils::ReadString(child, wxT("name")) == "column") { + if (XmlUtils::ReadString(child, wxT("name")) == "column") { column = child->GetNodeContent(); } - if(XmlUtils::ReadString(child, wxT("name")) == "rowspan") { + if (XmlUtils::ReadString(child, wxT("name")) == "rowspan") { rowspan = child->GetNodeContent(); } - if(XmlUtils::ReadString(child, wxT("name")) == "colspan") { + if (XmlUtils::ReadString(child, wxT("name")) == "colspan") { colspan = child->GetNodeContent(); } } @@ -324,25 +324,25 @@ void ImportFromwxFB::GetBookitemContents(const wxXmlNode* node, NotebookPageWrap wxString classname = XmlUtils::ReadString(node, wxT("class")); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "select"); - if(propertynode) { + if (propertynode) { wxString selected = propertynode->GetNodeContent(); - if(selected == "1") { + if (selected == "1") { wrapper->SetSelected(true); } } propertynode = XmlUtils::FindNodeByName(node, "property", "label"); - if(propertynode) { + if (propertynode) { wxString label = propertynode->GetNodeContent(); PropertyBase* prop = wrapper->GetProperty(PROP_LABEL); - if(prop) { + if (prop) { prop->SetValue(label); } } - if(classname != "choicebookpage") { // which don't have bitmaps + if (classname != "choicebookpage") { // which don't have bitmaps propertynode = XmlUtils::FindNodeByName(node, "property", "bitmap"); - if(propertynode) { + if (propertynode) { wxString bitmap = propertynode->GetNodeContent(); ProcessBitmapProperty(bitmap, wrapper); } @@ -372,11 +372,12 @@ wxString ImportFromwxFB::ConvertFBOptionsString(const wxString& content, const w } // static -void ImportFromwxFB::ProcessBitmapProperty(const wxString& bitmapinfo, wxcWidget* wrapper, +void ImportFromwxFB::ProcessBitmapProperty(const wxString& bitmapinfo, + wxcWidget* wrapper, const wxString& property /*= PROP_BITMAP_PATH*/, const wxString& client_hint /*=""*/) { - if(bitmapinfo.empty()) { + if (bitmapinfo.empty()) { return; // This isn't an error; the field may well be empty } @@ -388,49 +389,49 @@ void ImportFromwxFB::ProcessBitmapProperty(const wxString& bitmapinfo, wxcWidget // or: Load From Icon Resource; resourcename; [-1; -1] wxArrayString arr = wxCrafter::Split(bitmapinfo, ";"); // ToDo: when we can load an icon resource, deal with the ';' in [-1; -1]! - if(bitmapinfo.Contains("Load From File")) { + if (bitmapinfo.Contains("Load From File")) { wxString bitmappath; - if(arr.Item(0).Contains("Load From File")) { + if (arr.Item(0).Contains("Load From File")) { bitmappath = arr.Item(1); - } else if(arr.Item(1).Contains("Load From File")) { + } else if (arr.Item(1).Contains("Load From File")) { bitmappath = arr.Item(0); } - if(!bitmappath.empty()) { + if (!bitmappath.empty()) { PropertyBase* prop = wrapper->GetProperty(property); // Either PROP_BITMAP_PATH or PROP_DISABLED_BITMAP_PATH - if(prop) { + if (prop) { wxFileName fn(bitmappath.Trim(false)); // wxFB will probably have supplied a relative path - if(fn.Normalize()) { + if (fn.Normalize()) { prop->SetValue(fn.GetFullPath()); } } } } - else if(bitmapinfo.Contains("Load From Art Provider")) { + else if (bitmapinfo.Contains("Load From Art Provider")) { // "Load From Art Provider; wxART_GO_HOME; wxART_BUTTON" // but we don't know for sure that the stock_client attribute will be present, or which order they'll be in. // So: wxString idstring, clientstring, sizeHint; - for(size_t n = 0; n < arr.GetCount(); ++n) { - if(arr.Item(n).Contains("wxART_")) { + for (size_t n = 0; n < arr.GetCount(); ++n) { + if (arr.Item(n).Contains("wxART_")) { // Could be e.g. wxART_GO_HOME, or the client hint e.g. wxART_BUTTON. Abuse IsArtProviderBitmap() to // find out which wxString artId, clientId, fake = arr.Item(n) + ",foo"; - if(wxCrafter::IsArtProviderBitmap(fake, artId, clientId, sizeHint)) { + if (wxCrafter::IsArtProviderBitmap(fake, artId, clientId, sizeHint)) { idstring = arr.Item(n); } else { clientstring = arr.Item(n); } } } - if(!idstring.empty()) { + if (!idstring.empty()) { PropertyBase* prop = wrapper->GetProperty(property); - if(prop) { + if (prop) { wxString artdata = idstring; - if(clientstring.empty()) { + if (clientstring.empty()) { clientstring = client_hint; // Use any hint we were given } - if(!clientstring.empty()) { + if (!clientstring.empty()) { artdata << "," << clientstring; } prop->SetValue(artdata); @@ -445,7 +446,7 @@ wxString ImportFromwxFB::GetEventtypeFromHandlerstub(const wxString& stub) { // Despite the class name, this does XRC and wxSmith too. The 'duplicate' events are their way of labelling - if(sm_eventMap.size() == 0) { + if (sm_eventMap.size() == 0) { // 'Common' eventtypes sm_eventMap.insert(std::pair("OnKeyDown", "wxEVT_KEY_DOWN")); sm_eventMap.insert(std::pair("EVT_KEY_DOWN", "wxEVT_KEY_DOWN")); @@ -762,8 +763,8 @@ wxString ImportFromwxFB::GetEventtypeFromHandlerstub(const wxString& stub) std::pair("EVT_SPLITTER_SASH_POS_CHANGED", "wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED")); sm_eventMap.insert( std::pair("OnSplitterSashPosChanging", "wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING")); - sm_eventMap.insert(std::pair("EVT_SPLITTER_SASH_POS_CHANGING", - "wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING")); + sm_eventMap.insert(std::pair( + "EVT_SPLITTER_SASH_POS_CHANGING", "wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING")); sm_eventMap.insert(std::pair("OnSplitterUnsplit", "wxEVT_COMMAND_SPLITTER_UNSPLIT")); sm_eventMap.insert(std::pair("EVT_SPLITTER_UNSPLIT", "wxEVT_COMMAND_SPLITTER_UNSPLIT")); sm_eventMap.insert(std::pair("OnText", "wxEVT_COMMAND_TEXT_UPDATED")); diff --git a/wxcrafter/Importer/import_from_wxFB.h b/wxcrafter/Importer/import_from_wxFB.h index 8e2d951830..bb0511ec4e 100644 --- a/wxcrafter/Importer/import_from_wxFB.h +++ b/wxcrafter/Importer/import_from_wxFB.h @@ -4,6 +4,7 @@ #include "import_dlg.h" #include "wxc_widget.h" #include "wxgui_defs.h" + #include class wxWindow; @@ -21,8 +22,10 @@ class ImportFromwxFB bool ImportProject(ImportDlg::ImportFileData& data, const wxString& sourceFile = "") const; static wxString ConvertFBOptionsString(const wxString& content, const wxString& separator = ";"); - static void ProcessBitmapProperty(const wxString& value, wxcWidget* wrapper, - const wxString& property = PROP_BITMAP_PATH, const wxString& client_hint = ""); + static void ProcessBitmapProperty(const wxString& value, + wxcWidget* wrapper, + const wxString& property = PROP_BITMAP_PATH, + const wxString& client_hint = ""); bool GetProject() const; static wxString GetEventtypeFromHandlerstub(const wxString& stub); diff --git a/wxcrafter/Importer/import_from_wxSmith.cpp b/wxcrafter/Importer/import_from_wxSmith.cpp index e922928e97..7af3d7fe64 100644 --- a/wxcrafter/Importer/import_from_wxSmith.cpp +++ b/wxcrafter/Importer/import_from_wxSmith.cpp @@ -25,19 +25,23 @@ bool ImportFromwxSmith::ImportProject(ImportDlg::ImportFileData& data, const wxS { ImportDlg dlg(ImportDlg::IPD_Smith, m_Parent, sourceFile); - if(dlg.ShowModal() != wxID_OK) { return false; } + if (dlg.ShowModal() != wxID_OK) { + return false; + } wxString filepath = dlg.GetFilepath(); - if(filepath.empty() || !wxFileExists(filepath)) { return false; } + if (filepath.empty() || !wxFileExists(filepath)) { + return false; + } wxXmlDocument doc(filepath); - if(!doc.IsOk()) { + if (!doc.IsOk()) { wxMessageBox(_("Failed to load the file to import"), wxT("CodeLite"), wxICON_ERROR | wxOK, m_Parent); return false; } wxcWidget::List_t toplevels; - if(ParseFile(doc, toplevels) && !toplevels.empty()) { + if (ParseFile(doc, toplevels) && !toplevels.empty()) { wxcProjectMetadata::Get().Serialize(toplevels, wxFileName(dlg.GetOutputFilepath())); data = dlg.GetData(); return true; @@ -51,17 +55,21 @@ bool ImportFromwxSmith::ParseFile(wxXmlDocument& doc, wxcWidget::List_t& topleve // // wxXmlNode* toplevelnode = doc.GetRoot()->GetChildren(); - while(toplevelnode) { + while (toplevelnode) { wxString tag = toplevelnode->GetName(); - if(tag != wxT("object")) { - wxMessageBox(_("This doesn't seem to be a valid wxSmith file. Aborting."), wxT("CodeLite"), - wxICON_ERROR | wxOK, m_Parent); + if (tag != wxT("object")) { + wxMessageBox(_("This doesn't seem to be a valid wxSmith file. Aborting."), + wxT("CodeLite"), + wxICON_ERROR | wxOK, + m_Parent); return false; } bool alreadyParented(false); wxcWidget* wrapper = ParseNode(toplevelnode, NULL, alreadyParented); - if(wrapper) { toplevels.push_back(wrapper); } + if (wrapper) { + toplevels.push_back(wrapper); + } toplevelnode = toplevelnode->GetNext(); } @@ -82,11 +90,11 @@ wxcWidget* ImportFromwxSmith::ParseNode(wxXmlNode* node, wxcWidget* parentwrappe wxString classname = XmlUtils::ReadString(node, wxT("class")); wxCHECK_MSG(!classname.empty(), NULL, wxT("Object node doesn't have a 'class' attribute")); - if(classname == wxT("sizeritem")) { + if (classname == wxT("sizeritem")) { // See the ImportFromXRC comment. Replace node with the contained object node // We'll process sizeritemnode node separately later node = XmlUtils::FindFirstByTagName(node, wxT("object")); - if(!node) { + if (!node) { // I don't think this can happen, but... return NULL; } @@ -95,12 +103,12 @@ wxcWidget* ImportFromwxSmith::ParseNode(wxXmlNode* node, wxcWidget* parentwrappe classname = XmlUtils::ReadString(node, wxT("class")); } - else if(classname.Contains(wxT("bookpage"))) { + else if (classname.Contains(wxT("bookpage"))) { // See the above comment. Replace node with the contained object node // We'll process booknode node separately later booknode = node; node = XmlUtils::FindFirstByTagName(node, wxT("object")); - if(!node) { + if (!node) { // I don't think this can happen, but... return NULL; } @@ -109,33 +117,35 @@ wxcWidget* ImportFromwxSmith::ParseNode(wxXmlNode* node, wxcWidget* parentwrappe classname = XmlUtils::ReadString(node, wxT("class")); } - else if(classname == wxT("button")) { + else if (classname == wxT("button")) { buttonnode = node; node = XmlUtils::FindFirstByTagName(node, wxT("object")); - if(!node) { + if (!node) { return NULL; } classname = XmlUtils::ReadString(node, wxT("class")); - if(classname == "wxButton") { // and it certainly should be + if (classname == "wxButton") { // and it certainly should be classname = "stdbutton"; } } int Id = Allocator::StringToId(classname); - if(Id == wxNOT_FOUND) { + if (Id == wxNOT_FOUND) { wxLogWarning(wxString::Format(_("Can't import unknown class %s in from wxSmith"), classname)); return NULL; } - if((Id == ID_WXPANEL) && (parentwrapper == NULL)) { Id = ID_WXPANEL_TOPLEVEL; } + if ((Id == ID_WXPANEL) && (parentwrapper == NULL)) { + Id = ID_WXPANEL_TOPLEVEL; + } // classname == "separator", which gives and Id of ID_WXMENUITEM, could be a menu or toolbar one - if((classname == "separator") && (parentwrapper && parentwrapper->GetWidgetType() == TYPE_TOOLBAR)) { + if ((classname == "separator") && (parentwrapper && parentwrapper->GetWidgetType() == TYPE_TOOLBAR)) { Id = ID_WXTOOLBARITEM; } - if(booknode) { + if (booknode) { // Correctly label a wxPanel that's really a notebookpage Id = ID_WXPANEL_NOTEBOOK_PAGE; } @@ -148,7 +158,7 @@ wxcWidget* ImportFromwxSmith::ParseNode(wxXmlNode* node, wxcWidget* parentwrappe GetSizeritemContents(sizeritemnode, wrapper); // Now we have a valid wrapper, we can store the sizeritem info in it int depth = 0; - if(booknode) { + if (booknode) { // For book pages, extract any info from the node NotebookPageWrapper* nbwrapper = dynamic_cast(wrapper); wxCHECK_MSG(nbwrapper, NULL, wxT("A booknode which has no NotebookPageWrapper")); @@ -157,12 +167,12 @@ wxcWidget* ImportFromwxSmith::ParseNode(wxXmlNode* node, wxcWidget* parentwrappe // If this is a treebook subpage, it needs to be parented by a page, not the book // depth will only be >0 in that situation // NB I can't find a way to create a subpage in wxSmith, but just maybe... - if(depth) { + if (depth) { NotebookBaseWrapper* nb = dynamic_cast(parentwrapper); wxCHECK_MSG(nb, NULL, wxT("treebookpage 'parent' not a book")); wxcWidget* item = nb->GetChildPageAtDepth(depth - 1); - if(item) { + if (item) { item->AddChild(wrapper); alreadyParented = true; } else { @@ -173,18 +183,20 @@ wxcWidget* ImportFromwxSmith::ParseNode(wxXmlNode* node, wxcWidget* parentwrappe } } - if(buttonnode) { + if (buttonnode) { // For wxStdDialogButtonSizer buttons, extract any info from the node ImportFromXrc::DoProcessButtonNode(buttonnode, wrapper); } wxXmlNode* child = node->GetChildren(); - while(child) { + while (child) { wxString childname(child->GetName()); - if(childname == wxT("object")) { + if (childname == wxT("object")) { bool alreadyParented(false); wxcWidget* childwrapper = ParseNode(child, wrapper, alreadyParented); - if(childwrapper && !alreadyParented) { wrapper->AddChild(childwrapper); } + if (childwrapper && !alreadyParented) { + wrapper->AddChild(childwrapper); + } } child = child->GetNext(); @@ -198,21 +210,21 @@ void ImportFromwxSmith::GetSizeritemContents(const wxXmlNode* node, wxcWidget* w wrapper->ClearSizerAll(); // otherwise the default ones will remain wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("flag")); - if(propertynode) { + if (propertynode) { wxString flags = propertynode->GetNodeContent(); // We must cope with wxC's American misspellings... flags.Replace("wxALIGN_CENTRE", "wxALIGN_CENTER"); // if left|right|top|bottom add wxALL. Duplication does no harm here - if(flags.Contains("wxLEFT") && flags.Contains("wxRIGHT") && flags.Contains("wxTOP") && - flags.Contains("wxBOTTOM")) { + if (flags.Contains("wxLEFT") && flags.Contains("wxRIGHT") && flags.Contains("wxTOP") && + flags.Contains("wxBOTTOM")) { flags << "|wxALL"; } wxArrayString flagsarray = wxCrafter::Split(flags, "|"); // Eran: If flagsarray contains 'wxALL' - make sure all the other four stars are also there... - if(flagsarray.Index("wxALL") != wxNOT_FOUND) { + if (flagsarray.Index("wxALL") != wxNOT_FOUND) { flagsarray.Add("wxLEFT"); flagsarray.Add("wxRIGHT"); flagsarray.Add("wxTOP"); @@ -220,28 +232,30 @@ void ImportFromwxSmith::GetSizeritemContents(const wxXmlNode* node, wxcWidget* w flagsarray = wxCrafter::MakeUnique(flagsarray); } - for(size_t n = 0; n < flagsarray.GetCount(); ++n) { + for (size_t n = 0; n < flagsarray.GetCount(); ++n) { wrapper->EnableSizerFlag(flagsarray.Item(n), true); } } propertynode = XmlUtils::FindFirstByTagName(node, wxT("option")); // 'option' is XRC's term for proportion :/ - if(propertynode) { + if (propertynode) { wxString proportion = propertynode->GetNodeContent(); wrapper->SizerItem().SetProportion(wxCrafter::ToNumber(proportion, 0)); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("border")); - if(propertynode) { + if (propertynode) { wxString border = propertynode->GetNodeContent(); wrapper->SizerItem().SetBorder(wxCrafter::ToNumber(border, 0)); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("minsize")); - if(propertynode) { + if (propertynode) { wxString minsize = propertynode->GetNodeContent(); PropertyBase* prop = wrapper->GetProperty(PROP_MINSIZE); - if(prop) { prop->SetValue(minsize); } + if (prop) { + prop->SetValue(minsize); + } } // wxSmith stores these individually (like wxFB), but not in a separate node like wxFB @@ -254,29 +268,33 @@ void ImportFromwxSmith::GetGridBagSizerData(const wxXmlNode* node, wxcWidget* wr bool hasPos(false), hasSpan(false); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("row")); - if(propertynode) { + if (propertynode) { row = propertynode->GetNodeContent(); hasPos = true; } propertynode = XmlUtils::FindFirstByTagName(node, wxT("col")); - if(propertynode) { + if (propertynode) { column = propertynode->GetNodeContent(); hasPos = true; } propertynode = XmlUtils::FindFirstByTagName(node, wxT("rowspan")); - if(propertynode) { + if (propertynode) { rowspan = propertynode->GetNodeContent(); hasSpan = true; } propertynode = XmlUtils::FindFirstByTagName(node, wxT("colspan")); - if(propertynode) { + if (propertynode) { colspan = propertynode->GetNodeContent(); hasSpan = true; } - if(hasPos) { wrapper->SetGbPos(row + ',' + column); } - if(hasSpan) { wrapper->SetGbSpan(rowspan + ',' + colspan); } + if (hasPos) { + wrapper->SetGbPos(row + ',' + column); + } + if (hasSpan) { + wrapper->SetGbSpan(rowspan + ',' + colspan); + } } void ImportFromwxSmith::GetBookitemContents(const wxXmlNode* node, NotebookPageWrapper* wrapper, int& depth) const @@ -284,28 +302,34 @@ void ImportFromwxSmith::GetBookitemContents(const wxXmlNode* node, NotebookPageW wxString classname = XmlUtils::ReadString(node, wxT("class")); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("selected")); - if(propertynode) { + if (propertynode) { wxString selected = propertynode->GetNodeContent(); - if(selected == "1") { wrapper->SetSelected(true); } + if (selected == "1") { + wrapper->SetSelected(true); + } } propertynode = XmlUtils::FindFirstByTagName(node, wxT("label")); - if(propertynode) { + if (propertynode) { wxString label = propertynode->GetNodeContent(); PropertyBase* prop = wrapper->GetProperty(PROP_LABEL); - if(prop) { prop->SetValue(label); } + if (prop) { + prop->SetValue(label); + } } - if(classname != "choicebookpage") { // which don't have bitmaps + if (classname != "choicebookpage") { // which don't have bitmaps propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { + if (propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, wrapper, "PROP_BITMAP_PATH", "wxART_OTHER"); } } - if(classname == "treebookpage") { + if (classname == "treebookpage") { propertynode = XmlUtils::FindFirstByTagName(node, wxT("depth")); - if(propertynode) { depth = wxCrafter::ToNumber(propertynode->GetNodeContent(), 0); } + if (propertynode) { + depth = wxCrafter::ToNumber(propertynode->GetNodeContent(), 0); + } } } diff --git a/wxcrafter/Importer/import_from_xrc.cpp b/wxcrafter/Importer/import_from_xrc.cpp index 7c834a0aa5..edcd5b0161 100644 --- a/wxcrafter/Importer/import_from_xrc.cpp +++ b/wxcrafter/Importer/import_from_xrc.cpp @@ -21,24 +21,24 @@ ImportFromXrc::ImportFromXrc(wxWindow* parent) bool ImportFromXrc::ImportProject(ImportDlg::ImportFileData& data) const { ImportDlg dlg(ImportDlg::IPD_XRC, m_Parent); - if(dlg.ShowModal() != wxID_OK) { + if (dlg.ShowModal() != wxID_OK) { return false; } wxString filepath = dlg.GetFilepath(); - if(filepath.empty() || !wxFileExists(filepath)) { + if (filepath.empty() || !wxFileExists(filepath)) { return false; } wxXmlDocument doc(filepath); - if(!doc.IsOk()) { + if (!doc.IsOk()) { wxMessageBox(_("Failed to load the file to import"), wxT("CodeLite"), wxICON_ERROR | wxOK, m_Parent); return false; } wxcWidget::List_t toplevels; - if(ParseFile(doc, toplevels) && !toplevels.empty()) { + if (ParseFile(doc, toplevels) && !toplevels.empty()) { wxcProjectMetadata::Get().Serialize(toplevels, wxFileName(dlg.GetOutputFilepath())); data = dlg.GetData(); return true; @@ -49,17 +49,19 @@ bool ImportFromXrc::ImportProject(ImportDlg::ImportFileData& data) const bool ImportFromXrc::ParseFile(wxXmlDocument& doc, wxcWidget::List_t& toplevels) const { wxXmlNode* toplevelnode = doc.GetRoot()->GetChildren(); - while(toplevelnode) { + while (toplevelnode) { wxString tag = toplevelnode->GetName(); - if(tag != wxT("object")) { - wxMessageBox(_("This doesn't seem to be a valid XRC file. Aborting."), wxT("CodeLite"), wxICON_ERROR | wxOK, + if (tag != wxT("object")) { + wxMessageBox(_("This doesn't seem to be a valid XRC file. Aborting."), + wxT("CodeLite"), + wxICON_ERROR | wxOK, m_Parent); return false; } bool alreadyParented(false); wxcWidget* wrapper = ParseNode(toplevelnode, NULL, alreadyParented); - if(wrapper) { + if (wrapper) { toplevels.push_back(wrapper); } @@ -104,11 +106,11 @@ wxcWidget* ImportFromXrc::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, b wxString classname = XmlUtils::ReadString(node, wxT("class")); wxCHECK_MSG(!classname.empty(), NULL, wxT("Object node doesn't have a 'class' attribute")); - if(classname == wxT("sizeritem")) { + if (classname == wxT("sizeritem")) { // See the above comment. Replace node with the contained object node // We'll process sizeritemnode node separately later node = XmlUtils::FindFirstByTagName(node, wxT("object")); - if(!node) { + if (!node) { // I don't think this can happen, but... return NULL; } @@ -117,12 +119,12 @@ wxcWidget* ImportFromXrc::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, b classname = XmlUtils::ReadString(node, wxT("class")); } - else if(classname.Contains(wxT("bookpage"))) { + else if (classname.Contains(wxT("bookpage"))) { // See the above comment. Replace node with the contained object node // We'll process booknode node separately later booknode = node; node = XmlUtils::FindFirstByTagName(node, wxT("object")); - if(!node) { + if (!node) { // I don't think this can happen, but... return NULL; } @@ -131,49 +133,49 @@ wxcWidget* ImportFromXrc::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, b classname = XmlUtils::ReadString(node, wxT("class")); } - else if(classname == wxT("button")) { + else if (classname == wxT("button")) { buttonnode = node; node = XmlUtils::FindFirstByTagName(node, wxT("object")); - if(!node) { + if (!node) { return NULL; } classname = XmlUtils::ReadString(node, wxT("class")); - if(classname == "wxButton") { // and it certainly should be + if (classname == "wxButton") { // and it certainly should be classname = "stdbutton"; } } int Id = Allocator::StringToId(classname); - if(Id == wxNOT_FOUND) { + if (Id == wxNOT_FOUND) { wxLogWarning(wxString::Format(_("Can't import unknown class %s from XRC"), classname)); return NULL; } - if((Id == ID_WXPANEL) && (parentwrapper == NULL)) { + if ((Id == ID_WXPANEL) && (parentwrapper == NULL)) { Id = ID_WXPANEL_TOPLEVEL; } - if(parentwrapper && parentwrapper->GetWidgetType() == TYPE_TOOLBAR) { + if (parentwrapper && parentwrapper->GetWidgetType() == TYPE_TOOLBAR) { // In XRC, classname == "separator", which gives and Id of ID_WXMENUITEM, could be a menu or toolbar one // "space" is a stretchspacer - if(classname == "separator") { + if (classname == "separator") { Id = ID_WXTOOLBARITEM_SEPARATOR; - } else if(classname == "space") { + } else if (classname == "space") { Id = ID_WXTOOLBARITEM_STRETCHSPACE; } } - if(parentwrapper && parentwrapper->GetWidgetType() == TYPE_AUITOOLBAR) { + if (parentwrapper && parentwrapper->GetWidgetType() == TYPE_AUITOOLBAR) { // This time it could be separator, space, or label // "space" is a stretchspacer - if(classname == "separator") { + if (classname == "separator") { Id = ID_WXTOOLBARITEM_SEPARATOR; // No need for a specific one for aui - } else if(classname == "space") { + } else if (classname == "space") { // There were briefly 2 different words for 'space': space itself, and nonstretchspace // Now the official auitoolbar handler uses 'space' for both, distinguishing by the presence/absence of a // 'width' attribute, so do the same - if(XmlUtils::FindFirstByTagName(node, "width")) { + if (XmlUtils::FindFirstByTagName(node, "width")) { Id = ID_WXAUITOOLBARITEM_SPACE; } else { Id = ID_WXAUITOOLBARITEM_STRETCHSPACE; @@ -181,7 +183,7 @@ wxcWidget* ImportFromXrc::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, b } } - if(booknode) { + if (booknode) { // Correctly label a wxPanel that's really a notebookpage Id = ID_WXPANEL_NOTEBOOK_PAGE; } @@ -194,7 +196,7 @@ wxcWidget* ImportFromXrc::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, b GetSizeritemContents(sizeritemnode, wrapper); // Now we have a valid wrapper, we can store the sizeritem info in it int depth = 0; - if(booknode) { + if (booknode) { // For book pages, extract any info from the node NotebookPageWrapper* nbwrapper = dynamic_cast(wrapper); wxCHECK_MSG(nbwrapper, NULL, wxT("A booknode which has no NotebookPageWrapper")); @@ -202,12 +204,12 @@ wxcWidget* ImportFromXrc::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, b // If this is a treebook subpage, it needs to be parented by a page, not the book // depth will only be >0 in that situation - if(depth) { + if (depth) { NotebookBaseWrapper* nb = dynamic_cast(parentwrapper); wxCHECK_MSG(nb, NULL, wxT("treebookpage 'parent' not a book")); wxcWidget* item = nb->GetChildPageAtDepth(depth - 1); - if(item) { + if (item) { item->AddChild(wrapper); alreadyParented = true; } else { @@ -218,18 +220,18 @@ wxcWidget* ImportFromXrc::ParseNode(wxXmlNode* node, wxcWidget* parentwrapper, b } } - if(buttonnode) { + if (buttonnode) { // For wxStdDialogButtonSizer buttons, extract any info from the node ProcessButtonNode(buttonnode, wrapper); } wxXmlNode* child = node->GetChildren(); - while(child) { + while (child) { wxString childname(child->GetName()); - if(childname == wxT("object")) { + if (childname == wxT("object")) { bool alreadyParented(false); wxcWidget* childwrapper = ParseNode(child, wrapper, alreadyParented); - if(childwrapper && !alreadyParented) { + if (childwrapper && !alreadyParented) { wrapper->AddChild(childwrapper); } } @@ -245,65 +247,65 @@ void ImportFromXrc::GetSizeritemContents(const wxXmlNode* node, wxcWidget* wrapp wrapper->ClearSizerAll(); // otherwise the default ones will remain wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("flag")); - if(propertynode) { + if (propertynode) { wxString flags = propertynode->GetNodeContent(); // We must cope with wxC's American misspellings... flags.Replace("wxALIGN_CENTRE", "wxALIGN_CENTER"); // if left|right|top|bottom add wxALL. Duplication does no harm here - if(flags.Contains("wxLEFT") && flags.Contains("wxRIGHT") && flags.Contains("wxTOP") && - flags.Contains("wxBOTTOM")) { + if (flags.Contains("wxLEFT") && flags.Contains("wxRIGHT") && flags.Contains("wxTOP") && + flags.Contains("wxBOTTOM")) { flags << "|wxALL"; } wxArrayString flagsarray = wxCrafter::Split(flags, "|"); // Eran: If flagsarray contains 'wxALL' - make sure all the other four stars are also there... - if(flagsarray.Index("wxALL") != wxNOT_FOUND) { + if (flagsarray.Index("wxALL") != wxNOT_FOUND) { flagsarray.Add("wxLEFT"); flagsarray.Add("wxRIGHT"); flagsarray.Add("wxTOP"); flagsarray.Add("wxBOTTOM"); flagsarray = wxCrafter::MakeUnique(flagsarray); } - for(size_t n = 0; n < flagsarray.GetCount(); ++n) { + for (size_t n = 0; n < flagsarray.GetCount(); ++n) { wrapper->EnableSizerFlag(flagsarray.Item(n), true); } } propertynode = XmlUtils::FindFirstByTagName(node, wxT("option")); // 'option' is XRC's term for proportion :/ - if(propertynode) { + if (propertynode) { wxString proportion = propertynode->GetNodeContent(); wrapper->SizerItem().SetProportion(wxCrafter::ToNumber(proportion, 0)); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("border")); - if(propertynode) { + if (propertynode) { wxString border = propertynode->GetNodeContent(); wrapper->SizerItem().SetBorder(wxCrafter::ToNumber(border, 0)); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("cellpos")); - if(propertynode) { + if (propertynode) { wxString cellpos = propertynode->GetNodeContent(); - if(!cellpos.empty()) { + if (!cellpos.empty()) { wrapper->SetGbPos(cellpos); } } propertynode = XmlUtils::FindFirstByTagName(node, wxT("cellspan")); - if(propertynode) { + if (propertynode) { wxString cellspan = propertynode->GetNodeContent(); - if(!cellspan.empty()) { + if (!cellspan.empty()) { wrapper->SetGbSpan(cellspan); } } propertynode = XmlUtils::FindFirstByTagName(node, wxT("minsize")); - if(propertynode) { + if (propertynode) { wxString minsize = propertynode->GetNodeContent(); PropertyBase* prop = wrapper->GetProperty(PROP_MINSIZE); - if(prop) { + if (prop) { prop->SetValue(minsize); } } @@ -314,39 +316,40 @@ void ImportFromXrc::GetBookitemContents(const wxXmlNode* node, NotebookPageWrapp wxString classname = XmlUtils::ReadString(node, wxT("class")); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("selected")); - if(propertynode) { + if (propertynode) { wxString selected = propertynode->GetNodeContent(); - if(selected == "1") { + if (selected == "1") { wrapper->SetSelected(true); } } propertynode = XmlUtils::FindFirstByTagName(node, wxT("label")); - if(propertynode) { + if (propertynode) { wxString label = propertynode->GetNodeContent(); PropertyBase* prop = wrapper->GetProperty(PROP_LABEL); - if(prop) { + if (prop) { prop->SetValue(label); } } - if(classname != "choicebookpage") { // which don't have bitmaps + if (classname != "choicebookpage") { // which don't have bitmaps propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { + if (propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, wrapper, "PROP_BITMAP_PATH", "wxART_OTHER"); } } - if(classname == "treebookpage") { + if (classname == "treebookpage") { propertynode = XmlUtils::FindFirstByTagName(node, wxT("depth")); - if(propertynode) { + if (propertynode) { depth = wxCrafter::ToNumber(propertynode->GetNodeContent(), 0); } } } // static NB This is also used to import from wxSmith -void ImportFromXrc::ProcessBitmapProperty(const wxXmlNode* node, wxcWidget* wrapper, +void ImportFromXrc::ProcessBitmapProperty(const wxXmlNode* node, + wxcWidget* wrapper, const wxString& property /*= PROP_BITMAP_PATH*/, const wxString& client_hint /*=""*/) { @@ -354,12 +357,12 @@ void ImportFromXrc::ProcessBitmapProperty(const wxXmlNode* node, wxcWidget* wrap // (the some.png is optional here, but is used as a fallback if stock_id fails. wxC doesn't use this atm, so ignore // it here) wxString artstring = XmlUtils::ReadString(node, "stock_id"); - if(!artstring.empty()) { + if (!artstring.empty()) { wxString clientId = XmlUtils::ReadString(node, "stock_client"); - if(clientId.empty()) { + if (clientId.empty()) { clientId = client_hint; // Use any hint we were given } - if(!clientId.empty()) { + if (!clientId.empty()) { artstring << "," << clientId; } wrapper->SetPropertyString(property, artstring); @@ -382,23 +385,23 @@ void ImportFromXrc::DoProcessButtonNode(const wxXmlNode* node, wxcWidget* wrappe // Deduce a sensible ID. There isn't an id field in the xrc, so work it out from the name or label wxString name = wrapper->GetName().MakeLower(); wxString label = wrapper->Label().MakeLower(); - if(name.Contains("ok") || label.Contains("ok")) { + if (name.Contains("ok") || label.Contains("ok")) { wrapper->SetId("wxID_OK"); - } else if(name.Contains("cancel") || label.Contains("cancel")) { + } else if (name.Contains("cancel") || label.Contains("cancel")) { wrapper->SetId("wxID_CANCEL"); - } else if(name.Contains("yes") || label.Contains("yes")) { + } else if (name.Contains("yes") || label.Contains("yes")) { wrapper->SetId("wxID_YES"); - } else if(name.Contains("save") || label.Contains("save")) { + } else if (name.Contains("save") || label.Contains("save")) { wrapper->SetId("wxID_SAVE"); - } else if(name.Contains("apply") || label.Contains("apply")) { + } else if (name.Contains("apply") || label.Contains("apply")) { wrapper->SetId("wxID_APPLY"); - } else if(name.Contains("close") || label.Contains("close")) { + } else if (name.Contains("close") || label.Contains("close")) { wrapper->SetId("wxID_CLOSE"); - } else if(name.Contains("no") || label.Contains("no")) { + } else if (name.Contains("no") || label.Contains("no")) { wrapper->SetId("wxID_NO"); - } else if(name.Contains("context") || label.Contains("context")) { + } else if (name.Contains("context") || label.Contains("context")) { wrapper->SetId("wxID_CONTEXT_HELP"); - } else if(name.Contains("help") || label.Contains("help")) { + } else if (name.Contains("help") || label.Contains("help")) { wrapper->SetId("wxID_HELP"); } } @@ -408,10 +411,10 @@ void ImportFromXrc::ProcessNamedNode(wxXmlNode* node, wxcWidget* parentwrapper, // This is for processing the child menu of an auitoolbar dropdownitem (but might be useful elsewhere in the future) // The original node was , not , so normal parsing would ignore any children wxXmlNode* childnode = XmlUtils::FindFirstByTagName(node, "object"); - if(childnode && (XmlUtils::ReadString(childnode, "class") == name)) { + if (childnode && (XmlUtils::ReadString(childnode, "class") == name)) { bool alreadyParented(false); wxcWidget* childwrapper = ParseNode(childnode, parentwrapper, alreadyParented); - if(childwrapper) { + if (childwrapper) { parentwrapper->AddChild(childwrapper); } } diff --git a/wxcrafter/Importer/import_from_xrc.h b/wxcrafter/Importer/import_from_xrc.h index c212c94ee9..2e2d934c3e 100644 --- a/wxcrafter/Importer/import_from_xrc.h +++ b/wxcrafter/Importer/import_from_xrc.h @@ -16,9 +16,12 @@ class ImportFromXrc bool ImportProject(ImportDlg::ImportFileData& data) const; bool GetProject() const; static void DoProcessButtonNode(const wxXmlNode* node, wxcWidget* wrapper); - static void ProcessBitmapProperty(const wxXmlNode* node, wxcWidget* wrapper, - const wxString& property = PROP_BITMAP_PATH, const wxString& client_hint = ""); - void ProcessNamedNode(wxXmlNode* node, wxcWidget* parentwrapper, + static void ProcessBitmapProperty(const wxXmlNode* node, + wxcWidget* wrapper, + const wxString& property = PROP_BITMAP_PATH, + const wxString& client_hint = ""); + void ProcessNamedNode(wxXmlNode* node, + wxcWidget* parentwrapper, const wxString& name) const; // Used for auitoolbar dropdown nodes protected: diff --git a/wxcrafter/Preview/CaptionBar.cpp b/wxcrafter/Preview/CaptionBar.cpp index 4af0becd44..abdd66e499 100644 --- a/wxcrafter/Preview/CaptionBar.cpp +++ b/wxcrafter/Preview/CaptionBar.cpp @@ -54,7 +54,7 @@ void CaptionBar::OnPaint(wxPaintEvent& event) #endif wxCoord curx = 5; - if(m_icon.IsOk()) { + if (m_icon.IsOk()) { // Draw the frame icon wxCoord bmpy = (GetClientRect().GetHeight() - m_icon.GetHeight()) / 2; dc.DrawBitmap(m_icon, 5, bmpy); @@ -82,20 +82,20 @@ void CaptionBar::OnPaint(wxPaintEvent& event) int bmpSize = 0; const wxBitmap& bmpClose = myImages.Bitmap("button_close"); - if(styles.Index("wxCLOSE_BOX") != wxNOT_FOUND || styles.Index("wxDEFAULT_DIALOG_STYLE") != wxNOT_FOUND || - styles.Index("wxDEFAULT_FRAME_STYLE") != wxNOT_FOUND) { + if (styles.Index("wxCLOSE_BOX") != wxNOT_FOUND || styles.Index("wxDEFAULT_DIALOG_STYLE") != wxNOT_FOUND || + styles.Index("wxDEFAULT_FRAME_STYLE") != wxNOT_FOUND) { // draw close box draw_close_button = true; bmpSize += bmpClose.GetWidth(); } - if(styles.Index("wxMINIMIZE_BOX") != wxNOT_FOUND || styles.Index("wxDEFAULT_FRAME_STYLE") != wxNOT_FOUND) { + if (styles.Index("wxMINIMIZE_BOX") != wxNOT_FOUND || styles.Index("wxDEFAULT_FRAME_STYLE") != wxNOT_FOUND) { // draw close box draw_minimize_button = true; bmpSize += bmpClose.GetWidth(); } - if(styles.Index("wxMAXIMIZE_BOX") != wxNOT_FOUND || styles.Index("wxDEFAULT_FRAME_STYLE") != wxNOT_FOUND) { + if (styles.Index("wxMAXIMIZE_BOX") != wxNOT_FOUND || styles.Index("wxDEFAULT_FRAME_STYLE") != wxNOT_FOUND) { // draw close box draw_maximize_button = true; bmpSize += bmpClose.GetWidth(); @@ -105,17 +105,17 @@ void CaptionBar::OnPaint(wxPaintEvent& event) int button_x = clientRect.GetWidth() - bmpSize - 2; int button_y = (clientRect.GetHeight() - bmpClose.GetHeight()) / 2; - if(draw_minimize_button) { + if (draw_minimize_button) { dc.DrawBitmap(myImages.Bitmap("button_minimize"), button_x, button_y, true); button_x += bmpClose.GetWidth(); } - if(draw_maximize_button) { + if (draw_maximize_button) { dc.DrawBitmap(myImages.Bitmap("button_maximize"), button_x, button_y, true); button_x += bmpClose.GetWidth(); } - if(draw_close_button) { + if (draw_close_button) { dc.DrawBitmap(myImages.Bitmap("button_close"), button_x, button_y, true); button_x += bmpClose.GetWidth(); } diff --git a/wxcrafter/Preview/CaptionBar.h b/wxcrafter/Preview/CaptionBar.h index 8f3950a37c..fbe3cb2f65 100644 --- a/wxcrafter/Preview/CaptionBar.h +++ b/wxcrafter/Preview/CaptionBar.h @@ -2,6 +2,7 @@ #define CAPTIONBAR_H #include "gui.h" + #include class CaptionBar : public CaptionBarBase diff --git a/wxcrafter/Preview/menu_bar.cpp b/wxcrafter/Preview/menu_bar.cpp index bad0941877..67dc0eb541 100644 --- a/wxcrafter/Preview/menu_bar.cpp +++ b/wxcrafter/Preview/menu_bar.cpp @@ -26,7 +26,7 @@ MenuBar::MenuBar(wxWindow* parent, wxMenuBar* mb) , m_mb(mb) , m_controlHeight(30) { - for(size_t i = 0; i < m_mb->GetMenuCount(); i++) { + for (size_t i = 0; i < m_mb->GetMenuCount(); i++) { MenuInfo mi; mi.label = m_mb->GetMenuLabelText(i); mi.menu = m_mb->GetMenu(i); @@ -35,7 +35,7 @@ MenuBar::MenuBar(wxWindow* parent, wxMenuBar* mb) // Remove the menus size_t nCount = m_mb->GetMenuCount(); - for(size_t i = 0; i < nCount; ++i) { + for (size_t i = 0; i < nCount; ++i) { m_mb->Remove(0); } m_mbname = wxT("MENU_BAR_ID"); @@ -71,14 +71,14 @@ void MenuBar::OnLeftDown(wxMouseEvent& e) { size_t where = wxString::npos; wxPoint pt = e.GetPosition(); - for(size_t i = 0; i < m_menus.size(); i++) { - if(m_menus.at(i).rect.Contains(pt)) { + for (size_t i = 0; i < m_menus.size(); i++) { + if (m_menus.at(i).rect.Contains(pt)) { where = i; break; } } - if(where == wxString::npos) { + if (where == wxString::npos) { wxCommandEvent evt(wxEVT_PREVIEW_BAR_SELECTED); evt.SetString(wxT("")); EventNotifier::Get()->AddPendingEvent(evt); @@ -86,7 +86,7 @@ void MenuBar::OnLeftDown(wxMouseEvent& e) } wxString name; - if(m_menus.at(where).menu) { + if (m_menus.at(where).menu) { wxMenu* menu = m_menus.at(where).menu; wxCommandEvent evt(wxEVT_PREVIEW_BAR_SELECTED); @@ -116,7 +116,7 @@ void MenuBar::OnPaint(wxPaintEvent& e) int posy = MARGIN_Y; size_t count = m_menus.size(); - for(size_t i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { wxString menuTitle = m_menus.at(i).label; dc.GetTextExtent(menuTitle, &width, &height, NULL, NULL, &font); diff --git a/wxcrafter/Preview/popup_window_preview.cpp b/wxcrafter/Preview/popup_window_preview.cpp index 2cbab9f043..1f0e56abee 100644 --- a/wxcrafter/Preview/popup_window_preview.cpp +++ b/wxcrafter/Preview/popup_window_preview.cpp @@ -38,14 +38,14 @@ PopupWindowPreview::PopupWindowPreview(wxWindow* parent, const PopupWindowWrappe Center(); sz->Layout(); GetSizer()->Fit(this); - EventNotifier::Get()->Connect(wxEVT_CLOSE_PREVIEW, - wxCommandEventHandler(PopupWindowPreview::OnClosePreviewPreviewPanel), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PopupWindowPreview::OnClosePreviewPreviewPanel), NULL, this); } PopupWindowPreview::~PopupWindowPreview() { - EventNotifier::Get()->Disconnect(wxEVT_CLOSE_PREVIEW, - wxCommandEventHandler(PopupWindowPreview::OnClosePreviewPreviewPanel), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PopupWindowPreview::OnClosePreviewPreviewPanel), NULL, this); wxCommandEvent event(wxEVT_PREVIEW_CLOSED); EventNotifier::Get()->AddPendingEvent(event); } diff --git a/wxcrafter/Preview/popup_window_preview.h b/wxcrafter/Preview/popup_window_preview.h index 49c3d9512e..01b10ddf32 100644 --- a/wxcrafter/Preview/popup_window_preview.h +++ b/wxcrafter/Preview/popup_window_preview.h @@ -2,6 +2,7 @@ #define POPUPWINDOWPREVIEW_H #include "popup_window_wrapper.h" + #include class PopupWindowPreview : public wxFrame diff --git a/wxcrafter/Preview/preview_dialog.cpp b/wxcrafter/Preview/preview_dialog.cpp index 3b5db02b19..1e396fa044 100644 --- a/wxcrafter/Preview/preview_dialog.cpp +++ b/wxcrafter/Preview/preview_dialog.cpp @@ -40,15 +40,15 @@ PreviewDialog::PreviewDialog(wxWindow* parent, const DialogWrapper& dw) SetSizeHints(sz); Layout(); - EventNotifier::Get()->Connect(wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewDialog::OnClosePreview), NULL, - this); + EventNotifier::Get()->Connect( + wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewDialog::OnClosePreview), NULL, this); } PreviewDialog::~PreviewDialog() { wxcAuiManager::Get().UnInit(this); - EventNotifier::Get()->Disconnect(wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewDialog::OnClosePreview), NULL, - this); + EventNotifier::Get()->Disconnect( + wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewDialog::OnClosePreview), NULL, this); wxCommandEvent event(wxEVT_PREVIEW_CLOSED); EventNotifier::Get()->AddPendingEvent(event); diff --git a/wxcrafter/Preview/preview_dialog.h b/wxcrafter/Preview/preview_dialog.h index f48f0e6b13..99dc6a3c13 100644 --- a/wxcrafter/Preview/preview_dialog.h +++ b/wxcrafter/Preview/preview_dialog.h @@ -2,6 +2,7 @@ #define PREVIEWDIALOG_H #include "dialog_wrapper.h" + #include class PreviewDialog : public wxDialog diff --git a/wxcrafter/Preview/preview_frame.cpp b/wxcrafter/Preview/preview_frame.cpp index ab750b2d15..ca407677eb 100644 --- a/wxcrafter/Preview/preview_frame.cpp +++ b/wxcrafter/Preview/preview_frame.cpp @@ -34,7 +34,7 @@ PreviewFrame::PreviewFrame(wxWindow* parent, const TopLevelWinWrapper& fw) Center(); SetSizeHints(sz); - if(wxcAuiManager::Get().Find(this)) { + if (wxcAuiManager::Get().Find(this)) { wxcAuiManager::Get().Find(this)->Update(); } else { Layout(); @@ -46,8 +46,8 @@ PreviewFrame::PreviewFrame(wxWindow* parent, const TopLevelWinWrapper& fw) PreviewFrame::~PreviewFrame() { wxcAuiManager::Get().UnInit(this); - EventNotifier::Get()->Disconnect(wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewFrame::OnClosePreview), NULL, - this); + EventNotifier::Get()->Disconnect( + wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewFrame::OnClosePreview), NULL, this); wxCommandEvent event(wxEVT_PREVIEW_CLOSED); EventNotifier::Get()->AddPendingEvent(event); } diff --git a/wxcrafter/Preview/preview_frame.h b/wxcrafter/Preview/preview_frame.h index 57f165c21a..2272c37c57 100644 --- a/wxcrafter/Preview/preview_frame.h +++ b/wxcrafter/Preview/preview_frame.h @@ -2,6 +2,7 @@ #define PREVIEWFRAME_H #include "frame_wrapper.h" + #include // Base class: wxFrame class PreviewFrame : public wxFrame diff --git a/wxcrafter/Preview/preview_panel.cpp b/wxcrafter/Preview/preview_panel.cpp index 74ed064bae..0d814cf83b 100644 --- a/wxcrafter/Preview/preview_panel.cpp +++ b/wxcrafter/Preview/preview_panel.cpp @@ -40,14 +40,14 @@ PreviewPanel::PreviewPanel(wxWindow* parent, const TopLevelWinWrapper& fw) Center(); sz->Layout(); GetSizer()->Fit(this); - EventNotifier::Get()->Connect(wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewPanel::OnClosePreviewPreviewPanel), - NULL, this); + EventNotifier::Get()->Connect( + wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewPanel::OnClosePreviewPreviewPanel), NULL, this); } PreviewPanel::~PreviewPanel() { - EventNotifier::Get()->Disconnect(wxEVT_CLOSE_PREVIEW, - wxCommandEventHandler(PreviewPanel::OnClosePreviewPreviewPanel), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewPanel::OnClosePreviewPreviewPanel), NULL, this); wxCommandEvent event(wxEVT_PREVIEW_CLOSED); EventNotifier::Get()->AddPendingEvent(event); } diff --git a/wxcrafter/Preview/preview_wizard.cpp b/wxcrafter/Preview/preview_wizard.cpp index 364f393013..d44d5b77b0 100644 --- a/wxcrafter/Preview/preview_wizard.cpp +++ b/wxcrafter/Preview/preview_wizard.cpp @@ -34,14 +34,14 @@ PreviewWizard::PreviewWizard(wxWindow* parent, const WizardWrapper& dw) wxXmlResource::Get()->Unload(xrcFilePath); Center(); - EventNotifier::Get()->Connect(wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewWizard::OnClosePreview), NULL, - this); + EventNotifier::Get()->Connect( + wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewWizard::OnClosePreview), NULL, this); } PreviewWizard::~PreviewWizard() { - EventNotifier::Get()->Disconnect(wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewWizard::OnClosePreview), NULL, - this); + EventNotifier::Get()->Disconnect( + wxEVT_CLOSE_PREVIEW, wxCommandEventHandler(PreviewWizard::OnClosePreview), NULL, this); wxCommandEvent event(wxEVT_PREVIEW_CLOSED); EventNotifier::Get()->AddPendingEvent(event); @@ -62,7 +62,7 @@ void PreviewWizard::OnClose(wxCloseEvent& e) void PreviewWizard::Run() { wxWizardPageSimple* pageOne = XRCCTRL((*this), "WIZARD_PAGE_ONE", wxWizardPageSimple); - if(pageOne) { + if (pageOne) { GetPageAreaSizer()->Add(pageOne); RunWizard(pageOne); } diff --git a/wxcrafter/Preview/preview_wizard.h b/wxcrafter/Preview/preview_wizard.h index 51fc9f8fa2..14de0b484e 100644 --- a/wxcrafter/Preview/preview_wizard.h +++ b/wxcrafter/Preview/preview_wizard.h @@ -2,6 +2,7 @@ #define PREVIEWWIZARD_H #include "wizard_wrapper.h" + #include class PreviewWizard : public wxWizard diff --git a/wxcrafter/Preview/tool_bar.cpp b/wxcrafter/Preview/tool_bar.cpp index acec66494b..b021e29e2c 100644 --- a/wxcrafter/Preview/tool_bar.cpp +++ b/wxcrafter/Preview/tool_bar.cpp @@ -24,9 +24,9 @@ void ToolBar::AddToolbar(wxToolBar* tb) void ToolBar::OnClick(wxCommandEvent& e) { e.Skip(); - if(m_wxtb) { + if (m_wxtb) { wxToolBarToolBase* tool = m_wxtb->FindById(e.GetId()); - if(tool) { + if (tool) { wxString label = tool->GetLabel(); wxString s; s << m_wxtb->GetName() << wxT(":") << label; diff --git a/wxcrafter/Properties/bool_property.cpp b/wxcrafter/Properties/bool_property.cpp index f0d52427c6..e469c4ed24 100644 --- a/wxcrafter/Properties/bool_property.cpp +++ b/wxcrafter/Properties/bool_property.cpp @@ -14,7 +14,7 @@ BoolProperty::BoolProperty() wxString BoolProperty::GetValue() const { - if(m_value) { + if (m_value) { return wxT("1"); } else { @@ -24,7 +24,7 @@ wxString BoolProperty::GetValue() const void BoolProperty::SetValue(const wxString& value) { - if(value == wxT("1")) { + if (value == wxT("1")) { m_value = true; } else { m_value = false; diff --git a/wxcrafter/Properties/category_property.cpp b/wxcrafter/Properties/category_property.cpp index be2eca9b51..3fd57766e3 100644 --- a/wxcrafter/Properties/category_property.cpp +++ b/wxcrafter/Properties/category_property.cpp @@ -4,7 +4,7 @@ CategoryProperty::CategoryProperty(const wxString& name, const wxString& label) : PropertyBase(name) , m_value(name) { - if(label.IsEmpty()) + if (label.IsEmpty()) SetLabel(name); else SetLabel(label); diff --git a/wxcrafter/Properties/choice_property.cpp b/wxcrafter/Properties/choice_property.cpp index ae6477887f..a04ecb2543 100644 --- a/wxcrafter/Properties/choice_property.cpp +++ b/wxcrafter/Properties/choice_property.cpp @@ -18,21 +18,23 @@ ChoiceProperty::ChoiceProperty(const wxString& label, const wxArrayString& optio void ChoiceProperty::SetSelection(int selection) { - if(selection < 0 || selection >= (int)m_options.GetCount()) return; + if (selection < 0 || selection >= (int)m_options.GetCount()) + return; this->m_selection = selection; } wxString ChoiceProperty::GetValue() const { - if(m_selection < 0 || m_selection >= (int)m_options.GetCount()) return wxT(""); + if (m_selection < 0 || m_selection >= (int)m_options.GetCount()) + return wxT(""); return m_options.Item(m_selection); } void ChoiceProperty::SetValue(const wxString& value) { int where = m_options.Index(value); - if(where == wxNOT_FOUND) { + if (where == wxNOT_FOUND) { m_selection = m_options.Add(value); } else { @@ -43,7 +45,8 @@ void ChoiceProperty::SetValue(const wxString& value) void ChoiceProperty::Add(const wxString& value) { int where = m_options.Index(value); - if(where == wxNOT_FOUND) m_options.Add(value); + if (where == wxNOT_FOUND) + m_options.Add(value); } JSONItem ChoiceProperty::Serialize() const diff --git a/wxcrafter/Properties/choice_property.h b/wxcrafter/Properties/choice_property.h index 29bb6f30b1..f366bf87bd 100644 --- a/wxcrafter/Properties/choice_property.h +++ b/wxcrafter/Properties/choice_property.h @@ -2,6 +2,7 @@ #define CHOICEPROPERTY_H #include "property_base.h" + #include class ChoiceProperty : public PropertyBase diff --git a/wxcrafter/Properties/col_header_flags_property.cpp b/wxcrafter/Properties/col_header_flags_property.cpp index 38f8a9f7f2..ea58ebc5e2 100644 --- a/wxcrafter/Properties/col_header_flags_property.cpp +++ b/wxcrafter/Properties/col_header_flags_property.cpp @@ -3,16 +3,18 @@ #include "StdToWX.h" #include "wxgui_helpers.h" -#include #include +#include -ColHeaderFlagsProperty::ColHeaderFlagsProperty(const wxString& label, int initialValue, const wxString& tip, +ColHeaderFlagsProperty::ColHeaderFlagsProperty(const wxString& label, + int initialValue, + const wxString& tip, eColumnKind kind) : PropertyBase(tip) , m_initialValue(initialValue) { SetLabel(label); - if(kind == eColumnKind::kListCtrl) { + if (kind == eColumnKind::kListCtrl) { m_names = StdToWX::ToArrayString({ "wxCOL_RESIZABLE", "wxCOL_SORTABLE", @@ -26,8 +28,10 @@ ColHeaderFlagsProperty::ColHeaderFlagsProperty(const wxString& label, int initia m_values.Add(wxCOL_HIDDEN); } else { - m_names = StdToWX::ToArrayString({ "wxDATAVIEW_COL_RESIZABLE", "wxDATAVIEW_COL_SORTABLE", - "wxDATAVIEW_COL_REORDERABLE", "wxDATAVIEW_COL_HIDDEN" }); + m_names = StdToWX::ToArrayString({"wxDATAVIEW_COL_RESIZABLE", + "wxDATAVIEW_COL_SORTABLE", + "wxDATAVIEW_COL_REORDERABLE", + "wxDATAVIEW_COL_HIDDEN"}); m_values.Add(wxDATAVIEW_COL_RESIZABLE); m_values.Add(wxDATAVIEW_COL_SORTABLE); m_values.Add(wxDATAVIEW_COL_REORDERABLE); @@ -45,10 +49,14 @@ PropertyeType ColHeaderFlagsProperty::GetType() { return PT_COL_HEADER_FLAGS; } wxString ColHeaderFlagsProperty::GetValue() const { wxString str_value; - for(size_t i = 0; i < m_values.GetCount(); ++i) { - if(m_initialValue & m_values.Item(i)) { str_value << m_names.Item(i) << "|"; } + for (size_t i = 0; i < m_values.GetCount(); ++i) { + if (m_initialValue & m_values.Item(i)) { + str_value << m_names.Item(i) << "|"; + } + } + if (!str_value.IsEmpty()) { + str_value.RemoveLast(); } - if(!str_value.IsEmpty()) { str_value.RemoveLast(); } return str_value; } @@ -56,9 +64,11 @@ void ColHeaderFlagsProperty::SetValue(const wxString& value) { m_initialValue = 0; wxArrayString selections = wxCrafter::Split(value, "|,;"); - for(size_t i = 0; i < selections.GetCount(); ++i) { + for (size_t i = 0; i < selections.GetCount(); ++i) { int index = m_names.Index(selections.Item(i)); - if(index != wxNOT_FOUND) { m_initialValue |= m_values.Item(index); } + if (index != wxNOT_FOUND) { + m_initialValue |= m_values.Item(index); + } } } diff --git a/wxcrafter/Properties/col_header_flags_property.h b/wxcrafter/Properties/col_header_flags_property.h index 22cfd58f49..9b787bb7ac 100644 --- a/wxcrafter/Properties/col_header_flags_property.h +++ b/wxcrafter/Properties/col_header_flags_property.h @@ -20,7 +20,9 @@ class ColHeaderFlagsProperty : public PropertyBase long GetValueLong() const override; ColHeaderFlagsProperty(); - ColHeaderFlagsProperty(const wxString& label, int initialValue, const wxString& tip, + ColHeaderFlagsProperty(const wxString& label, + int initialValue, + const wxString& tip, eColumnKind kind = eColumnKind::kListCtrl); ~ColHeaderFlagsProperty() override = default; diff --git a/wxcrafter/Properties/file_ficker_property.cpp b/wxcrafter/Properties/file_ficker_property.cpp index feeb8d3732..2e4c58736f 100644 --- a/wxcrafter/Properties/file_ficker_property.cpp +++ b/wxcrafter/Properties/file_ficker_property.cpp @@ -42,10 +42,12 @@ void FilePickerProperty::UnSerialize(const JSONItem& json) void FilePickerProperty::FixPaths(const wxString& cwd) { wxString wd = cwd; - if(wd.IsEmpty()) { wd = wxcProjectMetadata::Get().GetProjectPath(); } + if (wd.IsEmpty()) { + wd = wxcProjectMetadata::Get().GetProjectPath(); + } wxFileName fn(m_path); - if(fn.IsAbsolute() && wd.IsEmpty() == false) { + if (fn.IsAbsolute() && wd.IsEmpty() == false) { fn.MakeRelativeTo(wd); m_path = fn.GetFullPath(); } diff --git a/wxcrafter/Properties/int_property.cpp b/wxcrafter/Properties/int_property.cpp index 3d496b8da9..95dd4a6db8 100644 --- a/wxcrafter/Properties/int_property.cpp +++ b/wxcrafter/Properties/int_property.cpp @@ -37,7 +37,7 @@ JSONItem IntProperty::Serialize() const void IntProperty::SetValue(const wxString& value) { long i(-1); - if(value.ToLong(&i)) { + if (value.ToLong(&i)) { m_value = i; } else { m_value = -1; diff --git a/wxcrafter/Properties/multi_strings_property.cpp b/wxcrafter/Properties/multi_strings_property.cpp index a87433be00..be20d7da49 100644 --- a/wxcrafter/Properties/multi_strings_property.cpp +++ b/wxcrafter/Properties/multi_strings_property.cpp @@ -1,6 +1,8 @@ #include "multi_strings_property.h" -MultiStringsProperty::MultiStringsProperty(const wxString& label, const wxString& tooltip, const wxString& delim, +MultiStringsProperty::MultiStringsProperty(const wxString& label, + const wxString& tooltip, + const wxString& delim, const wxString& msg) : PropertyBase(tooltip) , m_delim(delim) diff --git a/wxcrafter/Properties/multi_strings_property.h b/wxcrafter/Properties/multi_strings_property.h index 2ee5668ea3..36070aeed3 100644 --- a/wxcrafter/Properties/multi_strings_property.h +++ b/wxcrafter/Properties/multi_strings_property.h @@ -12,7 +12,9 @@ class MultiStringsProperty : public PropertyBase wxString m_value; public: - MultiStringsProperty(const wxString& label, const wxString& tooltip, const wxString& delim = wxT(";"), + MultiStringsProperty(const wxString& label, + const wxString& tooltip, + const wxString& delim = wxT(";"), const wxString& msg = wxT("")); ~MultiStringsProperty() override = default; diff --git a/wxcrafter/Properties/string_property.h b/wxcrafter/Properties/string_property.h index cc6d7ea408..9c78620335 100644 --- a/wxcrafter/Properties/string_property.h +++ b/wxcrafter/Properties/string_property.h @@ -22,6 +22,7 @@ class StringProperty : public MultiStringsProperty ~StringProperty() override = default; void operator=(const wxString& src) { m_value = src; } + public: wxString GetValue() const override; void SetValue(const wxString& value) override; diff --git a/wxcrafter/Properties/winid_property.cpp b/wxcrafter/Properties/winid_property.cpp index 4b3f26dbfd..32e3ea77a3 100644 --- a/wxcrafter/Properties/winid_property.cpp +++ b/wxcrafter/Properties/winid_property.cpp @@ -16,111 +16,111 @@ WinIdProperty::WinIdProperty() SetLabel(PROP_WINDOW_ID); m_winid = wxT("wxID_ANY"); - if(s_options.IsEmpty()) { - s_options = StdToWX::ToArrayString({ wxT("wxID_ANY"), - wxT("wxID_SEPARATOR"), - wxT("wxID_OPEN"), - wxT("wxID_CLOSE"), - wxT("wxID_NEW"), - wxT("wxID_SAVE"), - wxT("wxID_SAVEAS"), - wxT("wxID_REVERT"), - wxT("wxID_EXIT"), - wxT("wxID_UNDO"), - wxT("wxID_REDO"), - wxT("wxID_HELP"), - wxT("wxID_PRINT"), - wxT("wxID_PRINT_SETUP"), - wxT("wxID_PAGE_SETUP"), - wxT("wxID_PREVIEW"), - wxT("wxID_ABOUT"), - wxT("wxID_HELP_CONTENTS"), - wxT("wxID_HELP_INDEX"), - wxT("wxID_HELP_SEARCH"), - wxT("wxID_HELP_COMMANDS"), - wxT("wxID_HELP_PROCEDURES"), - wxT("wxID_HELP_CONTEXT"), - wxT("wxID_CLOSE_ALL"), - wxT("wxID_PREFERENCES"), - wxT("wxID_EDIT"), - wxT("wxID_CUT"), - wxT("wxID_COPY"), - wxT("wxID_PASTE"), - wxT("wxID_CLEAR"), - wxT("wxID_FIND"), - wxT("wxID_DUPLICATE"), - wxT("wxID_SELECTALL"), - wxT("wxID_DELETE"), - wxT("wxID_REPLACE"), - wxT("wxID_REPLACE_ALL"), - wxT("wxID_PROPERTIES"), - wxT("wxID_VIEW_DETAILS"), - wxT("wxID_VIEW_LARGEICONS"), - wxT("wxID_VIEW_SMALLICONS"), - wxT("wxID_VIEW_LIST"), - wxT("wxID_VIEW_SORTDATE"), - wxT("wxID_VIEW_SORTNAME"), - wxT("wxID_VIEW_SORTSIZE"), - wxT("wxID_VIEW_SORTTYPE"), - wxT("wxID_OK"), - wxT("wxID_CANCEL"), - wxT("wxID_APPLY"), - wxT("wxID_YES"), - wxT("wxID_NO"), - wxT("wxID_STATIC"), - wxT("wxID_FORWARD"), - wxT("wxID_BACKWARD"), - wxT("wxID_DEFAULT"), - wxT("wxID_MORE"), - wxT("wxID_SETUP"), - wxT("wxID_RESET"), - wxT("wxID_CONTEXT_HELP"), - wxT("wxID_YESTOALL"), - wxT("wxID_NOTOALL"), - wxT("wxID_ABORT"), - wxT("wxID_RETRY"), - wxT("wxID_IGNORE"), - wxT("wxID_ADD"), - wxT("wxID_REMOVE"), - wxT("wxID_UP"), - wxT("wxID_DOWN"), - wxT("wxID_HOME"), - wxT("wxID_REFRESH"), - wxT("wxID_STOP"), - wxT("wxID_INDEX"), - wxT("wxID_BOLD"), - wxT("wxID_ITALIC"), - wxT("wxID_JUSTIFY_CENTER"), - wxT("wxID_JUSTIFY_FILL"), - wxT("wxID_JUSTIFY_RIGHT"), - wxT("wxID_JUSTIFY_LEFT"), - wxT("wxID_UNDERLINE"), - wxT("wxID_INDENT"), - wxT("wxID_UNINDENT"), - wxT("wxID_ZOOM_100"), - wxT("wxID_ZOOM_FIT"), - wxT("wxID_ZOOM_IN"), - wxT("wxID_ZOOM_OUT"), - wxT("wxID_UNDELETE"), - wxT("wxID_REVERT_TO_SAVED"), - wxT("wxID_CDROM"), - wxT("wxID_CONVERT"), - wxT("wxID_EXECUTE"), - wxT("wxID_FLOPPY"), - wxT("wxID_HARDDISK"), - wxT("wxID_BOTTOM"), - wxT("wxID_FIRST"), - wxT("wxID_LAST"), - wxT("wxID_TOP"), - wxT("wxID_INFO"), - wxT("wxID_JUMP_TO"), - wxT("wxID_NETWORK"), - wxT("wxID_SELECT_COLOR"), - wxT("wxID_SELECT_FONT"), - wxT("wxID_SORT_ASCENDING"), - wxT("wxID_SORT_DESCENDING"), - wxT("wxID_SPELL_CHECK"), - wxT("wxID_STRIKETHROUGH") }); + if (s_options.IsEmpty()) { + s_options = StdToWX::ToArrayString({wxT("wxID_ANY"), + wxT("wxID_SEPARATOR"), + wxT("wxID_OPEN"), + wxT("wxID_CLOSE"), + wxT("wxID_NEW"), + wxT("wxID_SAVE"), + wxT("wxID_SAVEAS"), + wxT("wxID_REVERT"), + wxT("wxID_EXIT"), + wxT("wxID_UNDO"), + wxT("wxID_REDO"), + wxT("wxID_HELP"), + wxT("wxID_PRINT"), + wxT("wxID_PRINT_SETUP"), + wxT("wxID_PAGE_SETUP"), + wxT("wxID_PREVIEW"), + wxT("wxID_ABOUT"), + wxT("wxID_HELP_CONTENTS"), + wxT("wxID_HELP_INDEX"), + wxT("wxID_HELP_SEARCH"), + wxT("wxID_HELP_COMMANDS"), + wxT("wxID_HELP_PROCEDURES"), + wxT("wxID_HELP_CONTEXT"), + wxT("wxID_CLOSE_ALL"), + wxT("wxID_PREFERENCES"), + wxT("wxID_EDIT"), + wxT("wxID_CUT"), + wxT("wxID_COPY"), + wxT("wxID_PASTE"), + wxT("wxID_CLEAR"), + wxT("wxID_FIND"), + wxT("wxID_DUPLICATE"), + wxT("wxID_SELECTALL"), + wxT("wxID_DELETE"), + wxT("wxID_REPLACE"), + wxT("wxID_REPLACE_ALL"), + wxT("wxID_PROPERTIES"), + wxT("wxID_VIEW_DETAILS"), + wxT("wxID_VIEW_LARGEICONS"), + wxT("wxID_VIEW_SMALLICONS"), + wxT("wxID_VIEW_LIST"), + wxT("wxID_VIEW_SORTDATE"), + wxT("wxID_VIEW_SORTNAME"), + wxT("wxID_VIEW_SORTSIZE"), + wxT("wxID_VIEW_SORTTYPE"), + wxT("wxID_OK"), + wxT("wxID_CANCEL"), + wxT("wxID_APPLY"), + wxT("wxID_YES"), + wxT("wxID_NO"), + wxT("wxID_STATIC"), + wxT("wxID_FORWARD"), + wxT("wxID_BACKWARD"), + wxT("wxID_DEFAULT"), + wxT("wxID_MORE"), + wxT("wxID_SETUP"), + wxT("wxID_RESET"), + wxT("wxID_CONTEXT_HELP"), + wxT("wxID_YESTOALL"), + wxT("wxID_NOTOALL"), + wxT("wxID_ABORT"), + wxT("wxID_RETRY"), + wxT("wxID_IGNORE"), + wxT("wxID_ADD"), + wxT("wxID_REMOVE"), + wxT("wxID_UP"), + wxT("wxID_DOWN"), + wxT("wxID_HOME"), + wxT("wxID_REFRESH"), + wxT("wxID_STOP"), + wxT("wxID_INDEX"), + wxT("wxID_BOLD"), + wxT("wxID_ITALIC"), + wxT("wxID_JUSTIFY_CENTER"), + wxT("wxID_JUSTIFY_FILL"), + wxT("wxID_JUSTIFY_RIGHT"), + wxT("wxID_JUSTIFY_LEFT"), + wxT("wxID_UNDERLINE"), + wxT("wxID_INDENT"), + wxT("wxID_UNINDENT"), + wxT("wxID_ZOOM_100"), + wxT("wxID_ZOOM_FIT"), + wxT("wxID_ZOOM_IN"), + wxT("wxID_ZOOM_OUT"), + wxT("wxID_UNDELETE"), + wxT("wxID_REVERT_TO_SAVED"), + wxT("wxID_CDROM"), + wxT("wxID_CONVERT"), + wxT("wxID_EXECUTE"), + wxT("wxID_FLOPPY"), + wxT("wxID_HARDDISK"), + wxT("wxID_BOTTOM"), + wxT("wxID_FIRST"), + wxT("wxID_LAST"), + wxT("wxID_TOP"), + wxT("wxID_INFO"), + wxT("wxID_JUMP_TO"), + wxT("wxID_NETWORK"), + wxT("wxID_SELECT_COLOR"), + wxT("wxID_SELECT_FONT"), + wxT("wxID_SORT_ASCENDING"), + wxT("wxID_SORT_DESCENDING"), + wxT("wxID_SPELL_CHECK"), + wxT("wxID_STRIKETHROUGH")}); std::sort(s_options.begin(), s_options.end()); m_winIdSet.insert(s_options.begin(), s_options.end()); @@ -140,7 +140,7 @@ void WinIdProperty::UnSerialize(const JSONItem& json) { DoBaseUnSerialize(json); // Backward compatibility - if(json.hasNamedObject(wxT("m_winid"))) + if (json.hasNamedObject(wxT("m_winid"))) m_winid = json.namedObject(wxT("m_winid")).toString(); else m_winid = json.namedObject(wxT("m_value")).toString(); diff --git a/wxcrafter/UI/DefineCustomControlWizard.cpp b/wxcrafter/UI/DefineCustomControlWizard.cpp index 16a000e44e..34c7c9f78e 100644 --- a/wxcrafter/UI/DefineCustomControlWizard.cpp +++ b/wxcrafter/UI/DefineCustomControlWizard.cpp @@ -13,21 +13,21 @@ DefineCustomControlWizard::DefineCustomControlWizard(wxWindow* parent) void DefineCustomControlWizard::OnPageChanging(wxWizardEvent& event) { - if(event.GetDirection()) { - if(event.GetPage() == m_wizardPageGeneral && !::IsValidCppIdentifier(m_textClassName->GetValue())) { + if (event.GetDirection()) { + if (event.GetPage() == m_wizardPageGeneral && !::IsValidCppIdentifier(m_textClassName->GetValue())) { wxMessageBox(_("Invalid C++ class name provided!"), wxT("wxCrafter"), wxOK | wxICON_WARNING | wxCENTER); event.Veto(); return; - } else if(event.GetPage() == m_wizardPageHeader && m_textCtrlIncludeLine->IsEmpty()) { - wxMessageBox(_("Please set an include file for this control"), wxT("wxCrafter"), - wxOK | wxICON_WARNING | wxCENTER); + } else if (event.GetPage() == m_wizardPageHeader && m_textCtrlIncludeLine->IsEmpty()) { + wxMessageBox( + _("Please set an include file for this control"), wxT("wxCrafter"), wxOK | wxICON_WARNING | wxCENTER); event.Veto(); return; - } else if(event.GetPage() == m_wizardPageCpp && m_textCtrlInstantiationLine->IsEmpty()) { - wxMessageBox(_("Control instantiation code is missing"), wxT("wxCrafter"), - wxOK | wxICON_WARNING | wxCENTER); + } else if (event.GetPage() == m_wizardPageCpp && m_textCtrlInstantiationLine->IsEmpty()) { + wxMessageBox( + _("Control instantiation code is missing"), wxT("wxCrafter"), wxOK | wxICON_WARNING | wxCENTER); event.Veto(); return; } @@ -45,7 +45,7 @@ CustomControlTemplate DefineCustomControlWizard::GetControl() const wxStringMap_t events; int count = m_dvListCtrlEvents->GetItemCount(); - for(int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { wxString eventtype = m_dvListCtrlEvents->GetTextValue(i, 0); wxString eventclss = m_dvListCtrlEvents->GetTextValue(i, 1); @@ -68,7 +68,7 @@ void DefineCustomControlWizard::OnDeleteEventUI(wxUpdateUIEvent& event) void DefineCustomControlWizard::OnNewEvent(wxCommandEvent& event) { NewCustomEventDlg dlg(this); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxVector cols; cols.push_back(dlg.GetEventType()); cols.push_back(dlg.GetEventClass()); diff --git a/wxcrafter/UI/DeleteCustomControlDlg.cpp b/wxcrafter/UI/DeleteCustomControlDlg.cpp index 63b4d3b80e..4837b53e5c 100644 --- a/wxcrafter/UI/DeleteCustomControlDlg.cpp +++ b/wxcrafter/UI/DeleteCustomControlDlg.cpp @@ -21,12 +21,12 @@ void DeleteCustomControlDlg::OnDeleteControls(wxCommandEvent& event) wxString msg; msg << _("Are you sure you want to delete the following custom controls:\n"); - for(size_t i = 0; i < m_controlsToDelete.GetCount(); ++i) { + for (size_t i = 0; i < m_controlsToDelete.GetCount(); ++i) { msg << m_controlsToDelete.Item(i) << "\n"; } - if(::wxMessageBox(msg, wxT("wxCrafter"), wxICON_QUESTION | wxCENTER | wxYES_NO) == wxYES) { - for(size_t i = 0; i < m_controlsToDelete.GetCount(); ++i) { + if (::wxMessageBox(msg, wxT("wxCrafter"), wxICON_QUESTION | wxCENTER | wxYES_NO) == wxYES) { + for (size_t i = 0; i < m_controlsToDelete.GetCount(); ++i) { wxcSettings::Get().DeleteCustomControl(m_controlsToDelete.Item(i)); } wxcSettings::Get().Save(); @@ -42,12 +42,14 @@ void DeleteCustomControlDlg::OnItemValueChanged(wxDataViewEvent& event) wxVariant v; m_dvListCtrl->GetValue(v, row, 0); - if(v.GetBool()) { - if(m_controlsToDelete.Index(controlName) == wxNOT_FOUND) m_controlsToDelete.Add(controlName); + if (v.GetBool()) { + if (m_controlsToDelete.Index(controlName) == wxNOT_FOUND) + m_controlsToDelete.Add(controlName); } else { int where = m_controlsToDelete.Index(controlName); - if(where != wxNOT_FOUND) m_controlsToDelete.RemoveAt(where); + if (where != wxNOT_FOUND) + m_controlsToDelete.RemoveAt(where); } } diff --git a/wxcrafter/UI/EditCustomControlDlg.cpp b/wxcrafter/UI/EditCustomControlDlg.cpp index c7fa88378a..3fddf645a1 100644 --- a/wxcrafter/UI/EditCustomControlDlg.cpp +++ b/wxcrafter/UI/EditCustomControlDlg.cpp @@ -14,7 +14,7 @@ EditCustomControlDlg::EditCustomControlDlg(wxWindow* parent) m_choiceControls->Append(p.first); } - if(c.empty() == false) { + if (c.empty() == false) { m_choiceControls->SetSelection(0); wxCommandEvent dummy; @@ -26,11 +26,13 @@ EditCustomControlDlg::EditCustomControlDlg(wxWindow* parent) void EditCustomControlDlg::OnSelectControl(wxCommandEvent& event) { - if(m_isModified) { OnSave(event); } + if (m_isModified) { + OnSave(event); + } wxString controlName = m_choiceControls->GetStringSelection(); CustomControlTemplate cct = wxcSettings::Get().FindByControlName(controlName); - if(cct.IsValid()) { + if (cct.IsValid()) { m_textCtrlInstantiationLine->ChangeValue(cct.GetAllocationLine()); m_textCtrlIncludeFile->ChangeValue(cct.GetIncludeFile()); m_textCtrlXRCClass->ChangeValue(cct.GetXrcPreviewClass()); @@ -56,7 +58,7 @@ void EditCustomControlDlg::OnSave(wxCommandEvent& event) wxStringMap_t events; int count = m_dvListCtrlEvents->GetItemCount(); - for(int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { wxString eventtype = m_dvListCtrlEvents->GetTextValue(i, 0); wxString eventclss = m_dvListCtrlEvents->GetTextValue(i, 1); @@ -81,7 +83,7 @@ void EditCustomControlDlg::OnDeleteEvent(wxCommandEvent& event) void EditCustomControlDlg::OnNewEvent(wxCommandEvent& event) { NewCustomEventDlg dlg(wxCrafter::TopFrame()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxVector cols; cols.push_back(dlg.GetEventType()); diff --git a/wxcrafter/UI/FontPickerDlg.cpp b/wxcrafter/UI/FontPickerDlg.cpp index 5beb686643..8a87429af3 100644 --- a/wxcrafter/UI/FontPickerDlg.cpp +++ b/wxcrafter/UI/FontPickerDlg.cpp @@ -8,10 +8,12 @@ FontPickerDlg::FontPickerDlg(wxWindow* parent, const wxString& font) , m_fontname(font) { wxFont f = wxCrafter::StringToFont(m_fontname); - if(wxCrafter::IsSystemFont(m_fontname)) { + if (wxCrafter::IsSystemFont(m_fontname)) { wxString name = m_fontname.BeforeFirst(wxT(',')); int where = m_choiceSystemFonts->FindString(name); - if(where != wxNOT_FOUND) { m_choiceSystemFonts->SetSelection(where); } + if (where != wxNOT_FOUND) { + m_choiceSystemFonts->SetSelection(where); + } m_checkBoxBold->SetValue(f.GetWeight() == wxFONTWEIGHT_BOLD); m_checkBoxItalic->SetValue(f.GetStyle() == wxFONTSTYLE_ITALIC); @@ -19,13 +21,13 @@ FontPickerDlg::FontPickerDlg(wxWindow* parent, const wxString& font) m_checkBoxPreDefinedFont->SetValue(true); DoUpdateSelectionToPreDefinedFont(); - } else if(f.IsOk()) { + } else if (f.IsOk()) { m_fontPicker->SetSelectedFont(f); m_checkBoxCustomFont->SetValue(true); DoUpdateSelectionToCustomFont(); } - if(f.IsOk()) { + if (f.IsOk()) { m_staticTextSample->SetFont(f); m_staticTextSample->SetLabel(_("Sample Text")); } @@ -62,23 +64,23 @@ void FontPickerDlg::DoUpdateSelectionToPreDefinedFont() { // Update the preview wxFont font = wxCrafter::StringToFont(m_choiceSystemFonts->GetStringSelection()); - if(font.IsOk()) { + if (font.IsOk()) { - if(wxCrafter::IsSystemFont(m_choiceSystemFonts->GetStringSelection())) { + if (wxCrafter::IsSystemFont(m_choiceSystemFonts->GetStringSelection())) { m_fontname = m_choiceSystemFonts->GetStringSelection(); - if(m_checkBoxItalic->IsChecked()) { + if (m_checkBoxItalic->IsChecked()) { m_fontname << wxT(",italic"); font.SetStyle(wxFONTSTYLE_ITALIC); } else m_fontname << wxT(",normal"); - if(m_checkBoxBold->IsChecked()) { + if (m_checkBoxBold->IsChecked()) { m_fontname << wxT(",bold"); font.SetWeight(wxFONTWEIGHT_BOLD); } else m_fontname << wxT(",normal"); - if(m_checkBoxUnderlined->IsChecked()) { + if (m_checkBoxUnderlined->IsChecked()) { m_fontname << wxT(",underlined"); font.SetUnderlined(true); } else diff --git a/wxcrafter/UI/FontPickerDlg.h b/wxcrafter/UI/FontPickerDlg.h index 6a07da0d77..8c2845b61b 100644 --- a/wxcrafter/UI/FontPickerDlg.h +++ b/wxcrafter/UI/FontPickerDlg.h @@ -25,7 +25,7 @@ class FontPickerDlg : public FontPickerDlgBaseClass const wxString& GetFontName() const { static wxString EMPTY_STRING; - if(m_checkBoxCustomFont->IsChecked() == false && m_checkBoxPreDefinedFont->IsChecked() == false) + if (m_checkBoxCustomFont->IsChecked() == false && m_checkBoxPreDefinedFont->IsChecked() == false) return EMPTY_STRING; return m_fontname; diff --git a/wxcrafter/UI/NewFormWizard.cpp b/wxcrafter/UI/NewFormWizard.cpp index 232e07da21..a678f404a1 100644 --- a/wxcrafter/UI/NewFormWizard.cpp +++ b/wxcrafter/UI/NewFormWizard.cpp @@ -17,11 +17,11 @@ static wxString GetDisplayName(const wxFileName& fn) { - if(!fn.IsOk()) { + if (!fn.IsOk()) { return wxEmptyString; } wxString displayName; - if(fn.GetDirCount()) { + if (fn.GetDirCount()) { displayName << fn.GetDirs().Last() << wxFileName::GetPathSeparator(); } displayName << fn.GetFullName(); @@ -33,7 +33,7 @@ NewFormWizard::NewFormWizard(wxWindow* parent, IManager* mgr, int type) , m_mgr(mgr) { wxString stringSelection; - switch(type) { + switch (type) { case ID_WXDIALOG: stringSelection = wxT("wxDialog"); break; @@ -57,14 +57,14 @@ NewFormWizard::NewFormWizard(wxWindow* parent, IManager* mgr, int type) break; } - if(stringSelection.IsEmpty() == false) + if (stringSelection.IsEmpty() == false) m_choiceFormType->SetStringSelection(stringSelection); - if(m_mgr) { + if (m_mgr) { TreeItemInfo item = m_mgr->GetSelectedTreeItemInfo(TreeFileView); - if(item.m_item.IsOk() && item.m_itemType == ProjectItem::TypeVirtualDirectory) { + if (item.m_item.IsOk() && item.m_itemType == ProjectItem::TypeVirtualDirectory) { wxString path = VirtualDirectorySelectorDlg::DoGetPath(m_mgr->GetWorkspaceTree(), item.m_item, false); - if(path.IsEmpty() == false) { + if (path.IsEmpty() == false) { m_textCtrlVirtualFolder->ChangeValue(path); m_textCtrlVirtualFolder->SetEditable(false); } @@ -75,39 +75,39 @@ NewFormWizard::NewFormWizard(wxWindow* parent, IManager* mgr, int type) std::set uniqueFiles; std::vector> wxcp_files; - if(clCxxWorkspaceST::Get()->IsOpen()) { + if (clCxxWorkspaceST::Get()->IsOpen()) { wxArrayString allFiles; clCxxWorkspaceST::Get()->GetWorkspaceFiles(allFiles); - for(size_t i = 0; i < allFiles.GetCount(); ++i) { + for (size_t i = 0; i < allFiles.GetCount(); ++i) { const wxString& filename = allFiles.Item(i); wxFileName fn(filename); - if(fn.GetExt().Lower() == "wxcp") { - if(uniqueFiles.count(filename) == 0) { + if (fn.GetExt().Lower() == "wxcp") { + if (uniqueFiles.count(filename) == 0) { uniqueFiles.insert(filename); // we keep {display name:fullpath} pairs - wxcp_files.push_back({ GetDisplayName(fn), fn.GetFullPath() }); + wxcp_files.push_back({GetDisplayName(fn), fn.GetFullPath()}); } } } - for(const auto& p : wxcp_files) { + for (const auto& p : wxcp_files) { m_choiceWxcp->Append(p.first, new wxStringClientData(p.second)); } } - if(wxcProjectMetadata::Get().IsLoaded()) { + if (wxcProjectMetadata::Get().IsLoaded()) { wxFileName fn(wxcProjectMetadata::Get().GetProjectFile()); m_choiceWxcp->Append(GetDisplayName(fn), new wxStringClientData(fn.GetFullPath())); } - if(!m_choiceWxcp->IsEmpty()) { + if (!m_choiceWxcp->IsEmpty()) { m_choiceWxcp->SetSelection(0); } wxFileName fnProject(wxcProjectMetadata::Get().GetProjectFile()); int where = m_choiceWxcp->FindString(GetDisplayName(fnProject)); - if(where != wxNOT_FOUND) { + if (where != wxNOT_FOUND) { m_choiceWxcp->SetSelection(where); } } @@ -117,11 +117,11 @@ void NewFormWizard::OnFormTypeSelected(wxCommandEvent& event) { event.Skip(); } void NewFormWizard::OnSelectVirtualFolder(wxCommandEvent& event) { wxString suggestedName = m_textCtrlVirtualFolder->GetValue(); - if(suggestedName.empty() && clCxxWorkspaceST::Get()) { + if (suggestedName.empty() && clCxxWorkspaceST::Get()) { suggestedName = clCxxWorkspaceST::Get()->GetActiveProjectName(); } VirtualDirectorySelectorDlg selector(this, clCxxWorkspaceST::Get(), suggestedName); - if(selector.ShowModal() == wxID_OK) { + if (selector.ShowModal() == wxID_OK) { m_textCtrlVirtualFolder->SetEditable(true); m_textCtrlVirtualFolder->ChangeValue(selector.GetVirtualDirectoryPath()); m_textCtrlVirtualFolder->SetEditable(false); @@ -132,19 +132,19 @@ void NewFormWizard::OnFinishClicked(wxWizardEvent& event) { event.Skip(); } int NewFormWizard::GetFormType() const { - if(IsDialog()) + if (IsDialog()) return ID_WXDIALOG; - else if(IsFrame()) + else if (IsFrame()) return ID_WXFRAME; - else if(IsWizard()) + else if (IsWizard()) return ID_WXWIZARD; - else if(IsPanel()) + else if (IsPanel()) return ID_WXPANEL_TOPLEVEL; - else if(IsImageList()) + else if (IsImageList()) return ID_WXIMAGELIST; - else if(IsAuiToolBar()) + else if (IsAuiToolBar()) return ID_WXAUITOOLBARTOPLEVEL; - else if(IsPopupWindow()) + else if (IsPopupWindow()) return ID_WXPOPUPWINDOW; return wxNOT_FOUND; } @@ -157,33 +157,35 @@ wxString NewFormWizard::GetGeneratedFileBaseName() const { return m_textCtrFileN void NewFormWizard::OnWizardPageChanging(wxWizardEvent& event) { - if(event.GetDirection() && m_wizardPageGeneratedCode == event.GetPage()) { + if (event.GetDirection() && m_wizardPageGeneratedCode == event.GetPage()) { #if STANDALONE_BUILD - if(m_choiceWxcp->IsEmpty()) { - ::wxMessageBox(wxString() << _("You must create a project before you can add new forms"), "wxCrafter", + if (m_choiceWxcp->IsEmpty()) { + ::wxMessageBox(wxString() << _("You must create a project before you can add new forms"), + "wxCrafter", wxOK | wxCENTER | wxICON_WARNING); event.Veto(); return; } #endif - if(m_textCtrFileName->IsEmpty() && - (GetFormType() != ID_WXIMAGELIST && GetFormType() != ID_WXAUITOOLBARTOPLEVEL)) { + if (m_textCtrFileName->IsEmpty() && + (GetFormType() != ID_WXIMAGELIST && GetFormType() != ID_WXAUITOOLBARTOPLEVEL)) { ::wxMessageBox(_("Please enter a file name"), wxT("wxCrafter"), wxICON_WARNING | wxCENTER | wxOK); event.Veto(); return; } - if(m_textCtrlClassName->IsEmpty()) { + if (m_textCtrlClassName->IsEmpty()) { ::wxMessageBox(_("Please enter a class name"), wxT("wxCrafter"), wxICON_WARNING | wxCENTER | wxOK); event.Veto(); return; } #if !STANDALONE_BUILD - if(!clFileSystemWorkspace::Get().IsOpen() && m_textCtrlVirtualFolder->IsEmpty()) { - ::wxMessageBox(_("Please select a virtual folder for the generated code"), wxT("wxCrafter"), + if (!clFileSystemWorkspace::Get().IsOpen() && m_textCtrlVirtualFolder->IsEmpty()) { + ::wxMessageBox(_("Please select a virtual folder for the generated code"), + wxT("wxCrafter"), wxICON_WARNING | wxCENTER | wxOK); event.Veto(); return; @@ -208,9 +210,9 @@ void NewFormWizard::OnNewWxcpProject(wxCommandEvent& event) wxFileName defaultValue(::wxGetCwd(), "my_wxcp_file.wxcp"); - if(m_mgr) { + if (m_mgr) { ProjectPtr project = m_mgr->GetSelectedProject(); - if(project) { + if (project) { defaultValue.SetPath(project->GetFileName().GetPath()); } else { defaultValue.SetPath(::wxGetCwd()); @@ -219,7 +221,7 @@ void NewFormWizard::OnNewWxcpProject(wxCommandEvent& event) } wxString newfile = ::wxGetTextFromUser(msg, wxT("wxCrafter"), defaultValue.GetFullPath()); - if(newfile.IsEmpty()) + if (newfile.IsEmpty()) return; wxFileName fn(newfile); @@ -227,7 +229,7 @@ void NewFormWizard::OnNewWxcpProject(wxCommandEvent& event) wxString displayName = GetDisplayName(fn); int where = m_choiceWxcp->FindString(displayName); - if(where == wxNOT_FOUND) { + if (where == wxNOT_FOUND) { int newpos = m_choiceWxcp->Append(displayName, new wxStringClientData(fn.GetFullPath())); m_choiceWxcp->SetSelection(newpos); @@ -240,7 +242,7 @@ void NewFormWizard::OnNewWxcpProject(wxCommandEvent& event) wxString NewFormWizard::GetWxcpFile() const { int selection = m_choiceWxcp->GetSelection(); - if(selection == wxNOT_FOUND) { + if (selection == wxNOT_FOUND) { return ""; } @@ -276,13 +278,13 @@ void NewFormWizard::OnInheritedNameFocus(wxFocusEvent& event) { event.Skip(); - if(!m_textCtrlInheritedClassName->IsEmpty() || m_textCtrlClassName->IsEmpty()) { + if (!m_textCtrlInheritedClassName->IsEmpty() || m_textCtrlClassName->IsEmpty()) { // There's nothing to copy, or we already have an entry return; } wxString suggestion = m_textCtrlClassName->GetValue(); - if(suggestion.Replace("Base", "") || suggestion.Replace("base", "")) { + if (suggestion.Replace("Base", "") || suggestion.Replace("base", "")) { m_textCtrlInheritedClassName->ChangeValue(suggestion); } } @@ -291,7 +293,7 @@ void NewFormWizard::OnFilenameFocus(wxFocusEvent& event) { event.Skip(); - if(!m_textCtrFileName->IsEmpty() || m_textCtrlInheritedClassName->IsEmpty()) { + if (!m_textCtrFileName->IsEmpty() || m_textCtrlInheritedClassName->IsEmpty()) { // There's nothing to copy, or we already have an entry return; } @@ -327,14 +329,14 @@ void NewFormWizard::OnSelectVDUI(wxUpdateUIEvent& event) void NewFormWizard::OnBrowseWxcpFile(wxCommandEvent& event) { wxString path = wxFileSelector(_("Select wxCrafter file"), wxEmptyString, wxEmptyString, "*.wxcp"); - if(path.empty()) { + if (path.empty()) { return; } wxFileName fn(path); wxString displayName = GetDisplayName(fn); int where = m_choiceWxcp->FindString(displayName); - if(where == wxNOT_FOUND) { + if (where == wxNOT_FOUND) { where = m_choiceWxcp->Append(displayName, new wxStringClientData(path)); } m_choiceWxcp->SetSelection(where); diff --git a/wxcrafter/UI/PropertiesView/BmpTextSelectorDlg.cpp b/wxcrafter/UI/PropertiesView/BmpTextSelectorDlg.cpp index e5d3885738..6f399966c9 100644 --- a/wxcrafter/UI/PropertiesView/BmpTextSelectorDlg.cpp +++ b/wxcrafter/UI/PropertiesView/BmpTextSelectorDlg.cpp @@ -21,13 +21,15 @@ BmpTextSelectorDlg::BmpTextSelectorDlg(wxWindow* parent, const wxString& initial void BmpTextSelectorDlg::OnDelete(wxCommandEvent& event) { wxDataViewItem item = m_dvListCtrl->GetSelection(); - if(item.IsOk()) { m_dvListCtrl->DeleteItem(m_dvListCtrl->ItemToRow(item)); } + if (item.IsOk()) { + m_dvListCtrl->DeleteItem(m_dvListCtrl->ItemToRow(item)); + } } void BmpTextSelectorDlg::OnEdit(wxCommandEvent& event) { wxDataViewItem item = m_dvListCtrl->GetSelection(); - if(item.IsOk()) { + if (item.IsOk()) { int row = m_dvListCtrl->ItemToRow(item); wxVariant value; wxString bmp, label; @@ -36,7 +38,7 @@ void BmpTextSelectorDlg::OnEdit(wxCommandEvent& event) m_dvListCtrl->GetValue(value, row, 1); label = value.GetString(); SingleBitmapAndTextDlg dlg(this, bmp, label); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { m_dvListCtrl->SetValue(dlg.GetTextCtrlBmp()->GetValue(), row, 0); m_dvListCtrl->SetValue(dlg.GetTextCtrlText()->GetValue(), row, 1); } @@ -46,7 +48,7 @@ void BmpTextSelectorDlg::OnEdit(wxCommandEvent& event) void BmpTextSelectorDlg::OnNew(wxCommandEvent& event) { SingleBitmapAndTextDlg dlg(this, "", ""); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxVector cols; cols.push_back(dlg.GetTextCtrlBmp()->GetValue()); cols.push_back(dlg.GetTextCtrlText()->GetValue()); @@ -59,7 +61,7 @@ BmpTextVec_t BmpTextSelectorDlg::FromString(const wxString& text) BmpTextVec_t vec; JSON root(text); int size = root.toElement().arraySize(); - for(int i = 0; i < size; ++i) { + for (int i = 0; i < size; ++i) { JSONItem item = root.toElement().arrayItem(i); wxString bitmap = item.namedObject("bmp").toString(); wxString label = item.namedObject("label").toString(); @@ -86,7 +88,7 @@ wxString BmpTextSelectorDlg::GetValue() { BmpTextVec_t v; int count = m_dvListCtrl->GetItemCount(); - for(int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { wxVariant value; wxString bmp, label; m_dvListCtrl->GetValue(value, i, 0); @@ -102,5 +104,7 @@ void BmpTextSelectorDlg::OnEditUI(wxUpdateUIEvent& event) { event.Enable(m_dvLis void BmpTextSelectorDlg::OnItemActivated(wxDataViewEvent& event) { wxCommandEvent dummy; - if(m_dvListCtrl->GetSelection().IsOk()) { OnEdit(dummy); } + if (m_dvListCtrl->GetSelection().IsOk()) { + OnEdit(dummy); + } } diff --git a/wxcrafter/UI/PropertiesView/BmpTextSelectorDlg.h b/wxcrafter/UI/PropertiesView/BmpTextSelectorDlg.h index 4e17dd3499..673477ad78 100644 --- a/wxcrafter/UI/PropertiesView/BmpTextSelectorDlg.h +++ b/wxcrafter/UI/PropertiesView/BmpTextSelectorDlg.h @@ -2,6 +2,7 @@ #define BMPTEXTSELECTORDLG_H #include "wxcrafter.h" + #include using BmpTextVec_t = std::vector>; diff --git a/wxcrafter/UI/PropertiesView/SingleBitmapAndTextDlg.cpp b/wxcrafter/UI/PropertiesView/SingleBitmapAndTextDlg.cpp index 76d5faa959..d66e378b52 100644 --- a/wxcrafter/UI/PropertiesView/SingleBitmapAndTextDlg.cpp +++ b/wxcrafter/UI/PropertiesView/SingleBitmapAndTextDlg.cpp @@ -20,5 +20,7 @@ void SingleBitmapAndTextDlg::OnOKUI(wxUpdateUIEvent& event) void SingleBitmapAndTextDlg::OnSelectBitmap(wxCommandEvent& event) { BitmapSelectorDlg dlg(this, m_textCtrlBmp->GetValue()); - if(dlg.ShowModal() == wxID_OK) { m_textCtrlBmp->ChangeValue(dlg.GetBitmapFile()); } + if (dlg.ShowModal() == wxID_OK) { + m_textCtrlBmp->ChangeValue(dlg.GetBitmapFile()); + } } diff --git a/wxcrafter/UI/PropertiesView/aui_pane_info_list_view.cpp b/wxcrafter/UI/PropertiesView/aui_pane_info_list_view.cpp index d0e9cd327c..4b4ff30aa0 100644 --- a/wxcrafter/UI/PropertiesView/aui_pane_info_list_view.cpp +++ b/wxcrafter/UI/PropertiesView/aui_pane_info_list_view.cpp @@ -15,7 +15,8 @@ void AuiPaneInfoListView::Construct(wxPropertyGrid* pg, wxcWidget* wb) m_wxcWidget = wb; CHECK_POINTER(m_wxcWidget); - if(m_wxcWidget->IsAuiPane() == false) return; + if (m_wxcWidget->IsAuiPane() == false) + return; m_wxcWidget->GetAuiPaneInfo().Construct(pg); } diff --git a/wxcrafter/UI/PropertiesView/aui_pane_info_list_view.h b/wxcrafter/UI/PropertiesView/aui_pane_info_list_view.h index e65e3c2e79..a83ac18664 100644 --- a/wxcrafter/UI/PropertiesView/aui_pane_info_list_view.h +++ b/wxcrafter/UI/PropertiesView/aui_pane_info_list_view.h @@ -2,6 +2,7 @@ #define AUIPANEINFOLISTVIEW_H #include "wxc_widget.h" + #include class AuiPaneInfoListView diff --git a/wxcrafter/UI/PropertiesView/custom_pg_properties.cpp b/wxcrafter/UI/PropertiesView/custom_pg_properties.cpp index d2302f89df..737f0e1e8e 100644 --- a/wxcrafter/UI/PropertiesView/custom_pg_properties.cpp +++ b/wxcrafter/UI/PropertiesView/custom_pg_properties.cpp @@ -6,14 +6,18 @@ bool wxPG_Colour::OnEvent(wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& event) { - if(propgrid->IsMainButtonEvent(event)) { + if (propgrid->IsMainButtonEvent(event)) { SetValueToUnspecified(); ColorProperty* pb = reinterpret_cast(GetClientData()); - if(pb) { pb->SetValue(""); } + if (pb) { + pb->SetValue(""); + } // Notify about modifications wxCommandEvent evt(wxEVT_PROPERTIES_MODIFIED); - if(pb->GetLabel() == PROP_NAME) { evt.SetString(GetValueAsString()); } + if (pb->GetLabel() == PROP_NAME) { + evt.SetString(GetValueAsString()); + } EventNotifier::Get()->AddPendingEvent(evt); return true; @@ -26,8 +30,10 @@ bool wxPG_Colour::OnEvent(wxPropertyGrid* propgrid, wxWindow* primary, wxEvent& // wxcPGChoiceAndButtonEditor // ----------------------------------------------------------------------- -wxPGWindowList wxcPGChoiceAndButtonEditor::CreateControls(wxPropertyGrid* propGrid, wxPGProperty* property, - const wxPoint& pos, const wxSize& sz) const +wxPGWindowList wxcPGChoiceAndButtonEditor::CreateControls(wxPropertyGrid* propGrid, + wxPGProperty* property, + const wxPoint& pos, + const wxSize& sz) const { // Use one two units smaller to match size of the combo's dropbutton. // (normally a bigger button is used because it looks better) @@ -46,7 +52,9 @@ wxPGWindowList wxcPGChoiceAndButtonEditor::CreateControls(wxPropertyGrid* propGr wxWindow* bt = propGrid->GenerateEditorButton(bt_pos, bt_sz); bt->SetToolTip(_("Clear")); wxButton* button = dynamic_cast(bt); - if(button) { button->SetLabel("X"); } + if (button) { + button->SetLabel("X"); + } // Size of choice. wxSize ch_sz(sz.x - bt->GetSize().x, sz.y); diff --git a/wxcrafter/UI/PropertiesView/custom_pg_properties.h b/wxcrafter/UI/PropertiesView/custom_pg_properties.h index ecc30b490a..19b9f47f43 100644 --- a/wxcrafter/UI/PropertiesView/custom_pg_properties.h +++ b/wxcrafter/UI/PropertiesView/custom_pg_properties.h @@ -39,35 +39,39 @@ class EnterStringsDlgAdapter : public wxPGEditorDialogAdapter wxString origlbl = property->GetLabel(); wxString lbl = origlbl; - if(lbl.EndsWith(":") == false) { lbl << ":"; } + if (lbl.EndsWith(":") == false) { + lbl << ":"; + } - if(lbl == PROP_TOOLTIP || lbl == PROP_LABEL || lbl == PROP_MESSAGE || lbl == PROP_TITLE || - lbl == PROP_CB_CHOICES) { + if (lbl == PROP_TOOLTIP || lbl == PROP_LABEL || lbl == PROP_MESSAGE || lbl == PROP_TITLE || + lbl == PROP_CB_CHOICES) { delim = "\\n"; } bool wordsSplit = false; - if(origlbl == PROP_KEYWORDS_SET_1 || origlbl == PROP_KEYWORDS_SET_2 || origlbl == PROP_KEYWORDS_SET_3 || - origlbl == PROP_KEYWORDS_SET_4 || origlbl == PROP_KEYWORDS_SET_5) { + if (origlbl == PROP_KEYWORDS_SET_1 || origlbl == PROP_KEYWORDS_SET_2 || origlbl == PROP_KEYWORDS_SET_3 || + origlbl == PROP_KEYWORDS_SET_4 || origlbl == PROP_KEYWORDS_SET_5) { wordsSplit = true; delim = " "; } wxArrayString arr = wxCrafter::SplitByString(property->GetValueAsString(), delim, true); - for(size_t i = 0; i < arr.GetCount(); i++) { + for (size_t i = 0; i < arr.GetCount(); i++) { str << arr.Item(i) << wxT("\n"); } - if(str.IsEmpty() == false) { str.RemoveLast(); } + if (str.IsEmpty() == false) { + str.RemoveLast(); + } EnterStringsDlg dlg(wxCrafter::TopFrame(), str); dlg.SetMessage(wxT("")); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxString value = dlg.GetValue(); - if(wordsSplit) { + if (wordsSplit) { wxArrayString strings = wxCrafter::Split(value, wxT("\n\r; \t"), wxTOKEN_STRTOK); value = wxCrafter::Join(strings, delim); @@ -96,7 +100,7 @@ class FontPickerDlgAdapter : public wxPGEditorDialogAdapter bool DoShowDialog(wxPropertyGrid* propGrid, wxPGProperty* property) override { FontPickerDlg dlg(wxCrafter::TopFrame(), property->GetValueAsString()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxString fontName = dlg.GetFontName(); SetValue(fontName); return true; @@ -118,7 +122,7 @@ class BitmapPickerDlgAdapter : public wxPGEditorDialogAdapter bool DoShowDialog(wxPropertyGrid* propGrid, wxPGProperty* property) override { BitmapSelectorDlg dlg(wxCrafter::TopFrame(), property->GetValueAsString()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxString bmpname = dlg.GetBitmapFile(); SetValue(bmpname); return true; @@ -211,11 +215,13 @@ class FilePickerDlgAdapter : public wxPGEditorDialogAdapter wxString wildcard = wxT("PNG files (*.png)|*.png|BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif|All files (*)|*"); - wxString newPath = ::wxFileSelector(_("Select bitmap"), wxT(""), wxT(""), wxEmptyString, wildcard, wxFD_OPEN, - wxCrafter::TopFrame()); - if(newPath.IsEmpty() == false) { + wxString newPath = ::wxFileSelector( + _("Select bitmap"), wxT(""), wxT(""), wxEmptyString, wildcard, wxFD_OPEN, wxCrafter::TopFrame()); + if (newPath.IsEmpty() == false) { wxFileName newFilePath(newPath); - if(m_projectPath.IsEmpty() == false) { newFilePath.MakeRelativeTo(m_projectPath); } + if (m_projectPath.IsEmpty() == false) { + newFilePath.MakeRelativeTo(m_projectPath); + } SetValue(newFilePath.GetFullPath(wxPATH_UNIX)); return true; } @@ -243,13 +249,16 @@ class DirPickerDlgAdapter : public wxPGEditorDialogAdapter bool DoShowDialog(wxPropertyGrid* propGrid, wxPGProperty* property) override { - wxString newPath = ::wxDirSelector("Select a folder", wxEmptyString, wxDD_DEFAULT_STYLE, wxDefaultPosition, - wxCrafter::TopFrame()); - if(newPath.IsEmpty() == false) { + wxString newPath = ::wxDirSelector( + "Select a folder", wxEmptyString, wxDD_DEFAULT_STYLE, wxDefaultPosition, wxCrafter::TopFrame()); + if (newPath.IsEmpty() == false) { wxFileName newFilePath(newPath, ""); - if(m_projectPath.IsEmpty() == false) { newFilePath.MakeRelativeTo(m_projectPath); } + if (m_projectPath.IsEmpty() == false) { + newFilePath.MakeRelativeTo(m_projectPath); + } wxString new_path = newFilePath.GetFullPath(wxPATH_UNIX); - if(new_path.IsEmpty()) new_path = "."; + if (new_path.IsEmpty()) + new_path = "."; SetValue(new_path); return true; } @@ -263,7 +272,9 @@ class wxPG_DirPickerProperty : public wxStringProperty wxString m_projectPath; public: - wxPG_DirPickerProperty(const wxString& label, const wxString& projectPath, const wxString& name = wxPG_LABEL, + wxPG_DirPickerProperty(const wxString& label, + const wxString& projectPath, + const wxString& name = wxPG_LABEL, const wxString& value = "") : wxStringProperty(label, name, value) , m_projectPath(projectPath) @@ -285,7 +296,9 @@ class wxPG_FilePickerProperty : public wxStringProperty wxString m_projectPath; public: - wxPG_FilePickerProperty(const wxString& label, const wxString& projectPath, const wxString& name = wxPG_LABEL, + wxPG_FilePickerProperty(const wxString& label, + const wxString& projectPath, + const wxString& name = wxPG_LABEL, const wxString& value = "") : wxStringProperty(label, name, value) , m_projectPath(projectPath) @@ -323,7 +336,7 @@ class VDPickerDlgAdapter : public wxPGEditorDialogAdapter { VirtualDirectorySelectorDlg selector(wxCrafter::TopFrame(), clCxxWorkspaceST::Get(), m_vdPath); - if(selector.ShowModal() == wxID_OK) { + if (selector.ShowModal() == wxID_OK) { m_vdPath = selector.GetVirtualDirectoryPath(); SetValue(m_vdPath); return true; @@ -370,7 +383,7 @@ class BmpTextDialogAdapter : public wxPGEditorDialogAdapter bool DoShowDialog(wxPropertyGrid* propGrid, wxPGProperty* property) override { BmpTextSelectorDlg selector(wxCrafter::TopFrame(), m_initialValue); - if(selector.ShowModal() == wxID_OK) { + if (selector.ShowModal() == wxID_OK) { m_initialValue = selector.GetValue(); SetValue(m_initialValue); return true; @@ -399,7 +412,8 @@ class wxPG_BmpTextProperty : public wxStringProperty class wxPG_Colour : public wxSystemColourProperty { public: - wxPG_Colour(const wxString& label = wxPG_LABEL, const wxString& name = wxPG_LABEL, + wxPG_Colour(const wxString& label = wxPG_LABEL, + const wxString& name = wxPG_LABEL, const wxColourPropertyValue& value = wxColourPropertyValue()) : wxSystemColourProperty(label, name, value) { diff --git a/wxcrafter/UI/PropertiesView/properties_list_view.cpp b/wxcrafter/UI/PropertiesView/properties_list_view.cpp index 1caa963384..d31c884d99 100644 --- a/wxcrafter/UI/PropertiesView/properties_list_view.cpp +++ b/wxcrafter/UI/PropertiesView/properties_list_view.cpp @@ -20,7 +20,7 @@ namespace { wxcPGChoiceAndButtonEditor* gChoiceButtonEditor = NULL; // a list of properties that if changed, there is no need to refresh the view -std::unordered_set DO_NOT_NOTIFY_SET = { PROP_SUBCLASS_INCLUDE, PROP_SUBCLASS_NAME, PROP_SUBCLASS_STYLE }; +std::unordered_set DO_NOT_NOTIFY_SET = {PROP_SUBCLASS_INCLUDE, PROP_SUBCLASS_NAME, PROP_SUBCLASS_STYLE}; } // namespace PropertiesListView::PropertiesListView(wxWindow* win) @@ -31,7 +31,10 @@ PropertiesListView::PropertiesListView(wxWindow* win) SetSizer(sz); m_pgMgr = - new wxPropertyGridManager(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, + new wxPropertyGridManager(this, + wxID_ANY, + wxDefaultPosition, + wxDefaultSize, wxPG_SPLITTER_AUTO_CENTER | wxPG_BOLD_MODIFIED | wxPG_DESCRIPTION | wxBORDER_NONE); m_pg = m_pgMgr->GetGrid(); @@ -56,30 +59,38 @@ void PropertiesListView::ConstructProjectSettings() wxString filesStr = wxCrafter::Join(wxcProjectMetadata::Get().GetIncludeFiles(), ";"); m_pg->Append(new wxPropertyCategory(_("wxCrafter Project Settings"))); - AddDirPicker(_("Output Directory"), wxcProjectMetadata::Get().GetGeneratedFilesDir(), + AddDirPicker(_("Output Directory"), + wxcProjectMetadata::Get().GetGeneratedFilesDir(), _("The generated files' output directory")); - AddDirPicker(wxGetTranslation(PROP_OUTPUT_FILE_NAME), wxcProjectMetadata::Get().GetOutputFileName(), + AddDirPicker(wxGetTranslation(PROP_OUTPUT_FILE_NAME), + wxcProjectMetadata::Get().GetOutputFileName(), _("The generated files' name.\nwxCrafter will generate a $(FILE).cpp and $(FILE).hpp")); - AddLongTextProp(_("Additional Include Files"), filesStr, + AddLongTextProp(_("Additional Include Files"), + filesStr, _("List of additional include files that should be included in the " "generated files\ne.g. my_header.hpp ; string.h")); - AddTextProp(_("Bitmap Files"), wxcProjectMetadata::Get().GetBitmapsFile(), + AddTextProp(_("Bitmap Files"), + wxcProjectMetadata::Get().GetBitmapsFile(), _("Set here the file name for the bitmaps\nwxCrafter converts all the bitmaps in the project into C++ " "code and will place them in this file")); m_pg->Append(new wxPropertyCategory(_("wxWindow ID Generation"))); AddBoolProp( - _("Generate Window ID"), wxcProjectMetadata::Get().IsUseEnum(), + _("Generate Window ID"), + wxcProjectMetadata::Get().IsUseEnum(), _("Auto generate enum in the base class for the wxWindow IDs which are not a stock window ID nor wrapped with " "the XRCID macro\nWhen left unchecked it is up to the user to provide a header file with the wxWindow IDs")); - AddIntegerProp(_("First Window ID"), wxcProjectMetadata::Get().GetFirstWindowId(), + AddIntegerProp(_("First Window ID"), + wxcProjectMetadata::Get().GetFirstWindowId(), _("When 'Generate Window ID' is checked, use this as the first enumerator value")); m_pg->Append(new wxPropertyCategory(_("Code Generation"))); - AddBoolProp(_("Generate Translatable Strings"), wxcProjectMetadata::Get().IsUseUnderscoreMacro(), + AddBoolProp(_("Generate Translatable Strings"), + wxcProjectMetadata::Get().IsUseUnderscoreMacro(), _("When enabled, all generated strings are wrapped with the \"_\" macro, otherwise allow users to " "directly enter native text string encapsulated by wxT() macro")); - AddBoolProp(_("Add wxWidgets Handlers if missing"), wxcProjectMetadata::Get().IsAddHandlers(), + AddBoolProp(_("Add wxWidgets Handlers if missing"), + wxcProjectMetadata::Get().IsAddHandlers(), _("When enabled, wxCrafter will add missing handlers (e.g. wxBitmapXmlHandler)")); } @@ -88,42 +99,43 @@ void PropertiesListView::Construct(wxcWidget* wb) DoClear(); m_type = Type_Control; m_wxcWidget = wb; - if(!m_wxcWidget) { + if (!m_wxcWidget) { return; } // Populate the table for (const auto& [_, property] : wb->GetProperties()) { - if(!property) { + if (!property) { continue; } wxPGProperty* pgProp = NULL; - if(property->GetType() == PT_CATEGORY) { + if (property->GetType() == PT_CATEGORY) { pgProp = m_pg->Append(new wxPropertyCategory(property->GetValue())); - } else if(property->GetType() == PT_BOOL) { + } else if (property->GetType() == PT_BOOL) { pgProp = AddBoolProp(property->GetLabelForUI(), property->GetValue() == "1", property->GetTooltip()); - } else if(property->GetType() == PT_INT) { + } else if (property->GetType() == PT_INT) { IntProperty* intProp = dynamic_cast(property.get()); - if(intProp) { - if(intProp->IsUninitialized()) { + if (intProp) { + if (intProp->IsUninitialized()) { pgProp = AddIntegerProp(property->GetLabelForUI(), property->GetTooltip()); } else { - pgProp = AddIntegerProp(property->GetLabelForUI(), wxCrafter::ToNumber(property->GetValue(), -1), + pgProp = AddIntegerProp(property->GetLabelForUI(), + wxCrafter::ToNumber(property->GetValue(), -1), property->GetTooltip()); } } - } else if(property->GetType() == PT_COMBOX) { - pgProp = AddComboxProp(property->GetLabelForUI(), property->GetOptions(), property->GetValue(), - property->GetTooltip()); + } else if (property->GetType() == PT_COMBOX) { + pgProp = AddComboxProp( + property->GetLabelForUI(), property->GetOptions(), property->GetValue(), property->GetTooltip()); - } else if(property->GetType() == PT_STRING) { + } else if (property->GetType() == PT_STRING) { pgProp = AddTextProp(property->GetLabelForUI(), property->GetValue(), property->GetTooltip()); - } else if(property->GetType() == PT_CHOICE) { + } else if (property->GetType() == PT_CHOICE) { wxArrayString ops = property->GetOptions(); pgProp = AddChoiceProp(property->GetLabelForUI(), ops, ops.Index(property->GetValue()), property->GetTooltip()); @@ -131,30 +143,33 @@ void PropertiesListView::Construct(wxcWidget* wb) } else if (property->GetType() == PT_MULTI_STRING_PICKER) { pgProp = AddLongTextProp(property->GetLabelForUI(), property->GetValue(), property->GetTooltip()); - } else if(property->GetType() == PT_COLOR_PICKER) { + } else if (property->GetType() == PT_COLOR_PICKER) { pgProp = AddColorProp(property->GetLabelForUI(), property->GetValue(), property->GetTooltip()); - } else if(property->GetType() == PT_FONT_PICKER) { + } else if (property->GetType() == PT_FONT_PICKER) { pgProp = AddFontProp(property->GetLabelForUI(), property->GetValue(), property->GetTooltip()); - } else if(property->GetType() == PT_FILE_PICKER) { + } else if (property->GetType() == PT_FILE_PICKER) { pgProp = AddFilePicker(property->GetLabelForUI(), property->GetValue(), property->GetTooltip()); - } else if(property->GetType() == PT_BITMAP) { + } else if (property->GetType() == PT_BITMAP) { pgProp = AddBitmapPicker(property->GetLabelForUI(), property->GetValue(), property->GetTooltip()); - } else if(property->GetType() == PT_BITMAPTEXT_TABLE) { + } else if (property->GetType() == PT_BITMAPTEXT_TABLE) { pgProp = AddBmpTextPicker(property->GetLabelForUI(), property->GetValue(), property->GetTooltip()); - } else if(property->GetType() == PT_VIRTUAL_FOLDER_PICKER) { + } else if (property->GetType() == PT_VIRTUAL_FOLDER_PICKER) { pgProp = AddVDPicker(property->GetLabelForUI(), property->GetValue(), property->GetTooltip()); - } else if(property->GetType() == PT_COL_HEADER_FLAGS) { - pgProp = AddFlags(property->GetLabelForUI(), property->GetOptions(), property->GetOptionsValues(), - property->GetValueLong(), property->GetTooltip()); + } else if (property->GetType() == PT_COL_HEADER_FLAGS) { + pgProp = AddFlags(property->GetLabelForUI(), + property->GetOptions(), + property->GetOptionsValues(), + property->GetValueLong(), + property->GetTooltip()); } - if(pgProp) { + if (pgProp) { pgProp->SetClientData(property.get()); } } @@ -168,8 +183,8 @@ wxPGProperty* PropertiesListView::AddBoolProp(const wxString& label, bool checke return prop; } -wxPGProperty* PropertiesListView::AddChoiceProp(const wxString& label, const wxArrayString& value, int sel, - const wxString& tip) +wxPGProperty* +PropertiesListView::AddChoiceProp(const wxString& label, const wxArrayString& value, int sel, const wxString& tip) { wxPGProperty* prop = m_pg->Append(new wxEnumProperty(label, wxPG_LABEL, value)); prop->SetHelpString(tip); @@ -203,31 +218,33 @@ wxPGProperty* PropertiesListView::AddColorProp(const wxString& label, const wxSt { wxColourPropertyValue cpv; int colorIdx = wxCrafter::GetColourSysIndex(value); - if(colorIdx == -1 && value != "") { + if (colorIdx == -1 && value != "") { wxColour c = wxCrafter::NameToColour(value); cpv = wxColourPropertyValue(wxPG_COLOUR_CUSTOM, c); - } else if(colorIdx != -1) { + } else if (colorIdx != -1) { cpv = wxColourPropertyValue(colorIdx); } wxPGProperty* prop = m_pg->Append(new wxPG_Colour(label, wxPG_LABEL, cpv)); - if(!gChoiceButtonEditor) { + if (!gChoiceButtonEditor) { gChoiceButtonEditor = new wxcPGChoiceAndButtonEditor(); } m_pg->SetPropertyEditor(prop, gChoiceButtonEditor); prop->SetHelpString(tip); - if(value == "") { + if (value == "") { prop->SetValueToUnspecified(); } return prop; } -wxPGProperty* PropertiesListView::AddComboxProp(const wxString& label, const wxArrayString& options, - const wxString& value, const wxString& tip) +wxPGProperty* PropertiesListView::AddComboxProp(const wxString& label, + const wxArrayString& options, + const wxString& value, + const wxString& tip) { wxPGProperty* prop = m_pg->Append(new wxEditEnumProperty(label, wxPG_LABEL, options)); @@ -262,46 +279,46 @@ void PropertiesListView::DoClear() void PropertiesListView::OnCellChanged(wxPropertyGridEvent& e) { wxPGProperty* pgp = e.GetProperty(); - if(m_type == Type_Project_Metadata) { + if (m_type == Type_Project_Metadata) { wxPGProperty* p = NULL; p = m_pg->GetProperty(_("Output Directory")); - if(p) { + if (p) { wxcProjectMetadata::Get().SetGeneratedFilesDir(p->GetValueAsString()); } p = m_pg->GetProperty(_("Additional Include Files")); - if(p) { + if (p) { wxcProjectMetadata::Get().SetIncludeFiles(wxCrafter::Split(p->GetValueAsString(), ";")); } p = m_pg->GetProperty(_("Bitmap Files")); - if(p) { + if (p) { wxcProjectMetadata::Get().SetBitmapsFile(p->GetValueAsString()); } p = m_pg->GetProperty(wxGetTranslation(PROP_OUTPUT_FILE_NAME)); - if(p) { + if (p) { wxcProjectMetadata::Get().SetOutputFileName(p->GetValueAsString()); } p = m_pg->GetProperty(_("Generate Window ID")); - if(p) { + if (p) { wxcProjectMetadata::Get().SetUseEnum(p->GetValue().GetBool()); } p = m_pg->GetProperty(_("First Window ID")); - if(p) { + if (p) { wxcProjectMetadata::Get().SetFirstWindowId(p->GetValue().GetInteger()); } p = m_pg->GetProperty(_("Generate Translatable Strings")); - if(p) { + if (p) { wxcProjectMetadata::Get().SetUseUnderscoreMacro(p->GetValue().GetBool()); } p = m_pg->GetProperty(_("Add wxWidgets Handlers if missing")); - if(p) { + if (p) { wxcProjectMetadata::Get().SetAddHandlers(p->GetValue().GetBool()); } @@ -311,30 +328,30 @@ void PropertiesListView::OnCellChanged(wxPropertyGridEvent& e) } else { PropertyBase* pb = (PropertyBase*)pgp->GetClientData(); - if(pb) { + if (pb) { // Check if the label modified is the "Name" // if it is the "Name" - make sure there is no other wxcWidget with this name - if(pb->GetLabelForUI() == _("Name")) { - if(m_wxcWidget->GetTopLevel() && !m_wxcWidget->GetTopLevel()->IsNameUnique(pgp->GetValueAsString())) { + if (pb->GetLabelForUI() == _("Name")) { + if (m_wxcWidget->GetTopLevel() && !m_wxcWidget->GetTopLevel()->IsNameUnique(pgp->GetValueAsString())) { pgp->SetValueFromString(pb->GetValue(), 0); - ::wxMessageBox(_("A control with this name already exists!"), "wxCrafter", - wxICON_WARNING | wxOK | wxCENTER); + ::wxMessageBox( + _("A control with this name already exists!"), "wxCrafter", wxICON_WARNING | wxOK | wxCENTER); return; } } wxBoolProperty* boolProp = dynamic_cast(pgp); - if(boolProp) { + if (boolProp) { pb->SetValue(boolProp->GetValue().GetBool() ? "1" : "0"); } else { pb->SetValue(pgp->GetValueAsString()); } // we don't always want to notify about changes - if(DO_NOT_NOTIFY_SET.count(pb->GetLabel()) == 0) { + if (DO_NOT_NOTIFY_SET.count(pb->GetLabel()) == 0) { // Notify about modifications wxCommandEvent evt(wxEVT_PROPERTIES_MODIFIED); - if(pb->GetLabel() == PROP_NAME) { + if (pb->GetLabel() == PROP_NAME) { evt.SetString(pgp->GetValueAsString()); evt.SetClientData(m_wxcWidget); } @@ -374,8 +391,8 @@ wxPGProperty* PropertiesListView::AddDirPicker(const wxString& label, const wxSt return prop; } -wxPGProperty* PropertiesListView::AddFlags(const wxString& label, const wxArrayString& strings, - const wxArrayInt& values, long value, const wxString& tip) +wxPGProperty* PropertiesListView::AddFlags( + const wxString& label, const wxArrayString& strings, const wxArrayInt& values, long value, const wxString& tip) { wxPGProperty* prop = m_pg->Append(new wxFlagsProperty(label, wxPG_LABEL, strings, values, value)); prop->SetHelpString(tip); @@ -393,7 +410,7 @@ void PropertiesListView::OnCellChanging(wxPropertyGridEvent& e) minSizeLabel.EndsWith(":", &minSizeLabel); // Validate Size / Minimum Size properties - if(propName == sizeLabel || propName == minSizeLabel) { + if (propName == sizeLabel || propName == minSizeLabel) { // size regex static wxRegEx reSize("[-0-9]+,[ \t]*[-0-9]+"); @@ -401,7 +418,7 @@ void PropertiesListView::OnCellChanging(wxPropertyGridEvent& e) propValue.Trim().Trim(false); // Validate against the regex (only if not empty) - if(!propValue.IsEmpty() && !reSize.Matches(propValue)) { + if (!propValue.IsEmpty() && !reSize.Matches(propValue)) { e.Veto(); } else { @@ -420,13 +437,13 @@ void PropertiesListView::OnPropertyGridUpdateUI(wxUpdateUIEvent& event) wxPGProperty* kind = m_pgMgr->GetPropertyByLabel(_("Kind")); wxPGProperty* ddm = m_pgMgr->GetPropertyByLabel(_("Construct the Dropdown Menu")); - if(kind && ddm) { + if (kind && ddm) { // Doing ddm->Hide(kind->GetValueAsString() != ITEM_DROPDOWN) worked, but it was impossible to change the // properties value as it was constantly being refreshed // So only Show/Hide it when it's actually needed - if(!ddm->HasFlag(wxPG_PROP_HIDDEN) && (kind->GetValueAsString() != ITEM_DROPDOWN)) { + if (!ddm->HasFlag(wxPG_PROP_HIDDEN) && (kind->GetValueAsString() != ITEM_DROPDOWN)) { ddm->Hide(true); - } else if(ddm->HasFlag(wxPG_PROP_HIDDEN) && (kind->GetValueAsString() == ITEM_DROPDOWN)) { + } else if (ddm->HasFlag(wxPG_PROP_HIDDEN) && (kind->GetValueAsString() == ITEM_DROPDOWN)) { ddm->Hide(true); } } diff --git a/wxcrafter/UI/PropertiesView/properties_list_view.h b/wxcrafter/UI/PropertiesView/properties_list_view.h index d3e5f584e9..6f440913e2 100644 --- a/wxcrafter/UI/PropertiesView/properties_list_view.h +++ b/wxcrafter/UI/PropertiesView/properties_list_view.h @@ -39,10 +39,10 @@ class PropertiesListView : public wxPanel wxPGProperty* AddFilePicker(const wxString& label, const wxString& value, const wxString& tip); wxPGProperty* AddLongTextProp(const wxString& label, const wxString& value, const wxString& tip); wxPGProperty* AddColorProp(const wxString& label, const wxString& value, const wxString& tip); - wxPGProperty* AddComboxProp(const wxString& label, const wxArrayString& options, const wxString& value, - const wxString& tip); - wxPGProperty* AddFlags(const wxString& label, const wxArrayString& strings, const wxArrayInt& values, long value, - const wxString& tip); + wxPGProperty* + AddComboxProp(const wxString& label, const wxArrayString& options, const wxString& value, const wxString& tip); + wxPGProperty* AddFlags( + const wxString& label, const wxArrayString& strings, const wxArrayInt& values, long value, const wxString& tip); wxPGProperty* AddFontProp(const wxString& label, const wxString& value, const wxString& tip); wxPGProperty* AddVDPicker(const wxString& label, const wxString& value, const wxString& tip); wxPGProperty* AddBmpTextPicker(const wxString& label, const wxString& value, const wxString& tip); diff --git a/wxcrafter/UI/PropertiesView/styles_sheet_list_view.cpp b/wxcrafter/UI/PropertiesView/styles_sheet_list_view.cpp index e58ccfc4c2..233b9e4e65 100644 --- a/wxcrafter/UI/PropertiesView/styles_sheet_list_view.cpp +++ b/wxcrafter/UI/PropertiesView/styles_sheet_list_view.cpp @@ -37,8 +37,8 @@ void StylesSheetListView::Construct(wxPropertyGrid* pg, wxcWidget* wb) wxcWidget::MapStyles_t::ConstIterator iter = flags.Begin(); // The control specific flags will show up first - for(; iter != flags.End(); ++iter) { - if(iter->first == "0") { + for (; iter != flags.End(); ++iter) { + if (iter->first == "0") { iter++; // We found the terminator break; @@ -49,28 +49,32 @@ void StylesSheetListView::Construct(wxPropertyGrid* pg, wxcWidget* wb) // wxCAPTION size_t flag_fake_value = (1 << count++); controlStylesInt.Add(flag_fake_value); // Add the value - if(iter->second.is_set) { controlStylesValue |= flag_fake_value; } + if (iter->second.is_set) { + controlStylesValue |= flag_fake_value; + } } // From this point on, everything is belonged to the // wxWindow styles - for(; iter != flags.End(); ++iter) { + for (; iter != flags.End(); ++iter) { windowStyles.Add(iter->first); // Add the style name windowStylesInt.Add(iter->second.style_bit); // Add the value - if(iter->second.is_set) { windowStylesValue |= iter->second.style_bit; } + if (iter->second.is_set) { + windowStylesValue |= iter->second.style_bit; + } } m_controlFlags = NULL; m_windowFlags = NULL; - if(controlStyles.IsEmpty() == false) { + if (controlStyles.IsEmpty() == false) { m_controlFlags = (wxFlagsProperty*)pg->Append( new wxFlagsProperty(wb->GetWxClassName(), wxPG_LABEL, controlStyles, controlStylesInt, controlStylesValue)); pg->SetPropertyAttribute(m_controlFlags, wxPG_BOOL_USE_CHECKBOX, true); pg->Expand(m_controlFlags); } - if(windowStyles.IsEmpty() == false) { + if (windowStyles.IsEmpty() == false) { m_windowFlags = (wxFlagsProperty*)pg->Append( new wxFlagsProperty(_("wxWindow"), wxPG_LABEL, windowStyles, windowStylesInt, windowStylesValue)); pg->SetPropertyAttribute(m_windowFlags, wxPG_BOOL_USE_CHECKBOX, true); @@ -89,19 +93,25 @@ void StylesSheetListView::Changed(wxPropertyGrid* pg, wxPropertyGridEvent& e) { // We used fake flags in controlStyles to avoid clashes, so we can't just retrieve the value as integer // Translating back into the real values won't work either: it just produces the clashes again. So use the strings - if(m_wxcWidget) { + if (m_wxcWidget) { wxString controlStyles; wxString windowStyles; - if(m_windowFlags) { windowStyles = m_windowFlags->GetValueAsString(); } + if (m_windowFlags) { + windowStyles = m_windowFlags->GetValueAsString(); + } - if(m_controlFlags) { controlStyles = m_controlFlags->GetValueAsString(); } + if (m_controlFlags) { + controlStyles = m_controlFlags->GetValueAsString(); + } // joint flags - if(!controlStyles.empty() && !windowStyles.empty()) { controlStyles << ','; } + if (!controlStyles.empty() && !windowStyles.empty()) { + controlStyles << ','; + } wxArrayString arr = ::wxStringTokenize(controlStyles + windowStyles, ",", wxTOKEN_STRTOK); // Reset the styles m_wxcWidget->ClearStyles(); - for(size_t i = 0; i < arr.GetCount(); ++i) { + for (size_t i = 0; i < arr.GetCount(); ++i) { m_wxcWidget->EnableStyle(arr.Item(i).Trim().Trim(false), true); } diff --git a/wxcrafter/UI/ToolBoxPanel.cpp b/wxcrafter/UI/ToolBoxPanel.cpp index ec06d64cbf..c12bc62378 100644 --- a/wxcrafter/UI/ToolBoxPanel.cpp +++ b/wxcrafter/UI/ToolBoxPanel.cpp @@ -14,32 +14,32 @@ void ToolBoxPanel::OnControlUI(wxUpdateUIEvent& event) GUICraftItemData* data = m_mainView->GetSelItemData(); - if(data && data->m_wxcWidget) { + if (data && data->m_wxcWidget) { wxcWidget* widget = data->m_wxcWidget; - if(widget->GetType() == ID_WXSCROLLEDWIN && event.GetId() == ID_WXAUIMANAGER && - Allocator::Instance()->GetInsertionType(event.GetId(), data->m_wxcWidget->GetType(), false) == - Allocator::INSERT_CHILD) { + if (widget->GetType() == ID_WXSCROLLEDWIN && event.GetId() == ID_WXAUIMANAGER && + Allocator::Instance()->GetInsertionType(event.GetId(), data->m_wxcWidget->GetType(), false) == + Allocator::INSERT_CHILD) { event.Enable(false); - } else if(widget->IsTopWindow() && widget->HasMenuBar() && event.GetId() == ID_WXMENUBAR) { + } else if (widget->IsTopWindow() && widget->HasMenuBar() && event.GetId() == ID_WXMENUBAR) { event.Enable(false); - } else if(widget->IsTopWindow() && widget->HasToolBar() && event.GetId() == ID_WXTOOLBAR) { + } else if (widget->IsTopWindow() && widget->HasToolBar() && event.GetId() == ID_WXTOOLBAR) { event.Enable(false); - } else if(widget->IsTopWindow() && widget->HasStatusBar() && event.GetId() == ID_WXSTATUSBAR) { + } else if (widget->IsTopWindow() && widget->HasStatusBar() && event.GetId() == ID_WXSTATUSBAR) { event.Enable(false); - } else if(Allocator::Instance()->GetInsertionType(event.GetId(), data->m_wxcWidget->GetType(), false, widget) != - Allocator::INSERT_NONE) { + } else if (Allocator::Instance()->GetInsertionType( + event.GetId(), data->m_wxcWidget->GetType(), false, widget) != Allocator::INSERT_NONE) { event.Enable(true); } else { event.Enable(false); } - } else if(!data) { + } else if (!data) { // Root item is selected int type = wxcWidget::GetWidgetType(event.GetId()); event.Enable(type == TYPE_FORM || type == TYPE_WIZARD || type == TYPE_FORM_FRAME || type == TYPE_IMGLIST); diff --git a/wxcrafter/UI/events_table_list_view.cpp b/wxcrafter/UI/events_table_list_view.cpp index aa95b82a0f..c8e1b96536 100644 --- a/wxcrafter/UI/events_table_list_view.cpp +++ b/wxcrafter/UI/events_table_list_view.cpp @@ -12,9 +12,12 @@ wxString PLACE_HOLDER = ""; wxDECLARE_EVENT(wxEVT_EVENTS_PROPERTIES_UPDATED, wxCommandEvent); EventsTableListView::EventsTableListView(wxWindow* parent) - : wxPropertyGridManager(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxPG_SPLITTER_AUTO_CENTER | wxPG_BOLD_MODIFIED | wxPG_DESCRIPTION | - wxCrafter::GetControlBorder()) + : wxPropertyGridManager( + parent, + wxID_ANY, + wxDefaultPosition, + wxDefaultSize, + wxPG_SPLITTER_AUTO_CENTER | wxPG_BOLD_MODIFIED | wxPG_DESCRIPTION | wxCrafter::GetControlBorder()) , m_eventsDb(NULL) { Connect(wxEVT_PG_CHANGED, wxPropertyGridEventHandler(EventsTableListView::OnPropertyChanged), NULL, this); @@ -38,14 +41,14 @@ void EventsTableListView::Construct(EventsEditorPane* dlg, wxcWidget* control, c for (const auto& [_, cd] : events.GetEvents()) { wxString eventName = cd.GetEventName(); eventName.Trim().Trim(false); - if(eventName.IsEmpty()) + if (eventName.IsEmpty()) continue; // Check to see if this event has a user defined function wxString fooname; - if(control->HasEvent(eventName)) { + if (control->HasEvent(eventName)) { fooname = control->GetEvent(eventName).GetFunctionNameAndSignature(); - } else if(!cd.GetFunctionNameAndSignature().empty()) { + } else if (!cd.GetFunctionNameAndSignature().empty()) { // A few events (well, just 1 atm) come with a default function fooname = cd.GetFunctionNameAndSignature(); } else { @@ -64,7 +67,7 @@ void EventsTableListView::Save() wxPropertyGrid* grid = GetGrid(); wxPropertyGridIterator it; - for(it = grid->GetIterator(); !it.AtEnd(); it++) { + for (it = grid->GetIterator(); !it.AtEnd(); it++) { wxPGProperty* p = *it; wxString event = p->GetLabel(); wxString func = p->GetValueAsString(); @@ -72,10 +75,10 @@ void EventsTableListView::Save() func.Trim().Trim(false); // If the handler is empty delete the event - if(func.IsEmpty() || func == PLACE_HOLDER) { + if (func.IsEmpty() || func == PLACE_HOLDER) { m_control->RemoveEvent(event); - } else if(m_eventsDb) { + } else if (m_eventsDb) { ConnectDetails cd = m_eventsDb->GetEvents().Item(event); cd.MakeSignatureForName(func); // insert or update diff --git a/wxcrafter/UI/text_editor.cpp b/wxcrafter/UI/text_editor.cpp index 600722472e..c8ff440b0b 100644 --- a/wxcrafter/UI/text_editor.cpp +++ b/wxcrafter/UI/text_editor.cpp @@ -12,7 +12,7 @@ TextEditor::TextEditor(wxWindow* parent) void TextEditor::OnKeyDown(wxKeyEvent& event) { - if(event.GetKeyCode() == WXK_ESCAPE) { + if (event.GetKeyCode() == WXK_ESCAPE) { Hide(); } else { event.Skip(); diff --git a/wxcrafter/UI/wxcSettingsDlg.cpp b/wxcrafter/UI/wxcSettingsDlg.cpp index cb3a66b9dd..30424f5dc0 100644 --- a/wxcrafter/UI/wxcSettingsDlg.cpp +++ b/wxcrafter/UI/wxcSettingsDlg.cpp @@ -1,4 +1,5 @@ #include "wxcSettingsDlg.h" + #include "wxc_settings.h" wxcSettingsDlg::wxcSettingsDlg(wxWindow* parent) @@ -19,8 +20,8 @@ void wxcSettingsDlg::OnOk(wxCommandEvent& event) { wxcSettings::Get().EnableFlag(wxcSettings::FORMAT_INHERITED_FILES, m_checkBoxFormatInheritedFiles->IsChecked()); wxcSettings::Get().EnableFlag(wxcSettings::DUPLICATE_KEEPS_ALL_NAMES, m_checkBoxKeepAllPossibleNames->IsChecked()); - wxcSettings::Get().EnableFlag(wxcSettings::DUPLICATE_KEEPS_USERSET_NAMES, - m_checkBoxKeepAllUsersetNames->IsChecked()); + wxcSettings::Get().EnableFlag( + wxcSettings::DUPLICATE_KEEPS_USERSET_NAMES, m_checkBoxKeepAllUsersetNames->IsChecked()); wxcSettings::Get().EnableFlag(wxcSettings::DUPLICATE_EVENTHANDLERS_TOO, m_checkBoxCopyEventhandlerToo->IsChecked()); wxcSettings::Get().EnableFlag(wxcSettings::EXIT_MINIMIZE_TO_TRAY, m_checkBoxUseTRay->IsChecked()); wxcSettings::Get().Save(); diff --git a/wxcrafter/aui/AuiToolbarWrapperBase.cpp b/wxcrafter/aui/AuiToolbarWrapperBase.cpp index c8242fbfcc..efd24ffccd 100644 --- a/wxcrafter/aui/AuiToolbarWrapperBase.cpp +++ b/wxcrafter/aui/AuiToolbarWrapperBase.cpp @@ -10,8 +10,8 @@ bool AuiToolbarWrapperBase::HasDropdownWithMenu(const wxcWidget* widget) const { for (auto child : widget->GetChildren()) { ToolBarItemWrapper* item = dynamic_cast(child); - if(item && wxCrafter::GetToolType(item->PropertyString(PROP_KIND)) == wxCrafter::TOOL_TYPE_DROPDOWN && - item->PropertyString(PROP_DROPDOWN_MENU) == "1") { + if (item && wxCrafter::GetToolType(item->PropertyString(PROP_KIND)) == wxCrafter::TOOL_TYPE_DROPDOWN && + item->PropertyString(PROP_DROPDOWN_MENU) == "1") { return true; } } @@ -22,7 +22,7 @@ void AuiToolbarWrapperBase::GenerateExtraFunctions(const wxcWidget* widget, wxSt { TopLevelWinWrapper* tlw = dynamic_cast(widget->GetTopLevel()); CHECK_PTR_RET(tlw); - if(!tlw->IsAuiToolBarDropDownHelpersRegistered() && HasDropdownWithMenu(widget)) { + if (!tlw->IsAuiToolBarDropDownHelpersRegistered() && HasDropdownWithMenu(widget)) { impl << "\n" << "void " << tlw->GetName() << "::" << DEFAULT_AUI_DROPDOWN_FUNCTION_AND_SIG << "\n{\n" << " event.Skip();\n" @@ -51,8 +51,8 @@ wxString AuiToolbarWrapperBase::CppDtorCode(const wxcWidget* widget) const { wxString cppCode; TopLevelWinWrapper* tlw = dynamic_cast(widget->GetTopLevel()); - if(tlw && !tlw->IsAuiToolBarDropDownHelpersRegistered()) { - if(HasDropdownWithMenu(widget)) { + if (tlw && !tlw->IsAuiToolBarDropDownHelpersRegistered()) { + if (HasDropdownWithMenu(widget)) { cppCode << " std::map::iterator menuIter = m_dropdownMenus.begin();\n" << " for( ; menuIter != m_dropdownMenus.end(); ++menuIter ) {\n" << " wxDELETE( menuIter->second );\n" @@ -68,8 +68,10 @@ wxString AuiToolbarWrapperBase::GenerateClassMembers(const wxcWidget* widget) co wxString memberCode = widget->BaseDoGenerateClassMember(); // Base class stuff TopLevelWinWrapper* tlw = dynamic_cast(widget->GetTopLevel()); - if(tlw && !tlw->IsAuiToolBarDropDownHelpersRegistered() && HasDropdownWithMenu(widget)) { - if(!memberCode.empty()) { memberCode << "\n"; } + if (tlw && !tlw->IsAuiToolBarDropDownHelpersRegistered() && HasDropdownWithMenu(widget)) { + if (!memberCode.empty()) { + memberCode << "\n"; + } memberCode << " std::map m_dropdownMenus;"; } return memberCode; diff --git a/wxcrafter/aui/aui_manager_wrapper.cpp b/wxcrafter/aui/aui_manager_wrapper.cpp index a99138e672..fccdab0a30 100644 --- a/wxcrafter/aui/aui_manager_wrapper.cpp +++ b/wxcrafter/aui/aui_manager_wrapper.cpp @@ -41,7 +41,8 @@ AuiManagerWrapper::AuiManagerWrapper() Add(PROP_AUI_SASH_SIZE, -1, _("Set the wxAUI sash size")); Add(_("Caption")); - wxArrayString gradientTypes = StdToWX::ToArrayString({"wxAUI_GRADIENT_NONE", "wxAUI_GRADIENT_VERTICAL", "wxAUI_GRADIENT_HORIZONTAL"}); + wxArrayString gradientTypes = + StdToWX::ToArrayString({"wxAUI_GRADIENT_NONE", "wxAUI_GRADIENT_VERTICAL", "wxAUI_GRADIENT_HORIZONTAL"}); Add(PROP_AUI_GRADIENT_TYPE, gradientTypes, 0, _("Gradient type")); Add(PROP_AUI_CAPTION_COLOUR, "", _("Active caption colour")); @@ -64,15 +65,17 @@ AuiManagerWrapper::AuiManagerWrapper() PREPEND_STYLE(wxAUI_MGR_NO_VENETIAN_BLINDS_FADE, false); PREPEND_STYLE(wxAUI_MGR_LIVE_RESIZE, true); - RegisterEvent("wxEVT_AUI_PANE_BUTTON", "wxAuiManagerEvent", - _("Triggered when any button is pressed for any docked panes")); - RegisterEvent("wxEVT_AUI_PANE_CLOSE", "wxAuiManagerEvent", - _("Triggered when a docked or floating pane is closed.")); + RegisterEvent( + "wxEVT_AUI_PANE_BUTTON", "wxAuiManagerEvent", _("Triggered when any button is pressed for any docked panes")); + RegisterEvent( + "wxEVT_AUI_PANE_CLOSE", "wxAuiManagerEvent", _("Triggered when a docked or floating pane is closed.")); RegisterEvent("wxEVT_AUI_PANE_MAXIMIZE", "wxAuiManagerEvent", _("Triggered when a pane is maximized.")); RegisterEvent("wxEVT_AUI_PANE_RESTORE", "wxAuiManagerEvent", _("Triggered when a pane is restored.")); - RegisterEvent("wxEVT_AUI_PANE_ACTIVATED", "wxAuiManagerEvent", + RegisterEvent("wxEVT_AUI_PANE_ACTIVATED", + "wxAuiManagerEvent", _("Triggered when a pane is made 'active'. This event is new since wxWidgets 2.9.4.")); - RegisterEvent("wxEVT_AUI_RENDER", "wxAuiManagerEvent", + RegisterEvent("wxEVT_AUI_RENDER", + "wxAuiManagerEvent", _("This event can be caught to override the default renderer in order " "to custom draw your wxAuiManager window (not recommended).")); @@ -87,52 +90,52 @@ wxString AuiManagerWrapper::CppCtorCode() const wxString cppCode; cppCode << GetName() << " = new wxAuiManager;\n"; - if(GetParent()->IsTopWindow()) { + if (GetParent()->IsTopWindow()) { cppCode << GetName() << "->SetManagedWindow( this );\n"; } else { cppCode << GetName() << "->SetManagedWindow( " << GetParent()->GetName() << " );\n"; } cppCode << GetName() << "->SetFlags( " << StyleFlags("0") << ");\n"; - if(PropertyInt(PROP_AUI_SASH_SIZE) != -1) + if (PropertyInt(PROP_AUI_SASH_SIZE) != -1) cppCode << GetName() << "->GetArtProvider()->SetMetric( wxAUI_DOCKART_SASH_SIZE, " << PropertyInt(PROP_AUI_SASH_SIZE) << ");\n"; - if(PropertyInt(PROP_AUI_PANE_BORDER_SIZE) != -1) + if (PropertyInt(PROP_AUI_PANE_BORDER_SIZE) != -1) cppCode << GetName() << "->GetArtProvider()->SetMetric( wxAUI_DOCKART_PANE_BORDER_SIZE, " << PropertyInt(PROP_AUI_PANE_BORDER_SIZE) << ");\n"; wxString col; col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_SASH_COLOUR)); - if(!col.IsEmpty()) + if (!col.IsEmpty()) cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_SASH_COLOUR, " << col << ");\n"; col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_CAPTION_COLOUR)); - if(!col.IsEmpty()) + if (!col.IsEmpty()) cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR, " << col << ");\n"; col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_CAPTION_COLOUR_GRADIENT)); - if(!col.IsEmpty()) + if (!col.IsEmpty()) cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR, " << col << ");\n"; col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_INACTIVE_CAPTION_COLOUR)); - if(!col.IsEmpty()) + if (!col.IsEmpty()) cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR, " << col << ");\n"; col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_INACTIVE_CAPTION_COLOUR_GRADIENT)); - if(!col.IsEmpty()) + if (!col.IsEmpty()) cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR, " << col << ");\n"; col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_ACTIVE_CAPTION_TEXT_COLOUR)); - if(!col.IsEmpty()) + if (!col.IsEmpty()) cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR, " << col << ");\n"; col = wxCrafter::ColourToCpp(PropertyString(PROP_AUI_INACTIVE_CAPTION_TEXT_COLOUR)); - if(!col.IsEmpty()) + if (!col.IsEmpty()) cppCode << GetName() << "->GetArtProvider()->SetColor( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR, " << col << ");\n"; cppCode << GetName() << "->GetArtProvider()->SetMetric(wxAUI_DOCKART_GRADIENT_TYPE, " diff --git a/wxcrafter/aui/aui_notebook_wrapper.cpp b/wxcrafter/aui/aui_notebook_wrapper.cpp index 1a8d57e663..c759289aa6 100644 --- a/wxcrafter/aui/aui_notebook_wrapper.cpp +++ b/wxcrafter/aui/aui_notebook_wrapper.cpp @@ -1,6 +1,8 @@ #include "aui_notebook_wrapper.h" + #include "allocator_mgr.h" #include "wxgui_defs.h" + #include AuiNotebookWrapper::AuiNotebookWrapper() @@ -22,33 +24,43 @@ AuiNotebookWrapper::AuiNotebookWrapper() SetPropertyString(_("Common Settings"), "wxAuiNotebook"); m_properties.Item(PROP_SIZE)->SetValue(wxT("250,250")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE"), wxT("wxAuiNotebookEvent"), - _("A page is about to be closed")); + RegisterEvent( + wxT("wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE"), wxT("wxAuiNotebookEvent"), _("A page is about to be closed")); RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED"), wxT("wxAuiNotebookEvent"), _("A page has been closed")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED"), wxT("wxAuiNotebookEvent"), - _("The page selection was changed")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING"), wxT("wxAuiNotebookEvent"), + RegisterEvent( + wxT("wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED"), wxT("wxAuiNotebookEvent"), _("The page selection was changed")); + RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING"), + wxT("wxAuiNotebookEvent"), _("The page selection is about to be changed.\nThis event can be vetoed")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_BUTTON"), wxT("wxAuiNotebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_BUTTON"), + wxT("wxAuiNotebookEvent"), _("The window list button has been pressed")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG"), wxT("wxAuiNotebookEvent"), - _("Dragging is about to begin")); + RegisterEvent( + wxT("wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG"), wxT("wxAuiNotebookEvent"), _("Dragging is about to begin")); RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_END_DRAG"), wxT("wxAuiNotebookEvent"), _("Dragging has ended")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION"), wxT("wxAuiNotebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION"), + wxT("wxAuiNotebookEvent"), _("Emitted during a drag and drop operation")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND"), wxT("wxAuiNotebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND"), + wxT("wxAuiNotebookEvent"), _("Whether to allow a tab to be dropped. This event must be specially allowed")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE"), wxT("wxAuiNotebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE"), + wxT("wxAuiNotebookEvent"), _("Notify that the tab has been dragged")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK"), wxT("wxAuiNotebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK"), + wxT("wxAuiNotebookEvent"), _("Double clicked on the tabs background area")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN"), wxT("wxAuiNotebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN"), + wxT("wxAuiNotebookEvent"), _("The middle mouse button is pressed on a tab")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP"), wxT("wxAuiNotebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP"), + wxT("wxAuiNotebookEvent"), _("The middle mouse button is released on a tab")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN"), wxT("wxAuiNotebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN"), + wxT("wxAuiNotebookEvent"), _("The right mouse button is pressed on a tab")); - RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP"), wxT("wxAuiNotebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP"), + wxT("wxAuiNotebookEvent"), _("The right mouse button is released on a tab")); m_namePattern = wxT("m_auiBook"); SetName(GenerateName()); diff --git a/wxcrafter/aui/aui_pane_info.cpp b/wxcrafter/aui/aui_pane_info.cpp index b59ec481c5..2fdb9c7a2f 100644 --- a/wxcrafter/aui/aui_pane_info.cpp +++ b/wxcrafter/aui/aui_pane_info.cpp @@ -15,22 +15,34 @@ wxString AuiPaneInfo::ToCppCode() const { wxString cppCode = "wxAuiPaneInfo()"; - if(m_name.IsEmpty() == false) { cppCode << ".Name(" << wxCrafter::WXT(m_name) << ")"; } + if (m_name.IsEmpty() == false) { + cppCode << ".Name(" << wxCrafter::WXT(m_name) << ")"; + } - if(m_caption.IsEmpty() == false) { cppCode << ".Caption(" << wxCrafter::UNDERSCORE(m_caption) << ")"; } + if (m_caption.IsEmpty() == false) { + cppCode << ".Caption(" << wxCrafter::UNDERSCORE(m_caption) << ")"; + } cppCode << ".Direction(" << m_dockDirection << ")"; cppCode << ".Layer(" << m_layer << ")"; cppCode << ".Row(" << m_row << ")"; cppCode << ".Position(" << m_position << ")"; - if(m_bestSize != wxDefaultSize) { cppCode << ".BestSize(" << wxCrafter::EncodeSize(m_bestSize) << ")"; } + if (m_bestSize != wxDefaultSize) { + cppCode << ".BestSize(" << wxCrafter::EncodeSize(m_bestSize) << ")"; + } - if(m_minSize != wxDefaultSize) { cppCode << ".MinSize(" << wxCrafter::EncodeSize(m_minSize) << ")"; } + if (m_minSize != wxDefaultSize) { + cppCode << ".MinSize(" << wxCrafter::EncodeSize(m_minSize) << ")"; + } - if(m_maxSize != wxDefaultSize) { cppCode << ".MaxSize(" << wxCrafter::EncodeSize(m_maxSize) << ")"; } + if (m_maxSize != wxDefaultSize) { + cppCode << ".MaxSize(" << wxCrafter::EncodeSize(m_maxSize) << ")"; + } - if(!m_resizable) { cppCode << ".Fixed()"; } + if (!m_resizable) { + cppCode << ".Fixed()"; + } cppCode << ".CaptionVisible(" << BOOL_TO_STR(m_captionVisible) << ")"; cppCode << ".MaximizeButton(" << BOOL_TO_STR(m_maxButton) << ")"; @@ -38,7 +50,9 @@ wxString AuiPaneInfo::ToCppCode() const cppCode << ".MinimizeButton(" << BOOL_TO_STR(m_minButton) << ")"; cppCode << ".PinButton(" << BOOL_TO_STR(m_pinButton) << ")"; - if(m_toolbarPane) { cppCode << ".ToolbarPane()"; } + if (m_toolbarPane) { + cppCode << ".ToolbarPane()"; + } return cppCode; } @@ -65,7 +79,7 @@ void AuiPaneInfo::Construct(wxPropertyGrid* pg) const pg->Expand(dockings); const wxArrayString directions = StdToWX::ToArrayString( - { "wxAUI_DOCK_TOP", "wxAUI_DOCK_RIGHT", "wxAUI_DOCK_BOTTOM", "wxAUI_DOCK_LEFT", "wxAUI_DOCK_CENTER" }); + {"wxAUI_DOCK_TOP", "wxAUI_DOCK_RIGHT", "wxAUI_DOCK_BOTTOM", "wxAUI_DOCK_LEFT", "wxAUI_DOCK_CENTER"}); wxEnumProperty* dir = (wxEnumProperty*)pg->Append(new wxEnumProperty(_("Direction"), wxPG_LABEL, directions)); pg->Expand(dir); dir->SetChoiceSelection(directions.Index(m_dockDirection)); @@ -98,12 +112,15 @@ void AuiPaneInfo::Construct(wxPropertyGrid* pg) const void AuiPaneInfo::FromJSON(const JSONItem& json) { Reset(); - if(json.isOk() == false) { return; } + if (json.isOk() == false) { + return; + } m_name = json.namedObject("m_name").toString(); m_caption = json.namedObject("m_caption").toString(); m_dockDirection = json.namedObject("m_dockDirection").toString(); - if(m_dockDirection.IsEmpty()) m_dockDirection = "wxAUI_DOCK_LEFT"; + if (m_dockDirection.IsEmpty()) + m_dockDirection = "wxAUI_DOCK_LEFT"; m_layer = json.namedObject("m_layer").toInt(); m_row = json.namedObject("m_row").toInt(); @@ -168,39 +185,39 @@ void AuiPaneInfo::OnChanged(wxPropertyGridEvent& e) wxSize szValue = wxCrafter::DecodeSize(value); bool bValue = prop->GetValue().GetBool(); - if(label == _("Name")) + if (label == _("Name")) m_name = value; - else if(label == _("Caption")) + else if (label == _("Caption")) m_caption = value; - else if(label == _("Caption Visible")) + else if (label == _("Caption Visible")) m_captionVisible = bValue; - else if(label == _("Resizable")) + else if (label == _("Resizable")) m_resizable = bValue; - else if(label == _("Direction")) + else if (label == _("Direction")) m_dockDirection = value; - else if(label == _("Layer")) + else if (label == _("Layer")) m_layer = iValue; - else if(label == _("Row")) + else if (label == _("Row")) m_row = iValue; - else if(label == _("Position")) + else if (label == _("Position")) m_position = iValue; - else if(label == _("Best Size")) + else if (label == _("Best Size")) m_bestSize = szValue; - else if(label == _("Min Size")) + else if (label == _("Min Size")) m_minSize = szValue; - else if(label == _("Max Size")) + else if (label == _("Max Size")) m_maxSize = szValue; - else if(label == _("Close Button")) + else if (label == _("Close Button")) m_closeButton = bValue; - else if(label == _("Minimize Button")) + else if (label == _("Minimize Button")) m_minButton = bValue; - else if(label == _("Maximize Button")) + else if (label == _("Maximize Button")) m_maxButton = bValue; - else if(label == _("Pin Button")) + else if (label == _("Pin Button")) m_pinButton = bValue; - else if(label == _("ToolBar Pane")) + else if (label == _("ToolBar Pane")) m_toolbarPane = bValue; } @@ -232,15 +249,15 @@ wxString AuiPaneInfo::ToXRC(const wxString& objXRC) const << "" << wxCrafter::EncodeSize(m_maxSize) << "" << "" << wxCrafter::EncodeSize(m_minSize) << ""; - if(m_dockDirection == "wxAUI_DOCK_TOP") + if (m_dockDirection == "wxAUI_DOCK_TOP") xrc << "1"; - else if(m_dockDirection == "wxAUI_DOCK_BOTTOM") + else if (m_dockDirection == "wxAUI_DOCK_BOTTOM") xrc << "1"; - else if(m_dockDirection == "wxAUI_DOCK_LEFT") + else if (m_dockDirection == "wxAUI_DOCK_LEFT") xrc << "1"; - else if(m_dockDirection == "wxAUI_DOCK_RIGHT") + else if (m_dockDirection == "wxAUI_DOCK_RIGHT") xrc << "1"; - else if(m_dockDirection == "wxAUI_DOCK_CENTER" || m_dockDirection == "wxAUI_DOCK_CENTRE") + else if (m_dockDirection == "wxAUI_DOCK_CENTER" || m_dockDirection == "wxAUI_DOCK_CENTRE") xrc << "1"; else xrc << "1"; // Default @@ -256,7 +273,9 @@ wxString AuiPaneInfo::ToXRC(const wxString& objXRC) const << "" << XRC_BOOL_TO_STR(m_maxButton) << "" << "" << XRC_BOOL_TO_STR(m_pinButton) << ""; - if(m_toolbarPane) { xrc << "" << XRC_BOOL_TO_STR(m_toolbarPane) << ""; } + if (m_toolbarPane) { + xrc << "" << XRC_BOOL_TO_STR(m_toolbarPane) << ""; + } xrc << objXRC << ""; return xrc; } diff --git a/wxcrafter/controls/AnimationCtrlWrapper.cpp b/wxcrafter/controls/AnimationCtrlWrapper.cpp index 269385469a..03ab1f5c3e 100644 --- a/wxcrafter/controls/AnimationCtrlWrapper.cpp +++ b/wxcrafter/controls/AnimationCtrlWrapper.cpp @@ -41,7 +41,7 @@ wxString AnimationCtrlWrapper::CppCtorCode() const << ");\n"; // Load the image file - if(PropertyBool(PROP_ANIM_AUTO_PLAY) == "true") { + if (PropertyBool(PROP_ANIM_AUTO_PLAY) == "true") { code << "if( wxFileName::Exists(" << wxCrafter::WXT(PropertyFile(PROP_BITMAP_PATH)) << ") && " << GetName() << "->LoadFile(" << wxCrafter::WXT(PropertyFile(PROP_BITMAP_PATH)) << "))" << GetName() << "->Play();\n"; } diff --git a/wxcrafter/controls/BitmapComboxWrapper.cpp b/wxcrafter/controls/BitmapComboxWrapper.cpp index 5e1ab4a07b..0e189301a9 100644 --- a/wxcrafter/controls/BitmapComboxWrapper.cpp +++ b/wxcrafter/controls/BitmapComboxWrapper.cpp @@ -22,8 +22,8 @@ BitmapComboxWrapper::BitmapComboxWrapper() RegisterEventCommand("wxEVT_COMMAND_COMBOBOX_SELECTED", _("Process a wxEVT_COMMAND_COMBOBOX_SELECTED event, when an item on the list is selected. " "Note that calling GetValue returns the new value of selection.")); - RegisterEventCommand("wxEVT_COMMAND_TEXT_UPDATED", - _("Process a wxEVT_COMMAND_TEXT_UPDATED event, when the comboBox text changes.")); + RegisterEventCommand( + "wxEVT_COMMAND_TEXT_UPDATED", _("Process a wxEVT_COMMAND_TEXT_UPDATED event, when the comboBox text changes.")); RegisterEventCommand("wxEVT_COMMAND_TEXT_ENTER", _("Process a wxEVT_COMMAND_TEXT_ENTER event, when is pressed in the comboBox.")); @@ -53,11 +53,11 @@ wxString BitmapComboxWrapper::CppCtorCode() const << ", wxDefaultPosition, " << SizeAsString() << ", wxArrayString(), " << StyleFlags("0") << ");\n"; // Append the items - for(size_t i = 0; i < labels.GetCount(); ++i) { + for (size_t i = 0; i < labels.GetCount(); ++i) { code << GetName() << "->Append(" << wxCrafter::UNDERSCORE(labels.Item(i)) << ", " << bitmaps.Item(i) << ");\n"; } int sel = PropertyInt(PROP_SELECTION); - if(sel != wxNOT_FOUND && sel < (int)labels.GetCount()) { + if (sel != wxNOT_FOUND && sel < (int)labels.GetCount()) { code << GetName() << "->SetSelection(" << sel << ");\n"; } return code; @@ -83,7 +83,7 @@ void BitmapComboxWrapper::ToXRC(wxString& text, XRC_TYPE type) const text << ""; } - if(!HasStyle(wxCB_READONLY) && !PropertyString(PROP_HINT).empty()) { + if (!HasStyle(wxCB_READONLY) && !PropertyString(PROP_HINT).empty()) { // set hint for non-readonly combobox text << "" << wxCrafter::CDATA(PropertyString(PROP_HINT)) << ""; } diff --git a/wxcrafter/controls/Containers/collapsible_pane_wrapper.cpp b/wxcrafter/controls/Containers/collapsible_pane_wrapper.cpp index fcfa302037..81a5029e0a 100644 --- a/wxcrafter/controls/Containers/collapsible_pane_wrapper.cpp +++ b/wxcrafter/controls/Containers/collapsible_pane_wrapper.cpp @@ -10,7 +10,8 @@ CollapsiblePaneWrapper::CollapsiblePaneWrapper() : wxcWidget(ID_WXCOLLAPSIBLEPANE) { - RegisterEvent("wxEVT_COMMAND_COLLPANE_CHANGED", "wxCollapsiblePaneEvent", + RegisterEvent("wxEVT_COMMAND_COLLPANE_CHANGED", + "wxCollapsiblePaneEvent", _("The user expanded or collapsed the collapsible pane")); RegisterEvent("wxEVT_NAVIGATION_KEY", "wxNavigationKeyEvent", _("Process a navigation key event")); @@ -41,7 +42,7 @@ void CollapsiblePaneWrapper::ToXRC(wxString& text, XRC_TYPE type) const text << XRCPrefix() << XRCLabel() << XRCSize() << XRCCommonAttributes(); - if(type == XRC_DESIGNER) { + if (type == XRC_DESIGNER) { text << ""; } else { diff --git a/wxcrafter/controls/Containers/notebook_base_wrapper.cpp b/wxcrafter/controls/Containers/notebook_base_wrapper.cpp index 1c10257956..f9071a7b74 100644 --- a/wxcrafter/controls/Containers/notebook_base_wrapper.cpp +++ b/wxcrafter/controls/Containers/notebook_base_wrapper.cpp @@ -33,7 +33,7 @@ wxString NotebookBaseWrapper::CppCtorCode() const yy = -1; for (auto child : m_children) { NotebookPageWrapper* page = dynamic_cast(child); - if(page) { + if (page) { wxSize sz = page->GetImageSize(); xx = wxMax(sz.x, xx); yy = wxMax(sz.y, yy); @@ -42,7 +42,7 @@ wxString NotebookBaseWrapper::CppCtorCode() const // Add image list bool isAuiBook = (GetType() == ID_WXAUINOTEBOOK); - if((xx != -1 && yy != -1) && !isAuiBook) { + if ((xx != -1 && yy != -1) && !isAuiBook) { wxString ilName; ilName << GetName() << "_il"; code << "wxImageList* " << ilName << " = new wxImageList(" << xx << ", " << yy << ");\n"; @@ -51,7 +51,7 @@ wxString NotebookBaseWrapper::CppCtorCode() const wxString& helperCode = wxcNotebookCodeHelper::Get().Code(); wxcWidget* tlw = GetTopLevel(); - if(tlw && tlw->IsPropertyChecked(PROP_PERSISTENT)) { + if (tlw && tlw->IsPropertyChecked(PROP_PERSISTENT)) { helperCode << "\n"; helperCode << wxCrafter::WX29_BLOCK_START(); helperCode << "if(!wxPersistenceManager::Get().Find(" << GetName() << ")){\n"; @@ -79,7 +79,7 @@ NotebookPageWrapper* NotebookBaseWrapper::GetSelection() const // Check the children of this page and the page itself NotebookPageWrapper* sel = DoGetSelection(page); - if(sel) { + if (sel) { return sel; } } @@ -108,7 +108,7 @@ void NotebookBaseWrapper::DoSetSelection(NotebookPageWrapper* page, wxcWidget* p NotebookPageWrapper* NotebookBaseWrapper::DoGetSelection(NotebookPageWrapper* page) const { - if(page->IsSelected()) { + if (page->IsSelected()) { return page; } for (auto* child : page->GetChildren()) { @@ -135,15 +135,16 @@ int NotebookBaseWrapper::GetPageIndex(const NotebookPageWrapper* page) const return wxNOT_FOUND; } -bool NotebookBaseWrapper::DoGetPageIndex(const NotebookPageWrapper* page, const NotebookPageWrapper* pageToFind, +bool NotebookBaseWrapper::DoGetPageIndex(const NotebookPageWrapper* page, + const NotebookPageWrapper* pageToFind, int& count) const { - if(page == pageToFind) { + if (page == pageToFind) { return true; } count++; - if(page->GetChildren().empty()) { + if (page->GetChildren().empty()) { return false; } @@ -168,26 +169,26 @@ wxcWidget* NotebookBaseWrapper::GetChildPageAtDepth(size_t targetlevel) wxcWidget* target = NULL; NotebookPageWrapper* page = GetLastPage(); // Find the last page of the book - if(page) { + if (page) { target = DoGetChildPageAtDepth(page, targetlevel, 0); } return target; } -NotebookPageWrapper* NotebookBaseWrapper::DoGetChildPageAtDepth(NotebookPageWrapper* page, size_t targetlevel, - size_t currentlevel) const +NotebookPageWrapper* +NotebookBaseWrapper::DoGetChildPageAtDepth(NotebookPageWrapper* page, size_t targetlevel, size_t currentlevel) const { - if(currentlevel == targetlevel) { + if (currentlevel == targetlevel) { return page; } // The _last_ child notebookpage is the one to check const wxcWidget::List_t& children = page->GetChildren(); wxcWidget::List_t::const_reverse_iterator riter = children.rbegin(); - for(; riter != children.rend(); ++riter) { + for (; riter != children.rend(); ++riter) { NotebookPageWrapper* child = dynamic_cast(*riter); - if(child) { + if (child) { return DoGetChildPageAtDepth(child, targetlevel, ++currentlevel); } } diff --git a/wxcrafter/controls/Containers/notebook_base_wrapper.h b/wxcrafter/controls/Containers/notebook_base_wrapper.h index 651f55708b..c199f05939 100644 --- a/wxcrafter/controls/Containers/notebook_base_wrapper.h +++ b/wxcrafter/controls/Containers/notebook_base_wrapper.h @@ -16,8 +16,8 @@ class NotebookBaseWrapper : public wxcWidget NotebookPageWrapper* DoGetSelection(NotebookPageWrapper* page) const; bool DoGetPageIndex(const NotebookPageWrapper* page, const NotebookPageWrapper* pageToFind, int& count) const; NotebookPageWrapper* GetLastPage() const; - NotebookPageWrapper* DoGetChildPageAtDepth(NotebookPageWrapper* page, size_t targetlevel, - size_t currentlevel) const; + NotebookPageWrapper* + DoGetChildPageAtDepth(NotebookPageWrapper* page, size_t targetlevel, size_t currentlevel) const; public: wxString CppCtorCode() const override; diff --git a/wxcrafter/controls/Containers/notebook_page_wrapper.cpp b/wxcrafter/controls/Containers/notebook_page_wrapper.cpp index f85b845413..c9bcbfa2d1 100644 --- a/wxcrafter/controls/Containers/notebook_page_wrapper.cpp +++ b/wxcrafter/controls/Containers/notebook_page_wrapper.cpp @@ -38,26 +38,30 @@ wxcWidget* NotebookPageWrapper::Clone() const { return new NotebookPageWrapper() wxString NotebookPageWrapper::CppCtorCode() const { - if(IsTreebookPage()) { return DoTreebookCppCtorCode(); } + if (IsTreebookPage()) { + return DoTreebookCppCtorCode(); + } wxString code; code << CPPStandardWxCtor(wxT("wxTAB_TRAVERSAL")); // If our parent is not a notebook, return the code NotebookBaseWrapper* book = GetNotebook(); - if(!book) { return code; } + if (!book) { + return code; + } bool isAuiPage = (book->GetType() == ID_WXAUINOTEBOOK); bool isChoicePage = (book->GetType() == ID_WXCHOICEBOOK); - if(!isChoicePage) { + if (!isChoicePage) { // wxChoicebook does not support images (yet) wxcCodeGeneratorHelper::Get().AddBitmap(PropertyFile(PROP_BITMAP_PATH)); } bool bHasBitmap = (GetImageSize() != wxSize(-1, -1)); wxString imgListName, imgIndex; - if(!isChoicePage && !isAuiPage && bHasBitmap) { + if (!isChoicePage && !isAuiPage && bHasBitmap) { imgListName << GetParent()->GetName() << wxT("_il"); imgIndex << GetName() << wxT("ImgIndex"); code << wxT("int ") << imgIndex << wxT(";\n"); @@ -65,14 +69,14 @@ wxString NotebookPageWrapper::CppCtorCode() const << wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)) << wxT(");\n"); } - if(isAuiPage && bHasBitmap) { + if (isAuiPage && bHasBitmap) { // Aui passes the bitmap in the AddPage(...) call // Add this page to the notebook code << GetParent()->GetName() << wxT("->AddPage(") << GetName() << wxT(", ") << Label() << wxT(", ") << PropertyBool(PROP_SELECTED) << wxT(", ") << wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)) << wxT(");\n"); - } else if(bHasBitmap && !imgIndex.IsEmpty()) { + } else if (bHasBitmap && !imgIndex.IsEmpty()) { // Add this page to the notebook code << GetParent()->GetName() << wxT("->AddPage(") << GetName() << wxT(", ") << Label() << wxT(", ") << PropertyBool(PROP_SELECTED) << wxT(", ") << imgIndex << wxT(");\n"); @@ -96,9 +100,11 @@ wxString NotebookPageWrapper::GetWxClassName() const { return wxT("wxPanel"); } void NotebookPageWrapper::ToXRC(wxString& text, XRC_TYPE type) const { NotebookBaseWrapper* book = dynamic_cast(GetParent()); - if(!book) { return; } + if (!book) { + return; + } - if(IsTreebookPage()) { + if (IsTreebookPage()) { int depth(0); DoTreebookXRC(text, type, depth); return; @@ -106,12 +112,14 @@ void NotebookPageWrapper::ToXRC(wxString& text, XRC_TYPE type) const text << wxT("GetXRCPageClass() << wxT("\">") << XRCLabel(); - if(!IsChoicebookPage()) { + if (!IsChoicebookPage()) { wxString bmp = PropertyFile(PROP_BITMAP_PATH); - if(bmp.IsEmpty() == false) { text << XRCBitmap(); } + if (bmp.IsEmpty() == false) { + text << XRCBitmap(); + } } - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << wxT("") << wxCrafter::XMLEncode(PropertyString(PROP_SELECTED)) << wxT(""); } else { @@ -134,17 +142,21 @@ void NotebookPageWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) // There are 3 possible properties. Not all will apply to all bookpage types, but the XRC should only supply // relevant ones... wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { + if (propertynode) { wxString value = propertynode->GetNodeContent(); PropertyBase* prop = GetProperty(PROP_BITMAP_PATH); - if(prop) { prop->SetValue(value); } + if (prop) { + prop->SetValue(value); + } } propertynode = XmlUtils::FindFirstByTagName(node, wxT("selection")); - if(propertynode) { + if (propertynode) { wxString value = propertynode->GetNodeContent(); PropertyBase* prop = GetProperty(PROP_SELECTION); - if(prop) { prop->SetValue(value); } + if (prop) { + prop->SetValue(value); + } } /* propertynode = XmlUtils::FindFirstByTagName(node, wxT("depth")); @@ -165,10 +177,12 @@ void NotebookPageWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) // There are 3 possible properties. Not all will apply to all bookpage types, but the XRC should only supply // relevant ones... wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("selection")); - if(propertynode) { + if (propertynode) { wxString value = propertynode->GetNodeContent(); PropertyBase* prop = GetProperty(PROP_SELECTION); - if(prop) { prop->SetValue(value); } + if (prop) { + prop->SetValue(value); + } } } @@ -177,9 +191,9 @@ wxSize NotebookPageWrapper::GetImageSize() const clDirChanger dc(wxcProjectMetadata::Get().GetProjectPath()); wxString bmp = PropertyFile(PROP_BITMAP_PATH); wxFileName fn(bmp); - if(fn.FileExists()) { + if (fn.FileExists()) { wxBitmap bmpFile(fn.GetFullPath(), wxBITMAP_TYPE_ANY); - if(bmpFile.IsOk()) { + if (bmpFile.IsOk()) { wxSize bmpSize; bmpSize.x = bmpFile.GetWidth(); bmpSize.y = bmpFile.GetHeight(); @@ -192,10 +206,10 @@ wxSize NotebookPageWrapper::GetImageSize() const void NotebookPageWrapper::SetParent(wxcWidget* parent) { wxcWidget::SetParent(parent); - if(IsChoicebookPage()) { + if (IsChoicebookPage()) { DelProperty(PROP_BITMAP_PATH); - } else if(IsTreebookPage()) { + } else if (IsTreebookPage()) { Add(PROP_EXPANDED, true, _("Expand this node")); } } @@ -207,9 +221,11 @@ bool NotebookPageWrapper::IsTreebookPage() const bool isTreebookPage = false; // Find the first parent of type Notebook NotebookBaseWrapper* book = GetNotebook(); - if(book) { isTreebookPage = (dynamic_cast(book) != NULL); } + if (book) { + isTreebookPage = (dynamic_cast(book) != NULL); + } - if(!isTreebookPage) { + if (!isTreebookPage) { NotebookPageWrapper* parent = dynamic_cast(GetParent()); isTreebookPage = (parent != NULL); } @@ -220,12 +236,14 @@ void NotebookPageWrapper::DoTreebookXRC(wxString& text, XRC_TYPE type, int depth { text << wxT("") << XRCLabel(); - if(!IsChoicebookPage()) { + if (!IsChoicebookPage()) { wxString bmp = PropertyFile(PROP_BITMAP_PATH); - if(bmp.IsEmpty() == false) { text << XRCBitmap(); } + if (bmp.IsEmpty() == false) { + text << XRCBitmap(); + } } - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << wxT("") << wxCrafter::XMLEncode(PropertyString(PROP_SELECTED)) << wxT(""); } else { @@ -249,7 +267,9 @@ void NotebookPageWrapper::DoTreebookXRC(wxString& text, XRC_TYPE type, int depth } else { child->ToXRC(xrc, type); - if (child->IsSizerItem()) { xrc = child->WrapInSizerXRC(xrc); } + if (child->IsSizerItem()) { + xrc = child->WrapInSizerXRC(xrc); + } } text << xrc; } @@ -263,12 +283,15 @@ NotebookBaseWrapper* NotebookPageWrapper::GetNotebook() const { // Find the first parent of type Notebook wxcWidget* parent = GetParent(); - while(parent) { - if(dynamic_cast(parent)) { break; } + while (parent) { + if (dynamic_cast(parent)) { + break; + } parent = parent->GetParent(); } - if(!parent) return NULL; + if (!parent) + return NULL; return dynamic_cast(parent); } @@ -276,19 +299,24 @@ NotebookBaseWrapper* NotebookPageWrapper::GetNotebook() const int NotebookPageWrapper::GetPageIndex() const { NotebookBaseWrapper* book = GetNotebook(); - if(!book) { return wxNOT_FOUND; } + if (!book) { + return wxNOT_FOUND; + } return book->GetPageIndex((const NotebookPageWrapper*)this); } wxString NotebookPageWrapper::DoTreebookCppCtorCode() const { - if(!GetNotebook()) return wxT(""); + if (!GetNotebook()) + return wxT(""); wxString code; bool isNullPage = (PropertyBool(PROP_NULL_BOOK_PAGE) == "true"); - if(!isNullPage) { code << CPPStandardWxCtor(wxT("wxTAB_TRAVERSAL")); } + if (!isNullPage) { + code << CPPStandardWxCtor(wxT("wxTAB_TRAVERSAL")); + } bool bHasBitmap = false; wxString imgListName, imgIndex; @@ -299,7 +327,7 @@ wxString NotebookPageWrapper::DoTreebookCppCtorCode() const wxcCodeGeneratorHelper::Get().AddBitmap(PropertyFile(PROP_BITMAP_PATH)); wxSize sz = GetImageSize(); - if(sz != wxSize(-1, -1)) { + if (sz != wxSize(-1, -1)) { imgListName << book->GetName() << wxT("_il"); imgIndex << GetName() << wxT("ImgIndex"); @@ -309,16 +337,16 @@ wxString NotebookPageWrapper::DoTreebookCppCtorCode() const bHasBitmap = true; } - if(parentPage) { + if (parentPage) { // This is a sub page int parentIndex = parentPage->GetPageIndex(); - if(parentIndex != wxNOT_FOUND) { + if (parentIndex != wxNOT_FOUND) { code << book->GetName() << wxT("->InsertSubPage(") << parentIndex << wxT(", ") << (isNullPage ? wxString("NULL") : GetName()) << wxT(", ") << Label() << wxT(", ") << PropertyBool(PROP_SELECTED) << wxT(", ") << (bHasBitmap && !imgIndex.IsEmpty() ? imgIndex : wxT("wxNOT_FOUND")) << wxT(");\n"); - if(PropertyBool(PROP_EXPANDED) == wxT("true")) { + if (PropertyBool(PROP_EXPANDED) == wxT("true")) { wxcNotebookCodeHelper::Get().Code() << book->GetName() << wxT("->ExpandNode( ") << GetPageIndex() << wxT(", true );\n"); } @@ -329,7 +357,7 @@ wxString NotebookPageWrapper::DoTreebookCppCtorCode() const << Label() << wxT(", ") << PropertyBool(PROP_SELECTED) << wxT(", ") << (bHasBitmap && !imgIndex.IsEmpty() ? imgIndex : wxT("wxNOT_FOUND")) << wxT(");\n"); - if(PropertyBool(PROP_EXPANDED) == wxT("true")) { + if (PropertyBool(PROP_EXPANDED) == wxT("true")) { wxcNotebookCodeHelper::Get().Code() << book->GetName() << wxT("->ExpandNode( ") << GetPageIndex() << wxT(", true );\n"); } diff --git a/wxcrafter/controls/Containers/notebook_wrapper.cpp b/wxcrafter/controls/Containers/notebook_wrapper.cpp index 36285518e7..e6d0f0aff9 100644 --- a/wxcrafter/controls/Containers/notebook_wrapper.cpp +++ b/wxcrafter/controls/Containers/notebook_wrapper.cpp @@ -1,6 +1,8 @@ #include "notebook_wrapper.h" + #include "allocator_mgr.h" #include "wxgui_defs.h" + #include NotebookWrapper::NotebookWrapper() @@ -11,9 +13,10 @@ NotebookWrapper::NotebookWrapper() PREPEND_STYLE_FALSE(wxNB_MULTILINE); PREPEND_STYLE_FALSE(wxNB_NOPAGETHEME); - RegisterEvent(wxT("wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED"), wxT("wxNotebookEvent"), - _("The page selection was changed")); - RegisterEvent(wxT("wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING"), wxT("wxNotebookEvent"), + RegisterEvent( + wxT("wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED"), wxT("wxNotebookEvent"), _("The page selection was changed")); + RegisterEvent(wxT("wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING"), + wxT("wxNotebookEvent"), _("The page selection is about to be changed. This event can be vetoed")); m_namePattern = wxT("m_notebook"); SetName(GenerateName()); diff --git a/wxcrafter/controls/Containers/scrolled_window_wrapper.cpp b/wxcrafter/controls/Containers/scrolled_window_wrapper.cpp index c34d70795e..20a64085b5 100644 --- a/wxcrafter/controls/Containers/scrolled_window_wrapper.cpp +++ b/wxcrafter/controls/Containers/scrolled_window_wrapper.cpp @@ -16,22 +16,30 @@ ScrolledWindowWrapper::ScrolledWindowWrapper() Add(PROP_SCROLL_RATE_X, wxT("5"), _("Pixels per scroll unit in the horizontal direction")); Add(PROP_SCROLL_RATE_Y, wxT("5"), _("Pixels per scroll unit in the vertical direction")); - RegisterEvent("wxEVT_SCROLLWIN_TOP", "wxScrollWinEvent", + RegisterEvent("wxEVT_SCROLLWIN_TOP", + "wxScrollWinEvent", _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_TOP scroll-to-top events")); - RegisterEvent("wxEVT_SCROLLWIN_BOTTOM", "wxScrollWinEvent", + RegisterEvent("wxEVT_SCROLLWIN_BOTTOM", + "wxScrollWinEvent", _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_BOTTOM scroll-to-bottom events")); - RegisterEvent("wxEVT_SCROLLWIN_LINEUP", "wxScrollWinEvent", + RegisterEvent("wxEVT_SCROLLWIN_LINEUP", + "wxScrollWinEvent", _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_LINEUP line up events.")); - RegisterEvent("wxEVT_SCROLLWIN_LINEDOWN", "wxScrollWinEvent", + RegisterEvent("wxEVT_SCROLLWIN_LINEDOWN", + "wxScrollWinEvent", _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_LINEDOWN line down events")); - RegisterEvent("wxEVT_SCROLLWIN_PAGEUP", "wxScrollWinEvent", + RegisterEvent("wxEVT_SCROLLWIN_PAGEUP", + "wxScrollWinEvent", _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_PAGEUP page up events")); - RegisterEvent("wxEVT_SCROLLWIN_PAGEDOWN", "wxScrollWinEvent", + RegisterEvent("wxEVT_SCROLLWIN_PAGEDOWN", + "wxScrollWinEvent", _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_PAGEDOWN page down events")); - RegisterEvent("wxEVT_SCROLLWIN_THUMBTRACK", "wxScrollWinEvent", + RegisterEvent("wxEVT_SCROLLWIN_THUMBTRACK", + "wxScrollWinEvent", _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_THUMBTRACK thumbtrack events (frequent events sent " "as the user drags the thumbtrack)")); - RegisterEvent("wxEVT_SCROLLWIN_THUMBRELEASE", "wxScrollWinEvent", + RegisterEvent("wxEVT_SCROLLWIN_THUMBRELEASE", + "wxScrollWinEvent", _("Since wxWidgets 2.9.X\nProcess wxEVT_SCROLLWIN_THUMBRELEASE thumb release events")); m_namePattern = wxT("m_scrollWin"); SetName(GenerateName()); @@ -75,10 +83,14 @@ void ScrolledWindowWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) // Neither XRCed nor wxFB nor wxSmith actually produce any property here, but the doc says: wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("scrollrate")); - if(propertynode) { + if (propertynode) { wxSize size = wxCrafter::DecodeSize(propertynode->GetNodeContent()); - if(size.x != -1) { SetPropertyString(PROP_SCROLL_RATE_X, wxCrafter::ToString(size.x)); } - if(size.y != -1) { SetPropertyString(PROP_SCROLL_RATE_Y, wxCrafter::ToString(size.y)); } + if (size.x != -1) { + SetPropertyString(PROP_SCROLL_RATE_X, wxCrafter::ToString(size.x)); + } + if (size.y != -1) { + SetPropertyString(PROP_SCROLL_RATE_Y, wxCrafter::ToString(size.y)); + } } } @@ -88,8 +100,12 @@ void ScrolledWindowWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "scroll_rate_x"); - if(propertynode) { SetPropertyString(PROP_SCROLL_RATE_X, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SCROLL_RATE_X, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "scroll_rate_y"); - if(propertynode) { SetPropertyString(PROP_SCROLL_RATE_Y, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SCROLL_RATE_Y, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/Containers/tool_book_wrapper.cpp b/wxcrafter/controls/Containers/tool_book_wrapper.cpp index ca07fc9102..17d2427a56 100644 --- a/wxcrafter/controls/Containers/tool_book_wrapper.cpp +++ b/wxcrafter/controls/Containers/tool_book_wrapper.cpp @@ -1,6 +1,8 @@ #include "tool_book_wrapper.h" + #include "allocator_mgr.h" #include "wxgui_defs.h" + #include #include @@ -13,9 +15,10 @@ ToolBookWrapper::ToolBookWrapper() PREPEND_STYLE_FALSE(wxTBK_HORZ_LAYOUT); #endif - RegisterEvent(wxT("wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED"), wxT("wxToolbookEvent"), - _("The page selection was changed")); - RegisterEvent(wxT("wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING"), wxT("wxToolbookEvent"), + RegisterEvent( + wxT("wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED"), wxT("wxToolbookEvent"), _("The page selection was changed")); + RegisterEvent(wxT("wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING"), + wxT("wxToolbookEvent"), _("The page selection is about to be changed. This event can be vetoed")); m_namePattern = wxT("m_toolbook"); SetName(GenerateName()); diff --git a/wxcrafter/controls/Containers/tree_book_wrapper.cpp b/wxcrafter/controls/Containers/tree_book_wrapper.cpp index 79e01ed77b..d62ff722ab 100644 --- a/wxcrafter/controls/Containers/tree_book_wrapper.cpp +++ b/wxcrafter/controls/Containers/tree_book_wrapper.cpp @@ -1,19 +1,24 @@ #include "tree_book_wrapper.h" + #include "allocator_mgr.h" #include "wxgui_defs.h" + #include TreeBookWrapper::TreeBookWrapper() : NotebookBaseWrapper(ID_WXTREEBOOK) { SetPropertyString(_("Common Settings"), "wxTreebook"); - RegisterEvent(wxT("wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED"), wxT("wxTreebookEvent"), - _("The page selection was changed")); - RegisterEvent(wxT("wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING"), wxT("wxTreebookEvent"), + RegisterEvent( + wxT("wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED"), wxT("wxTreebookEvent"), _("The page selection was changed")); + RegisterEvent(wxT("wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING"), + wxT("wxTreebookEvent"), _("The page selection is about to be changed. This event can be vetoed")); - RegisterEvent(wxT("wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED"), wxT("wxTreebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED"), + wxT("wxTreebookEvent"), _("The page node is going to be collapsed")); - RegisterEvent(wxT("wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED"), wxT("wxTreebookEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED"), + wxT("wxTreebookEvent"), _("The page node is going to be expanded")); m_namePattern = wxT("m_treebook"); diff --git a/wxcrafter/controls/Containers/wizard_page_wrapper.cpp b/wxcrafter/controls/Containers/wizard_page_wrapper.cpp index dd0b58e4f1..97683eda8f 100644 --- a/wxcrafter/controls/Containers/wizard_page_wrapper.cpp +++ b/wxcrafter/controls/Containers/wizard_page_wrapper.cpp @@ -34,14 +34,16 @@ wxString WizardPageWrapper::CppCtorCode() const code << wxT("m_pages.push_back(") << GetName() << wxT(");\n"); WizardWrapper* wizard = dynamic_cast(GetParent()); - if(!wizard) { return code; } + if (!wizard) { + return code; + } // If this is the last page, perform the 'Chain' call // We use |@@| as a special delimiter here (to avoid indenting this code) // it will be replaced later by the TopLevelWindowWrapper to an empty string const wxcWidget::List_t& siblings = wizard->GetChildren(); const wxcWidget* lastChild = siblings.back(); - if(lastChild == this) { + if (lastChild == this) { code << wxT("|@@|if (m_pages.size() > 1) {\n") << wxT("|@@| for(size_t i=1; iGetChildren().front() == this); - if(type == XRC_DESIGNER) { + if (type == XRC_DESIGNER) { // HACK: Only display the active page - if(GUICraftMainPanel::m_MainPanel->GetActiveWizardPage() != this) return; + if (GUICraftMainPanel::m_MainPanel->GetActiveWizardPage() != this) + return; text << XRCCommonAttributes() << XRCSize() << XRCStyle() << XRCBitmap(); @@ -73,8 +76,8 @@ void WizardPageWrapper::ToXRC(wxString& text, XRC_TYPE type) const text << wxT(""); text << wxT(""); - } else if(type == XRC_PREVIEW) { - if(isFirstPage) { + } else if (type == XRC_PREVIEW) { + if (isFirstPage) { text << wxT(""); } else { text << XRCPrefix(); @@ -83,7 +86,7 @@ void WizardPageWrapper::ToXRC(wxString& text, XRC_TYPE type) const text << XRCCommonAttributes() << XRCSize() << XRCStyle() << XRCBitmap(); ChildrenXRC(text, type); text << XRCSuffix(); - } else if(type == XRC_LIVE) { + } else if (type == XRC_LIVE) { text << ""; text << XRCCommonAttributes() << XRCSize() << XRCStyle() << XRCBitmap(); ChildrenXRC(text, type); @@ -97,7 +100,9 @@ void WizardPageWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_OTHER"); } + if (propertynode) { + ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_OTHER"); + } } void WizardPageWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -106,7 +111,7 @@ void WizardPageWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "bitmap"); - if(propertynode) { + if (propertynode) { ImportFromwxFB::ProcessBitmapProperty(propertynode->GetNodeContent(), this, PROP_BITMAP_PATH, "wxART_OTHER"); } } diff --git a/wxcrafter/controls/Containers/wx_collapsible_pane_pane_wrapper.cpp b/wxcrafter/controls/Containers/wx_collapsible_pane_pane_wrapper.cpp index b4464bdb86..874f90b441 100644 --- a/wxcrafter/controls/Containers/wx_collapsible_pane_pane_wrapper.cpp +++ b/wxcrafter/controls/Containers/wx_collapsible_pane_pane_wrapper.cpp @@ -28,7 +28,7 @@ void wxCollapsiblePanePaneWrapper::ToXRC(wxString& text, XRC_TYPE type) const { wxString xrc; xrc << ""; diff --git a/wxcrafter/controls/Grid/grid_column_wrapper.cpp b/wxcrafter/controls/Grid/grid_column_wrapper.cpp index 8c8d2b3b6c..305b993f32 100644 --- a/wxcrafter/controls/Grid/grid_column_wrapper.cpp +++ b/wxcrafter/controls/Grid/grid_column_wrapper.cpp @@ -53,7 +53,7 @@ wxString GridColumnWrapper::Code(int colIndex) const cppCode << GetParent()->GetName() << wxT("->SetColLabelValue(") << colIndex << wxT(", ") << wxCrafter::UNDERSCORE(GetName()) << wxT(");\n"); int width = PropertyInt(PROP_WIDTH, -1); - if(width != -1) { + if (width != -1) { cppCode << GetParent()->GetName() << wxT("->SetColSize(") << colIndex << ", " << width << ");\n"; } return cppCode; diff --git a/wxcrafter/controls/Grid/grid_column_wrapper.h b/wxcrafter/controls/Grid/grid_column_wrapper.h index 3ed16e31de..fd6186515d 100644 --- a/wxcrafter/controls/Grid/grid_column_wrapper.h +++ b/wxcrafter/controls/Grid/grid_column_wrapper.h @@ -2,6 +2,7 @@ #define GRIDCOLUMNWRAPPER_H #include "wxc_widget.h" // Base class: wxcWidget + #include class GridColumnWrapper : public wxcWidget diff --git a/wxcrafter/controls/Grid/grid_row_wrapper.cpp b/wxcrafter/controls/Grid/grid_row_wrapper.cpp index 088cad1390..33733c8fd5 100644 --- a/wxcrafter/controls/Grid/grid_row_wrapper.cpp +++ b/wxcrafter/controls/Grid/grid_row_wrapper.cpp @@ -45,7 +45,7 @@ wxString GridRowWrapper::Code(int rowIndex) const cppCode << GetParent()->GetName() << wxT("->SetRowLabelValue(") << rowIndex << wxT(", ") << wxCrafter::UNDERSCORE(GetName()) << wxT(");\n"); int height = PropertyInt(PROP_HEIGHT, -1); - if(height != -1) { + if (height != -1) { cppCode << GetParent()->GetName() << wxT("->SetRowSize(") << rowIndex << ", " << height << ");\n"; } return cppCode; diff --git a/wxcrafter/controls/Grid/grid_row_wrapper.h b/wxcrafter/controls/Grid/grid_row_wrapper.h index e380bd82a3..9787f640df 100644 --- a/wxcrafter/controls/Grid/grid_row_wrapper.h +++ b/wxcrafter/controls/Grid/grid_row_wrapper.h @@ -2,6 +2,7 @@ #define GRIDROWWRAPPER_H #include "wxc_widget.h" + #include class GridRowWrapper : public wxcWidget diff --git a/wxcrafter/controls/Grid/grid_wrapper.cpp b/wxcrafter/controls/Grid/grid_wrapper.cpp index 2bd16d3b5b..a5c87ade8d 100644 --- a/wxcrafter/controls/Grid/grid_wrapper.cpp +++ b/wxcrafter/controls/Grid/grid_wrapper.cpp @@ -16,14 +16,15 @@ GridWrapper::GridWrapper() { EnableStyle(wxT("wxWANTS_CHARS"), true); - const wxArrayString vOpts = StdToWX::ToArrayString({ "wxALIGN_TOP", "wxALIGN_CENTRE", "wxALIGN_BOTTOM" }); - const wxArrayString hOpts = StdToWX::ToArrayString({ "wxALIGN_LEFT", "wxALIGN_CENTRE", "wxALIGN_RIGHT" }); + const wxArrayString vOpts = StdToWX::ToArrayString({"wxALIGN_TOP", "wxALIGN_CENTRE", "wxALIGN_BOTTOM"}); + const wxArrayString hOpts = StdToWX::ToArrayString({"wxALIGN_LEFT", "wxALIGN_CENTRE", "wxALIGN_RIGHT"}); SetPropertyString(_("Common Settings"), "wxGrid"); Add(_("wxGrid Header")); Add(PROP_AUTOSIZE_COL, true, _("Auto size column content to fit the column header")); Add(PROP_GRID_NATIVE_LOOK, true, _("Enable the use of native header window for column labels")); - // Add(PROP_GRID_NATIVE_COL_LABELS, true, _("Call this in order to make the column labels use a native look")); + // Add(PROP_GRID_NATIVE_COL_LABELS, true, _("Call this in order to make the column labels use a native + // look")); Add(_("wxGrid Columns Labels")); Add(PROP_HEIGHT, -1, _("Sets the height of the column label")); @@ -38,64 +39,83 @@ GridWrapper::GridWrapper() Add(_("wxGrid Cells")); Add(PROP_ALLOW_EDITING, true, _("Allow editing grid content")); - RegisterEvent(wxT("wxEVT_GRID_CELL_CHANGING"), wxT("wxGridEvent"), + RegisterEvent(wxT("wxEVT_GRID_CELL_CHANGING"), + wxT("wxGridEvent"), _("The user is about to change the data in a cell. The new cell value as string is available from " "GetString() event object method. This event can be vetoed if the change is not allowed. " "Processes a wxEVT_GRID_CELL_CHANGING event type")); - RegisterEvent(wxT("wxEVT_GRID_CELL_CHANGED"), wxT("wxGridEvent"), + RegisterEvent(wxT("wxEVT_GRID_CELL_CHANGED"), + wxT("wxGridEvent"), _("The user changed the data in a cell. The old cell value as string is available from GetString() " "event object method. Notice that vetoing this event still works for backwards compatibility " "reasons but any new code should only veto EVT_GRID_CELL_CHANGING event and not this one. " "Processes a wxEVT_GRID_CELL_CHANGED event type.")); - RegisterEvent(wxT("wxEVT_GRID_CELL_LEFT_CLICK"), wxT("wxGridEvent"), + RegisterEvent(wxT("wxEVT_GRID_CELL_LEFT_CLICK"), + wxT("wxGridEvent"), _("The user clicked a cell with the left mouse button. Processes a wxEVT_GRID_CELL_LEFT_CLICK.")); RegisterEvent( - wxT("wxEVT_GRID_CELL_LEFT_DCLICK"), wxT("wxGridEvent"), + wxT("wxEVT_GRID_CELL_LEFT_DCLICK"), + wxT("wxGridEvent"), _("The user double-clicked a cell with the left mouse button. Processes a wxEVT_GRID_CELL_LEFT_DCLICK")); - RegisterEvent(wxT("wxEVT_GRID_CELL_RIGHT_CLICK"), wxT("wxGridEvent"), + RegisterEvent(wxT("wxEVT_GRID_CELL_RIGHT_CLICK"), + wxT("wxGridEvent"), _("The user clicked a cell with the right mouse button. Processes a wxEVT_GRID_CELL_RIGHT_CLICK.")); RegisterEvent( - wxT("wxEVT_GRID_CELL_RIGHT_DCLICK"), wxT("wxGridEvent"), + wxT("wxEVT_GRID_CELL_RIGHT_DCLICK"), + wxT("wxGridEvent"), _("The user double-clicked a cell with the right mouse button. Processes a wxEVT_GRID_CELL_RIGHT_DCLICK.")); - RegisterEvent(wxT("wxEVT_GRID_EDITOR_HIDDEN"), wxT("wxGridEvent"), + RegisterEvent(wxT("wxEVT_GRID_EDITOR_HIDDEN"), + wxT("wxGridEvent"), _("The editor for a cell was hidden. Processes a wxEVT_GRID_EDITOR_HIDDEN event type.")); - RegisterEvent(wxT("wxEVT_GRID_EDITOR_SHOWN"), wxT("wxGridEvent"), + RegisterEvent(wxT("wxEVT_GRID_EDITOR_SHOWN"), + wxT("wxGridEvent"), _("The editor for a cell was shown. Processes a wxEVT_GRID_EDITOR_SHOWN event type")); - RegisterEvent(wxT("wxEVT_GRID_LABEL_LEFT_CLICK"), wxT("wxGridEvent"), + RegisterEvent(wxT("wxEVT_GRID_LABEL_LEFT_CLICK"), + wxT("wxGridEvent"), _("The user clicked a label with the left mouse button. Processes a wxEVT_GRID_LABEL_LEFT_CLICK.")); RegisterEvent( - wxT("wxEVT_GRID_LABEL_LEFT_DCLICK"), wxT("wxGridEvent"), + wxT("wxEVT_GRID_LABEL_LEFT_DCLICK"), + wxT("wxGridEvent"), _("The user double-clicked a label with the left mouse button. Processes a wxEVT_GRID_LABEL_LEFT_DCLICK.")); + RegisterEvent(wxT("wxEVT_GRID_LABEL_RIGHT_CLICK"), + wxT("wxGridEvent"), + _("The user clicked a label with the right mouse button. Processes a wxEVT_GRID_LABEL_RIGHT_CLICK.")); RegisterEvent( - wxT("wxEVT_GRID_LABEL_RIGHT_CLICK"), wxT("wxGridEvent"), - _("The user clicked a label with the right mouse button. Processes a wxEVT_GRID_LABEL_RIGHT_CLICK.")); - RegisterEvent( - wxT("wxEVT_GRID_LABEL_RIGHT_DCLICK"), wxT("wxGridEvent"), + wxT("wxEVT_GRID_LABEL_RIGHT_DCLICK"), + wxT("wxGridEvent"), _("The user double-clicked a label with the right mouse button. Processes a wxEVT_GRID_LABEL_RIGHT_DCLICK.")); - RegisterEvent(wxT("wxEVT_GRID_SELECT_CELL"), wxT("wxGridEvent"), + RegisterEvent(wxT("wxEVT_GRID_SELECT_CELL"), + wxT("wxGridEvent"), _("The user moved to, and selected a cell. Processes a wxEVT_GRID_SELECT_CELL.")); RegisterEvent( - wxT("wxEVT_GRID_COL_MOVE"), wxT("wxGridEvent"), + wxT("wxEVT_GRID_COL_MOVE"), + wxT("wxGridEvent"), _("The user tries to change the order of the columns in the grid by dragging the column specified by GetCol(). " - "This event can be vetoed to either prevent the user from reordering the column change completely (but notice " - "that if you don't want to allow it at all, you simply shouldn't call wxGrid::EnableDragColMove() in the first " + "This event can be vetoed to either prevent the user from reordering the column change completely (but " + "notice " + "that if you don't want to allow it at all, you simply shouldn't call wxGrid::EnableDragColMove() in the " + "first " "place), " "vetoed but handled in some way in the handler, e.g. by really moving the column to the new position at the " "associated table level, " - "or allowed to proceed in which case wxGrid::SetColPos() is used to reorder the columns display order without " + "or allowed to proceed in which case wxGrid::SetColPos() is used to reorder the columns display order " + "without " "affecting the use of " "the column indices otherwise. This event macro corresponds to wxEVT_GRID_COL_MOVE event type.")); - RegisterEvent(wxT("wxEVT_GRID_COL_SORT"), wxT("wxGridEvent"), - _("This event is generated when a column is clicked by the user and its name is explained by the fact " - "that the custom reaction to a " - "click on a column is to sort the grid contents by this column. However the grid itself has no " - "special support for sorting and it's " - "up to the handler of this event to update the associated table. But if the event is handled (and " - "not vetoed) the grid supposes that " - "the table was indeed resorted and updates the column to indicate the new sort order and refreshes " - "itself. This event macro corresponds " - "to wxEVT_GRID_COL_SORT event type.")); - RegisterEvent(wxT("wxEVT_GRID_TABBING"), wxT("wxGridEvent"), + RegisterEvent( + wxT("wxEVT_GRID_COL_SORT"), + wxT("wxGridEvent"), + _("This event is generated when a column is clicked by the user and its name is explained by the fact " + "that the custom reaction to a " + "click on a column is to sort the grid contents by this column. However the grid itself has no " + "special support for sorting and it's " + "up to the handler of this event to update the associated table. But if the event is handled (and " + "not vetoed) the grid supposes that " + "the table was indeed resorted and updates the column to indicate the new sort order and refreshes " + "itself. This event macro corresponds " + "to wxEVT_GRID_COL_SORT event type.")); + RegisterEvent(wxT("wxEVT_GRID_TABBING"), + wxT("wxGridEvent"), _("This event is generated when the user presses TAB or Shift-TAB in the grid. It can be used to " "customize the simple default TAB handling " "logic, e.g. to go to the next non-empty cell instead of just the next cell. See also " @@ -118,11 +138,11 @@ wxString GridWrapper::CppCtorCode() const GetRowsCols(rows, cols); - for(size_t i = 0; i < rows.size(); ++i) { + for (size_t i = 0; i < rows.size(); ++i) { cppRowColCode << rows.at(i)->Code(i); } - for(size_t i = 0; i < cols.size(); ++i) { + for (size_t i = 0; i < cols.size(); ++i) { cppRowColCode << cols.at(i)->Code(i); } @@ -140,10 +160,14 @@ wxString GridWrapper::CppCtorCode() const cppCode << GetName() << wxT("->EnableEditing(") << PropertyBool(PROP_ALLOW_EDITING) << ");\n"; int colHeight = PropertyInt(PROP_HEIGHT, -1); - if(colHeight != -1) { cppCode << GetName() << "->SetColLabelSize(" << colHeight << ");\n"; } + if (colHeight != -1) { + cppCode << GetName() << "->SetColLabelSize(" << colHeight << ");\n"; + } int rowLabelWidth = PropertyInt(PROP_WIDTH, -1); - if(rowLabelWidth != -1) { cppCode << GetName() << "->SetRowLabelSize(" << rowLabelWidth << ");\n"; } + if (rowLabelWidth != -1) { + cppCode << GetName() << "->SetRowLabelSize(" << rowLabelWidth << ");\n"; + } return cppCode; } @@ -153,7 +177,7 @@ wxString GridWrapper::GetWxClassName() const { return wxT("wxGrid"); } void GridWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { // Native wx do not support what we do... text << XRCPrefix() << XRCSize() << XRCStyle() << XRCCommonAttributes() << XRCSuffix(); @@ -169,7 +193,9 @@ void GridWrapper::ToXRC(wxString& text, XRC_TYPE type) const wxString style = StyleFlags(); wxArrayString styleArr = wxCrafter::Split(style, "|"); - if(styleArr.Index("wxBORDER_THEME") != wxNOT_FOUND) { styleArr.Remove("wxBORDER_THEME"); } + if (styleArr.Index("wxBORDER_THEME") != wxNOT_FOUND) { + styleArr.Remove("wxBORDER_THEME"); + } style = wxCrafter::Join(styleArr, "|"); style.Prepend(""); #else @@ -226,14 +252,14 @@ void GridWrapper::UnSerialize(const JSONItem& json) JSONItem styles = json.namedObject(wxT("m_styles")); int nCount = styles.arraySize(); - for(int i = 0; i < nCount; i++) { + for (int i = 0; i < nCount; i++) { wxString styleName = styles.arrayItem(i).toString(); EnableStyle(styleName, true); } JSONItem sizerFlags = json.namedObject(wxT("m_sizerFlags")); nCount = sizerFlags.arraySize(); - for(int i = 0; i < nCount; i++) { + for (int i = 0; i < nCount; i++) { wxString styleName = sizerFlags.arrayItem(i).toString(); EnableSizerFlag(styleName, true); } @@ -242,33 +268,33 @@ void GridWrapper::UnSerialize(const JSONItem& json) JSONItem properties = json.namedObject(wxT("m_properties")); nCount = properties.arraySize(); - for(int i = 0; i < nCount; i++) { + for (int i = 0; i < nCount; i++) { JSONItem jsonProp = properties.arrayItem(i); wxString propLabel = jsonProp.namedObject(wxT("m_label")).toString(); - if(propLabel == PROP_COLS_LIST) { + if (propLabel == PROP_COLS_LIST) { wxString cols_string = jsonProp.namedObject(wxT("m_value")).toString(); wxArrayString colsArr = wxCrafter::Split(cols_string, ";"); - for(size_t i = 0; i < colsArr.GetCount(); ++i) { + for (size_t i = 0; i < colsArr.GetCount(); ++i) { // The old way of creating rows - create new children and add them here wxcWidget* col = Allocator::Instance()->Create(ID_WXGRIDCOL); col->SetName(colsArr.Item(i)); AddChild(col); } - } else if(propLabel == PROP_ROWS_LIST) { + } else if (propLabel == PROP_ROWS_LIST) { wxString rows_string = jsonProp.namedObject(wxT("m_value")).toString(); wxArrayString rowsArr = wxCrafter::Split(rows_string, ";"); - for(size_t i = 0; i < rowsArr.GetCount(); ++i) { + for (size_t i = 0; i < rowsArr.GetCount(); ++i) { // The old way of creating rows - create new children and add them here wxcWidget* row = Allocator::Instance()->Create(ID_WXGRIDROW); row->SetName(rowsArr.Item(i)); AddChild(row); } - } else if(m_properties.Contains(propLabel)) { + } else if (m_properties.Contains(propLabel)) { m_properties.Item(propLabel)->UnSerialize(jsonProp); } } @@ -276,7 +302,7 @@ void GridWrapper::UnSerialize(const JSONItem& json) // Unserialize the events JSONItem events = json.namedObject(wxT("m_events")); nCount = events.arraySize(); - for(int i = 0; i < nCount; i++) { + for (int i = 0; i < nCount; i++) { JSONItem jsonEvent = events.arrayItem(i); ConnectDetails details; details.FromJSON(jsonEvent); @@ -285,10 +311,12 @@ void GridWrapper::UnSerialize(const JSONItem& json) JSONItem children = json.namedObject(wxT("m_children")); int nChildren = children.arraySize(); - for(int i = 0; i < nChildren; i++) { + for (int i = 0; i < nChildren; i++) { JSONItem child = children.arrayItem(i); wxcWidget* wrapper = Allocator::Instance()->CreateWrapperFromJSON(child); - if(wrapper) { AddChild(wrapper); } + if (wrapper) { + AddChild(wrapper); + } } } diff --git a/wxcrafter/controls/PropertyGrid/property_grid_manager_wrapper.cpp b/wxcrafter/controls/PropertyGrid/property_grid_manager_wrapper.cpp index 373076a8af..d775810f55 100644 --- a/wxcrafter/controls/PropertyGrid/property_grid_manager_wrapper.cpp +++ b/wxcrafter/controls/PropertyGrid/property_grid_manager_wrapper.cpp @@ -23,44 +23,58 @@ PropertyGridManagerWrapper::PropertyGridManagerWrapper() PREPEND_STYLE_FALSE(wxPG_NO_INTERNAL_BORDER); RegisterEvent( - "wxEVT_PG_SELECTED", "wxPropertyGridEvent", + "wxEVT_PG_SELECTED", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_SELECTED event, generated when a property selection has been changed, either by user " "action or by indirect program function.\nFor instance, collapsing a parent property programmatically causes " "any selected child property to become unselected, and may therefore cause this event to be generated.")); - RegisterEvent("wxEVT_PG_CHANGED", "wxPropertyGridEvent", + RegisterEvent("wxEVT_PG_CHANGED", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_CHANGED event, generated when property value has been changed by the user")); - RegisterEvent("wxEVT_PG_CHANGING", "wxPropertyGridEvent", + RegisterEvent("wxEVT_PG_CHANGING", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_CHANGING event, generated when property value is about to be changed by user. " "Use wxPropertyGridEvent::GetValue() to take a peek at the pending value, and " "wxPropertyGridEvent::Veto() to prevent change from taking place, if necessary")); - RegisterEvent("wxEVT_PG_HIGHLIGHTED", "wxPropertyGridEvent", + RegisterEvent("wxEVT_PG_HIGHLIGHTED", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse moves over a property. Event's " "property is NULL if hovered area does not belong to any property.")); RegisterEvent( - "wxEVT_PG_RIGHT_CLICK", "wxPropertyGridEvent", + "wxEVT_PG_RIGHT_CLICK", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is clicked on with right mouse button.")); - RegisterEvent("wxEVT_PG_DOUBLE_CLICK", "wxPropertyGridEvent", + RegisterEvent("wxEVT_PG_DOUBLE_CLICK", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when " "property is double-clicked on with left mouse button.")); - RegisterEvent("wxEVT_PG_ITEM_COLLAPSED", "wxPropertyGridEvent", + RegisterEvent("wxEVT_PG_ITEM_COLLAPSED", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses a property or category.")); - RegisterEvent("wxEVT_PG_ITEM_EXPANDED", "wxPropertyGridEvent", + RegisterEvent("wxEVT_PG_ITEM_EXPANDED", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands a property or category.")); - RegisterEvent("wxEVT_PG_LABEL_EDIT_BEGIN", "wxPropertyGridEvent", + RegisterEvent("wxEVT_PG_LABEL_EDIT_BEGIN", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when user is about to begin editing a " "property label. You can veto this event to prevent the action.")); - RegisterEvent("wxEVT_PG_LABEL_EDIT_ENDING", "wxPropertyGridEvent", + RegisterEvent("wxEVT_PG_LABEL_EDIT_ENDING", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when user is about to end editing of a " "property label. You can veto this event to prevent the action.")); RegisterEvent( - "wxEVT_PG_COL_BEGIN_DRAG", "wxPropertyGridEvent", + "wxEVT_PG_COL_BEGIN_DRAG", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_COL_BEGIN_DRAG event, generated when user starts resizing a column - can be vetoed.")); - RegisterEvent("wxEVT_PG_COL_DRAGGING", "wxPropertyGridEvent", + RegisterEvent("wxEVT_PG_COL_DRAGGING", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_COL_DRAGGING, event, generated when a column resize by user is in progress. " "This event is also generated when user double-clicks the splitter in order to recenter it.")); - RegisterEvent("wxEVT_PG_COL_END_DRAG", "wxPropertyGridEvent", + RegisterEvent("wxEVT_PG_COL_END_DRAG", + "wxPropertyGridEvent", _("Respond to wxEVT_PG_COL_END_DRAG event, generated after column resize by user has finished.")); - RegisterEvent("wxEVT_COMMAND_BUTTON_CLICKED", "wxCommandEvent", + RegisterEvent("wxEVT_COMMAND_BUTTON_CLICKED", + "wxCommandEvent", _("Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the custom editor button is clicked.")); Add(PROP_SASH_POS, -1, _("Sets x coordinate of the splitter")); @@ -99,7 +113,7 @@ wxString PropertyGridManagerWrapper::GetWxClassName() const { return "wxProperty void PropertyGridManagerWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << XRCUnknown(); } else { @@ -115,12 +129,12 @@ wxString PropertyGridManagerWrapper::DoGenerateCppCtorCode_End() const { wxString cppCode; - if(IsPropertyChecked(PROP_SPLITTER_LEFT)) { + if (IsPropertyChecked(PROP_SPLITTER_LEFT)) { cppCode << GetName() << "->GetGrid()->SetSplitterLeft(true);\n"; } int splitterPos = PropertyInt(PROP_SASH_POS); - if(splitterPos != wxNOT_FOUND) { + if (splitterPos != wxNOT_FOUND) { cppCode << GetName() << "->GetGrid()->SetSplitterPosition(" << splitterPos << ", 0);\n"; } return cppCode; diff --git a/wxcrafter/controls/PropertyGrid/property_grid_wrapper.cpp b/wxcrafter/controls/PropertyGrid/property_grid_wrapper.cpp index 09acfca1be..cebc58165e 100644 --- a/wxcrafter/controls/PropertyGrid/property_grid_wrapper.cpp +++ b/wxcrafter/controls/PropertyGrid/property_grid_wrapper.cpp @@ -100,7 +100,7 @@ wxString PropertyGridWrapper::CppCtorCode() const { wxString grid = GetWindowParent(); wxString appendFunc = "Append( "; - if(GetParent()->GetType() == ID_WXPGPROPERTY) { + if (GetParent()->GetType() == ID_WXPGPROPERTY) { appendFunc = "AppendIn( " + GetParent()->GetName() + ", "; } @@ -112,20 +112,20 @@ wxString PropertyGridWrapper::CppCtorCode() const wxString arrIntName = grid + "IntArr"; wxString propName = GetName(); - if(proptype == "wxBoolProperty") { + if (proptype == "wxBoolProperty") { strvalue = PropertyString(PROP_PG_BOOL_VALUE); - } else if(proptype == "wxIntProperty" || proptype == "wxFloatProperty") { + } else if (proptype == "wxIntProperty" || proptype == "wxFloatProperty") { strvalue = PropertyString(PROP_PG_STRING_VALUE); strvalue.Trim().Trim(false); - if(strvalue.IsEmpty()) { + if (strvalue.IsEmpty()) { strvalue = "0"; } - } else if(proptype == "wxFlagsProperty") { + } else if (proptype == "wxFlagsProperty") { strvalue = PropertyString(PROP_PG_STRING_VALUE); strvalue.Trim().Trim(false); - if(strvalue.IsEmpty()) { + if (strvalue.IsEmpty()) { strvalue = "0"; } @@ -133,14 +133,14 @@ wxString PropertyGridWrapper::CppCtorCode() const strvalue = wxCrafter::UNDERSCORE(PropertyString(PROP_PG_STRING_VALUE)); } - if(proptype == "wxIntProperty" || proptype == "wxFloatProperty" || proptype == "wxBoolProperty" || - proptype == "wxStringProperty" || proptype == "wxLongStringProperty" || proptype == "wxDirProperty" || - proptype == "wxFileProperty") { + if (proptype == "wxIntProperty" || proptype == "wxFloatProperty" || proptype == "wxBoolProperty" || + proptype == "wxStringProperty" || proptype == "wxLongStringProperty" || proptype == "wxDirProperty" || + proptype == "wxFileProperty") { cppCode << propName << " = " << grid << "->" << appendFunc << " new " << proptype << "( " << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << ", wxPG_LABEL, " << strvalue << ") );\n"; - if(proptype == "wxFileProperty") { + if (proptype == "wxFileProperty") { cppCode << "#if !defined(__WXOSX__) && !defined(_WIN64)\n"; cppCode << propName << "->SetAttribute(wxPG_FILE_WILDCARD, " << wxCrafter::WXT(PropertyString(PROP_PG_WILDCARD)) << ");\n"; @@ -148,33 +148,33 @@ wxString PropertyGridWrapper::CppCtorCode() const cppCode << propName << "->SetAttribute(\"ShowFullPath\", 1);\n"; } - } else if(proptype == "wxPropertyCategory") { + } else if (proptype == "wxPropertyCategory") { cppCode << propName << " = " << grid << "->" << appendFunc << " new wxPropertyCategory( " << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << " ) );\n"; - } else if(proptype == "wxArrayStringProperty") { + } else if (proptype == "wxArrayStringProperty") { wxArrayString options = wxCrafter::Split(PropertyString(PROP_PG_CHOICES), ";"); cppCode << arrName << ".Clear();\n"; - for(size_t i = 0; i < options.GetCount(); ++i) { + for (size_t i = 0; i < options.GetCount(); ++i) { cppCode << arrName << ".Add(" << wxCrafter::UNDERSCORE(options.Item(i)) << ");\n"; } cppCode << propName << " = " << grid << "->" << appendFunc << " new " << proptype << "( " << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << ", wxPG_LABEL, " << arrName << ") );\n"; - } else if(proptype == "wxEnumProperty") { + } else if (proptype == "wxEnumProperty") { wxArrayString options = wxCrafter::Split(PropertyString(PROP_PG_CHOICES), ";"); cppCode << arrName << ".Clear();\n"; cppCode << arrIntName << ".Clear();\n"; size_t selection = 0; - for(size_t i = 0; i < options.GetCount(); ++i) { + for (size_t i = 0; i < options.GetCount(); ++i) { cppCode << arrName << ".Add(" << wxCrafter::UNDERSCORE(options.Item(i)) << ");\n"; - if(wxCrafter::UNDERSCORE(options.Item(i)) == strvalue) { + if (wxCrafter::UNDERSCORE(options.Item(i)) == strvalue) { selection = i; } } options = wxCrafter::Split(PropertyString(PROP_PG_CHOICES_VALUES), ";"); - for(size_t i = 0; i < options.GetCount(); ++i) { + for (size_t i = 0; i < options.GetCount(); ++i) { cppCode << arrIntName << ".Add(" << options.Item(i) << ");\n"; } @@ -182,16 +182,16 @@ wxString PropertyGridWrapper::CppCtorCode() const << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << ", wxPG_LABEL, " << arrName << ", " << arrIntName << ", " << selection << ") );\n"; - } else if(proptype == "wxEditEnumProperty") { + } else if (proptype == "wxEditEnumProperty") { wxArrayString options = wxCrafter::Split(PropertyString(PROP_PG_CHOICES), ";"); cppCode << arrName << ".Clear();\n"; cppCode << arrIntName << ".Clear();\n"; - for(size_t i = 0; i < options.GetCount(); ++i) { + for (size_t i = 0; i < options.GetCount(); ++i) { cppCode << arrName << ".Add(" << wxCrafter::UNDERSCORE(options.Item(i)) << ");\n"; } options = wxCrafter::Split(PropertyString(PROP_PG_CHOICES_VALUES), ";"); - for(size_t i = 0; i < options.GetCount(); ++i) { + for (size_t i = 0; i < options.GetCount(); ++i) { cppCode << arrIntName << ".Add(" << options.Item(i) << ");\n"; } @@ -199,16 +199,16 @@ wxString PropertyGridWrapper::CppCtorCode() const << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << ", wxPG_LABEL, " << arrName << ", " << arrIntName << ", " << strvalue << ") );\n"; - } else if(proptype == "wxFlagsProperty") { + } else if (proptype == "wxFlagsProperty") { wxArrayString options = wxCrafter::Split(PropertyString(PROP_PG_CHOICES), ";"); cppCode << arrName << ".Clear();\n"; cppCode << arrIntName << ".Clear();\n"; - for(size_t i = 0; i < options.GetCount(); ++i) { + for (size_t i = 0; i < options.GetCount(); ++i) { cppCode << arrName << ".Add(" << wxCrafter::UNDERSCORE(options.Item(i)) << ");\n"; } options = wxCrafter::Split(PropertyString(PROP_PG_CHOICES_VALUES), ";"); - for(size_t i = 0; i < options.GetCount(); ++i) { + for (size_t i = 0; i < options.GetCount(); ++i) { cppCode << arrIntName << ".Add(" << options.Item(i) << ");\n"; } @@ -216,18 +216,18 @@ wxString PropertyGridWrapper::CppCtorCode() const << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << ", wxPG_LABEL, " << arrName << ", " << arrIntName << ", " << strvalue << ") );\n"; - } else if(proptype == "wxDateProperty") { + } else if (proptype == "wxDateProperty") { cppCode << propName << " = " << grid << "->" << appendFunc << " new wxDateProperty( " << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << ", wxPG_LABEL, wxDateTime::Now()) );\n"; - } else if(proptype == "wxImageFileProperty") { + } else if (proptype == "wxImageFileProperty") { cppCode << propName << " = " << grid << "->" << appendFunc << " new wxImageFileProperty( " << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << ") );\n"; - } else if(proptype == "wxFontProperty") { + } else if (proptype == "wxFontProperty") { wxString fontMemberName = propName + "Font"; wxString font = wxCrafter::FontToCpp(PropertyString(PROP_FONT), fontMemberName); - if(!font.IsEmpty() && font != "wxNullFont") { + if (!font.IsEmpty() && font != "wxNullFont") { cppCode << font; cppCode << propName << " = " << grid << "->" << appendFunc << " new wxFontProperty( " << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << ", wxPG_LABEL, " << fontMemberName @@ -238,9 +238,9 @@ wxString PropertyGridWrapper::CppCtorCode() const << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << ") );\n"; cppCode << propName << "->SetValueToUnspecified();\n"; } - } else if(proptype == "wxSystemColourProperty") { + } else if (proptype == "wxSystemColourProperty") { wxString colorname = wxCrafter::ColourToCpp(PropertyString(PROP_PG_COLOUR_DEFAULT)); - if(!colorname.IsEmpty()) { + if (!colorname.IsEmpty()) { cppCode << propName << " = " << grid << "->" << appendFunc << " new wxSystemColourProperty( " << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << ", wxPG_LABEL, " << colorname << ") );\n"; } else { @@ -250,13 +250,13 @@ wxString PropertyGridWrapper::CppCtorCode() const } } - if(!cppCode.IsEmpty()) { + if (!cppCode.IsEmpty()) { // set common properties cppCode << propName << "->SetHelpString(" << wxCrafter::UNDERSCORE(PropertyString(PROP_TOOLTIP)) << ");\n"; } wxString propEditor = PropertyString(PROP_CUSTOM_EDITOR); - if(!propEditor.IsEmpty()) { + if (!propEditor.IsEmpty()) { cppCode << propName << "->SetEditor( " << wxCrafter::WXT(propEditor) << " );\n"; } return cppCode; @@ -272,12 +272,12 @@ wxString PropertyGridWrapper::GetWxClassName() const { return "wxPGProperty"; } void PropertyGridWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { return; } else { wxString value = wxCrafter::CDATA(PropertyString(PROP_PG_STRING_VALUE)); - if(PropertyString(PROP_KIND) == "wxBoolProperty") { + if (PropertyString(PROP_KIND) == "wxBoolProperty") { value = PropertyString(PROP_PG_BOOL_VALUE); } @@ -303,7 +303,7 @@ wxString PropertyGridWrapper::DoGenerateCppCtorCode_End() const // all children have been added wxString cppCode; wxString colorname = wxCrafter::ColourToCpp(PropertyString(PROP_BG)); - if(!colorname.IsEmpty()) { + if (!colorname.IsEmpty()) { cppCode << GetName() << "->SetBackgroundColour(" << colorname << ");\n"; } return cppCode; diff --git a/wxcrafter/controls/RearrangeListWrapper.cpp b/wxcrafter/controls/RearrangeListWrapper.cpp index e63ce9db20..7b6ac14aed 100644 --- a/wxcrafter/controls/RearrangeListWrapper.cpp +++ b/wxcrafter/controls/RearrangeListWrapper.cpp @@ -32,7 +32,7 @@ wxString RearrangeListWrapper::CppCtorCode() const code << "wxArrayInt " << orderArr << ";\n"; code << "wxArrayString " << optionsArr << ";\n"; - for(size_t i = 0; i < options.GetCount(); i++) { + for (size_t i = 0; i < options.GetCount(); i++) { code << optionsArr << ".Add(" << wxCrafter::UNDERSCORE(options.Item(i)) << ");\n"; code << orderArr << ".Add(" << i << ");\n"; } diff --git a/wxcrafter/controls/RibbonBar/ribbon_bar_wrapper.cpp b/wxcrafter/controls/RibbonBar/ribbon_bar_wrapper.cpp index 18d77ea247..ef24298d60 100644 --- a/wxcrafter/controls/RibbonBar/ribbon_bar_wrapper.cpp +++ b/wxcrafter/controls/RibbonBar/ribbon_bar_wrapper.cpp @@ -11,20 +11,27 @@ RibbonBarWrapper::RibbonBarWrapper() : wxcWidget(ID_WXRIBBONBAR) { - RegisterEvent("wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED", "wxRibbonBarEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGED", + "wxRibbonBarEvent", _("Triggered after the transition from one page being active to a different page being active.")); - RegisterEvent("wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING", "wxRibbonBarEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONBAR_PAGE_CHANGING", + "wxRibbonBarEvent", _("Triggered prior to the transition from one page being active to a different page being active, " "and can veto the change.")); - RegisterEvent("wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN", "wxRibbonBarEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_DOWN", + "wxRibbonBarEvent", _("Triggered when the middle mouse button is pressed on a tab.")); - RegisterEvent("wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP", "wxRibbonBarEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONBAR_TAB_MIDDLE_UP", + "wxRibbonBarEvent", _("Triggered when the middle mouse button is released on a tab.")); - RegisterEvent("wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN", "wxRibbonBarEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN", + "wxRibbonBarEvent", _("Triggered when the right mouse button is pressed on a tab.")); - RegisterEvent("wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP", "wxRibbonBarEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP", + "wxRibbonBarEvent", _("Triggered when the right mouse button is released on a tab.")); - RegisterEvent("wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK", "wxRibbonBarEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK", + "wxRibbonBarEvent", _("Triggered when the left mouse button is double clicked on a tab.")); PREPEND_STYLE_TRUE(wxRIBBON_BAR_DEFAULT_STYLE); @@ -40,7 +47,7 @@ RibbonBarWrapper::RibbonBarWrapper() DelProperty(PROP_CONTROL_SPECIFIC_SETTINGS); Add("wxRibbonBar"); - const wxArrayString themes = StdToWX::ToArrayString({ "Default", "Generic", "MSW" }); + const wxArrayString themes = StdToWX::ToArrayString({"Default", "Generic", "MSW"}); Add(PROP_RIBBON_THEME, themes, 0, _("Select the ribbon bar theme")); m_namePattern = "m_ribbonBar"; SetName(GenerateName()); @@ -53,9 +60,9 @@ wxString RibbonBarWrapper::CppCtorCode() const wxString cppCode; cppCode << CPPStandardWxCtor("wxRIBBON_BAR_DEFAULT_STYLE"); wxString theme = PropertyString(PROP_RIBBON_THEME); - if(theme == "MSW") { + if (theme == "MSW") { cppCode << GetName() << "->SetArtProvider(new wxRibbonMSWArtProvider);\n"; - } else if(theme == "Generic") { + } else if (theme == "Generic") { cppCode << GetName() << "->SetArtProvider(new wxRibbonAUIArtProvider);\n"; } else { cppCode << GetName() << "->SetArtProvider(new wxRibbonDefaultArtProvider);\n"; @@ -76,9 +83,9 @@ void RibbonBarWrapper::ToXRC(wxString& text, XRC_TYPE type) const text << XRCPrefix() << XRCCommonAttributes() << XRCStyle() << XRCSize(); // set the theme wxString theme = PropertyString(PROP_RIBBON_THEME); - if(theme == "Generic") { + if (theme == "Generic") { theme = "aui"; - } else if(theme == "MSW") { + } else if (theme == "MSW") { theme = "msw"; } else { theme = "default"; @@ -94,7 +101,7 @@ void RibbonBarWrapper::SetSelection(RibbonPageWrapper* page) { for (auto child : GetChildren()) { RibbonPageWrapper* p = dynamic_cast(child); - if(p) { + if (p) { p->Select(p == page); } } @@ -104,7 +111,7 @@ RibbonPageWrapper* RibbonBarWrapper::GetSelection() const { for (auto child : GetChildren()) { RibbonPageWrapper* p = dynamic_cast(child); - if(p && p->IsSelected()) { + if (p && p->IsSelected()) { return p; } } diff --git a/wxcrafter/controls/RibbonBar/ribbon_button.cpp b/wxcrafter/controls/RibbonBar/ribbon_button.cpp index 210efa90a0..8ee30c042a 100644 --- a/wxcrafter/controls/RibbonBar/ribbon_button.cpp +++ b/wxcrafter/controls/RibbonBar/ribbon_button.cpp @@ -13,19 +13,19 @@ RibbonButtonBase::RibbonButtonBase(int type) : wxcWidget(type) { const wxArrayString kind = StdToWX::ToArrayString( - { "wxRIBBON_BUTTON_NORMAL", "wxRIBBON_BUTTON_DROPDOWN", "wxRIBBON_BUTTON_HYBRID", "wxRIBBON_BUTTON_TOGGLE" }); + {"wxRIBBON_BUTTON_NORMAL", "wxRIBBON_BUTTON_DROPDOWN", "wxRIBBON_BUTTON_HYBRID", "wxRIBBON_BUTTON_TOGGLE"}); m_isButtonBar = !(type == ID_WXRIBBONTOOL || type == ID_WXRIBBONDROPDOWNTOOL || type == ID_WXRIBBONHYBRIDTOOL || type == ID_WXRIBBONTOGGLETOOL); int selection = 0; - if(type == ID_WXRIBBONBUTTON || type == ID_WXRIBBONTOOL) { + if (type == ID_WXRIBBONBUTTON || type == ID_WXRIBBONTOOL) { selection = 0; - } else if(type == ID_WXRIBBONDROPDOWNBUTTON || type == ID_WXRIBBONDROPDOWNTOOL) { + } else if (type == ID_WXRIBBONDROPDOWNBUTTON || type == ID_WXRIBBONDROPDOWNTOOL) { selection = 1; - } else if(type == ID_WXRIBBONHYBRIDBUTTON || type == ID_WXRIBBONHYBRIDTOOL) { + } else if (type == ID_WXRIBBONHYBRIDBUTTON || type == ID_WXRIBBONHYBRIDTOOL) { selection = 2; - } else if(type == ID_WXRIBBONTOGGLEBUTTON || type == ID_WXRIBBONTOGGLETOOL) { + } else if (type == ID_WXRIBBONTOGGLEBUTTON || type == ID_WXRIBBONTOGGLETOOL) { selection = 3; } @@ -35,17 +35,19 @@ RibbonButtonBase::RibbonButtonBase(int type) Add(PROP_KIND, kind, selection, _("The button type")); wxCrafter::ResourceLoader bl; - if(m_isButtonBar) { + if (m_isButtonBar) { m_properties.Item(PROP_BITMAP_PATH)->SetValue(bl.GetPlaceHolderImagePath().GetFullPath()); } else { m_properties.Item(PROP_BITMAP_PATH)->SetValue(bl.GetPlaceHolder16ImagePath().GetFullPath()); } - if(m_isButtonBar) { - RegisterEvent("wxEVT_COMMAND_RIBBONBUTTON_CLICKED", "wxRibbonButtonBarEvent", + if (m_isButtonBar) { + RegisterEvent("wxEVT_COMMAND_RIBBONBUTTON_CLICKED", + "wxRibbonButtonBarEvent", _("Triggered when the normal (non-dropdown) region of a button on the button bar is clicked.")); - RegisterEvent("wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED", "wxRibbonButtonBarEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED", + "wxRibbonButtonBarEvent", _("Triggered when the dropdown region of a button on the button bar is clicked. " "wxRibbonButtonBarEvent::PopupMenu() should be called by the event handler if it wants to " "display a popup menu (which is what most dropdown buttons should be doing).")); @@ -53,9 +55,11 @@ RibbonButtonBase::RibbonButtonBase(int type) } else { DelProperty(PROP_LABEL); - RegisterEvent("wxEVT_COMMAND_RIBBONTOOL_CLICKED", "wxRibbonToolBarEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONTOOL_CLICKED", + "wxRibbonToolBarEvent", _("Triggered when the normal (non-dropdown) region of a tool on the toolbar is clicked.")); - RegisterEvent("wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED", "wxRibbonToolBarEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONTOOL_DROPDOWN_CLICKED", + "wxRibbonToolBarEvent", _("Triggered when the dropdown region of a tool on the toolbar is clicked. " "wxRibbonToolBarEvent::PopupMenu() should be called by the event handler if it wants to " "display a popup menu (which is what most dropdown buttons should be doing).")); @@ -69,7 +73,7 @@ wxString RibbonButtonBase::CppCtorCode() const wxcCodeGeneratorHelper::Get().AddBitmap(PropertyFile(PROP_BITMAP_PATH)); wxString code; - if(m_isButtonBar) { + if (m_isButtonBar) { code << GetParent()->GetName() << "->AddButton(" << GetId() << ", " << Label() << ", " << wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)) << ", " << wxCrafter::UNDERSCORE(PropertyString(PROP_HELP)) << ", " << PropertyString(PROP_KIND) << ");\n"; @@ -89,7 +93,7 @@ wxString RibbonButtonBase::GetWxClassName() const { return ""; } void RibbonButtonBase::ToXRC(wxString& text, XRC_TYPE type) const { - if(m_isButtonBar) { + if (m_isButtonBar) { text << ""; } else { @@ -99,10 +103,10 @@ void RibbonButtonBase::ToXRC(wxString& text, XRC_TYPE type) const text << XRCBitmap() << XRCLabel(); wxString kind = PropertyString(PROP_KIND); - if(kind == "wxRIBBON_BUTTON_DROPDOWN") { + if (kind == "wxRIBBON_BUTTON_DROPDOWN") { text << "1"; - } else if(kind == "wxRIBBON_BUTTON_HYBRID") { + } else if (kind == "wxRIBBON_BUTTON_HYBRID") { text << "1"; } diff --git a/wxcrafter/controls/RibbonBar/ribbon_gallery_wrapper.cpp b/wxcrafter/controls/RibbonBar/ribbon_gallery_wrapper.cpp index 7a3b740093..1f08682489 100644 --- a/wxcrafter/controls/RibbonBar/ribbon_gallery_wrapper.cpp +++ b/wxcrafter/controls/RibbonBar/ribbon_gallery_wrapper.cpp @@ -6,19 +6,22 @@ RibbonGalleryWrapper::RibbonGalleryWrapper() : wxcWidget(ID_WXRIBBONGALLERY) { SetPropertyString(_("Common Settings"), "wxRibbonGallery"); - RegisterEvent("wxEVT_COMMAND_RIBBONGALLERY_SELECTED", "wxRibbonGalleryEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONGALLERY_SELECTED", + "wxRibbonGalleryEvent", _("Triggered when the user selects an item from the gallery. Note that the ID is that of the " "gallery, not of the item.")); - RegisterEvent("wxEVT_COMMAND_RIBBONGALLERY_CLICKED", "wxRibbonGalleryEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONGALLERY_CLICKED", + "wxRibbonGalleryEvent", _("Similar to EVT_RIBBONGALLERY_SELECTED but triggered every time a gallery item is clicked, even if " "it is already selected. Note that the ID of the event is that of the gallery, not of the item, " "just as above. This event is available since wxWidgets 2.9.2.")); - RegisterEvent("wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED", "wxRibbonGalleryEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONGALLERY_HOVER_CHANGED", + "wxRibbonGalleryEvent", _("Triggered when the item being hovered over by the user changes. The item in the event will be the " "new item being hovered, or NULL if there is no longer an item being hovered. Note that the ID is " "that of the gallery, not of the item.")); - RegisterEventCommand("wxEVT_COMMAND_BUTTON_CLICKED", - _("Triggered when the \"extension\" button of the gallery is pressed")); + RegisterEventCommand( + "wxEVT_COMMAND_BUTTON_CLICKED", _("Triggered when the \"extension\" button of the gallery is pressed")); m_namePattern = "m_ribbonGallery"; SetName(GenerateName()); } diff --git a/wxcrafter/controls/RibbonBar/ribbon_page_wrapper.cpp b/wxcrafter/controls/RibbonBar/ribbon_page_wrapper.cpp index 303ef78f2c..e3650da109 100644 --- a/wxcrafter/controls/RibbonBar/ribbon_page_wrapper.cpp +++ b/wxcrafter/controls/RibbonBar/ribbon_page_wrapper.cpp @@ -29,7 +29,7 @@ wxString RibbonPageWrapper::CppCtorCode() const << Label() << ", " << wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)) << ", " << StyleFlags("0") << ");\n"; cppCode << CPPCommonAttributes(); - if(PropertyBool(PROP_SELECTED) == "true") { + if (PropertyBool(PROP_SELECTED) == "true") { cppCode << GetParent()->GetName() << "->SetActivePage( " << GetName() << " );\n"; } return cppCode; diff --git a/wxcrafter/controls/RibbonBar/ribbon_panel_wrapper.cpp b/wxcrafter/controls/RibbonBar/ribbon_panel_wrapper.cpp index d8b711a2a3..806631bda0 100644 --- a/wxcrafter/controls/RibbonBar/ribbon_panel_wrapper.cpp +++ b/wxcrafter/controls/RibbonBar/ribbon_panel_wrapper.cpp @@ -23,7 +23,8 @@ RibbonPanelWrapper::RibbonPanelWrapper() Add( PROP_BITMAP_PATH, "", _("Icon to be used in place of the panel's children when the panel is minimised")); - RegisterEvent("wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED", "wxRibbonPanelEvent", + RegisterEvent("wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED", + "wxRibbonPanelEvent", _("Triggered when the user activate the panel extension button")); m_namePattern = "m_ribbonPanel"; diff --git a/wxcrafter/controls/RibbonBar/ribbon_tool_bar_wrapper.cpp b/wxcrafter/controls/RibbonBar/ribbon_tool_bar_wrapper.cpp index 812c56b5d6..802a410a1b 100644 --- a/wxcrafter/controls/RibbonBar/ribbon_tool_bar_wrapper.cpp +++ b/wxcrafter/controls/RibbonBar/ribbon_tool_bar_wrapper.cpp @@ -29,7 +29,7 @@ wxString RibbonToolBarWrapper::CppCtorCode() const cppCode << CPPStandardWxCtor("0"); int minRows = PropertyInt(PROP_RIBBON_TOOLBAR_MIN_ROWS, 1); int maxRows = PropertyInt(PROP_RIBBON_TOOLBAR_MAX_ROWS, -1); - if(minRows > 0 && (maxRows >= minRows || maxRows == -1)) { + if (minRows > 0 && (maxRows >= minRows || maxRows == -1)) { cppCode << GetName() << "->SetRows(" << minRows << ", " << maxRows << ");\n"; } return cppCode; diff --git a/wxcrafter/controls/SimpleHtmlListBoxWrapper.cpp b/wxcrafter/controls/SimpleHtmlListBoxWrapper.cpp index 0dcc089f0f..e6c380e2c3 100644 --- a/wxcrafter/controls/SimpleHtmlListBoxWrapper.cpp +++ b/wxcrafter/controls/SimpleHtmlListBoxWrapper.cpp @@ -16,12 +16,13 @@ SimpleHtmlListBoxWrapper::SimpleHtmlListBoxWrapper() // Events RegisterEventCommand("wxEVT_LISTBOX", _("Process a wxEVT_LISTBOX event, when an item on the list is selected")); - RegisterEventCommand("wxEVT_LISTBOX_DCLICK", - _("Process a wxEVT_LISTBOX_DCLICK event, when the listbox is double-clicked")); + RegisterEventCommand( + "wxEVT_LISTBOX_DCLICK", _("Process a wxEVT_LISTBOX_DCLICK event, when the listbox is double-clicked")); RegisterEvent("wxEVT_HTML_CELL_CLICKED", "wxHtmlCellEvent", _("A wxHtmlCell was clicked. See wxHtmlCellEvent")); - RegisterEvent("wxEVT_HTML_CELL_HOVER", "wxHtmlCellEvent", - _("The mouse passed over a wxHtmlCell. See wxHtmlCellEvent")); - RegisterEvent("wxEVT_HTML_LINK_CLICKED", "wxHtmlLinkEvent", + RegisterEvent( + "wxEVT_HTML_CELL_HOVER", "wxHtmlCellEvent", _("The mouse passed over a wxHtmlCell. See wxHtmlCellEvent")); + RegisterEvent("wxEVT_HTML_LINK_CLICKED", + "wxHtmlLinkEvent", _("A wxHtmlCell which contains an hyperlink was clicked. See wxHtmlLinkEvent")); SetPropertyString(_("Common Settings"), "wxSimpleHtmlListBox"); Add( @@ -47,7 +48,7 @@ wxString SimpleHtmlListBoxWrapper::CppCtorCode() const optionsArr << GetName() << wxT("Arr"); code << wxT("wxArrayString ") << optionsArr << wxT(";\n"); - for(size_t i = 0; i < options.GetCount(); i++) { + for (size_t i = 0; i < options.GetCount(); i++) { code << optionsArr << wxT(".Add(") << wxCrafter::UNDERSCORE(options.Item(i)) << wxT(");\n"); } @@ -58,7 +59,7 @@ wxString SimpleHtmlListBoxWrapper::CppCtorCode() const code << CPPCommonAttributes(); int sel = wxCrafter::ToNumber(PropertyString(PROP_SELECTION), -1); - if(sel >= 0 && sel < (int)options.GetCount()) { + if (sel >= 0 && sel < (int)options.GetCount()) { code << GetName() << wxT("->SetSelection(") << PropertyString(PROP_SELECTION) << wxT(");\n"); } return code; diff --git a/wxcrafter/controls/SimpleHtmlListBoxWrapper.h b/wxcrafter/controls/SimpleHtmlListBoxWrapper.h index 0981489d2d..64b827c3c8 100644 --- a/wxcrafter/controls/SimpleHtmlListBoxWrapper.h +++ b/wxcrafter/controls/SimpleHtmlListBoxWrapper.h @@ -14,7 +14,6 @@ class SimpleHtmlListBoxWrapper : public wxcWidget wxString CppCtorCode() const override; void ToXRC(wxString& text, XRC_TYPE type) const override; wxcWidget* Clone() const override { return new SimpleHtmlListBoxWrapper(); } - }; #endif // SIMPLEHTMLLISTBOXWRAPPER_H diff --git a/wxcrafter/controls/TimePickerCtrlWrapper.cpp b/wxcrafter/controls/TimePickerCtrlWrapper.cpp index 47ea1c9f42..e901dc164c 100644 --- a/wxcrafter/controls/TimePickerCtrlWrapper.cpp +++ b/wxcrafter/controls/TimePickerCtrlWrapper.cpp @@ -1,10 +1,12 @@ #include "TimePickerCtrlWrapper.h" + #include "allocator_mgr.h" TimePickerCtrlWrapper::TimePickerCtrlWrapper() : wxcWidget(ID_WXTIMEPICKERCTRL) { - RegisterEvent(wxT("wxEVT_TIME_CHANGED"), wxT("wxDateEvent"), + RegisterEvent(wxT("wxEVT_TIME_CHANGED"), + wxT("wxDateEvent"), _("This event fires when the user changes the current selection in the control")); m_namePattern = wxT("m_timePickerCtrl"); SetPropertyString(_("Common Settings"), "wxTimePickerCtrl"); diff --git a/wxcrafter/controls/banner_window_wrapper.cpp b/wxcrafter/controls/banner_window_wrapper.cpp index f4f4021bec..e9889349a6 100644 --- a/wxcrafter/controls/banner_window_wrapper.cpp +++ b/wxcrafter/controls/banner_window_wrapper.cpp @@ -14,7 +14,7 @@ BannerWindowWrapper::BannerWindowWrapper() : wxcWidget(ID_WXBANNERWINDOW) { - const wxArrayString options = StdToWX::ToArrayString({ "wxTOP", "wxBOTTOM", "wxLEFT", "wxRIGHT" }); + const wxArrayString options = StdToWX::ToArrayString({"wxTOP", "wxBOTTOM", "wxLEFT", "wxRIGHT"}); SetPropertyString(_("Common Settings"), "wxBannerWindow"); Add( @@ -62,7 +62,7 @@ wxString BannerWindowWrapper::CppCtorCode() const col1 = wxCrafter::ColourToCpp(PropertyString(PROP_COLOR_GRADIENT_START)); col2 = wxCrafter::ColourToCpp(PropertyString(PROP_COLOR_GRADIENT_END)); - if(!col1.IsEmpty() && !col2.IsEmpty()) { + if (!col1.IsEmpty() && !col2.IsEmpty()) { cppCode << GetName() << "->SetGradient(" << col1 << ", " << col2 << ");\n"; } diff --git a/wxcrafter/controls/bitmap_button_wrapper.cpp b/wxcrafter/controls/bitmap_button_wrapper.cpp index 0daf379a89..433e83f240 100644 --- a/wxcrafter/controls/bitmap_button_wrapper.cpp +++ b/wxcrafter/controls/bitmap_button_wrapper.cpp @@ -19,7 +19,8 @@ BitmapButtonWrapper::BitmapButtonWrapper() PREPEND_STYLE(wxBU_RIGHT, false); PREPEND_STYLE(wxBU_TOP, false); - RegisterEvent(wxT("wxEVT_COMMAND_BUTTON_CLICKED"), wxT("wxCommandEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_BUTTON_CLICKED"), + wxT("wxCommandEvent"), _("Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked."), wxT("wxCommandEventHandler")); @@ -45,7 +46,9 @@ wxString BitmapButtonWrapper::CppCtorCode() const << wxT(", ") << wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)) << wxT(", wxDefaultPosition, ") << SizeAsString() << wxT(", ") << StyleFlags(wxT("0")) << wxT(");\n"); - if(PropertyString(PROP_DEFAULT_BUTTON) == wxT("1")) { code << GetName() << wxT("->SetDefault();"); } + if (PropertyString(PROP_DEFAULT_BUTTON) == wxT("1")) { + code << GetName() << wxT("->SetDefault();"); + } code << CPPCommonAttributes(); return code; } @@ -64,10 +67,14 @@ void BitmapButtonWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); } + if (propertynode) { + ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("default")); - if(propertynode) { SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); + } } void BitmapButtonWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -76,10 +83,14 @@ void BitmapButtonWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); } + if (propertynode) { + ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("default")); - if(propertynode) { SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); + } } void BitmapButtonWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -88,10 +99,12 @@ void BitmapButtonWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "bitmap"); - if(propertynode) { + if (propertynode) { ImportFromwxFB::ProcessBitmapProperty(propertynode->GetNodeContent(), this, PROP_BITMAP_PATH, "wxART_BUTTON"); } propertynode = XmlUtils::FindNodeByName(node, "property", "default"); - if(propertynode) { SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/bitmap_wrapper.cpp b/wxcrafter/controls/bitmap_wrapper.cpp index 1ccfe42f49..2bdf06833f 100644 --- a/wxcrafter/controls/bitmap_wrapper.cpp +++ b/wxcrafter/controls/bitmap_wrapper.cpp @@ -32,7 +32,7 @@ wxcWidget* BitmapWrapper::Clone() const { return new BitmapWrapper(); } wxString BitmapWrapper::CppCtorCode() const { - const wxArrayString exts = StdToWX::ToArrayString({ "", "@2x", "@1.25x", "@1.5x" }); + const wxArrayString exts = StdToWX::ToArrayString({"", "@2x", "@1.25x", "@1.5x"}); wxString bmpPath = PropertyString(PROP_BITMAP_PATH); wxFileName fn(bmpPath); // Support for hi-res images @@ -55,8 +55,8 @@ wxString BitmapWrapper::CppCtorCode() const cppCode << " wxBitmap bmp;\n"; cppCode << " wxIcon icn;\n"; cppCode << " bmp = " - << wxcCodeGeneratorHelper::Get().BitmapCode(PropertyString(PROP_BITMAP_PATH), - GetName() + exts.Item(i)) + << wxcCodeGeneratorHelper::Get().BitmapCode( + PropertyString(PROP_BITMAP_PATH), GetName() + exts.Item(i)) << ";\n"; cppCode << " if(bmp.IsOk()) {\n"; cppCode << " if((m_imagesWidth == bmp.GetWidth()) && (m_imagesHeight == bmp.GetHeight())){\n"; diff --git a/wxcrafter/controls/button_wrapper.cpp b/wxcrafter/controls/button_wrapper.cpp index 310462d348..06de906952 100644 --- a/wxcrafter/controls/button_wrapper.cpp +++ b/wxcrafter/controls/button_wrapper.cpp @@ -23,9 +23,10 @@ ButtonWrapper::ButtonWrapper() PREPEND_STYLE(wxBU_RIGHT, false); PREPEND_STYLE(wxBU_TOP, false); - const wxArrayString directions = StdToWX::ToArrayString({ "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM" }); + const wxArrayString directions = StdToWX::ToArrayString({"wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"}); - RegisterEvent(wxT("wxEVT_COMMAND_BUTTON_CLICKED"), wxT("wxCommandEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_BUTTON_CLICKED"), + wxT("wxCommandEvent"), _("Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked."), wxT("wxCommandEventHandler")); @@ -59,10 +60,12 @@ wxString ButtonWrapper::CppCtorCode() const << wxT(", ") << Label() << wxT(", wxDefaultPosition, ") << SizeAsString() << wxT(", ") << StyleFlags(wxT("0")) << wxT(");\n"); - if(PropertyString(PROP_DEFAULT_BUTTON) == wxT("1")) { code << GetName() << wxT("->SetDefault();\n"); } + if (PropertyString(PROP_DEFAULT_BUTTON) == wxT("1")) { + code << GetName() << wxT("->SetDefault();\n"); + } wxString bmpCpp = wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)); - if(bmpCpp != "wxNullBitmap") { + if (bmpCpp != "wxNullBitmap") { code << wxCrafter::WX294_BLOCK_START(); code << GetName() << "->SetBitmap(" << bmpCpp << ", " << PropertyString(PROP_DIRECTION) << ");\n"; code << GetName() << "->SetBitmapMargins(" << xy.ToString() << ");\n"; @@ -89,10 +92,14 @@ void ButtonWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); } + if (propertynode) { + ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("default")); - if(propertynode) { SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); + } } void ButtonWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -101,10 +108,14 @@ void ButtonWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); } + if (propertynode) { + ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("default")); - if(propertynode) { SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); + } } void ButtonWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -113,10 +124,12 @@ void ButtonWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "bitmap"); - if(propertynode) { + if (propertynode) { ImportFromwxFB::ProcessBitmapProperty(propertynode->GetNodeContent(), this, PROP_BITMAP_PATH, "wxART_BUTTON"); } propertynode = XmlUtils::FindNodeByName(node, "property", "default"); - if(propertynode) { SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/calendar_ctrl_wrapper.cpp b/wxcrafter/controls/calendar_ctrl_wrapper.cpp index 6716e8741b..6323ce7701 100644 --- a/wxcrafter/controls/calendar_ctrl_wrapper.cpp +++ b/wxcrafter/controls/calendar_ctrl_wrapper.cpp @@ -1,6 +1,8 @@ #include "calendar_ctrl_wrapper.h" + #include "allocator_mgr.h" #include "wxgui_defs.h" + #include CalendarCtrlWrapper::CalendarCtrlWrapper() @@ -14,13 +16,13 @@ CalendarCtrlWrapper::CalendarCtrlWrapper() PREPEND_STYLE_FALSE(wxCAL_SHOW_SURROUNDING_WEEKS); PREPEND_STYLE_FALSE(wxCAL_SEQUENTIAL_MONTH_SELECTION); - RegisterEvent(wxT("wxEVT_CALENDAR_DOUBLECLICKED"), wxT("wxCalendarEvent"), - _("A day was double clicked in the calendar.")); + RegisterEvent( + wxT("wxEVT_CALENDAR_DOUBLECLICKED"), wxT("wxCalendarEvent"), _("A day was double clicked in the calendar.")); RegisterEvent(wxT("wxEVT_CALENDAR_DAY_CHANGED"), wxT("wxCalendarEvent"), _("The selected day changed.")); RegisterEvent(wxT("wxEVT_CALENDAR_MONTH_CHANGED"), wxT("wxCalendarEvent"), _("The selected month changed.")); RegisterEvent(wxT("wxEVT_CALENDAR_SEL_CHANGED"), wxT("wxCalendarEvent"), _("The selected date changed.")); - RegisterEvent(wxT("wxEVT_CALENDAR_WEEKDAY_CLICKED"), wxT("wxCalendarEvent"), - _("User clicked on the week day header")); + RegisterEvent( + wxT("wxEVT_CALENDAR_WEEKDAY_CLICKED"), wxT("wxCalendarEvent"), _("User clicked on the week day header")); RegisterEvent(wxT("wxEVT_CALENDAR_YEAR_CHANGED"), wxT("wxCalendarEvent"), _("The selected year changed.")); SetPropertyString(_("Common Settings"), "wxCalendarCtrl"); diff --git a/wxcrafter/controls/check_box_wrapper.cpp b/wxcrafter/controls/check_box_wrapper.cpp index 0d30c3dfb4..90f0e457d9 100644 --- a/wxcrafter/controls/check_box_wrapper.cpp +++ b/wxcrafter/controls/check_box_wrapper.cpp @@ -34,7 +34,7 @@ wxString CheckBoxWrapper::CppCtorCode() const << wxT(", ") << Label() << wxT(", ") << wxT("wxDefaultPosition") << wxT(", ") << SizeAsString() << wxT(", ") << StyleFlags(wxT("0")) << wxT(");\n"); - if(PropertyString(PROP_VALUE) == wxT("1")) { + if (PropertyString(PROP_VALUE) == wxT("1")) { code << GetName() << wxT("->SetValue(true);\n"); } else { @@ -60,7 +60,9 @@ void CheckBoxWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("checked")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void CheckBoxWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -69,7 +71,9 @@ void CheckBoxWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("checked")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void CheckBoxWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -78,5 +82,7 @@ void CheckBoxWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", wxT("checked")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/check_list_box_wrapper.cpp b/wxcrafter/controls/check_list_box_wrapper.cpp index 0dfdc6a119..b275017f2d 100644 --- a/wxcrafter/controls/check_list_box_wrapper.cpp +++ b/wxcrafter/controls/check_list_box_wrapper.cpp @@ -21,9 +21,8 @@ CheckListBoxWrapper::CheckListBoxWrapper() RegisterEventCommand(wxT("wxEVT_COMMAND_LISTBOX_SELECTED"), _("Process a wxEVT_COMMAND_LISTBOX_SELECTED event\nwhen an item on the list is selected or " "the selection changes.")); - RegisterEventCommand( - wxT("wxEVT_COMMAND_LISTBOX_DOUBLECLICKED"), - _("Process a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event\nwhen the listbox is double-clicked.")); + RegisterEventCommand(wxT("wxEVT_COMMAND_LISTBOX_DOUBLECLICKED"), + _("Process a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event\nwhen the listbox is double-clicked.")); RegisterEventCommand(wxT("wxEVT_COMMAND_CHECKLISTBOX_TOGGLED"), _("Process a wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event\nwhen an item in the check list box " "is checked or unchecked.")); @@ -46,7 +45,7 @@ wxString CheckListBoxWrapper::CppCtorCode() const optionsArr << GetName() << wxT("Arr"); code << wxT("wxArrayString ") << optionsArr << wxT(";\n"); - for(size_t i = 0; i < options.GetCount(); i++) { + for (size_t i = 0; i < options.GetCount(); i++) { code << optionsArr << wxT(".Add(") << wxCrafter::UNDERSCORE(options.Item(i)) << wxT(");\n"); } @@ -69,7 +68,7 @@ void CheckListBoxWrapper::ToXRC(wxString& text, XRC_TYPE type) const wxArrayString options = wxCrafter::Split(PropertyString(PROP_OPTIONS), wxT(";")); text << wxT(""); - for(size_t i = 0; i < options.GetCount(); i++) { + for (size_t i = 0; i < options.GetCount(); i++) { text << wxT("") << wxCrafter::XMLEncode(options.Item(i)) << wxT(""); } text << wxT(""); @@ -83,7 +82,9 @@ void CheckListBoxWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("content")); - if(propertynode) { SetPropertyString(PROP_OPTIONS, XmlUtils::ChildNodesContentToString(propertynode)); } + if (propertynode) { + SetPropertyString(PROP_OPTIONS, XmlUtils::ChildNodesContentToString(propertynode)); + } // XRC also allows a 'checked' property for each item, but as neither XRCed, wxFB or (atm) wxC support this... } @@ -93,7 +94,7 @@ void CheckListBoxWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("content")); - if(propertynode) { + if (propertynode) { wxString t = XmlUtils::ChildNodesContentToString(propertynode); SetPropertyString(PROP_OPTIONS, XmlUtils::ChildNodesContentToString(propertynode)); } @@ -108,7 +109,7 @@ void CheckListBoxWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "choices"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_OPTIONS, ImportFromwxFB::ConvertFBOptionsString(propertynode->GetNodeContent())); } } diff --git a/wxcrafter/controls/choice_book_wrapper.cpp b/wxcrafter/controls/choice_book_wrapper.cpp index 9323b2fb69..da54af81a2 100644 --- a/wxcrafter/controls/choice_book_wrapper.cpp +++ b/wxcrafter/controls/choice_book_wrapper.cpp @@ -5,9 +5,10 @@ ChoiceBookWrapper::ChoiceBookWrapper() : NotebookBaseWrapper(ID_WXCHOICEBOOK) { - RegisterEvent(wxT("wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED"), wxT("wxChoicebookEvent"), - _("The page selection was changed")); - RegisterEvent(wxT("wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING"), wxT("wxChoicebookEvent"), + RegisterEvent( + wxT("wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGED"), wxT("wxChoicebookEvent"), _("The page selection was changed")); + RegisterEvent(wxT("wxEVT_COMMAND_CHOICEBOOK_PAGE_CHANGING"), + wxT("wxChoicebookEvent"), _("The page selection is about to be changed. This event can be vetoed")); SetPropertyString(_("Common Settings"), "wxChoicebook"); diff --git a/wxcrafter/controls/choice_wrapper.cpp b/wxcrafter/controls/choice_wrapper.cpp index bff2bb68c2..7067e2474b 100644 --- a/wxcrafter/controls/choice_wrapper.cpp +++ b/wxcrafter/controls/choice_wrapper.cpp @@ -30,7 +30,7 @@ wxString ChoiceWrapper::CppCtorCode() const wxArrayString options = wxCrafter::Split(PropertyString(PROP_OPTIONS), wxT(";")); code << wxT("wxArrayString ") << GetName() << wxT("Arr;\n"); - for(size_t i = 0; i < options.GetCount(); i++) { + for (size_t i = 0; i < options.GetCount(); i++) { code << GetName() << wxT("Arr.Add(") << wxCrafter::UNDERSCORE(options.Item(i)) << wxT(");\n"); } @@ -40,7 +40,7 @@ wxString ChoiceWrapper::CppCtorCode() const code << CPPCommonAttributes(); long sel = wxCrafter::ToNumber(PropertyString(PROP_SELECTION), -1); - if(sel != -1 && sel < (long)options.GetCount()) { + if (sel != -1 && sel < (long)options.GetCount()) { code << GetName() << wxT("->SetSelection(") << sel << wxT(");\n"); } return code; @@ -68,11 +68,15 @@ void ChoiceWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) // The Options (content) property has a default, so we must clear it even if the node is absent wxString multistring; wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("content")); - if(propertynode) { multistring = XmlUtils::ChildNodesContentToString(propertynode); } + if (propertynode) { + multistring = XmlUtils::ChildNodesContentToString(propertynode); + } SetPropertyString(PROP_OPTIONS, multistring); propertynode = XmlUtils::FindFirstByTagName(node, wxT("selection")); - if(propertynode) { SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); + } } void ChoiceWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -83,11 +87,15 @@ void ChoiceWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) // The Options (content) property has a default, so we must clear it even if the node is absent wxString multistring; wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("content")); - if(propertynode) { multistring = XmlUtils::ChildNodesContentToString(propertynode); } + if (propertynode) { + multistring = XmlUtils::ChildNodesContentToString(propertynode); + } SetPropertyString(PROP_OPTIONS, multistring); propertynode = XmlUtils::FindFirstByTagName(node, wxT("selection")); - if(propertynode) { SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); + } } void ChoiceWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -98,9 +106,13 @@ void ChoiceWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) // The "choices" property has a default, so we should clear it even if the node was absent wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "choices"); wxString content; - if(propertynode) { content = ImportFromwxFB::ConvertFBOptionsString(propertynode->GetNodeContent()); } + if (propertynode) { + content = ImportFromwxFB::ConvertFBOptionsString(propertynode->GetNodeContent()); + } SetPropertyString(PROP_OPTIONS, content); propertynode = XmlUtils::FindNodeByName(node, "property", "selection"); - if(propertynode) { SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/colour_picker_wrapper.cpp b/wxcrafter/controls/colour_picker_wrapper.cpp index 4e442f18b9..b42e972d0d 100644 --- a/wxcrafter/controls/colour_picker_wrapper.cpp +++ b/wxcrafter/controls/colour_picker_wrapper.cpp @@ -18,7 +18,8 @@ ColourPickerWrapper::ColourPickerWrapper() SetPropertyString(_("Common Settings"), "wxColourPickerCtrl"); Add(PROP_VALUE, wxT(""), _("Colour")); - RegisterEvent(wxT("wxEVT_COMMAND_COLOURPICKER_CHANGED"), wxT("wxColourPickerEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_COLOURPICKER_CHANGED"), + wxT("wxColourPickerEvent"), _("The user changed the colour selected in the control either using the button or using text " "control\n(see wxCLRP_USE_TEXTCTRL; note that in this case the event is fired only if the user's " "input is valid, i.e. recognizable).")); @@ -33,7 +34,9 @@ wxString ColourPickerWrapper::CppCtorCode() const { wxString code; wxString color = wxCrafter::ColourToCpp(PropertyString(PROP_VALUE)); - if(color.IsEmpty()) { color << wxT("*wxBLACK"); } + if (color.IsEmpty()) { + color << wxT("*wxBLACK"); + } code << GetName() << wxT(" = new ") << GetRealClassName() << wxT("(") << GetWindowParent() << wxT(", ") << WindowID() << wxT(", ") << color << wxT(", ") << wxT("wxDefaultPosition, ") << SizeAsString() << wxT(", ") @@ -58,7 +61,9 @@ void ColourPickerWrapper::ToXRC(wxString& text, XRC_TYPE type) const s << XRCPrefix() << XRCStyle() << XRCSize(); - if(value != wxT("")) { s << wxT("") << wxCrafter::GetColourForXRC(value) << wxT(""); } + if (value != wxT("")) { + s << wxT("") << wxCrafter::GetColourForXRC(value) << wxT(""); + } s << XRCCommonAttributes() << XRCSuffix(); @@ -71,7 +76,9 @@ void ColourPickerWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void ColourPickerWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -80,7 +87,9 @@ void ColourPickerWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("colour")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void ColourPickerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -89,5 +98,7 @@ void ColourPickerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "colour"); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/command_link_button_wrapper.cpp b/wxcrafter/controls/command_link_button_wrapper.cpp index 3db253fc35..851941f864 100644 --- a/wxcrafter/controls/command_link_button_wrapper.cpp +++ b/wxcrafter/controls/command_link_button_wrapper.cpp @@ -24,7 +24,8 @@ CommandLinkButtonWrapper::CommandLinkButtonWrapper() DelProperty(_("Control Specific Settings")); Add("wxCommandLinkButton"); - RegisterEvent("wxEVT_COMMAND_BUTTON_CLICKED", "wxCommandEvent", + RegisterEvent("wxEVT_COMMAND_BUTTON_CLICKED", + "wxCommandEvent", _("Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked."), "wxCommandEventHandler"); @@ -52,11 +53,11 @@ wxString CommandLinkButtonWrapper::CppCtorCode() const << "wxDefaultPosition, " << SizeAsString() << ", " << StyleFlags("0") << ");\n"; wxString bmpCpp = wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)); - if(bmpCpp != "wxNullBitmap") { + if (bmpCpp != "wxNullBitmap") { cppCode << GetName() << "->SetBitmap(" << bmpCpp << ", wxLEFT );\n"; } - if(PropertyBool(PROP_DEFAULT_BUTTON) == "true") { + if (PropertyBool(PROP_DEFAULT_BUTTON) == "true") { cppCode << GetName() << "->SetDefault();\n"; } diff --git a/wxcrafter/controls/data_view_list_ctrl_column.cpp b/wxcrafter/controls/data_view_list_ctrl_column.cpp index ad00ab5cfd..72b36a0bb0 100644 --- a/wxcrafter/controls/data_view_list_ctrl_column.cpp +++ b/wxcrafter/controls/data_view_list_ctrl_column.cpp @@ -3,8 +3,8 @@ #include "Properties/category_property.h" #include "Properties/choice_property.h" #include "Properties/col_header_flags_property.h" -#include "Properties/string_property.h" #include "Properties/multi_strings_property.h" +#include "Properties/string_property.h" #include "StdToWX.h" #include "allocator_mgr.h" #include "wxgui_helpers.h" @@ -16,11 +16,10 @@ DataViewListCtrlColumn::DataViewListCtrlColumn() m_sizerFlags.Clear(); m_properties.Clear(); - const wxArrayString coltype = - StdToWX::ToArrayString({ "bitmap", "check", "text", "icontext", "progress", "choice" }); - const wxArrayString alignment = StdToWX::ToArrayString({ "wxALIGN_LEFT", "wxALIGN_RIGHT", "wxALIGN_CENTER" }); + const wxArrayString coltype = StdToWX::ToArrayString({"bitmap", "check", "text", "icontext", "progress", "choice"}); + const wxArrayString alignment = StdToWX::ToArrayString({"wxALIGN_LEFT", "wxALIGN_RIGHT", "wxALIGN_CENTER"}); const wxArrayString cellType = - StdToWX::ToArrayString({ "wxDATAVIEW_CELL_INERT", "wxDATAVIEW_CELL_ACTIVATABLE", "wxDATAVIEW_CELL_EDITABLE" }); + StdToWX::ToArrayString({"wxDATAVIEW_CELL_INERT", "wxDATAVIEW_CELL_ACTIVATABLE", "wxDATAVIEW_CELL_EDITABLE"}); Add(_("wxDataViewListCtrl Column")); Add(PROP_NAME, _("My Column"), _("Column Caption")); @@ -52,39 +51,39 @@ wxString DataViewListCtrlColumn::CppCtorCode() const wxString colFlag = PropertyString(PROP_COL_FLAGS, "0"); wxString columnWidth; columnWidth << "WXC_FROM_DIP(" << PropertyString(PROP_WIDTH) << ")"; - if(coltype == "bitmap") { + if (coltype == "bitmap") { cppCode << parentName << "->AppendBitmapColumn(" << label << ", " << parentName << "->GetColumnCount(), " << cellMode << ", " << columnWidth << ", " << alignstring << ", " << colFlag << ");"; - } else if(coltype == "check") { + } else if (coltype == "check") { cppCode << parentName << "->AppendToggleColumn(" << label << ", "; - if(!childOfDataViewListCtrl) + if (!childOfDataViewListCtrl) cppCode << parentName << "->GetColumnCount(), "; cppCode << cellMode << ", " << columnWidth << ", " << alignstring << ", " << colFlag << ");"; - } else if(coltype == "text") { + } else if (coltype == "text") { cppCode << parentName << "->AppendTextColumn(" << label << ", "; - if(!childOfDataViewListCtrl) + if (!childOfDataViewListCtrl) cppCode << parentName << "->GetColumnCount(), "; cppCode << cellMode << ", " << columnWidth << ", " << alignstring << ", " << colFlag << ");"; - } else if(coltype == "icontext") { + } else if (coltype == "icontext") { cppCode << parentName << "->AppendIconTextColumn(" << label << ", "; - if(!childOfDataViewListCtrl) + if (!childOfDataViewListCtrl) cppCode << parentName << "->GetColumnCount(), "; cppCode << cellMode << ", " << columnWidth << ", " << alignstring << ", " << colFlag << ");"; - } else if(coltype == "progress") { + } else if (coltype == "progress") { cppCode << parentName << "->AppendProgressColumn(" << label << ", "; - if(!childOfDataViewListCtrl) + if (!childOfDataViewListCtrl) cppCode << parentName << "->GetColumnCount(), "; cppCode << cellMode << ", " << columnWidth << ", " << alignstring << ", " << colFlag << ");"; - } else if(coltype == "choice") { + } else if (coltype == "choice") { cppCode << "{\n"; cppCode << " wxArrayString choices;\n"; wxArrayString choices = ::wxStringTokenize(PropertyString(PROP_OPTIONS), ";", wxTOKEN_STRTOK); - for(size_t i = 0; i < choices.GetCount(); ++i) { + for (size_t i = 0; i < choices.GetCount(); ++i) { cppCode << " choices.Add(" << wxCrafter::UNDERSCORE(choices.Item(i)) << ");\n"; } cppCode << " " << parentName << "->AppendColumn( new wxDataViewColumn( " << label @@ -102,7 +101,7 @@ wxString DataViewListCtrlColumn::GetWxClassName() const { return ""; } void DataViewListCtrlColumn::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == wxcWidget::XRC_LIVE) { + if (type == wxcWidget::XRC_LIVE) { text << XRCUnknown(); } else { text << wxT("") << wxT("") diff --git a/wxcrafter/controls/data_view_list_ctrl_wrapper.cpp b/wxcrafter/controls/data_view_list_ctrl_wrapper.cpp index 63460838de..d843f91862 100644 --- a/wxcrafter/controls/data_view_list_ctrl_wrapper.cpp +++ b/wxcrafter/controls/data_view_list_ctrl_wrapper.cpp @@ -15,46 +15,63 @@ DataViewListCtrlWrapper::DataViewListCtrlWrapper() PREPEND_STYLE(wxDV_VARIABLE_LINE_HEIGHT, false); PREPEND_STYLE(wxDV_NO_HEADER, false); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.\nThis event is triggered by double " "clicking an item or pressing some special key (usually \"Enter\") when it is focused")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING event.\nThis event can be vetoed in order to " "prevent editing on an item by item basis")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event generated when the user right clicks " "inside the control.\nNotice that this menu is generated even if the click didn't occur on any " "valid item, in this case wxDataViewEvent::GetItem() simply returns an invalid item.")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_DROP", "wxDataViewEvent", - _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP event")); + RegisterEvent( + "wxEVT_COMMAND_DATAVIEW_ITEM_DROP", "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP event")); SetPropertyString(_("Common Settings"), "wxDataViewListCtrl"); m_namePattern = "m_dvListCtrl"; @@ -76,7 +93,7 @@ wxString DataViewListCtrlWrapper::GetWxClassName() const { return "wxDataViewLis void DataViewListCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << XRCUnknown(); } else { diff --git a/wxcrafter/controls/data_view_tree_ctrl_wrapper.cpp b/wxcrafter/controls/data_view_tree_ctrl_wrapper.cpp index 1a09766cde..57b176aa2f 100644 --- a/wxcrafter/controls/data_view_tree_ctrl_wrapper.cpp +++ b/wxcrafter/controls/data_view_tree_ctrl_wrapper.cpp @@ -16,46 +16,63 @@ DataViewTreeCtrlWrapper::DataViewTreeCtrlWrapper() PREPEND_STYLE(wxDV_VARIABLE_LINE_HEIGHT, false); PREPEND_STYLE(wxDV_NO_HEADER, false); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.\nThis event is triggered by double " "clicking an item or pressing some special key (usually \"Enter\") when it is focused")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING event.\nThis event can be vetoed in order to " "prevent editing on an item by item basis")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event generated when the user right clicks " "inside the control.\nNotice that this menu is generated even if the click didn't occur on any " "valid item, in this case wxDataViewEvent::GetItem() simply returns an invalid item.")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_DROP", "wxDataViewEvent", - _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP event")); + RegisterEvent( + "wxEVT_COMMAND_DATAVIEW_ITEM_DROP", "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP event")); SetPropertyString(_("Common Settings"), "wxDataViewTreeCtrl"); DelProperty(_("Control Specific Settings")); @@ -78,7 +95,7 @@ wxString DataViewTreeCtrlWrapper::GetWxClassName() const { return "wxDataViewTre void DataViewTreeCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << XRCUnknown(); } else { diff --git a/wxcrafter/controls/data_view_tree_list_ctrl_wrapper.cpp b/wxcrafter/controls/data_view_tree_list_ctrl_wrapper.cpp index e173753aeb..6e519973d7 100644 --- a/wxcrafter/controls/data_view_tree_list_ctrl_wrapper.cpp +++ b/wxcrafter/controls/data_view_tree_list_ctrl_wrapper.cpp @@ -21,46 +21,63 @@ DataViewTreeListCtrlWrapper::DataViewTreeListCtrlWrapper() PREPEND_STYLE(wxDV_VARIABLE_LINE_HEIGHT, false); PREPEND_STYLE(wxDV_NO_HEADER, false); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED event.\nThis event is triggered by double " "clicking an item or pressing some special key (usually \"Enter\") when it is focused")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_START_EDITING event.\nThis event can be vetoed in order to " "prevent editing on an item by item basis")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU event generated when the user right clicks " "inside the control.\nNotice that this menu is generated even if the click didn't occur on any " "valid item, in this case wxDataViewEvent::GetItem() simply returns an invalid item.")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE", "wxDataViewEvent", + RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE", + "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE event")); - RegisterEvent("wxEVT_COMMAND_DATAVIEW_ITEM_DROP", "wxDataViewEvent", - _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP event")); + RegisterEvent( + "wxEVT_COMMAND_DATAVIEW_ITEM_DROP", "wxDataViewEvent", _("Process a wxEVT_COMMAND_DATAVIEW_ITEM_DROP event")); m_namePattern = "m_dataview"; SetName(GenerateName()); @@ -77,7 +94,7 @@ DataViewTreeListCtrlWrapper::DataViewTreeListCtrlWrapper() wxString name = GetName(); // Using the plain name here, e.g. m_dataview13, creates code that won't compile: // wxObjectDataPtr m_dataview13Model; - if(name.Left(2) == "m_") { + if (name.Left(2) == "m_") { name = name.Mid(2); } Add(PROP_DV_MODEL_CLASS_NAME, name + "Model", tip); @@ -101,7 +118,7 @@ void DataViewTreeListCtrlWrapper::GetIncludeFile(wxArrayString& headers) const headers.Add("#include "); wxString modelName = GetModelName(); - if(modelName.IsEmpty()) { + if (modelName.IsEmpty()) { return; } @@ -119,14 +136,14 @@ wxString DataViewTreeListCtrlWrapper::GetWxClassName() const { return "wxDataVie void DataViewTreeListCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << XRCUnknown(); } else { text << ""; @@ -143,7 +160,7 @@ void DataViewTreeListCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const void DataViewTreeListCtrlWrapper::GenerateAdditionalFiles(wxStringMap_t& extraFile) const { wxString modelName = GetModelName(); - if(modelName.IsEmpty()) { + if (modelName.IsEmpty()) { return; } @@ -185,7 +202,7 @@ wxString DataViewTreeListCtrlWrapper::DoGenerateClassMember() const members << wxcWidget::DoGenerateClassMember(); wxString modelName = GetModelName(); - if(modelName.IsEmpty()) { + if (modelName.IsEmpty()) { return members; } @@ -198,7 +215,7 @@ wxString DataViewTreeListCtrlWrapper::DoGenerateClassMember() const wxString DataViewTreeListCtrlWrapper::AssociateModelCode() const { wxString modelBaseName = GetModelName(); - if(modelBaseName.IsEmpty()) { + if (modelBaseName.IsEmpty()) { return ""; } diff --git a/wxcrafter/controls/date_picker_ctrl.cpp b/wxcrafter/controls/date_picker_ctrl.cpp index 3195c9fb1c..c16328fe8c 100644 --- a/wxcrafter/controls/date_picker_ctrl.cpp +++ b/wxcrafter/controls/date_picker_ctrl.cpp @@ -1,6 +1,8 @@ #include "date_picker_ctrl.h" + #include "allocator_mgr.h" #include "wxgui_defs.h" + #include DatePickerCtrl::DatePickerCtrl() @@ -12,7 +14,8 @@ DatePickerCtrl::DatePickerCtrl() PREPEND_STYLE_FALSE(wxDP_ALLOWNONE); PREPEND_STYLE_FALSE(wxDP_SHOWCENTURY); - RegisterEvent(wxT("wxEVT_DATE_CHANGED"), wxT("wxDateEvent"), + RegisterEvent(wxT("wxEVT_DATE_CHANGED"), + wxT("wxDateEvent"), _("This event fires when the user changes the current selection in the control.")); m_namePattern = wxT("m_datePicker"); SetName(GenerateName()); diff --git a/wxcrafter/controls/dir_picker_ctrl_wrapper.cpp b/wxcrafter/controls/dir_picker_ctrl_wrapper.cpp index 3c3007a82e..055f0255ed 100644 --- a/wxcrafter/controls/dir_picker_ctrl_wrapper.cpp +++ b/wxcrafter/controls/dir_picker_ctrl_wrapper.cpp @@ -21,7 +21,8 @@ DirPickerCtrlWrapper::DirPickerCtrlWrapper() PREPEND_STYLE(wxDIRP_DEFAULT_STYLE, true); PREPEND_STYLE(wxDIRP_SMALL, true); - RegisterEvent(wxT("wxEVT_COMMAND_DIRPICKER_CHANGED"), wxT("wxFileDirPickerEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_DIRPICKER_CHANGED"), + wxT("wxFileDirPickerEvent"), _("The user changed the directory selected in the control either using the button or using text " "control\n(see wxDIRP_USE_TEXTCTRL; note that in this case the event is fired only if the user's " "input is valid, e.g. an existing directory path).")); @@ -65,10 +66,14 @@ void DirPickerCtrlWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, "message"); - if(propertynode) { SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); + } } void DirPickerCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -77,10 +82,14 @@ void DirPickerCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("path")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, "message"); - if(propertynode) { SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); + } } void DirPickerCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -89,8 +98,12 @@ void DirPickerCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "value"); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "message"); - if(propertynode) { SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/file_picker_ctrl_wrapper.cpp b/wxcrafter/controls/file_picker_ctrl_wrapper.cpp index 5f67c3544a..168a236121 100644 --- a/wxcrafter/controls/file_picker_ctrl_wrapper.cpp +++ b/wxcrafter/controls/file_picker_ctrl_wrapper.cpp @@ -26,7 +26,8 @@ FilePickerCtrlWrapper::FilePickerCtrlWrapper() PREPEND_STYLE(wxFLP_USE_TEXTCTRL, false); PREPEND_STYLE(wxFLP_DEFAULT_STYLE, true); - RegisterEvent(wxT("wxEVT_COMMAND_FILEPICKER_CHANGED"), wxT("wxFileDirPickerEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_FILEPICKER_CHANGED"), + wxT("wxFileDirPickerEvent"), _("The user changed the file selected in the control either using the button or using text " "control\n(see wxFLP_USE_TEXTCTRL; note that in this case the event is fired\nonly if the user's " "input is valid, e.g. an existing file path if wxFLP_FILE_MUST_EXIST was given).")); @@ -72,13 +73,19 @@ void FilePickerCtrlWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, "message"); - if(propertynode) { SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, "wildcard"); - if(propertynode) { SetPropertyString(PROP_WILDCARD, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_WILDCARD, propertynode->GetNodeContent()); + } } void FilePickerCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -87,13 +94,19 @@ void FilePickerCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("path")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, "message"); - if(propertynode) { SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, "wildcard"); - if(propertynode) { SetPropertyString(PROP_WILDCARD, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_WILDCARD, propertynode->GetNodeContent()); + } } void FilePickerCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -102,11 +115,17 @@ void FilePickerCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "value"); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "message"); - if(propertynode) { SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MESSAGE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "wildcard"); - if(propertynode) { SetPropertyString(PROP_WILDCARD, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_WILDCARD, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/font_picker_ctrl_wrapper.cpp b/wxcrafter/controls/font_picker_ctrl_wrapper.cpp index 3f26e9d85d..982d816839 100644 --- a/wxcrafter/controls/font_picker_ctrl_wrapper.cpp +++ b/wxcrafter/controls/font_picker_ctrl_wrapper.cpp @@ -19,7 +19,8 @@ FontPickerCtrlWrapper::FontPickerCtrlWrapper() PREPEND_STYLE(wxFNTP_USEFONT_FOR_LABEL, false); PREPEND_STYLE(wxFNTP_DEFAULT_STYLE, true); - RegisterEvent(wxT("wxEVT_COMMAND_FONTPICKER_CHANGED"), wxT("wxFontPickerEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_FONTPICKER_CHANGED"), + wxT("wxFontPickerEvent"), _("Generated whenever the selected font changes.")); Add(PROP_VALUE, wxEmptyString, _("Initial font")); m_namePattern = wxT("m_fontPicker"); @@ -33,7 +34,7 @@ wxString FontPickerCtrlWrapper::CppCtorCode() const wxString code; wxString fontCode; wxString fontMemberName = GetName() + wxT("Font"); - if(wxCrafter::FontToCpp(PropertyString(PROP_VALUE), fontMemberName) != wxT("wxNullFont")) { + if (wxCrafter::FontToCpp(PropertyString(PROP_VALUE), fontMemberName) != wxT("wxNullFont")) { code << wxCrafter::FontToCpp(PropertyString(PROP_VALUE), fontMemberName); fontCode = fontMemberName; @@ -68,7 +69,9 @@ void FontPickerCtrlWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, wxCrafter::XRCToFontstring(propertynode)); } + if (propertynode) { + SetPropertyString(PROP_VALUE, wxCrafter::XRCToFontstring(propertynode)); + } } void FontPickerCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -77,7 +80,9 @@ void FontPickerCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, wxCrafter::XRCToFontstring(propertynode)); } + if (propertynode) { + SetPropertyString(PROP_VALUE, wxCrafter::XRCToFontstring(propertynode)); + } } void FontPickerCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -86,8 +91,10 @@ void FontPickerCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "value"); - if(propertynode) { + if (propertynode) { wxString fontasstring = wxCrafter::FBToFontstring(propertynode->GetNodeContent()); - if(!fontasstring.empty()) { SetPropertyString(PROP_VALUE, fontasstring); } + if (!fontasstring.empty()) { + SetPropertyString(PROP_VALUE, fontasstring); + } } } diff --git a/wxcrafter/controls/gauge_wrapper.cpp b/wxcrafter/controls/gauge_wrapper.cpp index 27b27a872d..254476bd79 100644 --- a/wxcrafter/controls/gauge_wrapper.cpp +++ b/wxcrafter/controls/gauge_wrapper.cpp @@ -59,10 +59,14 @@ void GaugeWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("range")); - if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void GaugeWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -71,10 +75,14 @@ void GaugeWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("range")); - if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void GaugeWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -83,8 +91,12 @@ void GaugeWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "range"); - if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "value"); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/generic_dir_ctrl_wrapper.cpp b/wxcrafter/controls/generic_dir_ctrl_wrapper.cpp index 4fb4fc37a1..f13290607f 100644 --- a/wxcrafter/controls/generic_dir_ctrl_wrapper.cpp +++ b/wxcrafter/controls/generic_dir_ctrl_wrapper.cpp @@ -25,43 +25,57 @@ GenericDirCtrlWrapper::GenericDirCtrlWrapper() PREPEND_STYLE_FALSE(wxDIRCTRL_SHOW_FILTERS); PREPEND_STYLE_FALSE(wxDIRCTRL_EDIT_LABELS); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_DRAG"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_DRAG"), + wxT("wxTreeEvent"), _("The user has started dragging an item with the left mouse button.\nThe event handler must call " - "wxTreeEvent::Allow() for the drag operation to continue.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_RDRAG"), wxT("wxTreeEvent"), + "wxTreeEvent::Allow() for the drag operation to continue.")); + RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_RDRAG"), + wxT("wxTreeEvent"), _("The user has started dragging an item with the right mouse button.\nThe event handler must call " - "wxTreeEvent::Allow() for the drag operation to continue.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_END_DRAG"), wxT("wxTreeEvent"), + "wxTreeEvent::Allow() for the drag operation to continue.")); + RegisterEvent(wxT("wxEVT_COMMAND_TREE_END_DRAG"), + wxT("wxTreeEvent"), _("The user has released the mouse after dragging an item.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT"), + wxT("wxTreeEvent"), _("Begin editing a label. This can be prevented by calling Veto().")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_END_LABEL_EDIT"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_END_LABEL_EDIT"), + wxT("wxTreeEvent"), _("The user has finished editing a label. This can be prevented by calling Veto().")); RegisterEvent(wxT("wxEVT_COMMAND_TREE_DELETE_ITEM"), wxT("wxTreeEvent"), _("A tree item has been deleted.")); RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_EXPANDED"), wxT("wxTreeEvent"), _("The item has been expanded.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_EXPANDING"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_EXPANDING"), + wxT("wxTreeEvent"), _("The item is being expanded. This can be prevented by calling Veto().")); RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_COLLAPSED"), wxT("wxTreeEvent"), _("The item has been collapsed.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_COLLAPSING"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_COLLAPSING"), + wxT("wxTreeEvent"), _("The item is being collapsed. This can be prevented by calling Veto().")); RegisterEvent(wxT("wxEVT_COMMAND_TREE_SEL_CHANGED"), wxT("wxTreeEvent"), _("Selection has changed.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_SEL_CHANGING"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_SEL_CHANGING"), + wxT("wxTreeEvent"), _("Selection is changing. This can be prevented by calling Veto().")); RegisterEvent(wxT("wxEVT_COMMAND_TREE_KEY_DOWN"), wxT("wxTreeEvent"), _("A key has been pressed.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_ACTIVATED"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_ACTIVATED"), + wxT("wxTreeEvent"), _("An item has been activated (e.g. double clicked).")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK"), + wxT("wxTreeEvent"), _("The user has clicked the item with the right mouse button.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK"), + wxT("wxTreeEvent"), _("The user has clicked the item with the middle mouse button.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK"), + wxT("wxTreeEvent"), _("The state image has been clicked. Windows only.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP"), + wxT("wxTreeEvent"), _("The opportunity to set the item tooltip is being given to the application\n (call " - "wxTreeEvent::SetToolTip). Windows only.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_MENU"), wxT("wxTreeEvent"), + "wxTreeEvent::SetToolTip). Windows only.")); + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_MENU"), + wxT("wxTreeEvent"), _("The context menu for the selected item has been requested,\neither by a right click or by using " - "the menu key.")); + "the menu key.")); m_namePattern = wxT("m_genericDirCtrl"); SetName(GenerateName()); @@ -87,7 +101,7 @@ wxString GenericDirCtrlWrapper::CppCtorCode() const wxString path = PropertyString(PROP_DEFAULT_FOLDER); path.Trim().Trim(false); - if(path.IsEmpty() == false) { + if (path.IsEmpty() == false) { code << GetName() << wxT("->SetDefaultPath(") << wxCrafter::WXT(path) << wxT(");\n"); } @@ -95,14 +109,18 @@ wxString GenericDirCtrlWrapper::CppCtorCode() const wxString filter = PropertyString(PROP_FILTER); filter.Trim().Trim(false); - if(filter.IsEmpty() == false) { code << GetName() << wxT("->SetFilter(") << wxCrafter::WXT(filter) << wxT(");\n"); } + if (filter.IsEmpty() == false) { + code << GetName() << wxT("->SetFilter(") << wxCrafter::WXT(filter) << wxT(");\n"); + } // Set the filter index wxString filterIndex = PropertyString(PROP_DEFAULT_FILTER); filterIndex.Trim().Trim(false); int index = wxCrafter::ToNumber(filterIndex, -1); - if(-1 != index) { code << GetName() << wxT("->SetFilterIndex(") << index << wxT(");\n"); } + if (-1 != index) { + code << GetName() << wxT("->SetFilterIndex(") << index << wxT(");\n"); + } // Show hidden files? wxString show = PropertyBool(PROP_SHOW_HIDDEN); @@ -132,13 +150,19 @@ void GenericDirCtrlWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("defaultfolder")); - if(propertynode) { SetPropertyString(PROP_DEFAULT_FOLDER, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_FOLDER, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("filter")); - if(propertynode) { SetPropertyString(PROP_FILTER, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_FILTER, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("defaultfilter")); - if(propertynode) { SetPropertyString(PROP_DEFAULT_FILTER, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_FILTER, propertynode->GetNodeContent()); + } } void GenericDirCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -147,13 +171,19 @@ void GenericDirCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("defaultfolder")); - if(propertynode) { SetPropertyString(PROP_DEFAULT_FOLDER, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_FOLDER, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("filter")); - if(propertynode) { SetPropertyString(PROP_FILTER, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_FILTER, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("defaultfilter")); - if(propertynode) { SetPropertyString(PROP_DEFAULT_FILTER, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_FILTER, propertynode->GetNodeContent()); + } } void GenericDirCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -162,17 +192,25 @@ void GenericDirCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "defaultfolder"); - if(propertynode) { SetPropertyString(PROP_DEFAULT_FOLDER, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_FOLDER, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "filter"); - if(propertynode) { SetPropertyString(PROP_FILTER, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_FILTER, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "defaultfilter"); - if(propertynode) { SetPropertyString(PROP_DEFAULT_FILTER, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_FILTER, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "show_hidden"); - if(propertynode) { + if (propertynode) { PropertyBase* prop = GetProperty(PROP_SHOW_HIDDEN); - if(prop) { prop->SetValue(propertynode->GetNodeContent()); } + if (prop) { + prop->SetValue(propertynode->GetNodeContent()); + } } } diff --git a/wxcrafter/controls/gl_canvas_wrapper.cpp b/wxcrafter/controls/gl_canvas_wrapper.cpp index 4e41088cf5..6fafeb8d10 100644 --- a/wxcrafter/controls/gl_canvas_wrapper.cpp +++ b/wxcrafter/controls/gl_canvas_wrapper.cpp @@ -79,9 +79,9 @@ wxString GLCanvasWrapper::CppCtorCode() const wxArrayString validAttrsName, validAttrsValue; // get the number of attributes provided int bufferSize = 0; - for(size_t i = 0; i < m_attrs.GetCount(); ++i) { + for (size_t i = 0; i < m_attrs.GetCount(); ++i) { wxString v = PropertyString(m_attrs.Item(i)); - if(!v.Trim().Trim(false).IsEmpty()) { + if (!v.Trim().Trim(false).IsEmpty()) { bufferSize += 2; // one for the property and one for its value validAttrsName.Add(m_attrs.Item(i)); validAttrsValue.Add(v); @@ -90,7 +90,7 @@ wxString GLCanvasWrapper::CppCtorCode() const wxString AttrName; AttrName << GetName() << "Attr"; - if(bufferSize) { + if (bufferSize) { bufferSize++; // terminator attrList << "int *" << AttrName << " = new int[ " << bufferSize << " ];\n"; } else { @@ -98,14 +98,18 @@ wxString GLCanvasWrapper::CppCtorCode() const } int idx = 0; - for(size_t i = 0; i < validAttrsName.GetCount(); ++i) { + for (size_t i = 0; i < validAttrsName.GetCount(); ++i) { attrList << AttrName << "[" << idx++ << "] = " << validAttrsName.Item(i) << ";\n"; attrList << AttrName << "[" << idx++ << "] = " << validAttrsValue.Item(i) << ";\n"; } - if(validAttrsName.GetCount()) { attrList << AttrName << "[" << idx << "] = 0;\n"; } + if (validAttrsName.GetCount()) { + attrList << AttrName << "[" << idx << "] = 0;\n"; + } - if(!attrList.IsEmpty()) { cppCode << attrList; } + if (!attrList.IsEmpty()) { + cppCode << attrList; + } cppCode << GetName() << " = new " << GetRealClassName() << "(" << GetWindowParent() << ", " << GetId() << ", " << AttrName << ", " @@ -121,7 +125,7 @@ wxString GLCanvasWrapper::GetWxClassName() const { return "wxGLCanvas"; } void GLCanvasWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << XRCUnknown(); } else { diff --git a/wxcrafter/controls/html_window_wrapper.cpp b/wxcrafter/controls/html_window_wrapper.cpp index 57e53dbf47..6b071e465c 100644 --- a/wxcrafter/controls/html_window_wrapper.cpp +++ b/wxcrafter/controls/html_window_wrapper.cpp @@ -20,9 +20,10 @@ HtmlWindowWrapper::HtmlWindowWrapper() Add(PROP_URL, wxT(""), _("URL to load")); RegisterEvent(wxT("wxEVT_COMMAND_HTML_CELL_CLICKED"), wxT("wxHtmlCellEvent"), _("A wxHtmlCell was clicked.")); - RegisterEvent(wxT("wxEVT_COMMAND_HTML_CELL_HOVER"), wxT("wxHtmlCellEvent"), - _("The mouse passed over a wxHtmlCell.")); - RegisterEvent(wxT("wxEVT_COMMAND_HTML_LINK_CLICKED"), wxT("wxHtmlLinkEvent"), + RegisterEvent( + wxT("wxEVT_COMMAND_HTML_CELL_HOVER"), wxT("wxHtmlCellEvent"), _("The mouse passed over a wxHtmlCell.")); + RegisterEvent(wxT("wxEVT_COMMAND_HTML_LINK_CLICKED"), + wxT("wxHtmlLinkEvent"), _("A wxHtmlCell which contains an hyperlink was clicked.")); m_namePattern = wxT("m_htmlWin"); @@ -38,11 +39,15 @@ wxString HtmlWindowWrapper::CppCtorCode() const wxString htmlCode = PropertyString(PROP_HTMLCODE); htmlCode.Trim().Trim(false); - if(htmlCode.IsEmpty() == false) { code << GetName() << wxT("->SetPage(") << wxCrafter::WXT(htmlCode) << wxT(");\n"); } + if (htmlCode.IsEmpty() == false) { + code << GetName() << wxT("->SetPage(") << wxCrafter::WXT(htmlCode) << wxT(");\n"); + } wxString url = PropertyFile(PROP_URL); url.Trim().Trim(false); - if(url.IsEmpty() == false) { code << GetName() << wxT("->LoadPage(") << wxCrafter::WXT(url) << wxT(");\n"); } + if (url.IsEmpty() == false) { + code << GetName() << wxT("->LoadPage(") << wxCrafter::WXT(url) << wxT(");\n"); + } code << CPPCommonAttributes(); return code; @@ -61,7 +66,9 @@ void HtmlWindowWrapper::ToXRC(wxString& text, XRC_TYPE type) const wxString html = PropertyString(PROP_HTMLCODE); html.Trim().Trim(false); - if(html.IsEmpty() == false) { text << wxT(""); } + if (html.IsEmpty() == false) { + text << wxT(""); + } text << XRCSuffix(); } @@ -71,10 +78,14 @@ void HtmlWindowWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("htmlcode")); - if(propertynode) { SetPropertyString(PROP_HTMLCODE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_HTMLCODE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("url")); - if(propertynode) { SetPropertyString(PROP_URL, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_URL, propertynode->GetNodeContent()); + } } void HtmlWindowWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -83,10 +94,14 @@ void HtmlWindowWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("htmlcode")); - if(propertynode) { SetPropertyString(PROP_HTMLCODE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_HTMLCODE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("url")); - if(propertynode) { SetPropertyString(PROP_URL, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_URL, propertynode->GetNodeContent()); + } } // wxFB doesn't do anything useful for this diff --git a/wxcrafter/controls/hyper_link_ctrl_wrapper.cpp b/wxcrafter/controls/hyper_link_ctrl_wrapper.cpp index f6260a518c..d42b18d3e3 100644 --- a/wxcrafter/controls/hyper_link_ctrl_wrapper.cpp +++ b/wxcrafter/controls/hyper_link_ctrl_wrapper.cpp @@ -18,7 +18,8 @@ HyperLinkCtrlWrapper::HyperLinkCtrlWrapper() PREPEND_STYLE_FALSE(wxHL_CONTEXTMENU); PREPEND_STYLE_TRUE(wxHL_DEFAULT_STYLE); - RegisterEvent(wxT("wxEVT_COMMAND_HYPERLINK"), wxT("wxHyperlinkEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_HYPERLINK"), + wxT("wxHyperlinkEvent"), _("The hyperlink was (left) clicked. If this event is not handled in user's code (or it's skipped; " "see wxEvent::Skip)\nthen a call to wxLaunchDefaultBrowser is done with the hyperlink's URL.")); @@ -55,13 +56,19 @@ wxString HyperLinkCtrlWrapper::CppCtorCode() const code << CPPCommonAttributes(); wxString color; color = wxCrafter::ColourToCpp(PropertyString(PROP_NORMAL_COLOR)); - if(color.IsEmpty() == false) { code << GetName() << wxT("->SetNormalColour(") << color << wxT(");\n"); } + if (color.IsEmpty() == false) { + code << GetName() << wxT("->SetNormalColour(") << color << wxT(");\n"); + } color = wxCrafter::ColourToCpp(PropertyString(PROP_HOVER_COLOR)); - if(color.IsEmpty() == false) { code << GetName() << wxT("->SetHoverColour(") << color << wxT(");\n"); } + if (color.IsEmpty() == false) { + code << GetName() << wxT("->SetHoverColour(") << color << wxT(");\n"); + } color = wxCrafter::ColourToCpp(PropertyString(PROP_VISITED_COLOR)); - if(color.IsEmpty() == false) { code << GetName() << wxT("->SetVisitedColour(") << color << wxT(");\n"); } + if (color.IsEmpty() == false) { + code << GetName() << wxT("->SetVisitedColour(") << color << wxT(");\n"); + } return code; } @@ -83,7 +90,9 @@ void HyperLinkCtrlWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); // Baseclass stuff first wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("url")); - if(propertynode) { SetPropertyString(PROP_URL, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_URL, propertynode->GetNodeContent()); + } // XRC doesn't seem to do the other properties } @@ -92,16 +101,24 @@ void HyperLinkCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); // Baseclass stuff first wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("url")); - if(propertynode) { SetPropertyString(PROP_URL, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_URL, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("normal_color")); - if(propertynode) { SetPropertyString(PROP_NORMAL_COLOR, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_NORMAL_COLOR, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("hover_color")); - if(propertynode) { SetPropertyString(PROP_HOVER_COLOR, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_HOVER_COLOR, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("visited_color")); - if(propertynode) { SetPropertyString(PROP_VISITED_COLOR, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VISITED_COLOR, propertynode->GetNodeContent()); + } } void HyperLinkCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -110,23 +127,31 @@ void HyperLinkCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "url"); - if(propertynode) { SetPropertyString(PROP_URL, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_URL, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "hover_color"); - if(propertynode) { + if (propertynode) { wxString col = wxCrafter::ValueToColourString(propertynode->GetNodeContent()); - if(!col.empty()) { SetPropertyString(PROP_HOVER_COLOR, col); } + if (!col.empty()) { + SetPropertyString(PROP_HOVER_COLOR, col); + } } propertynode = XmlUtils::FindNodeByName(node, "property", "normal_color"); - if(propertynode) { + if (propertynode) { wxString col = wxCrafter::ValueToColourString(propertynode->GetNodeContent()); - if(!col.empty()) { SetPropertyString(PROP_NORMAL_COLOR, col); } + if (!col.empty()) { + SetPropertyString(PROP_NORMAL_COLOR, col); + } } propertynode = XmlUtils::FindNodeByName(node, "property", "visited_color"); - if(propertynode) { + if (propertynode) { wxString col = wxCrafter::ValueToColourString(propertynode->GetNodeContent()); - if(!col.empty()) { SetPropertyString(PROP_VISITED_COLOR, col); } + if (!col.empty()) { + SetPropertyString(PROP_VISITED_COLOR, col); + } } } diff --git a/wxcrafter/controls/info_bar_button_wrapper.cpp b/wxcrafter/controls/info_bar_button_wrapper.cpp index 35abedb3bb..efbe53505f 100644 --- a/wxcrafter/controls/info_bar_button_wrapper.cpp +++ b/wxcrafter/controls/info_bar_button_wrapper.cpp @@ -22,7 +22,8 @@ InfoBarButtonWrapper::InfoBarButtonWrapper() _("The label of the button. It may only be empty if the button ID is one of the stock ids " "in which case the corresponding stock label (see wxGetStockLabel()) will be used")); - RegisterEvent(wxT("wxEVT_COMMAND_BUTTON_CLICKED"), wxT("wxCommandEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_BUTTON_CLICKED"), + wxT("wxCommandEvent"), _("Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked."), wxT("wxCommandEventHandler")); diff --git a/wxcrafter/controls/info_bar_wrapper.cpp b/wxcrafter/controls/info_bar_wrapper.cpp index ec3efc653a..371124b0a8 100644 --- a/wxcrafter/controls/info_bar_wrapper.cpp +++ b/wxcrafter/controls/info_bar_wrapper.cpp @@ -28,7 +28,7 @@ wxString InfoBarWrapper::GetWxClassName() const { return "wxInfoBar"; } void InfoBarWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << XRCUnknown(); } else { diff --git a/wxcrafter/controls/list_book_wrapper.cpp b/wxcrafter/controls/list_book_wrapper.cpp index 7e68cb9c22..427faef8c3 100644 --- a/wxcrafter/controls/list_book_wrapper.cpp +++ b/wxcrafter/controls/list_book_wrapper.cpp @@ -1,6 +1,8 @@ #include "list_book_wrapper.h" + #include "allocator_mgr.h" #include "wxgui_defs.h" + #include ListBookWrapper::ListBookWrapper() @@ -13,9 +15,10 @@ ListBookWrapper::ListBookWrapper() PREPEND_STYLE_FALSE(wxLB_TOP); PREPEND_STYLE_FALSE(wxLB_BOTTOM); - RegisterEvent(wxT("wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED"), wxT("wxListbookEvent"), - _("The page selection was changed")); - RegisterEvent(wxT("wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING"), wxT("wxListbookEvent"), + RegisterEvent( + wxT("wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED"), wxT("wxListbookEvent"), _("The page selection was changed")); + RegisterEvent(wxT("wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING"), + wxT("wxListbookEvent"), _("The page selection is about to be changed. This event can be vetoed")); m_namePattern = wxT("m_listbook"); SetName(GenerateName()); diff --git a/wxcrafter/controls/list_box_wrapper.cpp b/wxcrafter/controls/list_box_wrapper.cpp index 96a0e9440d..2a2b7e69ce 100644 --- a/wxcrafter/controls/list_box_wrapper.cpp +++ b/wxcrafter/controls/list_box_wrapper.cpp @@ -22,9 +22,8 @@ ListBoxWrapper::ListBoxWrapper() RegisterEventCommand(wxT("wxEVT_COMMAND_LISTBOX_SELECTED"), _("Process a wxEVT_COMMAND_LISTBOX_SELECTED event, when an item on the list is selected or " "the selection changes.")); - RegisterEventCommand( - wxT("wxEVT_COMMAND_LISTBOX_DOUBLECLICKED"), - _("Process a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event, when the listbox is double-clicked.")); + RegisterEventCommand(wxT("wxEVT_COMMAND_LISTBOX_DOUBLECLICKED"), + _("Process a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event, when the listbox is double-clicked.")); SetPropertyString(_("Common Settings"), "wxListBox"); Add(PROP_OPTIONS, _("The List Box Items. A semi-colon list of strings")); @@ -48,7 +47,7 @@ wxString ListBoxWrapper::CppCtorCode() const optionsArr << GetName() << wxT("Arr"); code << wxT("wxArrayString ") << optionsArr << wxT(";\n"); - for(size_t i = 0; i < options.GetCount(); i++) { + for (size_t i = 0; i < options.GetCount(); i++) { code << optionsArr << wxT(".Add(") << wxCrafter::UNDERSCORE(options.Item(i)) << wxT(");\n"); } @@ -58,7 +57,7 @@ wxString ListBoxWrapper::CppCtorCode() const code << CPPCommonAttributes(); int sel = wxCrafter::ToNumber(PropertyString(PROP_SELECTION), -1); - if(sel >= 0 && sel < (int)options.GetCount()) { + if (sel >= 0 && sel < (int)options.GetCount()) { code << GetName() << wxT("->SetSelection(") << PropertyString(PROP_SELECTION) << wxT(");\n"); } return code; @@ -81,10 +80,14 @@ void ListBoxWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("content")); - if(propertynode) { SetPropertyString(PROP_OPTIONS, XmlUtils::ChildNodesContentToString(propertynode)); } + if (propertynode) { + SetPropertyString(PROP_OPTIONS, XmlUtils::ChildNodesContentToString(propertynode)); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("selection")); - if(propertynode) { SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); + } } void ListBoxWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -93,10 +96,14 @@ void ListBoxWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("default")); - if(propertynode) { SetPropertyString(PROP_OPTIONS, XmlUtils::ChildNodesContentToString(propertynode)); } + if (propertynode) { + SetPropertyString(PROP_OPTIONS, XmlUtils::ChildNodesContentToString(propertynode)); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("selection")); - if(propertynode) { SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); + } } void ListBoxWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -105,7 +112,7 @@ void ListBoxWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "choices"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_OPTIONS, ImportFromwxFB::ConvertFBOptionsString(propertynode->GetNodeContent())); } diff --git a/wxcrafter/controls/list_ctrl_column_wrapper.cpp b/wxcrafter/controls/list_ctrl_column_wrapper.cpp index 0c2bb64cad..96dbaa1afd 100644 --- a/wxcrafter/controls/list_ctrl_column_wrapper.cpp +++ b/wxcrafter/controls/list_ctrl_column_wrapper.cpp @@ -29,7 +29,8 @@ wxString ListCtrlColumnWrapper::CppCtorCode() const { wxString cppCode; cppCode << GetWindowParent() << wxT("->InsertColumn(") << GetWindowParent() << wxT("->GetColumnCount(), ") - << wxCrafter::UNDERSCORE(GetName()) << wxT(", ") << wxT("wxLIST_FORMAT_LEFT, ") << PropertyString(PROP_WIDTH) << wxT(");"); + << wxCrafter::UNDERSCORE(GetName()) << wxT(", ") << wxT("wxLIST_FORMAT_LEFT, ") + << PropertyString(PROP_WIDTH) << wxT(");"); return cppCode; } @@ -53,10 +54,14 @@ void ListCtrlColumnWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("text")); - if(propertynode) { SetName(propertynode->GetNodeContent()); } + if (propertynode) { + SetName(propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("width")); - if(propertynode) { SetPropertyString(PROP_WIDTH, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_WIDTH, propertynode->GetNodeContent()); + } } // AFAICT wxSmith & wxFB don't do ListCtrlColumns diff --git a/wxcrafter/controls/list_ctrl_wrapper.cpp b/wxcrafter/controls/list_ctrl_wrapper.cpp index c95748827c..b7b894210b 100644 --- a/wxcrafter/controls/list_ctrl_wrapper.cpp +++ b/wxcrafter/controls/list_ctrl_wrapper.cpp @@ -1,6 +1,8 @@ #include "list_ctrl_wrapper.h" + #include "allocator_mgr.h" #include "wxgui_defs.h" + #include ListCtrlWrapper::ListCtrlWrapper() @@ -25,34 +27,39 @@ ListCtrlWrapper::ListCtrlWrapper() RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_SELECTED"), wxT("wxListEvent"), _("The item has been selected")); RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_DESELECTED"), wxT("wxListEvent"), _("The item has been deselected")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK"), wxT("wxListEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK"), + wxT("wxListEvent"), _("The right mouse button has been clicked on an item")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK"), wxT("wxListEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK"), + wxT("wxListEvent"), _("The middle mouse button has been clicked on an item")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_ACTIVATED"), wxT("wxListEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_ACTIVATED"), + wxT("wxListEvent"), _("The item has been activated (ENTER or double click)")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_ITEM_FOCUSED"), wxT("wxListEvent"), - _("The currently focused item has changed")); + RegisterEvent( + wxT("wxEVT_COMMAND_LIST_ITEM_FOCUSED"), wxT("wxListEvent"), _("The currently focused item has changed")); RegisterEvent(wxT("wxEVT_COMMAND_LIST_KEY_DOWN"), wxT("wxListEvent"), _("A key has been pressed")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_CLICK"), wxT("wxListEvent"), - _("A column (m_col) has been left-clicked")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_RIGHT_CLICK"), wxT("wxListEvent"), - _("A column (m_col) has been right-clicked")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_BEGIN_DRAG"), wxT("wxListEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_CLICK"), wxT("wxListEvent"), _("A column (m_col) has been left-clicked")); + RegisterEvent( + wxT("wxEVT_COMMAND_LIST_COL_RIGHT_CLICK"), wxT("wxListEvent"), _("A column (m_col) has been right-clicked")); + RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_BEGIN_DRAG"), + wxT("wxListEvent"), _("The user started resizing a column - can be vetoed")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_DRAGGING"), wxT("wxListEvent"), - _("The divider between columns is being dragged")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_COL_END_DRAG"), wxT("wxListEvent"), - _("A column has been resized by the user")); + RegisterEvent( + wxT("wxEVT_COMMAND_LIST_COL_DRAGGING"), wxT("wxListEvent"), _("The divider between columns is being dragged")); + RegisterEvent( + wxT("wxEVT_COMMAND_LIST_COL_END_DRAG"), wxT("wxListEvent"), _("A column has been resized by the user")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_BEGIN_DRAG"), wxT("wxListEvent"), - _("Begin dragging with the left mouse button")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_BEGIN_RDRAG"), wxT("wxListEvent"), - _("Begin dragging with the right mouse button.")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT"), wxT("wxListEvent"), + RegisterEvent( + wxT("wxEVT_COMMAND_LIST_BEGIN_DRAG"), wxT("wxListEvent"), _("Begin dragging with the left mouse button")); + RegisterEvent( + wxT("wxEVT_COMMAND_LIST_BEGIN_RDRAG"), wxT("wxListEvent"), _("Begin dragging with the right mouse button.")); + RegisterEvent(wxT("wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT"), + wxT("wxListEvent"), _("Begin editing a label. This can be prevented by calling Veto()")); - RegisterEvent(wxT("wxEVT_COMMAND_LIST_END_LABEL_EDIT"), wxT("wxListEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_LIST_END_LABEL_EDIT"), + wxT("wxListEvent"), _("Finish editing a label. This can be prevented by calling Veto()")); RegisterEvent(wxT("wxEVT_COMMAND_LIST_DELETE_ITEM"), wxT("wxListEvent"), _("Delete an item")); RegisterEvent(wxT("wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS"), wxT("wxListEvent"), _("Delete all items")); diff --git a/wxcrafter/controls/media_ctrl_wrapper.cpp b/wxcrafter/controls/media_ctrl_wrapper.cpp index afde27dca4..946ab5ffa2 100644 --- a/wxcrafter/controls/media_ctrl_wrapper.cpp +++ b/wxcrafter/controls/media_ctrl_wrapper.cpp @@ -27,21 +27,23 @@ MediaCtrlWrapper::MediaCtrlWrapper() controls.Add(PROP_MC_DEFAULT_CONTROLS); Add(PROP_MC_CONTROLS, controls, 0, _("Show the player controls")); - RegisterEvent("wxEVT_MEDIA_LOADED", "wxMediaEvent", - _("Sent when a media has loaded enough data that it can start playing")); - RegisterEvent("wxEVT_MEDIA_STOP", "wxMediaEvent", + RegisterEvent( + "wxEVT_MEDIA_LOADED", "wxMediaEvent", _("Sent when a media has loaded enough data that it can start playing")); + RegisterEvent("wxEVT_MEDIA_STOP", + "wxMediaEvent", _("Sent when a media has switched to the wxMEDIASTATE_STOPPED state. You may be able to Veto this " "event to prevent it from stopping, causing it to continue playing - even if it has reached that " "end of the media (note that this may not have the desired effect - if you want to loop the media, " "for example, catch the EVT_MEDIA_FINISHED and play there instead).")); - RegisterEvent("wxEVT_MEDIA_FINISHED", "wxMediaEvent", - _("Sent when a media has finished playing in a wxMediaCtrl.")); - RegisterEvent("wxEVT_MEDIA_STATECHANGED", "wxMediaEvent", + RegisterEvent( + "wxEVT_MEDIA_FINISHED", "wxMediaEvent", _("Sent when a media has finished playing in a wxMediaCtrl.")); + RegisterEvent("wxEVT_MEDIA_STATECHANGED", + "wxMediaEvent", _("Sent when a media has switched its state (from any media state)")); - RegisterEvent("wxEVT_MEDIA_PLAY", "wxMediaEvent", - _("Sent when a media has switched to the wxMEDIASTATE_PLAYING state")); - RegisterEvent("wxEVT_MEDIA_PAUSE", "wxMediaEvent", - _("Sent when a media has switched to the wxMEDIASTATE_PAUSED state")); + RegisterEvent( + "wxEVT_MEDIA_PLAY", "wxMediaEvent", _("Sent when a media has switched to the wxMEDIASTATE_PLAYING state")); + RegisterEvent( + "wxEVT_MEDIA_PAUSE", "wxMediaEvent", _("Sent when a media has switched to the wxMEDIASTATE_PAUSED state")); m_namePattern = "m_mediaCtrl"; SetName(GenerateName()); @@ -68,7 +70,7 @@ wxString MediaCtrlWrapper::GetWxClassName() const { return "wxMediaCtrl"; } void MediaCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << XRCUnknown(); } else { diff --git a/wxcrafter/controls/menu_toolbar/menu_bar_wrapper.cpp b/wxcrafter/controls/menu_toolbar/menu_bar_wrapper.cpp index 89326537ca..94154d393d 100644 --- a/wxcrafter/controls/menu_toolbar/menu_bar_wrapper.cpp +++ b/wxcrafter/controls/menu_toolbar/menu_bar_wrapper.cpp @@ -1,6 +1,8 @@ #include "menu_bar_wrapper.h" + #include "allocator_mgr.h" #include "wxgui_defs.h" + #include MenuBarWrapper::MenuBarWrapper() @@ -20,7 +22,7 @@ wxString MenuBarWrapper::CppCtorCode() const { wxString code; code << GetName() << wxT(" = new ") << GetWxClassName() << wxT("(") << StyleFlags(wxT("0")) << wxT(");\n"); - if(GetParent() && GetParent()->GetType() == ID_WXFRAME) { + if (GetParent() && GetParent()->GetType() == ID_WXFRAME) { code << wxT("this->SetMenuBar(") << GetName() << wxT(");\n"); } return code; @@ -33,7 +35,7 @@ wxString MenuBarWrapper::GetWxClassName() const { return wxT("wxMenuBar"); } void MenuBarWrapper::ToXRC(wxString& text, XRC_TYPE type) const { wxString menuBarXRC; - if(type == XRC_DESIGNER) { + if (type == XRC_DESIGNER) { return; // menuBarXRC << wxT(""); } else { diff --git a/wxcrafter/controls/menu_toolbar/menu_item_wrapper.cpp b/wxcrafter/controls/menu_toolbar/menu_item_wrapper.cpp index f5f1aaf0ad..3fedb14f53 100644 --- a/wxcrafter/controls/menu_toolbar/menu_item_wrapper.cpp +++ b/wxcrafter/controls/menu_toolbar/menu_item_wrapper.cpp @@ -54,10 +54,10 @@ wxString MenuItemWrapper::CppCtorCode() const wxString label; wxcWidget* parent = GetParent(); // Find the first non-menu parent, to check it's kosher - while(parent && (parent->GetType() == ID_WXMENU || parent->GetType() == ID_WXSUBMENU)) { + while (parent && (parent->GetType() == ID_WXMENU || parent->GetType() == ID_WXSUBMENU)) { parent = parent->GetParent(); } - if(parent && parent->GetType() == ID_WXTOOLBARITEM) { + if (parent && parent->GetType() == ID_WXTOOLBARITEM) { // An item in a toolbaritem dropdown menu (probably an auitoolbar, as that's not yet implemented for the // standard one) // This is handled in a completely different way, so don't emit anything @@ -69,7 +69,7 @@ wxString MenuItemWrapper::CppCtorCode() const wxString actualKind; wxCrafter::TOOL_TYPE toolType = wxCrafter::GetToolType(PropertyString(PROP_KIND)); - switch(toolType) { + switch (toolType) { case wxCrafter::TOOL_TYPE_SEPARATOR: ID = wxT("wxID_SEPARATOR"); break; @@ -88,13 +88,13 @@ wxString MenuItemWrapper::CppCtorCode() const break; } - if(ID == wxT("wxID_SEPARATOR")) { + if (ID == wxT("wxID_SEPARATOR")) { code << GetWindowParent() << wxT("->AppendSeparator();\n"); } else { label << PropertyString(PROP_LABEL); wxString accel = PropertyString(PROP_ACCELERATOR).Trim().Trim(false); - if(!accel.IsEmpty()) { + if (!accel.IsEmpty()) { label << wxT("\\t") << accel; } label.Trim().Trim(false); @@ -106,7 +106,7 @@ wxString MenuItemWrapper::CppCtorCode() const code << actualKind << wxT(");\n"); wxString bmpcode = wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)); - if( + if ( #if defined(__WXGTK__) (toolType == wxCrafter::TOOL_TYPE_NORMAL) && // gtk asserts if you try to give a bitmap to a check/radio menuitem @@ -117,7 +117,7 @@ wxString MenuItemWrapper::CppCtorCode() const code << GetWindowParent() << wxT("->Append(") << GetName() << wxT(");\n"); - if((actualKind == wxT("wxITEM_CHECK")) && (PropertyString(PROP_CHECKED) == "1")) { + if ((actualKind == wxT("wxITEM_CHECK")) && (PropertyString(PROP_CHECKED) == "1")) { code << GetName() << "->Check();\n"; } } @@ -132,12 +132,12 @@ void MenuItemWrapper::ToXRC(wxString& text, XRC_TYPE type) const { bool isSeparator = (WindowID() == wxT("wxID_SEPARATOR") || PropertyString(PROP_KIND) == ITEM_SEPARATOR); - if(isSeparator) { + if (isSeparator) { text << wxT(""); } else { text << XRCPrefix() << XRCKind() << XRCLabel(); - if( + if ( #if defined(__WXGTK__) (PropertyString(PROP_KIND) == ITEM_NORMAL) && // gtk asserts if you try to give a bitmap to a check/radio menuitem @@ -146,7 +146,7 @@ void MenuItemWrapper::ToXRC(wxString& text, XRC_TYPE type) const text << XRCBitmap(); } text << wxT("") << wxCrafter::CDATA(PropertyString(PROP_ACCELERATOR)) << wxT(""); - if((PropertyString(PROP_KIND) == ITEM_CHECK) && (PropertyString(PROP_CHECKED) == "1")) { + if ((PropertyString(PROP_KIND) == ITEM_CHECK) && (PropertyString(PROP_CHECKED) == "1")) { text << wxT("") << "1" << wxT(""); } // Add the help string @@ -158,10 +158,10 @@ void MenuItemWrapper::ToXRC(wxString& text, XRC_TYPE type) const wxString MenuItemWrapper::XRCKind() const { wxString kind = PropertyString(PROP_KIND); - if(kind == ITEM_RADIO) + if (kind == ITEM_RADIO) return wxT("1"); - else if(kind == ITEM_CHECK) + else if (kind == ITEM_CHECK) return wxT("1"); else @@ -188,38 +188,38 @@ void MenuItemWrapper::DoLoadXRCProperties(const wxXmlNode* node) { // Cope with separators. This will be a menuitem, but we must set its type wxString classname = XmlUtils::ReadString(node, wxT("class")); - if(classname == "separator") { + if (classname == "separator") { SetPropertyString(PROP_KIND, ITEM_SEPARATOR); return; // Nothing else needed for a separator } wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("checkable")); - if(propertynode && propertynode->GetNodeContent() == "1") { + if (propertynode && propertynode->GetNodeContent() == "1") { SetPropertyString(PROP_KIND, ITEM_CHECK); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("checked")); - if(propertynode && propertynode->GetNodeContent() == "1") { + if (propertynode && propertynode->GetNodeContent() == "1") { SetPropertyString(PROP_CHECKED, "1"); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("radio")); - if(propertynode && propertynode->GetNodeContent() == "1") { + if (propertynode && propertynode->GetNodeContent() == "1") { SetPropertyString(PROP_KIND, ITEM_RADIO); } propertynode = XmlUtils::FindFirstByTagName(node, "bitmap"); - if(propertynode) { + if (propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_MENU"); } propertynode = XmlUtils::FindFirstByTagName(node, "accel"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_ACCELERATOR, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "help"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_HELP, propertynode->GetNodeContent()); } } @@ -231,17 +231,17 @@ void MenuItemWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) // Next cope with separators. This will be a menuitem, but we must set its type wxString classname = XmlUtils::ReadString(node, wxT("class")); - if(classname == "separator") { + if (classname == "separator") { SetPropertyString(PROP_KIND, ITEM_SEPARATOR); return; // Nothing else needed for a separator } wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "kind"); - if(propertynode) { + if (propertynode) { wxString value = propertynode->GetNodeContent(); - if(value == "wxITEM_CHECK") { + if (value == "wxITEM_CHECK") { SetPropertyString(PROP_KIND, ITEM_CHECK); - } else if(value == "wxITEM_RADIO") { + } else if (value == "wxITEM_RADIO") { SetPropertyString(PROP_KIND, ITEM_RADIO); } else { SetPropertyString(PROP_KIND, ITEM_NORMAL); @@ -249,22 +249,22 @@ void MenuItemWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) } propertynode = XmlUtils::FindNodeByName(node, "property", "bitmap"); - if(propertynode) { + if (propertynode) { ImportFromwxFB::ProcessBitmapProperty(propertynode->GetNodeContent(), this, PROP_BITMAP_PATH, "wxART_MENU"); } propertynode = XmlUtils::FindNodeByName(node, "property", "shortcut"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_ACCELERATOR, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "help"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_HELP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", wxT("checked")); - if(propertynode && propertynode->GetNodeContent() == "1") { + if (propertynode && propertynode->GetNodeContent() == "1") { SetPropertyString(PROP_CHECKED, "1"); } } diff --git a/wxcrafter/controls/menu_toolbar/menu_wrapper.cpp b/wxcrafter/controls/menu_toolbar/menu_wrapper.cpp index 29baf87e21..4ee9e567f4 100644 --- a/wxcrafter/controls/menu_toolbar/menu_wrapper.cpp +++ b/wxcrafter/controls/menu_toolbar/menu_wrapper.cpp @@ -37,10 +37,10 @@ wxString MenuWrapper::CppCtorCode() const wxString code; wxcWidget* ancestor = GetParent(); // Find the first non-menu parent, to check it's kosher - while(ancestor && (ancestor->GetType() == ID_WXMENU || ancestor->GetType() == ID_WXSUBMENU)) { + while (ancestor && (ancestor->GetType() == ID_WXMENU || ancestor->GetType() == ID_WXSUBMENU)) { ancestor = ancestor->GetParent(); } - if(ancestor && ancestor->GetType() == ID_WXTOOLBARITEM) { + if (ancestor && ancestor->GetType() == ID_WXTOOLBARITEM) { // A toolbaritem dropdown menu (probably an auitoolbar, as that's not yet implemented for the standard one // This is handled in a completely different way, so don't emit anything return code; @@ -49,14 +49,14 @@ wxString MenuWrapper::CppCtorCode() const code << GetName() << wxT(" = new ") << GetWxClassName() << wxT("();\n"); wxcWidget* parent = GetParent(); - if(parent) { - if(parent->GetType() == ID_WXMENUBAR) { + if (parent) { + if (parent->GetType() == ID_WXMENUBAR) { // This menu is a child of a menubar, add it code << GetWindowParent() << wxT("->Append(") << GetName() << wxT(", ") << wxCrafter::UNDERSCORE(PropertyString(PROP_LABEL)) << wxT(");\n"); - } else if(parent->GetType() == ID_WXMENU || parent->GetType() == ID_WXSUBMENU) { + } else if (parent->GetType() == ID_WXMENU || parent->GetType() == ID_WXSUBMENU) { // Sub menu code << GetWindowParent() << wxT("->AppendSubMenu(") << GetName() << wxT(", ") << Label() << wxT(");\n"); diff --git a/wxcrafter/controls/menu_toolbar/status_bar_wrapper.cpp b/wxcrafter/controls/menu_toolbar/status_bar_wrapper.cpp index 376fc2cd1a..bed8766f9a 100644 --- a/wxcrafter/controls/menu_toolbar/status_bar_wrapper.cpp +++ b/wxcrafter/controls/menu_toolbar/status_bar_wrapper.cpp @@ -46,7 +46,9 @@ wxString StatusBarWrapper::GetWxClassName() const { return wxT("wxStatusBar"); } void StatusBarWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_DESIGNER) { return; } + if (type == XRC_DESIGNER) { + return; + } text << XRCPrefix() << XRCStyle() << XRCSize() << XRCCommonAttributes() << wxT("") << wxCrafter::ToNumber(PropertyString(PROP_FIELD_COUNT), 1) << wxT("") << XRCSuffix(); @@ -68,7 +70,9 @@ void StatusBarWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("fields")); - if(propertynode) { SetPropertyString(PROP_FIELD_COUNT, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_FIELD_COUNT, propertynode->GetNodeContent()); + } } void StatusBarWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -77,7 +81,9 @@ void StatusBarWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("fields")); - if(propertynode) { SetPropertyString(PROP_FIELD_COUNT, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_FIELD_COUNT, propertynode->GetNodeContent()); + } } void StatusBarWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -86,5 +92,7 @@ void StatusBarWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "fields"); - if(propertynode) { SetPropertyString(PROP_FIELD_COUNT, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_FIELD_COUNT, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/menu_toolbar/tool_bar_item_wrapper.cpp b/wxcrafter/controls/menu_toolbar/tool_bar_item_wrapper.cpp index 1ba45dda6e..87bd33687b 100644 --- a/wxcrafter/controls/menu_toolbar/tool_bar_item_wrapper.cpp +++ b/wxcrafter/controls/menu_toolbar/tool_bar_item_wrapper.cpp @@ -25,8 +25,8 @@ ToolBarItemWrapper::ToolBarItemWrapper(int type) RegisterEventCommand(wxT("wxEVT_COMMAND_TOOL_CLICKED"), _("Process a wxEVT_COMMAND_TOOL_CLICKED event (a synonym for wxEVT_COMMAND_MENU_SELECTED). " "Pass the id of the tool")); - RegisterEventCommand(wxT("wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED"), - _("Process a wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED event")); + RegisterEventCommand( + wxT("wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED"), _("Process a wxEVT_COMMAND_TOOL_DROPDOWN_CLICKED event")); m_styles.Clear(); m_sizerFlags.Clear(); @@ -56,7 +56,7 @@ wxcWidget* ToolBarItemWrapper::Clone() const { return new ToolBarItemWrapper(); static wxString GenerateCppCtorCodeRecursively(wxcWidget* widget) // Helper function for CppCtorCode() dropdown menus { wxString code; - if(wxCrafter::GetToolType(widget->PropertyString(PROP_KIND)) == wxCrafter::TOOL_TYPE_SEPARATOR) { + if (wxCrafter::GetToolType(widget->PropertyString(PROP_KIND)) == wxCrafter::TOOL_TYPE_SEPARATOR) { code << widget->CppCtorCode(); } else { wxString childcode = widget->CppCtorCode(); @@ -85,7 +85,7 @@ wxString ToolBarItemWrapper::CppCtorCode() const wxCrafter::TOOL_TYPE toolType = wxCrafter::GetToolType(PropertyString(PROP_KIND)); wxCrafter::TOOL_TYPE realToolType = toolType; - if(isAuiItem && toolType == wxCrafter::TOOL_TYPE_DROPDOWN) { + if (isAuiItem && toolType == wxCrafter::TOOL_TYPE_DROPDOWN) { /// wxAuiTooBar does not support wxITEM_DROPDOWN /// convert the type to wxITEM_NORMAL toolType = wxCrafter::TOOL_TYPE_NORMAL; @@ -101,7 +101,7 @@ wxString ToolBarItemWrapper::CppCtorCode() const wxString functionName = wxT("AddTool"); - switch(toolType) { + switch (toolType) { case wxCrafter::TOOL_TYPE_SEPARATOR: functionName = wxT("AddSeparator"); functionArgs.Clear(); @@ -117,19 +117,19 @@ wxString ToolBarItemWrapper::CppCtorCode() const } code << GetWindowParent() << "->" << functionName << wxT("(") << functionArgs << wxT(");\n"); - if(realToolType == wxCrafter::TOOL_TYPE_DROPDOWN && isAuiItem) { + if (realToolType == wxCrafter::TOOL_TYPE_DROPDOWN && isAuiItem) { // wxAuiToolBarItem* AddTool(...) is >= wx3.0, so we have to locate the new tool ourselves code << "wxAuiToolBarItem* " << GetName() << " = " << GetWindowParent() << "->FindToolByIndex(" << GetWindowParent() << "->GetToolCount()-1);\n"; code << "if (" << GetName() << ") {\n"; code << " " << GetName() << "->SetHasDropDown(true);\n"; - if(HasDefaultDropdown()) { + if (HasDefaultDropdown()) { wxcWidget* menu = GetChildren().front(); wxASSERT(menu && menu->GetType() == ID_WXMENU); - if(menu && menu->GetType() == ID_WXMENU) { + if (menu && menu->GetType() == ID_WXMENU) { wxString menuname = menu->GetName(); code << " " << menuname << " = new wxMenu;\n"; - if(menu && menu->GetType() == ID_WXMENU) { + if (menu && menu->GetType() == ID_WXMENU) { // Add each of the wxcWidget menu's children to the generated menu wxcWidget* me = menu->GetParent(); menu->SetParent(NULL); // Allow menu code to be emitted here; there's code to prevent this if the @@ -164,29 +164,33 @@ void ToolBarItemWrapper::ToXRC(wxString& text, XRC_TYPE type) const wxString tip = PropertyString(PROP_TOOLTIP); wxString help = PropertyString(PROP_HELP); - if(toolType == wxCrafter::TOOL_TYPE_SEPARATOR) { + if (toolType == wxCrafter::TOOL_TYPE_SEPARATOR) { text << wxT(""); - } else if(toolType == wxCrafter::TOOL_TYPE_SPACE) { + } else if (toolType == wxCrafter::TOOL_TYPE_SPACE) { text << wxT(""); } else { text << wxT(""); - if(toolType == wxCrafter::TOOL_TYPE_CHECK) { + if (toolType == wxCrafter::TOOL_TYPE_CHECK) { text << wxT("1"); - } else if(toolType == wxCrafter::TOOL_TYPE_RADIO) { + } else if (toolType == wxCrafter::TOOL_TYPE_RADIO) { text << wxT("1"); - } else if(toolType == wxCrafter::TOOL_TYPE_DROPDOWN) { + } else if (toolType == wxCrafter::TOOL_TYPE_DROPDOWN) { text << ""; - if(IsParentAuiToolbar()) { ChildrenXRC(text, type); } + if (IsParentAuiToolbar()) { + ChildrenXRC(text, type); + } text << ""; } text << XRCLabel(); - if(!tip.empty()) { text << wxT("") << wxCrafter::CDATA(tip) << wxT(""); } + if (!tip.empty()) { + text << wxT("") << wxCrafter::CDATA(tip) << wxT(""); + } text << wxT("") << wxCrafter::CDATA(help) << wxT(""); text << XRCBitmap(); text << wxT(""); @@ -200,17 +204,17 @@ void ToolBarItemWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) // Next cope with separators. This will be a toolbaritem, but we must set its type wxString classname = XmlUtils::ReadString(node, wxT("class")); - if(classname == "separator") { + if (classname == "separator") { SetPropertyString(PROP_KIND, ITEM_SEPARATOR); return; // Nothing else needed for a separator } - if(classname == "space") { + if (classname == "space") { SetPropertyString(PROP_KIND, ITEM_SPACE); // 'space' plus 'width' means an auitoolbar non-stretch spacer wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "width"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_WIDTH, propertynode->GetNodeContent()); } else { @@ -218,22 +222,30 @@ void ToolBarItemWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) // specify a different one wxString ppn = "1"; propertynode = XmlUtils::FindFirstByTagName(node, "proportion"); - if(propertynode) { ppn = propertynode->GetNodeContent(); } + if (propertynode) { + ppn = propertynode->GetNodeContent(); + } SetPropertyString(PROP_PROPORTION, ppn); } } wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("toggle")); - if(propertynode && propertynode->GetNodeContent() == "1") { SetPropertyString(PROP_KIND, ITEM_CHECK); } + if (propertynode && propertynode->GetNodeContent() == "1") { + SetPropertyString(PROP_KIND, ITEM_CHECK); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("radio")); - if(propertynode && propertynode->GetNodeContent() == "1") { SetPropertyString(PROP_KIND, ITEM_RADIO); } + if (propertynode && propertynode->GetNodeContent() == "1") { + SetPropertyString(PROP_KIND, ITEM_RADIO); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("hasdropdown")); // The previous way - if(propertynode && propertynode->GetNodeContent() == "1") { SetPropertyString(PROP_KIND, ITEM_DROPDOWN); } + if (propertynode && propertynode->GetNodeContent() == "1") { + SetPropertyString(PROP_KIND, ITEM_DROPDOWN); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("dropdown")); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_KIND, ITEM_DROPDOWN); ImportFromXrc imp(NULL); imp.ProcessNamedNode(propertynode, this, "wxMenu"); // This should load any contained dropdown menu @@ -242,15 +254,19 @@ void ToolBarItemWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) } propertynode = XmlUtils::FindFirstByTagName(node, "bitmap"); - if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_TOOLBAR"); } + if (propertynode) { + ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_TOOLBAR"); + } propertynode = XmlUtils::FindFirstByTagName(node, "bitmap2"); - if(propertynode) { + if (propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_DISABLED_BITMAP_PATH, "wxART_TOOLBAR"); } propertynode = XmlUtils::FindFirstByTagName(node, "longhelp"); - if(propertynode) { SetPropertyString(PROP_HELP, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_HELP, propertynode->GetNodeContent()); + } } void ToolBarItemWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -260,27 +276,35 @@ void ToolBarItemWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) // Next cope with separators. This will be a toolbaritem, but we must set its type wxString classname = XmlUtils::ReadString(node, wxT("class")); - if(classname == "separator") { + if (classname == "separator") { SetPropertyString(PROP_KIND, ITEM_SEPARATOR); return; // Nothing else needed for a separator } wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("check")); // Not 'toggle' - if(propertynode && propertynode->GetNodeContent() == "1") { SetPropertyString(PROP_KIND, ITEM_CHECK); } + if (propertynode && propertynode->GetNodeContent() == "1") { + SetPropertyString(PROP_KIND, ITEM_CHECK); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("radio")); - if(propertynode && propertynode->GetNodeContent() == "1") { SetPropertyString(PROP_KIND, ITEM_RADIO); } + if (propertynode && propertynode->GetNodeContent() == "1") { + SetPropertyString(PROP_KIND, ITEM_RADIO); + } propertynode = XmlUtils::FindFirstByTagName(node, "bitmap"); - if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_TOOLBAR"); } + if (propertynode) { + ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_TOOLBAR"); + } propertynode = XmlUtils::FindFirstByTagName(node, "bitmap2"); - if(propertynode) { + if (propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_DISABLED_BITMAP_PATH, "wxART_TOOLBAR"); } propertynode = XmlUtils::FindFirstByTagName(node, "longhelp"); - if(propertynode) { SetPropertyString(PROP_HELP, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_HELP, propertynode->GetNodeContent()); + } } void ToolBarItemWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -290,33 +314,41 @@ void ToolBarItemWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) // Next cope with separators. This will be a toolbaritem, but we must set its type wxString classname = XmlUtils::ReadString(node, wxT("class")); - if(classname == "toolSeparator") { + if (classname == "toolSeparator") { SetPropertyString(PROP_KIND, ITEM_SEPARATOR); return; // Nothing else needed for a separator } wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "kind"); - if(propertynode) { SetPropertyString(PROP_KIND, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_KIND, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "bitmap"); - if(propertynode) { + if (propertynode) { ImportFromwxFB::ProcessBitmapProperty(propertynode->GetNodeContent(), this, PROP_BITMAP_PATH, "wxART_TOOLBAR"); } propertynode = XmlUtils::FindNodeByName(node, "property", "statusbar"); // Yes, 'statusbar' is wxFB's 'help' label - if(propertynode) { SetPropertyString(PROP_HELP, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_HELP, propertynode->GetNodeContent()); + } } void ToolBarItemWrapper::OnPropertiesUpdated() { - if(IsParentAuiToolbar()) { - if(wxCrafter::GetToolType(PropertyString(PROP_KIND)) == wxCrafter::TOOL_TYPE_DROPDOWN) { + if (IsParentAuiToolbar()) { + if (wxCrafter::GetToolType(PropertyString(PROP_KIND)) == wxCrafter::TOOL_TYPE_DROPDOWN) { // If this was a change of type to a dropdown, we need to delete any stale connected event (which will have // the wrong signature) - if(GetChildren().empty()) { RemoveEvent("wxEVT_COMMAND_TOOL_CLICKED"); } + if (GetChildren().empty()) { + RemoveEvent("wxEVT_COMMAND_TOOL_CLICKED"); + } } else { // If this was a change of type from a dropdown, we again need to delete any stale connected event - if(!GetChildren().empty()) { RemoveEvent("wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN"); } + if (!GetChildren().empty()) { + RemoveEvent("wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN"); + } } } } @@ -326,20 +358,21 @@ void ToolBarItemWrapper::UpdateRegisteredEventsIfNeeded() bool isAuiItem = IsParentAuiToolbar(); wxCrafter::TOOL_TYPE toolType = wxCrafter::GetToolType(PropertyString(PROP_KIND)); - if(isAuiItem && toolType == wxCrafter::TOOL_TYPE_DROPDOWN) { + if (isAuiItem && toolType == wxCrafter::TOOL_TYPE_DROPDOWN) { // A wxAuiItem AND a dropdown menu item -> show only wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN m_controlEvents.Clear(); - RegisterEvent(wxT("wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN"), "wxAuiToolBarEvent", + RegisterEvent(wxT("wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN"), + "wxAuiToolBarEvent", _("Process a wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN event")); - } else if(isAuiItem) { + } else if (isAuiItem) { /// Not a dropdown but a wxAuiItem - show only 'Click' event m_controlEvents.Clear(); RegisterEventCommand(wxT("wxEVT_COMMAND_TOOL_CLICKED"), _("Process a wxEVT_COMMAND_TOOL_CLICKED event (a synonym for " "wxEVT_COMMAND_MENU_SELECTED). Pass the id of the tool")); - } else if(!isAuiItem && !(toolType == wxCrafter::TOOL_TYPE_DROPDOWN)) { + } else if (!isAuiItem && !(toolType == wxCrafter::TOOL_TYPE_DROPDOWN)) { /// Not a dropdown nor wxAuiItem - show only 'Click' event m_controlEvents.Clear(); RegisterEventCommand(wxT("wxEVT_COMMAND_TOOL_CLICKED"), @@ -517,8 +550,10 @@ void AuiToolBarLabelWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxString classname = XmlUtils::ReadString(node, wxT("class")); - if(classname == "label") { + if (classname == "label") { wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "width"); - if(propertynode) { SetPropertyString(PROP_WIDTH, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_WIDTH, propertynode->GetNodeContent()); + } } } diff --git a/wxcrafter/controls/menu_toolbar/toolbar_base_wrapper.cpp b/wxcrafter/controls/menu_toolbar/toolbar_base_wrapper.cpp index 8411ae0570..86e8193b41 100644 --- a/wxcrafter/controls/menu_toolbar/toolbar_base_wrapper.cpp +++ b/wxcrafter/controls/menu_toolbar/toolbar_base_wrapper.cpp @@ -62,7 +62,7 @@ wxString ToolbarBaseWrapper::CppCtorCode() const wxString code; bool isMainToolbar = (GetParent() && GetParent()->GetType() == ID_WXFRAME); bool isSubclassed = (GetRealClassName() != GetWxClassName()); - if(isMainToolbar && !isSubclassed) { + if (isMainToolbar && !isSubclassed) { code << GetName() << wxT(" = this->CreateToolBar(") << StyleFlags(wxT("wxTB_FLAT|wxTB_HORIZONTAL")) << wxT(", ") << WindowID() << wxT(");\n"); } else { @@ -73,15 +73,15 @@ wxString ToolbarBaseWrapper::CppCtorCode() const code << GetName() << wxT("->SetToolBitmapSize(wxSize") << pr.ToString(true) << wxT(");\n"); XYPair margins(PropertyString(PROP_MARGINS), -1, -1); - if(margins != XYPair(-1, -1)) { + if (margins != XYPair(-1, -1)) { code << GetName() << wxT("->SetMargins(") << margins.ToString() << wxT(");\n"); } wxString padding = PropertyString(PROP_PADDING); - if(padding != "1") { + if (padding != "1") { code << GetName() << wxT("->SetToolPacking(") << padding << wxT(");\n"); } wxString sepWidth = PropertyString(PROP_SEPARATOR_SIZE); - if(sepWidth != "5") { + if (sepWidth != "5") { code << GetName() << wxT("->SetToolSeparation(") << sepWidth << wxT(");\n"); } return code; @@ -93,7 +93,7 @@ wxString ToolbarBaseWrapper::GetWxClassName() const { return wxT("wxToolBar"); } void ToolbarBaseWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_DESIGNER && GetParent()->GetType() == ID_WXFRAME) { + if (type == XRC_DESIGNER && GetParent()->GetType() == ID_WXFRAME) { // This ToolBar is a direct child of the main frame // however, since our designer preview is wxPanel based // we cant really place it here, so return empty string @@ -106,16 +106,16 @@ void ToolbarBaseWrapper::ToXRC(wxString& text, XRC_TYPE type) const text << XRCPrefix() << XRCStyle() << wxT("") << prSize.ToString() << wxT(""); - if(prMargins != XYPair(-1, -1)) { + if (prMargins != XYPair(-1, -1)) { text << wxT("") << prMargins.ToString() << wxT(""); } wxString padding = PropertyString(PROP_PADDING); - if(padding != "1") { + if (padding != "1") { text << wxT("") << padding << wxT(""); } wxString sepWidth = PropertyString(PROP_SEPARATOR_SIZE); - if(sepWidth != "5") { + if (sepWidth != "5") { text << wxT("") << sepWidth << wxT(""); } @@ -132,7 +132,7 @@ wxString ToolbarBaseWrapper::DesignerXRC() const toolbarXRC << XRCStyle() << wxT("") << prSize.ToString() << wxT(""); - if(prMargins != XYPair(-1, -1)) { + if (prMargins != XYPair(-1, -1)) { toolbarXRC << wxT("") << prMargins.ToString() << wxT(""); } @@ -147,22 +147,22 @@ void ToolbarBaseWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmapsize")); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_BITMAP_SIZE, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("margins")); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_MARGINS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("packing")); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_PADDING, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("separation")); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_SEPARATOR_SIZE, propertynode->GetNodeContent()); } } @@ -174,22 +174,22 @@ void ToolbarBaseWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) // wxC doesn't (yet) do 'separation' or 'packing' wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "bitmapsize"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_BITMAP_SIZE, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "margins"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_MARGINS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "packing"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_PADDING, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "separation"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_SEPARATOR_SIZE, propertynode->GetNodeContent()); } } @@ -241,7 +241,7 @@ wxString AuiToolbarWrapper::CppCtorCode() const code << GetName() << wxT("->SetToolBitmapSize(wxSize") << pr.ToString(true) << wxT(");\n"); XYPair margins(PropertyString(PROP_MARGINS), -1, -1); - if(margins != XYPair(-1, -1)) { + if (margins != XYPair(-1, -1)) { code << GetName() << wxT("->SetMargins(") << margins.ToString() << wxT(");\n"); } return code; @@ -262,7 +262,7 @@ void AuiToolbarWrapper::ToXRC(wxString& text, XRC_TYPE type) const text << XRCPrefix() << XRCStyle() << XRCCommonAttributes() << wxT("") << prSize.ToString() << wxT(""); - if(prMargins != XYPair(-1, -1)) { + if (prMargins != XYPair(-1, -1)) { text << wxT("") << prMargins.ToString() << wxT(""); } @@ -277,12 +277,12 @@ void AuiToolbarWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) // wxC doesn't (yet) do 'separation' or 'packing' wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmapsize")); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_BITMAP_SIZE, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("margins")); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_MARGINS, propertynode->GetNodeContent()); } } @@ -294,12 +294,12 @@ void AuiToolbarWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) // wxC doesn't (yet) do 'separation' or 'packing' wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "bitmapsize"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_BITMAP_SIZE, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "margins"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_MARGINS, propertynode->GetNodeContent()); } } diff --git a/wxcrafter/controls/radio_box_wrapper.cpp b/wxcrafter/controls/radio_box_wrapper.cpp index 16985ac72e..31f75cb5ad 100644 --- a/wxcrafter/controls/radio_box_wrapper.cpp +++ b/wxcrafter/controls/radio_box_wrapper.cpp @@ -42,7 +42,7 @@ wxString RadioBoxWrapper::CppCtorCode() const code << wxT("wxArrayString ") << arrname << wxT(";\n"); - for(size_t i = 0; i < options.GetCount(); i++) { + for (size_t i = 0; i < options.GetCount(); i++) { code << arrname << wxT(".Add(") << wxCrafter::UNDERSCORE(options.Item(i)) << wxT(");\n"); } @@ -54,7 +54,7 @@ wxString RadioBoxWrapper::CppCtorCode() const << wxT(", ") << PropertyString(PROP_MAJORDIM) << wxT(", ") << StyleFlags(wxT("0")) << wxT(");\n"); code << CPPCommonAttributes(); int sel = wxCrafter::ToNumber(PropertyString(PROP_SELECTION), -1); - if(sel >= 0 && sel < (int)options.GetCount()) { + if (sel >= 0 && sel < (int)options.GetCount()) { code << GetName() << wxT("->SetSelection(") << PropertyString(PROP_SELECTION) << wxT(");\n"); } return code; @@ -79,14 +79,20 @@ void RadioBoxWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) // The Options (content) property has a default, so we must clear it even if the node is absent wxString multistring; wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("content")); - if(propertynode) { multistring = XmlUtils::ChildNodesContentToString(propertynode); } + if (propertynode) { + multistring = XmlUtils::ChildNodesContentToString(propertynode); + } SetPropertyString(PROP_OPTIONS, multistring); propertynode = XmlUtils::FindFirstByTagName(node, wxT("selection")); - if(propertynode) { SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("dimension")); - if(propertynode) { SetPropertyString(PROP_MAJORDIM, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAJORDIM, propertynode->GetNodeContent()); + } } void RadioBoxWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -97,14 +103,20 @@ void RadioBoxWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) // The Options (content) property has a default, so we must clear it even if the node is absent wxString multistring; wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("content")); - if(propertynode) { multistring = XmlUtils::ChildNodesContentToString(propertynode); } + if (propertynode) { + multistring = XmlUtils::ChildNodesContentToString(propertynode); + } SetPropertyString(PROP_OPTIONS, multistring); propertynode = XmlUtils::FindFirstByTagName(node, wxT("default")); - if(propertynode) { SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("dimension")); - if(propertynode) { SetPropertyString(PROP_MAJORDIM, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAJORDIM, propertynode->GetNodeContent()); + } } void RadioBoxWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -115,12 +127,18 @@ void RadioBoxWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) // The "choices" property has a default, so we should clear it even if the node was absent wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "choices"); wxString content; - if(propertynode) { content = ImportFromwxFB::ConvertFBOptionsString(propertynode->GetNodeContent()); } + if (propertynode) { + content = ImportFromwxFB::ConvertFBOptionsString(propertynode->GetNodeContent()); + } SetPropertyString(PROP_OPTIONS, content); propertynode = XmlUtils::FindNodeByName(node, "property", "selection"); - if(propertynode) { SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "majorDimension"); - if(propertynode) { SetPropertyString(PROP_MAJORDIM, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAJORDIM, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/radio_button_wrapper.cpp b/wxcrafter/controls/radio_button_wrapper.cpp index 53625cb233..834795bb4f 100644 --- a/wxcrafter/controls/radio_button_wrapper.cpp +++ b/wxcrafter/controls/radio_button_wrapper.cpp @@ -53,7 +53,9 @@ void RadioButtonWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void RadioButtonWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -62,9 +64,13 @@ void RadioButtonWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("label")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("selected")); - if(propertynode) { SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SELECTION, propertynode->GetNodeContent()); + } } void RadioButtonWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -73,5 +79,7 @@ void RadioButtonWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "value"); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/rich_text_ctrl_wrapper.cpp b/wxcrafter/controls/rich_text_ctrl_wrapper.cpp index 7352c28df5..e606083788 100644 --- a/wxcrafter/controls/rich_text_ctrl_wrapper.cpp +++ b/wxcrafter/controls/rich_text_ctrl_wrapper.cpp @@ -15,38 +15,48 @@ RichTextCtrlWrapper::RichTextCtrlWrapper() EnableStyle(wxT("wxWANTS_CHARS"), true); - RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_CHARACTER"), wxT("wxRichTextEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_CHARACTER"), + wxT("wxRichTextEvent"), _("Process a wxEVT_COMMAND_RICHTEXT_CHARACTER event, generated when the user presses a character " "key.\nValid event functions: GetFlags, GetPosition, GetCharacter.")); - RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_DELETE"), wxT("wxRichTextEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_DELETE"), + wxT("wxRichTextEvent"), _("Process a wxEVT_COMMAND_RICHTEXT_DELETE event, generated when the user presses the backspace or " "delete key.\nValid event functions: GetFlags, GetPosition")); - RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_RETURN"), wxT("wxRichTextEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_RETURN"), + wxT("wxRichTextEvent"), _("Process a wxEVT_COMMAND_RICHTEXT_RETURN event, generated when the user presses the return " "key.\nValid event functions: GetFlags, GetPosition.")); - RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED"), wxT("wxRichTextEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED"), + wxT("wxRichTextEvent"), _("Process a wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED event, generated when styling has been applied " "to the control.\nValid event functions: GetPosition, GetRange.")); - RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING"), wxT("wxRichTextEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING"), + wxT("wxRichTextEvent"), _("Process a wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING event, generated when the control's " "stylesheet has changed,\nfor example the user added, edited or deleted a style.\nValid event " "functions: GetRange, GetPosition.")); - RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING"), wxT("wxRichTextEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING"), + wxT("wxRichTextEvent"), _("Process a wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING event, generated when the control's " "stylesheet is about to be replaced\nfor example when a file is loaded into the control.\nValid " "event functions: Veto, GetOldStyleSheet, GetNewStyleSheet.")); - RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED"), wxT("wxRichTextEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED"), + wxT("wxRichTextEvent"), _("Process a wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED event, generated when the control's " "stylesheet has been replaced\nfor example when a file is loaded into the control\nValid event " "functions: GetOldStyleSheet, GetNewStyleSheet.")); - RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED"), wxT("wxRichTextEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED"), + wxT("wxRichTextEvent"), _("Process a wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED event generated when content has been " "inserted into the control.\nValid event functions: GetPosition, GetRange.")); - RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED"), wxT("wxRichTextEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED"), + wxT("wxRichTextEvent"), _("Process a wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED event, generated when content has been deleted " "from the control\nValid event functions: GetPosition, GetRange.")); RegisterEvent( - wxT("wxEVT_COMMAND_RICHTEXT_BUFFER_RESET"), wxT("wxRichTextEvent"), + wxT("wxEVT_COMMAND_RICHTEXT_BUFFER_RESET"), + wxT("wxRichTextEvent"), _("Process a wxEVT_COMMAND_RICHTEXT_BUFFER_RESET event, generated when the buffer has been reset by deleting " "all content.\nYou can use this to set a default style for the first new paragraph.")); RegisterEventCommand(wxT("wxEVT_COMMAND_TEXT_UPDATED"), @@ -83,7 +93,7 @@ wxString RichTextCtrlWrapper::GetWxClassName() const { return wxT("wxRichTextCtr void RichTextCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << XRCUnknown(); } else { diff --git a/wxcrafter/controls/scroll_bar_wrapper.cpp b/wxcrafter/controls/scroll_bar_wrapper.cpp index 2dd8476baf..5c935e4b4b 100644 --- a/wxcrafter/controls/scroll_bar_wrapper.cpp +++ b/wxcrafter/controls/scroll_bar_wrapper.cpp @@ -12,22 +12,27 @@ ScrollBarWrapper::ScrollBarWrapper() PREPEND_STYLE_STR(wxT("wxSB_HORIZONTAL"), wxSB_HORIZONTAL, true); PREPEND_STYLE_STR(wxT("wxSB_VERTICAL"), wxSB_VERTICAL, false); - RegisterEvent(wxT("wxEVT_SCROLL_TOP"), wxT("wxScrollEvent"), + RegisterEvent(wxT("wxEVT_SCROLL_TOP"), + wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position)")); - RegisterEvent(wxT("wxEVT_SCROLL_BOTTOM"), wxT("wxScrollEvent"), + RegisterEvent(wxT("wxEVT_SCROLL_BOTTOM"), + wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).")); RegisterEvent(wxT("wxEVT_SCROLL_LINEUP"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_LINEUP line up events.")); - RegisterEvent(wxT("wxEVT_SCROLL_LINEDOWN"), wxT("wxScrollEvent"), - _("Process wxEVT_SCROLL_LINEDOWN line down events.")); + RegisterEvent( + wxT("wxEVT_SCROLL_LINEDOWN"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_LINEDOWN line down events.")); RegisterEvent(wxT("wxEVT_SCROLL_PAGEUP"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_PAGEUP page up events.")); - RegisterEvent(wxT("wxEVT_SCROLL_PAGEDOWN"), wxT("wxScrollEvent"), - _("Process wxEVT_SCROLL_PAGEDOWN page down events")); - RegisterEvent(wxT("wxEVT_SCROLL_THUMBTRACK"), wxT("wxScrollEvent"), + RegisterEvent( + wxT("wxEVT_SCROLL_PAGEDOWN"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_PAGEDOWN page down events")); + RegisterEvent(wxT("wxEVT_SCROLL_THUMBTRACK"), + wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the user drags the " - "thumbtrack).")); - RegisterEvent(wxT("wxEVT_SCROLL_THUMBRELEASE"), wxT("wxScrollEvent"), + "thumbtrack).")); + RegisterEvent(wxT("wxEVT_SCROLL_THUMBRELEASE"), + wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_THUMBRELEASE thumb release events.")); - RegisterEvent(wxT("wxEVT_SCROLL_CHANGED"), wxT("wxScrollEvent"), + RegisterEvent(wxT("wxEVT_SCROLL_CHANGED"), + wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).")); SetPropertyString(_("Common Settings"), "wxScrollBar"); @@ -75,16 +80,24 @@ void ScrollBarWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("thumbsize")); - if(propertynode) { SetPropertyString(PROP_THUMBSIZE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_THUMBSIZE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("range")); - if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("pagesize")); - if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void ScrollBarWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -93,14 +106,22 @@ void ScrollBarWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "thumbsize"); - if(propertynode) { SetPropertyString(PROP_THUMBSIZE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_THUMBSIZE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "range"); - if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "pagesize"); - if(propertynode) { SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_RANGE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "value"); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/simple_book_wrapper.cpp b/wxcrafter/controls/simple_book_wrapper.cpp index a0701e7751..ab6aa82eaa 100644 --- a/wxcrafter/controls/simple_book_wrapper.cpp +++ b/wxcrafter/controls/simple_book_wrapper.cpp @@ -15,16 +15,23 @@ SimpleBookWrapper::SimpleBookWrapper() REMOVE_STYLE(wxBK_TOP); REMOVE_STYLE(wxBK_BOTTOM); - RegisterEvent(wxT("wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED"), wxT("wxNotebookEvent"), - _("The page selection was changed")); - RegisterEvent(wxT("wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING"), wxT("wxNotebookEvent"), + RegisterEvent( + wxT("wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED"), wxT("wxNotebookEvent"), _("The page selection was changed")); + RegisterEvent(wxT("wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING"), + wxT("wxNotebookEvent"), _("The page selection is about to be changed. This event can be vetoed")); - const wxArrayString effects = StdToWX::ToArrayString( - { "wxSHOW_EFFECT_NONE", "wxSHOW_EFFECT_ROLL_TO_LEFT", "wxSHOW_EFFECT_ROLL_TO_RIGHT", - "wxSHOW_EFFECT_ROLL_TO_TOP", "wxSHOW_EFFECT_ROLL_TO_BOTTOM", "wxSHOW_EFFECT_SLIDE_TO_LEFT", - "wxSHOW_EFFECT_SLIDE_TO_RIGHT", "wxSHOW_EFFECT_SLIDE_TO_TOP", "wxSHOW_EFFECT_SLIDE_TO_BOTTOM", - "wxSHOW_EFFECT_BLEND", "wxSHOW_EFFECT_EXPAND" }); + const wxArrayString effects = StdToWX::ToArrayString({"wxSHOW_EFFECT_NONE", + "wxSHOW_EFFECT_ROLL_TO_LEFT", + "wxSHOW_EFFECT_ROLL_TO_RIGHT", + "wxSHOW_EFFECT_ROLL_TO_TOP", + "wxSHOW_EFFECT_ROLL_TO_BOTTOM", + "wxSHOW_EFFECT_SLIDE_TO_LEFT", + "wxSHOW_EFFECT_SLIDE_TO_RIGHT", + "wxSHOW_EFFECT_SLIDE_TO_TOP", + "wxSHOW_EFFECT_SLIDE_TO_BOTTOM", + "wxSHOW_EFFECT_BLEND", + "wxSHOW_EFFECT_EXPAND"}); SetPropertyString(_("Common Settings"), "wxSimplebook"); Add(PROP_EFFECT, effects, 0, _("Set the same effect to use for both showing and hiding the pages")); m_namePattern = wxT("m_simpleBook"); diff --git a/wxcrafter/controls/slider_wrapper.cpp b/wxcrafter/controls/slider_wrapper.cpp index 19813fb64c..b863bfd0cc 100644 --- a/wxcrafter/controls/slider_wrapper.cpp +++ b/wxcrafter/controls/slider_wrapper.cpp @@ -25,22 +25,27 @@ SliderWrapper::SliderWrapper() PREPEND_STYLE(wxSL_SELRANGE, false); PREPEND_STYLE(wxSL_INVERSE, false); - RegisterEvent(wxT("wxEVT_SCROLL_TOP"), wxT("wxScrollEvent"), + RegisterEvent(wxT("wxEVT_SCROLL_TOP"), + wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_TOP scroll-to-top events (minimum position)")); - RegisterEvent(wxT("wxEVT_SCROLL_BOTTOM"), wxT("wxScrollEvent"), + RegisterEvent(wxT("wxEVT_SCROLL_BOTTOM"), + wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_BOTTOM scroll-to-bottom events (maximum position).")); RegisterEvent(wxT("wxEVT_SCROLL_LINEUP"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_LINEUP line up events.")); - RegisterEvent(wxT("wxEVT_SCROLL_LINEDOWN"), wxT("wxScrollEvent"), - _("Process wxEVT_SCROLL_LINEDOWN line down events.")); + RegisterEvent( + wxT("wxEVT_SCROLL_LINEDOWN"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_LINEDOWN line down events.")); RegisterEvent(wxT("wxEVT_SCROLL_PAGEUP"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_PAGEUP page up events.")); - RegisterEvent(wxT("wxEVT_SCROLL_PAGEDOWN"), wxT("wxScrollEvent"), - _("Process wxEVT_SCROLL_PAGEDOWN page down events")); - RegisterEvent(wxT("wxEVT_SCROLL_THUMBTRACK"), wxT("wxScrollEvent"), + RegisterEvent( + wxT("wxEVT_SCROLL_PAGEDOWN"), wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_PAGEDOWN page down events")); + RegisterEvent(wxT("wxEVT_SCROLL_THUMBTRACK"), + wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_THUMBTRACK thumbtrack events (frequent events sent as the user drags the " - "thumbtrack).")); - RegisterEvent(wxT("wxEVT_SCROLL_THUMBRELEASE"), wxT("wxScrollEvent"), + "thumbtrack).")); + RegisterEvent(wxT("wxEVT_SCROLL_THUMBRELEASE"), + wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_THUMBRELEASE thumb release events.")); - RegisterEvent(wxT("wxEVT_SCROLL_CHANGED"), wxT("wxScrollEvent"), + RegisterEvent(wxT("wxEVT_SCROLL_CHANGED"), + wxT("wxScrollEvent"), _("Process wxEVT_SCROLL_CHANGED end of scrolling events (MSW only).")); m_namePattern = wxT("m_slider"); @@ -78,13 +83,19 @@ void SliderWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("min")); - if(propertynode) { SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("max")); - if(propertynode) { SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void SliderWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -93,13 +104,19 @@ void SliderWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("min")); - if(propertynode) { SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("max")); - if(propertynode) { SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void SliderWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -108,11 +125,17 @@ void SliderWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "minValue"); - if(propertynode) { SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "maxValue"); - if(propertynode) { SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "value"); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/spacer_wrapper.cpp b/wxcrafter/controls/spacer_wrapper.cpp index f323fc3d7c..772b88cb66 100644 --- a/wxcrafter/controls/spacer_wrapper.cpp +++ b/wxcrafter/controls/spacer_wrapper.cpp @@ -29,7 +29,7 @@ wxString SpacerWrapper::CppCtorCode() const wxString cpp; wxSize size = GetSize(); - if(GetParent()->GetType() == ID_WXGRIDBAGSIZER) { + if (GetParent()->GetType() == ID_WXGRIDBAGSIZER) { cpp << GetParent()->GetName() << wxT("->Add(") << wxCrafter::ToString(size.x) << wxT(", ") << wxCrafter::ToString(size.y) << wxT(", ") << wxT("wxGBPosition(") << GetGbPos() << wxT("), ") << wxT("wxGBSpan(") << GetGbSpan() << wxT("), ") << SizerFlags(wxT("0")) << wxT(", ") @@ -60,21 +60,27 @@ void SpacerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) // For some curious reason, wxFB stores spacer size in separate height and width nodes :/ wxString ht("0"), wd("0"); wxXmlNode* child = node->GetChildren(); - while(child) { + while (child) { wxString childname(child->GetName()); - if(childname == wxT("property")) { + if (childname == wxT("property")) { wxString attr(XmlUtils::ReadString(child, wxT("name"))); - if(attr == "height") { ht = child->GetNodeContent(); } + if (attr == "height") { + ht = child->GetNodeContent(); + } } - if(childname == wxT("property")) { + if (childname == wxT("property")) { wxString attr(XmlUtils::ReadString(child, wxT("name"))); - if(attr == "width") { wd = child->GetNodeContent(); } + if (attr == "width") { + wd = child->GetNodeContent(); + } } child = child->GetNext(); } PropertyBase* prop = GetProperty(PROP_SIZE); - if(prop) { prop->SetValue(wd + "," + ht); } + if (prop) { + prop->SetValue(wd + "," + ht); + } } diff --git a/wxcrafter/controls/spin_ctrl_wrapper.cpp b/wxcrafter/controls/spin_ctrl_wrapper.cpp index 5f64e97262..9e23be75a0 100644 --- a/wxcrafter/controls/spin_ctrl_wrapper.cpp +++ b/wxcrafter/controls/spin_ctrl_wrapper.cpp @@ -14,7 +14,8 @@ SpinCtrlWrapper::SpinCtrlWrapper() PREPEND_STYLE_TRUE(wxSP_ARROW_KEYS); PREPEND_STYLE_FALSE(wxSP_WRAP); - RegisterEvent(wxT("wxEVT_SPINCTRL"), wxT("wxSpinEvent"), + RegisterEvent(wxT("wxEVT_SPINCTRL"), + wxT("wxSpinEvent"), _("Generated whenever the numeric value of the spinctrl is updated")); RegisterEventCommand(wxT("wxEVT_COMMAND_TEXT_UPDATED"), _("Process a wxEVT_COMMAND_TEXT_UPDATED event, when the spinCtrl text changes.")); diff --git a/wxcrafter/controls/spin_wrapper_base.cpp b/wxcrafter/controls/spin_wrapper_base.cpp index 59ec43f1da..cd47cd3dd9 100644 --- a/wxcrafter/controls/spin_wrapper_base.cpp +++ b/wxcrafter/controls/spin_wrapper_base.cpp @@ -1,4 +1,5 @@ #include "spin_wrapper_base.h" + #include "wxgui_helpers.h" #include "xmlutils.h" @@ -12,20 +13,24 @@ void SpinWrapperBase::EnsureSaneValues(wxString& min, wxString& max, int& imin, // Protect against empty range fields, which would otherwise generate code like spin->SetRange(0, ); // Also against max < min, which annoys gtk so much it throws its toys out of the pram and segfaults min = PropertyString(PROP_MINVALUE); - if(min.empty()) { min = "0"; } + if (min.empty()) { + min = "0"; + } max = PropertyString(PROP_MAXVALUE); - if(max.empty()) { max = "100"; } + if (max.empty()) { + max = "100"; + } imin = wxCrafter::ToNumber(min, 0); imax = wxCrafter::ToNumber(max, 100); - if(imax < imin) { + if (imax < imin) { imax = imin + 100; // Well, why not? max = wxCrafter::ToString(imax); } // For 'value', ensure it's in range, otherwise gtk will be unhappy val = PropertyInt(PROP_VALUE); - if(val < imin) { + if (val < imin) { val = imin; - } else if(val > imax) { + } else if (val > imax) { val = imax; } } @@ -36,13 +41,19 @@ void SpinWrapperBase::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("min")); - if(propertynode) { SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("max")); - if(propertynode) { SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void SpinWrapperBase::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -51,13 +62,19 @@ void SpinWrapperBase::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("min")); - if(propertynode) { SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("max")); - if(propertynode) { SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } void SpinWrapperBase::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -66,21 +83,27 @@ void SpinWrapperBase::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "min"); - if(propertynode) { SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MINVALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "max"); - if(propertynode) { SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAXVALUE, propertynode->GetNodeContent()); + } // XRC only does "value". wxFB does this plus initial. I presume they mean the same thing; perhaps 'value' sets the // spinctrl textctrl too propertynode = XmlUtils::FindNodeByName(node, "property", "value"); - if(propertynode) { + if (propertynode) { wxString value = propertynode->GetNodeContent(); - if(!value.empty()) { + if (!value.empty()) { SetPropertyString(PROP_VALUE, value); } else { propertynode = XmlUtils::FindNodeByName(node, "property", "initial"); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } } } } diff --git a/wxcrafter/controls/splitter_window_wrapper.cpp b/wxcrafter/controls/splitter_window_wrapper.cpp index 07b3c78ef3..39a356f62b 100644 --- a/wxcrafter/controls/splitter_window_wrapper.cpp +++ b/wxcrafter/controls/splitter_window_wrapper.cpp @@ -39,13 +39,15 @@ SplitterWindowWrapper::SplitterWindowWrapper() PREPEND_STYLE_FALSE(wxSP_PERMIT_UNSPLIT); PREPEND_STYLE_FALSE(wxSP_LIVE_UPDATE); - RegisterEvent(wxT("wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING"), wxT(" wxSplitterEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING"), + wxT(" wxSplitterEvent"), _("The sash position is in the process of being changed")); - RegisterEvent(wxT("wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED"), wxT(" wxSplitterEvent"), - _("The sash position was changed")); - RegisterEvent(wxT("wxEVT_COMMAND_SPLITTER_UNSPLIT"), wxT(" wxSplitterEvent"), - _("The splitter has been just unsplit")); - RegisterEvent(wxT("wxEVT_COMMAND_SPLITTER_DOUBLECLICKED"), wxT(" wxSplitterEvent"), + RegisterEvent( + wxT("wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED"), wxT(" wxSplitterEvent"), _("The sash position was changed")); + RegisterEvent( + wxT("wxEVT_COMMAND_SPLITTER_UNSPLIT"), wxT(" wxSplitterEvent"), _("The splitter has been just unsplit")); + RegisterEvent(wxT("wxEVT_COMMAND_SPLITTER_DOUBLECLICKED"), + wxT(" wxSplitterEvent"), _("The sash was double clicked.\nThe default behaviour is to unsplit the window when this " "happens\n(unless the minimum pane size has been set to a value greater than zero)")); @@ -80,7 +82,9 @@ void SplitterWindowWrapper::ToXRC(wxString& text, XRC_TYPE type) const int sashpos = wxCrafter::ToNumber(PropertyString(PROP_SASH_POS), 0); wxString orientation = "vertical"; - if(!IsSplitVertically()) { orientation = "horizontal"; } + if (!IsSplitVertically()) { + orientation = "horizontal"; + } text << XRCPrefix() << XRCSize() << XRCCommonAttributes() << XRCStyle() << wxT("") << wxCrafter::FloatToCString(gravity) << wxT("") << wxT("") << minsize << wxT("") @@ -98,19 +102,25 @@ void SplitterWindowWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("gravity")); - if(propertynode) { SetPropertyString(PROP_SASH_GRAVITY, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SASH_GRAVITY, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("minsize")); - if(propertynode) { SetPropertyString(PROP_MIN_PANE_SIZE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MIN_PANE_SIZE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("sashpos")); - if(propertynode) { SetPropertyString(PROP_SASH_POS, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SASH_POS, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("orientation")); - if(propertynode) { - SetPropertyString(PROP_SPLIT_MODE, propertynode->GetNodeContent() == "vertical" - ? wxString("wxSPLIT_VERTICAL") - : wxString("wxSPLIT_HORIZONTAL")); + if (propertynode) { + SetPropertyString(PROP_SPLIT_MODE, + propertynode->GetNodeContent() == "vertical" ? wxString("wxSPLIT_VERTICAL") + : wxString("wxSPLIT_HORIZONTAL")); } } @@ -120,16 +130,24 @@ void SplitterWindowWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("gravity")); - if(propertynode) { SetPropertyString(PROP_SASH_GRAVITY, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SASH_GRAVITY, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("minsize")); - if(propertynode) { SetPropertyString(PROP_MIN_PANE_SIZE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MIN_PANE_SIZE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("sashpos")); - if(propertynode) { SetPropertyString(PROP_SASH_POS, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SASH_POS, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("orientation")); - if(propertynode) { SetPropertyString(PROP_SPLIT_MODE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SPLIT_MODE, propertynode->GetNodeContent()); + } } void SplitterWindowWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -138,16 +156,24 @@ void SplitterWindowWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "sashgravity"); - if(propertynode) { SetPropertyString(PROP_SASH_GRAVITY, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SASH_GRAVITY, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "min_pane_size"); - if(propertynode) { SetPropertyString(PROP_MIN_PANE_SIZE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MIN_PANE_SIZE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "sashpos"); - if(propertynode) { SetPropertyString(PROP_SASH_POS, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SASH_POS, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "splitmode"); - if(propertynode) { SetPropertyString(PROP_SPLIT_MODE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_SPLIT_MODE, propertynode->GetNodeContent()); + } } bool SplitterWindowWrapper::IsSplitVertically() const diff --git a/wxcrafter/controls/static_bitmap_wrapper.cpp b/wxcrafter/controls/static_bitmap_wrapper.cpp index 272db9cf76..ad34444973 100644 --- a/wxcrafter/controls/static_bitmap_wrapper.cpp +++ b/wxcrafter/controls/static_bitmap_wrapper.cpp @@ -45,7 +45,9 @@ void StaticBitmapWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); } + if (propertynode) { + ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); + } } void StaticBitmapWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -54,7 +56,9 @@ void StaticBitmapWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); } + if (propertynode) { + ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_BUTTON"); + } } void StaticBitmapWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -63,7 +67,7 @@ void StaticBitmapWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "bitmap"); - if(propertynode) { + if (propertynode) { ImportFromwxFB::ProcessBitmapProperty(propertynode->GetNodeContent(), this, PROP_BITMAP_PATH, "wxART_BUTTON"); } } diff --git a/wxcrafter/controls/static_line_wrapper.cpp b/wxcrafter/controls/static_line_wrapper.cpp index 37f168f577..2c977f56f3 100644 --- a/wxcrafter/controls/static_line_wrapper.cpp +++ b/wxcrafter/controls/static_line_wrapper.cpp @@ -1,5 +1,7 @@ #include "static_line_wrapper.h" + #include "allocator_mgr.h" + #include StaticLineWrapper::StaticLineWrapper() diff --git a/wxcrafter/controls/static_text_wrapper.cpp b/wxcrafter/controls/static_text_wrapper.cpp index 13fbab4ddc..0d90b48954 100644 --- a/wxcrafter/controls/static_text_wrapper.cpp +++ b/wxcrafter/controls/static_text_wrapper.cpp @@ -36,7 +36,7 @@ wxString StaticTextWrapper::CppCtorCode() const << wxT(", ") << Label() << wxT(", wxDefaultPosition, ") << SizeAsString() << wxT(", ") << StyleFlags(wxT("0")) << wxT(");\n"); - if(wxCrafter::ToNumber(PropertyString(PROP_WRAP), -1) >= 0) { // The default value is -1 + if (wxCrafter::ToNumber(PropertyString(PROP_WRAP), -1) >= 0) { // The default value is -1 code << GetName() << "->Wrap(" << PropertyString(PROP_WRAP) << ");\n"; } @@ -48,7 +48,7 @@ void StaticTextWrapper::ToXRC(wxString& text, XRC_TYPE type) const { wxString xrc; xrc << XRCPrefix() << XRCLabel() << XRCStyle() << XRCSize() << XRCCommonAttributes(); - if(wxCrafter::ToNumber(PropertyString(PROP_WRAP), -1) >= 0) { // The default value is -1 + if (wxCrafter::ToNumber(PropertyString(PROP_WRAP), -1) >= 0) { // The default value is -1 xrc << wxT("") << PropertyString(PROP_WRAP) << wxT(""); } xrc << XRCSuffix(); @@ -61,7 +61,9 @@ void StaticTextWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("wrap")); - if(propertynode) { SetPropertyString(PROP_WRAP, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_WRAP, propertynode->GetNodeContent()); + } } // wxSmith doesn't wrap @@ -72,7 +74,9 @@ void StaticTextWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "wrap"); - if(propertynode) { SetPropertyString(PROP_WRAP, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_WRAP, propertynode->GetNodeContent()); + } } wxcWidget* StaticTextWrapper::Clone() const { return new StaticTextWrapper(); } diff --git a/wxcrafter/controls/styled_text_ctrl_wrapper.cpp b/wxcrafter/controls/styled_text_ctrl_wrapper.cpp index e02d720586..c875f73e4c 100644 --- a/wxcrafter/controls/styled_text_ctrl_wrapper.cpp +++ b/wxcrafter/controls/styled_text_ctrl_wrapper.cpp @@ -17,12 +17,12 @@ StyledTextCtrlWrapper::LexersMap_t StyledTextCtrlWrapper::m_lexers; StyledTextCtrlWrapper::StyledTextCtrlWrapper() : wxcWidget(ID_WXSTC) - , m_wrapOptions(StdToWX::ToArrayString({ "None", "Word", "Char" })) - , m_eolMode(StdToWX::ToArrayString({ "CRLF", "CR", "LF", "Default" })) - , m_indentGuides(StdToWX::ToArrayString({ "None", "Real", "Look Forward", "Look Both" })) + , m_wrapOptions(StdToWX::ToArrayString({"None", "Word", "Char"})) + , m_eolMode(StdToWX::ToArrayString({"CRLF", "CR", "LF", "Default"})) + , m_indentGuides(StdToWX::ToArrayString({"None", "Real", "Look Forward", "Look Both"})) { // Register the known lexers - if(m_lexers.empty()) { + if (m_lexers.empty()) { ADD_LEXER(wxSTC_LEX_CONTAINER); ADD_LEXER(wxSTC_LEX_NULL); ADD_LEXER(wxSTC_LEX_PYTHON); @@ -128,18 +128,21 @@ StyledTextCtrlWrapper::StyledTextCtrlWrapper() RegisterEvent("wxEVT_STC_CHANGE", "wxStyledTextEvent", ""); RegisterEvent( - "wxEVT_STC_STYLENEEDED", "wxStyledTextEvent", + "wxEVT_STC_STYLENEEDED", + "wxStyledTextEvent", _("If you used SCI_SETLEXER(SCLEX_CONTAINER) to make the container act as the lexer\nyou will receive this " "notification when Scintilla is about to display or print text that requires styling")); RegisterEvent("wxEVT_STC_CHARADDED", "wxStyledTextEvent", _("A char was added")); - RegisterEvent("wxEVT_STC_SAVEPOINTREACHED", "wxStyledTextEvent", + RegisterEvent("wxEVT_STC_SAVEPOINTREACHED", + "wxStyledTextEvent", _("Sent to the container when the save point is entered\nallowing the container to display a " "\"document saved\" indicator and change its menus")); - RegisterEvent("wxEVT_STC_SAVEPOINTLEFT", "wxStyledTextEvent", + RegisterEvent("wxEVT_STC_SAVEPOINTLEFT", + "wxStyledTextEvent", _("Sent to the container when the save point is left\nallowing the container to display a \"document " "dirty\" indicator and change its menus")); - RegisterEvent("wxEVT_STC_ROMODIFYATTEMPT", "wxStyledTextEvent", - _("An attempt to modify a read-only document was made")); + RegisterEvent( + "wxEVT_STC_ROMODIFYATTEMPT", "wxStyledTextEvent", _("An attempt to modify a read-only document was made")); RegisterEvent("wxEVT_STC_KEY", "wxStyledTextEvent", _("Key was pressed")); RegisterEvent("wxEVT_STC_DOUBLECLICK", "wxStyledTextEvent", _("Double-click")); RegisterEvent("wxEVT_STC_UPDATEUI", "wxStyledTextEvent", _("Update UI")); @@ -147,36 +150,44 @@ StyledTextCtrlWrapper::StyledTextCtrlWrapper() RegisterEvent("wxEVT_STC_MACRORECORD", "wxStyledTextEvent", _("Macro record started/stopped")); RegisterEvent("wxEVT_STC_MARGINCLICK", "wxStyledTextEvent", _("One of margins was left clicked with the mouse")); RegisterEvent( - "wxEVT_STC_NEEDSHOWN", "wxStyledTextEvent", + "wxEVT_STC_NEEDSHOWN", + "wxStyledTextEvent", _("Scintilla has determined that a range of lines that is currently invisible should be made visible")); - RegisterEvent("wxEVT_STC_PAINTED", "wxStyledTextEvent", + RegisterEvent("wxEVT_STC_PAINTED", + "wxStyledTextEvent", _("Painting has just been done.\nUseful when you want to update some other widgets based on a change " "in Scintilla\nbut want to have the paint occur first to appear more responsive")); - RegisterEvent("wxEVT_STC_USERLISTSELECTION", "wxStyledTextEvent", - _("The user has selected an item in a user list.")); - RegisterEvent("wxEVT_STC_URIDROPPED", "wxStyledTextEvent", + RegisterEvent( + "wxEVT_STC_USERLISTSELECTION", "wxStyledTextEvent", _("The user has selected an item in a user list.")); + RegisterEvent("wxEVT_STC_URIDROPPED", + "wxStyledTextEvent", _("Only on the GTK+ version. Indicates that the user has dragged a URI such as a file name or Web " "address onto Scintilla")); - RegisterEvent("wxEVT_STC_DWELLSTART", "wxStyledTextEvent", + RegisterEvent("wxEVT_STC_DWELLSTART", + "wxStyledTextEvent", _("Generated when the user keeps the mouse in one position for the dwell period")); - RegisterEvent("wxEVT_STC_DWELLEND", "wxStyledTextEvent", + RegisterEvent("wxEVT_STC_DWELLEND", + "wxStyledTextEvent", _("Generated after a wxEVT_STC_DWELLSTART and the mouse is moved or other activity such as key press " "indicates the dwell is over")); RegisterEvent("wxEVT_STC_START_DRAG", "wxStyledTextEvent", _("Drag and Drop start event")); RegisterEvent("wxEVT_STC_DRAG_OVER", "wxStyledTextEvent", _("Drag and Drop over event")); RegisterEvent("wxEVT_STC_DO_DROP", "wxStyledTextEvent", _("Drag and Drop drop event")); - RegisterEvent("wxEVT_STC_ZOOM", "wxStyledTextEvent", + RegisterEvent("wxEVT_STC_ZOOM", + "wxStyledTextEvent", _("This event is generated when the user zooms the display using the keyboard")); RegisterEvent("wxEVT_STC_HOTSPOT_CLICK", "wxStyledTextEvent", _("A hotspot was clicked")); RegisterEvent("wxEVT_STC_HOTSPOT_DCLICK", "wxStyledTextEvent", _("A hotspot was double clicked")); RegisterEvent("wxEVT_STC_CALLTIP_CLICK", "wxStyledTextEvent", _("The calltip window was clicked")); RegisterEvent("wxEVT_STC_AUTOCOMP_SELECTION", "wxStyledTextEvent", _("Auto-completion list selection was made")); - RegisterEvent("wxEVT_STC_INDICATOR_CLICK", "wxStyledTextEvent", - _("User clicked the mouse on a text that has an indicator")); - RegisterEvent("wxEVT_STC_INDICATOR_RELEASE", "wxStyledTextEvent", + RegisterEvent( + "wxEVT_STC_INDICATOR_CLICK", "wxStyledTextEvent", _("User clicked the mouse on a text that has an indicator")); + RegisterEvent("wxEVT_STC_INDICATOR_RELEASE", + "wxStyledTextEvent", _("User released the mouse on a text that has an indicator")); RegisterEvent("wxEVT_STC_AUTOCOMP_CANCELLED", "wxStyledTextEvent", _("Auto completion list was cancelled")); - RegisterEvent("wxEVT_STC_AUTOCOMP_CHAR_DELETED", "wxStyledTextEvent", + RegisterEvent("wxEVT_STC_AUTOCOMP_CHAR_DELETED", + "wxStyledTextEvent", _("The user deleted a character while auto-completion list was active")); SetPropertyString(_("Common Settings"), "wxStyledTextCtrl"); @@ -230,7 +241,7 @@ wxString StyledTextCtrlWrapper::CppCtorCode() const cppCode << GetName() << "->SetMarginSensitive(4, true);\n"; cppCode << GetName() << "->SetMarginWidth (4, " << (foldMargin ? 16 : 0) << ");\n\n"; - if(foldMargin) { + if (foldMargin) { cppCode << GetName() << "->SetProperty(" << wxCrafter::WXT("fold") << "," << wxCrafter::WXT("1") << ");\n"; cppCode << GetName() << "->MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN);\n"; cppCode << GetName() << "->MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_ARROW);\n"; @@ -256,7 +267,7 @@ wxString StyledTextCtrlWrapper::CppCtorCode() const // Line numbers cppCode << "// Configure the line numbers margin\n"; wxString pixelWidth = GetName() + "_PixelWidth"; - if(lineNumber) { + if (lineNumber) { cppCode << "int " << pixelWidth << " = 4 + 5 *" << GetName() << "->TextWidth(wxSTC_STYLE_LINENUMBER, wxT(\"9\"));\n"; } @@ -278,7 +289,7 @@ wxString StyledTextCtrlWrapper::CppCtorCode() const cppCode << GetName() << "->StyleClearAll();\n"; wxString font_var = GetName() + "Font"; wxString fontCode = wxCrafter::FontToCpp(PropertyString(PROP_FONT), font_var); - if(fontCode != "wxNullFont") { + if (fontCode != "wxNullFont") { cppCode << "for(int i=0; iStyleSetFont(i, " << font_var << ");\n"; cppCode << "}\n"; @@ -286,15 +297,21 @@ wxString StyledTextCtrlWrapper::CppCtorCode() const // Wrap int wrapMode = m_wrapOptions.Index(PropertyString(PROP_STC_WRAP)); - if(wrapMode != -1) { cppCode << GetName() << "->SetWrapMode(" << wrapMode << ");\n"; } + if (wrapMode != -1) { + cppCode << GetName() << "->SetWrapMode(" << wrapMode << ");\n"; + } int indentGuides = m_indentGuides.Index(PropertyString(PROP_STC_INDENT_GUIDES)); - if(indentGuides != -1) { cppCode << GetName() << "->SetIndentationGuides(" << indentGuides << ");\n"; } + if (indentGuides != -1) { + cppCode << GetName() << "->SetIndentationGuides(" << indentGuides << ");\n"; + } - if(PropertyBool(PROP_STC_VIEW_EOL) == "true") { cppCode << GetName() << "->SetViewEOL(true);\n"; } + if (PropertyBool(PROP_STC_VIEW_EOL) == "true") { + cppCode << GetName() << "->SetViewEOL(true);\n"; + } int eolMode = m_eolMode.Index(PropertyString(PROP_STC_EOL_MODE)); - if(eolMode != 3) { // 3 is invalid + if (eolMode != 3) { // 3 is invalid cppCode << GetName() << "->SetEOLMode(" << eolMode << ");\n"; } @@ -312,7 +329,7 @@ wxString StyledTextCtrlWrapper::GetWxClassName() const { return "wxStyledTextCtr void StyledTextCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { // There is no support for STC in XRC text << XRCUnknown(); @@ -320,23 +337,33 @@ void StyledTextCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const } else { text << XRCPrefix() << XRCSize() << XRCStyle() << XRCCommonAttributes(); - if(PropertyBool(PROP_STC_MARGIN_FOLD) == "true") { text << "1"; } + if (PropertyBool(PROP_STC_MARGIN_FOLD) == "true") { + text << "1"; + } - if(PropertyBool(PROP_STC_MARGIN_SYMBOL) == "true") { text << "1"; } - if(PropertyBool(PROP_STC_MARGIN_LINE_NUMBERS) == "true") { + if (PropertyBool(PROP_STC_MARGIN_SYMBOL) == "true") { + text << "1"; + } + if (PropertyBool(PROP_STC_MARGIN_LINE_NUMBERS) == "true") { text << "1"; } - if(PropertyBool(PROP_STC_MARGIN_SEPARATOR) == "true") { text << "1"; } + if (PropertyBool(PROP_STC_MARGIN_SEPARATOR) == "true") { + text << "1"; + } int wrapMode = m_wrapOptions.Index(PropertyString(PROP_STC_WRAP)); text << "" << wrapMode << ""; text << "" << m_indentGuides.Index(PropertyString(PROP_STC_INDENT_GUIDES)) << ""; - if(PropertyBool(PROP_STC_VIEW_EOL) == "true") { text << "1"; } + if (PropertyBool(PROP_STC_VIEW_EOL) == "true") { + text << "1"; + } int eolMode = m_eolMode.Index(PropertyString(PROP_STC_EOL_MODE)); - if(eolMode != 3) { text << "" << eolMode << ""; } + if (eolMode != 3) { + text << "" << eolMode << ""; + } text << "" << PropertyString(PROP_STC_LEXER) << ""; text << XRCSuffix(); diff --git a/wxcrafter/controls/styled_text_ctrl_wrapper.h b/wxcrafter/controls/styled_text_ctrl_wrapper.h index 9faba1490f..2cba221c32 100644 --- a/wxcrafter/controls/styled_text_ctrl_wrapper.h +++ b/wxcrafter/controls/styled_text_ctrl_wrapper.h @@ -2,6 +2,7 @@ #define STYLEDTEXTCTRLWRAPPER_H #include "wxc_widget.h" // Base class: WrapperBase + #include class StyledTextCtrlWrapper : public wxcWidget diff --git a/wxcrafter/controls/task_bar_icon_wrapper.cpp b/wxcrafter/controls/task_bar_icon_wrapper.cpp index 49feea7f3e..0a829d9dd1 100644 --- a/wxcrafter/controls/task_bar_icon_wrapper.cpp +++ b/wxcrafter/controls/task_bar_icon_wrapper.cpp @@ -16,8 +16,7 @@ TaskBarIconWrapper::TaskBarIconWrapper() { m_styles.Clear(); Add(PROP_TOOLTIP, _("Set the wxTaskBarIcon tooltip")); - const wxArrayString types = - StdToWX::ToArrayString({ "wxTBI_DEFAULT_TYPE", "wxTBI_DOCK", "wxTBI_CUSTOM_STATUSITEM" }); + const wxArrayString types = StdToWX::ToArrayString({"wxTBI_DEFAULT_TYPE", "wxTBI_DOCK", "wxTBI_CUSTOM_STATUSITEM"}); SetPropertyString(_("Common Settings"), "wxTaskBarIcon"); Add(PROP_TASKBAR_ICONTYPE, types, 0, _("The iconType is only applicable on wxOSX_Cocoa")); @@ -44,7 +43,7 @@ wxString TaskBarIconWrapper::CppCtorCode() const wxString code; code << GetName() << " = new " << GetRealClassName() << "(" << PropertyString(PROP_TASKBAR_ICONTYPE) << ");\n"; - if(!bmp.IsEmpty()) { + if (!bmp.IsEmpty()) { code << "{\n"; code << " wxIcon icn;\n"; code << " icn.CopyFromBitmap(" << wxcCodeGeneratorHelper::Get().BitmapCode(PropertyFile(PROP_BITMAP_PATH)) diff --git a/wxcrafter/controls/text_ctrl_wrapper.cpp b/wxcrafter/controls/text_ctrl_wrapper.cpp index c682a94a4e..f6f0720d97 100644 --- a/wxcrafter/controls/text_ctrl_wrapper.cpp +++ b/wxcrafter/controls/text_ctrl_wrapper.cpp @@ -76,7 +76,7 @@ wxString TextCtrlWrapper::CppCtorCode() const wxString code; code << CPPStandardWxCtorWithValue(wxT("0")); - if(!HasStyle(wxTE_MULTILINE)) { + if (!HasStyle(wxTE_MULTILINE)) { // Only supported for wx30 and later code << wxCrafter::WX30_BLOCK_START(); @@ -85,17 +85,17 @@ wxString TextCtrlWrapper::CppCtorCode() const } #if wxUSE_SPELLCHECK - if(IsPropertyChecked(PROP_SPELLCHECK)) { + if (IsPropertyChecked(PROP_SPELLCHECK)) { code << "\n#if wxUSE_SPELLCHECK\n"; code << GetName() << "->EnableProofCheck();\n"; code << "#endif\n"; } #endif // wxUSE_SPELLCHECK - if(IsPropertyChecked(PROP_AUTO_COMPLETE_DIRS)) { + if (IsPropertyChecked(PROP_AUTO_COMPLETE_DIRS)) { code << GetName() << "->AutoCompleteDirectories();\n"; - } else if(IsPropertyChecked(PROP_AUTO_COMPLETE_FILES)) { + } else if (IsPropertyChecked(PROP_AUTO_COMPLETE_FILES)) { code << GetName() << "->AutoCompleteFileNames();\n"; } return code; @@ -106,11 +106,11 @@ void TextCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const // Filter out maxlen if the textctrl is multiline (otherwise wx2.9 asserts); similarly hint wxString maxlen, hint; - if(!HasStyle(wxTE_MULTILINE)) { - if(wxCrafter::ToNumber(PropertyString(PROP_MAXLENGTH), -1) > 0) { + if (!HasStyle(wxTE_MULTILINE)) { + if (wxCrafter::ToNumber(PropertyString(PROP_MAXLENGTH), -1) > 0) { maxlen = "" + PropertyString(PROP_MAXLENGTH) << ""; } - if(!PropertyString(PROP_HINT).empty()) { + if (!PropertyString(PROP_HINT).empty()) { hint = "" + wxCrafter::CDATA(PropertyString(PROP_HINT)) << ""; } } @@ -125,10 +125,14 @@ void TextCtrlWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("maxlength")); - if(propertynode) { SetPropertyString(PROP_MAXLENGTH, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAXLENGTH, propertynode->GetNodeContent()); + } } void TextCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -137,10 +141,14 @@ void TextCtrlWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("value")); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("maxlength")); - if(propertynode) { SetPropertyString(PROP_MAXLENGTH, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAXLENGTH, propertynode->GetNodeContent()); + } } void TextCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -149,10 +157,14 @@ void TextCtrlWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "value"); - if(propertynode) { SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_VALUE, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindNodeByName(node, "property", "maxlength"); - if(propertynode) { SetPropertyString(PROP_MAXLENGTH, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_MAXLENGTH, propertynode->GetNodeContent()); + } } wxcWidget* TextCtrlWrapper::Clone() const { return new TextCtrlWrapper(); } diff --git a/wxcrafter/controls/timer_wrapper.cpp b/wxcrafter/controls/timer_wrapper.cpp index 21a378aa40..dd7bbf16f0 100644 --- a/wxcrafter/controls/timer_wrapper.cpp +++ b/wxcrafter/controls/timer_wrapper.cpp @@ -35,7 +35,7 @@ wxString TimerWrapper::CppCtorCode() const int interval = wxCrafter::ToNumber(PropertyString(PROP_INTERVAL), 1000); wxString cppCode; cppCode << GetName() << " = new " << GetRealClassName() << ";\n"; - if(PropertyBool(PROP_START_TIMER) == "true") { + if (PropertyBool(PROP_START_TIMER) == "true") { cppCode << GetName() << "->Start(" << interval << ", " << PropertyBool(PROP_ONE_SHOT_TIMER) << ");\n"; } return cppCode; diff --git a/wxcrafter/controls/toggle_button_wrapper.cpp b/wxcrafter/controls/toggle_button_wrapper.cpp index 1d98fcdeb3..1959fe57cd 100644 --- a/wxcrafter/controls/toggle_button_wrapper.cpp +++ b/wxcrafter/controls/toggle_button_wrapper.cpp @@ -57,7 +57,9 @@ void ToggleButtonWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("checked")); - if(propertynode) { SetPropertyString(PROP_CHECKED, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_CHECKED, propertynode->GetNodeContent()); + } } void ToggleButtonWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -66,7 +68,9 @@ void ToggleButtonWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("checked")); - if(propertynode) { SetPropertyString(PROP_CHECKED, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_CHECKED, propertynode->GetNodeContent()); + } } void ToggleButtonWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -75,5 +79,7 @@ void ToggleButtonWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "value"); - if(propertynode) { SetPropertyString(PROP_CHECKED, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_CHECKED, propertynode->GetNodeContent()); + } } diff --git a/wxcrafter/controls/top_level_win_wrapper.cpp b/wxcrafter/controls/top_level_win_wrapper.cpp index a32d034f58..035baeec6e 100644 --- a/wxcrafter/controls/top_level_win_wrapper.cpp +++ b/wxcrafter/controls/top_level_win_wrapper.cpp @@ -241,8 +241,8 @@ void TopLevelWinWrapper::GenerateCode(const wxcProjectMetadata& project, } wxFileName headerFile, sourceFile; - wxFileName baseFile(wxcProjectMetadata::Get().GetGeneratedFilesDir(), - wxcProjectMetadata::Get().GetOutputFileName()); + wxFileName baseFile( + wxcProjectMetadata::Get().GetGeneratedFilesDir(), wxcProjectMetadata::Get().GetOutputFileName()); // If the files are relative make them abs if (baseFile.IsRelative()) { diff --git a/wxcrafter/controls/top_level_win_wrapper.h b/wxcrafter/controls/top_level_win_wrapper.h index 2e79db7174..4788e23463 100644 --- a/wxcrafter/controls/top_level_win_wrapper.h +++ b/wxcrafter/controls/top_level_win_wrapper.h @@ -47,8 +47,13 @@ class TopLevelWinWrapper : public wxcWidget */ virtual wxString GetParentCtorInitArgumentList() const { return "(parent)"; } - virtual void GenerateCode(const wxcProjectMetadata& project, bool promptUser, bool baseOnly, wxString& baseCpp, - wxString& baseHeader, wxArrayString& headers, wxStringMap_t& additionalFiles); + virtual void GenerateCode(const wxcProjectMetadata& project, + bool promptUser, + bool baseOnly, + wxString& baseCpp, + wxString& baseHeader, + wxArrayString& headers, + wxStringMap_t& additionalFiles); bool IsTopWindow() const override { return true; } /** diff --git a/wxcrafter/controls/tree_ctrl_wrapper.cpp b/wxcrafter/controls/tree_ctrl_wrapper.cpp index 834a4507d0..bb8e30ca3c 100644 --- a/wxcrafter/controls/tree_ctrl_wrapper.cpp +++ b/wxcrafter/controls/tree_ctrl_wrapper.cpp @@ -1,6 +1,8 @@ #include "tree_ctrl_wrapper.h" + #include "allocator_mgr.h" #include "wxgui_defs.h" + #include TreeCtrlWrapper::TreeCtrlWrapper() @@ -21,41 +23,55 @@ TreeCtrlWrapper::TreeCtrlWrapper() PREPEND_STYLE(wxTR_MULTIPLE, false); PREPEND_STYLE(wxTR_DEFAULT_STYLE, true); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_DRAG"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_DRAG"), + wxT("wxTreeEvent"), _("The user has started dragging an item with the left mouse button.\nThe event handler must call " "wxTreeEvent::Allow() for the drag operation to continue.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_RDRAG"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_RDRAG"), + wxT("wxTreeEvent"), _("The user has started dragging an item with the right mouse button.\nThe event handler must call " "wxTreeEvent::Allow() for the drag operation to continue.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_END_DRAG"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_END_DRAG"), + wxT("wxTreeEvent"), _("The user has released the mouse after dragging an item.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT"), + wxT("wxTreeEvent"), _("Begin editing a label. This can be prevented by calling Veto().")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_END_LABEL_EDIT"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_END_LABEL_EDIT"), + wxT("wxTreeEvent"), _("The user has finished editing a label. This can be prevented by calling Veto().")); RegisterEvent(wxT("wxEVT_COMMAND_TREE_DELETE_ITEM"), wxT("wxTreeEvent"), _("A tree item has been deleted.")); RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_EXPANDED"), wxT("wxTreeEvent"), _("The item has been expanded.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_EXPANDING"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_EXPANDING"), + wxT("wxTreeEvent"), _("The item is being expanded. This can be prevented by calling Veto().")); RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_COLLAPSED"), wxT("wxTreeEvent"), _("The item has been collapsed.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_COLLAPSING"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_COLLAPSING"), + wxT("wxTreeEvent"), _("The item is being collapsed. This can be prevented by calling Veto().")); RegisterEvent(wxT("wxEVT_COMMAND_TREE_SEL_CHANGED"), wxT("wxTreeEvent"), _("Selection has changed.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_SEL_CHANGING"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_SEL_CHANGING"), + wxT("wxTreeEvent"), _("Selection is changing. This can be prevented by calling Veto().")); RegisterEvent(wxT("wxEVT_COMMAND_TREE_KEY_DOWN"), wxT("wxTreeEvent"), _("A key has been pressed.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_ACTIVATED"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_ACTIVATED"), + wxT("wxTreeEvent"), _("An item has been activated (e.g. double clicked).")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK"), + wxT("wxTreeEvent"), _("The user has clicked the item with the right mouse button.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK"), + wxT("wxTreeEvent"), _("The user has clicked the item with the middle mouse button.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK"), + wxT("wxTreeEvent"), _("The state image has been clicked. Windows only.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP"), + wxT("wxTreeEvent"), _("The opportunity to set the item tooltip is being given to the application\n (call " "wxTreeEvent::SetToolTip). Windows only.")); - RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_MENU"), wxT("wxTreeEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_TREE_ITEM_MENU"), + wxT("wxTreeEvent"), _("The context menu for the selected item has been requested,\neither by a right click or by using " "the menu key.")); diff --git a/wxcrafter/controls/tree_list_ctrl_column_wrapper.cpp b/wxcrafter/controls/tree_list_ctrl_column_wrapper.cpp index 5b11fa3d67..e427f9f3c3 100644 --- a/wxcrafter/controls/tree_list_ctrl_column_wrapper.cpp +++ b/wxcrafter/controls/tree_list_ctrl_column_wrapper.cpp @@ -17,7 +17,7 @@ TreeListCtrlColumnWrapper::TreeListCtrlColumnWrapper() m_sizerFlags.Clear(); m_properties.Clear(); - const wxArrayString alignment = StdToWX::ToArrayString({ "wxALIGN_LEFT", "wxALIGN_RIGHT", "wxALIGN_CENTER" }); + const wxArrayString alignment = StdToWX::ToArrayString({"wxALIGN_LEFT", "wxALIGN_RIGHT", "wxALIGN_CENTER"}); // FIXME: add alignment + column flags here Add(_("wxTreeListCtrl Column")); @@ -57,7 +57,7 @@ wxString TreeListCtrlColumnWrapper::GetWxClassName() const { return ""; } void TreeListCtrlColumnWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << XRCUnknown(); } else { diff --git a/wxcrafter/controls/tree_list_ctrl_wrapper.cpp b/wxcrafter/controls/tree_list_ctrl_wrapper.cpp index 0ca1516050..3ae8ba4f61 100644 --- a/wxcrafter/controls/tree_list_ctrl_wrapper.cpp +++ b/wxcrafter/controls/tree_list_ctrl_wrapper.cpp @@ -16,32 +16,39 @@ TreeListCtrlWrapper::TreeListCtrlWrapper() PREPEND_STYLE(wxTL_DEFAULT_STYLE, true); RegisterEvent( - "wxEVT_TREELIST_SELECTION_CHANGED", "wxTreeListEvent", + "wxEVT_TREELIST_SELECTION_CHANGED", + "wxTreeListEvent", _("Process wxEVT_TREELIST_SELECTION_CHANGED event and notifies about the selection change in the " "control. In the single selection case the item indicated by the event has been selected and " "previously selected item, if any, was deselected. In multiple selection case, the selection of this " "item has just changed (it may have been either selected or deselected) but notice that the " "selection of other items could have changed as well, use wxTreeListCtrl::GetSelections() to " "retrieve the new selection if necessary.")); - RegisterEvent("wxEVT_TREELIST_ITEM_EXPANDING", "wxTreeListEvent", + RegisterEvent("wxEVT_TREELIST_ITEM_EXPANDING", + "wxTreeListEvent", _("Process wxEVT_TREELIST_ITEM_EXPANDING event notifying about the given branch being expanded. This " "event is sent before the expansion occurs and can be vetoed to prevent it from happening.")); RegisterEvent( - "wxEVT_TREELIST_ITEM_EXPANDED", "wxTreeListEvent", + "wxEVT_TREELIST_ITEM_EXPANDED", + "wxTreeListEvent", _("Process wxEVT_TREELIST_ITEM_EXPANDED event notifying about the expansion of the given branch. This " "event is sent after the expansion occurs and can't be vetoed.")); RegisterEvent( - "wxEVT_TREELIST_ITEM_CHECKED", "wxTreeListEvent", + "wxEVT_TREELIST_ITEM_CHECKED", + "wxTreeListEvent", _("Process wxEVT_TREELIST_ITEM_CHECKED event notifying about the user checking or unchecking the item. " "You can use wxTreeListCtrl::GetCheckedState() to retrieve the new item state and " "wxTreeListEvent::GetOldCheckedState() to get the previous one.")); - RegisterEvent("wxEVT_TREELIST_ITEM_ACTIVATED", "wxTreeListEvent", + RegisterEvent("wxEVT_TREELIST_ITEM_ACTIVATED", + "wxTreeListEvent", _("Process wxEVT_TREELIST_ITEM_ACTIVATED event notifying about the user double clicking the item or " "activating it from keyboard.")); - RegisterEvent("wxEVT_TREELIST_ITEM_CONTEXT_MENU", "wxTreeListEvent", + RegisterEvent("wxEVT_TREELIST_ITEM_CONTEXT_MENU", + "wxTreeListEvent", _("Process wxEVT_TREELIST_ITEM_CONTEXT_MENU event indicating that the popup menu for the given item " "should be displayed.")); - RegisterEvent("wxEVT_TREELIST_COLUMN_SORTED", "wxTreeListEvent", + RegisterEvent("wxEVT_TREELIST_COLUMN_SORTED", + "wxTreeListEvent", _("Process wxEVT_TREELIST_COLUMN_SORTED event indicating that the control contents has just been " "resorted using the specified column. The event doesn't carry the sort direction, use " "GetSortColumn() method if you need to know it.")); diff --git a/wxcrafter/controls/web_view_wrapper.cpp b/wxcrafter/controls/web_view_wrapper.cpp index 68401eadfe..062c83ee94 100644 --- a/wxcrafter/controls/web_view_wrapper.cpp +++ b/wxcrafter/controls/web_view_wrapper.cpp @@ -7,27 +7,33 @@ WebViewWrapper::WebViewWrapper() : wxcWidget(ID_WXWEBVIEW) { - RegisterEvent("wxEVT_COMMAND_WEBVIEW_NAVIGATING", "wxWebViewEvent", + RegisterEvent("wxEVT_COMMAND_WEBVIEW_NAVIGATING", + "wxWebViewEvent", _("Process a wxEVT_COMMAND_WEBVIEW_NAVIGATING event, generated before trying to get a resource. This " "event may be vetoed to prevent navigating to this resource. Note that if the displayed HTML " "document has several frames, one such event will be generated per frame")); - RegisterEvent("wxEVT_COMMAND_WEBVIEW_NAVIGATED", "wxWebViewEvent", + RegisterEvent("wxEVT_COMMAND_WEBVIEW_NAVIGATED", + "wxWebViewEvent", _("Process a wxEVT_COMMAND_WEBVIEW_NAVIGATED event generated after it was confirmed that a resource " "would be requested. This event may not be vetoed. Note that if the displayed HTML document has " "several frames, one such event will be generated per frame.")); - RegisterEvent("wxEVT_COMMAND_WEBVIEW_LOADED", "wxWebViewEvent", + RegisterEvent("wxEVT_COMMAND_WEBVIEW_LOADED", + "wxWebViewEvent", _("Process a wxEVT_COMMAND_WEBVIEW_LOADED event generated when the document is fully loaded and " "displayed. Note that if the displayed HTML document has several frames, one such event will be " "generated per frame.")); - RegisterEvent("wxEVT_COMMAND_WEBVIEW_ERROR", "wxWebViewEvent", + RegisterEvent("wxEVT_COMMAND_WEBVIEW_ERROR", + "wxWebViewEvent", _("Process a wxEVT_COMMAND_WEBVIEW_ERROR event generated when a navigation error occurs. The integer " "associated with this event will be a wxWebNavigationError item. The string associated with this " "event may contain a backend-specific more precise error message/code")); - RegisterEvent("wxEVT_COMMAND_WEBVIEW_NEWWINDOW", "wxWebViewEvent", + RegisterEvent("wxEVT_COMMAND_WEBVIEW_NEWWINDOW", + "wxWebViewEvent", _("Process a wxEVT_COMMAND_WEBVIEW_NEWWINDOW event, generated when a new window is created. You must " "handle this event if you want anything to happen, for example to load the page in a new window or " "tab.")); - RegisterEvent("wxEVT_COMMAND_WEBVIEW_TITLE_CHANGED", "wxWebViewEvent", + RegisterEvent("wxEVT_COMMAND_WEBVIEW_TITLE_CHANGED", + "wxWebViewEvent", _("Process a wxEVT_COMMAND_WEBVIEW_TITLE_CHANGED event, generated when the page title changes. Use " "GetString to get the title.")); @@ -67,9 +73,9 @@ wxString WebViewWrapper::GetWxClassName() const { return "wxWebView"; } void WebViewWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_LIVE) { + if (type == XRC_LIVE) { text << XRCUnknown(); - } else if(type == XRC_PREVIEW) { + } else if (type == XRC_PREVIEW) { text << XRCPrefix() << XRCSize() << XRCStyle() << XRCCommonAttributes() << "" << wxCrafter::CDATA(PropertyString(PROP_URL)) << "" << XRCSuffix(); } else { diff --git a/wxcrafter/sizers/box_sizer_wrapper.cpp b/wxcrafter/sizers/box_sizer_wrapper.cpp index 0c5894c672..0f126a5dac 100644 --- a/wxcrafter/sizers/box_sizer_wrapper.cpp +++ b/wxcrafter/sizers/box_sizer_wrapper.cpp @@ -11,7 +11,7 @@ BoxSizerWrapper::BoxSizerWrapper() m_type = ID_WXBOXSIZER; m_styles.Clear(); // Sizer has no styles - const wxArrayString arr = StdToWX::ToArrayString({ "wxVERTICAL", "wxHORIZONTAL" }); + const wxArrayString arr = StdToWX::ToArrayString({"wxVERTICAL", "wxHORIZONTAL"}); SetPropertyString(_("Common Settings"), "wxBoxSizer"); Add(PROP_ORIENTATION, arr, 0, _("Sizer orientation")); @@ -28,7 +28,7 @@ wxString BoxSizerWrapper::GetWxClassName() const { return "wxBoxSizer"; } wxString BoxSizerWrapper::CppCtorCode() const { wxString code; - if(!KeepAsClassMember()) { + if (!KeepAsClassMember()) { code << "wxBoxSizer* "; } @@ -36,8 +36,8 @@ wxString BoxSizerWrapper::CppCtorCode() const code << GenerateMinSizeCode(); - if(IsMainSizer()) { - if(GetParent()->IsTopWindow()) { + if (IsMainSizer()) { + if (GetParent()->IsTopWindow()) { code << "this->SetSizer(" << GetName() << ");\n"; } else { @@ -65,7 +65,7 @@ void BoxSizerWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "orient"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_ORIENTATION, propertynode->GetNodeContent()); } } @@ -77,12 +77,12 @@ void BoxSizerWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) // wxSmith doesn't use "name" here, but "variable" means the same thing afaict wxString value = XmlUtils::ReadString(node, "variable"); - if(!value.empty()) { + if (!value.empty()) { SetName(value); } wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "orient"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_ORIENTATION, propertynode->GetNodeContent()); } } @@ -93,7 +93,7 @@ void BoxSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "orient"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_ORIENTATION, propertynode->GetNodeContent()); } } diff --git a/wxcrafter/sizers/flexgridsizer_wrapper.cpp b/wxcrafter/sizers/flexgridsizer_wrapper.cpp index 4130179eb6..237875cb48 100644 --- a/wxcrafter/sizers/flexgridsizer_wrapper.cpp +++ b/wxcrafter/sizers/flexgridsizer_wrapper.cpp @@ -32,7 +32,7 @@ wxString FlexGridSizerWrapper::CppCtorCode() const wxArrayString growCols = wxCrafter::Split(PropertyString(PROP_GROW_COLS), ","); wxArrayString growRows = wxCrafter::Split(PropertyString(PROP_GROW_ROWS), ","); - if(!KeepAsClassMember()) { + if (!KeepAsClassMember()) { code << "wxFlexGridSizer* "; } @@ -41,16 +41,16 @@ wxString FlexGridSizerWrapper::CppCtorCode() const << GetName() << "->SetFlexibleDirection( wxBOTH );\n" << GetName() << "->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );\n"; - for(size_t i = 0; i < growCols.GetCount(); i++) { + for (size_t i = 0; i < growCols.GetCount(); i++) { code << GetName() << "->AddGrowableCol(" << growCols.Item(i) << ");\n"; } - for(size_t i = 0; i < growRows.GetCount(); i++) { + for (size_t i = 0; i < growRows.GetCount(); i++) { code << GetName() << "->AddGrowableRow(" << growRows.Item(i) << ");\n"; } code << GenerateMinSizeCode(); - if(IsMainSizer()) { - if(GetParent()->IsTopWindow()) { + if (IsMainSizer()) { + if (GetParent()->IsTopWindow()) { code << "this->SetSizer(" << GetName() << ");\n"; } else { code << GetWindowParent() << "->SetSizer(" << GetName() << ");\n"; @@ -91,32 +91,32 @@ void FlexGridSizerWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) void FlexGridSizerWrapper::DoLoadXRCProperties(const wxXmlNode* node) { wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "cols"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_COLS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "rows"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_ROWS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "vgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_VGAP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "hgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_HGAP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "growablecols"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_GROW_COLS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "growablerows"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_GROW_ROWS, propertynode->GetNodeContent()); } } @@ -127,32 +127,32 @@ void FlexGridSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "cols"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_COLS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "rows"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_ROWS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "vgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_VGAP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "hgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_HGAP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "growablecols"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_GROW_COLS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "growablerows"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_GROW_ROWS, propertynode->GetNodeContent()); } } diff --git a/wxcrafter/sizers/grid_bag_sizer_wrapper.cpp b/wxcrafter/sizers/grid_bag_sizer_wrapper.cpp index 49aaa9cd6e..afec0876f6 100644 --- a/wxcrafter/sizers/grid_bag_sizer_wrapper.cpp +++ b/wxcrafter/sizers/grid_bag_sizer_wrapper.cpp @@ -26,15 +26,15 @@ wxString GridBagSizerWrapper::CppCtorCode() const { wxString code; - if(!KeepAsClassMember()) { + if (!KeepAsClassMember()) { code << "wxGridBagSizer* "; } code << GetName() << " = new wxGridBagSizer(" << PropertyString(PROP_VGAP) << ", " << PropertyString(PROP_HGAP) << ");\n"; code << GenerateMinSizeCode(); - if(IsMainSizer()) { - if(GetParent()->IsTopWindow()) { + if (IsMainSizer()) { + if (GetParent()->IsTopWindow()) { code << "this->SetSizer(" << GetName() << ");\n"; } else { code << GetParent()->GetName() << "->SetSizer(" << GetName() << ");\n"; @@ -79,22 +79,22 @@ void GridBagSizerWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) void GridBagSizerWrapper::DoLoadXRCProperties(const wxXmlNode* node) { wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "vgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_VGAP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "hgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_HGAP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "growablecols"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_GROW_COLS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "growablerows"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_GROW_ROWS, propertynode->GetNodeContent()); } } @@ -105,22 +105,22 @@ void GridBagSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "vgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_VGAP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "hgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_HGAP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "growablecols"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_GROW_COLS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "growablerows"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_GROW_ROWS, propertynode->GetNodeContent()); } } @@ -130,11 +130,11 @@ wxString GridBagSizerWrapper::DoGenerateCppCtorCode_End() const wxString code; wxArrayString growCols = wxCrafter::Split(PropertyString(PROP_GROW_COLS), ","); wxArrayString growRows = wxCrafter::Split(PropertyString(PROP_GROW_ROWS), ","); - for(size_t i = 0; i < growCols.GetCount(); i++) { + for (size_t i = 0; i < growCols.GetCount(); i++) { code << GetName() << "->AddGrowableCol(" << growCols.Item(i) << ");\n"; } - for(size_t i = 0; i < growRows.GetCount(); i++) { + for (size_t i = 0; i < growRows.GetCount(); i++) { code << GetName() << "->AddGrowableRow(" << growRows.Item(i) << ");\n"; } return code; diff --git a/wxcrafter/sizers/grid_sizer_wrapper.cpp b/wxcrafter/sizers/grid_sizer_wrapper.cpp index ef9d952ee3..c4d64e3a7c 100644 --- a/wxcrafter/sizers/grid_sizer_wrapper.cpp +++ b/wxcrafter/sizers/grid_sizer_wrapper.cpp @@ -26,7 +26,7 @@ wxString GridSizerWrapper::CppCtorCode() const { wxString code; - if(!KeepAsClassMember()) { + if (!KeepAsClassMember()) { code << "wxGridSizer* "; } @@ -35,8 +35,8 @@ wxString GridSizerWrapper::CppCtorCode() const code << GenerateMinSizeCode(); - if(IsMainSizer()) { - if(GetParent()->IsTopWindow()) { + if (IsMainSizer()) { + if (GetParent()->IsTopWindow()) { code << "this->SetSizer(" << GetName() << ");\n"; } else { code << GetParent()->GetName() << "->SetSizer(" << GetName() << ");\n"; @@ -75,22 +75,22 @@ void GridSizerWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) void GridSizerWrapper::DoLoadXRCProperties(const wxXmlNode* node) { wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "cols"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_COLS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "rows"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_ROWS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "vgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_VGAP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindFirstByTagName(node, "hgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_HGAP, propertynode->GetNodeContent()); } } @@ -101,22 +101,22 @@ void GridSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "cols"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_COLS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "rows"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_ROWS, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "vgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_VGAP, propertynode->GetNodeContent()); } propertynode = XmlUtils::FindNodeByName(node, "property", "hgap"); - if(propertynode) { + if (propertynode) { SetPropertyString(PROP_HGAP, propertynode->GetNodeContent()); } } diff --git a/wxcrafter/sizers/sizer_wrapper_base.cpp b/wxcrafter/sizers/sizer_wrapper_base.cpp index 4240c8c57d..b133aaa328 100644 --- a/wxcrafter/sizers/sizer_wrapper_base.cpp +++ b/wxcrafter/sizers/sizer_wrapper_base.cpp @@ -35,7 +35,7 @@ wxString SizerWrapperBase::GenerateMinSizeCode() const { wxString code; wxSize sz = wxCrafter::DecodeSize(PropertyString(PROP_MINSIZE)); - if(sz != wxDefaultSize) { + if (sz != wxDefaultSize) { code << GetName() << "->SetMinSize(" << wxCrafter::EncodeSize(sz) << ");\n"; } return code; @@ -43,13 +43,13 @@ wxString SizerWrapperBase::GenerateMinSizeCode() const wxString SizerWrapperBase::GenerateMinSizeXRC() const { - if(!IsMainSizer()) { + if (!IsMainSizer()) { return wxEmptyString; } wxString code; wxSize sz = wxCrafter::DecodeSize(m_parent->PropertyString(PROP_MINSIZE)); - if(sz != wxDefaultSize) { + if (sz != wxDefaultSize) { code << "" << wxCrafter::EncodeSize(sz) << "\n"; } return code; diff --git a/wxcrafter/sizers/static_box_sizer_wrapper.cpp b/wxcrafter/sizers/static_box_sizer_wrapper.cpp index 430c5823c8..2e3ef8b730 100644 --- a/wxcrafter/sizers/static_box_sizer_wrapper.cpp +++ b/wxcrafter/sizers/static_box_sizer_wrapper.cpp @@ -11,7 +11,7 @@ StaticBoxSizerWrapper::StaticBoxSizerWrapper() m_type = ID_WXSTATICBOXSIZER; m_styles.Clear(); // Sizer has no styles - const wxArrayString arr = StdToWX::ToArrayString({ "Vertical", "Horizontal" }); + const wxArrayString arr = StdToWX::ToArrayString({"Vertical", "Horizontal"}); SetPropertyString(_("Common Settings"), "wxStaticBoxSizer"); Add(PROP_ORIENTATION, arr, 0, _("Sizer orientation")); @@ -32,15 +32,15 @@ wxString StaticBoxSizerWrapper::CppCtorCode() const wxString staticBox; staticBox << " new wxStaticBox(" << GetWindowParent() << ", wxID_ANY, " << Label() << ")"; - if(!KeepAsClassMember()) { + if (!KeepAsClassMember()) { code << "wxStaticBoxSizer* "; } code << GetName() << " = new wxStaticBoxSizer(" << staticBox << ", " << orient << ");\n"; code << GenerateMinSizeCode(); - if(IsMainSizer()) { - if(GetParent()->IsTopWindow()) { + if (IsMainSizer()) { + if (GetParent()->IsTopWindow()) { code << "this->SetSizer(" << GetName() << ");\n"; } else { @@ -80,7 +80,7 @@ void StaticBoxSizerWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "orient"); - if(propertynode) { + if (propertynode) { // BoxSizerWrapper uses wxVERTICAL/wxHORIZONTAL but for some reason StaticBoxSizerWrapper has // Vertical/Horizontal bool horizontal = propertynode->GetNodeContent().Lower().Contains("horizontal"); @@ -94,7 +94,7 @@ void StaticBoxSizerWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, "orient"); - if(propertynode) { + if (propertynode) { bool horizontal = propertynode->GetNodeContent().Lower().Contains("horizontal"); SetPropertyString(PROP_ORIENTATION, horizontal ? "Horizontal" : "Vertical"); } @@ -106,7 +106,7 @@ void StaticBoxSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "orient"); - if(propertynode) { + if (propertynode) { bool horizontal = propertynode->GetNodeContent().Lower().Contains("horizontal"); SetPropertyString(PROP_ORIENTATION, horizontal ? "Horizontal" : "Vertical"); } diff --git a/wxcrafter/sizers/std_button_wrapper.cpp b/wxcrafter/sizers/std_button_wrapper.cpp index 2e6979b3b7..cec95b8e3a 100644 --- a/wxcrafter/sizers/std_button_wrapper.cpp +++ b/wxcrafter/sizers/std_button_wrapper.cpp @@ -14,10 +14,18 @@ StdButtonWrapper::StdButtonWrapper() : wxcWidget(ID_WXSTDBUTTON) { m_properties.Clear(); - const wxArrayString ids = StdToWX::ToArrayString({ "wxID_OK", "wxID_YES", "wxID_SAVE", "wxID_APPLY", "wxID_CLOSE", - "wxID_NO", "wxID_CANCEL", "wxID_HELP", "wxID_CONTEXT_HELP" }); + const wxArrayString ids = StdToWX::ToArrayString({"wxID_OK", + "wxID_YES", + "wxID_SAVE", + "wxID_APPLY", + "wxID_CLOSE", + "wxID_NO", + "wxID_CANCEL", + "wxID_HELP", + "wxID_CONTEXT_HELP"}); - RegisterEvent(wxT("wxEVT_COMMAND_BUTTON_CLICKED"), wxT("wxCommandEvent"), + RegisterEvent(wxT("wxEVT_COMMAND_BUTTON_CLICKED"), + wxT("wxCommandEvent"), _("Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked."), wxT("wxCommandEventHandler")); @@ -36,7 +44,9 @@ wxString StdButtonWrapper::CppCtorCode() const { wxString code; code << CPPStandardWxCtorWithLabel("0"); - if(PropertyString(PROP_DEFAULT_BUTTON) == wxT("1")) { code << GetName() << wxT("->SetDefault();\n"); } + if (PropertyString(PROP_DEFAULT_BUTTON) == wxT("1")) { + code << GetName() << wxT("->SetDefault();\n"); + } code << CPPCommonAttributes(); return code; } @@ -59,7 +69,9 @@ void StdButtonWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("default")); - if(propertynode) { SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_DEFAULT_BUTTON, propertynode->GetNodeContent()); + } } // wxFB doesn't do anything here diff --git a/wxcrafter/sizers/std_dialog_button_sizer_wrapper.cpp b/wxcrafter/sizers/std_dialog_button_sizer_wrapper.cpp index cab87b76c9..031c527be3 100644 --- a/wxcrafter/sizers/std_dialog_button_sizer_wrapper.cpp +++ b/wxcrafter/sizers/std_dialog_button_sizer_wrapper.cpp @@ -40,7 +40,7 @@ void StdDialogButtonSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) using Pair_t = std::pair; using Vector_t = std::vector; static Vector_t s_buttons; - if(s_buttons.empty()) { + if (s_buttons.empty()) { s_buttons.push_back(Pair_t("OK", "wxID_OK")); s_buttons.push_back(Pair_t("Cancel", "wxID_CANCEL")); s_buttons.push_back(Pair_t("Apply", "wxID_APPLY")); @@ -55,14 +55,14 @@ void StdDialogButtonSizerWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) for (const auto& [buttonname, id] : s_buttons) { wxString value; wxXmlNode* child = node->GetChildren(); - while(child) { + while (child) { wxString childname(child->GetName()); - if(childname == wxT("property")) { + if (childname == wxT("property")) { wxString attr(XmlUtils::ReadString(child, wxT("name"))); - if(attr == buttonname) { + if (attr == buttonname) { value = child->GetNodeContent(); - if(value == "1") { + if (value == "1") { wxcWidget* sbwrapper = Allocator::Instance()->Create(ID_WXSTDBUTTON); wxCHECK_RET(sbwrapper, wxT("Failed to create a stdbtnwrapper")); // We've created a button; afaict there're no styles/properties to add to it. Just set its ID diff --git a/wxcrafter/sizers/std_dialog_button_sizer_wrapper.h b/wxcrafter/sizers/std_dialog_button_sizer_wrapper.h index f668e929fd..68ad33952e 100644 --- a/wxcrafter/sizers/std_dialog_button_sizer_wrapper.h +++ b/wxcrafter/sizers/std_dialog_button_sizer_wrapper.h @@ -2,6 +2,7 @@ #define STDDIALOGBUTTONSIZERWRAPPER_H #include "wxc_widget.h" // Base class: WrapperBase + #include class StdDialogButtonSizerWrapper : public wxEvtHandler, public wxcWidget diff --git a/wxcrafter/src/AboutDlg.cpp b/wxcrafter/src/AboutDlg.cpp index c3dc109807..1398167fbd 100644 --- a/wxcrafter/src/AboutDlg.cpp +++ b/wxcrafter/src/AboutDlg.cpp @@ -19,7 +19,7 @@ wxcAboutDlg::wxcAboutDlg(wxWindow* parent) m_staticTextVersion->SetLabel(vers); auto lexer = ColoursAndFontsManager::Get().GetLexer("text"); - if(lexer) { + if (lexer) { lexer->ApplySystemColours(m_stcLicense); } diff --git a/wxcrafter/src/BitmapSelectorDlg.cpp b/wxcrafter/src/BitmapSelectorDlg.cpp index dab57ea2d6..a4e3f9d0c1 100644 --- a/wxcrafter/src/BitmapSelectorDlg.cpp +++ b/wxcrafter/src/BitmapSelectorDlg.cpp @@ -12,59 +12,59 @@ BitmapSelectorDlg::BitmapSelectorDlg(wxWindow* parent, const wxString& selection) : BitmapSelectorDlgBase(parent) { - wxArrayString arr = StdToWX::ToArrayString({ wxT("wxART_ERROR"), - wxT("wxART_QUESTION"), - wxT("wxART_WARNING"), - wxT("wxART_INFORMATION"), - wxT("wxART_ADD_BOOKMARK"), - wxT("wxART_DEL_BOOKMARK"), - wxT("wxART_HELP_SIDE_PANEL"), - wxT("wxART_HELP_SETTINGS"), - wxT("wxART_HELP_BOOK"), - wxT("wxART_HELP_FOLDER"), - wxT("wxART_HELP_PAGE"), - wxT("wxART_GO_BACK"), - wxT("wxART_GO_FORWARD"), - wxT("wxART_GO_UP"), - wxT("wxART_GO_DOWN"), - wxT("wxART_GO_TO_PARENT"), - wxT("wxART_GO_HOME"), - wxT("wxART_GOTO_FIRST"), - wxT("wxART_GOTO_LAST"), - wxT("wxART_PRINT"), - wxT("wxART_HELP"), - wxT("wxART_TIP"), - wxT("wxART_REPORT_VIEW"), - wxT("wxART_LIST_VIEW"), - wxT("wxART_NEW_DIR"), - wxT("wxART_FOLDER"), - wxT("wxART_FOLDER_OPEN"), - wxT("wxART_GO_DIR_UP"), - wxT("wxART_EXECUTABLE_FILE"), - wxT("wxART_NORMAL_FILE"), - wxT("wxART_TICK_MARK"), - wxT("wxART_CROSS_MARK"), - wxT("wxART_MISSING_IMAGE"), - wxT("wxART_NEW"), - wxT("wxART_FILE_OPEN"), - wxT("wxART_FILE_SAVE"), - wxT("wxART_FILE_SAVE_AS"), - wxT("wxART_DELETE"), - wxT("wxART_COPY"), - wxT("wxART_CUT"), - wxT("wxART_PASTE"), - wxT("wxART_UNDO"), - wxT("wxART_REDO"), - wxT("wxART_PLUS"), - wxT("wxART_MINUS"), - wxT("wxART_CLOSE"), - wxT("wxART_QUIT"), - wxT("wxART_FIND"), - wxT("wxART_FIND_AND_REPLACE"), - wxT("wxART_HARDDISK"), - wxT("wxART_FLOPPY"), - wxT("wxART_CDROM"), - wxT("wxART_REMOVABLE") }); + wxArrayString arr = StdToWX::ToArrayString({wxT("wxART_ERROR"), + wxT("wxART_QUESTION"), + wxT("wxART_WARNING"), + wxT("wxART_INFORMATION"), + wxT("wxART_ADD_BOOKMARK"), + wxT("wxART_DEL_BOOKMARK"), + wxT("wxART_HELP_SIDE_PANEL"), + wxT("wxART_HELP_SETTINGS"), + wxT("wxART_HELP_BOOK"), + wxT("wxART_HELP_FOLDER"), + wxT("wxART_HELP_PAGE"), + wxT("wxART_GO_BACK"), + wxT("wxART_GO_FORWARD"), + wxT("wxART_GO_UP"), + wxT("wxART_GO_DOWN"), + wxT("wxART_GO_TO_PARENT"), + wxT("wxART_GO_HOME"), + wxT("wxART_GOTO_FIRST"), + wxT("wxART_GOTO_LAST"), + wxT("wxART_PRINT"), + wxT("wxART_HELP"), + wxT("wxART_TIP"), + wxT("wxART_REPORT_VIEW"), + wxT("wxART_LIST_VIEW"), + wxT("wxART_NEW_DIR"), + wxT("wxART_FOLDER"), + wxT("wxART_FOLDER_OPEN"), + wxT("wxART_GO_DIR_UP"), + wxT("wxART_EXECUTABLE_FILE"), + wxT("wxART_NORMAL_FILE"), + wxT("wxART_TICK_MARK"), + wxT("wxART_CROSS_MARK"), + wxT("wxART_MISSING_IMAGE"), + wxT("wxART_NEW"), + wxT("wxART_FILE_OPEN"), + wxT("wxART_FILE_SAVE"), + wxT("wxART_FILE_SAVE_AS"), + wxT("wxART_DELETE"), + wxT("wxART_COPY"), + wxT("wxART_CUT"), + wxT("wxART_PASTE"), + wxT("wxART_UNDO"), + wxT("wxART_REDO"), + wxT("wxART_PLUS"), + wxT("wxART_MINUS"), + wxT("wxART_CLOSE"), + wxT("wxART_QUIT"), + wxT("wxART_FIND"), + wxT("wxART_FIND_AND_REPLACE"), + wxT("wxART_HARDDISK"), + wxT("wxART_FLOPPY"), + wxT("wxART_CDROM"), + wxT("wxART_REMOVABLE")}); arr.Sort(); m_choiceArtID->Append(arr); @@ -72,16 +72,22 @@ BitmapSelectorDlg::BitmapSelectorDlg(wxWindow* parent, const wxString& selection m_checkBoxConvertToRelativePath->SetValue(!wxcSettings::Get().HasFlag(wxcSettings::DONT_USE_RELATIVE_BITMAPS)); wxString artID, clientID, sizeHint; - if(wxCrafter::IsArtProviderBitmap(selection, artID, clientID, sizeHint)) { + if (wxCrafter::IsArtProviderBitmap(selection, artID, clientID, sizeHint)) { int where = m_choiceArtClientID->FindString(clientID); - if(where != wxNOT_FOUND) { m_choiceArtClientID->SetSelection(where); } + if (where != wxNOT_FOUND) { + m_choiceArtClientID->SetSelection(where); + } where = m_choiceArtID->FindString(artID); - if(where != wxNOT_FOUND) { m_choiceArtID->SetSelection(where); } + if (where != wxNOT_FOUND) { + m_choiceArtID->SetSelection(where); + } where = m_choiceSize->FindString(sizeHint); - if(where != wxNOT_FOUND) { m_choiceSize->SetSelection(where); } + if (where != wxNOT_FOUND) { + m_choiceSize->SetSelection(where); + } m_checkBoxSelectFile->SetValue(false); m_checkBoxArtProvider->SetValue(true); @@ -92,7 +98,7 @@ BitmapSelectorDlg::BitmapSelectorDlg(wxWindow* parent, const wxString& selection m_checkBoxArtProvider->SetValue(false); wxFileName fn(selection); - if(!fn.IsRelative() && m_checkBoxConvertToRelativePath->IsChecked()) { + if (!fn.IsRelative() && m_checkBoxConvertToRelativePath->IsChecked()) { fn.MakeRelativeTo(wxcProjectMetadata::Get().GetProjectPath()); } m_textCtrlFile->ChangeValue(wxCrafter::ToUnixPath(fn.GetFullPath())); @@ -103,24 +109,26 @@ BitmapSelectorDlg::BitmapSelectorDlg(wxWindow* parent, const wxString& selection BitmapSelectorDlg::~BitmapSelectorDlg() { - wxcSettings::Get().EnableFlag(wxcSettings::DONT_USE_RELATIVE_BITMAPS, - !m_checkBoxConvertToRelativePath->IsChecked()); + wxcSettings::Get().EnableFlag( + wxcSettings::DONT_USE_RELATIVE_BITMAPS, !m_checkBoxConvertToRelativePath->IsChecked()); } void BitmapSelectorDlg::OnBrowseFile(wxCommandEvent& event) { wxString initialFileValue = m_textCtrlFile->GetValue(); wxFileName fnBitmap(initialFileValue); - if(fnBitmap.IsRelative()) { fnBitmap.MakeAbsolute(wxcProjectMetadata::Get().GetProjectPath()); } + if (fnBitmap.IsRelative()) { + fnBitmap.MakeAbsolute(wxcProjectMetadata::Get().GetProjectPath()); + } initialFileValue = fnBitmap.GetFullPath(); wxString wildcard = wxT("PNG files (*.png)|*.png|BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif|All files (*)|*"); - wxString newPath = ::wxFileSelector(_("Select bitmap"), fnBitmap.GetPath(), fnBitmap.GetFullName(), wxEmptyString, - wildcard, wxFD_OPEN); + wxString newPath = ::wxFileSelector( + _("Select bitmap"), fnBitmap.GetPath(), fnBitmap.GetFullName(), wxEmptyString, wildcard, wxFD_OPEN); - if(newPath.IsEmpty() == false) { + if (newPath.IsEmpty() == false) { wxFileName newFilePath(newPath); - if(m_checkBoxConvertToRelativePath->IsChecked()) { + if (m_checkBoxConvertToRelativePath->IsChecked()) { newFilePath.MakeRelativeTo(wxcProjectMetadata::Get().GetProjectPath()); } m_textCtrlFile->ChangeValue(wxCrafter::ToUnixPath(newFilePath.GetFullPath())); @@ -136,7 +144,7 @@ void BitmapSelectorDlg::OnUserArtProviderUI(wxUpdateUIEvent& event) wxString BitmapSelectorDlg::GetBitmapFile() const { - if(m_checkBoxArtProvider->IsChecked()) { + if (m_checkBoxArtProvider->IsChecked()) { wxString str; wxString size = m_choiceSize->GetStringSelection(); str << m_choiceArtID->GetStringSelection() << "," << m_choiceArtClientID->GetStringSelection() << "," << size; @@ -153,7 +161,7 @@ void BitmapSelectorDlg::OnUserArtProvider(wxCommandEvent& event) { m_checkBoxSel void BitmapSelectorDlg::OnUseRelativePaths(wxCommandEvent& event) { wxFileName newFilePath(m_textCtrlFile->GetValue()); - if(event.IsChecked()) { + if (event.IsChecked()) { newFilePath.MakeRelativeTo(wxcProjectMetadata::Get().GetProjectPath()); } else { newFilePath.MakeAbsolute(wxcProjectMetadata::Get().GetProjectPath()); diff --git a/wxcrafter/src/allocator_mgr.cpp b/wxcrafter/src/allocator_mgr.cpp index 35da9ad044..921068f65c 100644 --- a/wxcrafter/src/allocator_mgr.cpp +++ b/wxcrafter/src/allocator_mgr.cpp @@ -219,7 +219,8 @@ Allocator::Allocator() Register(new ScrolledWindowWrapper(), "wxscrolledwindow"); Register(new NotebookWrapper(), "wxnotebook"); Register(new NotebookPageWrapper(), "notebook-page"); - Register(new NotebookPageWrapper(), "notebook-page", + Register(new NotebookPageWrapper(), + "notebook-page", ID_WXTREEBOOK_SUB_PAGE); // re-register the same object but with different ID Register(new ToolBookWrapper(), "wxtoolbook"); Register(new ListBookWrapper(), "wxlistbook"); @@ -387,7 +388,7 @@ wxMenu* Allocator::CreateControlsMenu() const Allocator* Allocator::Instance() { - if(ms_instance == 0) { + if (ms_instance == 0) { ms_instance = new Allocator(); } return ms_instance; @@ -403,7 +404,7 @@ void Allocator::Release() wxcWidget* Allocator::Create(int id) { Map_t::iterator iter = m_objs.find(id); - if(iter == m_objs.end()) + if (iter == m_objs.end()) return NULL; return iter->second->Clone(); @@ -412,7 +413,7 @@ wxcWidget* Allocator::Create(int id) void Allocator::Register(wxcWidget* obj, const wxString& bmpname, int id) { int objId = id; - if(objId == -1) { + if (objId == -1) { objId = obj->GetType(); } m_objs[objId] = obj; @@ -422,7 +423,7 @@ void Allocator::Register(wxcWidget* obj, const wxString& bmpname, int id) int Allocator::GetImageId(int controlId) const { ImageMap_t::const_iterator iter = m_imageIds.find(controlId); - if(iter == m_imageIds.end()) + if (iter == m_imageIds.end()) return -1; return iter->second; } @@ -433,7 +434,7 @@ wxcWidget* Allocator::CreateWrapperFromJSON(const JSONItem& json) int type = json.namedObject(wxT("m_type")).toInt(); wrapper = Create(type); - if(!wrapper) + if (!wrapper) return NULL; wrapper->UnSerialize(json); @@ -539,10 +540,10 @@ void Allocator::PrepareMenu(wxMenu& menu, wxcWidget* item) { // ADD_NEW_CONTROL bool isChildOfTreeBook = false; - if(item) { + if (item) { wxcWidget* parent = item->GetParent(); - while(parent) { - if(parent->GetType() == ID_WXTREEBOOK) { + while (parent) { + if (parent->GetType() == ID_WXTREEBOOK) { isChildOfTreeBook = true; break; } @@ -551,33 +552,33 @@ void Allocator::PrepareMenu(wxMenu& menu, wxcWidget* item) } FLAGS_t flags = DoGetValidMenus(item); - if(flags & MT_PG_MANAGER) { + if (flags & MT_PG_MANAGER) { menu.Append(ID_WXPGPROPERTY, _("Add wxPGProperty")); } - if(flags & MT_PG_PROPERTY) { + if (flags & MT_PG_PROPERTY) { menu.Append(ID_WXPGPROPERTY_SUB, _("Add wxPGProperty Child")); } - if(flags & MT_INFOBAR) { + if (flags & MT_INFOBAR) { menu.Append(ID_WXINFOBARBUTTON, _("Add Button")); } - if(flags & MT_IMGLIST) { + if (flags & MT_IMGLIST) { menu.Append(ID_WXBITMAP, _("Add Bitmap")); } - if(flags & MT_GRID) { + if (flags & MT_GRID) { menu.Append(ID_WXGRIDCOL, _("Add Column")); menu.Append(ID_WXGRIDROW, _("Add Row")); } - if(flags & MT_COLLPANE) { + if (flags & MT_COLLPANE) { menu.Append(ID_WXCOLLAPSIBLEPANE_PANE, _("Add Pane")); } - if(flags & MT_TOOLBAR) { + if (flags & MT_TOOLBAR) { menu.Append(ID_WXTOOLBARITEM, _("Add Tool")); menu.Append(wxID_ANY, _("Add Control"), CreateControlsMenu()); - if(item->GetType() == ID_WXAUITOOLBAR || item->GetType() == ID_WXAUITOOLBARTOPLEVEL) { + if (item->GetType() == ID_WXAUITOOLBAR || item->GetType() == ID_WXAUITOOLBARTOPLEVEL) { menu.Append(ID_WXAUITOOLBARLABEL, _("Add Label")); menu.Append(ID_WXAUITOOLBARITEM_SPACE, _("Add Spacer")); menu.Append(ID_WXAUITOOLBARITEM_STRETCHSPACE, _("Add Stretch Spacer")); @@ -588,148 +589,148 @@ void Allocator::PrepareMenu(wxMenu& menu, wxcWidget* item) menu.Append(ID_WXTOOLBARITEM_SEPARATOR, _("Add Separator")); } - if(flags & MT_MENUBAR) { + if (flags & MT_MENUBAR) { menu.Append(ID_WXMENU, _("Add wxMenu")); } - if(flags & MT_MENU) { + if (flags & MT_MENU) { menu.Append(ID_WXMENUITEM, _("Add Menu Item")); menu.Append(ID_WXSUBMENU, _("Add Sub Menu")); } - if(flags & MT_TOP_LEVEL) { + if (flags & MT_TOP_LEVEL) { #if STANDALONE_BUILD menu.Append(wxID_NEW, _("New Project...")); #endif menu.Append(ID_FORM_TYPE, _("Add Form"), CreateTopLevelMenu()); } - if(flags & MT_WIZARDPAGE) { + if (flags & MT_WIZARDPAGE) { menu.Append(ID_WXWIZARDPAGE, _("Add Page")); } - if(flags & MT_SIZERS) { + if (flags & MT_SIZERS) { menu.Append(wxID_ANY, _("Add Sizer"), CreateSizersMenu()); } - if(flags & MT_INSERT_INTO_SIZER) { + if (flags & MT_INSERT_INTO_SIZER) { menu.Append(wxID_ANY, _("Insert into new Sizer"), CreateInsertIntoSizerMenu()); } - if(flags & MT_SIZERS_TYPE) { + if (flags & MT_SIZERS_TYPE) { menu.Append(wxID_ANY, _("Change wxSizer Type"), CreateSizerTypeMenu()); menu.AppendSeparator(); } - if(flags & MT_AUIMGR) { + if (flags & MT_AUIMGR) { menu.Append(ID_WXAUIMANAGER, _("Add wxAuiManager")); } - if(flags & MT_CONTAINERS) { + if (flags & MT_CONTAINERS) { menu.Append(wxID_ANY, _("Add Container"), CreateContainersMenu()); } - if(flags & MT_CONTROLS) { + if (flags & MT_CONTROLS) { menu.Append(wxID_ANY, _("Add Control"), CreateControlsMenu()); } - if(flags & MT_RIBBON) { + if (flags & MT_RIBBON) { menu.Append(ID_WXRIBBONPAGE, _("Add wxRibbonPage")); } - if(flags & MT_RIBBON_PAGE) { + if (flags & MT_RIBBON_PAGE) { menu.Append(ID_WXRIBBONPANEL, _("Add wxRibbonPanel")); } - if(flags & MT_RIBBON_PANEL) { + if (flags & MT_RIBBON_PANEL) { menu.Append(ID_WXRIBBONBUTTONBAR, _("Add wxRibbonButtonBar")); menu.Append(ID_WXRIBBONTOOLBAR, _("Add wxRibbonToolBar")); menu.Append(ID_WXRIBBONGALLERY, _("Add wxRibbonGallery")); } - if(flags & MT_RIBBON_BUTTON_BAR) { + if (flags & MT_RIBBON_BUTTON_BAR) { menu.Append(ID_WXRIBBONBUTTON, _("Add Button")); menu.Append(ID_WXRIBBONDROPDOWNBUTTON, _("Add Dropdown Button")); menu.Append(ID_WXRIBBONHYBRIDBUTTON, _("Add Hybrid Button")); menu.Append(ID_WXRIBBONTOGGLEBUTTON, _("Add Toggle Button")); } - if(flags & MT_RIBBON_TOOL_BAR) { + if (flags & MT_RIBBON_TOOL_BAR) { menu.Append(ID_WXRIBBONTOOL, _("Add Tool")); menu.Append(ID_WXRIBBONDROPDOWNTOOL, _("Add Dropdown Tool")); menu.Append(ID_WXRIBBONHYBRIDTOOL, _("Add Hybrid Tool")); menu.Append(ID_WXRIBBONTOGGLETOOL, _("Add Toggle Tool")); } - if(flags & MT_RIBBON_GALLERY) { + if (flags & MT_RIBBON_GALLERY) { menu.Append(ID_WXRIBBONGALLERYITME, _("Add Gallery Item")); } - if(flags & MT_NOTEBOOK_PAGES) { + if (flags & MT_NOTEBOOK_PAGES) { menu.Append(ID_WXPANEL_NOTEBOOK_PAGE, _("Add Notebook Page")); - if(isChildOfTreeBook) { + if (isChildOfTreeBook) { menu.Append(ID_WXTREEBOOK_SUB_PAGE, _("Add Sub Page")); } } - if(flags & MT_SPLITTERWIN_PAGES) { + if (flags & MT_SPLITTERWIN_PAGES) { menu.Append(ID_WXSPLITTERWINDOW_PAGE, _("Add Panel"), _("Add Panel")); } - if(flags & MT_DV_LIST_CTRL_COL) { + if (flags & MT_DV_LIST_CTRL_COL) { menu.Append(ID_WXDATAVIEWCOL, _("Add Column")); } - if(flags & MT_LIST_CTRL_COLUMNS) { + if (flags & MT_LIST_CTRL_COLUMNS) { menu.Append(ID_WXLISTCTRL_COL, _("Add List Column")); } - if(flags & MT_TREE_LIST_CTRL_COLUMNS) { + if (flags & MT_TREE_LIST_CTRL_COLUMNS) { menu.Append(ID_WXTREELISTCTRLCOL, _("Add Column")); } - if(flags & MT_EVENTS) { + if (flags & MT_EVENTS) { DoAddEventsMenu(menu); } - if(flags & MT_CONTROL_EVENTS) { + if (flags & MT_CONTROL_EVENTS) { DoAddControlEventsMenu(menu); } - if(flags & MT_PROJECT) { + if (flags & MT_PROJECT) { DoAddProjectMenu(menu); } - if(flags & MT_PREVIEW_CODE) { - if(menu.GetMenuItemCount() != 0) + if (flags & MT_PREVIEW_CODE) { + if (menu.GetMenuItemCount() != 0) menu.AppendSeparator(); menu.Append(ID_GENERATE_CODE, _("Generate code...")); } - if(flags & MT_TIMER) { - if(menu.GetMenuItemCount() != 0) + if (flags & MT_TIMER) { + if (menu.GetMenuItemCount() != 0) menu.AppendSeparator(); menu.Append(ID_WXTIMER, _("Add wxTimer")); } - if(flags & MT_TASKBARICON) { - if(menu.GetMenuItemCount() != 0) + if (flags & MT_TASKBARICON) { + if (menu.GetMenuItemCount() != 0) menu.AppendSeparator(); menu.Append(ID_WXTASKBARICON, _("Add wxTaskBarIcon")); } - if(flags & MT_EDIT) { + if (flags & MT_EDIT) { DoAddEditMenu(menu); } - if(flags & MT_PASTE) { + if (flags & MT_PASTE) { menu.Append(ID_PASTE, _("Paste")); } // Last, add the common menu - if(flags & MT_COMMON_MENU) { + if (flags & MT_COMMON_MENU) { DoAddCommonMenu(menu); } - if(item && item->GetType() == ID_WXSTDDLGBUTTONSIZER) { + if (item && item->GetType() == ID_WXSTDDLGBUTTONSIZER) { menu.PrependSeparator(); menu.Prepend(ID_WXSTDBUTTON, _("Add Button")); } @@ -739,14 +740,14 @@ FLAGS_t Allocator::DoGetValidMenus(wxcWidget* item) const { // ADD_NEW_CONTROL FLAGS_t menuflags = 0; - if(!item) { + if (!item) { menuflags |= MT_PROJECT; menuflags |= MT_TOP_LEVEL; menuflags |= MT_PASTE; } else { - switch(item->GetType()) { + switch (item->GetType()) { case ID_WXRIBBONGALLERYITME: menuflags |= MT_COMMON_MENU; menuflags |= MT_EDIT; @@ -871,7 +872,7 @@ FLAGS_t Allocator::DoGetValidMenus(wxcWidget* item) const case ID_WXPANEL_TOPLEVEL: case ID_WXPOPUPWINDOW: menuflags |= MT_TIMER; - if(!item->HasMainSizer() && !item->IsAuiManaged()) { + if (!item->HasMainSizer() && !item->IsAuiManaged()) { menuflags |= MT_SIZERS; menuflags |= MT_AUIMGR; } @@ -976,7 +977,7 @@ FLAGS_t Allocator::DoGetValidMenus(wxcWidget* item) const { // wxTreebook pages are allowed to have notebook pages as their direct children NotebookPageWrapper* page = dynamic_cast(item); - if(page && page->IsTreebookPage()) { + if (page && page->IsTreebookPage()) { menuflags |= MT_NOTEBOOK_PAGES; } } @@ -1019,7 +1020,7 @@ FLAGS_t Allocator::DoGetValidMenus(wxcWidget* item) const void Allocator::DoAddCommonMenu(wxMenu& menu) const { - if(menu.GetMenuItemCount() != 0) { + if (menu.GetMenuItemCount() != 0) { menu.AppendSeparator(); } menu.Append(ID_MOVE_NODE_UP, _("Move Up")); @@ -1032,7 +1033,7 @@ void Allocator::DoAddCommonMenu(wxMenu& menu) const void Allocator::DoAddProjectMenu(wxMenu& menu) const { - if(menu.GetMenuItemCount() != 0) { + if (menu.GetMenuItemCount() != 0) { menu.AppendSeparator(); } menu.Append(ID_SAVE_WXGUI_PROJECT, _("Save")); @@ -1053,19 +1054,19 @@ bool Allocator::CanPaste(wxcWidget* source, wxcWidget* target) const int insertType = Allocator::Instance()->GetInsertionType(source->GetType(), target->GetType(), false); // we don't allow moving around top level items - if(source->IsTopWindow() && target->IsTopWindow()) + if (source->IsTopWindow() && target->IsTopWindow()) // allow copying top level windows return true; - if(insertType == Allocator::INSERT_CHILD) { + if (insertType == Allocator::INSERT_CHILD) { return true; - } else if(insertType == Allocator::INSERT_MAIN_SIZER) { - if(target->HasMainSizer()) + } else if (insertType == Allocator::INSERT_MAIN_SIZER) { + if (target->HasMainSizer()) return false; else return true; - } else if(insertType == Allocator::INSERT_SIBLING) { + } else if (insertType == Allocator::INSERT_SIBLING) { // check that the parent can accept it as a child CHECK_POINTER_RET_FALSE(target->GetParent()); int parentInsertType = @@ -1079,7 +1080,7 @@ bool Allocator::CanPaste(wxcWidget* source, wxcWidget* target) const void Allocator::DoAddEditMenu(wxMenu& menu) const { - if(menu.GetMenuItemCount() != 0) + if (menu.GetMenuItemCount() != 0) menu.AppendSeparator(); menu.Append(ID_RENAME, _("Rename...")); menu.AppendSeparator(); @@ -1092,7 +1093,7 @@ void Allocator::DoAddEditMenu(wxMenu& menu) const void Allocator::DoLink(int selected, int aboutToBeInsert, int relation) { InsertMap_t::iterator iter = m_relations.find(selected); - if(iter == m_relations.end()) { + if (iter == m_relations.end()) { m_relations.insert(std::make_pair(selected, std::map())); } std::map& m = m_relations[selected]; @@ -1105,45 +1106,47 @@ int Allocator::GetInsertionType(int controlId, int targetControlId, bool allowPr int selected = wxcWidget::GetWidgetType(targetControlId); bool selectionIsDirectChildOfAUI = false; - if(selectedWidget && selectedWidget->GetParent() && selectedWidget->GetParent()->GetType() == ID_WXAUIMANAGER) { + if (selectedWidget && selectedWidget->GetParent() && selectedWidget->GetParent()->GetType() == ID_WXAUIMANAGER) { // the selected widget is a direct child of wxAuiManager selectionIsDirectChildOfAUI = true; } InsertMap_t::const_iterator iter = m_relations.find(selected); - if(iter == m_relations.end()) + if (iter == m_relations.end()) return INSERT_NONE; // Get the relations allowed with 'selected' const std::map& m = m_relations.find(selected)->second; std::map::const_iterator itRelation = m.find(aboutToBeInsert); - if(itRelation == m.end()) + if (itRelation == m.end()) return INSERT_NONE; - if(selectionIsDirectChildOfAUI && itRelation->second == INSERT_SIBLING) { + if (selectionIsDirectChildOfAUI && itRelation->second == INSERT_SIBLING) { // allow sibling only if wxAuiManager allows to accept it as child const std::map& m = m_relations.find(TYPE_AUI_MGR)->second; std::map::const_iterator it = m.find(aboutToBeInsert); - if(it == m.end()) { + if (it == m.end()) { // not allowed return INSERT_NONE; } } int type = itRelation->second; - if(type == INSERT_PROMPT_CHILD_OR_SIBLING && allowPrompt) { + if (type == INSERT_PROMPT_CHILD_OR_SIBLING && allowPrompt) { // there is an ambiguity to resolve here - prompt the user int res = ::PromptForYesNoDialogWithCheckbox(_("This item can be placed either as a sibling or as a child of the " "target widget\nWhere should wxCrafter position this widget?"), - "wxCrafterInsertionType", _("As a Sibling"), _("As a Child")); - if(res == wxID_YES) { + "wxCrafterInsertionType", + _("As a Sibling"), + _("As a Child")); + if (res == wxID_YES) { return INSERT_SIBLING; } else { return INSERT_CHILD; } - } else if(type == INSERT_PROMPT_CHILD_OR_SIBLING) { + } else if (type == INSERT_PROMPT_CHILD_OR_SIBLING) { // prefer sibling over child return INSERT_CHILD; @@ -1619,192 +1622,192 @@ int Allocator::StringToId(const wxString& classname) // ADD_NEW_CONTROL // First the truncated wxFB top-level names :/ - if(classname == wxT("Frame")) + if (classname == wxT("Frame")) return ID_WXFRAME; - if(classname == wxT("Dialog")) + if (classname == wxT("Dialog")) return ID_WXDIALOG; - if(classname == wxT("Panel")) + if (classname == wxT("Panel")) return ID_WXPANEL_TOPLEVEL; - if(classname == wxT("Wizard")) + if (classname == wxT("Wizard")) return ID_WXWIZARD; - if(classname == wxT("WizardPageSimple")) + if (classname == wxT("WizardPageSimple")) return ID_WXWIZARDPAGE; - if(classname == wxT("wxButton")) + if (classname == wxT("wxButton")) return ID_WXBUTTON; - if(classname == wxT("wxBoxSizer")) + if (classname == wxT("wxBoxSizer")) return ID_WXBOXSIZER; - if(classname == wxT("wxFrame")) + if (classname == wxT("wxFrame")) return ID_WXFRAME; - if(classname == wxT("wxFlexGridSizer")) + if (classname == wxT("wxFlexGridSizer")) return ID_WXFLEXGRIDSIZER; - if(classname == wxT("wxBitmapButton")) + if (classname == wxT("wxBitmapButton")) return ID_WXBITMAPBUTTON; - if(classname == wxT("wxStaticText")) + if (classname == wxT("wxStaticText")) return ID_WXSTATICTEXT; - if(classname == wxT("wxTextCtrl")) + if (classname == wxT("wxTextCtrl")) return ID_WXTEXTCTRL; - if(classname == wxT("wxPanel")) + if (classname == wxT("wxPanel")) return ID_WXPANEL; - if(classname == wxT("wxStaticBitmap")) + if (classname == wxT("wxStaticBitmap")) return ID_WXSTATICBITMAP; - if(classname == wxT("wxComboBox")) + if (classname == wxT("wxComboBox")) return ID_WXCOMBOBOX; - if(classname == wxT("wxChoice")) + if (classname == wxT("wxChoice")) return ID_WXCHOICE; - if(classname == wxT("wxListBox")) + if (classname == wxT("wxListBox")) return ID_WXLISTBOX; - if(classname == wxT("wxListCtrl")) + if (classname == wxT("wxListCtrl")) return ID_WXLISTCTRL; - if(classname == wxT("listcol")) + if (classname == wxT("listcol")) return ID_WXLISTCTRL_COL; - if(classname == wxT("wxCheckBox")) + if (classname == wxT("wxCheckBox")) return ID_WXCHECKBOX; - if(classname == wxT("wxRadioBox")) + if (classname == wxT("wxRadioBox")) return ID_WXRADIOBOX; - if(classname == wxT("wxRadioButton")) + if (classname == wxT("wxRadioButton")) return ID_WXRADIOBUTTON; - if(classname == wxT("wxStaticLine")) + if (classname == wxT("wxStaticLine")) return ID_WXSTATICLINE; - if(classname == wxT("wxSlider")) + if (classname == wxT("wxSlider")) return ID_WXSLIDER; - if(classname == wxT("wxGauge")) + if (classname == wxT("wxGauge")) return ID_WXGAUGE; - if(classname == wxT("wxDialog")) + if (classname == wxT("wxDialog")) return ID_WXDIALOG; - if(classname == wxT("wxTreeCtrl")) + if (classname == wxT("wxTreeCtrl")) return ID_WXTREECTRL; - if(classname == wxT("wxHtmlWindow")) + if (classname == wxT("wxHtmlWindow")) return ID_WXHTMLWIN; - if(classname == wxT("wxRichTextCtrl")) + if (classname == wxT("wxRichTextCtrl")) return ID_WXRICHTEXT; - if(classname == wxT("wxCheckListBox")) + if (classname == wxT("wxCheckListBox")) return ID_WXCHECKLISTBOX; - if(classname == wxT("wxGrid")) + if (classname == wxT("wxGrid")) return ID_WXGRID; - if(classname == wxT("wxToggleButton")) + if (classname == wxT("wxToggleButton")) return ID_WXTOGGLEBUTTON; - if(classname == wxT("wxBitmapToggleButton")) + if (classname == wxT("wxBitmapToggleButton")) return ID_WXBITMAPTOGGLEBUTTON; - if(classname == wxT("wxSearchCtrl")) + if (classname == wxT("wxSearchCtrl")) return ID_WXSEARCHCTRL; - if(classname == wxT("wxColourPickerCtrl")) + if (classname == wxT("wxColourPickerCtrl")) return ID_WXCOLORPICKER; - if(classname == wxT("wxFontPickerCtrl")) + if (classname == wxT("wxFontPickerCtrl")) return ID_WXFONTPICKER; - if(classname == wxT("wxFilePickerCtrl")) + if (classname == wxT("wxFilePickerCtrl")) return ID_WXFILEPICKER; - if(classname == wxT("wxDirPickerCtrl")) + if (classname == wxT("wxDirPickerCtrl")) return ID_WXDIRPICKER; - if(classname == wxT("wxDatePickerCtrl")) + if (classname == wxT("wxDatePickerCtrl")) return ID_WXDATEPICKER; - if(classname == wxT("wxCalendarCtrl")) + if (classname == wxT("wxCalendarCtrl")) return ID_WXCALEDARCTRL; - if(classname == wxT("wxScrollBar")) + if (classname == wxT("wxScrollBar")) return ID_WXSCROLLBAR; - if(classname == wxT("wxSpinCtrl")) + if (classname == wxT("wxSpinCtrl")) return ID_WXSPINCTRL; - if(classname == wxT("wxSpinButton")) + if (classname == wxT("wxSpinButton")) return ID_WXSPINBUTTON; - if(classname == wxT("wxHyperlinkCtrl")) + if (classname == wxT("wxHyperlinkCtrl")) return ID_WXHYPERLINK; - if(classname == wxT("wxGenericDirCtrl")) + if (classname == wxT("wxGenericDirCtrl")) return ID_WXGENERICDIRCTRL; - if(classname == wxT("wxScrolledWindow")) + if (classname == wxT("wxScrolledWindow")) return ID_WXSCROLLEDWIN; - if(classname == wxT("wxNotebook")) + if (classname == wxT("wxNotebook")) return ID_WXNOTEBOOK; - if(classname == wxT("wxToolbook")) + if (classname == wxT("wxToolbook")) return ID_WXTOOLBOOK; - if(classname == wxT("wxListbook")) + if (classname == wxT("wxListbook")) return ID_WXLISTBOOK; - if(classname == wxT("wxChoicebook")) + if (classname == wxT("wxChoicebook")) return ID_WXCHOICEBOOK; - if(classname == wxT("wxTreebook")) + if (classname == wxT("wxTreebook")) return ID_WXTREEBOOK; - if(classname == wxT("notebookpage")) + if (classname == wxT("notebookpage")) return ID_WXPANEL_NOTEBOOK_PAGE; - if(classname == wxT("choicebookpage")) + if (classname == wxT("choicebookpage")) return ID_WXPANEL_NOTEBOOK_PAGE; - if(classname == wxT("listbookpage")) + if (classname == wxT("listbookpage")) return ID_WXPANEL_NOTEBOOK_PAGE; - if(classname == wxT("treebookpage")) + if (classname == wxT("treebookpage")) return ID_WXPANEL_NOTEBOOK_PAGE; // Not ID_WXTREEBOOK_SUB_PAGE, which is only used from the AddSubpage menuitem - if(classname == wxT("wxSplitterWindow")) + if (classname == wxT("wxSplitterWindow")) return ID_WXSPLITTERWINDOW; - if(classname == wxT("splitteritem")) + if (classname == wxT("splitteritem")) return ID_WXSPLITTERWINDOW_PAGE; // XRCed doesn't use this, but wxFB calls it 'splitteritem' - if(classname == wxT("wxStaticBoxSizer")) + if (classname == wxT("wxStaticBoxSizer")) return ID_WXSTATICBOXSIZER; - if(classname == wxT("wxWizard")) + if (classname == wxT("wxWizard")) return ID_WXWIZARD; - if(classname == wxT("wxWizardPage")) + if (classname == wxT("wxWizardPage")) return ID_WXWIZARDPAGE; - if(classname == wxT("wxWizardPageSimple")) + if (classname == wxT("wxWizardPageSimple")) return ID_WXWIZARDPAGE; - if(classname == wxT("wxGridSizer")) + if (classname == wxT("wxGridSizer")) return ID_WXGRIDSIZER; - if(classname == wxT("wxGridBagSizer")) + if (classname == wxT("wxGridBagSizer")) return ID_WXGRIDBAGSIZER; - if(classname == wxT("spacer")) + if (classname == wxT("spacer")) return ID_WXSPACER; - if(classname == wxT("wxSpacer")) + if (classname == wxT("wxSpacer")) return ID_WXSPACER; // XRC actually uses "spacer", but keep this duplicate for completeness - if(classname == wxT("wxStdDialogButtonSizer")) + if (classname == wxT("wxStdDialogButtonSizer")) return ID_WXSTDDLGBUTTONSIZER; - if(classname == wxT("stdbutton")) + if (classname == wxT("stdbutton")) return ID_WXSTDBUTTON; - if(classname == wxT("wxAuiNotebook")) + if (classname == wxT("wxAuiNotebook")) return ID_WXAUINOTEBOOK; - if(classname == wxT("wxMenuBar")) + if (classname == wxT("wxMenuBar")) return ID_WXMENUBAR; - if(classname == wxT("wxMenu")) + if (classname == wxT("wxMenu")) return ID_WXMENU; - if(classname == wxT("wxMenuItem")) + if (classname == wxT("wxMenuItem")) return ID_WXMENUITEM; - if(classname == wxT("submenu")) + if (classname == wxT("submenu")) return ID_WXSUBMENU; - if(classname == wxT("wxToolBar")) + if (classname == wxT("wxToolBar")) return ID_WXTOOLBAR; - if(classname == wxT("tool")) + if (classname == wxT("tool")) return ID_WXTOOLBARITEM; - if(classname == wxT("toolSeparator")) + if (classname == wxT("toolSeparator")) return ID_WXTOOLBARITEM; - if(classname == wxT("space")) + if (classname == wxT("space")) return ID_WXTOOLBARITEM; - if(classname == wxT("separator")) + if (classname == wxT("separator")) return ID_WXMENUITEM; // but in XRC could actually be a toolbar separator - if(classname == wxT("wxAuiToolBar")) + if (classname == wxT("wxAuiToolBar")) return ID_WXAUITOOLBAR; - if(classname == wxT("label")) + if (classname == wxT("label")) return ID_WXAUITOOLBARLABEL; - if(classname == wxT("wxStatusBar")) + if (classname == wxT("wxStatusBar")) return ID_WXSTATUSBAR; - if(classname == wxT("unknown")) + if (classname == wxT("unknown")) return ID_WXCUSTOMCONTROL; // XRC - if(classname == wxT("CustomControl")) + if (classname == wxT("CustomControl")) return ID_WXCUSTOMCONTROL; // wxFB - if(classname == wxT("Custom")) + if (classname == wxT("Custom")) return ID_WXCUSTOMCONTROL; // wxSmith - if(classname == wxT("wxDataViewListCtrl")) + if (classname == wxT("wxDataViewListCtrl")) return ID_WXDATAVIEWLISTCTRL; - if(classname == wxT("wxDataViewColumn")) + if (classname == wxT("wxDataViewColumn")) return ID_WXDATAVIEWCOL; - if(classname == wxT("wxPopupWindow")) + if (classname == wxT("wxPopupWindow")) return ID_WXPOPUPWINDOW; - if(classname == wxT("wxSimplebook")) + if (classname == wxT("wxSimplebook")) return ID_WXSIMPLEBOOK; - if(classname == wxT("wxScintilla")) + if (classname == wxT("wxScintilla")) return ID_WXSTC; // wxFB (sometimes?) - if(classname == wxT("wxTreeListCtrl")) + if (classname == wxT("wxTreeListCtrl")) return ID_WXTREELISTCTRL; - if(classname == wxT("wxAnimationCtrl")) + if (classname == wxT("wxAnimationCtrl")) return ID_WXANIMATIONCTRL; - if(classname == wxT("wxSimpleHtmlListBox")) + if (classname == wxT("wxSimpleHtmlListBox")) return ID_WXSIMPLEHTMLLISTBOX; - if(classname == wxT("wxActivityIndicator")) + if (classname == wxT("wxActivityIndicator")) return ID_WXACTIVITYINDICATOR; - if(classname == wxT("wxTimePickerCtrl")) + if (classname == wxT("wxTimePickerCtrl")) return ID_WXTIMEPICKERCTRL; return wxNOT_FOUND; }; diff --git a/wxcrafter/src/designer_panel.cpp b/wxcrafter/src/designer_panel.cpp index ed763016c0..7914586f2e 100644 --- a/wxcrafter/src/designer_panel.cpp +++ b/wxcrafter/src/designer_panel.cpp @@ -67,7 +67,7 @@ class CONTEXT_MENU } ~CONTEXT_MENU() { - if(m_fireEvent) { + if (m_fireEvent) { wxCommandEvent contextMenuEvent(wxEVT_SHOW_CONTEXT_MENU); EventNotifier::Get()->AddPendingEvent(contextMenuEvent); } @@ -119,33 +119,33 @@ DesignerPanel::DesignerPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos GetSizer()->Add(m_mainPanel, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 5); wxColour bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - if(DrawingUtils::IsDark(bgColour)) { + if (DrawingUtils::IsDark(bgColour)) { bgColour = bgColour.ChangeLightness(120); } else { bgColour = bgColour.ChangeLightness(90); } SetBackgroundColour(bgColour); - EventNotifier::Get()->Connect(wxEVT_UPDATE_PREVIEW, wxCommandEventHandler(DesignerPanel::OnUpdatePreview), NULL, - this); - EventNotifier::Get()->Connect(wxEVT_WXGUI_PROJECT_CLOSED, wxCommandEventHandler(DesignerPanel::OnClearPreview), - NULL, this); - EventNotifier::Get()->Connect(wxEVT_WXGUI_PROJECT_LOADED, wxCommandEventHandler(DesignerPanel::OnLoadPreview), NULL, - this); - EventNotifier::Get()->Connect(wxEVT_TREE_ITEM_SELECTED, wxCommandEventHandler(DesignerPanel::OnHighlightControl), - NULL, this); + EventNotifier::Get()->Connect( + wxEVT_UPDATE_PREVIEW, wxCommandEventHandler(DesignerPanel::OnUpdatePreview), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_WXGUI_PROJECT_CLOSED, wxCommandEventHandler(DesignerPanel::OnClearPreview), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_WXGUI_PROJECT_LOADED, wxCommandEventHandler(DesignerPanel::OnLoadPreview), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_TREE_ITEM_SELECTED, wxCommandEventHandler(DesignerPanel::OnHighlightControl), NULL, this); GetSizer()->Layout(); } DesignerPanel::~DesignerPanel() { - EventNotifier::Get()->Disconnect(wxEVT_UPDATE_PREVIEW, wxCommandEventHandler(DesignerPanel::OnUpdatePreview), NULL, - this); - EventNotifier::Get()->Disconnect(wxEVT_WXGUI_PROJECT_CLOSED, wxCommandEventHandler(DesignerPanel::OnClearPreview), - NULL, this); - EventNotifier::Get()->Disconnect(wxEVT_WXGUI_PROJECT_LOADED, wxCommandEventHandler(DesignerPanel::OnLoadPreview), - NULL, this); - EventNotifier::Get()->Disconnect(wxEVT_TREE_ITEM_SELECTED, wxCommandEventHandler(DesignerPanel::OnHighlightControl), - NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_UPDATE_PREVIEW, wxCommandEventHandler(DesignerPanel::OnUpdatePreview), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_WXGUI_PROJECT_CLOSED, wxCommandEventHandler(DesignerPanel::OnClearPreview), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_WXGUI_PROJECT_LOADED, wxCommandEventHandler(DesignerPanel::OnLoadPreview), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_TREE_ITEM_SELECTED, wxCommandEventHandler(DesignerPanel::OnHighlightControl), NULL, this); } void DesignerPanel::OnUpdatePreview(wxCommandEvent& e) @@ -153,14 +153,14 @@ void DesignerPanel::OnUpdatePreview(wxCommandEvent& e) e.Skip(); BOOL_LOCKER bl(m_constructing); - if(m_xrcLoaded == e.GetString()) + if (m_xrcLoaded == e.GetString()) return; #ifdef __WXMSW__ wxWindowUpdateLocker locker(this); #endif - if(m_mainPanel) { + if (m_mainPanel) { DoClear(); } @@ -197,91 +197,91 @@ void DesignerPanel::DoControlSelected(wxEvent& e) { bool bIsRightUp = ::wxGetMouseState().RightIsDown(); wxWindow* win = dynamic_cast(e.GetEventObject()); - if(win) { + if (win) { // Fire context menu if needed CONTEXT_MENU eventStarte(bIsRightUp); wxString clsname, parent_clsname; const wxClassInfo* clsInfo = win->GetClassInfo(); - if(clsInfo && clsInfo->GetClassName()) { + if (clsInfo && clsInfo->GetClassName()) { clsname = clsInfo->GetClassName(); } - if(win->GetParent() && win->GetParent()->GetClassInfo() && win->GetParent()->GetClassInfo()->GetClassName()) { + if (win->GetParent() && win->GetParent()->GetClassInfo() && win->GetParent()->GetClassInfo()->GetClassName()) { parent_clsname = win->GetParent()->GetClassInfo()->GetClassName(); } wxWindow* selectedWin = win; wxString thename = win->GetName(); - if(parent_clsname == wxT("wxGrid")) { + if (parent_clsname == wxT("wxGrid")) { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == "OpenGLCanvas") { + } else if (parent_clsname == "OpenGLCanvas") { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == "wxPropertyGridManager") { + } else if (parent_clsname == "wxPropertyGridManager") { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == wxT("wxListCtrl")) { + } else if (parent_clsname == wxT("wxListCtrl")) { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == wxT("wxSearchCtrl")) { + } else if (parent_clsname == wxT("wxSearchCtrl")) { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == wxT("wxColourPickerCtrl")) { + } else if (parent_clsname == wxT("wxColourPickerCtrl")) { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == wxT("wxFilePickerCtrl")) { + } else if (parent_clsname == wxT("wxFilePickerCtrl")) { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == wxT("wxDirPickerCtrl")) { + } else if (parent_clsname == wxT("wxDirPickerCtrl")) { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == wxT("wxGenericDirCtrl")) { + } else if (parent_clsname == wxT("wxGenericDirCtrl")) { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == "wxDataViewListCtrl") { + } else if (parent_clsname == "wxDataViewListCtrl") { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == "wxDataViewTreeCtrl") { + } else if (parent_clsname == "wxDataViewTreeCtrl") { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); - } else if(parent_clsname == "wxDataViewCtrl") { + } else if (parent_clsname == "wxDataViewCtrl") { selectedWin = win->GetParent(); thename = win->GetParent()->GetName(); } // Allow click on wxNotebook to actually switch pages - if(clsname == wxT("wxNotebook") || (parent_clsname == wxT("wxToolbook") && clsname == wxT("wxToolBar")) || - (parent_clsname == wxT("wxListbook") && clsname == wxT("wxListView")) || - (clsname == wxT("wxAuiTabCtrl") || parent_clsname == wxT("wxAuiNotebook")) || - (parent_clsname == wxT("wxTreebook") || clsname == "wxRibbonBar")) { + if (clsname == wxT("wxNotebook") || (parent_clsname == wxT("wxToolbook") && clsname == wxT("wxToolBar")) || + (parent_clsname == wxT("wxListbook") && clsname == wxT("wxListView")) || + (clsname == wxT("wxAuiTabCtrl") || parent_clsname == wxT("wxAuiNotebook")) || + (parent_clsname == wxT("wxTreebook") || clsname == "wxRibbonBar")) { e.Skip(); DoDrawSurroundingMarker(selectedWin); return; } - if(clsname == wxT("wxAuiToolBar")) { + if (clsname == wxT("wxAuiToolBar")) { // We handle clicks in the OnAuiToolbarClicked() method e.Skip(); DoDrawSurroundingMarker(selectedWin); return; } - if(clsname == wxT("wxToolBar")) { + if (clsname == wxT("wxToolBar")) { e.Skip(); DoDrawSurroundingMarker(selectedWin); return; @@ -296,24 +296,24 @@ void DesignerPanel::DoControlSelected(wxEvent& e) void DesignerPanel::RecurseConnectEvents(wxWindow* pclComponent) { - if(pclComponent) { + if (pclComponent) { wxString name = pclComponent->GetName(); name.Trim(); m_windows.insert(std::make_pair(name, pclComponent)); - pclComponent->Connect(wxID_ANY, wxEVT_LEFT_DOWN, wxMouseEventHandler(DesignerPanel::OnMouseLeftDown), - (wxObject*)NULL, this); + pclComponent->Connect( + wxID_ANY, wxEVT_LEFT_DOWN, wxMouseEventHandler(DesignerPanel::OnMouseLeftDown), (wxObject*)NULL, this); - pclComponent->Connect(wxID_ANY, wxEVT_RIGHT_DOWN, wxMouseEventHandler(DesignerPanel::OnMouseLeftDown), - (wxObject*)NULL, this); + pclComponent->Connect( + wxID_ANY, wxEVT_RIGHT_DOWN, wxMouseEventHandler(DesignerPanel::OnMouseLeftDown), (wxObject*)NULL, this); - pclComponent->Connect(wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(DesignerPanel::OnControlFocus), - (wxObject*)NULL, this); + pclComponent->Connect( + wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(DesignerPanel::OnControlFocus), (wxObject*)NULL, this); // Now, for container windows e.g. panels, grab the opportunity to identify all contained sizers/spacers StoreSizersRecursively(pclComponent->GetSizer(), pclComponent); // For non-containers this will harmlessly pass NULL wxWindowList::compatibility_iterator pclNode = pclComponent->GetChildren().GetFirst(); - while(pclNode) { + while (pclNode) { wxWindow* pclChild = pclNode->GetData(); this->RecurseConnectEvents(pclChild); @@ -324,17 +324,17 @@ void DesignerPanel::RecurseConnectEvents(wxWindow* pclComponent) void DesignerPanel::RecurseDisconnectEvents(wxWindow* pclComponent) { - if(pclComponent) { - pclComponent->Disconnect(wxID_ANY, wxEVT_LEFT_DOWN, wxMouseEventHandler(DesignerPanel::OnMouseLeftDown), - (wxObject*)NULL, this); + if (pclComponent) { + pclComponent->Disconnect( + wxID_ANY, wxEVT_LEFT_DOWN, wxMouseEventHandler(DesignerPanel::OnMouseLeftDown), (wxObject*)NULL, this); - pclComponent->Disconnect(wxID_ANY, wxEVT_RIGHT_DOWN, wxMouseEventHandler(DesignerPanel::OnMouseLeftDown), - (wxObject*)NULL, this); + pclComponent->Disconnect( + wxID_ANY, wxEVT_RIGHT_DOWN, wxMouseEventHandler(DesignerPanel::OnMouseLeftDown), (wxObject*)NULL, this); - pclComponent->Disconnect(wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(DesignerPanel::OnControlFocus), - (wxObject*)NULL, this); + pclComponent->Disconnect( + wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(DesignerPanel::OnControlFocus), (wxObject*)NULL, this); wxWindowList::compatibility_iterator pclNode = pclComponent->GetChildren().GetFirst(); - while(pclNode) { + while (pclNode) { wxWindow* pclChild = pclNode->GetData(); this->RecurseDisconnectEvents(pclChild); @@ -347,33 +347,33 @@ void DesignerPanel::StoreSizersRecursively(wxSizer* sizer, wxWindow* container) { // There doesn't seem to be any way to retrieve a wxSizerItem for a top-level sizer :/ // So ignore it (fortunately it won't have borders or an interesting outline) but add all children - if(sizer) { + if (sizer) { wxSizerItemList::compatibility_iterator node = sizer->GetChildren().GetFirst(); - while(node) { + while (node) { wxSizerItem* child = node->GetData(); // We need to process the contents of a staticboxsizer differently; they are positioned wrt the staticbox, // not the real container - if(child->IsSizer()) { + if (child->IsSizer()) { wxStaticBoxSizer* sbs = wxDynamicCast(child->GetSizer(), wxStaticBoxSizer); - if(sbs) { + if (sbs) { container = (wxWindow*)(sbs->GetStaticBox()); } } int id = child->GetId(); // GetId() returns XRCID(name), or wxNOT_FOUND for "" - if(id != wxNOT_FOUND) { + if (id != wxNOT_FOUND) { m_sizeritems.insert(std::make_pair(id, SizeritemData(container, child))); } - if(child->IsSizer()) { + if (child->IsSizer()) { wxSizer* childsizer = child->GetSizer(); StoreSizersRecursively(childsizer, container); - if(!childsizer->GetItemCount()) { + if (!childsizer->GetItemCount()) { // Empty sizers all get positioned at 0,0, which breaks outlining; they also annoy gtk. // So let's pretend it contains a 5*5 spacer // But be careful if it's a gridbagsizer: a plain AddSpacer() asserts wxGridBagSizer* gbs = wxDynamicCast(childsizer, wxGridBagSizer); - if(gbs) { + if (gbs) { gbs->Add(0, 0, wxGBPosition()); } else { childsizer->AddSpacer(5); @@ -389,7 +389,7 @@ void DesignerPanel::StoreSizersRecursively(wxSizer* sizer, wxWindow* container) void DesignerPanel::DoMarkSizeritem(wxSizerItem* szitem, wxWindow* container) { // If no item provided, remark the current selection - if(!szitem && m_hintedContainer && m_hintedSizeritem) { + if (!szitem && m_hintedContainer && m_hintedSizeritem) { wxClientDC dc(m_hintedContainer); dc.SetPen(wxColour("ORANGE")); wxRect rect(m_hintedSizeritem->GetRect()); @@ -400,7 +400,7 @@ void DesignerPanel::DoMarkSizeritem(wxSizerItem* szitem, wxWindow* container) ClearStaleOutlines(); - if(szitem && container) { + if (szitem && container) { m_hintedSizeritem = szitem; m_hintedContainer = container; wxClientDC dc(container); @@ -415,19 +415,19 @@ void DesignerPanel::DoMarkSizeritem(wxSizerItem* szitem, wxWindow* container) void DesignerPanel::DoDrawSurroundingMarker(wxWindow* win) { // NULL provided, remark the current selection - if(!win && m_parentWin && m_hintedWin) { + if (!win && m_parentWin && m_hintedWin) { wxClientDC dc(m_parentWin); dc.SetPen(*wxRED_PEN); MarkOutline(dc); MarkBorders(dc); return; - } else if(!win) { + } else if (!win) { return; } wxWindow* parent = win->GetParent(); - if(!parent) { + if (!parent) { return; } @@ -447,7 +447,7 @@ void DesignerPanel::DoDrawSurroundingMarker(wxWindow* win) void DesignerPanel::MarkOutline(wxDC& dc, wxRect* rect /*=NULL*/) const { wxRect rr; - if(!rect) { + if (!rect) { rr = m_hintedWin->GetRect(); } else { rr = *rect; @@ -457,7 +457,7 @@ void DesignerPanel::MarkOutline(wxDC& dc, wxRect* rect /*=NULL*/) const rr.Offset(pt); rr.Inflate(1, 1); #if wxVERSION_NUMBER > 2904 - if(pt != wxPoint()) { + if (pt != wxPoint()) { // i.e. this is a notebookpage, so (for some reason) it needs to be more inflated rr.Inflate(2, 2); } @@ -470,12 +470,12 @@ void DesignerPanel::MarkOutline(wxDC& dc, wxRect* rect /*=NULL*/) const void DesignerPanel::MarkBorders(wxDC& dc) const { wxSizer* sizer = m_hintedWin->GetContainingSizer(); - if(!sizer) { + if (!sizer) { return; } wxSizerItem* szitem = sizer->GetItem(m_hintedWin); - if(!szitem || !szitem->GetBorder()) { + if (!szitem || !szitem->GetBorder()) { return; } @@ -486,22 +486,22 @@ void DesignerPanel::MarkBorders(wxDC& dc) const void DesignerPanel::DoMarkBorders(wxDC& dc, wxRect rr, int bdrwidth, int flags) const { - if(flags & wxTOP) { + if (flags & wxTOP) { wxPoint mid = rr.GetTopLeft() + wxPoint(rr.GetWidth() / 2, 0); dc.DrawLine(mid, mid - wxPoint(0, bdrwidth)); } - if(flags & wxBOTTOM) { + if (flags & wxBOTTOM) { wxPoint mid = rr.GetBottomLeft() + wxPoint(rr.GetWidth() / 2, 0); dc.DrawLine(mid, mid + wxPoint(0, bdrwidth)); } - if(flags & wxLEFT) { + if (flags & wxLEFT) { wxPoint mid = rr.GetTopLeft() + wxPoint(0, rr.GetHeight() / 2); dc.DrawLine(mid, mid - wxPoint(bdrwidth, 0)); } - if(flags & wxRIGHT) { + if (flags & wxRIGHT) { wxPoint mid = rr.GetTopRight() + wxPoint(0, rr.GetHeight() / 2); dc.DrawLine(mid, mid + wxPoint(bdrwidth, 0)); } @@ -510,7 +510,7 @@ void DesignerPanel::DoMarkBorders(wxDC& dc, wxRect rr, int bdrwidth, int flags) void DesignerPanel::ClearStaleOutlines() const { // First any control - if(m_parentWin && m_hintedWin) { + if (m_parentWin && m_hintedWin) { wxClientDC dc(m_parentWin); dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); MarkOutline(dc); @@ -518,7 +518,7 @@ void DesignerPanel::ClearStaleOutlines() const } // Now any sizer/spacer - if(m_hintedContainer && m_hintedSizeritem) { + if (m_hintedContainer && m_hintedSizeritem) { wxClientDC dc(m_hintedContainer); dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); wxRect rect(m_hintedSizeritem->GetRect()); @@ -530,15 +530,15 @@ void DesignerPanel::ClearStaleOutlines() const wxPoint DesignerPanel::GetOutlineOffset() const { wxPoint pt; - if(m_parentWin && m_hintedWin && wxDynamicCast(m_parentWin, wxNotebook)) { + if (m_parentWin && m_hintedWin && wxDynamicCast(m_parentWin, wxNotebook)) { int x, y, px, py; m_hintedWin->GetScreenPosition(&x, &y); m_parentWin->GetScreenPosition(&px, &py); // The small margin between the notebook and the page needs offsetting - if(m_parentWin->GetWindowStyle() & wxNB_TOP) { + if (m_parentWin->GetWindowStyle() & wxNB_TOP) { pt.x = pt.y = px - x - 3; // The -3 is a kludge - } else if(m_parentWin->GetWindowStyle() & wxNB_LEFT) { + } else if (m_parentWin->GetWindowStyle() & wxNB_LEFT) { pt.x = pt.y = py - y - 3; } } @@ -548,19 +548,18 @@ wxPoint DesignerPanel::GetOutlineOffset() const void DesignerPanel::DoClear() { // Remove all children of this sizer - if(!GetSizer()->IsEmpty()) { + if (!GetSizer()->IsEmpty()) { GetSizer()->Clear(); } - if(m_mainPanel) { + if (m_mainPanel) { m_mainPanel->Destroy(); } m_mainPanel = nullptr; - + // create new panel and place it m_mainPanel = new DesignerContainerPanel(this); GetSizer()->Add(m_mainPanel, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 5); - m_xrcLoaded.Clear(); m_hintedWin = NULL; m_parentWin = NULL; @@ -571,19 +570,19 @@ void DesignerPanel::DoClear() void DesignerPanel::DoNotebookPageChangeEvent(wxEvent& e) { - if(m_constructing) { + if (m_constructing) { return; } wxBookCtrlBase* nbk = dynamic_cast(e.GetEventObject()); - if(!nbk) { + if (!nbk) { return; } int idx = nbk->GetSelection(); - if(idx != wxNOT_FOUND) { + if (idx != wxNOT_FOUND) { wxWindow* page = nbk->GetPage(idx); - if(page) { + if (page) { wxCommandEvent evt(wxEVT_PREVIEW_BOOKPAGE_SELECTED); evt.SetString(page->GetName()); EventNotifier::Get()->AddPendingEvent(evt); @@ -603,18 +602,18 @@ void DesignerPanel::OnTreebookPageChanged(wxTreebookEvent& e) { DoNotebookPageCh void DesignerPanel::DoAuiBookChanged(wxAuiNotebookEvent& e) { - if(m_constructing) { + if (m_constructing) { return; } wxAuiNotebook* nbk = dynamic_cast(e.GetEventObject()); - if(!nbk) + if (!nbk) return; int idx = nbk->GetSelection(); - if(idx != wxNOT_FOUND) { + if (idx != wxNOT_FOUND) { wxWindow* page = nbk->GetPage(idx); - if(page) { + if (page) { wxCommandEvent evt(wxEVT_PREVIEW_BOOKPAGE_SELECTED); evt.SetString(page->GetName()); EventNotifier::Get()->AddPendingEvent(evt); @@ -640,11 +639,11 @@ void DesignerPanel::DoLoadXRC(int topLeveWinType) clDirChanger dc(wxcProjectMetadata::Get().GetProjectPath()); panel = wxXmlResource::Get()->LoadPanel(m_mainPanel, wxT("PreviewPanel")); - if(panel) { + if (panel) { - if(topLeveWinType == ID_WXFRAME || topLeveWinType == ID_WXDIALOG) { + if (topLeveWinType == ID_WXFRAME || topLeveWinType == ID_WXDIALOG) { wxBitmap tlwIcon; - if(!bmpIcon.IsEmpty()) { + if (!bmpIcon.IsEmpty()) { // convert bmpIcon to fullpath wxFileName fnBmp(bmpIcon); fnBmp.MakeAbsolute(wxcProjectMetadata::Get().GetProjectPath()); @@ -655,7 +654,7 @@ void DesignerPanel::DoLoadXRC(int topLeveWinType) RecurseConnectEvents(panel); wxMenuBar* mb = wxXmlResource::Get()->LoadMenuBar(wxT("MENU_BAR_ID")); - if(mb) { + if (mb) { #ifdef __WXGTK__ // GTK assumes that a wxMenuBar is attached to a frame // so give it one @@ -671,7 +670,7 @@ void DesignerPanel::DoLoadXRC(int topLeveWinType) ToolBar* pane = new ToolBar(m_mainPanel); wxToolBar* tb = wxXmlResource::Get()->LoadToolBar(pane, wxT("TOOL_BAR_ID")); - if(tb) { + if (tb) { pane->AddToolbar(tb); m_mainPanel->SetToolbar(pane); @@ -683,13 +682,13 @@ void DesignerPanel::DoLoadXRC(int topLeveWinType) GetSizer()->Layout(); wxStatusBar* sb = dynamic_cast( wxXmlResource::Get()->LoadObject(m_mainPanel, wxT("STATUS_BAR_ID"), wxT("wxStatusBar"))); - if(sb) { + if (sb) { m_mainPanel->SetStatusBar(sb); } m_mainPanel->CalcBestSize(topLeveWinType); wxXmlResource::Get()->Unload(fn.GetFullPath()); - if(topLeveWinType == ID_WXWIZARD) { + if (topLeveWinType == ID_WXWIZARD) { GetSizer()->Fit(m_mainPanel); } } @@ -700,10 +699,10 @@ void DesignerPanel::OnAuiToolClicked(wxCommandEvent& e) { wxAuiToolBar* tb = dynamic_cast(e.GetEventObject()); wxToolBar* bar = dynamic_cast(e.GetEventObject()); - if(tb) { + if (tb) { wxAuiToolBarItem* tool = tb->FindTool(e.GetId()); - if(tool) { + if (tool) { wxString label = tool->GetLabel(); wxString s = tb->GetName(); s << wxT(":") << label; @@ -716,9 +715,9 @@ void DesignerPanel::OnAuiToolClicked(wxCommandEvent& e) e.Skip(); } - } else if(bar) { + } else if (bar) { wxToolBarToolBase* tool = bar->FindById(e.GetId()); - if(tool) { + if (tool) { wxString label = tool->GetLabel(); wxString s; s << bar->GetName() << wxT(":") << label; @@ -741,12 +740,12 @@ void DesignerPanel::OnHighlightControl(wxCommandEvent& e) e.Skip(); wxString s = e.GetString(); - if(m_windows.count(s)) { + if (m_windows.count(s)) { DoDrawSurroundingMarker(m_windows[s]); } else { // If it wasn't in the window list, it should be a sizer or spacer int id = wxXmlResource::GetXRCID(s); - if((id != wxID_NONE) && m_sizeritems.count(id)) { + if ((id != wxID_NONE) && m_sizeritems.count(id)) { SizeritemData* sid = &(m_sizeritems.find(id)->second); DoMarkSizeritem(sid->m_sizeritem, sid->m_parentWin); } @@ -760,7 +759,7 @@ void DesignerPanel::OnControlFocus(wxFocusEvent& event) wxDataViewTreeCtrl* win1 = dynamic_cast(event.GetEventObject()); wxDataViewCtrl* win2 = dynamic_cast(event.GetEventObject()); wxDataViewListCtrl* win3 = dynamic_cast(event.GetEventObject()); - if(win1 || win2 || win3) { + if (win1 || win2 || win3) { DoControlSelected(event); } #endif @@ -770,7 +769,7 @@ void DesignerPanel::OnRadioBox(wxCommandEvent& e) { e.Skip(); wxRadioBox* rb = dynamic_cast(e.GetEventObject()); - if(rb) { + if (rb) { DoControlSelected(e); } } @@ -778,7 +777,7 @@ void DesignerPanel::OnRadioBox(wxCommandEvent& e) void DesignerPanel::OnRibbonPageChanged(wxRibbonBarEvent& e) { e.Skip(); - if(e.GetPage()) { + if (e.GetPage()) { wxCommandEvent evt(wxEVT_PREVIEW_RIBBON_PAGE_SELECTED); evt.SetString(e.GetPage()->GetName()); EventNotifier::Get()->AddPendingEvent(evt); @@ -789,7 +788,7 @@ void DesignerPanel::OnTreeListCtrlFocus(wxFocusEvent& e) { e.Skip(); wxTreeListCtrl* rb = dynamic_cast(e.GetEventObject()); - if(rb) { + if (rb) { DoControlSelected(e); } } diff --git a/wxcrafter/src/designer_panel.h b/wxcrafter/src/designer_panel.h index 12908a97f6..3df2b77f6b 100644 --- a/wxcrafter/src/designer_panel.h +++ b/wxcrafter/src/designer_panel.h @@ -59,8 +59,11 @@ class DesignerPanel : public wxScrolledWindow void OnTreeListCtrlFocus(wxFocusEvent& e); public: - DesignerPanel(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& position = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0); + DesignerPanel(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& position = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0); ~DesignerPanel() override; DECLARE_EVENT_TABLE() diff --git a/wxcrafter/src/duplicateTLWdlg.cpp b/wxcrafter/src/duplicateTLWdlg.cpp index ff71650f93..82f418896b 100644 --- a/wxcrafter/src/duplicateTLWdlg.cpp +++ b/wxcrafter/src/duplicateTLWdlg.cpp @@ -9,13 +9,13 @@ void DuplicateTLWDlg::OnInheritedNameFocus(wxFocusEvent& event) { event.Skip(); - if(!m_textInheritedName->IsEmpty() || m_textBasename->IsEmpty()) { + if (!m_textInheritedName->IsEmpty() || m_textBasename->IsEmpty()) { // There's nothing to copy, or we already have an entry return; } wxString suggestion = m_textBasename->GetValue(); - if(suggestion.Replace("Base", "") || suggestion.Replace("base", "")) { + if (suggestion.Replace("Base", "") || suggestion.Replace("base", "")) { m_textInheritedName->ChangeValue(suggestion); } } @@ -24,11 +24,13 @@ void DuplicateTLWDlg::OnFilenameFocus(wxFocusEvent& event) { event.Skip(); - if(!m_textFilename->IsEmpty() || m_textInheritedName->IsEmpty()) { + if (!m_textFilename->IsEmpty() || m_textInheritedName->IsEmpty()) { // There's nothing to copy, or we already have an entry return; } wxString suggestion = m_textInheritedName->GetValue(); - if(suggestion.Lower() != suggestion) { m_textFilename->ChangeValue(suggestion.Lower()); } + if (suggestion.Lower() != suggestion) { + m_textFilename->ChangeValue(suggestion.Lower()); + } } diff --git a/wxcrafter/src/enter_strings_dlg.cpp b/wxcrafter/src/enter_strings_dlg.cpp index 54187c2788..dfc98166ae 100644 --- a/wxcrafter/src/enter_strings_dlg.cpp +++ b/wxcrafter/src/enter_strings_dlg.cpp @@ -8,7 +8,9 @@ EnterStringsDlg::EnterStringsDlg(wxWindow* parent, const wxString& value) : EnterStringsDlgBase(parent) { LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexer("text", "Default"); - if(lexer) { lexer->Apply(m_stc); } + if (lexer) { + lexer->Apply(m_stc); + } m_stc->SetText(value); SetName("EnterStringsDlg"); WindowAttrManager::Load(this); @@ -18,7 +20,7 @@ wxString EnterStringsDlg::GetValue() const { return m_stc->GetText(); } void EnterStringsDlg::SetMessage(const wxString& msg) { - if(msg.IsEmpty() == false) { + if (msg.IsEmpty() == false) { m_staticTextMessage->SetLabel(msg); m_staticTextMessage->Show(); } else { diff --git a/wxcrafter/src/events_database.cpp b/wxcrafter/src/events_database.cpp index d2f87c5a3f..46e590c5f3 100644 --- a/wxcrafter/src/events_database.cpp +++ b/wxcrafter/src/events_database.cpp @@ -126,30 +126,30 @@ void EventsDatabase::FillCommonEvents() _("Process a wxEVT_LEFT_DOWN event. The handler of this event should normally " "call event.Skip() to allow the default processing to take place as otherwise " "the window under mouse wouldn't get the focus."))); - m_events.PushBack("wxEVT_LEFT_UP", - ConnectDetails("wxEVT_LEFT_UP", "wxMouseEvent", _("Process a wxEVT_LEFT_UP event."))); + m_events.PushBack( + "wxEVT_LEFT_UP", ConnectDetails("wxEVT_LEFT_UP", "wxMouseEvent", _("Process a wxEVT_LEFT_UP event."))); m_events.PushBack("wxEVT_LEFT_DCLICK", ConnectDetails("wxEVT_LEFT_DCLICK", "wxMouseEvent", _("Process a wxEVT_LEFT_DCLICK event."))); m_events.PushBack("wxEVT_MIDDLE_DOWN", ConnectDetails("wxEVT_MIDDLE_DOWN", "wxMouseEvent", _("Process a wxEVT_MIDDLE_DOWN event"))); - m_events.PushBack("wxEVT_MIDDLE_UP", - ConnectDetails("wxEVT_MIDDLE_UP", "wxMouseEvent", _("Process a wxEVT_MIDDLE_UP event"))); + m_events.PushBack( + "wxEVT_MIDDLE_UP", ConnectDetails("wxEVT_MIDDLE_UP", "wxMouseEvent", _("Process a wxEVT_MIDDLE_UP event"))); m_events.PushBack("wxEVT_MIDDLE_DCLICK", ConnectDetails("wxEVT_MIDDLE_DCLICK", "wxMouseEvent", _("Process a wxEVT_MIDDLE_DCLICK event."))); - m_events.PushBack("wxEVT_RIGHT_DOWN", - ConnectDetails("wxEVT_RIGHT_DOWN", "wxMouseEvent", _("Process a wxEVT_RIGHT_DOWN event"))); - m_events.PushBack("wxEVT_RIGHT_UP", - ConnectDetails("wxEVT_RIGHT_UP", "wxMouseEvent", _("Process a wxEVT_RIGHT_UP event"))); + m_events.PushBack( + "wxEVT_RIGHT_DOWN", ConnectDetails("wxEVT_RIGHT_DOWN", "wxMouseEvent", _("Process a wxEVT_RIGHT_DOWN event"))); + m_events.PushBack( + "wxEVT_RIGHT_UP", ConnectDetails("wxEVT_RIGHT_UP", "wxMouseEvent", _("Process a wxEVT_RIGHT_UP event"))); m_events.PushBack("wxEVT_RIGHT_DCLICK", ConnectDetails("wxEVT_RIGHT_DCLICK", "wxMouseEvent", _("Process a wxEVT_RIGHT_DCLICK event"))); - m_events.PushBack("wxEVT_MOTION", - ConnectDetails("wxEVT_MOTION", "wxMouseEvent", _("Process a wxEVT_MOTION event"))); + m_events.PushBack( + "wxEVT_MOTION", ConnectDetails("wxEVT_MOTION", "wxMouseEvent", _("Process a wxEVT_MOTION event"))); m_events.PushBack("wxEVT_ENTER_WINDOW", ConnectDetails("wxEVT_ENTER_WINDOW", "wxMouseEvent", _("Process a wxEVT_ENTER_WINDOW event"))); m_events.PushBack("wxEVT_LEAVE_WINDOW", ConnectDetails("wxEVT_LEAVE_WINDOW", "wxMouseEvent", _("Process a wxEVT_LEAVE_WINDOW event."))); - m_events.PushBack("wxEVT_MOUSEWHEEL", - ConnectDetails("wxEVT_MOUSEWHEEL", "wxMouseEvent", _("Process a wxEVT_MOUSEWHEEL event"))); + m_events.PushBack( + "wxEVT_MOUSEWHEEL", ConnectDetails("wxEVT_MOUSEWHEEL", "wxMouseEvent", _("Process a wxEVT_MOUSEWHEEL event"))); m_events.PushBack( "wxEVT_MOUSE_CAPTURE_LOST", ConnectDetails("wxEVT_MOUSE_CAPTURE_LOST", @@ -159,10 +159,10 @@ void EventsDatabase::FillCommonEvents() "if another application captures the mouse)"))); // Focus - m_events.PushBack("wxEVT_SET_FOCUS", - ConnectDetails("wxEVT_SET_FOCUS", "wxFocusEvent", _("Process a wxEVT_SET_FOCUS event"))); - m_events.PushBack("wxEVT_KILL_FOCUS", - ConnectDetails("wxEVT_KILL_FOCUS", "wxFocusEvent", _("Process a wxEVT_KILL_FOCUS event"))); + m_events.PushBack( + "wxEVT_SET_FOCUS", ConnectDetails("wxEVT_SET_FOCUS", "wxFocusEvent", _("Process a wxEVT_SET_FOCUS event"))); + m_events.PushBack( + "wxEVT_KILL_FOCUS", ConnectDetails("wxEVT_KILL_FOCUS", "wxFocusEvent", _("Process a wxEVT_KILL_FOCUS event"))); // UI m_events.PushBack("wxEVT_PAINT", ConnectDetails("wxEVT_PAINT", "wxPaintEvent", _("Process a wxEVT_PAINT event"))); @@ -170,12 +170,12 @@ void EventsDatabase::FillCommonEvents() "wxEVT_ERASE_BACKGROUND", ConnectDetails("wxEVT_ERASE_BACKGROUND", "wxEraseEvent", _("Process a wxEVT_ERASE_BACKGROUND event."))); m_events.PushBack("wxEVT_SIZE", ConnectDetails("wxEVT_SIZE", "wxSizeEvent", _("Process a wxEVT_SIZE event"))); - m_events.PushBack("wxEVT_MOVE", - ConnectDetails("wxEVT_MOVE", - "wxMoveEvent", - _("Process a wxEVT_MOVE event, which is generated when a window is moved."))); - m_events.PushBack("wxEVT_UPDATE_UI", - ConnectDetails("wxEVT_UPDATE_UI", "wxUpdateUIEvent", _("Process a wxEVT_UPDATE_UI event"))); + m_events.PushBack( + "wxEVT_MOVE", + ConnectDetails( + "wxEVT_MOVE", "wxMoveEvent", _("Process a wxEVT_MOVE event, which is generated when a window is moved."))); + m_events.PushBack( + "wxEVT_UPDATE_UI", ConnectDetails("wxEVT_UPDATE_UI", "wxUpdateUIEvent", _("Process a wxEVT_UPDATE_UI event"))); // Misc m_events.PushBack("wxEVT_IDLE", ConnectDetails("wxEVT_IDLE", "wxIdleEvent", _("Process a wxEVT_IDLE event"))); diff --git a/wxcrafter/src/events_database.h b/wxcrafter/src/events_database.h index b231ef1e42..26820de7ae 100644 --- a/wxcrafter/src/events_database.h +++ b/wxcrafter/src/events_database.h @@ -22,8 +22,11 @@ class ConnectDetails public: ConnectDetails() = default; - ConnectDetails(const wxString& eventName, const wxString& eventClass, const wxString& description, - bool noBody = false, const wxString& functionNameAndSignature = "") + ConnectDetails(const wxString& eventName, + const wxString& eventClass, + const wxString& description, + bool noBody = false, + const wxString& functionNameAndSignature = "") : m_eventName(eventName) , m_eventClass(eventClass) , m_description(description) @@ -94,8 +97,11 @@ class EventsDatabase void FillCommonEvents(); void Add(const ConnectDetails& ed); - void Add(const wxString& eventName, const wxString& className, const wxString& description, - const wxString& functionNameAndSig = "", bool noBody = false); + void Add(const wxString& eventName, + const wxString& className, + const wxString& description, + const wxString& functionNameAndSig = "", + bool noBody = false); void Clear(); bool Exists(int menuId) const; ConnectDetails Item(int menuId) const; diff --git a/wxcrafter/src/file_picker_ctrl.cpp b/wxcrafter/src/file_picker_ctrl.cpp index 1fd3893c1e..741fcb7299 100644 --- a/wxcrafter/src/file_picker_ctrl.cpp +++ b/wxcrafter/src/file_picker_ctrl.cpp @@ -1,4 +1,5 @@ #include "file_picker_ctrl.h" + #include #include @@ -30,7 +31,7 @@ void FilePickerCtrl::DoEdit() str.Trim().Trim(false); wxFileName fn; - if(m_bmpPath.IsEmpty()) { + if (m_bmpPath.IsEmpty()) { fn = wxFileName(m_projectPath, wxT("")); } else { @@ -40,9 +41,11 @@ void FilePickerCtrl::DoEdit() wxString wildcard = wxT("PNG files (*.png)|*.png|BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif|All files (*)|*"); wxString newPath = wxFileSelector(_("Select bitmap"), wxT(""), wxT(""), wxEmptyString, wildcard, wxFD_OPEN); - if(newPath.IsEmpty() == false) { + if (newPath.IsEmpty() == false) { wxFileName newFilePath(newPath); - if(m_projectPath.IsEmpty() == false) { newFilePath.MakeRelativeTo(m_projectPath); } + if (m_projectPath.IsEmpty() == false) { + newFilePath.MakeRelativeTo(m_projectPath); + } m_bmpPath = newFilePath.GetFullPath(wxPATH_UNIX); wxTextCtrl::ChangeValue(m_bmpPath); DoNotify(); diff --git a/wxcrafter/src/functions_parser.cpp b/wxcrafter/src/functions_parser.cpp index 29b6f4ca3a..2363151c63 100644 --- a/wxcrafter/src/functions_parser.cpp +++ b/wxcrafter/src/functions_parser.cpp @@ -16,7 +16,8 @@ FunctionsParser::FunctionsParser(wxcWidget::Map_t& connectedEvents, const wxStri #define YYNEXT_RET_ON_EOF() \ { \ type = m_scanner.yylex(); \ - if(type == 0) return; \ + if (type == 0) \ + return; \ } #define INC_DEPTH_CONTINUE() \ { \ @@ -27,7 +28,7 @@ FunctionsParser::FunctionsParser(wxcWidget::Map_t& connectedEvents, const wxStri #define DEC_DEPTH_BREAK_IF_ZERO() \ { \ depth--; \ - if(depth == 0) { \ + if (depth == 0) { \ break; \ } else { \ continue; \ @@ -39,17 +40,18 @@ int FunctionsParser::ReadClassName(wxString& clsname) clsname.clear(); int type = 0; - while(true) { + while (true) { type = m_scanner.yylex(); - if(type == 0) return 0; + if (type == 0) + return 0; - if(type == IDENTIFIER) { + if (type == IDENTIFIER) { clsname = m_scanner.YYText(); - } else if(type == '{' || type == ':') { + } else if (type == '{' || type == ':') { return type; - } else if(type == ';') { + } else if (type == ';') { // we probably encountered a forward declaration or 'friend' statement clsname.Clear(); return (int)';'; @@ -64,10 +66,10 @@ void FunctionsParser::Parse() int depth = 0; // search for the class first - while(true) { + while (true) { YYNEXT_RET_ON_EOF(); - if(type == lexCLASS) { + if (type == lexCLASS) { // YYNEXT_RET_ON_EOF(); // read all tokens until we find a ':' or '{' @@ -76,47 +78,50 @@ void FunctionsParser::Parse() // until it hits a ':' or '{' // the last IDENTIFIER consumed is the class name type = ReadClassName(identifierName); - if(type == 0) return; + if (type == 0) + return; - if(identifierName == m_classname) { break; } + if (identifierName == m_classname) { + break; + } } } - if(type == '{') { + if (type == '{') { // we already consumed the '{' char by calling to ReadClassName() depth = 1; } else { // search for the open curly brace - while(true) { + while (true) { YYNEXT_RET_ON_EOF(); - if(type == '{') { + if (type == '{') { depth = 1; break; } } } - while(true) { + while (true) { YYNEXT_RET_ON_EOF(); - if(type == '{') { + if (type == '{') { INC_DEPTH_CONTINUE(); - } else if(type == '}') { + } else if (type == '}') { DEC_DEPTH_BREAK_IF_ZERO(); - } else if(type == lexVOID && depth == 1) { + } else if (type == lexVOID && depth == 1) { // Check the next type, we only check if detph == 1 (meaning we are still inside our class scope) YYNEXT_RET_ON_EOF(); - if(type == '{') { + if (type == '{') { INC_DEPTH_CONTINUE(); - } else if(type == '}') { + } else if (type == '}') { DEC_DEPTH_BREAK_IF_ZERO(); - } else if(type == IDENTIFIER) { + } else if (type == IDENTIFIER) { CheckIfFunctionsExists(wxString(m_scanner.YYText(), wxConvUTF8)); } } diff --git a/wxcrafter/src/my_dialog.cpp b/wxcrafter/src/my_dialog.cpp index 2f06db662f..d4d6704a22 100644 --- a/wxcrafter/src/my_dialog.cpp +++ b/wxcrafter/src/my_dialog.cpp @@ -1,4 +1,5 @@ #include "my_dialog.h" + #include "wxc_aui_manager.h" MyDialog::~MyDialog() { wxcAuiManager::Get().UnInit(this); } diff --git a/wxcrafter/src/my_dialog.h b/wxcrafter/src/my_dialog.h index 29ce9312d8..49b2283390 100644 --- a/wxcrafter/src/my_dialog.h +++ b/wxcrafter/src/my_dialog.h @@ -8,8 +8,12 @@ class MyDialog : public wxDialog public: MyDialog() = default; // Constructor with no modal flag - the new convention. - MyDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE, + MyDialog(wxWindow* parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = wxDialogNameStr) : wxDialog(parent, id, title, pos, size, style, name) { diff --git a/wxcrafter/src/my_frame.h b/wxcrafter/src/my_frame.h index 371bc2b9d4..41ee4cd5a3 100644 --- a/wxcrafter/src/my_frame.h +++ b/wxcrafter/src/my_frame.h @@ -7,8 +7,12 @@ class MyFrame : public wxFrame { public: MyFrame() = default; - MyFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, + MyFrame(wxWindow* parent, + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxFrameNameStr) { Create(parent, id, title, pos, size, style, name); diff --git a/wxcrafter/src/my_panel.h b/wxcrafter/src/my_panel.h index 762fa51194..61b9baa7fb 100644 --- a/wxcrafter/src/my_panel.h +++ b/wxcrafter/src/my_panel.h @@ -7,8 +7,11 @@ class MyPanel : public wxPanel { public: MyPanel() = default; - MyPanel(wxWindow* parent, wxWindowID winid = wxID_ANY, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL | wxNO_BORDER, + MyPanel(wxWindow* parent, + wxWindowID winid = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxTAB_TRAVERSAL | wxNO_BORDER, const wxString& name = wxPanelNameStr) { Create(parent, winid, pos, size, style, name); diff --git a/wxcrafter/src/my_tree_ctrl.cpp b/wxcrafter/src/my_tree_ctrl.cpp index 2fce4e2f01..810017ce46 100644 --- a/wxcrafter/src/my_tree_ctrl.cpp +++ b/wxcrafter/src/my_tree_ctrl.cpp @@ -13,7 +13,7 @@ wxDataViewItem MyTreeCtrl::AddRoot(const wxString& name, int imgId, int expandIm void MyTreeCtrl::SelectItem(const wxDataViewItem& item, bool select) { - if(select) + if (select) Select(item); else Unselect(item); @@ -23,7 +23,7 @@ wxDataViewItem MyTreeCtrl::GetFirstChild(const wxDataViewItem& item) { m_children.clear(); GetStore()->GetChildren(item, m_children); - if(m_children.IsEmpty()) + if (m_children.IsEmpty()) return wxDataViewItem(); else { m_next = 1; @@ -33,9 +33,11 @@ wxDataViewItem MyTreeCtrl::GetFirstChild(const wxDataViewItem& item) wxDataViewItem MyTreeCtrl::GetNextChild(const wxDataViewItem& item) { - if(m_children.IsEmpty()) return wxDataViewItem(); + if (m_children.IsEmpty()) + return wxDataViewItem(); - if(m_next >= m_children.GetCount()) return wxDataViewItem(); + if (m_next >= m_children.GetCount()) + return wxDataViewItem(); wxDataViewItem chld = m_children.Item(m_next); m_next++; diff --git a/wxcrafter/src/my_tree_ctrl.h b/wxcrafter/src/my_tree_ctrl.h index d9b5d7009e..305c4516f4 100644 --- a/wxcrafter/src/my_tree_ctrl.h +++ b/wxcrafter/src/my_tree_ctrl.h @@ -10,8 +10,11 @@ class MyTreeCtrl : public wxDataViewTreeCtrl size_t m_next; public: - MyTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_SINGLE | wxDV_ROW_LINES); + MyTreeCtrl(wxWindow* parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDV_NO_HEADER | wxDV_SINGLE | wxDV_ROW_LINES); ~MyTreeCtrl() override = default; wxDataViewItem AddRoot(const wxString& name, int imgId = -1, int expandImgId = -1); diff --git a/wxcrafter/src/output_nbook.cpp b/wxcrafter/src/output_nbook.cpp index ed7e28ee4b..a385f0d699 100644 --- a/wxcrafter/src/output_nbook.cpp +++ b/wxcrafter/src/output_nbook.cpp @@ -13,8 +13,8 @@ #include #include -OutputNBook::OutputNBook(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, - const wxString& name) +OutputNBook::OutputNBook( + wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxNotebook(parent, id, pos, size, style, name) { } @@ -25,9 +25,12 @@ void OutputNBook::CppPageSelected(wxStyledTextCtrl* cpptext, wxStyledTextCtrl* h wxString cpp, header; wxStringMap_t additionalFiles; - GUICraftMainPanel::m_MainPanel->GenerateCppOutput(cpp, header, headers, additionalFiles, - GUICraftMainPanel::kGenCodeForPreview | - GUICraftMainPanel::kGenCodeSelectionOnly); + GUICraftMainPanel::m_MainPanel->GenerateCppOutput( + cpp, + header, + headers, + additionalFiles, + GUICraftMainPanel::kGenCodeForPreview | GUICraftMainPanel::kGenCodeSelectionOnly); wxString prefix; headers = wxCrafter::MakeUnique(headers); @@ -35,7 +38,7 @@ void OutputNBook::CppPageSelected(wxStyledTextCtrl* cpptext, wxStyledTextCtrl* h // Prepare the project additional include files wxString projectIncludes; const wxArrayString& includes = wxcProjectMetadata::Get().GetIncludeFiles(); - for(size_t i = 0; i < includes.GetCount(); i++) { + for (size_t i = 0; i < includes.GetCount(); i++) { projectIncludes << wxT("#include ") << wxCrafter::AddQuotes(includes.Item(i)) << wxT("\n"); } prefix << projectIncludes; @@ -47,7 +50,7 @@ void OutputNBook::CppPageSelected(wxStyledTextCtrl* cpptext, wxStyledTextCtrl* h cppPrefix << wxT("#include \"") << headerFile.GetFullName() << wxT("\"\n"); cppPrefix << projectIncludes << wxT("\n"); cppPrefix << "// clang-format on\n\n"; - + header.Prepend(prefix); cpp.Prepend(cppPrefix); @@ -69,7 +72,9 @@ void OutputNBook::XrcPageSelected(wxStyledTextCtrl* text) const wxStringInputStream str(output); wxStringOutputStream out; wxXmlDocument doc(str); - if(!doc.Save(out)) { ::wxMessageBox(output); } + if (!doc.Save(out)) { + ::wxMessageBox(output); + } text->SetReadOnly(false); text->SetText(out.GetString()); diff --git a/wxcrafter/src/output_nbook.h b/wxcrafter/src/output_nbook.h index 76d46a1cb1..ac320696e1 100644 --- a/wxcrafter/src/output_nbook.h +++ b/wxcrafter/src/output_nbook.h @@ -7,8 +7,12 @@ class OutputNBook : public wxNotebook { public: - OutputNBook(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxNotebookNameStr); + OutputNBook(wxWindow* parent, + wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxNotebookNameStr); ~OutputNBook() override = default; void CppPageSelected(wxStyledTextCtrl* cpptext, wxStyledTextCtrl* headertext) const; diff --git a/wxcrafter/src/splitter_window_page.cpp b/wxcrafter/src/splitter_window_page.cpp index 92e2234601..9b8ea8d4d8 100644 --- a/wxcrafter/src/splitter_window_page.cpp +++ b/wxcrafter/src/splitter_window_page.cpp @@ -1,4 +1,5 @@ #include "splitter_window_page.h" + #include "allocator_mgr.h" #include "splitter_window_wrapper.h" @@ -15,15 +16,17 @@ wxString SplitterWindowPage::CppCtorCode() const { wxString code = PanelWrapper::CppCtorCode(); SplitterWindowWrapper* sp = dynamic_cast(GetParent()); - if(!sp) { return code; } + if (!sp) { + return code; + } // Add the splitter specific code here const wxcWidget::List_t& siblings = sp->GetChildren(); - if(IsLastChild()) { + if (IsLastChild()) { // We are the last child, create the code that calls the 'split' method wxString first, second; for (const auto* sibling : siblings) { - if(first.IsEmpty()) { + if (first.IsEmpty()) { first = sibling->GetName(); } else { @@ -32,10 +35,10 @@ wxString SplitterWindowPage::CppCtorCode() const } bool splitVert = sp->IsSplitVertically(); - if(first.IsEmpty() == false && second.IsEmpty() == false) { + if (first.IsEmpty() == false && second.IsEmpty() == false) { code << sp->GetName(); - if(splitVert) { + if (splitVert) { code << wxT("->SplitVertically("); } else { code << wxT("->SplitHorizontally("); diff --git a/wxcrafter/src/wxcLicenseGPL2.cpp b/wxcrafter/src/wxcLicenseGPL2.cpp index 24227bd58a..8558ed3d0c 100644 --- a/wxcrafter/src/wxcLicenseGPL2.cpp +++ b/wxcrafter/src/wxcLicenseGPL2.cpp @@ -303,7 +303,8 @@ the "copyright" line and a pointer to where the full notice is found. but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -)" R"( +)" + R"( You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. diff --git a/wxcrafter/src/wxc_aui_manager.cpp b/wxcrafter/src/wxc_aui_manager.cpp index 9bd0eff32f..f5e0cc0e2e 100644 --- a/wxcrafter/src/wxc_aui_manager.cpp +++ b/wxcrafter/src/wxc_aui_manager.cpp @@ -9,7 +9,7 @@ wxcAuiManager& wxcAuiManager::Get() void wxcAuiManager::UnInit(wxWindow* win) { std::map::iterator iter = m_auiMgrMap.find(win); - if(iter != m_auiMgrMap.end()) { + if (iter != m_auiMgrMap.end()) { iter->second->UnInit(); delete iter->second; m_auiMgrMap.erase(iter); @@ -25,6 +25,7 @@ void wxcAuiManager::Add(wxWindow* win, wxAuiManager* aui) wxAuiManager* wxcAuiManager::Find(wxWindow* win) const { - if(m_auiMgrMap.count(win) == 0) return NULL; + if (m_auiMgrMap.count(win) == 0) + return NULL; return m_auiMgrMap.find(win)->second; } diff --git a/wxcrafter/src/wxc_aui_tool_stickiness.cpp b/wxcrafter/src/wxc_aui_tool_stickiness.cpp index d56274f0f6..260eb50fce 100644 --- a/wxcrafter/src/wxc_aui_tool_stickiness.cpp +++ b/wxcrafter/src/wxc_aui_tool_stickiness.cpp @@ -3,14 +3,18 @@ wxcAuiToolStickiness::wxcAuiToolStickiness(wxAuiToolBar* tb, int toolId) : m_tb(tb) { - if(m_tb) { m_item = m_tb->FindTool(toolId); } + if (m_tb) { + m_item = m_tb->FindTool(toolId); + } - if(m_item) { m_item->SetSticky(true); } + if (m_item) { + m_item->SetSticky(true); + } } wxcAuiToolStickiness::~wxcAuiToolStickiness() { - if(m_item) { + if (m_item) { m_item->SetSticky(false); m_tb->Refresh(); } diff --git a/wxcrafter/src/wxc_aui_tool_stickiness.h b/wxcrafter/src/wxc_aui_tool_stickiness.h index 733f3b58b4..0ab7a3dde1 100644 --- a/wxcrafter/src/wxc_aui_tool_stickiness.h +++ b/wxcrafter/src/wxc_aui_tool_stickiness.h @@ -1,8 +1,8 @@ #ifndef WXCAUITOOLSTICKINESS_H #define WXCAUITOOLSTICKINESS_H -#include #include +#include class wxcAuiToolStickiness { diff --git a/wxcrafter/src/wxc_bitmap_code_generator.cpp b/wxcrafter/src/wxc_bitmap_code_generator.cpp index ea666aecb0..e75c81df6f 100644 --- a/wxcrafter/src/wxc_bitmap_code_generator.cpp +++ b/wxcrafter/src/wxc_bitmap_code_generator.cpp @@ -43,14 +43,14 @@ bool wxcCodeGeneratorHelper::CreateXRC() wxString text; text << wxT("\n"); text << wxT(""); - if(wxcProjectMetadata::Get().IsAddHandlers()) { + if (wxcProjectMetadata::Get().IsAddHandlers()) { text << "\n"; } else { text << "\n"; } // Supported hi-res images extension - const wxArrayString exts = StdToWX::ToArrayString({ "@2x", "@1.25x", "@1.5x" }); + const wxArrayString exts = StdToWX::ToArrayString({"@2x", "@1.25x", "@1.5x"}); for (const auto& p : m_bitmapMap) { wxFileName fn(p.second); @@ -87,7 +87,9 @@ bool wxcCodeGeneratorHelper::CreateXRC() wxString outputString; wxStringOutputStream outStream(&outputString); - if(!doc.Save(outStream)) { return false; } + if (!doc.Save(outStream)) { + return false; + } // Check to see if we already got m_destCPP = @@ -97,14 +99,14 @@ bool wxcCodeGeneratorHelper::CreateXRC() bool isBitmapModifiedOutside = IsGenerateNeeded(); - if(isBitmapModifiedOutside) { + if (isBitmapModifiedOutside) { // Request for update wxCommandEvent evtUpdateDesigner(wxEVT_REFRESH_DESIGNER); EventNotifier::Get()->AddPendingEvent(evtUpdateDesigner); } #if !defined(__WXMAC__) - if(wxCrafter::IsTheSame(outputString, m_xrcFile) && m_destCPP.FileExists() && !isBitmapModifiedOutside) { + if (wxCrafter::IsTheSame(outputString, m_xrcFile) && m_destCPP.FileExists() && !isBitmapModifiedOutside) { // the XRC used to generate the file is the same as the new one // and we got a CPP file - skip the code generation wxCommandEvent eventEnd(wxEVT_BITMAP_CODE_GENERATION_DONE); @@ -113,7 +115,9 @@ bool wxcCodeGeneratorHelper::CreateXRC() return true; } #endif - if(!doc.Save(m_xrcFile.GetFullPath())) { return false; } + if (!doc.Save(m_xrcFile.GetFullPath())) { + return false; + } { wxFrame* topFrame = EventNotifier::Get()->TopFrame(); @@ -143,16 +147,16 @@ wxString wxcCodeGeneratorHelper::GenerateInitCode(TopLevelWinWrapper* tw) const wxString code; code << " if ( !bBitmapLoaded ) {\n" << " // We need to initialise the default bitmap handler\n"; - if(wxcProjectMetadata::Get().IsAddHandlers()) { + if (wxcProjectMetadata::Get().IsAddHandlers()) { code << " wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler);\n"; } code << " " << wxcProjectMetadata::Get().GetBitmapFunction() << "();\n" << " bBitmapLoaded = true;\n" << " }\n"; - if(tw->HasIcon()) { + if (tw->HasIcon()) { wxString appIconCode = GenerateTopLevelWindowIconCode(); - if(!appIconCode.IsEmpty()) { + if (!appIconCode.IsEmpty()) { // add the icon code here code << appIconCode << "\n"; } @@ -172,11 +176,13 @@ wxString wxcCodeGeneratorHelper::BitmapCode(const wxString& bmp, const wxString& wxString tmpbmp = bmp; tmpbmp.Trim().Trim(false); - if(tmpbmp.IsEmpty()) { return wxT("wxNullBitmap"); } + if (tmpbmp.IsEmpty()) { + return wxT("wxNullBitmap"); + } wxString artId, clientId, sizeHint; wxString code; - if(wxCrafter::IsArtProviderBitmap(bmp, artId, clientId, sizeHint)) { + if (wxCrafter::IsArtProviderBitmap(bmp, artId, clientId, sizeHint)) { code << "wxArtProvider::GetBitmap(" << artId << ", " << clientId << ", " << wxCrafter::MakeWxSizeStr(sizeHint) << ")"; @@ -194,17 +200,22 @@ wxString wxcCodeGeneratorHelper::AddBitmap(const wxString& bitmapFile, const wxS { wxString bmppath = bitmapFile; bmppath.Trim().Trim(false); - if(bmppath.IsEmpty()) return ""; + if (bmppath.IsEmpty()) + return ""; wxString artId, clientId, sizeHint; - if(wxCrafter::IsArtProviderBitmap(bmppath, artId, clientId, sizeHint)) { return ""; } + if (wxCrafter::IsArtProviderBitmap(bmppath, artId, clientId, sizeHint)) { + return ""; + } wxFileName fn(bmppath); wxString bmpname; // set the name + remove old entry name.IsEmpty() ? bmpname = fn.GetName() : bmpname = name; - if(m_bitmapMap.count(bmpname)) { m_bitmapMap.erase(bmpname); } + if (m_bitmapMap.count(bmpname)) { + m_bitmapMap.erase(bmpname); + } m_bitmapMap.insert(std::make_pair(bmpname, bmppath)); return bmpname; @@ -212,17 +223,19 @@ wxString wxcCodeGeneratorHelper::AddBitmap(const wxString& bitmapFile, const wxS bool wxcCodeGeneratorHelper::IsGenerateNeeded() const { - if(!m_xrcFile.FileExists()) { return true; } + if (!m_xrcFile.FileExists()) { + return true; + } wxString basepath = wxcProjectMetadata::Get().GetProjectPath(); time_t xrcModTime = m_xrcFile.GetModificationTime().GetTicks(); for (const auto& p : m_bitmapMap) { wxFileName bmpFile(p.second); - if(bmpFile.MakeAbsolute(basepath)) { - if(bmpFile.FileExists()) { + if (bmpFile.MakeAbsolute(basepath)) { + if (bmpFile.FileExists()) { time_t bmpMod = bmpFile.GetModificationTime().GetTicks(); - if(bmpMod > xrcModTime) { + if (bmpMod > xrcModTime) { // the bmp file is newer than the xrc file - regenerate return true; } @@ -238,7 +251,9 @@ void wxcCodeGeneratorHelper::ClearWindowIds() { m_winIds.clear(); } wxString wxcCodeGeneratorHelper::GenerateWinIdEnum() const { - if(m_winIds.empty() || !wxcProjectMetadata::Get().IsUseEnum()) { return ""; } + if (m_winIds.empty() || !wxcProjectMetadata::Get().IsUseEnum()) { + return ""; + } int firstId = wxcProjectMetadata::Get().GetFirstWindowId(); wxString enumCode; @@ -253,9 +268,12 @@ wxString wxcCodeGeneratorHelper::GenerateWinIdEnum() const void wxcCodeGeneratorHelper::AddIcon(const wxString& bitmapFile) { - if(bitmapFile.IsEmpty()) { return; } + if (bitmapFile.IsEmpty()) { + return; + } wxString bmpadded = AddBitmap(bitmapFile); - if(bmpadded.IsEmpty()) return; + if (bmpadded.IsEmpty()) + return; m_icons.Add(bmpadded); } @@ -263,10 +281,10 @@ wxString wxcCodeGeneratorHelper::GenerateTopLevelWindowIconCode() const { wxString code; - if(!m_icons.IsEmpty()) { + if (!m_icons.IsEmpty()) { code << " // Set icon(s) to the application/dialog\n"; code << " wxIconBundle app_icons;\n"; - for(size_t i = 0; i < m_icons.GetCount(); ++i) { + for (size_t i = 0; i < m_icons.GetCount(); ++i) { code << " {\n" << " wxBitmap iconBmp = " << BitmapCode(m_icons.Item(i)) << ";\n" << " wxIcon icn;\n" diff --git a/wxcrafter/src/wxc_edit_manager.cpp b/wxcrafter/src/wxc_edit_manager.cpp index f52495a8dd..263b18dc96 100644 --- a/wxcrafter/src/wxc_edit_manager.cpp +++ b/wxcrafter/src/wxc_edit_manager.cpp @@ -1,7 +1,9 @@ #include "wxc_edit_manager.h" + #include "event_notifier.h" #include "wxc_project_metadata.h" #include "wxguicraft_main_view.h" + #include wxDEFINE_EVENT(wxEVT_MULTIPLE_UNREDO, wxCommandEvent); @@ -11,16 +13,16 @@ const int FIRST_MENU_ID = 10000; wxcEditManager::wxcEditManager() : m_isModified(false) { - EventNotifier::Get()->Connect(wxEVT_WXGUI_PROJECT_SAVED, wxCommandEventHandler(wxcEditManager::OnProjectSaved), - NULL, this); - EventNotifier::Get()->Connect(wxEVT_WXC_PROJECT_LOADED, wxCommandEventHandler(wxcEditManager::OnProjectLoaded), - NULL, this); - EventNotifier::Get()->Connect(wxEVT_WXGUI_PROJECT_CLOSED, wxCommandEventHandler(wxcEditManager::OnProjectClosed), - NULL, this); - EventNotifier::Get()->Connect(wxEVT_PROJECT_METADATA_MODIFIED, - wxCommandEventHandler(wxcEditManager::OnProjectMetadataChanged), NULL, this); - EventNotifier::Get()->Connect(wxEVT_PROPERTIES_MODIFIED, wxCommandEventHandler(wxcEditManager::OnPropertyChanged), - NULL, this); + EventNotifier::Get()->Connect( + wxEVT_WXGUI_PROJECT_SAVED, wxCommandEventHandler(wxcEditManager::OnProjectSaved), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_WXC_PROJECT_LOADED, wxCommandEventHandler(wxcEditManager::OnProjectLoaded), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_WXGUI_PROJECT_CLOSED, wxCommandEventHandler(wxcEditManager::OnProjectClosed), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_PROJECT_METADATA_MODIFIED, wxCommandEventHandler(wxcEditManager::OnProjectMetadataChanged), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_PROPERTIES_MODIFIED, wxCommandEventHandler(wxcEditManager::OnPropertyChanged), NULL, this); } wxcEditManager& wxcEditManager::Get() @@ -54,7 +56,7 @@ void wxcEditManager::OnUndoDropdownItem(wxCommandEvent& event) { const int count = event.GetId() - FIRST_MENU_ID + 1; wxCHECK_RET(count > 0 && count <= (int)m_undoList.size(), "Invalid command index"); - for(int n = 0; n < count; ++n) { + for (int n = 0; n < count; ++n) { State::Ptr_t state = m_undoList.back(); m_undoList.pop_back(); m_redoList.push_back(state); @@ -71,7 +73,7 @@ void wxcEditManager::OnRedoDropdownItem(wxCommandEvent& event) { const int count = event.GetId() - FIRST_MENU_ID + 1; wxCHECK_RET(count > 0 && count <= (int)m_redoList.size(), "Invalid command index"); - for(int n = 0; n < count; ++n) { + for (int n = 0; n < count; ++n) { State::Ptr_t state = m_redoList.back(); m_redoList.pop_back(); m_undoList.push_back(state); @@ -100,7 +102,8 @@ void wxcEditManager::Clear() State::Ptr_t wxcEditManager::GetCurrentState() const { - if(m_undoList.empty()) return m_initialState; + if (m_undoList.empty()) + return m_initialState; return m_undoList.back(); } @@ -141,7 +144,7 @@ void wxcEditManager::OnPropertyChanged(wxCommandEvent& event) void wxcEditManager::PushState(const wxString& label) { - if(GUICraftMainPanel::m_MainPanel) { + if (GUICraftMainPanel::m_MainPanel) { SetModified(true); State::Ptr_t state = GUICraftMainPanel::m_MainPanel->CurrentState(); state->label = label; @@ -164,7 +167,7 @@ void wxcEditManager::NotifyProjectSynched() void wxcEditManager::SetModified(bool modified) { m_isModified = modified; - if(m_isModified) { + if (m_isModified) { NotifyProjectModified(); } else { NotifyProjectSynched(); @@ -181,17 +184,21 @@ void wxcEditManager::DoPopulateUnRedoMenu(wxMenu& menu, bool undoing) int id = FIRST_MENU_ID; int count = 0; - if(undoing) { - if(m_undoList.size() > 0) { - for(State::List_t::const_reverse_iterator iter = m_undoList.rbegin(); iter != m_undoList.rend(); ++iter) { + if (undoing) { + if (m_undoList.size() > 0) { + for (State::List_t::const_reverse_iterator iter = m_undoList.rbegin(); iter != m_undoList.rend(); ++iter) { State::Ptr_t command = *iter; - if(command) { menu.Append(id++, wxString::Format("%i ", ++count) + prefix + command->label); } + if (command) { + menu.Append(id++, wxString::Format("%i ", ++count) + prefix + command->label); + } } } } else { - for(State::List_t::const_reverse_iterator iter = m_redoList.rbegin(); iter != m_redoList.rend(); ++iter) { + for (State::List_t::const_reverse_iterator iter = m_redoList.rbegin(); iter != m_redoList.rend(); ++iter) { State::Ptr_t command = *iter; - if(command) { menu.Append(id++, wxString::Format("%i ", ++count) + prefix + command->label); } + if (command) { + menu.Append(id++, wxString::Format("%i ", ++count) + prefix + command->label); + } } } } diff --git a/wxcrafter/src/wxc_project_metadata.cpp b/wxcrafter/src/wxc_project_metadata.cpp index 0aef98d708..5772310683 100644 --- a/wxcrafter/src/wxc_project_metadata.cpp +++ b/wxcrafter/src/wxc_project_metadata.cpp @@ -33,14 +33,14 @@ void wxcProjectMetadata::FromJSON(const JSONItem& json) m_addHandlers = json.namedObject("m_addHandlers").toBool(m_addHandlers); wxcSettings::Get().MergeCustomControl(json.namedObject("m_templateClasses")); - if(m_bitmapFunction.IsEmpty()) { + if (m_bitmapFunction.IsEmpty()) { DoGenerateBitmapFunctionName(); } // for backward-compatibility, we continue to use .h file extension if it's already there wxFileName headerFile = BaseCppFile(); headerFile.SetExt("h"); - if(headerFile.IsRelative()) { + if (headerFile.IsRelative()) { headerFile.MakeAbsolute(GetProjectPath()); } wxString header_file = headerFile.GetFullPath(); @@ -82,7 +82,7 @@ wxString wxcProjectMetadata::GetCppFileName() const wxString wxcProjectMetadata::GetXrcFileName() const { wxFileName xrc(m_projectFile); - if(!xrc.IsAbsolute()) { + if (!xrc.IsAbsolute()) { xrc = wxFileName(m_generatedFilesDir, m_projectFile); } xrc.SetExt("xrc"); @@ -168,7 +168,7 @@ void wxcProjectMetadata::DoGenerateBitmapFunctionName() wxString wxcProjectMetadata::DoGenerateBitmapsFile() const { - if(GetProjectFile().IsEmpty()) { + if (GetProjectFile().IsEmpty()) { return ""; } @@ -187,7 +187,7 @@ wxString wxcProjectMetadata::DoGenerateBitmapsFile() const wxString wxcProjectMetadata::GetBitmapsFile() const { - if(m_bitmapsFile.IsEmpty()) { + if (m_bitmapsFile.IsEmpty()) { return DoGenerateBitmapsFile(); } @@ -206,7 +206,7 @@ void wxcProjectMetadata::Serialize(const wxcWidget::List_t& topLevelsList, const root.toElement().append(windows); wxFFile fp(filename.GetFullPath(), "w+b"); - if(fp.IsOpened()) { + if (fp.IsOpened()) { for (auto widget : topLevelsList) { JSONItem obj = JSONItem::createObject(); @@ -222,7 +222,7 @@ void wxcProjectMetadata::Serialize(const wxcWidget::List_t& topLevelsList, const wxString wxcProjectMetadata::GetOutputFileName() const { - if(m_outputFileName.IsEmpty()) { + if (m_outputFileName.IsEmpty()) { wxFileName fn(GetProjectFile()); return fn.GetName(); } @@ -239,10 +239,10 @@ void wxcProjectMetadata::SetProjectFile(const wxString& filename) void wxcProjectMetadata::UpdatePaths() { - if(m_generatedFilesDir.IsEmpty()) { + if (m_generatedFilesDir.IsEmpty()) { m_generatedFilesDir = "."; } - if(m_bitmapsFile.IsEmpty()) { + if (m_bitmapsFile.IsEmpty()) { m_bitmapsFile = DoGenerateBitmapsFile(); } } diff --git a/wxcrafter/src/wxc_settings.cpp b/wxcrafter/src/wxc_settings.cpp index 750abd31fe..7f88d21b98 100644 --- a/wxcrafter/src/wxc_settings.cpp +++ b/wxcrafter/src/wxc_settings.cpp @@ -21,7 +21,7 @@ void wxcSettings::Load() { wxFileName fn(wxCrafter::GetConfigFile()); JSON root(fn); - if(root.isOk()) { + if (root.isOk()) { m_flags = root.toElement().namedObject("m_annoyDialogs").toInt(m_flags); m_flags &= ~USE_TABBED_MODE; m_sashPosition = root.toElement().namedObject("m_sashPosition").toInt(150); @@ -31,7 +31,7 @@ void wxcSettings::Load() JSONItem arr = root.toElement().namedObject("m_templateClasses"); m_templateClasses.clear(); - for(int i = 0; i < arr.arraySize(); ++i) { + for (int i = 0; i < arr.arraySize(); ++i) { CustomControlTemplate templateControl; templateControl.FromJSON(arr.arrayItem(i)); templateControl.SetControlId(::wxNewEventType()); @@ -64,7 +64,7 @@ void wxcSettings::Save() void wxcSettings::RegisterCustomControl(CustomControlTemplate& cct) { CustomControlTemplateMap_t::iterator iter = m_templateClasses.find(cct.GetClassName()); - if(iter != m_templateClasses.end()) { + if (iter != m_templateClasses.end()) { m_templateClasses.erase(iter); } cct.SetControlId(::wxNewEventType()); @@ -84,7 +84,7 @@ CustomControlTemplate wxcSettings::FindByControlId(int controlId) const CustomControlTemplate wxcSettings::FindByControlName(const wxString& name) const { CustomControlTemplateMap_t::const_iterator iter = m_templateClasses.find(name); - if(iter == m_templateClasses.end()) { + if (iter == m_templateClasses.end()) { return CustomControlTemplate(); } return iter->second; @@ -93,7 +93,7 @@ CustomControlTemplate wxcSettings::FindByControlName(const wxString& name) const void wxcSettings::DeleteCustomControl(const wxString& name) { CustomControlTemplateMap_t::iterator iter = m_templateClasses.find(name); - if(iter == m_templateClasses.end()) { + if (iter == m_templateClasses.end()) { return; } @@ -102,12 +102,12 @@ void wxcSettings::DeleteCustomControl(const wxString& name) void wxcSettings::MergeCustomControl(const JSONItem& arr) { - for(int i = 0; i < arr.arraySize(); ++i) { + for (int i = 0; i < arr.arraySize(); ++i) { CustomControlTemplate templateControl; templateControl.FromJSON(arr.arrayItem(i)); templateControl.SetControlId(::wxNewEventType()); - if(m_templateClasses.count(templateControl.GetClassName())) { + if (m_templateClasses.count(templateControl.GetClassName())) { // an instance with this name already exists, replace it m_templateClasses.erase(templateControl.GetClassName()); } diff --git a/wxcrafter/src/wxc_settings.h b/wxcrafter/src/wxc_settings.h index 64a628ad68..d24fd0c56e 100644 --- a/wxcrafter/src/wxc_settings.h +++ b/wxcrafter/src/wxc_settings.h @@ -84,7 +84,7 @@ class wxcSettings void EnableFlag(int flag, bool b) { - if(b) { + if (b) { m_flags |= flag; } else { m_flags &= ~flag; diff --git a/wxcrafter/src/wxc_widget.h b/wxcrafter/src/wxc_widget.h index 3d0f863d0f..c0a9772170 100644 --- a/wxcrafter/src/wxc_widget.h +++ b/wxcrafter/src/wxc_widget.h @@ -203,11 +203,15 @@ class wxcWidget bool DoCheckNameUniqueness(const wxString& name, const wxcWidget* widget) const; // Copy current wxcWidget children into 'widget' - void DoCopyChildren(wxcWidget* widget, enum DuplicatingOptions nametypesToChange, + void DoCopyChildren(wxcWidget* widget, + enum DuplicatingOptions nametypesToChange, const std::set& existingNames) const; - virtual void DoDeepCopy(const wxcWidget& rhs, enum DuplicatingOptions nametypesToChange, - const std::set& existingNames, const wxString& chosenName = "", - const wxString& chosenInheritedName = "", const wxString& chosenFilename = ""); + virtual void DoDeepCopy(const wxcWidget& rhs, + enum DuplicatingOptions nametypesToChange, + const std::set& existingNames, + const wxString& chosenName = "", + const wxString& chosenInheritedName = "", + const wxString& chosenFilename = ""); public: void SetCopyReason(COPY_REASON cr) { m_copyReason = cr; } @@ -301,9 +305,15 @@ class wxcWidget protected: // Pure virtual virtual void GetIncludeFile(wxArrayString& headers) const = 0; - void DoTraverseAndGenCode(wxArrayString& headers, wxString& ctorCode, wxString& members, wxString& eventFunctions, - wxString& eventConnectCode, wxStringMap_t& additionalFiles, wxString& dtorCode, - wxString& extraFunctionsImpl, wxString& extraFunctionsDecl) const; + void DoTraverseAndGenCode(wxArrayString& headers, + wxString& ctorCode, + wxString& members, + wxString& eventFunctions, + wxString& eventConnectCode, + wxStringMap_t& additionalFiles, + wxString& dtorCode, + wxString& extraFunctionsImpl, + wxString& extraFunctionsDecl) const; void DoGetCustomControlsName(const wxcWidget* widget, wxArrayString& controls) const; wxString DoGenerateEventStubs() const; @@ -355,8 +365,12 @@ class wxcWidget */ virtual wxString CreateBaseclassName() const; - void RegisterEvent(const wxString& eventName, const wxString& className, const wxString& description, - const wxString& handlerName = "", const wxString& functionNameAndSig = "", bool noBody = false); + void RegisterEvent(const wxString& eventName, + const wxString& className, + const wxString& description, + const wxString& handlerName = "", + const wxString& functionNameAndSig = "", + bool noBody = false); /** * @brief acronym for RegisterEvent(eventName, "wxCommandEvent", "wxCommandEventHandler") */ @@ -512,8 +526,10 @@ class wxcWidget /** * @brief create a copy of this class - with all its properties / sizers / styles and wxAUI properties copied */ - virtual wxcWidget* Copy(enum DuplicatingOptions nametypesToChange, const std::set& existingNames, - const wxString& chosenName = "", const wxString& chosenInheritedName = "", + virtual wxcWidget* Copy(enum DuplicatingOptions nametypesToChange, + const std::set& existingNames, + const wxString& chosenName = "", + const wxString& chosenInheritedName = "", const wxString& chosenFilename = "") const; /** diff --git a/wxcrafter/src/wxgui_bitmaploader.cpp b/wxcrafter/src/wxgui_bitmaploader.cpp index cfcf64df9e..14322c8ee5 100644 --- a/wxcrafter/src/wxgui_bitmaploader.cpp +++ b/wxcrafter/src/wxgui_bitmaploader.cpp @@ -16,7 +16,7 @@ std::map wxCrafter::ResourceLoader::m_files; wxCrafter::ResourceLoader::ResourceLoader(const wxString& skin) { - if(m_bitmaps.empty()) { + if (m_bitmaps.empty()) { wxString zipFile; #ifdef __WXMSW__ zipFile << wxStandardPaths::Get().GetDataDir() << wxT(INSTALL_DIR) << wxFileName::GetPathSeparator() << skin @@ -28,23 +28,27 @@ wxCrafter::ResourceLoader::ResourceLoader(const wxString& skin) std::unordered_map entries; zip.ExtractAll(entries); - if(entries.empty()) { return; } + if (entries.empty()) { + return; + } // Loop over the files - for(const auto& entry : entries) { + for (const auto& entry : entries) { wxFileName fn = wxFileName(entry.first); wxString name = fn.GetName(); clZipReader::Entry d = entry.second; - if(d.len && d.buffer) { + if (d.len && d.buffer) { // Avoid wxAsserts by checking it's likely to be a png before creating the image - if(fn.GetExt() == "png") { + if (fn.GetExt() == "png") { wxMemoryInputStream is(d.buffer, d.len); wxImage img(is, wxBITMAP_TYPE_PNG); wxBitmap bmp(img); - if(bmp.IsOk()) { m_bitmaps[name] = bmp; } + if (bmp.IsOk()) { + m_bitmaps[name] = bmp; + } } else { wxString fileContent((const char*)d.buffer, d.len); - m_files.insert({ fn.GetFullName(), fileContent }); + m_files.insert({fn.GetFullName(), fileContent}); } // release the memory free(d.buffer); @@ -58,7 +62,9 @@ const wxBitmap& wxCrafter::ResourceLoader::Bitmap(const wxString& name) const { static wxBitmap s_nullBitmap; std::map::const_iterator iter = m_bitmaps.find(name); - if(iter == m_bitmaps.end()) { return s_nullBitmap; } + if (iter == m_bitmaps.end()) { + return s_nullBitmap; + } return iter->second; } @@ -66,9 +72,9 @@ wxFileName wxCrafter::ResourceLoader::GetPlaceHolderImagePath() const { static const wxString PLACEHOLDER_IMG = wxT("placeholder"); const wxBitmap& bmp = Bitmap(PLACEHOLDER_IMG); - if(bmp.IsOk()) { + if (bmp.IsOk()) { wxFileName path(wxFileName::GetTempDir(), wxT("placeholder.png")); - if(bmp.SaveFile(path.GetFullPath(), wxBITMAP_TYPE_PNG)) { + if (bmp.SaveFile(path.GetFullPath(), wxBITMAP_TYPE_PNG)) { path.MakeRelativeTo(wxcProjectMetadata::Get().GetProjectPath()); return path; } @@ -80,9 +86,9 @@ wxFileName wxCrafter::ResourceLoader::GetPlaceHolder16ImagePath() const { static const wxString PLACEHOLDER_IMG16 = wxT("placeholder16"); const wxBitmap& bmp = Bitmap(PLACEHOLDER_IMG16); - if(bmp.IsOk()) { + if (bmp.IsOk()) { wxFileName path(wxFileName::GetTempDir(), wxT("placeholder16.png")); - if(bmp.SaveFile(path.GetFullPath(), wxBITMAP_TYPE_PNG)) { + if (bmp.SaveFile(path.GetFullPath(), wxBITMAP_TYPE_PNG)) { path.MakeRelativeTo(wxcProjectMetadata::Get().GetProjectPath()); return path; } @@ -93,6 +99,8 @@ wxFileName wxCrafter::ResourceLoader::GetPlaceHolder16ImagePath() const wxString wxCrafter::ResourceLoader::File(const wxString& name) const { std::map::const_iterator iter = m_files.find(name); - if(iter == m_files.end()) { return wxT(""); } + if (iter == m_files.end()) { + return wxT(""); + } return iter->second; } diff --git a/wxcrafter/src/wxgui_defs.h b/wxcrafter/src/wxgui_defs.h index dbe2db9abe..d2ab1c8acf 100644 --- a/wxcrafter/src/wxgui_defs.h +++ b/wxcrafter/src/wxgui_defs.h @@ -7,16 +7,16 @@ class wxcWidget; #define CHECK_POINTER(d) \ - if(!d) \ + if (!d) \ return; #define CHECK_POINTER_RET_NULL(d) \ - if(!d) \ + if (!d) \ return NULL; #define CHECK_POINTER_RET_FALSE(d) \ - if(!d) \ + if (!d) \ return false; -#define CHECK_TREEITEM(item) \ - if(item.IsOk() == false) \ +#define CHECK_TREEITEM(item) \ + if (item.IsOk() == false) \ return; #define STRINGFY(flag) wxString(#flag, wxConvUTF8) @@ -56,7 +56,7 @@ class wxcWidget; #define REMOVE_STYLE(styleBit) \ { \ wxString name = wxString(#styleBit, wxConvUTF8); \ - if(m_styles.Contains(name)) \ + if (m_styles.Contains(name)) \ m_styles.Remove(name); \ } diff --git a/wxcrafter/src/wxgui_globals.cpp b/wxcrafter/src/wxgui_globals.cpp index 6451f9e848..70841e91bd 100644 --- a/wxcrafter/src/wxgui_globals.cpp +++ b/wxcrafter/src/wxgui_globals.cpp @@ -45,10 +45,10 @@ bool ReadFileContent(const wxString& fileName, wxString& content) content.Clear(); wxFFile file(fileName, wxT("rb")); - if(file.IsOpened()) { + if (file.IsOpened()) { file.ReadAll(&content); - if(content.IsEmpty()) { + if (content.IsEmpty()) { // now try the Utf8 file.ReadAll(&content, wxConvUTF8); } diff --git a/wxcrafter/src/wxgui_helpers.cpp b/wxcrafter/src/wxgui_helpers.cpp index 30e8e3d775..ae5ace4561 100644 --- a/wxcrafter/src/wxgui_helpers.cpp +++ b/wxcrafter/src/wxgui_helpers.cpp @@ -39,56 +39,56 @@ namespace wxFont GetSystemFont(const wxString& name) { // name is in the format of name,style,weight,underlined - if(!name.IsEmpty()) { + if (!name.IsEmpty()) { wxArrayString parts = ::wxStringTokenize(name, wxT(","), wxTOKEN_STRTOK); - if(parts.IsEmpty()) + if (parts.IsEmpty()) return wxNullFont; wxFont font; wxString name, style, weight, underlined; name = parts.Item(0); - if(parts.GetCount() > 1) + if (parts.GetCount() > 1) style = parts.Item(1); - if(parts.GetCount() > 2) + if (parts.GetCount() > 2) weight = parts.Item(2); - if(parts.GetCount() > 3) + if (parts.GetCount() > 3) underlined = parts.Item(3); - if(name == wxT("wxSYS_OEM_FIXED_FONT")) + if (name == wxT("wxSYS_OEM_FIXED_FONT")) font = wxSystemSettings::GetFont(wxSYS_OEM_FIXED_FONT); - else if(name == wxT("wxSYS_ANSI_FIXED_FONT")) { + else if (name == wxT("wxSYS_ANSI_FIXED_FONT")) { font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); font.SetFamily(wxFONTFAMILY_TELETYPE); } - else if(name == wxT("wxSYS_ANSI_VAR_FONT")) + else if (name == wxT("wxSYS_ANSI_VAR_FONT")) font = wxSystemSettings::GetFont(wxSYS_ANSI_VAR_FONT); - else if(name == wxT("wxSYS_SYSTEM_FONT")) + else if (name == wxT("wxSYS_SYSTEM_FONT")) font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT); - else if(name == wxT("wxSYS_DEVICE_DEFAULT_FONT")) + else if (name == wxT("wxSYS_DEVICE_DEFAULT_FONT")) font = wxSystemSettings::GetFont(wxSYS_DEVICE_DEFAULT_FONT); - else if(name == wxT("wxSYS_SYSTEM_FIXED_FONT")) + else if (name == wxT("wxSYS_SYSTEM_FIXED_FONT")) font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FIXED_FONT); - else if(name == wxT("wxSYS_DEFAULT_GUI_FONT")) + else if (name == wxT("wxSYS_DEFAULT_GUI_FONT")) font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); else return wxNullFont; - if(style == wxT("italic")) + if (style == wxT("italic")) font.SetStyle(wxFONTSTYLE_ITALIC); else font.SetStyle(wxFONTSTYLE_NORMAL); - if(weight == wxT("bold")) + if (weight == wxT("bold")) font.SetWeight(wxFONTWEIGHT_BOLD); else font.SetWeight(wxFONTWEIGHT_NORMAL); - if(underlined == wxT("underlined")) + if (underlined == wxT("underlined")) font.SetUnderlined(true); else font.SetUnderlined(false); @@ -100,22 +100,22 @@ wxFont GetSystemFont(const wxString& name) wxFontFamily StringToFontFamily(const wxString& str) { wxFontFamily family = wxFONTFAMILY_DEFAULT; - if(str == wxT("decorative")) + if (str == wxT("decorative")) family = wxFONTFAMILY_DECORATIVE; - if(str == wxT("roman")) + if (str == wxT("roman")) family = wxFONTFAMILY_ROMAN; - if(str == wxT("script")) + if (str == wxT("script")) family = wxFONTFAMILY_SCRIPT; - if(str == wxT("swiss")) + if (str == wxT("swiss")) family = wxFONTFAMILY_SWISS; - if(str == wxT("modern")) + if (str == wxT("modern")) family = wxFONTFAMILY_MODERN; - if(str == wxT("teletype")) + if (str == wxT("teletype")) family = wxFONTFAMILY_TELETYPE; return family; @@ -124,9 +124,9 @@ wxFontFamily StringToFontFamily(const wxString& str) wxFontStyle StringToFontStyle(const wxString& str) { wxFontStyle style = wxFONTSTYLE_NORMAL; - if((str == wxT("italic")) || (wxCrafter::ToNumber(str, -1) == wxFONTSTYLE_ITALIC)) { + if ((str == wxT("italic")) || (wxCrafter::ToNumber(str, -1) == wxFONTSTYLE_ITALIC)) { style = wxFONTSTYLE_ITALIC; - } else if((str == wxT("slant")) || (wxCrafter::ToNumber(str, -1) == wxFONTSTYLE_SLANT)) { + } else if ((str == wxT("slant")) || (wxCrafter::ToNumber(str, -1) == wxFONTSTYLE_SLANT)) { style = wxFONTSTYLE_SLANT; } @@ -136,9 +136,9 @@ wxFontStyle StringToFontStyle(const wxString& str) wxFontWeight StringToFontWeight(const wxString& str) { wxFontWeight weight = wxFONTWEIGHT_NORMAL; - if((str == wxT("bold")) || (wxCrafter::ToNumber(str, -1) == wxFONTWEIGHT_BOLD)) { + if ((str == wxT("bold")) || (wxCrafter::ToNumber(str, -1) == wxFONTWEIGHT_BOLD)) { weight = wxFONTWEIGHT_BOLD; - } else if((str == wxT("light")) || (wxCrafter::ToNumber(str, -1) == wxFONTWEIGHT_LIGHT)) { + } else if ((str == wxT("light")) || (wxCrafter::ToNumber(str, -1) == wxFONTWEIGHT_LIGHT)) { weight = wxFONTWEIGHT_LIGHT; } @@ -193,31 +193,31 @@ wxString wxCrafter::GetSizeAsDlgUnits(const wxSize& size, const wxString& parent return str; } -wxFileName wxCrafter::LoadXRC(const wxString& xrcString, const wxString& filename, wxString& caption, wxString& style, - wxString& bmppath) +wxFileName wxCrafter::LoadXRC( + const wxString& xrcString, const wxString& filename, wxString& caption, wxString& style, wxString& bmppath) { { wxXmlDocument doc; wxStringInputStream inStr(xrcString); - if(doc.Load(inStr)) { + if (doc.Load(inStr)) { wxXmlNode* root = doc.GetRoot(); - if(root) { + if (root) { wxXmlNode* child = root->GetChildren(); - while(child) { - if(child->GetName() == "object" && child->GetAttribute("name") == "PreviewPanel") { + while (child) { + if (child->GetName() == "object" && child->GetAttribute("name") == "PreviewPanel") { // we got the main view wxXmlNode* captionNode = XmlUtils::FindFirstByTagName(child, "caption-title"); - if(captionNode) { + if (captionNode) { caption = captionNode->GetNodeContent(); } wxXmlNode* tlwStyle = XmlUtils::FindFirstByTagName(child, "tlw-style"); - if(tlwStyle) { + if (tlwStyle) { style = tlwStyle->GetNodeContent(); } wxXmlNode* tlwIcon = XmlUtils::FindFirstByTagName(child, "tlw-icon"); - if(tlwIcon) { + if (tlwIcon) { bmppath = tlwIcon->GetNodeContent(); } @@ -235,7 +235,7 @@ wxFileName wxCrafter::LoadXRC(const wxString& xrcString, const wxString& filenam wxStringOutputStream str(&fmtStr); wxStringInputStream inStr(xrcString); - if(!doc.Load(inStr)) { + if (!doc.Load(inStr)) { ::wxMessageBox(_("Invalid XRC! could not save DesignerPreview.xrc"), wxT("wxCrafter"), wxOK | wxICON_WARNING); return wxFileName(GetUserDataDir(), filename); } @@ -245,7 +245,7 @@ wxFileName wxCrafter::LoadXRC(const wxString& xrcString, const wxString& filenam #endif wxFFile fp(wxFileName(GetUserDataDir(), filename).GetFullPath(), wxT("w+b")); - if(fp.IsOpened()) { + if (fp.IsOpened()) { fp.Write(fmtStr, wxConvUTF8); fp.Close(); } @@ -258,7 +258,7 @@ wxFileName wxCrafter::LoadXRC(const wxString& xrcString, const wxString& filenam int wxCrafter::ToNumber(const wxString& str, int defaultValue) { long num(defaultValue); - if(str.ToLong(&num)) { + if (str.ToLong(&num)) { return num; } else { return defaultValue; @@ -278,11 +278,11 @@ wxArrayString wxCrafter::SplitByString(const wxString& str, const wxString& deli wxString tmp = str; int where = tmp.Find(delim); - while(where != wxNOT_FOUND) { + while (where != wxNOT_FOUND) { wxString token = tmp.Mid(0, where); - if(!keepEmptyLines) { + if (!keepEmptyLines) { token.Trim().Trim(false); - if(!token.IsEmpty()) + if (!token.IsEmpty()) arr.Add(token); } else { arr.Add(token); @@ -292,7 +292,7 @@ wxArrayString wxCrafter::SplitByString(const wxString& str, const wxString& deli where = tmp.Find(delim); } - if(tmp.IsEmpty() == false) + if (tmp.IsEmpty() == false) arr.Add(tmp); return arr; @@ -301,13 +301,13 @@ wxArrayString wxCrafter::SplitByString(const wxString& str, const wxString& deli wxString wxCrafter::Join(const wxArrayString& arr, const wxString& delim) { wxString res; - for(size_t i = 0; i < arr.GetCount(); i++) { + for (size_t i = 0; i < arr.GetCount(); i++) { wxString item = arr.Item(i); item.Trim().Trim(false); res << item << delim; } - if(res.IsEmpty() == false) { + if (res.IsEmpty() == false) { res.RemoveLast(delim.Len()); } return res; @@ -324,13 +324,13 @@ wxString wxCrafter::CamelCase(const wxString& str) wxString tmpstr = str; // Convert CamelCase to '_' separated string static wxRegEx re(wxT("([a-z])([A-Z])"), re_flags); - while(re.IsValid() && re.Matches(tmpstr)) { + while (re.IsValid() && re.Matches(tmpstr)) { re.Replace(&tmpstr, wxT("\\1_\\2")); } wxArrayString parts = wxCrafter::Split(tmpstr, wxT("_")); wxString fooname; - for(size_t i = 0; i < parts.GetCount(); i++) { + for (size_t i = 0; i < parts.GetCount(); i++) { parts.Item(i).MakeLower(); wxString firstChar = parts.Item(i).at(0); firstChar.MakeUpper(); @@ -340,31 +340,31 @@ wxString wxCrafter::CamelCase(const wxString& str) return fooname; } -static const wxArrayString s_colorNames = StdToWX::ToArrayString({ "AppWorkspace", - "ActiveBorder", - "ActiveCaption", - "ButtonFace", - "ButtonHighlight", - "ButtonShadow", - "ButtonText", - "CaptionText", - "ControlDark", - "ControlLight", - "Desktop", - "GrayText", - "Highlight", - "HighlightText", - "InactiveBorder", - "InactiveCaption", - "InactiveCaptionText", - "Menu", - "Scrollbar", - "Tooltip", - "TooltipText", - "Window", - "WindowFrame", - "WindowText", - "Custom" }); +static const wxArrayString s_colorNames = StdToWX::ToArrayString({"AppWorkspace", + "ActiveBorder", + "ActiveCaption", + "ButtonFace", + "ButtonHighlight", + "ButtonShadow", + "ButtonText", + "CaptionText", + "ControlDark", + "ControlLight", + "Desktop", + "GrayText", + "Highlight", + "HighlightText", + "InactiveBorder", + "InactiveCaption", + "InactiveCaptionText", + "Menu", + "Scrollbar", + "Tooltip", + "TooltipText", + "Window", + "WindowFrame", + "WindowText", + "Custom"}); static const wxArrayString s_colorSysNames = StdToWX::ToArrayString({ "wxSYS_COLOUR_APPWORKSPACE", @@ -396,7 +396,7 @@ static wxArrayInt s_colorIdx; static void init_color_indexes() { - if(s_colorIdx.IsEmpty()) { + if (s_colorIdx.IsEmpty()) { s_colorIdx.Add(wxSYS_COLOUR_APPWORKSPACE); s_colorIdx.Add(wxSYS_COLOUR_ACTIVEBORDER); s_colorIdx.Add(wxSYS_COLOUR_ACTIVECAPTION); @@ -429,17 +429,17 @@ wxString wxCrafter::ColourToCpp(const wxString& guiname) { init_color_indexes(); wxString colorname = guiname; - if(colorname == wxT("") || guiname.IsEmpty()) { + if (colorname == wxT("") || guiname.IsEmpty()) { return wxT(""); - } else if(colorname.StartsWith(wxT("("))) { + } else if (colorname.StartsWith(wxT("("))) { // Custom color wxString code; colorname.Prepend("rgb"); code << wxT("wxColour(") << WXT(colorname) << wxT(")"); return code; - } else if(colorname.StartsWith(wxT("#"))) { + } else if (colorname.StartsWith(wxT("#"))) { // Custom color wxString code; code << wxT("wxColour(") << WXT(colorname) << wxT(")"); @@ -448,7 +448,7 @@ wxString wxCrafter::ColourToCpp(const wxString& guiname) } else { int guinameidx = s_colorNames.Index(guiname); wxString code; - if(guinameidx != wxNOT_FOUND) { + if (guinameidx != wxNOT_FOUND) { code << wxT("wxSystemSettings::GetColour(") << s_colorSysNames.Item(guinameidx) << wxT(")"); } return code; @@ -473,11 +473,11 @@ wxString wxCrafter::ESCAPE(const wxString& s) wxString wxCrafter::UNDERSCORE(const wxString& s) { wxString str; - if(s.empty()) { + if (s.empty()) { // Don't annoy translators by giving them "" to translate return WXT(s); } else { - if(!wxcProjectMetadata::Get().IsUseUnderscoreMacro()) { + if (!wxcProjectMetadata::Get().IsUseUnderscoreMacro()) { // Use the wxT() macro str << "wxT(\"" << ESCAPE(s) << "\")"; } else { @@ -497,7 +497,7 @@ wxString wxCrafter::WXT(const wxString& s) wxString wxCrafter::FontToString(const wxFont& font) { wxString str; - if(!font.IsOk()) { + if (!font.IsOk()) { return wxEmptyString; } @@ -507,10 +507,10 @@ wxString wxCrafter::FontToString(const wxFont& font) str << font.GetPointSize() << wxT(","); // style - if(font.GetStyle() == wxFONTSTYLE_ITALIC) { + if (font.GetStyle() == wxFONTSTYLE_ITALIC) { str << wxT("italic, "); - } else if(font.GetStyle() == wxFONTSTYLE_SLANT) { + } else if (font.GetStyle() == wxFONTSTYLE_SLANT) { str << wxT("slant, "); } else { @@ -518,10 +518,10 @@ wxString wxCrafter::FontToString(const wxFont& font) } // weight - if(font.GetWeight() == wxFONTWEIGHT_LIGHT) { + if (font.GetWeight() == wxFONTWEIGHT_LIGHT) { str << wxT("light, "); - } else if(font.GetWeight() == wxFONTWEIGHT_BOLD) { + } else if (font.GetWeight() == wxFONTWEIGHT_BOLD) { str << wxT("bold, "); } else { @@ -529,22 +529,22 @@ wxString wxCrafter::FontToString(const wxFont& font) } // family - if(font.GetFamily() == wxFONTFAMILY_DECORATIVE) { + if (font.GetFamily() == wxFONTFAMILY_DECORATIVE) { str << wxT("decorative, "); - } else if(font.GetFamily() == wxFONTFAMILY_ROMAN) { + } else if (font.GetFamily() == wxFONTFAMILY_ROMAN) { str << wxT("roman, "); - } else if(font.GetFamily() == wxFONTFAMILY_SCRIPT) { + } else if (font.GetFamily() == wxFONTFAMILY_SCRIPT) { str << wxT("script, "); - } else if(font.GetFamily() == wxFONTFAMILY_SWISS) { + } else if (font.GetFamily() == wxFONTFAMILY_SWISS) { str << wxT("swiss, "); - } else if(font.GetFamily() == wxFONTFAMILY_MODERN) { + } else if (font.GetFamily() == wxFONTFAMILY_MODERN) { str << wxT("modern, "); - } else if(font.GetFamily() == wxFONTFAMILY_TELETYPE) { + } else if (font.GetFamily() == wxFONTFAMILY_TELETYPE) { str << wxT("teletype, "); } else { @@ -562,13 +562,13 @@ wxFont wxCrafter::StringToFont(const wxString& font) { // is this a system font? wxFont f = GetSystemFont(font); - if(f.IsOk() == true) { + if (f.IsOk() == true) { return f; } // Some imported fonts may be missing e.g. a 'face', so use wxTOKEN_RET_EMPTY_ALL wxArrayString parts = Split(font, wxT(","), wxTOKEN_RET_EMPTY_ALL); - if(parts.GetCount() != 6) { + if (parts.GetCount() != 6) { return wxNullFont; } @@ -579,7 +579,7 @@ wxFont wxCrafter::StringToFont(const wxString& font) wxFontFamily family = StringToFontFamily(parts.Item(3)); bool underlined = false; - if(parts.Item(4) == wxT("1")) + if (parts.Item(4) == wxT("1")) underlined = true; wxString face = parts.Item(5); @@ -592,15 +592,15 @@ bool wxCrafter::IsSystemFont(const wxString& font) { return GetSystemFont(font). wxString wxCrafter::FontToXRC(const wxString& font) { wxString xrc; - if(IsSystemFont(font)) { + if (IsSystemFont(font)) { wxFont f = GetSystemFont(font); wxArrayString parts = Split(font, wxT(",")); xrc << wxT("") << parts.Item(0) << wxT(""); - if(parts.GetCount() > 1) + if (parts.GetCount() > 1) xrc << wxT(""); - if(parts.GetCount() > 2) + if (parts.GetCount() > 2) xrc << wxT("") << parts.Item(2) << wxT(""); xrc << wxT("") << (f.GetUnderlined() ? wxT("1") : wxT("0")) << wxT(""); @@ -608,7 +608,7 @@ wxString wxCrafter::FontToXRC(const wxString& font) } else { wxArrayString parts = Split(font, wxT(",")); - if(parts.GetCount() == 6) { + if (parts.GetCount() == 6) { xrc << wxT("") << parts.Item(0) << wxT(""); xrc << wxT(""); xrc << wxT("") << parts.Item(2) << wxT(""); @@ -627,52 +627,52 @@ wxString wxCrafter::XRCToFontstring(const wxXmlNode* node) // or else anything between 1 and 6 of: size,style,weight,family,underlined,face // So start with creating a basic font, either standard or otherwise wxXmlNode* sysfontnode = XmlUtils::FindFirstByTagName(node, wxT("sysfont")); - if(sysfontnode) { + if (sysfontnode) { // There's a system font requested font = StringToFont(sysfontnode->GetNodeContent()); } - if(!font.IsOk()) { + if (!font.IsOk()) { // No preferred font, so use the standard one font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT); - if(!font.IsOk()) { + if (!font.IsOk()) { return ""; } } // Now override with any other info wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("size")); - if(propertynode) { + if (propertynode) { wxString content = propertynode->GetNodeContent(); // The XRC docs say this should be a wxSize for SetPixelSize() // but wxFB's XRC output contains a point setting - if(content.Contains(",")) { + if (content.Contains(",")) { font.SetPixelSize(DecodeSize(content)); } else { int pt = ToNumber(content, -1); - if(pt >= 0) { + if (pt >= 0) { font.SetPointSize(pt); } } } propertynode = XmlUtils::FindFirstByTagName(node, wxT("style")); - if(propertynode) { + if (propertynode) { font.SetStyle(StringToFontStyle(propertynode->GetNodeContent())); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("weight")); - if(propertynode) { + if (propertynode) { font.SetWeight(StringToFontWeight(propertynode->GetNodeContent())); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("family")); - if(propertynode) { + if (propertynode) { font.SetFamily(StringToFontFamily(propertynode->GetNodeContent())); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("underlined")); - if(propertynode) { + if (propertynode) { font.SetUnderlined(propertynode->GetNodeContent() == "1"); } propertynode = XmlUtils::FindFirstByTagName(node, wxT("face")); - if(propertynode) { + if (propertynode) { font.SetFaceName(propertynode->GetNodeContent()); } @@ -682,7 +682,7 @@ wxString wxCrafter::XRCToFontstring(const wxXmlNode* node) wxString wxCrafter::FBToFontstring(const wxString& FBstr) { wxString str; - if(FBstr.empty()) { + if (FBstr.empty()) { return str; } @@ -691,7 +691,7 @@ wxString wxCrafter::FBToFontstring(const wxString& FBstr) // We want: size, style, weight, family, underlined, face // The wxFB default font is also faceless, so we must use wxTOKEN_RET_EMPTY_ALL here wxArrayString arr = Split(FBstr, ",", wxTOKEN_RET_EMPTY_ALL); - if(arr.GetCount() < 6) { + if (arr.GetCount() < 6) { return str; } wxString face = arr.Item(0), sz = arr.Item(3); @@ -699,7 +699,7 @@ wxString wxCrafter::FBToFontstring(const wxString& FBstr) // This is the same as (the valid) wxFONTSIZE_SMALL but, at least on my system, results in a size of 12 pts which is // too large so use the system font size instead static int defaultfontsize = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT).GetPointSize(); - if(sz == "-1") { + if (sz == "-1") { sz = wxString::Format("%d", defaultfontsize); } @@ -707,7 +707,7 @@ wxString wxCrafter::FBToFontstring(const wxString& FBstr) arr.Item(0) = sz; arr.Add(face); wxFont font = wxCrafter::StringToFont(Join(arr, ",")); - if(font.IsOk()) { + if (font.IsOk()) { str = wxCrafter::FontToString(font); } @@ -716,16 +716,16 @@ wxString wxCrafter::FBToFontstring(const wxString& FBstr) wxString wxCrafter::FontToCpp(const wxString& font, const wxString& fontMemberName) { - if(font.IsEmpty()) + if (font.IsEmpty()) return wxT("wxNullFont"); wxString code; - if(IsSystemFont(font)) { + if (IsSystemFont(font)) { wxFont f = GetSystemFont(font); wxArrayString parts = Split(font, wxT(",")); - if(parts.Item(0) == "wxSYS_ANSI_FIXED_FONT") { + if (parts.Item(0) == "wxSYS_ANSI_FIXED_FONT") { code << "#ifdef __WXMSW__\n"; code << "// To get the newer version of the font on MSW, we use font wxSYS_DEFAULT_GUI_FONT with family " @@ -744,20 +744,20 @@ wxString wxCrafter::FontToCpp(const wxString& font, const wxString& fontMemberNa << wxT(");\n"); } - if(f.GetStyle() == wxFONTSTYLE_ITALIC) + if (f.GetStyle() == wxFONTSTYLE_ITALIC) code << fontMemberName << wxT(".SetStyle(wxFONTSTYLE_ITALIC);\n"); - if(f.GetUnderlined()) + if (f.GetUnderlined()) code << fontMemberName << wxT(".SetUnderlined(true);\n"); - if(f.GetWeight() == wxFONTWEIGHT_BOLD) + if (f.GetWeight() == wxFONTWEIGHT_BOLD) code << fontMemberName << wxT(".SetWeight(wxFONTWEIGHT_BOLD);\n"); return code; } else { // Custom font wxArrayString parts = Split(font, wxT(",")); - if(parts.GetCount() != 6) { + if (parts.GetCount() != 6) { return wxT("wxNullFont"); } @@ -769,40 +769,40 @@ wxString wxCrafter::FontToCpp(const wxString& font, const wxString& fontMemberNa wxString underlined = wxT("false"); wxString face = parts.Item(5); - if(parts.Item(1) == wxT("italic")) { + if (parts.Item(1) == wxT("italic")) { style = wxT("wxFONTSTYLE_ITALIC"); - } else if(parts.Item(1) == wxT("slant")) { + } else if (parts.Item(1) == wxT("slant")) { style = wxT("wxFONTSTYLE_SLANT"); } - if(parts.Item(2) == wxT("bold")) { + if (parts.Item(2) == wxT("bold")) { weight = wxT("wxFONTWEIGHT_BOLD"); - } else if(parts.Item(2) == wxT("light")) { + } else if (parts.Item(2) == wxT("light")) { weight = wxT("wxFONTWEIGHT_LIGHT"); } // family - if(parts.Item(3) == wxT("decorative")) + if (parts.Item(3) == wxT("decorative")) family = wxT("wxFONTFAMILY_DECORATIVE"); - if(parts.Item(3) == wxT("roman")) + if (parts.Item(3) == wxT("roman")) family = wxT("wxFONTFAMILY_ROMAN"); - if(parts.Item(3) == wxT("script")) + if (parts.Item(3) == wxT("script")) family = wxT("wxFONTFAMILY_SCRIPT"); - if(parts.Item(3) == wxT("swiss")) + if (parts.Item(3) == wxT("swiss")) family = wxT("wxFONTFAMILY_SWISS"); - if(parts.Item(3) == wxT("modern")) + if (parts.Item(3) == wxT("modern")) family = wxT("wxFONTFAMILY_MODERN"); - if(parts.Item(3) == wxT("teletype")) + if (parts.Item(3) == wxT("teletype")) family = wxT("wxFONTFAMILY_TELETYPE"); - if(parts.Item(4) == wxT("1")) + if (parts.Item(4) == wxT("1")) underlined = wxT("true"); else underlined = wxT("false"); @@ -817,7 +817,7 @@ wxString wxCrafter::XMLEncode(const wxString& text, bool decode /*=false*/) { wxString str = text; static std::map s_xmlEntities; - if(s_xmlEntities.empty()) { + if (s_xmlEntities.empty()) { s_xmlEntities[wxT("\"")] = wxT("""); s_xmlEntities[wxT("'")] = wxT("'"); s_xmlEntities[wxT("<")] = wxT("<"); @@ -838,7 +838,7 @@ wxString wxCrafter::XMLEncode(const wxString& text, bool decode /*=false*/) wxString wxCrafter::ToBool(const wxString& text) { - if(text == wxT("1")) + if (text == wxT("1")) return wxT("true"); else return wxT("false"); @@ -855,8 +855,8 @@ wxString wxCrafter::CDATA(const wxString& text) wxArrayString wxCrafter::MakeUnique(const wxArrayString& arr) { wxArrayString res; - for(size_t i = 0; i < arr.GetCount(); i++) { - if(res.Index(arr.Item(i)) == wxNOT_FOUND) { + for (size_t i = 0; i < arr.GetCount(); i++) { + if (res.Index(arr.Item(i)) == wxNOT_FOUND) { res.Add(arr.Item(i)); } } @@ -865,12 +865,12 @@ wxArrayString wxCrafter::MakeUnique(const wxArrayString& arr) void wxCrafter::WriteFile(const wxFileName& filename, const wxString& content, bool overwriteContent) { - if(!overwriteContent && filename.FileExists()) { + if (!overwriteContent && filename.FileExists()) { return; } wxFFile fp(filename.GetFullPath(), wxT("w+b")); - if(fp.IsOpened()) { + if (fp.IsOpened()) { fp.Write(content, wxConvUTF8); fp.Close(); } @@ -878,7 +878,7 @@ void wxCrafter::WriteFile(const wxFileName& filename, const wxString& content, b bool wxCrafter::IsTheSame(const wxFileName& f1, const wxFileName& f2) { - if(f1.FileExists() == false || f2.FileExists() == false) + if (f1.FileExists() == false || f2.FileExists() == false) return false; wxString fileOneContent, fileTwoContent; @@ -886,10 +886,10 @@ bool wxCrafter::IsTheSame(const wxFileName& f1, const wxFileName& f2) wxFFile fileOne(f1.GetFullPath(), wxT("r+b")); wxFFile fileTwo(f2.GetFullPath(), wxT("r+b")); - if(fileOne.IsOpened() && fileTwo.IsOpened()) { + if (fileOne.IsOpened() && fileTwo.IsOpened()) { // Compare the content - if(fileOne.ReadAll(&fileOneContent, wxConvUTF8) && fileTwo.ReadAll(&fileTwoContent, wxConvUTF8) && - fileOneContent == fileTwoContent) { + if (fileOne.ReadAll(&fileOneContent, wxConvUTF8) && fileTwo.ReadAll(&fileTwoContent, wxConvUTF8) && + fileOneContent == fileTwoContent) { return true; } } @@ -898,16 +898,16 @@ bool wxCrafter::IsTheSame(const wxFileName& f1, const wxFileName& f2) bool wxCrafter::IsTheSame(const wxString& fileContent, const wxFileName& f) { - if(!f.FileExists()) + if (!f.FileExists()) return false; wxString fileOneContent; wxFFile fileOne(f.GetFullPath(), wxT("r+b")); - if(fileOne.IsOpened()) { + if (fileOne.IsOpened()) { // Compare the content - if(fileOne.ReadAll(&fileOneContent, wxConvUTF8) && fileOneContent == fileContent) { + if (fileOne.ReadAll(&fileOneContent, wxConvUTF8) && fileOneContent == fileContent) { return true; } } @@ -920,7 +920,7 @@ float wxCrafter::ToFloat(const wxString& str, float defaultValue) /// Use ToCDouble to avoid cases (e.g. German locale) /// where 0.5 is actually 0,5 - which obviously breaks compilation - if(str.ToCDouble(&v)) { + if (str.ToCDouble(&v)) { return v; } else { return defaultValue; @@ -943,7 +943,7 @@ wxArrayString wxCrafter::GetToolTypes(bool forToolbar) kinds.Add(ITEM_CHECK); kinds.Add(ITEM_RADIO); kinds.Add(ITEM_SEPARATOR); - if(forToolbar) { + if (forToolbar) { kinds.Add(ITEM_DROPDOWN); } return kinds; @@ -951,22 +951,22 @@ wxArrayString wxCrafter::GetToolTypes(bool forToolbar) wxCrafter::TOOL_TYPE wxCrafter::GetToolType(const wxString& name) { - if(name == ITEM_NORMAL) { + if (name == ITEM_NORMAL) { return TOOL_TYPE_NORMAL; - } else if(name == ITEM_CHECK) { + } else if (name == ITEM_CHECK) { return TOOL_TYPE_CHECK; - } else if(name == ITEM_RADIO) { + } else if (name == ITEM_RADIO) { return TOOL_TYPE_RADIO; - } else if(name == ITEM_SEPARATOR) { + } else if (name == ITEM_SEPARATOR) { return TOOL_TYPE_SEPARATOR; - } else if(name == ITEM_SPACE) { + } else if (name == ITEM_SPACE) { return TOOL_TYPE_SPACE; - } else if(name == ITEM_DROPDOWN) { + } else if (name == ITEM_DROPDOWN) { return TOOL_TYPE_DROPDOWN; /* } else if(name == ITEM_AUILABEL) { This, and those of the other aui oddities, aren't needed atm @@ -979,19 +979,19 @@ wxCrafter::TOOL_TYPE wxCrafter::GetToolType(const wxString& name) wxString wxCrafter::ToolTypeToWX(TOOL_TYPE type) { - if(type == TOOL_TYPE_NORMAL) { + if (type == TOOL_TYPE_NORMAL) { return wxT("wxITEM_NORMAL"); - } else if(type == TOOL_TYPE_CHECK) { + } else if (type == TOOL_TYPE_CHECK) { return wxT("wxITEM_CHECK"); - } else if(type == TOOL_TYPE_RADIO) { + } else if (type == TOOL_TYPE_RADIO) { return wxT("wxITEM_RADIO"); - } else if(type == TOOL_TYPE_SEPARATOR) { + } else if (type == TOOL_TYPE_SEPARATOR) { return wxT("wxITEM_SEPARATOR"); - } else if(type == TOOL_TYPE_DROPDOWN) { + } else if (type == TOOL_TYPE_DROPDOWN) { return wxT("wxITEM_DROPDOWN"); } else { @@ -1007,7 +1007,7 @@ wxString wxCrafter::GetUserDataDir() #endif dir.AppendDir(wxT("wxcrafter")); static bool once = true; - if(once) { + if (once) { dir.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); once = false; } @@ -1016,9 +1016,9 @@ wxString wxCrafter::GetUserDataDir() void wxCrafter::SetStatusMessage(const wxString& msg) { - if(TopFrame()) { + if (TopFrame()) { MainFrame* frame = dynamic_cast(TopFrame()); - if(frame) { + if (frame) { frame->SetStatusMessage(msg); } } @@ -1033,7 +1033,7 @@ wxString wxCrafter::GetConfigFile() wxArrayString wxCrafter::Split(const wxString& str, const wxString& delim, wxStringTokenizerMode mode) { wxArrayString arr = wxStringTokenize(str, delim, mode); - for(size_t i = 0; i < arr.GetCount(); i++) { + for (size_t i = 0; i < arr.GetCount(); i++) { arr.Item(i).Trim().Trim(false); } return arr; @@ -1043,10 +1043,10 @@ int wxCrafter::GetColourSysIndex(const wxString& name) { init_color_indexes(); int where = s_colorNames.Index(name); - if(where == wxNOT_FOUND) { + if (where == wxNOT_FOUND) { // try the system colours where = s_colorSysNames.Index(name); - if(where != wxNOT_FOUND) { + if (where != wxNOT_FOUND) { return s_colorIdx.Item(where); } } else { @@ -1058,17 +1058,17 @@ int wxCrafter::GetColourSysIndex(const wxString& name) wxString wxCrafter::GetColourForXRC(const wxString& name) { init_color_indexes(); - if(name == "" || name.IsEmpty()) + if (name == "" || name.IsEmpty()) return wxEmptyString; - if(s_colorSysNames.Index(name) != wxNOT_FOUND) + if (s_colorSysNames.Index(name) != wxNOT_FOUND) return name; int colorIdx = s_colorNames.Index(name); - if(colorIdx == wxNOT_FOUND) { + if (colorIdx == wxNOT_FOUND) { wxString colname = name; colname.Trim().Trim(false); - if(colname.StartsWith("(")) { + if (colname.StartsWith("(")) { colname.Prepend("rgb"); } @@ -1083,22 +1083,22 @@ wxString wxCrafter::GetColourForXRC(const wxString& name) wxColour wxCrafter::NameToColour(const wxString& name) { int sysidx = GetColourSysIndex(name); - if(sysidx != wxNOT_FOUND) + if (sysidx != wxNOT_FOUND) return wxSystemSettings::GetColour((wxSystemColour)sysidx); // not a system colour name nor PG name, a custom color then wxString colname = name; colname.Trim().Trim(false); - if(colname.StartsWith("#")) { + if (colname.StartsWith("#")) { // HTML format wxColour col(colname); return col; - } else if(colname.StartsWith("rgb")) { + } else if (colname.StartsWith("rgb")) { return wxColour(colname); - } else if(colname.StartsWith("(")) { + } else if (colname.StartsWith("(")) { return wxColour(colname.Prepend("rgb")); } return *wxWHITE; @@ -1109,7 +1109,7 @@ wxString wxCrafter::ValueToColourString(const wxString& value) wxString str(value); // Value might be any of the ways of specifying colour, // but it may also be imported from wxFB as rgb() but without the syntax - if((value.Left(1) != "(") && (value.BeforeLast(',') != "")) { + if ((value.Left(1) != "(") && (value.BeforeLast(',') != "")) { str = '(' + value + ')'; } @@ -1163,10 +1163,10 @@ wxString wxCrafter::AddQuotes(const wxString& str) { wxString s = str; s.Trim().Trim(false); - if(!s.StartsWith('"')) + if (!s.StartsWith('"')) s.Prepend('"'); - if(!s.EndsWith('"')) + if (!s.EndsWith('"')) s.Append('"'); return s; @@ -1174,7 +1174,7 @@ wxString wxCrafter::AddQuotes(const wxString& str) void wxCrafter::MakeAbsToProject(wxFileName& fn) { - if(fn.IsRelative()) { + if (fn.IsRelative()) { fn.MakeAbsolute(wxcProjectMetadata::Get().GetProjectPath()); } } @@ -1182,7 +1182,7 @@ void wxCrafter::MakeAbsToProject(wxFileName& fn) int wxCrafter::ToAligment(const wxString& aligment) { static std::map s_stringToAlignment; - if(s_stringToAlignment.empty()) { + if (s_stringToAlignment.empty()) { s_stringToAlignment.insert(std::make_pair("wxALIGN_NOT", wxALIGN_NOT)); s_stringToAlignment.insert(std::make_pair("wxALIGN_CENTER_HORIZONTAL", wxALIGN_CENTER_HORIZONTAL)); s_stringToAlignment.insert(std::make_pair("wxALIGN_CENTRE_HORIZONTAL", wxALIGN_CENTRE_HORIZONTAL)); @@ -1198,7 +1198,7 @@ int wxCrafter::ToAligment(const wxString& aligment) s_stringToAlignment.insert(std::make_pair("wxALIGN_INVALID", wxALIGN_INVALID)); } - if(s_stringToAlignment.count(aligment) == 0) + if (s_stringToAlignment.count(aligment) == 0) return wxALIGN_NOT; return s_stringToAlignment.find(aligment)->second; } @@ -1209,7 +1209,7 @@ int wxCrafter::ColumnFlagsFromString(const wxString& col_flags) { int flags = 0; static std::map s_stringToFlag; - if(s_stringToFlag.empty()) { + if (s_stringToFlag.empty()) { s_stringToFlag.insert(std::make_pair("wxCOL_RESIZABLE", (int)wxCOL_RESIZABLE)); s_stringToFlag.insert(std::make_pair("wxCOL_SORTABLE", (int)wxCOL_SORTABLE)); s_stringToFlag.insert(std::make_pair("wxCOL_REORDERABLE", (int)wxCOL_REORDERABLE)); @@ -1218,10 +1218,10 @@ int wxCrafter::ColumnFlagsFromString(const wxString& col_flags) } wxArrayString flagsStringArr = ::wxStringTokenize(col_flags, "|", wxTOKEN_STRTOK); - for(size_t i = 0; i < flagsStringArr.GetCount(); ++i) { + for (size_t i = 0; i < flagsStringArr.GetCount(); ++i) { wxString flagString = flagsStringArr.Item(i).Trim(); ; - if(s_stringToFlag.count(flagString)) { + if (s_stringToFlag.count(flagString)) { flags |= s_stringToFlag.find(flagString)->second; } } @@ -1232,74 +1232,74 @@ bool wxCrafter::IsArtProviderBitmap(const wxString& bmpString, wxString& artId, { static wxArrayString arr; if (arr.IsEmpty()) { - arr = StdToWX::ToArrayString({ wxT("wxART_ERROR"), - wxT("wxART_QUESTION"), - wxT("wxART_WARNING"), - wxT("wxART_INFORMATION"), - wxT("wxART_ADD_BOOKMARK"), - wxT("wxART_DEL_BOOKMARK"), - wxT("wxART_HELP_SIDE_PANEL"), - wxT("wxART_HELP_SETTINGS"), - wxT("wxART_HELP_BOOK"), - wxT("wxART_HELP_FOLDER"), - wxT("wxART_HELP_PAGE"), - wxT("wxART_GO_BACK"), - wxT("wxART_GO_FORWARD"), - wxT("wxART_GO_UP"), - wxT("wxART_GO_DOWN"), - wxT("wxART_GO_TO_PARENT"), - wxT("wxART_GO_HOME"), - wxT("wxART_GOTO_FIRST"), - wxT("wxART_GOTO_LAST"), - wxT("wxART_PRINT"), - wxT("wxART_HELP"), - wxT("wxART_TIP"), - wxT("wxART_REPORT_VIEW"), - wxT("wxART_LIST_VIEW"), - wxT("wxART_NEW_DIR"), - wxT("wxART_FOLDER"), - wxT("wxART_FOLDER_OPEN"), - wxT("wxART_GO_DIR_UP"), - wxT("wxART_EXECUTABLE_FILE"), - wxT("wxART_NORMAL_FILE"), - wxT("wxART_TICK_MARK"), - wxT("wxART_CROSS_MARK"), - wxT("wxART_MISSING_IMAGE"), - wxT("wxART_NEW"), - wxT("wxART_FILE_OPEN"), - wxT("wxART_FILE_SAVE"), - wxT("wxART_FILE_SAVE_AS"), - wxT("wxART_DELETE"), - wxT("wxART_COPY"), - wxT("wxART_CUT"), - wxT("wxART_PASTE"), - wxT("wxART_UNDO"), - wxT("wxART_REDO"), - wxT("wxART_PLUS"), - wxT("wxART_MINUS"), - wxT("wxART_CLOSE"), - wxT("wxART_QUIT"), - wxT("wxART_FIND"), - wxT("wxART_FIND_AND_REPLACE"), - wxT("wxART_HARDDISK"), - wxT("wxART_FLOPPY"), - wxT("wxART_CDROM"), - wxT("wxART_REMOVABLE") }); + arr = StdToWX::ToArrayString({wxT("wxART_ERROR"), + wxT("wxART_QUESTION"), + wxT("wxART_WARNING"), + wxT("wxART_INFORMATION"), + wxT("wxART_ADD_BOOKMARK"), + wxT("wxART_DEL_BOOKMARK"), + wxT("wxART_HELP_SIDE_PANEL"), + wxT("wxART_HELP_SETTINGS"), + wxT("wxART_HELP_BOOK"), + wxT("wxART_HELP_FOLDER"), + wxT("wxART_HELP_PAGE"), + wxT("wxART_GO_BACK"), + wxT("wxART_GO_FORWARD"), + wxT("wxART_GO_UP"), + wxT("wxART_GO_DOWN"), + wxT("wxART_GO_TO_PARENT"), + wxT("wxART_GO_HOME"), + wxT("wxART_GOTO_FIRST"), + wxT("wxART_GOTO_LAST"), + wxT("wxART_PRINT"), + wxT("wxART_HELP"), + wxT("wxART_TIP"), + wxT("wxART_REPORT_VIEW"), + wxT("wxART_LIST_VIEW"), + wxT("wxART_NEW_DIR"), + wxT("wxART_FOLDER"), + wxT("wxART_FOLDER_OPEN"), + wxT("wxART_GO_DIR_UP"), + wxT("wxART_EXECUTABLE_FILE"), + wxT("wxART_NORMAL_FILE"), + wxT("wxART_TICK_MARK"), + wxT("wxART_CROSS_MARK"), + wxT("wxART_MISSING_IMAGE"), + wxT("wxART_NEW"), + wxT("wxART_FILE_OPEN"), + wxT("wxART_FILE_SAVE"), + wxT("wxART_FILE_SAVE_AS"), + wxT("wxART_DELETE"), + wxT("wxART_COPY"), + wxT("wxART_CUT"), + wxT("wxART_PASTE"), + wxT("wxART_UNDO"), + wxT("wxART_REDO"), + wxT("wxART_PLUS"), + wxT("wxART_MINUS"), + wxT("wxART_CLOSE"), + wxT("wxART_QUIT"), + wxT("wxART_FIND"), + wxT("wxART_FIND_AND_REPLACE"), + wxT("wxART_HARDDISK"), + wxT("wxART_FLOPPY"), + wxT("wxART_CDROM"), + wxT("wxART_REMOVABLE")}); arr.Sort(); } // Art ID wxArrayString parts = ::wxStringTokenize(bmpString, ",", wxTOKEN_STRTOK); sizeHint = "wxDefaultSize"; - if(parts.GetCount() > 1) { + if (parts.GetCount() > 1) { artId = parts.Item(0); clientID = parts.Item(1); } - if(parts.GetCount() > 2) { + if (parts.GetCount() > 2) { sizeHint = parts.Item(2); } - if(arr.Index(artId) != wxNOT_FOUND) { + if (arr.Index(artId) != wxNOT_FOUND) { return true; } return false; @@ -1308,14 +1308,14 @@ bool wxCrafter::IsArtProviderBitmap(const wxString& bmpString, wxString& artId, wxString wxCrafter::MakeWxSizeStr(const wxString& size) { wxString strSize; - if(size.StartsWith("wxSize")) { + if (size.StartsWith("wxSize")) { return size; } - if(size.Contains(",")) { + if (size.Contains(",")) { strSize << "wxSize(" << size << ")"; - } else if(size == "wxDefaultSize") { + } else if (size == "wxDefaultSize") { strSize = "wxDefaultSize"; } else { @@ -1338,7 +1338,7 @@ wxShowEffect wxCrafter::ShowEffectFromString(const wxString& effect) m.insert(std::make_pair("wxSHOW_EFFECT_BLEND", wxSHOW_EFFECT_BLEND)); m.insert(std::make_pair("wxSHOW_EFFECT_EXPAND", wxSHOW_EFFECT_EXPAND)); - if(m.count(effect)) { + if (m.count(effect)) { return m.find(effect)->second; } @@ -1356,15 +1356,15 @@ void wxCrafter::NotifyFileSaved(const wxFileName& fn) void wxCrafter::WrapInIfBlock(const wxString& condname, wxString& codeblock) { - if(condname.IsEmpty()) + if (condname.IsEmpty()) return; wxString topBlock, bottomBlock; - if(codeblock.StartsWith("\n")) { + if (codeblock.StartsWith("\n")) { topBlock << "\n"; } - if(!codeblock.EndsWith("\n")) { + if (!codeblock.EndsWith("\n")) { bottomBlock << "\n"; } @@ -1378,7 +1378,7 @@ void wxCrafter::GetWorkspaceFiles(wxStringSet_t& files) { wxArrayString arrFiles; clCxxWorkspaceST::Get()->GetWorkspaceFiles(arrFiles); - for(size_t i = 0; i < arrFiles.GetCount(); ++i) { + for (size_t i = 0; i < arrFiles.GetCount(); ++i) { files.insert(arrFiles.Item(i)); } } @@ -1386,7 +1386,7 @@ void wxCrafter::GetWorkspaceFiles(wxStringSet_t& files) void wxCrafter::GetProjectFiles(const wxString& projectName, wxStringSet_t& files) { ProjectPtr p = clCxxWorkspaceST::Get()->GetProject(projectName); - if(!p) { + if (!p) { return; } const Project::FilesMap_t& filesMap = p->GetFiles(); @@ -1399,11 +1399,11 @@ void wxCrafter::GetProjectFiles(const wxString& projectName, wxStringSet_t& file void wxCrafter::FormatString(wxString& content, const wxFileName& filename) { #if !STANDALONE_BUILD - clSourceFormatEvent event{ wxEVT_FORMAT_STRING }; + clSourceFormatEvent event{wxEVT_FORMAT_STRING}; event.SetFileName(filename.GetFullPath()); event.SetInputString(content); EventNotifier::Get()->ProcessEvent(event); - if(!event.GetFormattedString().IsEmpty()) { + if (!event.GetFormattedString().IsEmpty()) { content = event.GetFormattedString(); } #endif @@ -1421,7 +1421,7 @@ void wxCrafter::FormatFile(const wxFileName& filename) static wxWindow* sTopFrame = NULL; wxWindow* wxCrafter::TopFrame() { - if(!sTopFrame) { + if (!sTopFrame) { return wxTheApp->GetTopWindow(); } return sTopFrame; diff --git a/wxcrafter/src/wxgui_helpers.h b/wxcrafter/src/wxgui_helpers.h index ac5bc025fd..7154e336aa 100644 --- a/wxcrafter/src/wxgui_helpers.h +++ b/wxcrafter/src/wxgui_helpers.h @@ -38,8 +38,8 @@ wxBorder GetControlBorder(); wxSize DecodeSize(const wxString& strSize); wxString EncodeSize(const wxSize& size); wxString GetSizeAsDlgUnits(const wxSize& size, const wxString& parent); -wxFileName LoadXRC(const wxString& xrcString, const wxString& filename, wxString& caption, wxString& style, - wxString& bmppath); +wxFileName +LoadXRC(const wxString& xrcString, const wxString& filename, wxString& caption, wxString& style, wxString& bmppath); int ToNumber(const wxString& str, int defaultValue); float ToFloat(const wxString& str, float defaultValue); wxString FloatToCString(float f); diff --git a/wxcrafter/src/wxguicraft_main_view.h b/wxcrafter/src/wxguicraft_main_view.h index 3048f93f57..a28f62f52a 100644 --- a/wxcrafter/src/wxguicraft_main_view.h +++ b/wxcrafter/src/wxguicraft_main_view.h @@ -57,7 +57,7 @@ class GUICraftItemData : public wxTreeItemData } ~GUICraftItemData() override { - if(m_wxcWidget) { + if (m_wxcWidget) { delete m_wxcWidget; m_wxcWidget = NULL; } @@ -129,16 +129,21 @@ class GUICraftMainPanel : public GUICraftMainPanelBase wxString GetStyleFromGuiID(int guiId) const; void Clear(); - void DoBuildTree(wxTreeItemId& itemToSelect, wxcWidget* wrapper, const wxTreeItemId& parent, - const wxTreeItemId& beforeItem = wxTreeItemId(), bool insertBefore = true); + void DoBuildTree(wxTreeItemId& itemToSelect, + wxcWidget* wrapper, + const wxTreeItemId& parent, + const wxTreeItemId& beforeItem = wxTreeItemId(), + bool insertBefore = true); void ExpandToItem(const wxString& name, wxTreeItemId& searchFromItem); // Find and select the named item, starting // looking from branch searchFromItem (in // case of a name-clash) wxTreeItemId DoFindBestSelection(const wxTreeItemId& item); bool DoUpdateNotebookSelection(const wxTreeItemId& item); - void DoInsertBefore(const wxTreeItemId& sourceItem, const wxTreeItemId& targetItem, - wxcWidget* sourceItemData = NULL, bool insertBefore = true); + void DoInsertBefore(const wxTreeItemId& sourceItem, + const wxTreeItemId& targetItem, + wxcWidget* sourceItemData = NULL, + bool insertBefore = true); void DoAppendItem(const wxTreeItemId& sourceItem, const wxTreeItemId& targetItem, wxcWidget* sourceItemData = NULL); void DoChangeOrInsertIntoSizer(int id); wxArrayString GetCustomControlsUsed() const; @@ -164,7 +169,10 @@ class GUICraftMainPanel : public GUICraftMainPanelBase wxcWidget* GetActiveWizardPage() const; wxcWidget* GetActiveTopLevelWin() const; wxcWidget* DoGetItemData(const wxTreeItemId& item) const; - bool GenerateCppOutput(wxString& cpp, wxString& header, wxArrayString& headers, wxStringMap_t& additionalFiles, + bool GenerateCppOutput(wxString& cpp, + wxString& header, + wxArrayString& headers, + wxStringMap_t& additionalFiles, size_t flags = 0) const; void GenerateXrcOutput(wxString& output, size_t flags = 0) const; /** diff --git a/wxcrafter/src/wxrc.cpp b/wxcrafter/src/wxrc.cpp index 03d5e624e8..23ce60a5af 100644 --- a/wxcrafter/src/wxrc.cpp +++ b/wxcrafter/src/wxrc.cpp @@ -34,7 +34,7 @@ void wxcXmlResourceCmp::CompileRes() wxRemoveFile(m_outputCppFile); - if(!m_retCode) { + if (!m_retCode) { MakePackageCPP(files); } DeleteTempFiles(files); @@ -51,10 +51,10 @@ wxString wxcXmlResourceCmp::GetInternalFileName(const wxString& name, const wxAr wxString s = wxFileNameFromPath(m_outputCppFile) + wxT("$") + name2; - if(wxFileExists(s) && flist.Index(s) == wxNOT_FOUND) { - for(int i = 0;; i++) { + if (wxFileExists(s) && flist.Index(s) == wxNOT_FOUND) { + for (int i = 0;; i++) { s.Printf(wxFileNameFromPath(m_outputCppFile) + wxT("$%03i-") + name2, i); - if(!wxFileExists(s) || flist.Index(s) != wxNOT_FOUND) + if (!wxFileExists(s) || flist.Index(s) != wxNOT_FOUND) break; } } @@ -66,7 +66,7 @@ wxArrayString wxcXmlResourceCmp::PrepareTempFiles() wxArrayString flist; wxXmlDocument doc; - if(!doc.Load(m_xrcFile)) { + if (!doc.Load(m_xrcFile)) { m_retCode = 1; return wxArrayString(); } @@ -88,27 +88,27 @@ static bool NodeContainsFilename(wxXmlNode* node) const wxString name = node->GetName(); // Any bitmaps (bitmap2 is used for disabled toolbar buttons): - if(name == wxT("bitmap") || name == wxT("bitmap2")) + if (name == wxT("bitmap") || name == wxT("bitmap2")) return true; - if(name == wxT("icon")) + if (name == wxT("icon")) return true; // wxBitmapButton: wxXmlNode* parent = node->GetParent(); - if(parent != NULL && parent->GetAttribute(wxT("class"), wxT("")) == wxT("wxBitmapButton") && - (name == wxT("focus") || name == wxT("disabled") || name == wxT("hover") || name == wxT("selected"))) + if (parent != NULL && parent->GetAttribute(wxT("class"), wxT("")) == wxT("wxBitmapButton") && + (name == wxT("focus") || name == wxT("disabled") || name == wxT("hover") || name == wxT("selected"))) return true; // wxBitmap or wxIcon toplevel resources: - if(name == wxT("object")) { + if (name == wxT("object")) { wxString klass = node->GetAttribute(wxT("class"), wxEmptyString); - if(klass == wxT("wxBitmap") || klass == wxT("wxIcon") || klass == wxT("data")) + if (klass == wxT("wxBitmap") || klass == wxT("wxIcon") || klass == wxT("data")) return true; } // URLs in wxHtmlWindow: - if(name == wxT("url") && parent != NULL && parent->GetAttribute(wxT("class"), wxT("")) == wxT("wxHtmlWindow")) { + if (name == wxT("url") && parent != NULL && parent->GetAttribute(wxT("class"), wxT("")) == wxT("wxHtmlWindow")) { // FIXME: this is wrong for e.g. http:// URLs return true; } @@ -120,18 +120,18 @@ static bool NodeContainsFilename(wxXmlNode* node) void wxcXmlResourceCmp::FindFilesInXML(wxXmlNode* node, wxArrayString& flist, const wxString& inputPath) { // Is 'node' XML node element? - if(node == NULL) + if (node == NULL) return; - if(node->GetType() != wxXML_ELEMENT_NODE) + if (node->GetType() != wxXML_ELEMENT_NODE) return; bool containsFilename = NodeContainsFilename(node); wxXmlNode* n = node->GetChildren(); - while(n) { - if(containsFilename && (n->GetType() == wxXML_TEXT_NODE || n->GetType() == wxXML_CDATA_SECTION_NODE)) { + while (n) { + if (containsFilename && (n->GetType() == wxXML_TEXT_NODE || n->GetType() == wxXML_CDATA_SECTION_NODE)) { wxString fullname; - if(wxIsAbsolutePath(n->GetContent()) || inputPath.empty()) + if (wxIsAbsolutePath(n->GetContent()) || inputPath.empty()) fullname = n->GetContent(); else fullname = inputPath + wxFILE_SEP_PATH + n->GetContent(); @@ -139,7 +139,7 @@ void wxcXmlResourceCmp::FindFilesInXML(wxXmlNode* node, wxArrayString& flist, co wxString filename = GetInternalFileName(n->GetContent(), flist); n->SetContent(filename); - if(flist.Index(filename) == wxNOT_FOUND) + if (flist.Index(filename) == wxNOT_FOUND) flist.Add(filename); wxFileInputStream sin(fullname); @@ -148,7 +148,7 @@ void wxcXmlResourceCmp::FindFilesInXML(wxXmlNode* node, wxArrayString& flist, co } // subnodes: - if(n->GetType() == wxXML_ELEMENT_NODE) + if (n->GetType() == wxXML_ELEMENT_NODE) FindFilesInXML(n, flist, inputPath); n = n->GetNext(); @@ -157,7 +157,7 @@ void wxcXmlResourceCmp::FindFilesInXML(wxXmlNode* node, wxArrayString& flist, co void wxcXmlResourceCmp::DeleteTempFiles(const wxArrayString& flist) { - for(size_t i = 0; i < flist.GetCount(); i++) + for (size_t i = 0; i < flist.GetCount(); i++) wxRemoveFile(m_outputPath + wxFILE_SEP_PATH + flist[i]); } @@ -182,11 +182,11 @@ static wxString FileToCppArray(wxString filename, int num) unsigned char* buffer = new unsigned char[lng]; file.Read(buffer, lng); - for(size_t i = 0, linelng = 0; i < lng; i++) { + for (size_t i = 0, linelng = 0; i < lng; i++) { tmp.Printf(wxT("%i"), buffer[i]); - if(i != 0) + if (i != 0) output << wxT(','); - if(linelng > 70) { + if (linelng > 70) { linelng = 0; output << wxT("\n"); } @@ -231,7 +231,7 @@ void wxcXmlResourceCmp::MakePackageCPP(const wxArrayString& flist) "#endif\n" "\n"); - for(i = 0; i < flist.GetCount(); i++) + for (i = 0; i < flist.GetCount(); i++) file.Write(FileToCppArray(m_outputPath + wxFILE_SEP_PATH + flist[i], i)); file.Write("" @@ -247,21 +247,21 @@ void wxcXmlResourceCmp::MakePackageCPP(const wxArrayString& flist) " wxFSFile *f = fsys.OpenFile(wxT(\"memory:XRC_resource/dummy_file\"));\n" " wxMemoryFSHandler::RemoveFile(wxT(\"XRC_resource/dummy_file\"));\n" " if (f) delete f;\n"); - if(wxcProjectMetadata::Get().IsAddHandlers()) { + if (wxcProjectMetadata::Get().IsAddHandlers()) { file.Write(" else wxFileSystem::AddHandler(new wxMemoryFSHandlerBase);\n"); } file.Write(" }\n\n"); - for(i = 0; i < flist.GetCount(); i++) { + for (i = 0; i < flist.GetCount(); i++) { wxString s; wxString mime; wxString ext = wxFileName(flist[i]).GetExt(); - if(ext.Lower() == wxT("xrc")) + if (ext.Lower() == wxT("xrc")) mime = wxT("text/xml"); #if wxUSE_MIMETYPE else { wxFileType* ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext); - if(ft) { + if (ft) { ft->GetMimeType(&mime); delete ft; } @@ -270,7 +270,9 @@ void wxcXmlResourceCmp::MakePackageCPP(const wxArrayString& flist) s.Printf(" XRC_ADD_FILE(wxT(\"XRC_resource/" + flist[i] + "\"), xml_res_file_%u, xml_res_size_%u, wxT(\"%s\"));\n", - i, i, mime.c_str()); + i, + i, + mime.c_str()); file.Write(s); } @@ -294,7 +296,7 @@ void wxcXmlResourceCmp::GenCPPHeader() "__\n" "#define __" + headerName.GetName() + "_" + headerName.GetExt() + "__\n"); - for(size_t i = 0; i < aXRCWndClassData.GetCount(); ++i) { + for (size_t i = 0; i < aXRCWndClassData.GetCount(); ++i) { aXRCWndClassData.Item(i).GenerateHeaderCode(file); } file.Write("\nvoid \n" + m_functionName + "();\n#endif\n"); @@ -318,18 +320,18 @@ static wxString FileToPythonArray(wxString filename, int num) unsigned char* buffer = new unsigned char[lng]; file.Read(buffer, lng); - for(size_t i = 0, linelng = 0; i < lng; i++) { + for (size_t i = 0, linelng = 0; i < lng; i++) { unsigned char c = buffer[i]; - if(c == '\n') { + if (c == '\n') { tmp = (wxChar)c; linelng = 0; - } else if(c < 32 || c > 127 || c == '\'') + } else if (c < 32 || c > 127 || c == '\'') tmp.Printf(wxT("\\x%02x"), c); - else if(c == '\\') + else if (c == '\\') tmp = wxT("\\\\"); else tmp = (wxChar)c; - if(linelng > 70) { + if (linelng > 70) { linelng = 0; output << wxT("\\\n"); } @@ -357,7 +359,7 @@ void wxcXmlResourceCmp::MakePackagePython(const wxArrayString& flist) file.Write("def " + m_functionName + "():\n"); - for(i = 0; i < flist.GetCount(); i++) + for (i = 0; i < flist.GetCount(); i++) file.Write(FileToPythonArray(m_outputPath + wxFILE_SEP_PATH + flist[i], i)); file.Write(" # check if the memory filesystem handler has been loaded yet, and load it if not\n" @@ -372,7 +374,7 @@ void wxcXmlResourceCmp::MakePackagePython(const wxArrayString& flist) "\n" " # load all the strings as memory files and load into XmlRes\n"); - for(i = 0; i < flist.GetCount(); i++) { + for (i = 0; i < flist.GetCount(); i++) { wxString s; s.Printf(" wx.MemoryFSHandler.AddFile('XRC_resource/" + flist[i] + "', xml_res_file_%u)\n", i); file.Write(s); @@ -385,7 +387,7 @@ void wxcXmlResourceCmp::MakePackagePython(const wxArrayString& flist) void wxcXmlResourceCmp::OutputGettext() { wxFFile fout; - if(m_outputCppFile.empty()) + if (m_outputCppFile.empty()) fout.Attach(stdout); else fout.Open(m_outputCppFile, wxT("wt")); @@ -400,7 +402,7 @@ void wxcXmlResourceCmp::OutputGettext() fout.Write("_(\"" + extractedString.str + "\");\n"); } - if(!m_outputCppFile) + if (!m_outputCppFile) fout.Detach(); } @@ -409,7 +411,7 @@ ExtractedStrings wxcXmlResourceCmp::FindStrings() ExtractedStrings arr, a2; wxXmlDocument doc; - if(!doc.Load(m_xrcFile)) { + if (!doc.Load(m_xrcFile)) { m_retCode = 1; return arr; } @@ -470,23 +472,23 @@ ExtractedStrings wxcXmlResourceCmp::FindStrings(const wxString& filename, wxXmlN ExtractedStrings arr; wxXmlNode* n = node; - if(n == NULL) + if (n == NULL) return arr; n = n->GetChildren(); - while(n) { - if((node->GetType() == wxXML_ELEMENT_NODE) && - // parent is an element, i.e. has subnodes... - (n->GetType() == wxXML_TEXT_NODE || n->GetType() == wxXML_CDATA_SECTION_NODE) && - // ...it is textnode... - (node /*not n!*/->GetName() == wxT("label") || - (node /*not n!*/->GetName() == wxT("value") && !n->GetContent().IsNumber()) || - node /*not n!*/->GetName() == wxT("help") || node /*not n!*/->GetName() == wxT("longhelp") || - node /*not n!*/->GetName() == wxT("tooltip") || node /*not n!*/->GetName() == wxT("htmlcode") || - node /*not n!*/->GetName() == wxT("title") || node /*not n!*/->GetName() == wxT("item"))) + while (n) { + if ((node->GetType() == wxXML_ELEMENT_NODE) && + // parent is an element, i.e. has subnodes... + (n->GetType() == wxXML_TEXT_NODE || n->GetType() == wxXML_CDATA_SECTION_NODE) && + // ...it is textnode... + (node /*not n!*/->GetName() == wxT("label") || + (node /*not n!*/->GetName() == wxT("value") && !n->GetContent().IsNumber()) || + node /*not n!*/->GetName() == wxT("help") || node /*not n!*/->GetName() == wxT("longhelp") || + node /*not n!*/->GetName() == wxT("tooltip") || node /*not n!*/->GetName() == wxT("htmlcode") || + node /*not n!*/->GetName() == wxT("title") || node /*not n!*/->GetName() == wxT("item"))) // ...and known to contain translatable string // subnodes: - if(n->GetType() == wxXML_ELEMENT_NODE) { + if (n->GetType() == wxXML_ELEMENT_NODE) { ExtractedStrings a2 = FindStrings(filename, n); WX_APPEND_ARRAY(arr, a2); } diff --git a/wxcrafter/src/wxrc.h b/wxcrafter/src/wxrc.h index 15b44eadf2..81a4ad07d6 100644 --- a/wxcrafter/src/wxrc.h +++ b/wxcrafter/src/wxrc.h @@ -62,13 +62,14 @@ class XRCWndClassData wxString classValue; wxString nameValue; wxXmlNode* children; - while(node) { - if(node->GetName() == wxT("object") && node->GetAttribute(wxT("class"), &classValue) && - node->GetAttribute(wxT("name"), &nameValue)) { + while (node) { + if (node->GetName() == wxT("object") && node->GetAttribute(wxT("class"), &classValue) && + node->GetAttribute(wxT("name"), &nameValue)) { m_wdata.Add(XRCWidgetData(nameValue, classValue)); } children = node->GetChildren(); - if(children) BrowseXmlNode(children); + if (children) + BrowseXmlNode(children); node = node->GetNext(); } } @@ -78,12 +79,12 @@ class XRCWndClassData : m_className(className) , m_parentClassName(parentClassName) { - if(className == wxT("wxMenu")) { + if (className == wxT("wxMenu")) { m_ancestorClassNames.insert(wxT("wxMenu")); m_ancestorClassNames.insert(wxT("wxMenuBar")); - } else if(className == wxT("wxMDIChildFrame")) { + } else if (className == wxT("wxMDIChildFrame")) { m_ancestorClassNames.insert(wxT("wxMDIParentFrame")); - } else if(className == wxT("wxMenuBar") || className == wxT("wxStatusBar") || className == wxT("wxToolBar")) { + } else if (className == wxT("wxMenuBar") || className == wxT("wxStatusBar") || className == wxT("wxToolBar")) { m_ancestorClassNames.insert(wxT("wxFrame")); } else { m_ancestorClassNames.insert(wxT("wxWindow")); @@ -96,9 +97,9 @@ class XRCWndClassData bool CanBeUsedWithXRCCTRL(const wxString& name) { - if(name == wxT("tool") || name == wxT("data") || name == wxT("unknown") || name == wxT("notebookpage") || - name == wxT("separator") || name == wxT("sizeritem") || name == wxT("wxMenu") || name == wxT("wxMenuBar") || - name == wxT("wxMenuItem") || name.EndsWith(wxT("Sizer"))) { + if (name == wxT("tool") || name == wxT("data") || name == wxT("unknown") || name == wxT("notebookpage") || + name == wxT("separator") || name == wxT("sizeritem") || name == wxT("wxMenu") || name == wxT("wxMenuBar") || + name == wxT("wxMenuItem") || name.EndsWith(wxT("Sizer"))) { return false; } return true; @@ -109,19 +110,23 @@ class XRCWndClassData file.Write(wxT("class ") + m_className + wxT(" : public ") + m_parentClassName + wxT(" {\nprotected:\n")); size_t i; - for(i = 0; i < m_wdata.GetCount(); ++i) { + for (i = 0; i < m_wdata.GetCount(); ++i) { const XRCWidgetData& w = m_wdata.Item(i); - if(!CanBeUsedWithXRCCTRL(w.GetClass())) continue; - if(w.GetName().empty()) continue; + if (!CanBeUsedWithXRCCTRL(w.GetClass())) + continue; + if (w.GetName().empty()) + continue; file.Write(wxT(" ") + w.GetClass() + wxT("* ") + w.GetName() + wxT(";\n")); } file.Write(wxT("\nprivate:\n void InitWidgetsFromXRC(wxWindow *parent){\n") wxT(" wxXmlResource::Get()->LoadObject(this,parent,wxT(\"") + m_className + wxT("\"), wxT(\"") + m_parentClassName + wxT("\"));\n")); - for(i = 0; i < m_wdata.GetCount(); ++i) { + for (i = 0; i < m_wdata.GetCount(); ++i) { const XRCWidgetData& w = m_wdata.Item(i); - if(!CanBeUsedWithXRCCTRL(w.GetClass())) continue; - if(w.GetName().empty()) continue; + if (!CanBeUsedWithXRCCTRL(w.GetClass())) + continue; + if (w.GetName().empty()) + continue; file.Write(wxT(" ") + w.GetName() + wxT(" = XRCCTRL(*this,\"") + w.GetName() + wxT("\",") + w.GetClass() + wxT(");\n")); } @@ -129,7 +134,7 @@ class XRCWndClassData file.Write(wxT("public:\n")); - if(m_ancestorClassNames.size() == 1) { + if (m_ancestorClassNames.size() == 1) { file.Write(m_className + wxT("(") + *m_ancestorClassNames.begin() + wxT(" *parent=NULL){\n") + wxT(" InitWidgetsFromXRC((wxWindow *)parent);\n") wxT(" }\n") wxT("};\n")); } else { diff --git a/wxcrafter/src/xy_pair.cpp b/wxcrafter/src/xy_pair.cpp index 25d4898acd..fb5731067b 100644 --- a/wxcrafter/src/xy_pair.cpp +++ b/wxcrafter/src/xy_pair.cpp @@ -32,13 +32,15 @@ wxString XYPair::ToString(bool withBraces) const { wxString str; str << m_x << wxT(",") << m_y; - if(withBraces) { str.Prepend(wxT("(")).Append(wxT(")")); } + if (withBraces) { + str.Prepend(wxT("(")).Append(wxT(")")); + } return str; } bool XYPair::operator>(const XYPair& xy) const { - if(GetX() == xy.GetX()) { + if (GetX() == xy.GetX()) { return GetY() > xy.GetY(); } else { diff --git a/wxcrafter/top_level_windows/AuiToolBarTopLevel.cpp b/wxcrafter/top_level_windows/AuiToolBarTopLevel.cpp index 3514c9dbef..f293ebef3c 100644 --- a/wxcrafter/top_level_windows/AuiToolBarTopLevel.cpp +++ b/wxcrafter/top_level_windows/AuiToolBarTopLevel.cpp @@ -40,7 +40,7 @@ AuiToolBarTopLevelWrapper::AuiToolBarTopLevelWrapper() Add( PROP_CLASS_DECORATOR, "", _("MSW Only\nC++ macro decorator - allows exporting this class from a DLL")); - if(m_properties.Contains(PROP_NAME)) { + if (m_properties.Contains(PROP_NAME)) { m_properties.Item(PROP_NAME)->SetTooltip(_("The generated C++ class name")); } @@ -98,7 +98,7 @@ wxString AuiToolBarTopLevelWrapper::CppCtorCode() const code << "SetToolBitmapSize(wxSize" << pr.ToString(true) << ");\n"; XYPair margins(PropertyString(PROP_MARGINS), -1, -1); - if(margins != XYPair(-1, -1)) { + if (margins != XYPair(-1, -1)) { code << " SetMargins(" << margins.ToString() << ");\n"; } return code; @@ -133,7 +133,7 @@ wxString AuiToolBarTopLevelWrapper::GetWxClassName() const { return "wxAuiToolBa void AuiToolBarTopLevelWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_PREVIEW) { + if (type == XRC_PREVIEW) { text << "" << "-1,-1" // Fake a sizer @@ -146,7 +146,7 @@ void AuiToolBarTopLevelWrapper::ToXRC(wxString& text, XRC_TYPE type) const XYPair prSize(PropertyString(PROP_BITMAP_SIZE), 16, 16); XYPair prMargins(PropertyString(PROP_MARGINS), -1, -1); - if(type == XRC_PREVIEW) { + if (type == XRC_PREVIEW) { // IN Preview Mode, append to the class name // a number to distinguish it from the panel // that we added earlier in this function @@ -157,14 +157,14 @@ void AuiToolBarTopLevelWrapper::ToXRC(wxString& text, XRC_TYPE type) const } text << XRCStyle() << XRCCommonAttributes() << "" << prSize.ToString() << ""; - if(prMargins != XYPair(-1, -1)) { + if (prMargins != XYPair(-1, -1)) { text << "" << prMargins.ToString() << ""; } ChildrenXRC(text, type); text << XRCSuffix(); - if(type == XRC_PREVIEW) { + if (type == XRC_PREVIEW) { text << "" // sizeritem << "" // wxBoxSizer << ""; // PreviewPanel diff --git a/wxcrafter/top_level_windows/dialog_wrapper.cpp b/wxcrafter/top_level_windows/dialog_wrapper.cpp index b95946933c..dc702efc5b 100644 --- a/wxcrafter/top_level_windows/dialog_wrapper.cpp +++ b/wxcrafter/top_level_windows/dialog_wrapper.cpp @@ -18,10 +18,12 @@ DialogWrapper::DialogWrapper() PREPEND_STYLE(wxSTAY_ON_TOP, false); PREPEND_STYLE(wxDEFAULT_DIALOG_STYLE, true); - RegisterEvent(wxT("wxEVT_INIT_DIALOG"), wxT("wxInitDialogEvent"), + RegisterEvent(wxT("wxEVT_INIT_DIALOG"), + wxT("wxInitDialogEvent"), _("A wxInitDialogEvent is sent as a dialog or panel is being initialised. Handlers for this event " "can transfer data to the window.\nThe default handler calls wxWindow::TransferDataToWindow")); - RegisterEvent(wxT("wxEVT_CLOSE_WINDOW"), wxT("wxCloseEvent"), + RegisterEvent(wxT("wxEVT_CLOSE_WINDOW"), + wxT("wxCloseEvent"), _("Process a close event. This event applies to wxFrame and wxDialog classes")); RegisterEvent(wxT("wxEVT_ACTIVATE"), wxT("wxActivateEvent"), _("Process a wxEVT_ACTIVATE event")); RegisterEvent(wxT("wxEVT_ACTIVATE_APP"), wxT("wxActivateEvent"), _("Process a wxEVT_ACTIVATE_APP event")); @@ -101,13 +103,13 @@ wxString DialogWrapper::GetWxClassName() const { return wxT("wxDialog"); } void DialogWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type != wxcWidget::XRC_LIVE) { + if (type != wxcWidget::XRC_LIVE) { text << wxT("") << wxT(""); } wxString centred; - if(!PropertyString(PROP_CENTRE_ON_SCREEN).empty()) { + if (!PropertyString(PROP_CENTRE_ON_SCREEN).empty()) { centred = wxT("1"); // In XRC centring is on/off; it doesn't discriminate between // wxBOTH/wxVERTICAL/wxHORIZONTAL } @@ -119,7 +121,9 @@ void DialogWrapper::ToXRC(wxString& text, XRC_TYPE type) const ChildrenXRC(text, type); text << wxT(""); - if(type != wxcWidget::XRC_LIVE) { text << wxT(""); } + if (type != wxcWidget::XRC_LIVE) { + text << wxT(""); + } } void DialogWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) @@ -128,13 +132,17 @@ void DialogWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("centered")); - if(propertynode) { SetPropertyString(PROP_CENTRE_ON_SCREEN, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_CENTRE_ON_SCREEN, propertynode->GetNodeContent()); + } // We've already done 'size' in the baseclass, but do it again for TLWindows // That's because if no size was specified, wxC inflicts 500,300. This isn't what the user expected // So, if there is *not* a specified size, overwrite the wxC default with wxDefaultSize propertynode = XmlUtils::FindFirstByTagName(node, wxT("size")); - if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } + if (!propertynode) { + SetPropertyString(PROP_SIZE, "-1,-1"); + } } void DialogWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -143,13 +151,17 @@ void DialogWrapper::LoadPropertiesFromwxSmith(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxSmith(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("centered")); - if(propertynode) { SetPropertyString(PROP_CENTRE_ON_SCREEN, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_CENTRE_ON_SCREEN, propertynode->GetNodeContent()); + } // We've already done 'size' in the baseclass, but do it again for TLWindows // That's because if no size was specified, wxC inflicts 500,300. This isn't what the user expected // So, if there is *not* a specified size, overwrite the wxC default with wxDefaultSize propertynode = XmlUtils::FindFirstByTagName(node, wxT("size")); - if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } + if (!propertynode) { + SetPropertyString(PROP_SIZE, "-1,-1"); + } } void DialogWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -158,10 +170,14 @@ void DialogWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "center"); - if(propertynode) { SetPropertyString(PROP_CENTRE_ON_SCREEN, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_CENTRE_ON_SCREEN, propertynode->GetNodeContent()); + } // See the comment in LoadPropertiesFromXRC() propertynode = XmlUtils::FindNodeByName(node, "property", wxT("size")); - if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } + if (!propertynode) { + SetPropertyString(PROP_SIZE, "-1,-1"); + } } bool DialogWrapper::HasIcon() const { return true; } diff --git a/wxcrafter/top_level_windows/frame_wrapper.h b/wxcrafter/top_level_windows/frame_wrapper.h index ac67b09e2b..2b1adfd5b5 100644 --- a/wxcrafter/top_level_windows/frame_wrapper.h +++ b/wxcrafter/top_level_windows/frame_wrapper.h @@ -2,6 +2,7 @@ #define FRAMEWRAPPER_H #include "top_level_win_wrapper.h" // Base class: TopLevelWinWrapper + #include class FrameWrapper : public TopLevelWinWrapper diff --git a/wxcrafter/top_level_windows/image_list_wrapper.cpp b/wxcrafter/top_level_windows/image_list_wrapper.cpp index 64b69d87c4..3ba21f1bee 100644 --- a/wxcrafter/top_level_windows/image_list_wrapper.cpp +++ b/wxcrafter/top_level_windows/image_list_wrapper.cpp @@ -102,7 +102,7 @@ wxString ImageListWrapper::GetWxClassName() const { return "wxImageList"; } void ImageListWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type == XRC_DESIGNER) { + if (type == XRC_DESIGNER) { ChildrenXRC(text, type); WrapXRC(text); } diff --git a/wxcrafter/top_level_windows/panel_wrapper_top_level.cpp b/wxcrafter/top_level_windows/panel_wrapper_top_level.cpp index be8b079e1f..e491322bab 100644 --- a/wxcrafter/top_level_windows/panel_wrapper_top_level.cpp +++ b/wxcrafter/top_level_windows/panel_wrapper_top_level.cpp @@ -38,7 +38,7 @@ wxString PanelWrapperTopLevel::CppCtorCode() const { return TopLevelWinWrapper:: void PanelWrapperTopLevel::ToXRC(wxString& text, XRC_TYPE type) const { - if(type != wxcWidget::XRC_LIVE) { + if (type != wxcWidget::XRC_LIVE) { text << wxT("") << wxT(""); } @@ -48,7 +48,9 @@ void PanelWrapperTopLevel::ToXRC(wxString& text, XRC_TYPE type) const ChildrenXRC(text, type); text << wxT(""); - if(type != wxcWidget::XRC_LIVE) { text << wxT(""); } + if (type != wxcWidget::XRC_LIVE) { + text << wxT(""); + } } wxString PanelWrapperTopLevel::DesignerXRC(bool forPreviewDialog) const @@ -94,7 +96,9 @@ void PanelWrapperTopLevel::LoadPropertiesFromXRC(const wxXmlNode* node) // That's because if no size was specified, wxC inflicts 500,300. This isn't what the user expected // So, if there is *not* a specified size, overwrite the wxC default with wxDefaultSize wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("size")); - if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } + if (!propertynode) { + SetPropertyString(PROP_SIZE, "-1,-1"); + } } void PanelWrapperTopLevel::LoadPropertiesFromwxSmith(const wxXmlNode* node) @@ -106,7 +110,9 @@ void PanelWrapperTopLevel::LoadPropertiesFromwxSmith(const wxXmlNode* node) // That's because if no size was specified, wxC inflicts 500,300. This isn't what the user expected // So, if there is *not* a specified size, overwrite the wxC default with wxDefaultSize wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("size")); - if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } + if (!propertynode) { + SetPropertyString(PROP_SIZE, "-1,-1"); + } } void PanelWrapperTopLevel::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -116,5 +122,7 @@ void PanelWrapperTopLevel::LoadPropertiesFromwxFB(const wxXmlNode* node) // See the comment in LoadPropertiesFromXRC() wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", wxT("size")); - if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } + if (!propertynode) { + SetPropertyString(PROP_SIZE, "-1,-1"); + } } diff --git a/wxcrafter/top_level_windows/popup_window_wrapper.cpp b/wxcrafter/top_level_windows/popup_window_wrapper.cpp index e077b9591c..8bef0e8db3 100644 --- a/wxcrafter/top_level_windows/popup_window_wrapper.cpp +++ b/wxcrafter/top_level_windows/popup_window_wrapper.cpp @@ -1,4 +1,5 @@ #include "popup_window_wrapper.h" + #include "allocator_mgr.h" PopupWindowWrapper::PopupWindowWrapper() @@ -31,7 +32,7 @@ wxString PopupWindowWrapper::GetWxClassName() const { return "wxPopupWindow"; } void PopupWindowWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type != wxcWidget::XRC_LIVE) { + if (type != wxcWidget::XRC_LIVE) { text << wxT("") << wxT(""); } @@ -43,7 +44,9 @@ void PopupWindowWrapper::ToXRC(wxString& text, XRC_TYPE type) const ChildrenXRC(text, type); text << wxT(""); - if(type != wxcWidget::XRC_LIVE) { text << wxT(""); } + if (type != wxcWidget::XRC_LIVE) { + text << wxT(""); + } } wxString PopupWindowWrapper::BaseCtorDecl() const diff --git a/wxcrafter/top_level_windows/wizard_wrapper.cpp b/wxcrafter/top_level_windows/wizard_wrapper.cpp index a12308ddfa..d0139ccdf2 100644 --- a/wxcrafter/top_level_windows/wizard_wrapper.cpp +++ b/wxcrafter/top_level_windows/wizard_wrapper.cpp @@ -26,21 +26,26 @@ WizardWrapper::WizardWrapper() EnableStyle(wxT("wxCAPTION"), false); // Wizard related events - RegisterEvent(wxT("wxEVT_WIZARD_PAGE_CHANGED"), wxT("wxWizardEvent"), + RegisterEvent(wxT("wxEVT_WIZARD_PAGE_CHANGED"), + wxT("wxWizardEvent"), _("The page has just been changed (this event cannot be vetoed)")); - RegisterEvent(wxT("wxEVT_WIZARD_PAGE_CHANGING"), wxT("wxWizardEvent"), + RegisterEvent(wxT("wxEVT_WIZARD_PAGE_CHANGING"), + wxT("wxWizardEvent"), _("The page is being changed (this event can be vetoed).")); RegisterEvent(wxT("wxEVT_WIZARD_PAGE_SHOWN"), wxT("wxWizardEvent"), _("The page was shown and laid out.")); - RegisterEvent(wxT("wxEVT_WIZARD_CANCEL"), wxT("wxWizardEvent"), + RegisterEvent(wxT("wxEVT_WIZARD_CANCEL"), + wxT("wxWizardEvent"), _("The user attempted to cancel the wizard (this event may also be vetoed).")); RegisterEvent(wxT("wxEVT_WIZARD_HELP"), wxT("wxWizardEvent"), _("The wizard help button was pressed.")); RegisterEvent(wxT("wxEVT_WIZARD_FINISHED"), wxT("wxWizardEvent"), _("The wizard finished button was pressed.")); // Dialog related events - RegisterEvent(wxT("wxEVT_INIT_DIALOG"), wxT("wxInitDialogEvent"), + RegisterEvent(wxT("wxEVT_INIT_DIALOG"), + wxT("wxInitDialogEvent"), _("A wxInitDialogEvent is sent as a dialog or panel is being initialised. Handlers for this event " "can transfer data to the window.\nThe default handler calls wxWindow::TransferDataToWindow")); - RegisterEvent(wxT("wxEVT_CLOSE_WINDOW"), wxT("wxCloseEvent"), + RegisterEvent(wxT("wxEVT_CLOSE_WINDOW"), + wxT("wxCloseEvent"), _("Process a close event. This event applies to wxFrame and wxDialog classes")); RegisterEvent(wxT("wxEVT_ACTIVATE"), wxT("wxActivateEvent"), _("Process a wxEVT_ACTIVATE event")); RegisterEvent(wxT("wxEVT_ACTIVATE_APP"), wxT("wxActivateEvent"), _("Process a wxEVT_ACTIVATE_APP event")); @@ -94,13 +99,13 @@ wxString WizardWrapper::DesignerXRC(bool forPreviewDialog) const void WizardWrapper::ToXRC(wxString& text, XRC_TYPE type) const { - if(type != wxcWidget::XRC_LIVE) { + if (type != wxcWidget::XRC_LIVE) { text << wxT("") << wxT(""); } wxString centred; - if(!PropertyString(PROP_CENTRE_ON_SCREEN).empty()) { + if (!PropertyString(PROP_CENTRE_ON_SCREEN).empty()) { centred = wxT("1"); // In XRC centring is on/off; it doesn't discriminate between // wxBOTH/wxVERTICAL/wxHORIZONTAL } @@ -113,7 +118,9 @@ void WizardWrapper::ToXRC(wxString& text, XRC_TYPE type) const ChildrenXRC(text, type); text << wxT(""); - if(type != wxcWidget::XRC_LIVE) { text << wxT(""); } + if (type != wxcWidget::XRC_LIVE) { + text << wxT(""); + } } void WizardWrapper::GetIncludeFile(wxArrayString& headers) const @@ -152,16 +159,22 @@ void WizardWrapper::LoadPropertiesFromXRC(const wxXmlNode* node) wxcWidget::LoadPropertiesFromXRC(node); wxXmlNode* propertynode = XmlUtils::FindFirstByTagName(node, wxT("centered")); - if(propertynode) { SetPropertyString(PROP_CENTRE_ON_SCREEN, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_CENTRE_ON_SCREEN, propertynode->GetNodeContent()); + } propertynode = XmlUtils::FindFirstByTagName(node, wxT("bitmap")); - if(propertynode) { ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_OTHER"); } + if (propertynode) { + ImportFromXrc::ProcessBitmapProperty(propertynode, this, PROP_BITMAP_PATH, "wxART_OTHER"); + } // We've already done 'size' in the baseclass, but do it again for TLWindows // That's because if no size was specified, wxC inflicts 500,300. This isn't what the user expected // So, if there is *not* a specified size, overwrite the wxC default with wxDefaultSize propertynode = XmlUtils::FindFirstByTagName(node, wxT("size")); - if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } + if (!propertynode) { + SetPropertyString(PROP_SIZE, "-1,-1"); + } } void WizardWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) @@ -170,15 +183,19 @@ void WizardWrapper::LoadPropertiesFromwxFB(const wxXmlNode* node) wxcWidget::LoadPropertiesFromwxFB(node); wxXmlNode* propertynode = XmlUtils::FindNodeByName(node, "property", "bitmap"); - if(propertynode) { + if (propertynode) { ImportFromwxFB::ProcessBitmapProperty(propertynode->GetNodeContent(), this, PROP_BITMAP_PATH, "wxART_OTHER"); } propertynode = XmlUtils::FindNodeByName(node, "property", "center"); - if(propertynode) { SetPropertyString(PROP_CENTRE_ON_SCREEN, propertynode->GetNodeContent()); } + if (propertynode) { + SetPropertyString(PROP_CENTRE_ON_SCREEN, propertynode->GetNodeContent()); + } // See the comment in LoadPropertiesFromXRC() propertynode = XmlUtils::FindNodeByName(node, "property", wxT("size")); - if(!propertynode) { SetPropertyString(PROP_SIZE, "-1,-1"); } + if (!propertynode) { + SetPropertyString(PROP_SIZE, "-1,-1"); + } } bool WizardWrapper::HasIcon() const { return true; } diff --git a/wxcrafter/xrc_handlers/MyComboBoxXmlHandler.cpp b/wxcrafter/xrc_handlers/MyComboBoxXmlHandler.cpp index 428a5a57e0..b89c5f51ec 100644 --- a/wxcrafter/xrc_handlers/MyComboBoxXmlHandler.cpp +++ b/wxcrafter/xrc_handlers/MyComboBoxXmlHandler.cpp @@ -1,4 +1,5 @@ #include "MyComboBoxXmlHandler.h" + #include #include #include @@ -17,7 +18,7 @@ MyComboBoxXmlHandler::MyComboBoxXmlHandler() wxObject* MyComboBoxXmlHandler::DoCreateResource() { - if(m_class == wxT("wxComboBox")) { + if (m_class == wxT("wxComboBox")) { // find the selection long selection = GetLong(wxT("selection"), -1); @@ -27,12 +28,22 @@ wxObject* MyComboBoxXmlHandler::DoCreateResource() XRC_MAKE_INSTANCE(control, wxComboBox) - control->Create(m_parentAsWindow, GetID(), GetText(wxT("value")), GetPosition(), GetSize(), strList, GetStyle(), - wxDefaultValidator, GetName()); + control->Create(m_parentAsWindow, + GetID(), + GetText(wxT("value")), + GetPosition(), + GetSize(), + strList, + GetStyle(), + wxDefaultValidator, + GetName()); - if(selection != -1) control->SetSelection(selection); + if (selection != -1) + control->SetSelection(selection); - if(HasParam("hint")) { control->SetHint(GetText("hint")); } + if (HasParam("hint")) { + control->SetHint(GetText("hint")); + } SetupWindow(control); @@ -45,7 +56,8 @@ wxObject* MyComboBoxXmlHandler::DoCreateResource() // add to the list wxString str = GetNodeContent(m_node); - if(m_resource->GetFlags() & wxXRC_USE_LOCALE) str = wxGetTranslation(str, m_resource->GetDomain()); + if (m_resource->GetFlags() & wxXRC_USE_LOCALE) + str = wxGetTranslation(str, m_resource->GetDomain()); strList.Add(str); return NULL; diff --git a/wxcrafter/xrc_handlers/MyRearrangeListXmlHandler.cpp b/wxcrafter/xrc_handlers/MyRearrangeListXmlHandler.cpp index d8d58c6694..d586182e05 100644 --- a/wxcrafter/xrc_handlers/MyRearrangeListXmlHandler.cpp +++ b/wxcrafter/xrc_handlers/MyRearrangeListXmlHandler.cpp @@ -1,4 +1,5 @@ #include "MyRearrangeListXmlHandler.h" + #include #include #include @@ -26,26 +27,34 @@ bool MyRearrangeListXmlHandler::CanHandle(wxXmlNode* node) wxObject* MyRearrangeListXmlHandler::DoCreateResource() { - if(m_class == wxT("wxRearrangeList")) { + if (m_class == wxT("wxRearrangeList")) { // need to build the list of strings from children m_insideBox = true; CreateChildrenPrivately(NULL, GetParamNode(wxT("content"))); wxArrayInt order; - for(size_t i = 0; i < strList.GetCount(); ++i) { + for (size_t i = 0; i < strList.GetCount(); ++i) { order.push_back((int)i); } XRC_MAKE_INSTANCE(control, wxRearrangeList) - control->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), order, strList, GetStyle(), - wxDefaultValidator, GetName()); + control->Create(m_parentAsWindow, + GetID(), + GetPosition(), + GetSize(), + order, + strList, + GetStyle(), + wxDefaultValidator, + GetName()); // step through children myself (again.) wxXmlNode* n = GetParamNode(wxT("content")); - if(n) n = n->GetChildren(); + if (n) + n = n->GetChildren(); int i = 0; - while(n) { - if(n->GetType() != wxXML_ELEMENT_NODE || n->GetName() != wxT("item")) { + while (n) { + if (n->GetType() != wxXML_ELEMENT_NODE || n->GetName() != wxT("item")) { n = n->GetNext(); continue; } @@ -53,7 +62,8 @@ wxObject* MyRearrangeListXmlHandler::DoCreateResource() // checking boolean is a bit ugly here (see GetBool() ) wxString v = n->GetAttribute(wxT("checked"), wxEmptyString); v.MakeLower(); - if(v == wxT("1")) control->Check(i, true); + if (v == wxT("1")) + control->Check(i, true); i++; n = n->GetNext(); @@ -69,7 +79,8 @@ wxObject* MyRearrangeListXmlHandler::DoCreateResource() // add to the list wxString str = GetNodeContent(m_node); - if(m_resource->GetFlags() & wxXRC_USE_LOCALE) str = wxGetTranslation(str, m_resource->GetDomain()); + if (m_resource->GetFlags() & wxXRC_USE_LOCALE) + str = wxGetTranslation(str, m_resource->GetDomain()); strList.Add(str); return NULL; } diff --git a/wxcrafter/xrc_handlers/myxh_auibook.cpp b/wxcrafter/xrc_handlers/myxh_auibook.cpp index 69c8ac75ee..9230a47925 100644 --- a/wxcrafter/xrc_handlers/myxh_auibook.cpp +++ b/wxcrafter/xrc_handlers/myxh_auibook.cpp @@ -4,13 +4,14 @@ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" +#include #ifdef __BORLANDC__ #pragma hdrstop #endif #include "myxh_auibook.h" + #include #include #include @@ -20,8 +21,11 @@ class MyAuiBook : public wxAuiNotebook wxSize m_sz; public: - MyAuiBook(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxAUI_NB_DEFAULT_STYLE) + MyAuiBook(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxAUI_NB_DEFAULT_STYLE) : wxAuiNotebook(parent, id, pos, size, style) { m_sz = size; @@ -53,21 +57,24 @@ MyWxAuiNotebookXmlHandler::MyWxAuiNotebookXmlHandler() wxObject* MyWxAuiNotebookXmlHandler::DoCreateResource() { - if(m_class == wxT("notebookpage")) { + if (m_class == wxT("notebookpage")) { wxXmlNode* n = GetParamNode(wxT("object")); - if(!n) n = GetParamNode(wxT("object_ref")); + if (!n) + n = GetParamNode(wxT("object_ref")); - if(n) { + if (n) { bool old_ins = m_isInside; m_isInside = false; wxObject* item = CreateResFromNode(n, m_notebook, NULL); m_isInside = old_ins; wxWindow* wnd = wxDynamicCast(item, wxWindow); - if(wnd) { + if (wnd) { wxBitmap bmp = wxNullBitmap; - if(HasParam(wxT("bitmap"))) { bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); } + if (HasParam(wxT("bitmap"))) { + bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); + } m_notebook->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")), bmp); } else diff --git a/wxcrafter/xrc_handlers/myxh_auimgr.cpp b/wxcrafter/xrc_handlers/myxh_auimgr.cpp index 456eef72a3..fee9cae4e2 100644 --- a/wxcrafter/xrc_handlers/myxh_auimgr.cpp +++ b/wxcrafter/xrc_handlers/myxh_auimgr.cpp @@ -8,12 +8,13 @@ /////////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" +#include #ifdef __BORLANDC__ #pragma hdrstop #endif #include "myxh_auimgr.h" + #include #include @@ -68,9 +69,9 @@ wxAuiManager* MyWxAuiManagerXmlHandler::GetAuiManager(wxWindow* managed) const void MyWxAuiManagerXmlHandler::OnManagedWindowClose(wxWindowDestroyEvent& event) { wxWindow* window = wxDynamicCast(event.GetEventObject(), wxWindow); - for(Managers::iterator it = m_managers.begin(); it != m_managers.end(); ++it) { + for (Managers::iterator it = m_managers.begin(); it != m_managers.end(); ++it) { wxAuiManager* const mgr = *it; - if(mgr->GetManagedWindow() == window) { + if (mgr->GetManagedWindow() == window) { mgr->UnInit(); m_managers.erase(it); break; @@ -81,10 +82,10 @@ void MyWxAuiManagerXmlHandler::OnManagedWindowClose(wxWindowDestroyEvent& event) wxObject* MyWxAuiManagerXmlHandler::DoCreateResource() { - if(m_class == wxS("wxAuiManager")) { + if (m_class == wxS("wxAuiManager")) { wxAuiManager* manager = NULL; - if(m_parentAsWindow) { + if (m_parentAsWindow) { // Cache the previous values bool old_ins = m_mgrInside; wxAuiManager* old_mgr = m_manager; @@ -108,7 +109,8 @@ wxObject* MyWxAuiManagerXmlHandler::DoCreateResource() CreateChildren(m_manager); // Load a custom perspective if any - if(HasParam(wxS("perspective"))) m_manager->LoadPerspective(GetParamValue(wxS("perspective"))); + if (HasParam(wxS("perspective"))) + m_manager->LoadPerspective(GetParamValue(wxS("perspective"))); m_manager->Update(); @@ -121,13 +123,14 @@ wxObject* MyWxAuiManagerXmlHandler::DoCreateResource() } return manager; - } else if(m_class == "wxAuiPaneInfo") { + } else if (m_class == "wxAuiPaneInfo") { wxXmlNode* node = GetParamNode(wxS("object")); wxWindow* window = NULL; - if(!node) node = GetParamNode(wxS("object_ref")); + if (!node) + node = GetParamNode(wxS("object_ref")); - if(node) { + if (node) { bool old_ins = m_mgrInside; m_mgrInside = false; @@ -136,67 +139,92 @@ wxObject* MyWxAuiManagerXmlHandler::DoCreateResource() m_mgrInside = old_ins; window = wxDynamicCast(object, wxWindow); - if(!window && object) { ReportError(node, "wxAuiPaneInfo child must be a window."); } + if (!window && object) { + ReportError(node, "wxAuiPaneInfo child must be a window."); + } } - if(window) { + if (window) { wxAuiPaneInfo paneInfo = wxAuiPaneInfo(); wxString name = GetName(); paneInfo.Name(name); // Caption - if(HasParam(wxS("caption"))) paneInfo.Caption(GetText(wxS("caption"))); - if(HasParam(wxS("caption_visible"))) paneInfo.CaptionVisible(GetBool(wxS("caption_visible"))); + if (HasParam(wxS("caption"))) + paneInfo.Caption(GetText(wxS("caption"))); + if (HasParam(wxS("caption_visible"))) + paneInfo.CaptionVisible(GetBool(wxS("caption_visible"))); // Buttons - if(HasParam(wxS("close_button"))) paneInfo.CloseButton(GetBool(wxS("close_button"))); - if(HasParam(wxS("minimize_button"))) paneInfo.MinimizeButton(GetBool(wxS("minimize_button"))); - if(HasParam(wxS("maximize_button"))) paneInfo.MaximizeButton(GetBool(wxS("maximize_button"))); - if(HasParam(wxS("pin_button"))) paneInfo.PinButton(GetBool(wxS("pin_button"))); - if(HasParam(wxS("gripper"))) paneInfo.Gripper(GetBool(wxS("gripper"))); + if (HasParam(wxS("close_button"))) + paneInfo.CloseButton(GetBool(wxS("close_button"))); + if (HasParam(wxS("minimize_button"))) + paneInfo.MinimizeButton(GetBool(wxS("minimize_button"))); + if (HasParam(wxS("maximize_button"))) + paneInfo.MaximizeButton(GetBool(wxS("maximize_button"))); + if (HasParam(wxS("pin_button"))) + paneInfo.PinButton(GetBool(wxS("pin_button"))); + if (HasParam(wxS("gripper"))) + paneInfo.Gripper(GetBool(wxS("gripper"))); // Appearance - if(HasParam(wxS("pane_border"))) paneInfo.PaneBorder(GetBool(wxS("pane_border"))); + if (HasParam(wxS("pane_border"))) + paneInfo.PaneBorder(GetBool(wxS("pane_border"))); // State - if(HasParam(wxS("dock"))) + if (HasParam(wxS("dock"))) paneInfo.Dock(); - else if(HasParam(wxS("float"))) + else if (HasParam(wxS("float"))) paneInfo.Float(); // Dockable Directions - if(HasParam(wxS("top_dockable"))) paneInfo.TopDockable(GetBool(wxS("top_dockable"))); - if(HasParam(wxS("bottom_dockable"))) paneInfo.BottomDockable(GetBool(wxS("bottom_dockable"))); - if(HasParam(wxS("left_dockable"))) paneInfo.LeftDockable(GetBool(wxS("left_dockable"))); - if(HasParam(wxS("right_dockable"))) paneInfo.RightDockable(GetBool(wxS("right_dockable"))); + if (HasParam(wxS("top_dockable"))) + paneInfo.TopDockable(GetBool(wxS("top_dockable"))); + if (HasParam(wxS("bottom_dockable"))) + paneInfo.BottomDockable(GetBool(wxS("bottom_dockable"))); + if (HasParam(wxS("left_dockable"))) + paneInfo.LeftDockable(GetBool(wxS("left_dockable"))); + if (HasParam(wxS("right_dockable"))) + paneInfo.RightDockable(GetBool(wxS("right_dockable"))); // Behaviours - if(HasParam(wxS("dock_fixed"))) paneInfo.DockFixed(GetBool(wxS("dock_fixed"))); - if(HasParam(wxS("resizable"))) paneInfo.Resizable(GetBool(wxS("resizable"))); - if(HasParam(wxS("movable"))) paneInfo.Movable(GetBool(wxS("movable"))); - if(HasParam(wxS("floatable"))) paneInfo.Floatable(GetBool(wxS("floatable"))); + if (HasParam(wxS("dock_fixed"))) + paneInfo.DockFixed(GetBool(wxS("dock_fixed"))); + if (HasParam(wxS("resizable"))) + paneInfo.Resizable(GetBool(wxS("resizable"))); + if (HasParam(wxS("movable"))) + paneInfo.Movable(GetBool(wxS("movable"))); + if (HasParam(wxS("floatable"))) + paneInfo.Floatable(GetBool(wxS("floatable"))); // Sizes - if(HasParam(wxS("floating_size"))) paneInfo.FloatingSize(GetSize(wxS("floating_size"))); - if(HasParam(wxS("min_size"))) paneInfo.MinSize(GetSize(wxS("min_size"))); - if(HasParam(wxS("max_size"))) paneInfo.MaxSize(GetSize(wxS("max_size"))); - if(HasParam(wxS("best_size"))) paneInfo.BestSize(GetSize(wxS("best_size"))); + if (HasParam(wxS("floating_size"))) + paneInfo.FloatingSize(GetSize(wxS("floating_size"))); + if (HasParam(wxS("min_size"))) + paneInfo.MinSize(GetSize(wxS("min_size"))); + if (HasParam(wxS("max_size"))) + paneInfo.MaxSize(GetSize(wxS("max_size"))); + if (HasParam(wxS("best_size"))) + paneInfo.BestSize(GetSize(wxS("best_size"))); // Positions - if(HasParam(wxS("row"))) paneInfo.Row(GetLong(wxS("row"))); - if(HasParam(wxS("layer"))) paneInfo.Layer(GetLong(wxS("layer"))); - if(HasParam(wxS("default_pane"))) + if (HasParam(wxS("row"))) + paneInfo.Row(GetLong(wxS("row"))); + if (HasParam(wxS("layer"))) + paneInfo.Layer(GetLong(wxS("layer"))); + if (HasParam(wxS("default_pane"))) paneInfo.DefaultPane(); - else if(HasParam(wxS("toolbar_pane"))) + else if (HasParam(wxS("toolbar_pane"))) paneInfo.ToolbarPane(); // Directions - CenterPane()/CentrePane != Center()/Centre() - if(HasParam(wxS("center_pane")) || HasParam(wxS("centre_pane"))) paneInfo.CenterPane(); - if(HasParam(wxS("direction"))) + if (HasParam(wxS("center_pane")) || HasParam(wxS("centre_pane"))) + paneInfo.CenterPane(); + if (HasParam(wxS("direction"))) paneInfo.Direction(GetLong(wxS("direction"))); - else if(HasParam(wxS("top"))) + else if (HasParam(wxS("top"))) paneInfo.Top(); - else if(HasParam(wxS("bottom"))) + else if (HasParam(wxS("bottom"))) paneInfo.Bottom(); - else if(HasParam(wxS("left"))) + else if (HasParam(wxS("left"))) paneInfo.Left(); - else if(HasParam(wxS("right"))) + else if (HasParam(wxS("right"))) paneInfo.Right(); - else if(HasParam(wxS("center")) || HasParam(wxS("centre"))) + else if (HasParam(wxS("center")) || HasParam(wxS("centre"))) paneInfo.Center(); m_manager->AddPane(window, paneInfo); @@ -205,22 +233,23 @@ wxObject* MyWxAuiManagerXmlHandler::DoCreateResource() } return window; - } else if(m_class == wxS("notebookpage")) { + } else if (m_class == wxS("notebookpage")) { wxXmlNode* anb = GetParamNode(wxS("object")); - if(!anb) anb = GetParamNode(wxS("object_ref")); + if (!anb) + anb = GetParamNode(wxS("object_ref")); - if(anb) { + if (anb) { bool old_ins = m_anbInside; m_anbInside = false; wxObject* item = CreateResFromNode(anb, m_notebook, NULL); m_anbInside = old_ins; wxWindow* wnd = wxDynamicCast(item, wxWindow); - if(wnd) { - if(HasParam(wxS("bitmap"))) { - m_notebook->AddPage(wnd, GetText(wxS("label")), GetBool(wxS("selected")), - GetBitmap(wxS("bitmap"), wxART_OTHER)); + if (wnd) { + if (HasParam(wxS("bitmap"))) { + m_notebook->AddPage( + wnd, GetText(wxS("label")), GetBool(wxS("selected")), GetBitmap(wxS("bitmap"), wxART_OTHER)); } else { m_notebook->AddPage(wnd, GetText(wxS("label")), GetBool(wxS("selected"))); } diff --git a/wxcrafter/xrc_handlers/myxh_auimgr.h b/wxcrafter/xrc_handlers/myxh_auimgr.h index 959050f4db..87636ee36a 100644 --- a/wxcrafter/xrc_handlers/myxh_auimgr.h +++ b/wxcrafter/xrc_handlers/myxh_auimgr.h @@ -10,9 +10,8 @@ #ifndef _WX_XH_AUI_H_ #define _WX_XH_AUI_H_ -#include "wx/xrc/xmlres.h" - #include "wx/vector.h" +#include "wx/xrc/xmlres.h" class WXDLLIMPEXP_FWD_AUI wxAuiManager; class WXDLLIMPEXP_FWD_AUI wxAuiNotebook; diff --git a/wxcrafter/xrc_handlers/myxh_auitoolb.cpp b/wxcrafter/xrc_handlers/myxh_auitoolb.cpp index 93b50faf33..76208df995 100644 --- a/wxcrafter/xrc_handlers/myxh_auitoolb.cpp +++ b/wxcrafter/xrc_handlers/myxh_auitoolb.cpp @@ -9,14 +9,17 @@ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". +#include + #include "myxh_auitoolb.h" + #include "wx/aui/auibar.h" #include "wx/frame.h" #include "wx/log.h" #include "wx/menu.h" #include "wx/pen.h" #include "wx/sizer.h" -#include "wx/wxprec.h" + #include MyWxAuiToolBarXmlHandler::MyWxAuiToolBarXmlHandler() @@ -39,49 +42,64 @@ MyWxAuiToolBarXmlHandler::MyWxAuiToolBarXmlHandler() wxObject* MyWxAuiToolBarXmlHandler::DoCreateResource() { - if(m_class == wxT("tool")) { - if(!m_toolbar) { return NULL; } + if (m_class == wxT("tool")) { + if (!m_toolbar) { + return NULL; + } wxItemKind kind = wxITEM_NORMAL; - if(GetBool(wxT("radio"))) kind = wxITEM_RADIO; + if (GetBool(wxT("radio"))) + kind = wxITEM_RADIO; - if(GetBool(wxT("toggle"))) { kind = wxITEM_CHECK; } + if (GetBool(wxT("toggle"))) { + kind = wxITEM_CHECK; + } - m_toolbar->AddTool(GetID(), GetText(wxT("label")), GetBitmap(wxT("bitmap"), wxART_TOOLBAR, m_toolSize), - GetText(wxT("longhelp")), kind); + m_toolbar->AddTool(GetID(), + GetText(wxT("label")), + GetBitmap(wxT("bitmap"), wxART_TOOLBAR, m_toolSize), + GetText(wxT("longhelp")), + kind); - if(GetBool(wxT("disabled"))) m_toolbar->EnableTool(GetID(), false); + if (GetBool(wxT("disabled"))) + m_toolbar->EnableTool(GetID(), false); - if(GetBool(wxS("checked"))) { m_toolbar->ToggleTool(GetID(), true); } + if (GetBool(wxS("checked"))) { + m_toolbar->ToggleTool(GetID(), true); + } wxAuiToolBarItem* tool = m_toolbar->FindTool(GetID()); wxXmlNode* const nodeDropdown = GetParamNode("dropdown"); // The new official wx xh_auitoolb.cpp uses "dropdown" - if(tool && (GetBool("hasdropdown") || (nodeDropdown != NULL))) { + if (tool && (GetBool("hasdropdown") || (nodeDropdown != NULL))) { // From the official wx3.1 handler // also check for the menu specified inside dropdown (it is // optional and may be absent for e.g. dynamically-created menus) wxMenu* menu = NULL; // menu for drop down items wxXmlNode* const nodeMenu = nodeDropdown->GetChildren(); - if(nodeMenu) { + if (nodeMenu) { wxObject* res = CreateResFromNode(nodeMenu, NULL); menu = wxDynamicCast(res, wxMenu); } tool->SetHasDropDown(true); - if(menu) { tool->SetUserData(m_menuHandler.RegisterMenu(m_toolbar, GetID(), menu)); } + if (menu) { + tool->SetUserData(m_menuHandler.RegisterMenu(m_toolbar, GetID(), menu)); + } } return m_toolbar; // must return non-NULL } - else if(m_class == wxS("label")) { - if(m_toolbar) { m_toolbar->AddLabel(GetID(), GetText(wxS("label")), GetLong(wxS("width"), -1l)); } + else if (m_class == wxS("label")) { + if (m_toolbar) { + m_toolbar->AddLabel(GetID(), GetText(wxS("label")), GetLong(wxS("width"), -1l)); + } return m_toolbar; } - else if(m_class == wxS("space")) { - if(m_toolbar) { + else if (m_class == wxS("space")) { + if (m_toolbar) { // This may be a stretch spacer (the default) or a non-stretch one which will have the attribute 'width' - if(HasParam("width")) { + if (HasParam("width")) { m_toolbar->AddSpacer(GetLong("width")); } else { m_toolbar->AddStretchSpacer(GetLong(wxS("proportion"), 1l)); @@ -91,8 +109,10 @@ wxObject* MyWxAuiToolBarXmlHandler::DoCreateResource() return m_toolbar; } - else if(m_class == wxT("separator")) { - if(m_toolbar) { m_toolbar->AddSeparator(); } + else if (m_class == wxT("separator")) { + if (m_toolbar) { + m_toolbar->AddSeparator(); + } return m_toolbar; } @@ -104,32 +124,38 @@ wxObject* MyWxAuiToolBarXmlHandler::DoCreateResource() SetupWindow(toolbar); m_toolSize = GetSize(wxT("bitmapsize")); - if(!(m_toolSize == wxDefaultSize)) toolbar->SetToolBitmapSize(m_toolSize); + if (!(m_toolSize == wxDefaultSize)) + toolbar->SetToolBitmapSize(m_toolSize); wxSize margins = GetSize(wxT("margins")); - if(!(margins == wxDefaultSize)) toolbar->SetMargins(margins.x, margins.y); + if (!(margins == wxDefaultSize)) + toolbar->SetMargins(margins.x, margins.y); long packing = GetLong(wxT("packing"), -1); - if(packing != -1) toolbar->SetToolPacking(packing); + if (packing != -1) + toolbar->SetToolPacking(packing); long separation = GetLong(wxT("separation"), -1); - if(separation != -1) toolbar->SetToolSeparation(separation); + if (separation != -1) + toolbar->SetToolSeparation(separation); wxXmlNode* children_node = GetParamNode(wxT("object")); - if(!children_node) children_node = GetParamNode(wxT("object_ref")); + if (!children_node) + children_node = GetParamNode(wxT("object_ref")); - if(children_node == NULL) return toolbar; + if (children_node == NULL) + return toolbar; m_isInside = true; m_toolbar = toolbar; wxXmlNode* n = children_node; - while(n) { - if((n->GetType() == wxXML_ELEMENT_NODE) && - (n->GetName() == wxT("object") || n->GetName() == wxT("object_ref"))) { + while (n) { + if ((n->GetType() == wxXML_ELEMENT_NODE) && + (n->GetName() == wxT("object") || n->GetName() == wxT("object_ref"))) { wxObject* created = CreateResFromNode(n, toolbar, NULL); wxControl* control = wxDynamicCast(created, wxControl); - if(!IsOfClass(n, wxT("tool")) && !IsOfClass(n, wxT("label")) && !IsOfClass(n, wxT("separator")) && - !IsOfClass(n, wxT("space")) && // == AddStretchSpacer() - control != NULL) + if (!IsOfClass(n, wxT("tool")) && !IsOfClass(n, wxT("label")) && !IsOfClass(n, wxT("separator")) && + !IsOfClass(n, wxT("space")) && // == AddStretchSpacer() + control != NULL) toolbar->AddControl(control); } n = n->GetNext(); @@ -153,13 +179,13 @@ bool MyWxAuiToolBarXmlHandler::CanHandle(wxXmlNode* node) // -------------------------- From the official wx3.1 handler ---------------------- void MyWxAuiToolBarXmlHandler::MenuHandler::OnDropDown(wxAuiToolBarEvent& event) { - if(event.IsDropDownClicked()) { + if (event.IsDropDownClicked()) { wxAuiToolBar* toobar = wxDynamicCast(event.GetEventObject(), wxAuiToolBar); - if(toobar != NULL) { + if (toobar != NULL) { wxAuiToolBarItem* item = toobar->FindTool(event.GetId()); - if(item != NULL) { + if (item != NULL) { wxMenu* const menu = m_menus[item->GetUserData()]; - if(menu != NULL) { + if (menu != NULL) { wxPoint pt = event.GetItemRect().GetBottomLeft(); pt.y++; toobar->PopupMenu(menu, pt); diff --git a/wxcrafter/xrc_handlers/myxh_auitoolb.h b/wxcrafter/xrc_handlers/myxh_auitoolb.h index 71dc68dc23..98cc52d84b 100644 --- a/wxcrafter/xrc_handlers/myxh_auitoolb.h +++ b/wxcrafter/xrc_handlers/myxh_auitoolb.h @@ -10,9 +10,10 @@ #ifndef _MY_WX_XH_AUITOOLB_H_ #define _MY_WX_XH_AUITOOLB_H_ -#include #include "wx/aui/auibar.h" #include "wx/menu.h" + +#include #include class wxAuiToolBar; diff --git a/wxcrafter/xrc_handlers/myxh_cmdlinkbtn.cpp b/wxcrafter/xrc_handlers/myxh_cmdlinkbtn.cpp index dcc9402864..47f4efbeb4 100644 --- a/wxcrafter/xrc_handlers/myxh_cmdlinkbtn.cpp +++ b/wxcrafter/xrc_handlers/myxh_cmdlinkbtn.cpp @@ -1,4 +1,5 @@ #include "myxh_cmdlinkbtn.h" + #include MyWxCommandLinkButtonXmlHandler::MyWxCommandLinkButtonXmlHandler() @@ -16,10 +17,19 @@ wxObject* MyWxCommandLinkButtonXmlHandler::DoCreateResource() { XRC_MAKE_INSTANCE(button, wxCommandLinkButton) - button->Create(m_parentAsWindow, GetID(), GetText(wxS("label")), GetText(wxS("note")), GetPosition(), GetSize(), - GetStyle(), wxDefaultValidator, GetName()); + button->Create(m_parentAsWindow, + GetID(), + GetText(wxS("label")), + GetText(wxS("note")), + GetPosition(), + GetSize(), + GetStyle(), + wxDefaultValidator, + GetName()); wxBitmap bmp = GetBitmap(); - if(bmp.IsOk()) { button->SetBitmap(GetBitmap(), wxLEFT); } + if (bmp.IsOk()) { + button->SetBitmap(GetBitmap(), wxLEFT); + } SetupWindow(button); return button; } diff --git a/wxcrafter/xrc_handlers/myxh_dataview.cpp b/wxcrafter/xrc_handlers/myxh_dataview.cpp index 66ec44e231..abd33b65e7 100644 --- a/wxcrafter/xrc_handlers/myxh_dataview.cpp +++ b/wxcrafter/xrc_handlers/myxh_dataview.cpp @@ -1,4 +1,5 @@ #include "myxh_dataview.h" + #include #include #include @@ -18,7 +19,7 @@ MyWxDataViewCtrlHandler::MyWxDataViewCtrlHandler() wxObject* MyWxDataViewCtrlHandler::DoCreateResource() { - if(m_class == "wxDataViewColumn") { + if (m_class == "wxDataViewColumn") { HandleListCol(); } else { @@ -41,7 +42,9 @@ void MyWxDataViewCtrlHandler::HandleListCol() wxDataViewCtrl* const list = wxDynamicCast(m_parentAsWindow, wxDataViewCtrl); wxCHECK_RET(list, wxT("must have wxDataViewCtrl parent")); - if(!HasParam(wxT("coltype"))) { return; } + if (!HasParam(wxT("coltype"))) { + return; + } // Column properties wxString coltype = GetText("coltype"); @@ -52,38 +55,41 @@ void MyWxDataViewCtrlHandler::HandleListCol() wxString cellmode = GetText("cellmode", false); wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT; - if(cellmode == "wxDATAVIEW_CELL_ACTIVATABLE") + if (cellmode == "wxDATAVIEW_CELL_ACTIVATABLE") mode = wxDATAVIEW_CELL_ACTIVATABLE; - else if(cellmode == "") + else if (cellmode == "") mode = wxDATAVIEW_CELL_EDITABLE; wxAlignment al = wxALIGN_LEFT; - if(salign == "wxALIGN_RIGHT") + if (salign == "wxALIGN_RIGHT") al = wxALIGN_RIGHT; - else if(salign == "wxALIGN_CENTER") + else if (salign == "wxALIGN_CENTER") al = wxALIGN_CENTER; - if(coltype == "bitmap") { + if (coltype == "bitmap") { list->AppendBitmapColumn(label, list->GetColumnCount(), mode, colwidth, al, style); - } else if(coltype == "check") { + } else if (coltype == "check") { list->AppendToggleColumn(label, list->GetColumnCount(), mode, colwidth, al, style); - } else if(coltype == "text") { + } else if (coltype == "text") { list->AppendTextColumn(label, list->GetColumnCount(), mode, colwidth, al, style); - } else if(coltype == "icontext") { + } else if (coltype == "icontext") { list->AppendIconTextColumn(label, list->GetColumnCount(), mode, colwidth, al, style); - } else if(coltype == "progress") { + } else if (coltype == "progress") { list->AppendProgressColumn(label, list->GetColumnCount(), mode, colwidth, al, style); - } else if(coltype == "choice") { + } else if (coltype == "choice") { wxString content = GetText("choices", false); wxArrayString choices = ::wxStringTokenize(content, ",", wxTOKEN_STRTOK); list->AppendColumn(new wxDataViewColumn(label, new wxDataViewChoiceRenderer(choices, mode, wxDVR_DEFAULT_ALIGNMENT), - list->GetColumnCount(), colwidth, al, style)); + list->GetColumnCount(), + colwidth, + al, + style)); } } diff --git a/wxcrafter/xrc_handlers/myxh_dlg.cpp b/wxcrafter/xrc_handlers/myxh_dlg.cpp index f769ff594e..b5342e53ed 100644 --- a/wxcrafter/xrc_handlers/myxh_dlg.cpp +++ b/wxcrafter/xrc_handlers/myxh_dlg.cpp @@ -1,6 +1,7 @@ // For compilers that support precompilation, includes "wx.h". +#include + #include "my_dialog.h" -#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop @@ -46,18 +47,27 @@ wxObject* MyWxDialogXmlHandler::DoCreateResource() { XRC_MAKE_INSTANCE(dlg, MyDialog); - dlg->Create(m_parentAsWindow, GetID(), GetText(wxT("title")), wxDefaultPosition, wxDefaultSize, - GetStyle(wxT("style"), wxDEFAULT_DIALOG_STYLE), GetName()); + dlg->Create(m_parentAsWindow, + GetID(), + GetText(wxT("title")), + wxDefaultPosition, + wxDefaultSize, + GetStyle(wxT("style"), wxDEFAULT_DIALOG_STYLE), + GetName()); - if(HasParam(wxT("size"))) dlg->SetClientSize(GetSize(wxT("size"), dlg)); - if(HasParam(wxT("pos"))) dlg->Move(GetPosition()); - if(HasParam(wxT("icon"))) dlg->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON)); + if (HasParam(wxT("size"))) + dlg->SetClientSize(GetSize(wxT("size"), dlg)); + if (HasParam(wxT("pos"))) + dlg->Move(GetPosition()); + if (HasParam(wxT("icon"))) + dlg->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON)); SetupWindow(dlg); CreateChildren(dlg); - if(GetBool(wxT("centered"), false)) dlg->Centre(); + if (GetBool(wxT("centered"), false)) + dlg->Centre(); return dlg; } diff --git a/wxcrafter/xrc_handlers/myxh_dvlistctrl.cpp b/wxcrafter/xrc_handlers/myxh_dvlistctrl.cpp index 26b9163539..92cde82e2b 100644 --- a/wxcrafter/xrc_handlers/myxh_dvlistctrl.cpp +++ b/wxcrafter/xrc_handlers/myxh_dvlistctrl.cpp @@ -1,4 +1,5 @@ #include "myxh_dvlistctrl.h" + #include #include #include @@ -18,7 +19,7 @@ MyWxDataViewListCtrlHandler::MyWxDataViewListCtrlHandler() wxObject* MyWxDataViewListCtrlHandler::DoCreateResource() { - if(m_class == "wxDataViewColumn") { + if (m_class == "wxDataViewColumn") { HandleListCol(); } else { @@ -41,7 +42,9 @@ void MyWxDataViewListCtrlHandler::HandleListCol() wxDataViewListCtrl* const list = wxDynamicCast(m_parentAsWindow, wxDataViewListCtrl); wxCHECK_RET(list, wxT("must have wxDataViewListCtrl parent")); - if(!HasParam(wxT("coltype"))) { return; } + if (!HasParam(wxT("coltype"))) { + return; + } // Column properties wxString coltype = GetText("coltype"); @@ -52,38 +55,41 @@ void MyWxDataViewListCtrlHandler::HandleListCol() wxString cellmode = GetText("cellmode", false); wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT; - if(cellmode == "wxDATAVIEW_CELL_ACTIVATABLE") + if (cellmode == "wxDATAVIEW_CELL_ACTIVATABLE") mode = wxDATAVIEW_CELL_ACTIVATABLE; - else if(cellmode == "") + else if (cellmode == "") mode = wxDATAVIEW_CELL_EDITABLE; wxAlignment al = wxALIGN_LEFT; - if(salign == "wxALIGN_RIGHT") + if (salign == "wxALIGN_RIGHT") al = wxALIGN_RIGHT; - else if(salign == "wxALIGN_CENTER") + else if (salign == "wxALIGN_CENTER") al = wxALIGN_CENTER; - if(coltype == "bitmap") { + if (coltype == "bitmap") { list->AppendBitmapColumn(label, list->GetColumnCount(), mode, colwidth, al, style); - } else if(coltype == "check") { + } else if (coltype == "check") { list->AppendToggleColumn(label, mode, colwidth, al, style); - } else if(coltype == "text") { + } else if (coltype == "text") { list->AppendTextColumn(label, mode, colwidth, al, style); - } else if(coltype == "icontext") { + } else if (coltype == "icontext") { list->AppendIconTextColumn(label, mode, colwidth, al, style); - } else if(coltype == "progress") { + } else if (coltype == "progress") { list->AppendProgressColumn(label, mode, colwidth, al, style); - } else if(coltype == "choice") { + } else if (coltype == "choice") { wxString content = GetText("choices", false); wxArrayString choices = ::wxStringTokenize(content, ",", wxTOKEN_STRTOK); list->AppendColumn(new wxDataViewColumn(label, new wxDataViewChoiceRenderer(choices, mode, wxDVR_DEFAULT_ALIGNMENT), - list->GetColumnCount(), colwidth, al, style)); + list->GetColumnCount(), + colwidth, + al, + style)); } } diff --git a/wxcrafter/xrc_handlers/myxh_frame.cpp b/wxcrafter/xrc_handlers/myxh_frame.cpp index c7f0c0ebc4..cfecaaf14c 100644 --- a/wxcrafter/xrc_handlers/myxh_frame.cpp +++ b/wxcrafter/xrc_handlers/myxh_frame.cpp @@ -1,5 +1,7 @@ #include "myxh_frame.h" + #include "my_frame.h" + #include IMPLEMENT_DYNAMIC_CLASS(wxMyFrameXmlHandler, wxXmlResourceHandler) @@ -44,16 +46,25 @@ wxObject* wxMyFrameXmlHandler::DoCreateResource() { XRC_MAKE_INSTANCE(frame, MyFrame); - frame->Create(m_parentAsWindow, GetID(), GetText(wxT("title")), wxDefaultPosition, wxDefaultSize, - GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE), GetName()); + frame->Create(m_parentAsWindow, + GetID(), + GetText(wxT("title")), + wxDefaultPosition, + wxDefaultSize, + GetStyle(wxT("style"), wxDEFAULT_FRAME_STYLE), + GetName()); - if(HasParam(wxT("size"))) frame->SetClientSize(GetSize(wxT("size"), frame)); - if(HasParam(wxT("pos"))) frame->Move(GetPosition()); - if(HasParam(wxT("icon"))) frame->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON)); + if (HasParam(wxT("size"))) + frame->SetClientSize(GetSize(wxT("size"), frame)); + if (HasParam(wxT("pos"))) + frame->Move(GetPosition()); + if (HasParam(wxT("icon"))) + frame->SetIcons(GetIconBundle(wxT("icon"), wxART_FRAME_ICON)); SetupWindow(frame); CreateChildren(frame); - if(GetBool(wxT("centered"), false)) frame->Centre(); + if (GetBool(wxT("centered"), false)) + frame->Centre(); return frame; } diff --git a/wxcrafter/xrc_handlers/myxh_glcanvas.cpp b/wxcrafter/xrc_handlers/myxh_glcanvas.cpp index 7184601db5..7dbc038778 100644 --- a/wxcrafter/xrc_handlers/myxh_glcanvas.cpp +++ b/wxcrafter/xrc_handlers/myxh_glcanvas.cpp @@ -1,5 +1,6 @@ +#include + #include "OpenGLCanvas.h" -#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop diff --git a/wxcrafter/xrc_handlers/myxh_grid.cpp b/wxcrafter/xrc_handlers/myxh_grid.cpp index 1ac02360c5..613518c584 100644 --- a/wxcrafter/xrc_handlers/myxh_grid.cpp +++ b/wxcrafter/xrc_handlers/myxh_grid.cpp @@ -9,7 +9,8 @@ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" +#include + #include "wxgui_helpers.h" #ifdef __BORLANDC__ @@ -27,6 +28,7 @@ #define wxOVERRIDE override #include "myxh_grid.h" + #include MyWxGridXmlHandler::MyWxGridXmlHandler() @@ -68,16 +70,16 @@ wxObject* MyWxGridXmlHandler::DoCreateResource() // Extract columns info GridColInfo::Vector_t columns; wxXmlNode* columnsNode = GetParamNode(wxT("columns")); - if(columnsNode) { + if (columnsNode) { wxXmlNode* colnode = columnsNode->GetChildren(); - while(colnode) { + while (colnode) { wxXmlNode* colAttr = colnode->GetChildren(); GridColInfo col; - while(colAttr) { - if(colAttr->GetName() == "name") { + while (colAttr) { + if (colAttr->GetName() == "name") { col.label = colAttr->GetNodeContent(); - } else if(colAttr->GetName() == "colsize") { + } else if (colAttr->GetName() == "colsize") { colAttr->GetNodeContent().ToCLong(&col.size); } colAttr = colAttr->GetNext(); @@ -90,16 +92,16 @@ wxObject* MyWxGridXmlHandler::DoCreateResource() // Extract rows info GridRowInfo::Vector_t rows; wxXmlNode* rowsNode = GetParamNode(wxT("rows")); - if(rowsNode) { + if (rowsNode) { wxXmlNode* rownode = rowsNode->GetChildren(); - while(rownode) { + while (rownode) { wxXmlNode* rowAttr = rownode->GetChildren(); GridRowInfo row; - while(rowAttr) { - if(rowAttr->GetName() == "name") { + while (rowAttr) { + if (rowAttr->GetName() == "name") { row.label = rowAttr->GetNodeContent(); - } else if(rowAttr->GetName() == "rowsize") { + } else if (rowAttr->GetName() == "rowsize") { rowAttr->GetNodeContent().ToCLong(&row.size); } rowAttr = rowAttr->GetNext(); @@ -110,24 +112,32 @@ wxObject* MyWxGridXmlHandler::DoCreateResource() } grid->CreateGrid(0, columns.size()); - for(size_t i = 0; i < columns.size(); ++i) { + for (size_t i = 0; i < columns.size(); ++i) { grid->SetColLabelValue(i, columns.at(i).label); - if(columns.at(i).size != -1) { grid->SetColSize(i, columns.at(i).size); } + if (columns.at(i).size != -1) { + grid->SetColSize(i, columns.at(i).size); + } } - if(HasParam(wxT("autosizecol"))) { - if(GetLong(wxT("autosizecol")) == 1) { grid->AutoSizeColumns(); } + if (HasParam(wxT("autosizecol"))) { + if (GetLong(wxT("autosizecol")) == 1) { + grid->AutoSizeColumns(); + } } - if(HasParam(wxT("eidtable"))) { grid->EnableEditing((GetLong(wxT("editable")) == 1)); } + if (HasParam(wxT("eidtable"))) { + grid->EnableEditing((GetLong(wxT("editable")) == 1)); + } // Append the rows - for(size_t i = 0; i < rows.size(); ++i) { + for (size_t i = 0; i < rows.size(); ++i) { int rowid = grid->GetNumberRows(); grid->AppendRows(); grid->SetRowLabelValue(rowid, rows.at(i).label); - if(rows.at(i).size != -1) { grid->SetRowSize(rowid, rows.at(i).size); } + if (rows.at(i).size != -1) { + grid->SetRowSize(rowid, rows.at(i).size); + } } // Alignment @@ -146,9 +156,13 @@ wxObject* MyWxGridXmlHandler::DoCreateResource() long colLabelHeight = GetLong("col-label-size"); long rowLabelWidth = GetLong("row-label-size"); - if(colLabelHeight != -1) { grid->SetColLabelSize(colLabelHeight); } + if (colLabelHeight != -1) { + grid->SetColLabelSize(colLabelHeight); + } - if(rowLabelWidth != -1) { grid->SetRowLabelSize(rowLabelWidth); } + if (rowLabelWidth != -1) { + grid->SetRowLabelSize(rowLabelWidth); + } SetupWindow(grid); return grid; @@ -159,6 +173,8 @@ bool MyWxGridXmlHandler::CanHandle(wxXmlNode* node) { return IsOfClass(node, wxT wxString MyWxGridXmlHandler::GetNodeContent(const wxString& name) { wxXmlNode* node = GetParamNode(name); - if(node) { return node->GetNodeContent(); } + if (node) { + return node->GetNodeContent(); + } return wxEmptyString; } diff --git a/wxcrafter/xrc_handlers/myxh_infobar.cpp b/wxcrafter/xrc_handlers/myxh_infobar.cpp index ff93de5ece..2091673ebd 100644 --- a/wxcrafter/xrc_handlers/myxh_infobar.cpp +++ b/wxcrafter/xrc_handlers/myxh_infobar.cpp @@ -1,4 +1,5 @@ #include "myxh_infobar.h" + #include MyWxInfoBarCtrlHandler::MyWxInfoBarCtrlHandler() @@ -9,7 +10,7 @@ MyWxInfoBarCtrlHandler::MyWxInfoBarCtrlHandler() wxObject* MyWxInfoBarCtrlHandler::DoCreateResource() { - if(m_class == "wxInfoBarButton") { + if (m_class == "wxInfoBarButton") { HandleButton(); } else { @@ -33,7 +34,9 @@ void MyWxInfoBarCtrlHandler::HandleButton() wxString buttonLabel = GetText("label"); int buttonId = GetID(); - if(buttonId != wxNOT_FOUND) { bar->AddButton(buttonId, buttonLabel); } + if (buttonId != wxNOT_FOUND) { + bar->AddButton(buttonId, buttonLabel); + } } wxInfoBar* MyWxInfoBarCtrlHandler::HandleInfoBar() @@ -47,16 +50,16 @@ wxInfoBar* MyWxInfoBarCtrlHandler::HandleInfoBar() int nIconId = wxICON_NONE; - if(iconId == "wxICON_NONE") + if (iconId == "wxICON_NONE") nIconId = wxICON_NONE; - else if(iconId == "wxICON_ERROR") + else if (iconId == "wxICON_ERROR") nIconId = wxICON_ERROR; - else if(iconId == "wxICON_INFORMATION") + else if (iconId == "wxICON_INFORMATION") nIconId = wxICON_INFORMATION; - else if(iconId == "wxICON_WARNING") + else if (iconId == "wxICON_WARNING") nIconId = wxICON_WARNING; infobar->SetName(GetName()); diff --git a/wxcrafter/xrc_handlers/myxh_listc.cpp b/wxcrafter/xrc_handlers/myxh_listc.cpp index 6974a21651..f569669df2 100644 --- a/wxcrafter/xrc_handlers/myxh_listc.cpp +++ b/wxcrafter/xrc_handlers/myxh_listc.cpp @@ -10,6 +10,7 @@ ///////////////////////////////////////////////////////////////////////////// #include "myxh_listc.h" + #include #include #include @@ -62,9 +63,9 @@ MYwxListCtrlXmlHandler::MYwxListCtrlXmlHandler() wxObject* MYwxListCtrlXmlHandler::DoCreateResource() { - if(m_class == LISTITEM_CLASS_NAME) { + if (m_class == LISTITEM_CLASS_NAME) { HandleListItem(); - } else if(m_class == LISTCOL_CLASS_NAME) { + } else if (m_class == LISTCOL_CLASS_NAME) { HandleListCol(); } else { wxASSERT_MSG(m_class == LISTCTRL_CLASS_NAME, wxT("can't handle unknown node")); @@ -83,8 +84,10 @@ bool MYwxListCtrlXmlHandler::CanHandle(wxXmlNode* node) void MYwxListCtrlXmlHandler::HandleCommonItemAttrs(wxListItem& item) { - if(HasParam(wxT("align"))) item.SetAlign((wxListColumnFormat)GetStyle(wxT("align"))); - if(HasParam(wxT("text"))) item.SetText(GetText(wxT("text"))); + if (HasParam(wxT("align"))) + item.SetAlign((wxListColumnFormat)GetStyle(wxT("align"))); + if (HasParam(wxT("text"))) + item.SetText(GetText(wxT("text"))); } void MYwxListCtrlXmlHandler::HandleListCol() @@ -92,13 +95,17 @@ void MYwxListCtrlXmlHandler::HandleListCol() wxListCtrl* const list = wxDynamicCast(m_parentAsWindow, wxListCtrl); wxCHECK_RET(list, wxT("must have wxListCtrl parent")); - if(!list->HasFlag(wxLC_REPORT)) { return; } + if (!list->HasFlag(wxLC_REPORT)) { + return; + } wxListItem item; HandleCommonItemAttrs(item); - if(HasParam(wxT("width"))) item.SetWidth((int)GetLong(wxT("width"))); - if(HasParam(wxT("image"))) item.SetImage((int)GetLong(wxT("image"))); + if (HasParam(wxT("width"))) + item.SetWidth((int)GetLong(wxT("width"))); + if (HasParam(wxT("image"))) + item.SetImage((int)GetLong(wxT("image"))); list->InsertColumn(list->GetColumnCount(), item); } @@ -112,24 +119,32 @@ void MYwxListCtrlXmlHandler::HandleListItem() HandleCommonItemAttrs(item); - if(HasParam(wxT("bg"))) item.SetBackgroundColour(GetColour(wxT("bg"))); - if(HasParam(wxT("col"))) item.SetColumn((int)GetLong(wxT("col"))); - if(HasParam(wxT("data"))) item.SetData(GetLong(wxT("data"))); - if(HasParam(wxT("font"))) item.SetFont(GetFont()); - if(HasParam(wxT("state"))) item.SetState(GetStyle(wxT("state"))); - if(HasParam(wxT("textcolour"))) item.SetTextColour(GetColour(wxT("textcolour"))); - if(HasParam(wxT("textcolor"))) item.SetTextColour(GetColour(wxT("textcolor"))); + if (HasParam(wxT("bg"))) + item.SetBackgroundColour(GetColour(wxT("bg"))); + if (HasParam(wxT("col"))) + item.SetColumn((int)GetLong(wxT("col"))); + if (HasParam(wxT("data"))) + item.SetData(GetLong(wxT("data"))); + if (HasParam(wxT("font"))) + item.SetFont(GetFont()); + if (HasParam(wxT("state"))) + item.SetState(GetStyle(wxT("state"))); + if (HasParam(wxT("textcolour"))) + item.SetTextColour(GetColour(wxT("textcolour"))); + if (HasParam(wxT("textcolor"))) + item.SetTextColour(GetColour(wxT("textcolor"))); // the list control icon style, may be 0 int image; - if(list->HasFlag(wxLC_ICON)) + if (list->HasFlag(wxLC_ICON)) image = GetImageIndex(list, wxIMAGE_LIST_NORMAL); - else if(list->HasFlag(wxLC_SMALL_ICON) || list->HasFlag(wxLC_REPORT) || list->HasFlag(wxLC_LIST)) + else if (list->HasFlag(wxLC_SMALL_ICON) || list->HasFlag(wxLC_REPORT) || list->HasFlag(wxLC_LIST)) image = GetImageIndex(list, wxIMAGE_LIST_SMALL); else image = wxNOT_FOUND; - if(image != wxNOT_FOUND) item.SetImage(image); + if (image != wxNOT_FOUND) + item.SetImage(image); // append the list item to the control item.SetId(list->GetItemCount()); @@ -147,9 +162,11 @@ wxListCtrl* MYwxListCtrlXmlHandler::HandleListCtrl() // we can optionally have normal and/or small image lists wxImageList* imagelist; imagelist = GetImageList(wxT("imagelist")); - if(imagelist) list->AssignImageList(imagelist, wxIMAGE_LIST_NORMAL); + if (imagelist) + list->AssignImageList(imagelist, wxIMAGE_LIST_NORMAL); imagelist = GetImageList(wxT("imagelist-small")); - if(imagelist) list->AssignImageList(imagelist, wxIMAGE_LIST_SMALL); + if (imagelist) + list->AssignImageList(imagelist, wxIMAGE_LIST_SMALL); #endif CreateChildrenPrivately(list); @@ -163,7 +180,7 @@ long MYwxListCtrlXmlHandler::GetImageIndex(wxListCtrl* listctrl, int which) // use different tag names depending on whether we need a normal or small // image wxString bmpParam(wxT("bitmap")), imgParam(wxT("image")); - switch(which) { + switch (which) { case wxIMAGE_LIST_SMALL: bmpParam += wxT("-small"); imgParam += wxT("-small"); @@ -180,14 +197,14 @@ long MYwxListCtrlXmlHandler::GetImageIndex(wxListCtrl* listctrl, int which) // look for either bitmap or image tags int imgIndex = wxNOT_FOUND; - if(HasParam(bmpParam)) { + if (HasParam(bmpParam)) { // we implicitly construct an image list containing the specified // bitmaps wxBitmap bmp = GetBitmap(bmpParam, wxART_OTHER); // create the image list on demand for the first bitmap wxImageList* imgList = listctrl->GetImageList(which); - if(!imgList) { + if (!imgList) { imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight()); listctrl->AssignImageList(imgList, which); } @@ -195,7 +212,7 @@ long MYwxListCtrlXmlHandler::GetImageIndex(wxListCtrl* listctrl, int which) imgIndex = imgList->Add(bmp); } - if(HasParam(imgParam)) { + if (HasParam(imgParam)) { // just use the specified index directly imgIndex = GetLong(imgParam); diff --git a/wxcrafter/xrc_handlers/myxh_mediactrl.cpp b/wxcrafter/xrc_handlers/myxh_mediactrl.cpp index 17ba74b394..7c49a40e8b 100644 --- a/wxcrafter/xrc_handlers/myxh_mediactrl.cpp +++ b/wxcrafter/xrc_handlers/myxh_mediactrl.cpp @@ -1,5 +1,6 @@ +#include + #include "MediaCtrl.h" -#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop diff --git a/wxcrafter/xrc_handlers/myxh_panel.cpp b/wxcrafter/xrc_handlers/myxh_panel.cpp index 6d72d95190..43fc59d057 100644 --- a/wxcrafter/xrc_handlers/myxh_panel.cpp +++ b/wxcrafter/xrc_handlers/myxh_panel.cpp @@ -1,5 +1,7 @@ #include "myxh_panel.h" + #include "my_panel.h" + #include IMPLEMENT_DYNAMIC_CLASS(MyWxPanelXmlHandler, wxXmlResourceHandler) @@ -20,8 +22,8 @@ wxObject* MyWxPanelXmlHandler::DoCreateResource() { XRC_MAKE_INSTANCE(panel, MyPanel) - panel->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style"), wxTAB_TRAVERSAL), - GetName()); + panel->Create( + m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style"), wxTAB_TRAVERSAL), GetName()); SetupWindow(panel); CreateChildren(panel); diff --git a/wxcrafter/xrc_handlers/myxh_propgrid.cpp b/wxcrafter/xrc_handlers/myxh_propgrid.cpp index 3fcb3845d5..e24a307d7c 100644 --- a/wxcrafter/xrc_handlers/myxh_propgrid.cpp +++ b/wxcrafter/xrc_handlers/myxh_propgrid.cpp @@ -32,7 +32,7 @@ MyWxPropGridXmlHandler::MyWxPropGridXmlHandler() wxObject* MyWxPropGridXmlHandler::DoCreateResource() { - if(m_class == wxT("wxPGProperty")) { + if (m_class == wxT("wxPGProperty")) { HandlePgProperty(m_propertyParent); } else { @@ -49,12 +49,12 @@ wxObject* MyWxPropGridXmlHandler::DoCreateResource() // add the splitter property after the children were added int splitterLeft = GetBool("splitterleft"); - if(splitterLeft) { + if (splitterLeft) { m_pgmgr->SetSplitterLeft(); } int splitterPos = GetLong("splitterpos", wxNOT_FOUND); - if(splitterPos != wxNOT_FOUND) { + if (splitterPos != wxNOT_FOUND) { m_pgmgr->GetPage(0)->SetSplitterPosition(splitterPos); } @@ -72,7 +72,7 @@ bool MyWxPropGridXmlHandler::CanHandle(wxXmlNode* node) void MyWxPropGridXmlHandler::HandlePgProperty(wxPGProperty* parent) { - if(!HasParam(wxT("proptype"))) { + if (!HasParam(wxT("proptype"))) { return; } @@ -89,73 +89,73 @@ void MyWxPropGridXmlHandler::HandlePgProperty(wxPGProperty* parent) wxArrayString items = GetArray(GetParamNode("content")); wxPGProperty* prop = NULL; - if(proptype == "wxIntProperty") { + if (proptype == "wxIntProperty") { long v; value.ToLong(&v); prop = DoAppendProperty(parent, new wxIntProperty(label, wxPG_LABEL, v)); - } else if(proptype == "wxFloatProperty") { + } else if (proptype == "wxFloatProperty") { double v; value.ToDouble(&v); prop = DoAppendProperty(parent, new wxFloatProperty(label, wxPG_LABEL, v)); - } else if(proptype == "wxBoolProperty") { + } else if (proptype == "wxBoolProperty") { prop = DoAppendProperty(parent, new wxBoolProperty(label, wxPG_LABEL, value == "1")); - } else if(proptype == "wxStringProperty") { + } else if (proptype == "wxStringProperty") { prop = DoAppendProperty(parent, new wxStringProperty(label, wxPG_LABEL, value)); - } else if(proptype == "wxLongStringProperty") { + } else if (proptype == "wxLongStringProperty") { prop = DoAppendProperty(parent, new wxLongStringProperty(label, wxPG_LABEL, value)); - } else if(proptype == "wxDirProperty") { + } else if (proptype == "wxDirProperty") { prop = DoAppendProperty(parent, new wxDirProperty(label, wxPG_LABEL, value)); - } else if(proptype == "wxArrayStringProperty") { + } else if (proptype == "wxArrayStringProperty") { prop = DoAppendProperty(parent, new wxArrayStringProperty(label, wxPG_LABEL, items)); - } else if(proptype == "wxFileProperty") { + } else if (proptype == "wxFileProperty") { prop = DoAppendProperty(parent, new wxFileProperty(label, wxPG_LABEL, value)); m_pgmgr->SetPropertyAttribute(prop, wxPG_FILE_WILDCARD, wildcard); - } else if(proptype == "wxPropertyCategory") { + } else if (proptype == "wxPropertyCategory") { prop = DoAppendProperty(parent, new wxPropertyCategory(label)); - } else if(proptype == "wxEnumProperty") { + } else if (proptype == "wxEnumProperty") { int sel = items.Index(value); - if(sel == wxNOT_FOUND) { + if (sel == wxNOT_FOUND) { sel = 0; } prop = DoAppendProperty(parent, new wxEnumProperty(label, wxPG_LABEL, items, wxArrayInt(), sel)); - } else if(proptype == "wxEditEnumProperty") { + } else if (proptype == "wxEditEnumProperty") { prop = DoAppendProperty(parent, new wxEditEnumProperty(label, wxPG_LABEL, items, wxArrayInt(), value)); - } else if(proptype == "wxFlagsProperty") { + } else if (proptype == "wxFlagsProperty") { prop = DoAppendProperty(parent, new wxFlagsProperty(label, wxPG_LABEL, items, wxArrayInt(), 0)); - } else if(proptype == "wxDateProperty") { + } else if (proptype == "wxDateProperty") { prop = DoAppendProperty(parent, new wxDateProperty(label, wxPG_LABEL, wxDateTime::Now())); - } else if(proptype == "wxImageFileProperty") { + } else if (proptype == "wxImageFileProperty") { prop = DoAppendProperty(parent, new wxImageFileProperty(label)); - } else if(proptype == "wxFontProperty") { + } else if (proptype == "wxFontProperty") { prop = DoAppendProperty(parent, new wxFontProperty(label)); prop->SetValueToUnspecified(); - } else if(proptype == "wxSystemColourProperty") { + } else if (proptype == "wxSystemColourProperty") { prop = DoAppendProperty(parent, new wxSystemColourProperty(label)); prop->SetValueToUnspecified(); } // Handle nested children - if(prop) { - if(bgcol.IsOk()) { + if (prop) { + if (bgcol.IsOk()) { prop->SetBackgroundColour(bgcol, bgcolRecurse); } - if(!propEditor.IsEmpty()) { + if (!propEditor.IsEmpty()) { prop->SetEditor(propEditor); } prop->SetHelpString(tip); @@ -173,13 +173,13 @@ void MyWxPropGridXmlHandler::HandlePgProperty(wxPGProperty* parent) wxArrayString MyWxPropGridXmlHandler::GetArray(const wxXmlNode* node) const { - if(!node) + if (!node) return wxArrayString(); wxArrayString items; wxXmlNode* child = node->GetChildren(); - while(child) { - if(child->GetName() == "item") { + while (child) { + if (child->GetName() == "item") { items.Add(child->GetNodeContent()); } child = child->GetNext(); @@ -189,7 +189,7 @@ wxArrayString MyWxPropGridXmlHandler::GetArray(const wxXmlNode* node) const wxPGProperty* MyWxPropGridXmlHandler::DoAppendProperty(wxPGProperty* parent, wxPGProperty* prop) { - if(parent) { + if (parent) { return m_pgmgr->GetPage(0)->AppendIn(parent, prop); } else { return m_pgmgr->GetPage(0)->Append(prop); diff --git a/wxcrafter/xrc_handlers/myxh_propgrid.h b/wxcrafter/xrc_handlers/myxh_propgrid.h index 6796a5dfeb..be5609e033 100644 --- a/wxcrafter/xrc_handlers/myxh_propgrid.h +++ b/wxcrafter/xrc_handlers/myxh_propgrid.h @@ -10,8 +10,8 @@ #ifndef _WX_XH_PROPGRID_H_ #define _WX_XH_PROPGRID_H_ -#include #include +#include class wxPGProperty; class wxPropertyGrid; diff --git a/wxcrafter/xrc_handlers/myxh_ribbon.cpp b/wxcrafter/xrc_handlers/myxh_ribbon.cpp index 1724ade3f9..dbaacfbc82 100644 --- a/wxcrafter/xrc_handlers/myxh_ribbon.cpp +++ b/wxcrafter/xrc_handlers/myxh_ribbon.cpp @@ -9,20 +9,20 @@ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" +#include #ifdef __BORLANDC__ #pragma hdrstop #endif #include "myxh_ribbon.h" + #include #include #include #include -#include - #include +#include #ifndef WX_PRECOMP #include @@ -58,23 +58,23 @@ MyWxRibbonXmlHandler::MyWxRibbonXmlHandler() wxObject* MyWxRibbonXmlHandler::DoCreateResource() { - if(m_class == wxT("button")) + if (m_class == wxT("button")) return Handle_button(); - else if(m_class == wxT("tool")) + else if (m_class == wxT("tool")) return Handle_tool(); - else if(m_class == wxT("wxRibbonButtonBar")) + else if (m_class == wxT("wxRibbonButtonBar")) return Handle_buttonbar(); - else if(m_class == wxT("item")) + else if (m_class == wxT("item")) return Handle_galleryitem(); - else if(m_class == wxT("wxRibbonGallery")) + else if (m_class == wxT("wxRibbonGallery")) return Handle_gallery(); - else if(m_class == wxT("wxRibbonPanel") || m_class == wxT("panel")) + else if (m_class == wxT("wxRibbonPanel") || m_class == wxT("panel")) return Handle_panel(); - else if(m_class == wxT("wxRibbonPage") || m_class == wxT("page")) + else if (m_class == wxT("wxRibbonPage") || m_class == wxT("page")) return Handle_page(); - else if(m_class == wxT("wxRibbonBar")) + else if (m_class == wxT("wxRibbonBar")) return Handle_bar(); - else if(m_class == wxT("wxRibbonToolBar")) + else if (m_class == wxT("wxRibbonToolBar")) return Handle_toolbar(); else return Handle_control(); @@ -102,11 +102,11 @@ void MyWxRibbonXmlHandler::Handle_RibbonArtProvider(wxRibbonControl* control) { wxString provider = GetText("art-provider", false); - if(provider == "default" || provider.IsEmpty()) + if (provider == "default" || provider.IsEmpty()) control->SetArtProvider(new wxRibbonDefaultArtProvider); - else if(provider.CmpNoCase("aui") == 0) + else if (provider.CmpNoCase("aui") == 0) control->SetArtProvider(new wxRibbonAUIArtProvider); - else if(provider.CmpNoCase("msw") == 0) + else if (provider.CmpNoCase("msw") == 0) control->SetArtProvider(new wxRibbonMSWArtProvider); else ReportError("invalid ribbon art provider"); @@ -116,7 +116,7 @@ wxObject* MyWxRibbonXmlHandler::Handle_buttonbar() { XRC_MAKE_INSTANCE(buttonBar, wxRibbonButtonBar); - if(!buttonBar->Create(wxDynamicCast(m_parent, wxWindow), GetID(), GetPosition(), GetSize(), GetStyle())) { + if (!buttonBar->Create(wxDynamicCast(m_parent, wxWindow), GetID(), GetPosition(), GetSize(), GetStyle())) { ReportError("could not create ribbon button bar"); } else { buttonBar->SetName(GetName()); @@ -136,7 +136,7 @@ wxObject* MyWxRibbonXmlHandler::Handle_toolbar() { XRC_MAKE_INSTANCE(toolbar, wxRibbonToolBar); - if(!toolbar->Create(wxDynamicCast(m_parent, wxWindow), GetID(), GetPosition(), GetSize(), GetStyle())) { + if (!toolbar->Create(wxDynamicCast(m_parent, wxWindow), GetID(), GetPosition(), GetSize(), GetStyle())) { ReportError("could not create ribbon toolbar"); } else { int minrows = GetLong("minrows", 1); @@ -161,9 +161,10 @@ wxObject* MyWxRibbonXmlHandler::Handle_tool() wxRibbonToolBar* buttonBar = wxStaticCast(m_parent, wxRibbonToolBar); wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL; - if(GetBool(wxT("hybrid"))) kind = wxRIBBON_BUTTON_HYBRID; + if (GetBool(wxT("hybrid"))) + kind = wxRIBBON_BUTTON_HYBRID; - if(GetBool("separator")) { + if (GetBool("separator")) { buttonBar->AddSeparator(); return NULL; } @@ -176,29 +177,33 @@ wxObject* MyWxRibbonXmlHandler::Handle_tool() // check whether we have dropdown tag inside wxMenu* menu = NULL; // menu for drop down items wxXmlNode* const nodeDropdown = GetParamNode("dropdown"); - if(nodeDropdown) { - if(kind == wxRIBBON_BUTTON_NORMAL) kind = wxRIBBON_BUTTON_DROPDOWN; + if (nodeDropdown) { + if (kind == wxRIBBON_BUTTON_NORMAL) + kind = wxRIBBON_BUTTON_DROPDOWN; // also check for the menu specified inside dropdown (it is // optional and may be absent for e.g. dynamically-created // menus) wxXmlNode* const nodeMenu = nodeDropdown->GetChildren(); - if(nodeMenu) { + if (nodeMenu) { wxObject* res = CreateResFromNode(nodeMenu, NULL); menu = wxDynamicCast(res, wxMenu); - if(!menu) { ReportError(nodeMenu, "drop-down tool contents can only be a wxMenu"); } + if (!menu) { + ReportError(nodeMenu, "drop-down tool contents can only be a wxMenu"); + } - if(nodeMenu->GetNext()) { + if (nodeMenu->GetNext()) { ReportError(nodeMenu->GetNext(), "unexpected extra contents under drop-down tool"); } } } - if(!buttonBar->AddTool(GetID(), GetBitmap("bitmap"), GetBitmap("disabled-bitmap"), GetText("help"), kind)) { + if (!buttonBar->AddTool(GetID(), GetBitmap("bitmap"), GetBitmap("disabled-bitmap"), GetText("help"), kind)) { ReportError("could not create button"); } - if(GetBool(wxT("disabled"))) buttonBar->EnableTool(GetID(), false); + if (GetBool(wxT("disabled"))) + buttonBar->EnableTool(GetID(), false); return NULL; // nothing to return } @@ -209,7 +214,8 @@ wxObject* MyWxRibbonXmlHandler::Handle_button() wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL; - if(GetBool(wxT("hybrid"))) kind = wxRIBBON_BUTTON_HYBRID; + if (GetBool(wxT("hybrid"))) + kind = wxRIBBON_BUTTON_HYBRID; // FIXME: The code below uses wxXmlNode directly but this can't be done // in the ribbon library code as it would force it to always link @@ -219,30 +225,40 @@ wxObject* MyWxRibbonXmlHandler::Handle_button() // check whether we have dropdown tag inside wxMenu* menu = NULL; // menu for drop down items wxXmlNode* const nodeDropdown = GetParamNode("dropdown"); - if(nodeDropdown) { - if(kind == wxRIBBON_BUTTON_NORMAL) kind = wxRIBBON_BUTTON_DROPDOWN; + if (nodeDropdown) { + if (kind == wxRIBBON_BUTTON_NORMAL) + kind = wxRIBBON_BUTTON_DROPDOWN; // also check for the menu specified inside dropdown (it is // optional and may be absent for e.g. dynamically-created // menus) wxXmlNode* const nodeMenu = nodeDropdown->GetChildren(); - if(nodeMenu) { + if (nodeMenu) { wxObject* res = CreateResFromNode(nodeMenu, NULL); menu = wxDynamicCast(res, wxMenu); - if(!menu) { ReportError(nodeMenu, "drop-down tool contents can only be a wxMenu"); } + if (!menu) { + ReportError(nodeMenu, "drop-down tool contents can only be a wxMenu"); + } - if(nodeMenu->GetNext()) { + if (nodeMenu->GetNext()) { ReportError(nodeMenu->GetNext(), "unexpected extra contents under drop-down tool"); } } } - if(!buttonBar->AddButton(GetID(), GetText("label"), GetBitmap("bitmap"), GetBitmap("small-bitmap"), - GetBitmap("disabled-bitmap"), GetBitmap("small-disabled-bitmap"), kind, GetText("help"))) { + if (!buttonBar->AddButton(GetID(), + GetText("label"), + GetBitmap("bitmap"), + GetBitmap("small-bitmap"), + GetBitmap("disabled-bitmap"), + GetBitmap("small-disabled-bitmap"), + kind, + GetText("help"))) { ReportError("could not create button"); } - if(GetBool(wxT("disabled"))) buttonBar->EnableButton(GetID(), false); + if (GetBool(wxT("disabled"))) + buttonBar->EnableButton(GetID(), false); return NULL; // nothing to return } @@ -251,9 +267,9 @@ wxObject* MyWxRibbonXmlHandler::Handle_control() { wxRibbonControl* control = wxDynamicCast(m_instance, wxRibbonControl); - if(!m_instance) + if (!m_instance) ReportError("wxRibbonControl must be subclassed"); - else if(!control) + else if (!control) ReportError("controls must derive from wxRibbonControl"); control->Create(wxDynamicCast(m_parent, wxWindow), GetID(), GetPosition(), GetSize(), GetStyle()); @@ -265,13 +281,13 @@ wxObject* MyWxRibbonXmlHandler::Handle_page() { XRC_MAKE_INSTANCE(ribbonPage, wxRibbonPage); - if(!ribbonPage->Create(wxDynamicCast(m_parent, wxRibbonBar), GetID(), GetText("label"), GetBitmap("icon"), - GetStyle())) { + if (!ribbonPage->Create( + wxDynamicCast(m_parent, wxRibbonBar), GetID(), GetText("label"), GetBitmap("icon"), GetStyle())) { ReportError("could not create ribbon page"); } else { ribbonPage->SetName(GetName()); bool selected = GetBool("selected"); - if(selected) { + if (selected) { wxRibbonBar* ribbonbar = wxDynamicCast(m_parent, wxRibbonBar); ribbonbar->SetActivePage(ribbonPage); } @@ -292,7 +308,7 @@ wxObject* MyWxRibbonXmlHandler::Handle_gallery() { XRC_MAKE_INSTANCE(ribbonGallery, wxRibbonGallery); - if(!ribbonGallery->Create(wxDynamicCast(m_parent, wxWindow), GetID(), GetPosition(), GetSize(), GetStyle())) { + if (!ribbonGallery->Create(wxDynamicCast(m_parent, wxWindow), GetID(), GetPosition(), GetSize(), GetStyle())) { ReportError("could not create ribbon gallery"); } else { ribbonGallery->SetName(GetName()); @@ -322,8 +338,13 @@ wxObject* MyWxRibbonXmlHandler::Handle_panel() { XRC_MAKE_INSTANCE(ribbonPanel, wxRibbonPanel); - if(!ribbonPanel->Create(wxDynamicCast(m_parent, wxWindow), GetID(), GetText("label"), GetBitmap("icon"), - GetPosition(), GetSize(), GetStyle("style", wxRIBBON_PANEL_DEFAULT_STYLE))) { + if (!ribbonPanel->Create(wxDynamicCast(m_parent, wxWindow), + GetID(), + GetText("label"), + GetBitmap("icon"), + GetPosition(), + GetSize(), + GetStyle("style", wxRIBBON_PANEL_DEFAULT_STYLE))) { ReportError("could not create ribbon panel"); } else { ribbonPanel->SetName(GetName()); @@ -341,8 +362,11 @@ wxObject* MyWxRibbonXmlHandler::Handle_bar() Handle_RibbonArtProvider(ribbonBar); - if(!ribbonBar->Create(wxDynamicCast(m_parent, wxWindow), GetID(), GetPosition(), GetSize(), - GetStyle("style", wxRIBBON_BAR_DEFAULT_STYLE))) { + if (!ribbonBar->Create(wxDynamicCast(m_parent, wxWindow), + GetID(), + GetPosition(), + GetSize(), + GetStyle("style", wxRIBBON_BAR_DEFAULT_STYLE))) { ReportError("could not create ribbonbar"); } else { ribbonBar->SetName(GetName()); diff --git a/wxcrafter/xrc_handlers/myxh_richtext.cpp b/wxcrafter/xrc_handlers/myxh_richtext.cpp index 9cd9fbe667..67b3777a85 100644 --- a/wxcrafter/xrc_handlers/myxh_richtext.cpp +++ b/wxcrafter/xrc_handlers/myxh_richtext.cpp @@ -9,7 +9,7 @@ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" +#include #ifdef __BORLANDC__ #pragma hdrstop @@ -18,6 +18,7 @@ #if wxUSE_XRC && wxUSE_RICHTEXT #include "myxh_richtext.h" + #include MyWxRichTextCtrlXmlHandler::MyWxRichTextCtrlXmlHandler() @@ -36,12 +37,19 @@ wxObject* MyWxRichTextCtrlXmlHandler::DoCreateResource() { XRC_MAKE_INSTANCE(text, wxRichTextCtrl) - text->Create(m_parentAsWindow, GetID(), GetText(wxT("value")), GetPosition(), GetSize(), GetStyle(), - wxDefaultValidator, GetName()); + text->Create(m_parentAsWindow, + GetID(), + GetText(wxT("value")), + GetPosition(), + GetSize(), + GetStyle(), + wxDefaultValidator, + GetName()); SetupWindow(text); - if(HasParam(wxT("maxlength"))) text->SetMaxLength(GetLong(wxT("maxlength"))); + if (HasParam(wxT("maxlength"))) + text->SetMaxLength(GetLong(wxT("maxlength"))); return text; } diff --git a/wxcrafter/xrc_handlers/myxh_searchctrl.cpp b/wxcrafter/xrc_handlers/myxh_searchctrl.cpp index 8521291003..d390cfb6f6 100644 --- a/wxcrafter/xrc_handlers/myxh_searchctrl.cpp +++ b/wxcrafter/xrc_handlers/myxh_searchctrl.cpp @@ -9,7 +9,7 @@ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" +#include #ifdef __BORLANDC__ #pragma hdrstop @@ -38,14 +38,26 @@ wxObject* MyWxSearchCtrlXmlHandler::DoCreateResource() { XRC_MAKE_INSTANCE(ctrl, wxSearchCtrl) - ctrl->Create(m_parentAsWindow, GetID(), GetText(wxT("value")), GetPosition(), GetSize(), - GetStyle(wxT("style"), wxTE_LEFT), wxDefaultValidator, GetName()); + ctrl->Create(m_parentAsWindow, + GetID(), + GetText(wxT("value")), + GetPosition(), + GetSize(), + GetStyle(wxT("style"), wxTE_LEFT), + wxDefaultValidator, + GetName()); - if(HasParam(wxT("cancelbtn"))) { ctrl->ShowCancelButton(GetLong(wxT("cancelbtn")) == 1); } + if (HasParam(wxT("cancelbtn"))) { + ctrl->ShowCancelButton(GetLong(wxT("cancelbtn")) == 1); + } - if(HasParam(wxT("searchbtn"))) { ctrl->ShowSearchButton(GetLong(wxT("searchbtn")) == 1); } + if (HasParam(wxT("searchbtn"))) { + ctrl->ShowSearchButton(GetLong(wxT("searchbtn")) == 1); + } - if(HasParam(wxT("hint"))) { ctrl->SetHint(GetText("hint")); } + if (HasParam(wxT("hint"))) { + ctrl->SetHint(GetText("hint")); + } SetupWindow(ctrl); return ctrl; diff --git a/wxcrafter/xrc_handlers/myxh_simplebook.cpp b/wxcrafter/xrc_handlers/myxh_simplebook.cpp index cefca9c9b2..ece165b5f9 100644 --- a/wxcrafter/xrc_handlers/myxh_simplebook.cpp +++ b/wxcrafter/xrc_handlers/myxh_simplebook.cpp @@ -1,5 +1,7 @@ #include "myxh_simplebook.h" + #include "wxgui_helpers.h" + #include #include #include @@ -14,19 +16,20 @@ MyWxSimplebookXmlHandler::MyWxSimplebookXmlHandler() wxObject* MyWxSimplebookXmlHandler::DoCreateResource() { - if(m_class == wxT("simplebookpage")) { + if (m_class == wxT("simplebookpage")) { wxXmlNode* n = GetParamNode(wxT("object")); - if(!n) n = GetParamNode(wxT("object_ref")); + if (!n) + n = GetParamNode(wxT("object_ref")); - if(n) { + if (n) { bool old_ins = m_isInside; m_isInside = false; wxObject* item = CreateResFromNode(n, m_notebook, NULL); m_isInside = old_ins; wxWindow* wnd = wxDynamicCast(item, wxWindow); - if(wnd) { + if (wnd) { m_notebook->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")), wxNOT_FOUND); } else diff --git a/wxcrafter/xrc_handlers/myxh_stc.cpp b/wxcrafter/xrc_handlers/myxh_stc.cpp index f8b14b9e28..cad37b83d0 100644 --- a/wxcrafter/xrc_handlers/myxh_stc.cpp +++ b/wxcrafter/xrc_handlers/myxh_stc.cpp @@ -1,7 +1,8 @@ // For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" +#include #include "myxh_stc.h" + #include #include @@ -18,7 +19,7 @@ MyWxStcXmlHandler::MyWxStcXmlHandler() : wxXmlResourceHandler() { AddWindowStyles(); - if(s_lexers.empty()) { + if (s_lexers.empty()) { ADD_LEXER(wxSTC_LEX_CONTAINER); ADD_LEXER(wxSTC_LEX_NULL); ADD_LEXER(wxSTC_LEX_PYTHON); @@ -136,8 +137,8 @@ wxObject* MyWxStcXmlHandler::DoCreateResource() wxFont font = GetFont(); text->StyleClearAll(); - if(font.IsOk()) { - for(int i = 0; i < wxSTC_STYLE_MAX; ++i) { + if (font.IsOk()) { + for (int i = 0; i < wxSTC_STYLE_MAX; ++i) { text->StyleSetFont(i, font); } } @@ -145,11 +146,15 @@ wxObject* MyWxStcXmlHandler::DoCreateResource() text->SetViewEOL(displayEol); text->SetWrapMode(wrapText); - if(eolMode != -1) { text->SetEOLMode(eolMode); } + if (eolMode != -1) { + text->SetEOLMode(eolMode); + } text->SetIndentationGuides(indentGuides); int lexer = wxSTC_LEX_NULL; - if(s_lexers.count(slexerId)) { lexer = s_lexers.find(slexerId)->second; } + if (s_lexers.count(slexerId)) { + lexer = s_lexers.find(slexerId)->second; + } text->SetLexer(lexer); text->SetProperty("fold", "1"); text->SetProperty("fold.html", "1"); diff --git a/wxcrafter/xrc_handlers/myxh_textctrl.cpp b/wxcrafter/xrc_handlers/myxh_textctrl.cpp index 855b06ab1a..63f56bee46 100644 --- a/wxcrafter/xrc_handlers/myxh_textctrl.cpp +++ b/wxcrafter/xrc_handlers/myxh_textctrl.cpp @@ -1,4 +1,5 @@ #include "myxh_textctrl.h" + #include MyTextCtrlXrcHandler::MyTextCtrlXrcHandler() @@ -37,14 +38,23 @@ wxObject* MyTextCtrlXrcHandler::DoCreateResource() { XRC_MAKE_INSTANCE(text, wxTextCtrl) - text->Create(m_parentAsWindow, GetID(), GetText(wxT("value")), GetPosition(), GetSize(), GetStyle(), - wxDefaultValidator, GetName()); + text->Create(m_parentAsWindow, + GetID(), + GetText(wxT("value")), + GetPosition(), + GetSize(), + GetStyle(), + wxDefaultValidator, + GetName()); SetupWindow(text); - if(HasParam(wxT("maxlength"))) text->SetMaxLength(GetLong(wxT("maxlength"))); + if (HasParam(wxT("maxlength"))) + text->SetMaxLength(GetLong(wxT("maxlength"))); - if(HasParam("hint") && !(text->GetWindowStyle() & wxTE_MULTILINE)) { text->SetHint(GetText("hint")); } + if (HasParam("hint") && !(text->GetWindowStyle() & wxTE_MULTILINE)) { + text->SetHint(GetText("hint")); + } return text; } diff --git a/wxcrafter/xrc_handlers/myxh_toolbk.cpp b/wxcrafter/xrc_handlers/myxh_toolbk.cpp index 7f0823face..59cd4ed719 100644 --- a/wxcrafter/xrc_handlers/myxh_toolbk.cpp +++ b/wxcrafter/xrc_handlers/myxh_toolbk.cpp @@ -8,8 +8,9 @@ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". +#include + #include "myxh_toolbk.h" -#include "wx/wxprec.h" #if wxUSE_XRC && wxUSE_TOOLBOOK @@ -40,31 +41,34 @@ MYwxToolbookXmlHandler::MYwxToolbookXmlHandler() wxObject* MYwxToolbookXmlHandler::DoCreateResource() { - if(m_class == wxT("toolbookpage")) { + if (m_class == wxT("toolbookpage")) { wxXmlNode* n = GetParamNode(wxT("object")); - if(!n) n = GetParamNode(wxT("object_ref")); + if (!n) + n = GetParamNode(wxT("object_ref")); - if(n) { + if (n) { bool old_ins = m_isInside; m_isInside = false; wxObject* item = CreateResFromNode(n, m_toolbook, NULL); m_isInside = old_ins; wxWindow* wnd = wxDynamicCast(item, wxWindow); - if(wnd) { + if (wnd) { int imgId = -1; - if(HasParam(wxT("bitmap"))) { + if (HasParam(wxT("bitmap"))) { wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); wxImageList* imgList = m_toolbook->GetImageList(); - if(imgList == NULL) { + if (imgList == NULL) { imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight()); m_toolbook->AssignImageList(imgList); } imgId = imgList->Add(bmp); - } else if(HasParam(wxT("image"))) { - if(m_toolbook->GetImageList()) { imgId = (int)GetLong(wxT("image")); } + } else if (HasParam(wxT("image"))) { + if (m_toolbook->GetImageList()) { + imgId = (int)GetLong(wxT("image")); + } } m_toolbook->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")), imgId); diff --git a/wxcrafter/xrc_handlers/myxh_treebk.cpp b/wxcrafter/xrc_handlers/myxh_treebk.cpp index 5d6a2e7b46..0aceb07e0a 100644 --- a/wxcrafter/xrc_handlers/myxh_treebk.cpp +++ b/wxcrafter/xrc_handlers/myxh_treebk.cpp @@ -9,7 +9,7 @@ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" +#include #ifdef __BORLANDC__ #pragma hdrstop @@ -49,7 +49,7 @@ bool MYwxTreebookXmlHandler::CanHandle(wxXmlNode* node) wxObject* MYwxTreebookXmlHandler::DoCreateResource() { - if(m_class == wxT("wxTreebook")) { + if (m_class == wxT("wxTreebook")) { XRC_MAKE_INSTANCE(tbk, wxTreebook) tbk->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style")), GetName()); @@ -67,11 +67,11 @@ wxObject* MYwxTreebookXmlHandler::DoCreateResource() wxXmlNode* node = GetParamNode(wxT("object")); int pageIndex = 0; - for(unsigned int i = 0; i < m_tbk->GetPageCount(); i++) { - if(m_tbk->GetPage(i)) { + for (unsigned int i = 0; i < m_tbk->GetPageCount(); i++) { + if (m_tbk->GetPage(i)) { wxXmlNode* child = node->GetChildren(); - while(child) { - if(child->GetName() == wxT("expanded") && child->GetNodeContent() == wxT("1")) + while (child) { + if (child->GetName() == wxT("expanded") && child->GetNodeContent() == wxT("1")) m_tbk->ExpandNode(pageIndex, true); child = child->GetNext(); @@ -91,9 +91,10 @@ wxObject* MYwxTreebookXmlHandler::DoCreateResource() wxXmlNode* n = GetParamNode(wxT("object")); wxWindow* wnd = NULL; - if(!n) n = GetParamNode(wxT("object_ref")); + if (!n) + n = GetParamNode(wxT("object_ref")); - if(n) { + if (n) { bool old_ins = m_isInside; m_isInside = false; wxObject* item = CreateResFromNode(n, m_tbk, NULL); @@ -103,19 +104,19 @@ wxObject* MYwxTreebookXmlHandler::DoCreateResource() size_t depth = GetLong(wxT("depth")); - if(depth <= m_treeContext.GetCount()) { + if (depth <= m_treeContext.GetCount()) { // first prepare the icon int imgIndex = wxNOT_FOUND; - if(HasParam(wxT("bitmap"))) { + if (HasParam(wxT("bitmap"))) { wxBitmap bmp = GetBitmap(wxT("bitmap"), wxART_OTHER); wxImageList* imgList = m_tbk->GetImageList(); - if(imgList == NULL) { + if (imgList == NULL) { imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight()); m_tbk->AssignImageList(imgList); } imgIndex = imgList->Add(bmp); - } else if(HasParam(wxT("image"))) { - if(m_tbk->GetImageList()) { + } else if (HasParam(wxT("image"))) { + if (m_tbk->GetImageList()) { imgIndex = GetLong(wxT("image")); } else // image without image list? { @@ -123,12 +124,13 @@ wxObject* MYwxTreebookXmlHandler::DoCreateResource() } // then add the page to the corresponding parent - if(depth < m_treeContext.GetCount()) m_treeContext.RemoveAt(depth, m_treeContext.GetCount() - depth); - if(depth == 0) { + if (depth < m_treeContext.GetCount()) + m_treeContext.RemoveAt(depth, m_treeContext.GetCount() - depth); + if (depth == 0) { m_tbk->AddPage(wnd, GetText(wxT("label")), GetBool(wxT("selected")), imgIndex); } else { - m_tbk->InsertSubPage(m_treeContext.Item(depth - 1), wnd, GetText(wxT("label")), GetBool(wxT("selected")), - imgIndex); + m_tbk->InsertSubPage( + m_treeContext.Item(depth - 1), wnd, GetText(wxT("label")), GetBool(wxT("selected")), imgIndex); } m_treeContext.Add(m_tbk->GetPageCount() - 1); diff --git a/wxcrafter/xrc_handlers/myxh_treelist.cpp b/wxcrafter/xrc_handlers/myxh_treelist.cpp index a3fce5f2c9..3e4f9acc84 100644 --- a/wxcrafter/xrc_handlers/myxh_treelist.cpp +++ b/wxcrafter/xrc_handlers/myxh_treelist.cpp @@ -1,7 +1,9 @@ #include "myxh_treelist.h" + #include "designer_panel.h" #include "wxgui_helpers.h" #include "wxguicraft_main_view.h" + #include #include @@ -24,7 +26,7 @@ bool MyTreeListCtrl::CanHandle(wxXmlNode* node) wxObject* MyTreeListCtrl::DoCreateResource() { - if(m_class == "wxTreeListCtrlCol") { + if (m_class == "wxTreeListCtrlCol") { HandleListCol(); } else { diff --git a/wxcrafter/xrc_handlers/myxh_webview.cpp b/wxcrafter/xrc_handlers/myxh_webview.cpp index 24c3e98042..46e0a7699f 100644 --- a/wxcrafter/xrc_handlers/myxh_webview.cpp +++ b/wxcrafter/xrc_handlers/myxh_webview.cpp @@ -1,4 +1,4 @@ -#include "wx/wxprec.h" +#include #ifdef __BORLANDC__ #pragma hdrstop @@ -27,9 +27,17 @@ wxObject* MyWxWebViewXmlHandler::DoCreateResource() { #if USE_WEBVIEW wxString url = GetText("url", false); - if(url.IsEmpty()) { url = "http://www.google.com"; } - wxWebView* webview = wxWebView::New(m_parentAsWindow, GetID(), url, GetPosition(), GetSize(), - wxWebViewBackendDefault, GetStyle(wxT("style")), GetName()); + if (url.IsEmpty()) { + url = "http://www.google.com"; + } + wxWebView* webview = wxWebView::New(m_parentAsWindow, + GetID(), + url, + GetPosition(), + GetSize(), + wxWebViewBackendDefault, + GetStyle(wxT("style")), + GetName()); #else wxHtmlWindow* webview = new wxHtmlWindow(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT("style")), GetName()); diff --git a/wxformbuilder/confformbuilder.h b/wxformbuilder/confformbuilder.h index e1f717112c..e62ec7b016 100644 --- a/wxformbuilder/confformbuilder.h +++ b/wxformbuilder/confformbuilder.h @@ -1,25 +1,25 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : confformbuilder.h -// +// copyright : (C) 2008 by Eran Ifrah +// file name : confformbuilder.h +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -31,29 +31,20 @@ class ConfFormBuilder : public SerializedObject { - wxString m_fbPath; - wxString m_command; + wxString m_fbPath; + wxString m_command; public: - ConfFormBuilder(); - virtual ~ConfFormBuilder() = default; + ConfFormBuilder(); + virtual ~ConfFormBuilder() = default; public: - virtual void DeSerialize(Archive &arch); - virtual void Serialize(Archive &arch); - + virtual void DeSerialize(Archive& arch); + virtual void Serialize(Archive& arch); - void SetCommand(const wxString& command) { - this->m_command = command; - } - void SetFbPath(const wxString& fbPath) { - this->m_fbPath = fbPath; - } - const wxString& GetCommand() const { - return m_command; - } - const wxString& GetFbPath() const { - return m_fbPath; - } + void SetCommand(const wxString& command) { this->m_command = command; } + void SetFbPath(const wxString& fbPath) { this->m_fbPath = fbPath; } + const wxString& GetCommand() const { return m_command; } + const wxString& GetFbPath() const { return m_fbPath; } }; #endif // __confformbuilder__ diff --git a/wxformbuilder/formbuildsettingsdlg.cpp b/wxformbuilder/formbuildsettingsdlg.cpp index b6e5ccd851..61efd8cf55 100644 --- a/wxformbuilder/formbuildsettingsdlg.cpp +++ b/wxformbuilder/formbuildsettingsdlg.cpp @@ -1,73 +1,81 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : formbuildsettingsdlg.cpp -// +// copyright : (C) 2008 by Eran Ifrah +// file name : formbuildsettingsdlg.cpp +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#include "imanager.h" #include "formbuildsettingsdlg.h" -#include "iconfigtool.h" + #include "confformbuilder.h" +#include "iconfigtool.h" +#include "imanager.h" + #include -FormBuildSettingsDlg::FormBuildSettingsDlg( wxWindow* parent, IManager *mgr ) - : FormBuildSettingsBaseDlg( parent ) - , m_mgr(mgr) +FormBuildSettingsDlg::FormBuildSettingsDlg(wxWindow* parent, IManager* mgr) + : FormBuildSettingsBaseDlg(parent) + , m_mgr(mgr) { - ConfFormBuilder data; - m_mgr->GetConfigTool()->ReadObject(wxT("wxFormBuilder"), &data); - - m_textCtrlCommand->SetValue(data.GetCommand()); - m_textCtrlFBPath->SetValue(data.GetFbPath()); - - m_textCtrlFBPath->SetFocus(); - GetSizer()->Fit(this); + ConfFormBuilder data; + m_mgr->GetConfigTool()->ReadObject(wxT("wxFormBuilder"), &data); + + m_textCtrlCommand->SetValue(data.GetCommand()); + m_textCtrlFBPath->SetValue(data.GetFbPath()); + + m_textCtrlFBPath->SetFocus(); + GetSizer()->Fit(this); } -void FormBuildSettingsDlg::OnButtonBrowse( wxCommandEvent& event ) +void FormBuildSettingsDlg::OnButtonBrowse(wxCommandEvent& event) { - wxUnusedVar(event); - wxString new_path = wxFileSelector(_("Select wxFormBuilder exe:"), m_textCtrlFBPath->GetValue().c_str(), wxT(""), wxT(""), wxFileSelectorDefaultWildcardStr, 0, this); - if (new_path.IsEmpty() == false) { - m_textCtrlFBPath->SetValue(new_path); - } + wxUnusedVar(event); + wxString new_path = wxFileSelector(_("Select wxFormBuilder exe:"), + m_textCtrlFBPath->GetValue().c_str(), + wxT(""), + wxT(""), + wxFileSelectorDefaultWildcardStr, + 0, + this); + if (new_path.IsEmpty() == false) { + m_textCtrlFBPath->SetValue(new_path); + } } -void FormBuildSettingsDlg::OnButtonOK( wxCommandEvent& event ) +void FormBuildSettingsDlg::OnButtonOK(wxCommandEvent& event) { - wxUnusedVar(event); - - // store values - ConfFormBuilder data; - - data.SetCommand(m_textCtrlCommand->GetValue()); - data.SetFbPath(m_textCtrlFBPath->GetValue()); - - m_mgr->GetConfigTool()->WriteObject(wxT("wxFormBuilder"), &data); - EndModal(wxID_OK); + wxUnusedVar(event); + + // store values + ConfFormBuilder data; + + data.SetCommand(m_textCtrlCommand->GetValue()); + data.SetFbPath(m_textCtrlFBPath->GetValue()); + + m_mgr->GetConfigTool()->WriteObject(wxT("wxFormBuilder"), &data); + EndModal(wxID_OK); } -void FormBuildSettingsDlg::OnButtonCancel( wxCommandEvent& event ) +void FormBuildSettingsDlg::OnButtonCancel(wxCommandEvent& event) { - wxUnusedVar(event); - EndModal(wxID_CANCEL); + wxUnusedVar(event); + EndModal(wxID_CANCEL); } diff --git a/wxformbuilder/formbuildsettingsdlg.h b/wxformbuilder/formbuildsettingsdlg.h index 2c90c8ec74..440e8e19d4 100644 --- a/wxformbuilder/formbuildsettingsdlg.h +++ b/wxformbuilder/formbuildsettingsdlg.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : formbuildsettingsdlg.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2008 by Eran Ifrah +// file name : formbuildsettingsdlg.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #ifndef __formbuildsettingsdlg__ #define __formbuildsettingsdlg__ @@ -37,17 +37,17 @@ class IManager; /** Implementing FormBuildSettingsBaseDlg */ class FormBuildSettingsDlg : public FormBuildSettingsBaseDlg { - IManager *m_mgr; - + IManager* m_mgr; + protected: - // Handlers for FormBuildSettingsBaseDlg events. - void OnButtonBrowse( wxCommandEvent& event ); - void OnButtonOK( wxCommandEvent& event ); - void OnButtonCancel( wxCommandEvent& event ); - + // Handlers for FormBuildSettingsBaseDlg events. + void OnButtonBrowse(wxCommandEvent& event); + void OnButtonOK(wxCommandEvent& event); + void OnButtonCancel(wxCommandEvent& event); + public: - /** Constructor */ - FormBuildSettingsDlg( wxWindow* parent, IManager *mgr ); + /** Constructor */ + FormBuildSettingsDlg(wxWindow* parent, IManager* mgr); }; #endif // __formbuildsettingsdlg__ diff --git a/wxformbuilder/wxfbitemdlg.cpp b/wxformbuilder/wxfbitemdlg.cpp index fd9220aa6a..01f9cd8142 100644 --- a/wxformbuilder/wxfbitemdlg.cpp +++ b/wxformbuilder/wxfbitemdlg.cpp @@ -23,11 +23,13 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// +#include "wxfbitemdlg.h" + #include "VirtualDirectorySelectorDlg.h" #include "globals.h" #include "imanager.h" #include "project.h" -#include "wxfbitemdlg.h" + #include #include @@ -36,7 +38,7 @@ wxFBItemDlg::wxFBItemDlg(wxWindow* parent, IManager* mgr) , m_mgr(mgr) { TreeItemInfo item = m_mgr->GetSelectedTreeItemInfo(TreeFileView); - if(item.m_item.IsOk() && item.m_itemType == ProjectItem::TypeVirtualDirectory) { + if (item.m_item.IsOk() && item.m_itemType == ProjectItem::TypeVirtualDirectory) { m_textCtrlVD->SetValue(VirtualDirectorySelectorDlg::DoGetPath(m_mgr->GetWorkspaceTree(), item.m_item, false)); } m_textCtrlClassName->SetFocus(); @@ -47,7 +49,7 @@ void wxFBItemDlg::OnGenerate(wxCommandEvent& event) { wxUnusedVar(event); - if(!IsValidCppIdentifier(m_textCtrlClassName->GetValue())) { + if (!IsValidCppIdentifier(m_textCtrlClassName->GetValue())) { wxMessageBox(_("Invalid C++ class name"), wxT("CodeLite"), wxOK | wxICON_WARNING); return; } @@ -58,7 +60,7 @@ void wxFBItemDlg::OnGenerate(wxCommandEvent& event) void wxFBItemDlg::OnGenerateUI(wxUpdateUIEvent& event) { bool titleCondition; - if(m_textCtrlTitle->IsEnabled()) { + if (m_textCtrlTitle->IsEnabled()) { titleCondition = !m_textCtrlTitle->IsEmpty(); } else { titleCondition = true; @@ -76,7 +78,7 @@ void wxFBItemDlg::OnCancel(wxCommandEvent& event) void wxFBItemDlg::OnBrowseVD(wxCommandEvent& event) { VirtualDirectorySelectorDlg dlg(this, m_mgr->GetWorkspace(), m_textCtrlVD->GetValue()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { m_textCtrlVD->SetValue(dlg.GetVirtualDirectoryPath()); } } diff --git a/wxformbuilder/wxfbitemdlg.h b/wxformbuilder/wxfbitemdlg.h index a83287723d..9e7f8255aa 100644 --- a/wxformbuilder/wxfbitemdlg.h +++ b/wxformbuilder/wxfbitemdlg.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// copyright : (C) 2008 by Eran Ifrah -// file name : wxfbitemdlg.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// copyright : (C) 2008 by Eran Ifrah +// file name : wxfbitemdlg.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #ifndef __wxfbitemdlg__ #define __wxfbitemdlg__ @@ -35,37 +35,38 @@ Subclass of wxFBItemBaseDlg, which is generated by wxFormBuilder. class IManager; enum wxFBItemKind { - wxFBItemKind_Unknown, - wxFBItemKind_Dialog, - wxFBItemKind_Dialog_With_Buttons, - wxFBItemKind_Frame, - wxFBItemKind_Panel + wxFBItemKind_Unknown, + wxFBItemKind_Dialog, + wxFBItemKind_Dialog_With_Buttons, + wxFBItemKind_Frame, + wxFBItemKind_Panel }; struct wxFBItemInfo { - wxString className; - wxString virtualFolder; - wxString title; - wxString file; - wxFBItemKind kind; + wxString className; + wxString virtualFolder; + wxString title; + wxString file; + wxFBItemKind kind; }; /** Implementing wxFBItemBaseDlg */ class wxFBItemDlg : public wxFBItemBaseDlg { - IManager *m_mgr; - + IManager* m_mgr; + protected: - // Handlers for wxFBItemBaseDlg events. - void OnGenerate( wxCommandEvent& event ); - void OnGenerateUI( wxUpdateUIEvent& event ); - void OnCancel( wxCommandEvent& event ); - void OnBrowseVD(wxCommandEvent &event); + // Handlers for wxFBItemBaseDlg events. + void OnGenerate(wxCommandEvent& event); + void OnGenerateUI(wxUpdateUIEvent& event); + void OnCancel(wxCommandEvent& event); + void OnBrowseVD(wxCommandEvent& event); + public: - /** Constructor */ - wxFBItemDlg( wxWindow* parent, IManager *mgr ); - wxFBItemInfo GetData(); - void DisableTitleField(); + /** Constructor */ + wxFBItemDlg(wxWindow* parent, IManager* mgr); + wxFBItemInfo GetData(); + void DisableTitleField(); }; #endif // __wxfbitemdlg__