Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / dialog / frmdirlbox.cxx
blobf4b9dc52efbb58d834f3465d8b1c34f871c7990f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
23 namespace svx {
27 namespace {
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 ) );
39 } // namespace
41 FrameDirectionListBox::FrameDirectionListBox( Window* pParent, WinBits nBits )
42 : ListBox(pParent, nBits)
43 , meSaveValue(FRMDIR_HORI_LEFT_TOP)
47 FrameDirectionListBox::~FrameDirectionListBox()
51 extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeFrameDirectionListBox(Window *pParent, VclBuilder::stringmap &)
53 FrameDirectionListBox* pListBox = new FrameDirectionListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_TABSTOP);
54 pListBox->EnableAutoSize(true);
55 return pListBox;
59 void FrameDirectionListBox::InsertEntryValue( const OUString& rString, SvxFrameDirection eDirection, sal_Int32 nPos )
61 sal_Int32 nRealPos = InsertEntry( rString, nPos );
62 SetEntryData( nRealPos, lclEnumToVoid( eDirection ) );
65 void FrameDirectionListBox::RemoveEntryValue( SvxFrameDirection eDirection )
67 sal_Int32 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
68 if( nPos != LISTBOX_ENTRY_NOTFOUND )
69 RemoveEntry( nPos );
72 void FrameDirectionListBox::SelectEntryValue( SvxFrameDirection eDirection )
74 sal_Int32 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
75 if( nPos == LISTBOX_ENTRY_NOTFOUND )
76 SetNoSelection();
77 else
78 SelectEntryPos( nPos );
81 SvxFrameDirection FrameDirectionListBox::GetSelectEntryValue() const
83 sal_Int32 nPos = GetSelectEntryPos();
84 if( nPos == LISTBOX_ENTRY_NOTFOUND )
85 return static_cast< SvxFrameDirection >( 0xFFFF );
86 return lclVoidToEnum( GetEntryData( nPos ) );
91 FrameDirListBoxWrapper::FrameDirListBoxWrapper( FrameDirListBox& rListBox ) :
92 SingleControlWrapperType( rListBox )
96 bool FrameDirListBoxWrapper::IsControlDontKnow() const
98 return GetControl().GetSelectEntryCount() == 0;
101 void FrameDirListBoxWrapper::SetControlDontKnow( bool bSet )
103 if( bSet )
104 GetControl().SetNoSelection();
107 SvxFrameDirection FrameDirListBoxWrapper::GetControlValue() const
109 return GetControl().GetSelectEntryValue();
112 void FrameDirListBoxWrapper::SetControlValue( SvxFrameDirection eValue )
114 GetControl().SelectEntryValue( eValue );
119 } // namespace svx
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */