1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 #include <optaccessibility.hxx>
32 #include <optaccessibility.hrc>
33 #include <dialmgr.hxx>
35 #include <svtools/accessibilityoptions.hxx>
36 #include <vcl/settings.hxx>
37 #include <vcl/svapp.hxx>
39 static void MovePosY( Window
& _rWin
, long _nDelta
)
41 Point aPoint
= _rWin
.GetPosPixel();
42 aPoint
.Y() += _nDelta
;
44 _rWin
.SetPosPixel( aPoint
);
47 struct SvxAccessibilityOptionsTabPage_Impl
49 SvtAccessibilityOptions m_aConfig
;
50 SvxAccessibilityOptionsTabPage_Impl()
54 SvxAccessibilityOptionsTabPage::SvxAccessibilityOptionsTabPage( Window
* pParent
, const SfxItemSet
& rSet
)
55 :SfxTabPage(pParent
, CUI_RES( RID_SVXPAGE_ACCESSIBILITYCONFIG
), rSet
)
56 ,m_aMiscellaneousLabel (this, CUI_RES(FL_MISCELLANEOUS
))
57 ,m_aAccessibilityTool (this, CUI_RES(CB_ACCESSIBILITY_TOOL
))
58 ,m_aTextSelectionInReadonly (this, CUI_RES(CB_TEXTSELECTION
))
59 ,m_aAnimatedGraphics (this, CUI_RES(CB_ANIMATED_GRAPHICS
))
60 ,m_aAnimatedTexts (this, CUI_RES(CB_ANIMATED_TEXTS
))
61 ,m_aTipHelpCB (this, CUI_RES(CB_TIPHELP
))
62 ,m_aTipHelpNF (this, CUI_RES(NF_TIPHELP
))
63 ,m_aTipHelpFT (this, CUI_RES(FT_TIPHELP
))
64 ,m_aHCOptionsLabel (this, CUI_RES(FL_HC_OPTIONS
))
65 ,m_aAutoDetectHC (this, CUI_RES(CB_AUTO_DETECT_HC
))
66 ,m_aAutomaticFontColor (this, CUI_RES(CB_AUTOMATIC_FONT_COLOR
))
67 ,m_aPagePreviews (this, CUI_RES(CB_PAGE_PREVIEWS
))
68 ,m_pImpl(new SvxAccessibilityOptionsTabPage_Impl
)
71 m_aTipHelpCB
.SetClickHdl(LINK(this, SvxAccessibilityOptionsTabPage
, TipHelpHdl
));
73 long nHeightDelta
= 0; // to correct positions _under_ m_aAccessibilityTool
77 // UNIX: read the gconf2 setting instead to use the checkbox
78 m_aAccessibilityTool
.Hide();
79 nHeightDelta
= -( ROWA_2
- ROWA_1
);
82 // calculate the height of the checkbox. Do we need two (default in resource) or only one line
83 String aText
= m_aAccessibilityTool
.GetText();
84 long nWidth
= m_aAccessibilityTool
.GetTextWidth( aText
);
85 long nCtrlWidth
= m_aAccessibilityTool
.GetSizePixel().Width() - ( COL2
- COL1
);
86 if ( nWidth
> nCtrlWidth
)
88 long nDelta
= 2 * RSC_CD_FIXEDLINE_HEIGHT
+ LINESPACE
- RSC_CD_CHECKBOX_HEIGHT
;
89 nHeightDelta
= nDelta
;
90 Size aSize
= m_aAccessibilityTool
.LogicToPixel( Size( 0, nDelta
), MAP_APPFONT
);
91 nDelta
= aSize
.Height();
92 aSize
= m_aAccessibilityTool
.GetSizePixel();
93 aSize
.Height() += nDelta
;
94 m_aAccessibilityTool
.SetSizePixel( aSize
);
99 { //adjust positions of controls under m_aAccessibilityTool
100 Size aSize
= m_aAccessibilityTool
.LogicToPixel( Size( 0, nHeightDelta
), MAP_APPFONT
);
101 nHeightDelta
= aSize
.Height();
103 MovePosY( m_aTextSelectionInReadonly
, nHeightDelta
);
104 MovePosY( m_aAnimatedGraphics
, nHeightDelta
);
105 MovePosY( m_aAnimatedTexts
, nHeightDelta
);
106 MovePosY( m_aTipHelpCB
, nHeightDelta
);
107 MovePosY( m_aTipHelpNF
, nHeightDelta
);
108 MovePosY( m_aTipHelpFT
, nHeightDelta
);
109 MovePosY( m_aHCOptionsLabel
, nHeightDelta
);
110 MovePosY( m_aAutoDetectHC
, nHeightDelta
);
111 MovePosY( m_aAutomaticFontColor
, nHeightDelta
);
112 MovePosY( m_aPagePreviews
, nHeightDelta
);
116 SvxAccessibilityOptionsTabPage::~SvxAccessibilityOptionsTabPage()
121 SfxTabPage
* SvxAccessibilityOptionsTabPage::Create( Window
* pParent
, const SfxItemSet
& rAttrSet
)
123 return new SvxAccessibilityOptionsTabPage(pParent
, rAttrSet
);
126 sal_Bool
SvxAccessibilityOptionsTabPage::FillItemSet( SfxItemSet
& )
128 //aConfig.Set... from controls
130 m_pImpl
->m_aConfig
.SetIsForPagePreviews( m_aPagePreviews
.IsChecked() );
131 m_pImpl
->m_aConfig
.SetIsHelpTipsDisappear( m_aTipHelpCB
.IsChecked() );
132 m_pImpl
->m_aConfig
.SetHelpTipSeconds( (short)m_aTipHelpNF
.GetValue() );
133 m_pImpl
->m_aConfig
.SetIsAllowAnimatedGraphics( m_aAnimatedGraphics
.IsChecked() );
134 m_pImpl
->m_aConfig
.SetIsAllowAnimatedText( m_aAnimatedTexts
.IsChecked() );
135 m_pImpl
->m_aConfig
.SetIsAutomaticFontColor( m_aAutomaticFontColor
.IsChecked() );
136 m_pImpl
->m_aConfig
.SetSelectionInReadonly( m_aTextSelectionInReadonly
.IsChecked());
137 m_pImpl
->m_aConfig
.SetAutoDetectSystemHC( m_aAutoDetectHC
.IsChecked());
139 if(m_pImpl
->m_aConfig
.IsModified())
140 m_pImpl
->m_aConfig
.Commit();
142 AllSettings aAllSettings
= Application::GetSettings();
143 MiscSettings aMiscSettings
= aAllSettings
.GetMiscSettings();
145 aMiscSettings
.SetEnableATToolSupport( m_aAccessibilityTool
.IsChecked() );
147 aAllSettings
.SetMiscSettings(aMiscSettings
);
148 Application::MergeSystemSettings( aAllSettings
);
149 Application::SetSettings(aAllSettings
);
154 void SvxAccessibilityOptionsTabPage::Reset( const SfxItemSet
& )
156 //set controls from aConfig.Get...
158 m_aPagePreviews
.Check( m_pImpl
->m_aConfig
.GetIsForPagePreviews() );
159 EnableTipHelp( m_pImpl
->m_aConfig
.GetIsHelpTipsDisappear() );
160 m_aTipHelpNF
.SetValue( m_pImpl
->m_aConfig
.GetHelpTipSeconds() );
161 m_aAnimatedGraphics
.Check( m_pImpl
->m_aConfig
.GetIsAllowAnimatedGraphics() );
162 m_aAnimatedTexts
.Check( m_pImpl
->m_aConfig
.GetIsAllowAnimatedText() );
163 m_aAutomaticFontColor
.Check( m_pImpl
->m_aConfig
.GetIsAutomaticFontColor() );
164 // m_aSystemFont.Check( m_pImpl->m_aConfig.GetIsSystemFont() );
165 m_aTextSelectionInReadonly
.Check( m_pImpl
->m_aConfig
.IsSelectionInReadonly() );
166 m_aAutoDetectHC
.Check( m_pImpl
->m_aConfig
.GetAutoDetectSystemHC() );
169 AllSettings aAllSettings
= Application::GetSettings();
170 MiscSettings aMiscSettings
= aAllSettings
.GetMiscSettings();
171 m_aAccessibilityTool
.Check( aMiscSettings
.GetEnableATToolSupport() );
174 IMPL_LINK(SvxAccessibilityOptionsTabPage
, TipHelpHdl
, CheckBox
*, pBox
)
176 sal_Bool bChecked
= pBox
->IsChecked();
177 m_aTipHelpNF
.Enable(bChecked
);
181 void SvxAccessibilityOptionsTabPage::EnableTipHelp(sal_Bool bCheck
)
183 m_aTipHelpCB
.Check(bCheck
);
184 m_aTipHelpNF
.Enable(bCheck
);