2016-02-13 17:06:36 -06:00
# -*- coding: utf-8 -*-
############################################################
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
#
# 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.
#
# This program is distributed in the hope that it will be useful,
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
############################################################
import wx
import application
2016-02-16 17:20:55 -06:00
class spellCheckerDialog ( wx . Dialog ) :
def __init__ ( self ) :
super ( spellCheckerDialog , self ) . __init__ ( None , 1 )
panel = wx . Panel ( self )
sizer = wx . BoxSizer ( wx . VERTICAL )
2016-03-22 11:21:35 -06:00
word = wx . StaticText ( panel , - 1 , _ ( u " &Misspelled word " ) )
2016-02-16 17:20:55 -06:00
self . word = wx . TextCtrl ( panel , - 1 )
wordBox = wx . BoxSizer ( wx . HORIZONTAL )
wordBox . Add ( word , 0 , wx . ALL , 5 )
wordBox . Add ( self . word , 0 , wx . ALL , 5 )
2016-03-22 11:21:35 -06:00
context = wx . StaticText ( panel , - 1 , _ ( u " Con&text " ) )
2016-02-16 17:20:55 -06:00
self . context = wx . TextCtrl ( panel , - 1 )
contextBox = wx . BoxSizer ( wx . HORIZONTAL )
contextBox . Add ( context , 0 , wx . ALL , 5 )
contextBox . Add ( self . context , 0 , wx . ALL , 5 )
2016-03-22 11:21:35 -06:00
suggest = wx . StaticText ( panel , - 1 , _ ( u " &Suggestions " ) )
2016-02-16 17:20:55 -06:00
self . suggestions = wx . ListBox ( panel , - 1 , choices = [ ] , style = wx . LB_SINGLE )
suggestionsBox = wx . BoxSizer ( wx . HORIZONTAL )
suggestionsBox . Add ( suggest , 0 , wx . ALL , 5 )
suggestionsBox . Add ( self . suggestions , 0 , wx . ALL , 5 )
2016-03-22 11:21:35 -06:00
self . ignore = wx . Button ( panel , - 1 , _ ( u " &Ignore " ) )
self . ignoreAll = wx . Button ( panel , - 1 , _ ( u " Ignore &all " ) )
self . replace = wx . Button ( panel , - 1 , _ ( u " &Replace " ) )
self . replaceAll = wx . Button ( panel , - 1 , _ ( u " Replace a&ll " ) )
2016-02-16 17:20:55 -06:00
close = wx . Button ( panel , wx . ID_CANCEL )
btnBox = wx . BoxSizer ( wx . HORIZONTAL )
btnBox . Add ( self . ignore , 0 , wx . ALL , 5 )
btnBox . Add ( self . ignoreAll , 0 , wx . ALL , 5 )
btnBox . Add ( self . replace , 0 , wx . ALL , 5 )
btnBox . Add ( self . replaceAll , 0 , wx . ALL , 5 )
btnBox . Add ( close , 0 , wx . ALL , 5 )
sizer . Add ( wordBox , 0 , wx . ALL , 5 )
sizer . Add ( contextBox , 0 , wx . ALL , 5 )
sizer . Add ( suggestionsBox , 0 , wx . ALL , 5 )
sizer . Add ( btnBox , 0 , wx . ALL , 5 )
panel . SetSizer ( sizer )
self . SetClientSize ( sizer . CalcMin ( ) )
2016-02-13 17:06:36 -06:00
2016-02-16 17:20:55 -06:00
def get_response ( self ) :
return self . ShowModal ( )
2016-02-13 17:06:36 -06:00
2016-02-16 17:20:55 -06:00
def set_title ( self , title ) :
return self . SetTitle ( title )
2016-02-13 17:06:36 -06:00
2016-02-16 17:20:55 -06:00
def set_word_and_suggestions ( self , word , context , suggestions ) :
self . word . SetValue ( word )
self . context . ChangeValue ( context )
self . suggestions . Set ( suggestions )
self . suggestions . SetFocus ( )
2016-02-13 17:06:36 -06:00
2016-02-16 17:20:55 -06:00
def get_selected_suggestion ( self ) :
return self . suggestions . GetStringSelection ( )
2016-02-13 17:06:36 -06:00
def dict_not_found_error ( ) :
2016-02-16 17:20:55 -06:00
wx . MessageDialog ( None , _ ( u " An error has occurred. There are no dictionaries available for the selected language in {0} " ) . format ( application . name , ) , _ ( u " Error " ) , wx . ICON_ERROR ) . ShowModal ( )
2016-02-13 17:06:36 -06:00
def finished ( ) :
2016-02-16 17:20:55 -06:00
wx . MessageDialog ( None , _ ( u " Spell check complete. " ) , application . name , style = wx . OK ) . ShowModal ( )