Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "res_Titles.hxx"
22 : #include "res_Titles.hrc"
23 : #include "ResId.hxx"
24 : #include "TitleDialogData.hxx"
25 : #include <svtools/controldims.hrc>
26 :
27 : //.............................................................................
28 : namespace chart
29 : {
30 : //.............................................................................
31 :
32 0 : TitleResources::TitleResources( Window* pWindow, bool bShowSecondaryAxesTitle )
33 : : m_aFT_Main(pWindow, SchResId(FT_MAINTITLE))
34 : , m_aEd_Main(pWindow, SchResId(ED_MAINTITLE))
35 : , m_aFT_Sub(pWindow, SchResId(FT_SUBTITLE))
36 : , m_aEd_Sub(pWindow, SchResId(ED_SUBTITLE))
37 : , m_aFL_Axes(pWindow, SchResId(FL_AXES))
38 : , m_aFT_XAxis(pWindow, SchResId(FT_TITLE_X_AXIS))
39 : , m_aEd_XAxis(pWindow, SchResId(ED_X_AXIS))
40 : , m_aFT_YAxis(pWindow, SchResId(FT_TITLE_Y_AXIS))
41 : , m_aEd_YAxis(pWindow, SchResId(ED_Y_AXIS))
42 : , m_aFT_ZAxis(pWindow, SchResId(FT_TITLE_Z_AXIS))
43 : , m_aEd_ZAxis(pWindow, SchResId(ED_Z_AXIS))
44 : , m_aFL_SecondaryAxes(pWindow, SchResId(FL_SECONDARY_AXES))
45 : , m_aFT_SecondaryXAxis(pWindow, SchResId(FT_TITLE_SECONDARY_X_AXIS))
46 : , m_aEd_SecondaryXAxis(pWindow, SchResId(ED_SECONDARY_X_AXIS))
47 : , m_aFT_SecondaryYAxis(pWindow, SchResId(FT_TITLE_SECONDARY_Y_AXIS))
48 0 : , m_aEd_SecondaryYAxis(pWindow, SchResId(ED_SECONDARY_Y_AXIS))
49 : {
50 0 : long nMaxTextWidth = ::std::max( m_aFT_Main.CalcMinimumSize().Width(),m_aFT_Sub.CalcMinimumSize().Width() ) ;
51 0 : nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_XAxis.CalcMinimumSize().Width() ) ;
52 0 : nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_YAxis.CalcMinimumSize().Width() ) ;
53 0 : nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_ZAxis.CalcMinimumSize().Width() ) ;
54 0 : if( bShowSecondaryAxesTitle )
55 : {
56 0 : nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_SecondaryXAxis.CalcMinimumSize().Width() ) ;
57 0 : nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_SecondaryYAxis.CalcMinimumSize().Width() ) ;
58 : }
59 :
60 0 : Size aControlDistance( m_aFT_Main.LogicToPixel( Size(RSC_SP_CTRL_DESC_X,RSC_SP_CTRL_GROUP_Y), MapMode(MAP_APPFONT) ) );
61 0 : long nEditFieldXPos = m_aFT_Main.GetPosPixel().X() + nMaxTextWidth + aControlDistance.Width();
62 0 : long nEditFieldWidth = m_aEd_Main.GetPosPixel().X() + m_aEd_Main.GetSizePixel().Width() - nEditFieldXPos;
63 :
64 0 : if( nEditFieldWidth > 10 )
65 : {
66 0 : Size aFTSize( m_aFT_Main.GetSizePixel() );
67 0 : aFTSize.Width() = nMaxTextWidth;
68 0 : m_aFT_Main.SetSizePixel(aFTSize);
69 0 : m_aFT_Sub.SetSizePixel(aFTSize);
70 0 : m_aFT_XAxis.SetSizePixel(aFTSize);
71 0 : m_aFT_YAxis.SetSizePixel(aFTSize);
72 0 : m_aFT_ZAxis.SetSizePixel(aFTSize);
73 0 : if( bShowSecondaryAxesTitle )
74 : {
75 0 : m_aFT_SecondaryXAxis.SetSizePixel(aFTSize);
76 0 : m_aFT_SecondaryYAxis.SetSizePixel(aFTSize);
77 : }
78 :
79 0 : m_aEd_Main.SetPosPixel( Point( nEditFieldXPos, m_aEd_Main.GetPosPixel().Y() ) );
80 0 : m_aEd_Sub.SetPosPixel( Point( nEditFieldXPos, m_aEd_Sub.GetPosPixel().Y() ) );
81 0 : m_aEd_XAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_XAxis.GetPosPixel().Y() ) );
82 0 : m_aEd_YAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_YAxis.GetPosPixel().Y() ) );
83 0 : m_aEd_ZAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_ZAxis.GetPosPixel().Y() ) );
84 0 : if(bShowSecondaryAxesTitle)
85 : {
86 0 : m_aEd_SecondaryXAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_SecondaryXAxis.GetPosPixel().Y() ) );
87 0 : m_aEd_SecondaryYAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_SecondaryYAxis.GetPosPixel().Y() ) );
88 : }
89 :
90 0 : Size aEditSize( m_aEd_Main.GetSizePixel() );
91 0 : aEditSize.Width() = nEditFieldWidth;
92 0 : m_aEd_Main.SetSizePixel( aEditSize );
93 0 : m_aEd_Sub.SetSizePixel( aEditSize );
94 0 : m_aEd_XAxis.SetSizePixel( aEditSize );
95 0 : m_aEd_YAxis.SetSizePixel( aEditSize );
96 0 : m_aEd_ZAxis.SetSizePixel( aEditSize );
97 0 : if(bShowSecondaryAxesTitle)
98 : {
99 0 : m_aEd_SecondaryXAxis.SetSizePixel( aEditSize );
100 0 : m_aEd_SecondaryYAxis.SetSizePixel( aEditSize );
101 : }
102 : }
103 :
104 0 : m_aFT_SecondaryXAxis.Show( bShowSecondaryAxesTitle );
105 0 : m_aEd_SecondaryXAxis.Show( bShowSecondaryAxesTitle );
106 0 : m_aFT_SecondaryYAxis.Show( bShowSecondaryAxesTitle );
107 0 : m_aEd_SecondaryYAxis.Show( bShowSecondaryAxesTitle );
108 0 : }
109 :
110 0 : TitleResources::~TitleResources()
111 : {
112 0 : }
113 :
114 0 : void TitleResources::SetUpdateDataHdl( const Link& rLink )
115 : {
116 0 : sal_uLong nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT;
117 :
118 0 : m_aEd_Main.EnableUpdateData( nTimeout );
119 0 : m_aEd_Main.SetUpdateDataHdl( rLink );
120 :
121 0 : m_aEd_Sub.EnableUpdateData( nTimeout );
122 0 : m_aEd_Sub.SetUpdateDataHdl( rLink );
123 :
124 0 : m_aEd_XAxis.EnableUpdateData( nTimeout );
125 0 : m_aEd_XAxis.SetUpdateDataHdl( rLink );
126 :
127 0 : m_aEd_YAxis.EnableUpdateData( nTimeout );
128 0 : m_aEd_YAxis.SetUpdateDataHdl( rLink );
129 :
130 0 : m_aEd_ZAxis.EnableUpdateData( nTimeout );
131 0 : m_aEd_ZAxis.SetUpdateDataHdl( rLink );
132 :
133 0 : m_aEd_SecondaryXAxis.EnableUpdateData( nTimeout );
134 0 : m_aEd_SecondaryXAxis.SetUpdateDataHdl( rLink );
135 :
136 0 : m_aEd_SecondaryYAxis.EnableUpdateData( nTimeout );
137 0 : m_aEd_SecondaryYAxis.SetUpdateDataHdl( rLink );
138 0 : }
139 :
140 0 : bool TitleResources::IsModified()
141 : {
142 0 : return m_aEd_Main.IsModified()
143 0 : || m_aEd_Sub.IsModified()
144 0 : || m_aEd_XAxis.IsModified()
145 0 : || m_aEd_YAxis.IsModified()
146 0 : || m_aEd_ZAxis.IsModified()
147 0 : || m_aEd_SecondaryXAxis.IsModified()
148 0 : || m_aEd_SecondaryYAxis.IsModified();
149 : }
150 :
151 0 : void TitleResources::ClearModifyFlag()
152 : {
153 0 : m_aEd_Main.ClearModifyFlag();
154 0 : m_aEd_Sub.ClearModifyFlag();
155 0 : m_aEd_XAxis.ClearModifyFlag();
156 0 : m_aEd_YAxis.ClearModifyFlag();
157 0 : m_aEd_ZAxis.ClearModifyFlag();
158 0 : m_aEd_SecondaryXAxis.ClearModifyFlag();
159 0 : m_aEd_SecondaryYAxis.ClearModifyFlag();
160 0 : }
161 :
162 0 : void TitleResources::writeToResources( const TitleDialogData& rInput )
163 : {
164 0 : m_aFT_Main.Enable( rInput.aPossibilityList[0] );
165 0 : m_aFT_Sub.Enable( rInput.aPossibilityList[1] );
166 0 : m_aFT_XAxis.Enable( rInput.aPossibilityList[2] );
167 0 : m_aFT_YAxis.Enable( rInput.aPossibilityList[3] );
168 0 : m_aFT_ZAxis.Enable( rInput.aPossibilityList[4] );
169 0 : m_aFT_SecondaryXAxis.Enable( rInput.aPossibilityList[5] );
170 0 : m_aFT_SecondaryYAxis.Enable( rInput.aPossibilityList[6] );
171 :
172 0 : m_aEd_Main.Enable( rInput.aPossibilityList[0] );
173 0 : m_aEd_Sub.Enable( rInput.aPossibilityList[1] );
174 0 : m_aEd_XAxis.Enable( rInput.aPossibilityList[2] );
175 0 : m_aEd_YAxis.Enable( rInput.aPossibilityList[3] );
176 0 : m_aEd_ZAxis.Enable( rInput.aPossibilityList[4] );
177 0 : m_aEd_SecondaryXAxis.Enable( rInput.aPossibilityList[5] );
178 0 : m_aEd_SecondaryYAxis.Enable( rInput.aPossibilityList[6] );
179 :
180 0 : m_aEd_Main.SetText(rInput.aTextList[0]);
181 0 : m_aEd_Sub.SetText(rInput.aTextList[1]);
182 0 : m_aEd_XAxis.SetText(rInput.aTextList[2]);
183 0 : m_aEd_YAxis.SetText(rInput.aTextList[3]);
184 0 : m_aEd_ZAxis.SetText(rInput.aTextList[4]);
185 0 : m_aEd_SecondaryXAxis.SetText(rInput.aTextList[5]);
186 0 : m_aEd_SecondaryYAxis.SetText(rInput.aTextList[6]);
187 0 : }
188 :
189 0 : void TitleResources::readFromResources( TitleDialogData& rOutput )
190 : {
191 0 : rOutput.aExistenceList[0] = static_cast<sal_Bool>(m_aEd_Main.GetText().Len()!=0);
192 0 : rOutput.aExistenceList[1] = static_cast<sal_Bool>(m_aEd_Sub.GetText().Len()!=0);
193 0 : rOutput.aExistenceList[2] = static_cast<sal_Bool>(m_aEd_XAxis.GetText().Len()!=0);
194 0 : rOutput.aExistenceList[3] = static_cast<sal_Bool>(m_aEd_YAxis.GetText().Len()!=0);
195 0 : rOutput.aExistenceList[4] = static_cast<sal_Bool>(m_aEd_ZAxis.GetText().Len()!=0);
196 0 : rOutput.aExistenceList[5] = static_cast<sal_Bool>(m_aEd_SecondaryXAxis.GetText().Len()!=0);
197 0 : rOutput.aExistenceList[6] = static_cast<sal_Bool>(m_aEd_SecondaryYAxis.GetText().Len()!=0);
198 :
199 0 : rOutput.aTextList[0] = m_aEd_Main.GetText();
200 0 : rOutput.aTextList[1] = m_aEd_Sub.GetText();
201 0 : rOutput.aTextList[2] = m_aEd_XAxis.GetText();
202 0 : rOutput.aTextList[3] = m_aEd_YAxis.GetText();
203 0 : rOutput.aTextList[4] = m_aEd_ZAxis.GetText();
204 0 : rOutput.aTextList[5] = m_aEd_SecondaryXAxis.GetText();
205 0 : rOutput.aTextList[6] = m_aEd_SecondaryYAxis.GetText();
206 0 : }
207 :
208 : //.............................................................................
209 : } //namespace chart
210 : //.............................................................................
211 :
212 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|