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