Update ooo320-m1
[ooovba.git] / svx / source / cui / commonlingui.cxx
blobd8108f93db090a111539b4ccdfb06a3ff3d961ff
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: commonlingui.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include "commonlingui.hxx"
35 #ifndef _SVX_DIALOGS_HRC
36 #include <svx/dialogs.hrc>
37 #endif
38 #include <svx/dialmgr.hxx>
39 #include <vcl/decoview.hxx>
41 #include "hangulhanjadlg.hrc"
43 //=============================================================================
44 // SvxClickInfoCtr
45 //=============================================================================
47 //-----------------------------------------------------------------------------
48 SvxClickInfoCtr::SvxClickInfoCtr( Window* pParent, const ResId& rResId ) :
49 Control( pParent, rResId ),
50 aFixedInfo( this)
52 aFixedInfo.SetSizePixel(GetOutputSizePixel());
53 aFixedInfo.Show();
56 //-----------------------------------------------------------------------------
57 void SvxClickInfoCtr::MouseButtonDown( const MouseEvent& )
59 aActivateLink.Call(this);
62 //-----------------------------------------------------------------------------
63 long SvxClickInfoCtr::PreNotify( NotifyEvent& rNEvt )
65 if(rNEvt.GetType()==EVENT_GETFOCUS || rNEvt.GetType()==EVENT_MOUSEBUTTONDOWN)
67 aActivateLink.Call(this);
70 return Control::PreNotify(rNEvt);
73 //-----------------------------------------------------------------------------
74 void SvxClickInfoCtr::SetText( const XubString& rStr )
76 aFixedInfo.SetText(rStr );
79 //-----------------------------------------------------------------------------
80 XubString SvxClickInfoCtr::GetText() const
82 return aFixedInfo.GetText();
85 //-----------------------------------------------------------------------------
86 __EXPORT SvxClickInfoCtr::~SvxClickInfoCtr()
90 //=============================================================================
91 // SvxCommonLinguisticControl
92 //=============================================================================
93 //-----------------------------------------------------------------------------
94 SvxCommonLinguisticControl::SvxCommonLinguisticControl( ModalDialog* _pParent )
95 :Window( _pParent, SVX_RES( RID_SVX_WND_COMMON_LINGU ) )
96 ,aWordText ( this, SVX_RES( FT_WORD ) )
97 ,aAktWord ( this, SVX_RES( FT_AKTWORD ) )
98 ,aNewWord ( this, SVX_RES( FT_NEWWORD ) )
99 ,aNewWordED ( this, SVX_RES( ED_NEWWORD ) )
100 ,aSuggestionFT ( this, SVX_RES( FT_SUGGESTION ) )
101 ,aIgnoreBtn ( this, SVX_RES( BTN_IGNORE ) )
102 ,aIgnoreAllBtn ( this, SVX_RES( BTN_IGNOREALL ) )
103 ,aChangeBtn ( this, SVX_RES( BTN_CHANGE ) )
104 ,aChangeAllBtn ( this, SVX_RES( BTN_CHANGEALL ) )
105 ,aOptionsBtn ( this, SVX_RES( BTN_OPTIONS ) )
106 ,aStatusText ( this, SVX_RES( FT_STATUS ) )
107 ,aHelpBtn ( this, SVX_RES( BTN_SPL_HELP ) )
108 ,aCancelBtn ( this, SVX_RES( BTN_SPL_CANCEL ) )
109 ,aAuditBox ( this, SVX_RES( GB_AUDIT ) )
111 FreeResource();
113 #ifdef FS_PRIV_DEBUG
114 SetType( WINDOW_TABPAGE );
115 #endif
117 SetPosSizePixel( Point( 0, 0 ), _pParent->GetOutputSizePixel() );
118 Show();
121 // -----------------------------------------------------------------------
122 PushButton* SvxCommonLinguisticControl::implGetButton( ButtonType _eType ) const
124 const PushButton* pButton = NULL;
125 switch ( _eType )
127 case eClose: pButton = &aCancelBtn; break;
128 case eIgnore: pButton = &aIgnoreBtn; break;
129 case eIgnoreAll: pButton = &aIgnoreAllBtn; break;
130 case eChange: pButton = &aChangeBtn; break;
131 case eChangeAll: pButton = &aChangeAllBtn; break;
132 case eOptions: pButton = &aOptionsBtn; break;
134 return const_cast< PushButton* >( pButton );
137 // -----------------------------------------------------------------------
138 void SvxCommonLinguisticControl::SetButtonHandler( ButtonType _eType, const Link& _rHandler )
140 Button* pButton = GetButton( _eType );
141 if ( pButton )
142 pButton->SetClickHdl( _rHandler );
145 // -----------------------------------------------------------------------
146 void SvxCommonLinguisticControl::EnableButton( ButtonType _eType, sal_Bool _bEnable )
148 Button* pButton = GetButton( _eType );
149 if ( pButton )
150 pButton->Enable( _bEnable );
153 // -----------------------------------------------------------------------
154 void SvxCommonLinguisticControl::InsertControlGroup( Window& _rFirstGroupWindow, Window& _rLastGroupWindow, ControlGroup _eInsertAfter )
156 Window* pInsertAfter = NULL; // will be the last window of our own "undividable" group, after which we insert the foreign group
157 switch ( _eInsertAfter )
159 case eLeftRightWords : pInsertAfter = &aNewWordED; break;
160 case eSuggestionLabel : pInsertAfter = &aSuggestionFT; break;
161 case eActionButtons : pInsertAfter = &aChangeAllBtn; break;
162 case eDialogButtons : pInsertAfter = &aCancelBtn; break;
165 // now loop through the remaining windows of the foreign group
166 Window* pInsertBehind = pInsertAfter;
167 Window* pInsert = &_rFirstGroupWindow;
169 // some strange thing below: asking a window for WINDOW_NEXT or WINDOW_PREV does not take into
170 // account the border window, _but_ SetZOrder _does_!. Thus, when advancing through a chain
171 // of windows, we need to work with the border windows (WINDOW_BORDER), instead of simply
172 // asking for WINDOW_NEXT.
174 Window* pLoopEnd = _rLastGroupWindow.GetWindow( WINDOW_BORDER );
175 while ( pInsert && ( pInsertBehind != pLoopEnd ) )
177 // we'll destroy the NEXT relation immediately, so remember the next window
178 DBG_ASSERT( pInsert->GetWindow( WINDOW_BORDER ), "SvxCommonLinguisticControl::InsertControlGroup: border window is expected to be non NULL!" );
179 Window* pNextInsert = pInsert->GetWindow( WINDOW_BORDER )->GetWindow( WINDOW_NEXT );
180 // knit
181 pInsert->SetZOrder( pInsertBehind, WINDOW_ZORDER_BEHIND );
182 // advance
183 pInsertBehind = pInsert;
184 pInsert = pNextInsert;
186 DBG_ASSERT( pInsertBehind == pLoopEnd, "SvxCommonLinguisticControl::InsertControlGroup: controls do not form a group!" );
187 // if we did not reach pLoopEnd, then we did not reach _rLastGroupWindow in the loop, then
188 // (FirstWindow, LastWindow) was no valid control group
191 // -----------------------------------------------------------------------
192 String SvxCommonLinguisticControl::GetNewEditWord()
194 return aNewWordED.GetText();
197 // -----------------------------------------------------------------------
198 void SvxCommonLinguisticControl::SetNewEditWord( const String& _rNew )
200 aNewWordED.SetText( _rNew );
203 //-----------------------------------------------------------------------------
204 void SvxCommonLinguisticControl::UpdateIgnoreHelp( )
207 String aInfoStr( RTL_CONSTASCII_USTRINGPARAM( ": " ) );
208 aInfoStr.Append( GetCurrentText() );
210 String aString = GetNonMnemonicString( aIgnoreAllBtn.GetText() );
211 aString.Append( aInfoStr );
212 aIgnoreAllBtn.SetQuickHelpText( aString );
214 aString = GetNonMnemonicString( aIgnoreBtn.GetText() );
215 aString.Append( aInfoStr );
216 aIgnoreBtn.SetQuickHelpText( aString );
219 //-----------------------------------------------------------------------------
220 void SvxCommonLinguisticControl::UpdateChangesHelp( const String& _rNewText )
222 String aInfoStr( RTL_CONSTASCII_USTRINGPARAM( ": " ) );
223 aInfoStr.Append( GetCurrentText() );
224 aInfoStr.Append( String( RTL_CONSTASCII_USTRINGPARAM( " -> " ) ) );
225 aInfoStr.Append( _rNewText );
226 // TODO: shouldn't this be part of the resources, for proper localization?
228 String aString = GetNonMnemonicString( aChangeAllBtn.GetText() );
229 aString.Append( aInfoStr );
230 aChangeAllBtn.SetQuickHelpText( aString );
232 aString = GetNonMnemonicString( aChangeBtn.GetText() );
233 aString.Append( aInfoStr );
234 aChangeBtn.SetQuickHelpText( aString );
237 //-----------------------------------------------------------------------------
238 void SvxCommonLinguisticControl::Paint( const Rectangle& rRect )
240 Window::Paint(rRect );
242 DecorationView aDecoView( this );
244 Rectangle aRect( aAuditBox.GetPosPixel(), aAuditBox.GetSizePixel() );
245 aDecoView.DrawButton( aRect, BUTTON_DRAW_NOFILL );
248 //-----------------------------------------------------------------------------
249 void SvxCommonLinguisticControl::Enlarge( sal_Int32 _nX, sal_Int32 _nY )
251 Size aSize;
252 Point aPos;
254 // the controls which need to be resized
256 Window* pResize[] =
258 this, &aAuditBox, &aStatusText
260 for ( sal_uInt32 i = 0; i < sizeof( pResize ) / sizeof( pResize[0] ); ++i )
262 aSize = pResize[i]->GetSizePixel( );
263 pResize[i]->SetSizePixel( Size( aSize.Width() + _nX, aSize.Height() + _nY ) );
267 // the controls which stick to the bottom of the window
269 Window* pMoveDown[] =
271 &aStatusText, &aHelpBtn, &aCancelBtn
273 for ( sal_uInt32 i = 0; i < sizeof( pMoveDown ) / sizeof( pMoveDown[0] ); ++i )
275 aPos = pMoveDown[i]->GetPosPixel();
276 aPos.Y() += _nY;
277 pMoveDown[i]->SetPosPixel( aPos );
281 // the controls which stick to the right
283 Window* pMoveRight[] =
285 &aIgnoreBtn, &aIgnoreAllBtn, &aChangeBtn, &aChangeAllBtn, &aOptionsBtn, &aHelpBtn, &aCancelBtn
287 for ( sal_uInt32 i = 0; i < sizeof( pMoveRight ) / sizeof( pMoveRight[0] ); ++i )
289 aPos = pMoveRight[i]->GetPosPixel();
290 aPos.X() += _nX;
291 pMoveRight[i]->SetPosPixel( aPos );