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 31*cdf0e10cSrcweir #include <optaccessibility.hxx> 32*cdf0e10cSrcweir #include <optaccessibility.hrc> 33*cdf0e10cSrcweir #include <dialmgr.hxx> 34*cdf0e10cSrcweir #include <cuires.hrc> 35*cdf0e10cSrcweir #include <svtools/accessibilityoptions.hxx> 36*cdf0e10cSrcweir #include <vcl/settings.hxx> 37*cdf0e10cSrcweir #include <vcl/svapp.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir static void MovePosY( Window& _rWin, long _nDelta ) 40*cdf0e10cSrcweir { 41*cdf0e10cSrcweir Point aPoint = _rWin.GetPosPixel(); 42*cdf0e10cSrcweir aPoint.Y() += _nDelta; 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir _rWin.SetPosPixel( aPoint ); 45*cdf0e10cSrcweir } 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir struct SvxAccessibilityOptionsTabPage_Impl 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir SvtAccessibilityOptions m_aConfig; 50*cdf0e10cSrcweir SvxAccessibilityOptionsTabPage_Impl() 51*cdf0e10cSrcweir : m_aConfig(){} 52*cdf0e10cSrcweir }; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir SvxAccessibilityOptionsTabPage::SvxAccessibilityOptionsTabPage( Window* pParent, const SfxItemSet& rSet ) 55*cdf0e10cSrcweir :SfxTabPage(pParent, CUI_RES( RID_SVXPAGE_ACCESSIBILITYCONFIG ), rSet) 56*cdf0e10cSrcweir ,m_aMiscellaneousLabel (this, CUI_RES(FL_MISCELLANEOUS )) 57*cdf0e10cSrcweir ,m_aAccessibilityTool (this, CUI_RES(CB_ACCESSIBILITY_TOOL )) 58*cdf0e10cSrcweir ,m_aTextSelectionInReadonly (this, CUI_RES(CB_TEXTSELECTION )) 59*cdf0e10cSrcweir ,m_aAnimatedGraphics (this, CUI_RES(CB_ANIMATED_GRAPHICS )) 60*cdf0e10cSrcweir ,m_aAnimatedTexts (this, CUI_RES(CB_ANIMATED_TEXTS )) 61*cdf0e10cSrcweir ,m_aTipHelpCB (this, CUI_RES(CB_TIPHELP )) 62*cdf0e10cSrcweir ,m_aTipHelpNF (this, CUI_RES(NF_TIPHELP )) 63*cdf0e10cSrcweir ,m_aTipHelpFT (this, CUI_RES(FT_TIPHELP )) 64*cdf0e10cSrcweir ,m_aHCOptionsLabel (this, CUI_RES(FL_HC_OPTIONS )) 65*cdf0e10cSrcweir ,m_aAutoDetectHC (this, CUI_RES(CB_AUTO_DETECT_HC )) 66*cdf0e10cSrcweir ,m_aAutomaticFontColor (this, CUI_RES(CB_AUTOMATIC_FONT_COLOR)) 67*cdf0e10cSrcweir ,m_aPagePreviews (this, CUI_RES(CB_PAGE_PREVIEWS )) 68*cdf0e10cSrcweir ,m_pImpl(new SvxAccessibilityOptionsTabPage_Impl) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir FreeResource(); 71*cdf0e10cSrcweir m_aTipHelpCB.SetClickHdl(LINK(this, SvxAccessibilityOptionsTabPage, TipHelpHdl)); 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir long nHeightDelta = 0; // to correct positions _under_ m_aAccessibilityTool 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir #ifdef UNX 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir // UNIX: read the gconf2 setting instead to use the checkbox 78*cdf0e10cSrcweir m_aAccessibilityTool.Hide(); 79*cdf0e10cSrcweir nHeightDelta = -( ROWA_2 - ROWA_1 ); 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir #else 82*cdf0e10cSrcweir // calculate the height of the checkbox. Do we need two (default in resource) or only one line 83*cdf0e10cSrcweir String aText = m_aAccessibilityTool.GetText(); 84*cdf0e10cSrcweir long nWidth = m_aAccessibilityTool.GetTextWidth( aText ); 85*cdf0e10cSrcweir long nCtrlWidth = m_aAccessibilityTool.GetSizePixel().Width() - ( COL2 - COL1 ); 86*cdf0e10cSrcweir if ( nWidth > nCtrlWidth ) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir long nDelta = 2 * RSC_CD_FIXEDLINE_HEIGHT + LINESPACE - RSC_CD_CHECKBOX_HEIGHT; 89*cdf0e10cSrcweir nHeightDelta = nDelta; 90*cdf0e10cSrcweir Size aSize = m_aAccessibilityTool.LogicToPixel( Size( 0, nDelta ), MAP_APPFONT ); 91*cdf0e10cSrcweir nDelta = aSize.Height(); 92*cdf0e10cSrcweir aSize = m_aAccessibilityTool.GetSizePixel(); 93*cdf0e10cSrcweir aSize.Height() += nDelta; 94*cdf0e10cSrcweir m_aAccessibilityTool.SetSizePixel( aSize ); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir #endif 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir if( nHeightDelta ) 99*cdf0e10cSrcweir { //adjust positions of controls under m_aAccessibilityTool 100*cdf0e10cSrcweir Size aSize = m_aAccessibilityTool.LogicToPixel( Size( 0, nHeightDelta ), MAP_APPFONT ); 101*cdf0e10cSrcweir nHeightDelta = aSize.Height(); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir MovePosY( m_aTextSelectionInReadonly, nHeightDelta ); 104*cdf0e10cSrcweir MovePosY( m_aAnimatedGraphics, nHeightDelta ); 105*cdf0e10cSrcweir MovePosY( m_aAnimatedTexts, nHeightDelta ); 106*cdf0e10cSrcweir MovePosY( m_aTipHelpCB, nHeightDelta ); 107*cdf0e10cSrcweir MovePosY( m_aTipHelpNF, nHeightDelta ); 108*cdf0e10cSrcweir MovePosY( m_aTipHelpFT, nHeightDelta ); 109*cdf0e10cSrcweir MovePosY( m_aHCOptionsLabel, nHeightDelta ); 110*cdf0e10cSrcweir MovePosY( m_aAutoDetectHC, nHeightDelta ); 111*cdf0e10cSrcweir MovePosY( m_aAutomaticFontColor, nHeightDelta ); 112*cdf0e10cSrcweir MovePosY( m_aPagePreviews, nHeightDelta ); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir SvxAccessibilityOptionsTabPage::~SvxAccessibilityOptionsTabPage() 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir delete m_pImpl; 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir SfxTabPage* SvxAccessibilityOptionsTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet ) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir return new SvxAccessibilityOptionsTabPage(pParent, rAttrSet); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir sal_Bool SvxAccessibilityOptionsTabPage::FillItemSet( SfxItemSet& ) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir //aConfig.Set... from controls 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir m_pImpl->m_aConfig.SetIsForPagePreviews( m_aPagePreviews.IsChecked() ); 131*cdf0e10cSrcweir m_pImpl->m_aConfig.SetIsHelpTipsDisappear( m_aTipHelpCB.IsChecked() ); 132*cdf0e10cSrcweir m_pImpl->m_aConfig.SetHelpTipSeconds( (short)m_aTipHelpNF.GetValue() ); 133*cdf0e10cSrcweir m_pImpl->m_aConfig.SetIsAllowAnimatedGraphics( m_aAnimatedGraphics.IsChecked() ); 134*cdf0e10cSrcweir m_pImpl->m_aConfig.SetIsAllowAnimatedText( m_aAnimatedTexts.IsChecked() ); 135*cdf0e10cSrcweir m_pImpl->m_aConfig.SetIsAutomaticFontColor( m_aAutomaticFontColor.IsChecked() ); 136*cdf0e10cSrcweir m_pImpl->m_aConfig.SetSelectionInReadonly( m_aTextSelectionInReadonly.IsChecked()); 137*cdf0e10cSrcweir m_pImpl->m_aConfig.SetAutoDetectSystemHC( m_aAutoDetectHC.IsChecked()); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir if(m_pImpl->m_aConfig.IsModified()) 140*cdf0e10cSrcweir m_pImpl->m_aConfig.Commit(); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir AllSettings aAllSettings = Application::GetSettings(); 143*cdf0e10cSrcweir MiscSettings aMiscSettings = aAllSettings.GetMiscSettings(); 144*cdf0e10cSrcweir #ifndef UNX 145*cdf0e10cSrcweir aMiscSettings.SetEnableATToolSupport( m_aAccessibilityTool.IsChecked() ); 146*cdf0e10cSrcweir #endif 147*cdf0e10cSrcweir aAllSettings.SetMiscSettings(aMiscSettings); 148*cdf0e10cSrcweir Application::MergeSystemSettings( aAllSettings ); 149*cdf0e10cSrcweir Application::SetSettings(aAllSettings); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir return sal_False; 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir void SvxAccessibilityOptionsTabPage::Reset( const SfxItemSet& ) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir //set controls from aConfig.Get... 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir m_aPagePreviews.Check( m_pImpl->m_aConfig.GetIsForPagePreviews() ); 159*cdf0e10cSrcweir EnableTipHelp( m_pImpl->m_aConfig.GetIsHelpTipsDisappear() ); 160*cdf0e10cSrcweir m_aTipHelpNF.SetValue( m_pImpl->m_aConfig.GetHelpTipSeconds() ); 161*cdf0e10cSrcweir m_aAnimatedGraphics.Check( m_pImpl->m_aConfig.GetIsAllowAnimatedGraphics() ); 162*cdf0e10cSrcweir m_aAnimatedTexts.Check( m_pImpl->m_aConfig.GetIsAllowAnimatedText() ); 163*cdf0e10cSrcweir m_aAutomaticFontColor.Check( m_pImpl->m_aConfig.GetIsAutomaticFontColor() ); 164*cdf0e10cSrcweir // m_aSystemFont.Check( m_pImpl->m_aConfig.GetIsSystemFont() ); 165*cdf0e10cSrcweir m_aTextSelectionInReadonly.Check( m_pImpl->m_aConfig.IsSelectionInReadonly() ); 166*cdf0e10cSrcweir m_aAutoDetectHC.Check( m_pImpl->m_aConfig.GetAutoDetectSystemHC() ); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir AllSettings aAllSettings = Application::GetSettings(); 170*cdf0e10cSrcweir MiscSettings aMiscSettings = aAllSettings.GetMiscSettings(); 171*cdf0e10cSrcweir m_aAccessibilityTool.Check( aMiscSettings.GetEnableATToolSupport() ); 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir IMPL_LINK(SvxAccessibilityOptionsTabPage, TipHelpHdl, CheckBox*, pBox) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir sal_Bool bChecked = pBox->IsChecked(); 177*cdf0e10cSrcweir m_aTipHelpNF.Enable(bChecked); 178*cdf0e10cSrcweir return 0; 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir void SvxAccessibilityOptionsTabPage::EnableTipHelp(sal_Bool bCheck) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir m_aTipHelpCB.Check(bCheck); 184*cdf0e10cSrcweir m_aTipHelpNF.Enable(bCheck); 185*cdf0e10cSrcweir } 186