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