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