xref: /trunk/main/cui/source/dialogs/commonlingui.cxx (revision 2ee96f1c)
1*2ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2ee96f1cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2ee96f1cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2ee96f1cSAndrew Rist  * distributed with this work for additional information
6*2ee96f1cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2ee96f1cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2ee96f1cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2ee96f1cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2ee96f1cSAndrew Rist  *
11*2ee96f1cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2ee96f1cSAndrew Rist  *
13*2ee96f1cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2ee96f1cSAndrew Rist  * software distributed under the License is distributed on an
15*2ee96f1cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2ee96f1cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2ee96f1cSAndrew Rist  * specific language governing permissions and limitations
18*2ee96f1cSAndrew Rist  * under the License.
19*2ee96f1cSAndrew Rist  *
20*2ee96f1cSAndrew Rist  *************************************************************/
21*2ee96f1cSAndrew Rist 
22*2ee96f1cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir #include "commonlingui.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <cuires.hrc>
29cdf0e10cSrcweir #include <dialmgr.hxx>
30cdf0e10cSrcweir #include <vcl/decoview.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "hangulhanjadlg.hrc"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir //=============================================================================
35cdf0e10cSrcweir // SvxClickInfoCtr
36cdf0e10cSrcweir //=============================================================================
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //-----------------------------------------------------------------------------
SvxClickInfoCtr(Window * pParent,const ResId & rResId)39cdf0e10cSrcweir SvxClickInfoCtr::SvxClickInfoCtr( Window* pParent, const ResId& rResId ) :
40cdf0e10cSrcweir 		Control( pParent, rResId ),
41cdf0e10cSrcweir 		aFixedInfo( this)
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 	aFixedInfo.SetSizePixel(GetOutputSizePixel());
44cdf0e10cSrcweir 	aFixedInfo.Show();
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //-----------------------------------------------------------------------------
MouseButtonDown(const MouseEvent &)48cdf0e10cSrcweir void SvxClickInfoCtr::MouseButtonDown( const MouseEvent& )
49cdf0e10cSrcweir {
50cdf0e10cSrcweir 	aActivateLink.Call(this);
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //-----------------------------------------------------------------------------
PreNotify(NotifyEvent & rNEvt)54cdf0e10cSrcweir long SvxClickInfoCtr::PreNotify( NotifyEvent& rNEvt )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir 	if(rNEvt.GetType()==EVENT_GETFOCUS || rNEvt.GetType()==EVENT_MOUSEBUTTONDOWN)
57cdf0e10cSrcweir 	{
58cdf0e10cSrcweir 		aActivateLink.Call(this);
59cdf0e10cSrcweir 	}
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	return Control::PreNotify(rNEvt);
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //-----------------------------------------------------------------------------
SetText(const XubString & rStr)65cdf0e10cSrcweir void SvxClickInfoCtr::SetText( const XubString& rStr )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir 	aFixedInfo.SetText(rStr );
68cdf0e10cSrcweir }
69cdf0e10cSrcweir 
70cdf0e10cSrcweir //-----------------------------------------------------------------------------
GetText() const71cdf0e10cSrcweir XubString SvxClickInfoCtr::GetText() const
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 	return aFixedInfo.GetText();
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //-----------------------------------------------------------------------------
~SvxClickInfoCtr()77cdf0e10cSrcweir __EXPORT SvxClickInfoCtr::~SvxClickInfoCtr()
78cdf0e10cSrcweir {
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir //=============================================================================
82cdf0e10cSrcweir // SvxCommonLinguisticControl
83cdf0e10cSrcweir //=============================================================================
84cdf0e10cSrcweir //-----------------------------------------------------------------------------
SvxCommonLinguisticControl(ModalDialog * _pParent)85cdf0e10cSrcweir SvxCommonLinguisticControl::SvxCommonLinguisticControl( ModalDialog* _pParent )
86cdf0e10cSrcweir 	:Window( _pParent, CUI_RES( RID_SVX_WND_COMMON_LINGU ) )
87cdf0e10cSrcweir 	,aWordText		( this,	CUI_RES( FT_WORD ) )
88cdf0e10cSrcweir 	,aAktWord		( this,	CUI_RES( FT_AKTWORD ) )
89cdf0e10cSrcweir 	,aNewWord		( this,	CUI_RES( FT_NEWWORD ) )
90cdf0e10cSrcweir 	,aNewWordED		( this,	CUI_RES( ED_NEWWORD ) )
91cdf0e10cSrcweir 	,aSuggestionFT	( this, CUI_RES( FT_SUGGESTION ) )
92cdf0e10cSrcweir     ,aIgnoreBtn     ( this, CUI_RES( BTN_IGNORE ) )
93cdf0e10cSrcweir 	,aIgnoreAllBtn	( this,	CUI_RES( BTN_IGNOREALL ) )
94cdf0e10cSrcweir 	,aChangeBtn		( this,	CUI_RES( BTN_CHANGE ) )
95cdf0e10cSrcweir 	,aChangeAllBtn	( this,	CUI_RES( BTN_CHANGEALL ) )
96cdf0e10cSrcweir 	,aOptionsBtn	( this, CUI_RES( BTN_OPTIONS ) )
97cdf0e10cSrcweir 	,aStatusText	( this, CUI_RES( FT_STATUS ) )
98cdf0e10cSrcweir     ,aHelpBtn       ( this, CUI_RES( BTN_SPL_HELP ) )
99cdf0e10cSrcweir     ,aCancelBtn     ( this, CUI_RES( BTN_SPL_CANCEL ) )
100cdf0e10cSrcweir     ,aAuditBox      ( this, CUI_RES( GB_AUDIT ) )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	FreeResource();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir #ifdef FS_PRIV_DEBUG
105cdf0e10cSrcweir 	SetType( WINDOW_TABPAGE );
106cdf0e10cSrcweir #endif
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	aAktWord.SetAccessibleName(aWordText.GetText());
109cdf0e10cSrcweir 	SetPosSizePixel( Point( 0, 0 ), _pParent->GetOutputSizePixel() );
110cdf0e10cSrcweir 	Show();
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir // -----------------------------------------------------------------------
implGetButton(ButtonType _eType) const114cdf0e10cSrcweir PushButton*	SvxCommonLinguisticControl::implGetButton( ButtonType _eType  ) const
115cdf0e10cSrcweir {
116cdf0e10cSrcweir 	const PushButton* pButton = NULL;
117cdf0e10cSrcweir 	switch ( _eType )
118cdf0e10cSrcweir 	{
119cdf0e10cSrcweir 		case eClose: pButton = &aCancelBtn; break;
120cdf0e10cSrcweir 		case eIgnore: pButton = &aIgnoreBtn; break;
121cdf0e10cSrcweir 		case eIgnoreAll: pButton = &aIgnoreAllBtn; break;
122cdf0e10cSrcweir 		case eChange: pButton = &aChangeBtn; break;
123cdf0e10cSrcweir 		case eChangeAll: pButton = &aChangeAllBtn; break;
124cdf0e10cSrcweir 		case eOptions: pButton = &aOptionsBtn; break;
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 	return const_cast< PushButton* >( pButton );
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir // -----------------------------------------------------------------------
SetButtonHandler(ButtonType _eType,const Link & _rHandler)130cdf0e10cSrcweir void SvxCommonLinguisticControl::SetButtonHandler( ButtonType _eType, const Link& _rHandler )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir 	Button* pButton = GetButton( _eType );
133cdf0e10cSrcweir 	if ( pButton )
134cdf0e10cSrcweir 		pButton->SetClickHdl( _rHandler );
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // -----------------------------------------------------------------------
EnableButton(ButtonType _eType,sal_Bool _bEnable)138cdf0e10cSrcweir void SvxCommonLinguisticControl::EnableButton( ButtonType _eType, sal_Bool _bEnable )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir 	Button* pButton = GetButton( _eType );
141cdf0e10cSrcweir 	if ( pButton )
142cdf0e10cSrcweir 		pButton->Enable( _bEnable );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir // -----------------------------------------------------------------------
InsertControlGroup(Window & _rFirstGroupWindow,Window & _rLastGroupWindow,ControlGroup _eInsertAfter)146cdf0e10cSrcweir void SvxCommonLinguisticControl::InsertControlGroup( Window& _rFirstGroupWindow, Window& _rLastGroupWindow, ControlGroup _eInsertAfter )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir 	Window* pInsertAfter = NULL;	// will be the last window of our own "undividable" group, after which we insert the foreign group
149cdf0e10cSrcweir 	switch ( _eInsertAfter )
150cdf0e10cSrcweir 	{
151cdf0e10cSrcweir 		case eLeftRightWords	: pInsertAfter = &aNewWordED; break;
152cdf0e10cSrcweir 		case eSuggestionLabel	: pInsertAfter = &aSuggestionFT; break;
153cdf0e10cSrcweir 		case eActionButtons		: pInsertAfter = &aChangeAllBtn; break;
154cdf0e10cSrcweir 		case eDialogButtons		: pInsertAfter = &aCancelBtn; break;
155cdf0e10cSrcweir 	}
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	// now loop through the remaining windows of the foreign group
158cdf0e10cSrcweir 	Window* pInsertBehind = pInsertAfter;
159cdf0e10cSrcweir 	Window* pInsert = &_rFirstGroupWindow;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	// some strange thing below: asking a window for WINDOW_NEXT or WINDOW_PREV does not take into
162cdf0e10cSrcweir 	// account the border window, _but_ SetZOrder _does_!. Thus, when advancing through a chain
163cdf0e10cSrcweir 	// of windows, we need to work with the border windows (WINDOW_BORDER), instead of simply
164cdf0e10cSrcweir 	// asking for WINDOW_NEXT.
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	Window* pLoopEnd = _rLastGroupWindow.GetWindow( WINDOW_BORDER );
167cdf0e10cSrcweir 	while ( pInsert && ( pInsertBehind != pLoopEnd ) )
168cdf0e10cSrcweir 	{
169cdf0e10cSrcweir 		// we'll destroy the NEXT relation immediately, so remember the next window
170cdf0e10cSrcweir 		DBG_ASSERT( pInsert->GetWindow( WINDOW_BORDER ), "SvxCommonLinguisticControl::InsertControlGroup: border window is expected to be non NULL!" );
171cdf0e10cSrcweir 		Window* pNextInsert = pInsert->GetWindow( WINDOW_BORDER )->GetWindow( WINDOW_NEXT );
172cdf0e10cSrcweir 		// knit
173cdf0e10cSrcweir 		pInsert->SetZOrder( pInsertBehind, WINDOW_ZORDER_BEHIND );
174cdf0e10cSrcweir 		// advance
175cdf0e10cSrcweir 		pInsertBehind = pInsert;
176cdf0e10cSrcweir 		pInsert = pNextInsert;
177cdf0e10cSrcweir 	}
178cdf0e10cSrcweir 	DBG_ASSERT( pInsertBehind == pLoopEnd, "SvxCommonLinguisticControl::InsertControlGroup: controls do not form a group!" );
179cdf0e10cSrcweir 		// if we did not reach pLoopEnd, then we did not reach _rLastGroupWindow in the loop, then
180cdf0e10cSrcweir 		// (FirstWindow, LastWindow) was no valid control group
181cdf0e10cSrcweir }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir //-----------------------------------------------------------------------------
Paint(const Rectangle & rRect)184cdf0e10cSrcweir void SvxCommonLinguisticControl::Paint( const Rectangle& rRect )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir 	Window::Paint(rRect );
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	DecorationView aDecoView( this );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 	Rectangle aRect( aAuditBox.GetPosPixel(), aAuditBox.GetSizePixel() );
191cdf0e10cSrcweir 	aDecoView.DrawButton( aRect, BUTTON_DRAW_NOFILL );
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
194cdf0e10cSrcweir //-----------------------------------------------------------------------------
Enlarge(sal_Int32 _nX,sal_Int32 _nY)195cdf0e10cSrcweir void SvxCommonLinguisticControl::Enlarge( sal_Int32 _nX, sal_Int32 _nY )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir 	Size aSize;
198cdf0e10cSrcweir 	Point aPos;
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 	// the controls which need to be resized
201cdf0e10cSrcweir 	{
202cdf0e10cSrcweir 		Window* pResize[] =
203cdf0e10cSrcweir 		{
204cdf0e10cSrcweir 			this, &aAuditBox, &aStatusText
205cdf0e10cSrcweir 		};
206cdf0e10cSrcweir         for ( sal_uInt32 i = 0; i < sizeof( pResize ) / sizeof( pResize[0] ); ++i )
207cdf0e10cSrcweir 		{
208cdf0e10cSrcweir 			aSize = pResize[i]->GetSizePixel( );
209cdf0e10cSrcweir 			pResize[i]->SetSizePixel( Size( aSize.Width() + _nX, aSize.Height() + _nY ) );
210cdf0e10cSrcweir 		}
211cdf0e10cSrcweir 	}
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	// the controls which stick to the bottom of the window
214cdf0e10cSrcweir 	{
215cdf0e10cSrcweir 		Window* pMoveDown[] =
216cdf0e10cSrcweir 		{
217cdf0e10cSrcweir 			&aStatusText, &aHelpBtn, &aCancelBtn
218cdf0e10cSrcweir 		};
219cdf0e10cSrcweir         for ( sal_uInt32 i = 0; i < sizeof( pMoveDown ) / sizeof( pMoveDown[0] ); ++i )
220cdf0e10cSrcweir 		{
221cdf0e10cSrcweir 			aPos = pMoveDown[i]->GetPosPixel();
222cdf0e10cSrcweir 			aPos.Y() += _nY;
223cdf0e10cSrcweir 			pMoveDown[i]->SetPosPixel( aPos );
224cdf0e10cSrcweir 		}
225cdf0e10cSrcweir 	}
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	// the controls which stick to the right
228cdf0e10cSrcweir 	{
229cdf0e10cSrcweir 		Window* pMoveRight[] =
230cdf0e10cSrcweir 		{
231cdf0e10cSrcweir 			&aIgnoreBtn, &aIgnoreAllBtn, &aChangeBtn, &aChangeAllBtn, &aOptionsBtn, &aHelpBtn, &aCancelBtn
232cdf0e10cSrcweir 		};
233cdf0e10cSrcweir         for ( sal_uInt32 i = 0; i < sizeof( pMoveRight ) / sizeof( pMoveRight[0] ); ++i )
234cdf0e10cSrcweir 		{
235cdf0e10cSrcweir 			aPos = pMoveRight[i]->GetPosPixel();
236cdf0e10cSrcweir 			aPos.X() += _nX;
237cdf0e10cSrcweir 			pMoveRight[i]->SetPosPixel( aPos );
238cdf0e10cSrcweir 		}
239cdf0e10cSrcweir 	}
240cdf0e10cSrcweir }
241