1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "res_Titles.hxx"
31 #include "res_Titles.hrc"
33 #include "TitleDialogData.hxx"
35 #ifndef _SVT_CONTROLDIMS_HRC_
36 #include <svtools/controldims.hrc>
39 //.............................................................................
42 //.............................................................................
44 TitleResources::TitleResources( Window
* pWindow
, bool bShowSecondaryAxesTitle
)
45 : m_aFT_Main(pWindow
, SchResId(FT_MAINTITLE
))
46 , m_aEd_Main(pWindow
, SchResId(ED_MAINTITLE
))
47 , m_aFT_Sub(pWindow
, SchResId(FT_SUBTITLE
))
48 , m_aEd_Sub(pWindow
, SchResId(ED_SUBTITLE
))
49 , m_aFL_Axes(pWindow
, SchResId(FL_AXES
))
50 , m_aFT_XAxis(pWindow
, SchResId(FT_TITLE_X_AXIS
))
51 , m_aEd_XAxis(pWindow
, SchResId(ED_X_AXIS
))
52 , m_aFT_YAxis(pWindow
, SchResId(FT_TITLE_Y_AXIS
))
53 , m_aEd_YAxis(pWindow
, SchResId(ED_Y_AXIS
))
54 , m_aFT_ZAxis(pWindow
, SchResId(FT_TITLE_Z_AXIS
))
55 , m_aEd_ZAxis(pWindow
, SchResId(ED_Z_AXIS
))
56 , m_aFL_SecondaryAxes(pWindow
, SchResId(FL_SECONDARY_AXES
))
57 , m_aFT_SecondaryXAxis(pWindow
, SchResId(FT_TITLE_SECONDARY_X_AXIS
))
58 , m_aEd_SecondaryXAxis(pWindow
, SchResId(ED_SECONDARY_X_AXIS
))
59 , m_aFT_SecondaryYAxis(pWindow
, SchResId(FT_TITLE_SECONDARY_Y_AXIS
))
60 , m_aEd_SecondaryYAxis(pWindow
, SchResId(ED_SECONDARY_Y_AXIS
))
62 long nMaxTextWidth
= ::std::max( m_aFT_Main
.CalcMinimumSize().Width(),m_aFT_Sub
.CalcMinimumSize().Width() ) ;
63 nMaxTextWidth
= ::std::max( nMaxTextWidth
, m_aFT_XAxis
.CalcMinimumSize().Width() ) ;
64 nMaxTextWidth
= ::std::max( nMaxTextWidth
, m_aFT_YAxis
.CalcMinimumSize().Width() ) ;
65 nMaxTextWidth
= ::std::max( nMaxTextWidth
, m_aFT_ZAxis
.CalcMinimumSize().Width() ) ;
66 if( bShowSecondaryAxesTitle
)
68 nMaxTextWidth
= ::std::max( nMaxTextWidth
, m_aFT_SecondaryXAxis
.CalcMinimumSize().Width() ) ;
69 nMaxTextWidth
= ::std::max( nMaxTextWidth
, m_aFT_SecondaryYAxis
.CalcMinimumSize().Width() ) ;
72 Size
aControlDistance( m_aFT_Main
.LogicToPixel( Size(RSC_SP_CTRL_DESC_X
,RSC_SP_CTRL_GROUP_Y
), MapMode(MAP_APPFONT
) ) );
73 long nEditFieldXPos
= m_aFT_Main
.GetPosPixel().X() + nMaxTextWidth
+ aControlDistance
.Width();
74 long nEditFieldWidth
= m_aEd_Main
.GetPosPixel().X() + m_aEd_Main
.GetSizePixel().Width() - nEditFieldXPos
;
76 if( nEditFieldWidth
> 10 )
78 Size
aFTSize( m_aFT_Main
.GetSizePixel() );
79 aFTSize
.Width() = nMaxTextWidth
;
80 m_aFT_Main
.SetSizePixel(aFTSize
);
81 m_aFT_Sub
.SetSizePixel(aFTSize
);
82 m_aFT_XAxis
.SetSizePixel(aFTSize
);
83 m_aFT_YAxis
.SetSizePixel(aFTSize
);
84 m_aFT_ZAxis
.SetSizePixel(aFTSize
);
85 if( bShowSecondaryAxesTitle
)
87 m_aFT_SecondaryXAxis
.SetSizePixel(aFTSize
);
88 m_aFT_SecondaryYAxis
.SetSizePixel(aFTSize
);
91 m_aEd_Main
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_Main
.GetPosPixel().Y() ) );
92 m_aEd_Sub
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_Sub
.GetPosPixel().Y() ) );
93 m_aEd_XAxis
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_XAxis
.GetPosPixel().Y() ) );
94 m_aEd_YAxis
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_YAxis
.GetPosPixel().Y() ) );
95 m_aEd_ZAxis
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_ZAxis
.GetPosPixel().Y() ) );
96 if(bShowSecondaryAxesTitle
)
98 m_aEd_SecondaryXAxis
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_SecondaryXAxis
.GetPosPixel().Y() ) );
99 m_aEd_SecondaryYAxis
.SetPosPixel( Point( nEditFieldXPos
, m_aEd_SecondaryYAxis
.GetPosPixel().Y() ) );
102 Size
aEditSize( m_aEd_Main
.GetSizePixel() );
103 aEditSize
.Width() = nEditFieldWidth
;
104 m_aEd_Main
.SetSizePixel( aEditSize
);
105 m_aEd_Sub
.SetSizePixel( aEditSize
);
106 m_aEd_XAxis
.SetSizePixel( aEditSize
);
107 m_aEd_YAxis
.SetSizePixel( aEditSize
);
108 m_aEd_ZAxis
.SetSizePixel( aEditSize
);
109 if(bShowSecondaryAxesTitle
)
111 m_aEd_SecondaryXAxis
.SetSizePixel( aEditSize
);
112 m_aEd_SecondaryYAxis
.SetSizePixel( aEditSize
);
116 m_aFT_SecondaryXAxis
.Show( bShowSecondaryAxesTitle
);
117 m_aEd_SecondaryXAxis
.Show( bShowSecondaryAxesTitle
);
118 m_aFT_SecondaryYAxis
.Show( bShowSecondaryAxesTitle
);
119 m_aEd_SecondaryYAxis
.Show( bShowSecondaryAxesTitle
);
122 TitleResources::~TitleResources()
126 void TitleResources::SetUpdateDataHdl( const Link
& rLink
)
128 sal_uLong nTimeout
= 4*EDIT_UPDATEDATA_TIMEOUT
;
130 m_aEd_Main
.EnableUpdateData( nTimeout
);
131 m_aEd_Main
.SetUpdateDataHdl( rLink
);
133 m_aEd_Sub
.EnableUpdateData( nTimeout
);
134 m_aEd_Sub
.SetUpdateDataHdl( rLink
);
136 m_aEd_XAxis
.EnableUpdateData( nTimeout
);
137 m_aEd_XAxis
.SetUpdateDataHdl( rLink
);
139 m_aEd_YAxis
.EnableUpdateData( nTimeout
);
140 m_aEd_YAxis
.SetUpdateDataHdl( rLink
);
142 m_aEd_ZAxis
.EnableUpdateData( nTimeout
);
143 m_aEd_ZAxis
.SetUpdateDataHdl( rLink
);
145 m_aEd_SecondaryXAxis
.EnableUpdateData( nTimeout
);
146 m_aEd_SecondaryXAxis
.SetUpdateDataHdl( rLink
);
148 m_aEd_SecondaryYAxis
.EnableUpdateData( nTimeout
);
149 m_aEd_SecondaryYAxis
.SetUpdateDataHdl( rLink
);
152 bool TitleResources::IsModified()
154 return m_aEd_Main
.IsModified()
155 || m_aEd_Sub
.IsModified()
156 || m_aEd_XAxis
.IsModified()
157 || m_aEd_YAxis
.IsModified()
158 || m_aEd_ZAxis
.IsModified()
159 || m_aEd_SecondaryXAxis
.IsModified()
160 || m_aEd_SecondaryYAxis
.IsModified();
163 void TitleResources::ClearModifyFlag()
165 m_aEd_Main
.ClearModifyFlag();
166 m_aEd_Sub
.ClearModifyFlag();
167 m_aEd_XAxis
.ClearModifyFlag();
168 m_aEd_YAxis
.ClearModifyFlag();
169 m_aEd_ZAxis
.ClearModifyFlag();
170 m_aEd_SecondaryXAxis
.ClearModifyFlag();
171 m_aEd_SecondaryYAxis
.ClearModifyFlag();
174 void TitleResources::writeToResources( const TitleDialogData
& rInput
)
176 m_aFT_Main
.Enable( rInput
.aPossibilityList
[0] );
177 m_aFT_Sub
.Enable( rInput
.aPossibilityList
[1] );
178 m_aFT_XAxis
.Enable( rInput
.aPossibilityList
[2] );
179 m_aFT_YAxis
.Enable( rInput
.aPossibilityList
[3] );
180 m_aFT_ZAxis
.Enable( rInput
.aPossibilityList
[4] );
181 m_aFT_SecondaryXAxis
.Enable( rInput
.aPossibilityList
[5] );
182 m_aFT_SecondaryYAxis
.Enable( rInput
.aPossibilityList
[6] );
184 m_aEd_Main
.Enable( rInput
.aPossibilityList
[0] );
185 m_aEd_Sub
.Enable( rInput
.aPossibilityList
[1] );
186 m_aEd_XAxis
.Enable( rInput
.aPossibilityList
[2] );
187 m_aEd_YAxis
.Enable( rInput
.aPossibilityList
[3] );
188 m_aEd_ZAxis
.Enable( rInput
.aPossibilityList
[4] );
189 m_aEd_SecondaryXAxis
.Enable( rInput
.aPossibilityList
[5] );
190 m_aEd_SecondaryYAxis
.Enable( rInput
.aPossibilityList
[6] );
192 m_aEd_Main
.SetText(rInput
.aTextList
[0]);
193 m_aEd_Sub
.SetText(rInput
.aTextList
[1]);
194 m_aEd_XAxis
.SetText(rInput
.aTextList
[2]);
195 m_aEd_YAxis
.SetText(rInput
.aTextList
[3]);
196 m_aEd_ZAxis
.SetText(rInput
.aTextList
[4]);
197 m_aEd_SecondaryXAxis
.SetText(rInput
.aTextList
[5]);
198 m_aEd_SecondaryYAxis
.SetText(rInput
.aTextList
[6]);
201 void TitleResources::readFromResources( TitleDialogData
& rOutput
)
203 rOutput
.aExistenceList
[0] = static_cast<sal_Bool
>(m_aEd_Main
.GetText().Len()!=0);
204 rOutput
.aExistenceList
[1] = static_cast<sal_Bool
>(m_aEd_Sub
.GetText().Len()!=0);
205 rOutput
.aExistenceList
[2] = static_cast<sal_Bool
>(m_aEd_XAxis
.GetText().Len()!=0);
206 rOutput
.aExistenceList
[3] = static_cast<sal_Bool
>(m_aEd_YAxis
.GetText().Len()!=0);
207 rOutput
.aExistenceList
[4] = static_cast<sal_Bool
>(m_aEd_ZAxis
.GetText().Len()!=0);
208 rOutput
.aExistenceList
[5] = static_cast<sal_Bool
>(m_aEd_SecondaryXAxis
.GetText().Len()!=0);
209 rOutput
.aExistenceList
[6] = static_cast<sal_Bool
>(m_aEd_SecondaryYAxis
.GetText().Len()!=0);
211 rOutput
.aTextList
[0] = m_aEd_Main
.GetText();
212 rOutput
.aTextList
[1] = m_aEd_Sub
.GetText();
213 rOutput
.aTextList
[2] = m_aEd_XAxis
.GetText();
214 rOutput
.aTextList
[3] = m_aEd_YAxis
.GetText();
215 rOutput
.aTextList
[4] = m_aEd_ZAxis
.GetText();
216 rOutput
.aTextList
[5] = m_aEd_SecondaryXAxis
.GetText();
217 rOutput
.aTextList
[6] = m_aEd_SecondaryYAxis
.GetText();
220 //.............................................................................
222 //.............................................................................
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */