1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_CUI_SOURCE_INC_HANGULHANJADLG_HXX
20 #define INCLUDED_CUI_SOURCE_INC_HANGULHANJADLG_HXX
22 #include <vcl/dialog.hxx>
23 #include <vcl/button.hxx>
24 #include <vcl/lstbox.hxx>
25 #include <vcl/combobox.hxx>
26 #include <vcl/fixed.hxx>
27 #include <vcl/scrbar.hxx>
28 #include <svx/checklbx.hxx>
29 #include <editeng/hangulhanja.hxx>
30 #include <com/sun/star/uno/Sequence.hxx>
31 #include <editeng/unolingu.hxx>
32 #include <com/sun/star/linguistic2/XConversionDictionaryList.hpp>
33 #include <svtools/valueset.hxx>
41 class SuggestionSet
: public ValueSet
44 SuggestionSet( vcl::Window
* pParent
);
45 virtual ~SuggestionSet();
46 virtual void dispose() SAL_OVERRIDE
;
48 virtual void UserDraw( const UserDrawEvent
& rUDEvt
) SAL_OVERRIDE
;
52 class SuggestionDisplay
: public Control
55 SuggestionDisplay( vcl::Window
* pParent
, WinBits nBits
);
56 virtual ~SuggestionDisplay();
57 virtual void dispose() SAL_OVERRIDE
;
59 void DisplayListBox( bool bDisplayListBox
);
61 void SetSelectHdl( const Link
<>& rLink
);
64 void InsertEntry( const OUString
& rStr
);
65 void SelectEntryPos( sal_uInt16 nPos
);
67 sal_uInt16
GetEntryCount() const;
69 OUString
GetEntry( sal_uInt16 nPos
) const;
70 OUString
GetSelectEntry() const;
72 virtual void StateChanged( StateChangedType nStateChange
) SAL_OVERRIDE
;
74 virtual void KeyInput( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
75 virtual void KeyUp( const KeyEvent
& rKEvt
) SAL_OVERRIDE
;
76 virtual void Activate() SAL_OVERRIDE
;
77 virtual void Deactivate() SAL_OVERRIDE
;
78 virtual void GetFocus() SAL_OVERRIDE
;
79 virtual void LoseFocus() SAL_OVERRIDE
;
80 virtual void Command( const CommandEvent
& rCEvt
) SAL_OVERRIDE
;
82 DECL_LINK( SelectSuggestionHdl
, Control
* );
87 void implUpdateDisplay();
88 bool hasCurrentControl();
89 Control
& implGetCurrentControl();
92 bool m_bDisplayListBox
;//otherwise ValueSet
93 VclPtr
<SuggestionSet
> m_aValueSet
;
94 VclPtr
<ListBox
> m_aListBox
;
97 bool m_bInSelectionUpdate
;
100 class RubyRadioButton
;
102 class HangulHanjaConversionDialog
: public ModalDialog
106 VclPtr
<PushButton
> m_pFind
;
107 VclPtr
<PushButton
> m_pIgnore
;
108 VclPtr
<PushButton
> m_pIgnoreAll
;
109 VclPtr
<PushButton
> m_pReplace
;
110 VclPtr
<PushButton
> m_pReplaceAll
;
111 VclPtr
<PushButton
> m_pOptions
;
112 VclPtr
<SuggestionDisplay
> m_pSuggestions
;
113 VclPtr
<RadioButton
> m_pSimpleConversion
;
114 VclPtr
<RadioButton
> m_pHangulBracketed
;
115 VclPtr
<RadioButton
> m_pHanjaBracketed
;
116 VclPtr
<Edit
> m_pWordInput
;
117 VclPtr
<FixedText
> m_pOriginalWord
;
118 VclPtr
<RubyRadioButton
> m_pHanjaAbove
;
119 VclPtr
<RubyRadioButton
> m_pHanjaBelow
;
120 VclPtr
<RubyRadioButton
> m_pHangulAbove
;
121 VclPtr
<RubyRadioButton
> m_pHangulBelow
;
122 VclPtr
<CheckBox
> m_pHangulOnly
;
123 VclPtr
<CheckBox
> m_pHanjaOnly
;
124 VclPtr
<CheckBox
> m_pReplaceByChar
;
126 VclPtr
<CheckBox
> m_pIgnoreNonPrimary
;
127 /** are we working for a document? This is normally true, but in case
128 the user uses the "find" functionality, we switch to working
129 with what the user entered, which then does not have any relation to
130 the document anymore. Some functionality must be disabled then */
131 bool m_bDocumentMode
;
133 Link
<> m_aOptionsChangedLink
;
134 Link
<> m_aClickByCharacterLink
;
137 HangulHanjaConversionDialog(
138 vcl::Window
* _pParent
,
139 editeng::HangulHanjaConversion::ConversionDirection _ePrimaryDirection
);
140 virtual ~HangulHanjaConversionDialog();
141 virtual void dispose() SAL_OVERRIDE
;
144 void SetOptionsChangedHdl( const Link
<>& _rHdl
);
145 void SetIgnoreHdl( const Link
<>& _rHdl
);
146 void SetIgnoreAllHdl( const Link
<>& _rHdl
);
147 void SetChangeHdl( const Link
<>& _rHdl
);
148 void SetChangeAllHdl( const Link
<>& _rHdl
);
150 void SetClickByCharacterHdl( const Link
<>& _rHdl
);
151 void SetConversionFormatChangedHdl( const Link
<>& _rHdl
);
152 void SetFindHdl( const Link
<>& _rHdl
);
154 OUString
GetCurrentString( ) const;
155 void SetCurrentString(
156 const OUString
& _rNewString
,
157 const ::com::sun::star::uno::Sequence
< OUString
>& _rSuggestions
,
158 bool _bOriginatesFromDocument
= true
161 void FocusSuggestion( );
163 /// retrieves the current suggestion
164 OUString
GetCurrentSuggestion( ) const;
166 void SetConversionFormat( editeng::HangulHanjaConversion::ConversionFormat _eType
);
167 editeng::HangulHanjaConversion::ConversionFormat
GetConversionFormat( ) const;
169 void SetByCharacter( bool _bByCharacter
);
170 void SetConversionDirectionState( bool _bTryBothDirections
, editeng::HangulHanjaConversion::ConversionDirection _ePrimaryConversionDirection
);
172 /// should text which does not match the primary conversion direction be ignored?
173 bool GetUseBothDirections( ) const;
175 /** get current conversion direction to use
176 (return argument if GetUseBothDirections is true) */
177 editeng::HangulHanjaConversion::ConversionDirection
GetDirection( editeng::HangulHanjaConversion::ConversionDirection eDefaultDirection
) const;
179 /// enables or disables the checkboxes for ruby formatted replacements
180 void EnableRubySupport( bool bVal
);
183 DECL_LINK( OnClose
, void* );
184 DECL_LINK( OnOption
, void* );
185 DECL_LINK( OnSuggestionModified
, void* );
186 DECL_LINK( OnSuggestionSelected
, void* );
187 DECL_LINK( OnConversionDirectionClicked
, CheckBox
* );
188 DECL_LINK( ClickByCharacterHdl
, CheckBox
* );
190 /// fill the suggestion list box with suggestions for the actual input
191 void FillSuggestions( const ::com::sun::star::uno::Sequence
< OUString
>& _rSuggestions
);
195 typedef ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XConversionDictionary
> > HHDictList
;
197 class HangulHanjaOptionsDialog
: public ModalDialog
200 VclPtr
<SvxCheckListBox
> m_pDictsLB
;
201 VclPtr
<CheckBox
> m_pIgnorepostCB
;
202 VclPtr
<CheckBox
> m_pShowrecentlyfirstCB
;
203 VclPtr
<CheckBox
> m_pAutoreplaceuniqueCB
;
204 VclPtr
<PushButton
> m_pNewPB
;
205 VclPtr
<PushButton
> m_pEditPB
;
206 VclPtr
<PushButton
> m_pDeletePB
;
207 VclPtr
<OKButton
> m_pOkPB
;
209 SvLBoxButtonData
* m_pCheckButtonData
;
211 HHDictList m_aDictList
;
212 ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XConversionDictionaryList
> m_xConversionDictionaryList
;
214 DECL_LINK( OkHdl
, void* );
215 DECL_LINK( OnNew
, void* );
216 DECL_LINK( OnEdit
, void* );
217 DECL_LINK( OnDelete
, void* );
218 DECL_LINK( DictsLB_SelectHdl
, void* );
219 DECL_LINK( NewDictHdl
, void* );
220 DECL_LINK( EditDictHdl
, void* );
221 DECL_LINK( DeleteDictHdl
, void* );
223 void Init(); ///< reads settings from core and init controls
225 HangulHanjaOptionsDialog( vcl::Window
* _pParent
);
226 virtual ~HangulHanjaOptionsDialog();
227 virtual void dispose() SAL_OVERRIDE
;
229 void AddDict( const OUString
& _rName
, bool _bChecked
);
233 class HangulHanjaNewDictDialog
: public ModalDialog
236 VclPtr
<Edit
> m_pDictNameED
;
237 VclPtr
<OKButton
> m_pOkBtn
;
241 DECL_LINK( OKHdl
, void* );
242 DECL_LINK( ModifyHdl
, void* );
244 HangulHanjaNewDictDialog( vcl::Window
* _pParent
);
245 virtual ~HangulHanjaNewDictDialog();
246 virtual void dispose() SAL_OVERRIDE
;
248 bool GetName( OUString
& _rRetName
) const;
252 class SuggestionList
;
254 class SuggestionEdit
: public Edit
257 VclPtr
<SuggestionEdit
> m_pPrev
;
258 VclPtr
<SuggestionEdit
> m_pNext
;
259 VclPtr
<ScrollBar
> m_pScrollBar
;
261 bool ShouldScroll( bool _bUp
) const;
262 void DoJump( bool _bUp
);
264 SuggestionEdit( vcl::Window
* pParent
, WinBits nBits
);
265 virtual ~SuggestionEdit();
266 virtual void dispose() SAL_OVERRIDE
;
267 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
268 void init( ScrollBar
* pScrollBar
, SuggestionEdit
* pPrev
, SuggestionEdit
* pNext
);
272 class HangulHanjaEditDictDialog
: public ModalDialog
275 const OUString m_aEditHintText
;
276 HHDictList
& m_rDictList
;
277 sal_uInt32 m_nCurrentDict
;
279 OUString m_aOriginal
;
280 SuggestionList
* m_pSuggestions
;
282 VclPtr
<ListBox
> m_aBookLB
;
283 VclPtr
<ComboBox
> m_aOriginalLB
;
284 VclPtr
<SuggestionEdit
> m_aEdit1
;
285 VclPtr
<SuggestionEdit
> m_aEdit2
;
286 VclPtr
<SuggestionEdit
> m_aEdit3
;
287 VclPtr
<SuggestionEdit
> m_aEdit4
;
288 VclPtr
<ScrollBar
> m_aScrollSB
;
289 VclPtr
<PushButton
> m_aNewPB
;
290 VclPtr
<PushButton
> m_aDeletePB
;
292 sal_uInt16 m_nTopPos
;
293 bool m_bModifiedSuggestions
;
294 bool m_bModifiedOriginal
;
296 DECL_LINK( OriginalModifyHdl
, void* );
297 DECL_LINK( ScrollHdl
, void* );
298 DECL_LINK( EditModifyHdl1
, Edit
* );
299 DECL_LINK( EditModifyHdl2
, Edit
* );
300 DECL_LINK( EditModifyHdl3
, Edit
* );
301 DECL_LINK( EditModifyHdl4
, Edit
* );
303 DECL_LINK( BookLBSelectHdl
, void* );
304 DECL_LINK( NewPBPushHdl
, void* );
305 DECL_LINK( DeletePBPushHdl
, void* );
307 void InitEditDictDialog( sal_uInt32 _nSelDict
);
308 void UpdateOriginalLB();
309 void UpdateSuggestions();
310 void UpdateButtonStates();
312 void SetEditText( Edit
& _rEdit
, sal_uInt16 _nEntryNum
);
313 void EditModify( Edit
* _pEdit
, sal_uInt8 _nEntryOffset
);
314 void EditFocusLost( Edit
* _pEdit
, sal_uInt8 _nEntryOffset
);
316 bool DeleteEntryFromDictionary( const OUString
& rEntry
, const ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XConversionDictionary
>& xDict
);
319 HangulHanjaEditDictDialog( vcl::Window
* _pParent
, HHDictList
& _rDictList
, sal_uInt32 _nSelDict
);
320 virtual ~HangulHanjaEditDictDialog();
321 virtual void dispose() SAL_OVERRIDE
;
323 void UpdateScrollbar();
330 #endif // SVX_HANGUL_HANJA_HXX
332 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */