1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2014 The CodeLite Team
// file name : SpellCheckerSettings.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: SpellCheckerSettings.cpp
// Purpose:
// Author: Frank Lichtner
// Modified by:
// Created: 02/02/14
// SVN-ID: $Id: SpellCheckerSettings.cpp 35 2014-02-22 18:18:49Z Frank $
// Copyright: 2014 Frank Lichtner
// License:
/////////////////////////////////////////////////////////////////////////////
#include <wx/valgen.h>
#include "SpellCheckerSettings.h"
#include "IHunSpell.h"
#include <windowattrmanager.h>
// ------------------------------------------------------------
SpellCheckerSettings::SpellCheckerSettings( wxWindow* parent ) : SpellCheckerSettings_base( parent )
{
m_pHunspell = NULL;
m_dictionaryPath.Empty();
m_pStrings->SetValidator( wxGenericValidator( &m_scanStrings ) );
m_pCppComments->SetValidator( wxGenericValidator( &m_scanCPP ) );
m_pC_Comments->SetValidator( wxGenericValidator( &m_scanC ) );
m_pDox1->SetValidator( wxGenericValidator( &m_scanD1 ) );
m_pDox2->SetValidator( wxGenericValidator( &m_scanD2 ) );
m_pCurrentLanguage->SetValidator( wxGenericValidator( &m_dictionaryFileName ) );
m_pDirPicker->GetTextCtrl()->SetEditable( false );
m_pDirPicker->GetTextCtrl()->SetBackgroundColour( wxColour( 255, 255, 230 ) );
WindowAttrManager::Load(this, "SpellCheckerSettings");
}
// ------------------------------------------------------------
void SpellCheckerSettings::OnInitDialog( wxInitDialogEvent& event )
{
event.Skip();
if( m_pHunspell ) {
m_pDirPicker->SetPath( m_dictionaryPath );
if( !m_dictionaryPath.IsEmpty() )
FillLanguageList();
}
}
// ------------------------------------------------------------
void SpellCheckerSettings::OnLanguageSelected( wxCommandEvent& event )
{
if( m_pHunspell ) {
wxString key = m_pLanguageList->GetString( event.GetInt() );
m_pCurrentLanguage->SetValue( m_pHunspell->GetLanguageShort( key ) );
}
}
// ------------------------------------------------------------
void SpellCheckerSettings::OnUpdateOk( wxUpdateUIEvent& event )
{
int checked = 0;
if( m_pStrings->IsChecked() )
checked++;
if( m_pCppComments->IsChecked() )
checked++;
if( m_pC_Comments->IsChecked() )
checked++;
if( m_pDox1->IsChecked() )
checked++;
if( m_pDox2->IsChecked() )
checked++;
if( checked && !m_pCurrentLanguage->GetValue().IsEmpty() )
event.Enable( true );
else
event.Enable( false );
}
// ------------------------------------------------------------
void SpellCheckerSettings::OnOk( wxCommandEvent& event )
{
event.Skip();
m_dictionaryPath = m_pDirPicker->GetPath();
if( !wxEndsWithPathSeparator( m_dictionaryPath ) )
m_dictionaryPath += wxFILE_SEP_PATH; ;
}
// ------------------------------------------------------------
void SpellCheckerSettings::OnDirChanged( wxFileDirPickerEvent& event )
{
m_dictionaryPath = m_pDirPicker->GetPath();
if( !wxEndsWithPathSeparator( m_dictionaryPath ) )
m_dictionaryPath += wxFILE_SEP_PATH;
m_pLanguageList->Clear();
m_pCurrentLanguage->SetValue( wxT( "" ) );
FillLanguageList();
}
// ------------------------------------------------------------
void SpellCheckerSettings::FillLanguageList()
{
if( !m_dictionaryPath.IsEmpty() ) {
wxArrayString lang;
m_pHunspell->GetAvailableLanguageKeyNames( m_dictionaryPath, lang );
m_pLanguageList->Clear();
m_pLanguageList->Append( lang );
}
}
// ------------------------------------------------------------
void SpellCheckerSettings::OnClearIgnoreList( wxCommandEvent& event )
{
m_pHunspell->ClearIgnoreList();
}
SpellCheckerSettings::~SpellCheckerSettings()
{
WindowAttrManager::Save(this, "SpellCheckerSettings");
}
void SpellCheckerSettings::SetDictionaryPath(const wxString& dictionaryPath)
{
this->m_dictionaryPath = dictionaryPath;
FillLanguageList();
}
// ------------------------------------------------------------
|