Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add class CFortranIndentConfigDlg to Configure Fortran Indent
Add CFortranIndentConfigDlg.h/.cpp Add Format_Fortran_Indent_Plugin.xrc Add Format_Fortran_Indent_Plugin(-off).png
- Loading branch information
Showing
17 changed files
with
310 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/*************************************************************** | ||
* Name: CFortranIndentConfigDlg.cpp | ||
* Purpose: Class to Configure Fortran Indent Dialog | ||
* Author: YWX (wxFortranIndent@163.com) | ||
* Created: 2012-4-24 | ||
* Copyright: (c) YWX <wxFortranIndent@163.com> | ||
* Licence: GNU General Public License, version 3 | ||
**************************************************************/ | ||
|
||
#include <sdk.h> | ||
#include "CFortranIndentConfigDlg.h" | ||
#include <configmanager.h> | ||
#include <wx/xrc/xmlres.h> | ||
#include <wx/checkbox.h> | ||
#include <wx/spinctrl.h> | ||
#include <string> | ||
|
||
BEGIN_EVENT_TABLE( CFortranIndentConfigDlg, wxPanel ) | ||
EVT_CHECKBOX( XRCID("cb_SameAsEditor"), CFortranIndentConfigDlg::OnIsSameAsEditorClick ) | ||
EVT_CHECKBOX( XRCID("cb_UseTab"), CFortranIndentConfigDlg::OnIsUseTabClick ) | ||
END_EVENT_TABLE() | ||
|
||
CFortranIndentConfigDlg::CFortranIndentConfigDlg(wxWindow* parent) | ||
{ | ||
wxXmlResource::Get()->LoadPanel(this, parent, _T("dlgFortranIndent")); | ||
|
||
LoadSettings(); | ||
} | ||
|
||
CFortranIndentConfigDlg::~CFortranIndentConfigDlg() | ||
{ | ||
} | ||
|
||
void CFortranIndentConfigDlg::LoadSettings() | ||
{ | ||
ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("fortran_indent")); | ||
|
||
bool isSameAsEditor = true; | ||
bool isUseTab = false; | ||
int iTabWidth = 4; | ||
bool isKeepBlankLineOnly = false; | ||
bool isTrimLineFromRight = false; | ||
|
||
if( cfg->Read( _T("is_SameAsEditor"), & isSameAsEditor ) ) | ||
{ | ||
cfg->Read( _T("is_UseTab"), & isUseTab ); | ||
cfg->Read( _T("i_TabWidth"), & iTabWidth ); | ||
cfg->Read( _T("is_KeepBlankLineOnly"), & isKeepBlankLineOnly ); | ||
cfg->Read( _T("is_TrimLineFromRight"), & isTrimLineFromRight ); | ||
} | ||
|
||
XRCCTRL(*this, "cb_SameAsEditor", wxCheckBox)->SetValue( isSameAsEditor ); | ||
XRCCTRL(*this, "cb_UseTab", wxCheckBox)->SetValue( isUseTab ); | ||
XRCCTRL(*this, "cb_UseTab", wxCheckBox)->Enable( ! isSameAsEditor ); | ||
XRCCTRL(*this, "sp_TabWidth", wxSpinCtrl)->SetValue( iTabWidth ); | ||
XRCCTRL(*this, "sp_TabWidth", wxCheckBox)->Enable( ! ( isSameAsEditor || isUseTab ) ); | ||
XRCCTRL(*this, "cb_KeepBlankLineOnly", wxCheckBox)->SetValue( isKeepBlankLineOnly ); | ||
XRCCTRL(*this, "cb_TrimLineFromRight", wxCheckBox)->SetValue( isTrimLineFromRight ); | ||
} | ||
|
||
void CFortranIndentConfigDlg::SaveSettings() | ||
{ | ||
ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("fortran_indent")); | ||
|
||
cfg->Write(_T("is_SameAsEditor"), (bool) XRCCTRL(*this, "cb_SameAsEditor", wxCheckBox)->GetValue()); | ||
cfg->Write(_T("is_UseTab"), (bool) XRCCTRL(*this, "cb_UseTab", wxCheckBox)->GetValue()); | ||
cfg->Write(_T("i_TabWidth"), (int) XRCCTRL(*this, "sp_TabWidth", wxSpinCtrl)->GetValue()); | ||
cfg->Write(_T("is_KeepBlankLineOnly"), (bool) XRCCTRL(*this, "cb_KeepBlankLineOnly", wxCheckBox)->GetValue()); | ||
cfg->Write(_T("is_TrimLineFromRight"), (bool) XRCCTRL(*this, "cb_TrimLineFromRight", wxCheckBox)->GetValue()); | ||
} | ||
|
||
void CFortranIndentConfigDlg::OnIsSameAsEditorClick(wxCommandEvent& event) | ||
{ | ||
bool isSameAsEditor = XRCCTRL(*this, "cb_SameAsEditor", wxCheckBox)->GetValue(); | ||
XRCCTRL(*this, "cb_UseTab", wxCheckBox)->Enable( ! ( isSameAsEditor ) ); | ||
bool isUseTab = XRCCTRL(*this, "cb_UseTab", wxCheckBox)->GetValue(); | ||
XRCCTRL(*this, "sp_TabWidth", wxCheckBox)->Enable( ! ( isSameAsEditor || isUseTab ) ); | ||
} | ||
|
||
void CFortranIndentConfigDlg::OnIsUseTabClick(wxCommandEvent& event) | ||
{ | ||
/// | ||
XRCCTRL(*this, "sp_TabWidth", wxCheckBox)->Enable( ! ( XRCCTRL(*this, "cb_UseTab", wxCheckBox)->GetValue() ) ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*************************************************************** | ||
* Name: CFortranIndentConfigDlg.h | ||
* Purpose: declaration of CFortranIndentConfigDlg class | ||
* Author: YWX (wxFortranIndent@163.com) | ||
* Created: 2012-4-25 | ||
* Copyright: (c) YWX <wxFortranIndent@163.com> | ||
* Licence: GNU General Public License, version 3 | ||
**************************************************************/ | ||
|
||
#ifndef _MY_WX_CFortranIndentConfigDlg_H_ | ||
#define _MY_WX_CFortranIndentConfigDlg_H_ | ||
|
||
#include <wx/intl.h> | ||
#include "configurationpanel.h" | ||
|
||
|
||
struct CMyFortranIndentConfig | ||
{ | ||
bool isSameAsEditor; | ||
bool isUseTab; | ||
int iTabWidth; | ||
bool isKeepBlankLineOnly; | ||
bool isTrimLineFromRight; | ||
|
||
CMyFortranIndentConfig() | ||
{ | ||
reset(); | ||
} | ||
|
||
void reset() | ||
{ | ||
isSameAsEditor = true; | ||
isUseTab = false; | ||
iTabWidth = 4; | ||
isKeepBlankLineOnly = false; | ||
isTrimLineFromRight = false; | ||
} | ||
}; | ||
|
||
|
||
class CFortranIndentConfigDlg : public cbConfigurationPanel | ||
{ | ||
public: | ||
CFortranIndentConfigDlg(wxWindow* parent); | ||
virtual ~CFortranIndentConfigDlg(); | ||
|
||
protected: | ||
virtual wxString GetTitle() const { return _("Fortran Indent"); } | ||
virtual wxString GetBitmapBaseName() const { return _T("Format_Fortran_Indent_Plugin"); } | ||
virtual void OnApply(){ SaveSettings(); } | ||
virtual void OnCancel(){} | ||
|
||
void LoadSettings(); | ||
void SaveSettings(); | ||
|
||
void OnIsSameAsEditorClick(wxCommandEvent& event); | ||
void OnIsUseTabClick(wxCommandEvent& event); | ||
|
||
private: | ||
DECLARE_EVENT_TABLE() | ||
}; | ||
|
||
|
||
#endif // _MY_WX_CFortranIndentConfigDlg_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.