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_TextSeparator.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_TextSeparator.hxx"
35 #include "ResourceIds.hrc"
36 #include "Strings.hrc"
40 #ifndef _SVT_CONTROLDIMS_HRC_
41 #include <svtools/controldims.hrc>
44 //.............................................................................
47 //.............................................................................
49 TextSeparatorResources::TextSeparatorResources( Window
* pWindow
)
50 : m_aFT_Separator( pWindow
, pWindow
->GetStyle() )
51 , m_aLB_Separator( pWindow
, SchResId( LB_TEXT_SEPARATOR
) )
55 m_aFT_Separator
.SetText( String( SchResId( STR_TEXT_SEPARATOR
)) );
56 m_aFT_Separator
.SetSizePixel( m_aFT_Separator
.CalcMinimumSize() );
58 m_aLB_Separator
.SetDropDownLineCount(m_aLB_Separator
.GetEntryCount());
59 m_aLB_Separator
.SetSizePixel( m_aLB_Separator
.CalcMinimumSize() );
61 m_aEntryMap
[ C2U( " " ) ] = 0;
62 m_aEntryMap
[ C2U( ", " ) ] = 1;
63 m_aEntryMap
[ C2U( "; " ) ] = 2;
64 m_aEntryMap
[ C2U( "\n" ) ] = 3;
66 TextSeparatorResources::~TextSeparatorResources()
69 void TextSeparatorResources::Show( bool bShow
)
71 m_aFT_Separator
.Show( bShow
);
72 m_aLB_Separator
.Show( bShow
);
74 void TextSeparatorResources::Enable( bool bEnable
)
76 m_aFT_Separator
.Enable( bEnable
);
77 m_aLB_Separator
.Enable( bEnable
);
79 void TextSeparatorResources::PositionBelowControl( const Window
& rWindow
)
81 Point
aPoint( rWindow
.GetPosPixel() );
82 Size
aSize( rWindow
.GetSizePixel() );
83 aPoint
.Y() += aSize
.Height();
84 Size
aBigDistanceSize( rWindow
.LogicToPixel( Size(0,RSC_SP_CTRL_Y
), MapMode(MAP_APPFONT
) ) );
85 aPoint
.Y() += aBigDistanceSize
.Height();
87 Size
aDistanceSize( rWindow
.LogicToPixel( Size(RSC_SP_CTRL_DESC_X
, (RSC_CD_DROPDOWN_HEIGHT
-RSC_CD_FIXEDTEXT_HEIGHT
)/2), MapMode(MAP_APPFONT
) ) );
88 aPoint
.Y() += aDistanceSize
.Height();
90 m_aFT_Separator
.SetPosPixel( aPoint
);
91 m_aLB_Separator
.SetPosPixel( Point( aPoint
.X()+m_aFT_Separator
.GetSizePixel().Width()+aDistanceSize
.Width(), aPoint
.Y()-aDistanceSize
.Height()-1) );
94 void TextSeparatorResources::AlignListBoxWidthAndXPos( long nWantedLeftBorder
/*use -1 to indicate that this can be automatic*/
95 , long nWantedRightBorder
/*use -1 to indicate that this can be automatic*/
96 , long nMinimumListBoxWidth
/*use -1 to indicate that this can be automatic*/ )
98 long nMinPossibleLeftBorder
= m_aFT_Separator
.GetPosPixel().X() + m_aFT_Separator
.GetSizePixel().Width() + 1 ;
99 if( nWantedLeftBorder
>= 0 && nWantedLeftBorder
>nMinPossibleLeftBorder
)
101 Point
aPos( m_aLB_Separator
.GetPosPixel() );
102 aPos
.X() = nWantedLeftBorder
;
103 m_aLB_Separator
.SetPosPixel( aPos
);
106 long nMinPossibleRightBorder
= m_aLB_Separator
.GetPosPixel().X() + m_aLB_Separator
.CalcMinimumSize().Width() - 1 ;
107 if( nWantedRightBorder
< m_aLB_Separator
.GetPosPixel().X() + nMinimumListBoxWidth
)
108 nWantedRightBorder
= m_aLB_Separator
.GetPosPixel().X() + nMinimumListBoxWidth
;
110 if( nWantedRightBorder
>= 0 && nWantedRightBorder
> nMinPossibleRightBorder
)
112 Size
aSize( m_aLB_Separator
.GetSizePixel() );
113 aSize
.Width() = nWantedRightBorder
-m_aLB_Separator
.GetPosPixel().X();
114 m_aLB_Separator
.SetSizePixel(aSize
);
118 Point
TextSeparatorResources::GetCurrentListBoxPosition() const
120 return m_aLB_Separator
.GetPosPixel();
123 Size
TextSeparatorResources::GetCurrentListBoxSize() const
125 return m_aLB_Separator
.GetSizePixel();
128 void TextSeparatorResources::SetValue( const rtl::OUString
& rSeparator
)
130 ::std::map
< ::rtl::OUString
, USHORT
>::iterator
aIter( m_aEntryMap
.find(rSeparator
) );
131 if( aIter
== m_aEntryMap
.end() )
132 m_aLB_Separator
.SelectEntryPos( m_nDefaultPos
);
134 m_aLB_Separator
.SelectEntryPos( aIter
->second
);
137 void TextSeparatorResources::SetDefault()
139 m_aLB_Separator
.SelectEntryPos( m_nDefaultPos
);
142 rtl::OUString
TextSeparatorResources::GetValue() const
144 USHORT nPos
= m_aLB_Separator
.GetSelectEntryPos();
145 ::std::map
< ::rtl::OUString
, USHORT
>::const_iterator
aIter( m_aEntryMap
.begin() );
146 while( aIter
!= m_aEntryMap
.end() )
148 if(aIter
->second
==nPos
)
155 //.............................................................................
157 //.............................................................................