1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*f6e50924SAndrew Rist * distributed with this work for additional information
6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10*f6e50924SAndrew Rist *
11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist *
13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17*f6e50924SAndrew Rist * specific language governing permissions and limitations
18*f6e50924SAndrew Rist * under the License.
19*f6e50924SAndrew Rist *
20*f6e50924SAndrew Rist *************************************************************/
21*f6e50924SAndrew Rist
22*f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <svx/frmdirlbox.hxx>
27cdf0e10cSrcweir
28cdf0e10cSrcweir namespace svx {
29cdf0e10cSrcweir
30cdf0e10cSrcweir // ============================================================================
31cdf0e10cSrcweir
32cdf0e10cSrcweir namespace {
33cdf0e10cSrcweir
lclEnumToVoid(SvxFrameDirection eDirection)34cdf0e10cSrcweir inline void* lclEnumToVoid( SvxFrameDirection eDirection )
35cdf0e10cSrcweir {
36cdf0e10cSrcweir return reinterpret_cast< void* >( static_cast< sal_uInt32 >( eDirection ) );
37cdf0e10cSrcweir }
38cdf0e10cSrcweir
lclVoidToEnum(void * pDirection)39cdf0e10cSrcweir inline SvxFrameDirection lclVoidToEnum( void* pDirection )
40cdf0e10cSrcweir {
41cdf0e10cSrcweir return static_cast< SvxFrameDirection >( reinterpret_cast< sal_IntPtr >( pDirection ) );
42cdf0e10cSrcweir }
43cdf0e10cSrcweir
44cdf0e10cSrcweir } // namespace
45cdf0e10cSrcweir
46cdf0e10cSrcweir // ============================================================================
47cdf0e10cSrcweir
FrameDirectionListBox(Window * pParent,WinBits nStyle)48cdf0e10cSrcweir FrameDirectionListBox::FrameDirectionListBox( Window* pParent, WinBits nStyle ) :
49cdf0e10cSrcweir ListBox( pParent, nStyle )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
FrameDirectionListBox(Window * pParent,const ResId & rResId)53cdf0e10cSrcweir FrameDirectionListBox::FrameDirectionListBox( Window* pParent, const ResId& rResId ) :
54cdf0e10cSrcweir ListBox( pParent, rResId )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
~FrameDirectionListBox()58cdf0e10cSrcweir FrameDirectionListBox::~FrameDirectionListBox()
59cdf0e10cSrcweir {
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
InsertEntryValue(const String & rString,SvxFrameDirection eDirection,sal_uInt16 nPos)62cdf0e10cSrcweir void FrameDirectionListBox::InsertEntryValue( const String& rString, SvxFrameDirection eDirection, sal_uInt16 nPos )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir sal_uInt16 nRealPos = InsertEntry( rString, nPos );
65cdf0e10cSrcweir SetEntryData( nRealPos, lclEnumToVoid( eDirection ) );
66cdf0e10cSrcweir }
67cdf0e10cSrcweir
RemoveEntryValue(SvxFrameDirection eDirection)68cdf0e10cSrcweir void FrameDirectionListBox::RemoveEntryValue( SvxFrameDirection eDirection )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir sal_uInt16 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
71cdf0e10cSrcweir if( nPos != LISTBOX_ENTRY_NOTFOUND )
72cdf0e10cSrcweir RemoveEntry( nPos );
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
SelectEntryValue(SvxFrameDirection eDirection)75cdf0e10cSrcweir void FrameDirectionListBox::SelectEntryValue( SvxFrameDirection eDirection )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir sal_uInt16 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
78cdf0e10cSrcweir if( nPos == LISTBOX_ENTRY_NOTFOUND )
79cdf0e10cSrcweir SetNoSelection();
80cdf0e10cSrcweir else
81cdf0e10cSrcweir SelectEntryPos( nPos );
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
GetSelectEntryValue() const84cdf0e10cSrcweir SvxFrameDirection FrameDirectionListBox::GetSelectEntryValue() const
85cdf0e10cSrcweir {
86cdf0e10cSrcweir sal_uInt16 nPos = GetSelectEntryPos();
87cdf0e10cSrcweir if( nPos == LISTBOX_ENTRY_NOTFOUND )
88cdf0e10cSrcweir return static_cast< SvxFrameDirection >( 0xFFFF );
89cdf0e10cSrcweir return lclVoidToEnum( GetEntryData( nPos ) );
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir // ============================================================================
93cdf0e10cSrcweir
FrameDirListBoxWrapper(FrameDirListBox & rListBox)94cdf0e10cSrcweir FrameDirListBoxWrapper::FrameDirListBoxWrapper( FrameDirListBox& rListBox ) :
95cdf0e10cSrcweir SingleControlWrapperType( rListBox )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir }
98cdf0e10cSrcweir
IsControlDontKnow() const99cdf0e10cSrcweir bool FrameDirListBoxWrapper::IsControlDontKnow() const
100cdf0e10cSrcweir {
101cdf0e10cSrcweir return GetControl().GetSelectEntryCount() == 0;
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
SetControlDontKnow(bool bSet)104cdf0e10cSrcweir void FrameDirListBoxWrapper::SetControlDontKnow( bool bSet )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir if( bSet )
107cdf0e10cSrcweir GetControl().SetNoSelection();
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
GetControlValue() const110cdf0e10cSrcweir SvxFrameDirection FrameDirListBoxWrapper::GetControlValue() const
111cdf0e10cSrcweir {
112cdf0e10cSrcweir return GetControl().GetSelectEntryValue();
113cdf0e10cSrcweir }
114cdf0e10cSrcweir
SetControlValue(SvxFrameDirection eValue)115cdf0e10cSrcweir void FrameDirListBoxWrapper::SetControlValue( SvxFrameDirection eValue )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir GetControl().SelectEntryValue( eValue );
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir // ============================================================================
121cdf0e10cSrcweir
122cdf0e10cSrcweir } // namespace svx
123cdf0e10cSrcweir
124