1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/frmdirlbox.hxx>
21 #include <vcl/builder.hxx>
25 // ============================================================================
29 inline void* lclEnumToVoid( SvxFrameDirection eDirection
)
31 return reinterpret_cast< void* >( static_cast< sal_uInt32
>( eDirection
) );
34 inline SvxFrameDirection
lclVoidToEnum( void* pDirection
)
36 return static_cast< SvxFrameDirection
>( reinterpret_cast< sal_IntPtr
>( pDirection
) );
41 // ============================================================================
43 FrameDirectionListBox::FrameDirectionListBox( Window
* pParent
, const ResId
& rResId
) :
44 ListBox( pParent
, rResId
)
48 FrameDirectionListBox::FrameDirectionListBox( Window
* pParent
, WinBits nBits
) :
49 ListBox( pParent
, nBits
)
53 FrameDirectionListBox::~FrameDirectionListBox()
57 extern "C" SAL_DLLPUBLIC_EXPORT Window
* SAL_CALL
makeFrameDirectionListBox(Window
*pParent
, VclBuilder::stringmap
&)
59 FrameDirectionListBox
* pListBox
= new FrameDirectionListBox(pParent
, WB_LEFT
|WB_DROPDOWN
|WB_VCENTER
|WB_3DLOOK
|WB_TABSTOP
);
60 pListBox
->EnableAutoSize(true);
65 void FrameDirectionListBox::InsertEntryValue( const String
& rString
, SvxFrameDirection eDirection
, sal_uInt16 nPos
)
67 sal_uInt16 nRealPos
= InsertEntry( rString
, nPos
);
68 SetEntryData( nRealPos
, lclEnumToVoid( eDirection
) );
71 void FrameDirectionListBox::RemoveEntryValue( SvxFrameDirection eDirection
)
73 sal_uInt16 nPos
= GetEntryPos( lclEnumToVoid( eDirection
) );
74 if( nPos
!= LISTBOX_ENTRY_NOTFOUND
)
78 void FrameDirectionListBox::SelectEntryValue( SvxFrameDirection eDirection
)
80 sal_uInt16 nPos
= GetEntryPos( lclEnumToVoid( eDirection
) );
81 if( nPos
== LISTBOX_ENTRY_NOTFOUND
)
84 SelectEntryPos( nPos
);
87 SvxFrameDirection
FrameDirectionListBox::GetSelectEntryValue() const
89 sal_uInt16 nPos
= GetSelectEntryPos();
90 if( nPos
== LISTBOX_ENTRY_NOTFOUND
)
91 return static_cast< SvxFrameDirection
>( 0xFFFF );
92 return lclVoidToEnum( GetEntryData( nPos
) );
95 // ============================================================================
97 FrameDirListBoxWrapper::FrameDirListBoxWrapper( FrameDirListBox
& rListBox
) :
98 SingleControlWrapperType( rListBox
)
102 bool FrameDirListBoxWrapper::IsControlDontKnow() const
104 return GetControl().GetSelectEntryCount() == 0;
107 void FrameDirListBoxWrapper::SetControlDontKnow( bool bSet
)
110 GetControl().SetNoSelection();
113 SvxFrameDirection
FrameDirListBoxWrapper::GetControlValue() const
115 return GetControl().GetSelectEntryValue();
118 void FrameDirListBoxWrapper::SetControlValue( SvxFrameDirection eValue
)
120 GetControl().SelectEntryValue( eValue
);
123 // ============================================================================
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */