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