1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: res_Titles.cxx,v $
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_chart2.hxx"
34 #include "res_Titles.hxx"
35 #include "res_Titles.hrc"
37 #include "TitleDialogData.hxx"
39 #ifndef _SVT_CONTROLDIMS_HRC_
40 #include <svtools/controldims.hrc>
43 //.............................................................................
46 //.............................................................................
48 TitleResources::TitleResources( Window
* pWindow
, bool bShowSecondaryAxesTitle
)
49 : m_aFT_Main(pWindow
, SchResId(FT_MAINTITLE
))
50 , m_aEd_Main(pWindow
, SchResId(ED_MAINTITLE
))
51 , m_aFT_Sub(pWindow
, SchResId(FT_SUBTITLE
))
52 , m_aEd_Sub(pWindow
, SchResId(ED_SUBTITLE
))
53 , m_aFL_Axes(pWindow
, SchResId(FL_AXES
))
54 , m_aFT_XAxis(pWindow
, SchResId(FT_TITLE_X_AXIS
))
55 , m_aEd_XAxis(pWindow
, SchResId(ED_X_AXIS
))
56 , m_aFT_YAxis(pWindow
, SchResId(FT_TITLE_Y_AXIS
))
57 , m_aEd_YAxis(pWindow
, SchResId(ED_Y_AXIS
))
58 , m_aFT_ZAxis(pWindow
, SchResId(FT_TITLE_Z_AXIS
))
59 , m_aEd_ZAxis(pWindow
, SchResId(ED_Z_AXIS
))
60 , m_aFL_SecondaryAxes(pWindow
, SchResId(FL_SECONDARY_AXES
))
61 , m_aFT_SecondaryXAxis(pWindow
, SchResId(FT_TITLE_SECONDARY_X_AXIS
))
62 , m_aEd_SecondaryXAxis(pWindow
, SchResId(ED_SECONDARY_X_AXIS
))
63 , m_aFT_SecondaryYAxis(pWindow
, SchResId(FT_TITLE_SECONDARY_Y_AXIS
))
64 , m_aEd_SecondaryYAxis(pWindow
, SchResId(ED_SECONDARY_Y_AXIS
))
66 long nMaxTextWidth
= ::std::max( m_aFT_Main
.CalcMinimumSize().Width(),m_aFT_Sub
.CalcMinimumSize().Width() ) ;
67 nMaxTextWidth
= ::std::max( nMaxTextWidth
, m_aFT_XAxis
.CalcMinimumSize().Width() ) ;
68 nMaxTextWidth
= ::std::max( nMaxTextWidth
, m_aFT_YAxis
.CalcMinimumSize().Width() ) ;
69 nMaxTextWidth
= ::std::max( nMaxTextWidth
, m_aFT_ZAxis
.CalcMinimumSize().Width() ) ;
70 if( bShowSecondaryAxesTitle
)
72 nMaxTextWidth
= ::std::max( nMaxTextWidth
, m_aFT_SecondaryXAxis
.CalcMinimumSize().Width() ) ;
73 nMaxTextWidth
= ::std::max( nMaxTextWidth
, m_aFT_SecondaryYAxis
.CalcMinimumSize().Width() ) ;
76 Size
aControlDistance( m_aFT_Main
.LogicToPixel( Size(RSC_SP_CTRL_DESC_X
,RSC_SP_CTRL_GROUP_Y
), MapMode(MAP_APPFONT
) ) );
77 long nEditFieldXPos
= m_aFT_Main
.GetPosPixel().X() + nMaxTextWidth
+ aControlDistance
.Width();
78 long nEditFieldWidth
= m_aEd_Main
.GetPosPixel().X() + m_aEd_Main
.GetSizePixel().Width() - nEditFieldXPos
;
80 if( nEditFieldWidth
> 10 )
82 Size
aFTSize( m_aFT_Main
.GetSizePixel() );
83 aFTSize
.Width() = nMaxTextWidth
;
84 m_aFT_Main
.SetSizePixel(aFTSize
);
85 m_aFT_Sub
.SetSizePixel(aFTSize
);
86 m_aFT_XAxis
.SetSizePixel(aFTSize
);
87 m_aFT_YAxis
.SetSizePixel(aFTSize
);
88 m_aFT_ZAxis
.SetSizePixel(aFTSize
);
89 if( bShowSecondaryAxesTitle
)
91 m_aFT_SecondaryXAxis
.SetSizePixel(aFTSize
);
92 m_aFT_SecondaryYAxis
.SetSizePixel(aFTSize
);
95 m_aEd_Main
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_Main
.GetPosPixel().Y() ) );
96 m_aEd_Sub
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_Sub
.GetPosPixel().Y() ) );
97 m_aEd_XAxis
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_XAxis
.GetPosPixel().Y() ) );
98 m_aEd_YAxis
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_YAxis
.GetPosPixel().Y() ) );
99 m_aEd_ZAxis
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_ZAxis
.GetPosPixel().Y() ) );
100 if(bShowSecondaryAxesTitle
)
102 m_aEd_SecondaryXAxis
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_SecondaryXAxis
.GetPosPixel().Y() ) );
103 m_aEd_SecondaryYAxis
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_SecondaryYAxis
.GetPosPixel().Y() ) );
106 Size
aEditSize( m_aEd_Main
.GetSizePixel() );
107 aEditSize
.Width() = nEditFieldWidth
;
108 m_aEd_Main
.SetSizePixel( aEditSize
);
109 m_aEd_Sub
.SetSizePixel( aEditSize
);
110 m_aEd_XAxis
.SetSizePixel( aEditSize
);
111 m_aEd_YAxis
.SetSizePixel( aEditSize
);
112 m_aEd_ZAxis
.SetSizePixel( aEditSize
);
113 if(bShowSecondaryAxesTitle
)
115 m_aEd_SecondaryXAxis
.SetSizePixel( aEditSize
);
116 m_aEd_SecondaryYAxis
.SetSizePixel( aEditSize
);
120 m_aFT_SecondaryXAxis
.Show( bShowSecondaryAxesTitle
);
121 m_aEd_SecondaryXAxis
.Show( bShowSecondaryAxesTitle
);
122 m_aFT_SecondaryYAxis
.Show( bShowSecondaryAxesTitle
);
123 m_aEd_SecondaryYAxis
.Show( bShowSecondaryAxesTitle
);
126 TitleResources::~TitleResources()
130 void TitleResources::SetUpdateDataHdl( const Link
& rLink
)
132 ULONG nTimeout
= 4*EDIT_UPDATEDATA_TIMEOUT
;
134 m_aEd_Main
.EnableUpdateData( nTimeout
);
135 m_aEd_Main
.SetUpdateDataHdl( rLink
);
137 m_aEd_Sub
.EnableUpdateData( nTimeout
);
138 m_aEd_Sub
.SetUpdateDataHdl( rLink
);
140 m_aEd_XAxis
.EnableUpdateData( nTimeout
);
141 m_aEd_XAxis
.SetUpdateDataHdl( rLink
);
143 m_aEd_YAxis
.EnableUpdateData( nTimeout
);
144 m_aEd_YAxis
.SetUpdateDataHdl( rLink
);
146 m_aEd_ZAxis
.EnableUpdateData( nTimeout
);
147 m_aEd_ZAxis
.SetUpdateDataHdl( rLink
);
149 m_aEd_SecondaryXAxis
.EnableUpdateData( nTimeout
);
150 m_aEd_SecondaryXAxis
.SetUpdateDataHdl( rLink
);
152 m_aEd_SecondaryYAxis
.EnableUpdateData( nTimeout
);
153 m_aEd_SecondaryYAxis
.SetUpdateDataHdl( rLink
);
156 bool TitleResources::IsModified()
158 return m_aEd_Main
.IsModified()
159 || m_aEd_Sub
.IsModified()
160 || m_aEd_XAxis
.IsModified()
161 || m_aEd_YAxis
.IsModified()
162 || m_aEd_ZAxis
.IsModified()
163 || m_aEd_SecondaryXAxis
.IsModified()
164 || m_aEd_SecondaryYAxis
.IsModified();
167 void TitleResources::ClearModifyFlag()
169 m_aEd_Main
.ClearModifyFlag();
170 m_aEd_Sub
.ClearModifyFlag();
171 m_aEd_XAxis
.ClearModifyFlag();
172 m_aEd_YAxis
.ClearModifyFlag();
173 m_aEd_ZAxis
.ClearModifyFlag();
174 m_aEd_SecondaryXAxis
.ClearModifyFlag();
175 m_aEd_SecondaryYAxis
.ClearModifyFlag();
178 void TitleResources::writeToResources( const TitleDialogData
& rInput
)
180 m_aFT_Main
.Enable( rInput
.aPossibilityList
[0] );
181 m_aFT_Sub
.Enable( rInput
.aPossibilityList
[1] );
182 m_aFT_XAxis
.Enable( rInput
.aPossibilityList
[2] );
183 m_aFT_YAxis
.Enable( rInput
.aPossibilityList
[3] );
184 m_aFT_ZAxis
.Enable( rInput
.aPossibilityList
[4] );
185 m_aFT_SecondaryXAxis
.Enable( rInput
.aPossibilityList
[5] );
186 m_aFT_SecondaryYAxis
.Enable( rInput
.aPossibilityList
[6] );
188 m_aEd_Main
.Enable( rInput
.aPossibilityList
[0] );
189 m_aEd_Sub
.Enable( rInput
.aPossibilityList
[1] );
190 m_aEd_XAxis
.Enable( rInput
.aPossibilityList
[2] );
191 m_aEd_YAxis
.Enable( rInput
.aPossibilityList
[3] );
192 m_aEd_ZAxis
.Enable( rInput
.aPossibilityList
[4] );
193 m_aEd_SecondaryXAxis
.Enable( rInput
.aPossibilityList
[5] );
194 m_aEd_SecondaryYAxis
.Enable( rInput
.aPossibilityList
[6] );
196 m_aEd_Main
.SetText(rInput
.aTextList
[0]);
197 m_aEd_Sub
.SetText(rInput
.aTextList
[1]);
198 m_aEd_XAxis
.SetText(rInput
.aTextList
[2]);
199 m_aEd_YAxis
.SetText(rInput
.aTextList
[3]);
200 m_aEd_ZAxis
.SetText(rInput
.aTextList
[4]);
201 m_aEd_SecondaryXAxis
.SetText(rInput
.aTextList
[5]);
202 m_aEd_SecondaryYAxis
.SetText(rInput
.aTextList
[6]);
205 void TitleResources::readFromResources( TitleDialogData
& rOutput
)
207 rOutput
.aExistenceList
[0] = static_cast<sal_Bool
>(m_aEd_Main
.GetText().Len()!=0);
208 rOutput
.aExistenceList
[1] = static_cast<sal_Bool
>(m_aEd_Sub
.GetText().Len()!=0);
209 rOutput
.aExistenceList
[2] = static_cast<sal_Bool
>(m_aEd_XAxis
.GetText().Len()!=0);
210 rOutput
.aExistenceList
[3] = static_cast<sal_Bool
>(m_aEd_YAxis
.GetText().Len()!=0);
211 rOutput
.aExistenceList
[4] = static_cast<sal_Bool
>(m_aEd_ZAxis
.GetText().Len()!=0);
212 rOutput
.aExistenceList
[5] = static_cast<sal_Bool
>(m_aEd_SecondaryXAxis
.GetText().Len()!=0);
213 rOutput
.aExistenceList
[6] = static_cast<sal_Bool
>(m_aEd_SecondaryYAxis
.GetText().Len()!=0);
215 rOutput
.aTextList
[0] = m_aEd_Main
.GetText();
216 rOutput
.aTextList
[1] = m_aEd_Sub
.GetText();
217 rOutput
.aTextList
[2] = m_aEd_XAxis
.GetText();
218 rOutput
.aTextList
[3] = m_aEd_YAxis
.GetText();
219 rOutput
.aTextList
[4] = m_aEd_ZAxis
.GetText();
220 rOutput
.aTextList
[5] = m_aEd_SecondaryXAxis
.GetText();
221 rOutput
.aTextList
[6] = m_aEd_SecondaryYAxis
.GetText();
224 //.............................................................................
226 //.............................................................................