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 : #include <svx/frmdirlbox.hxx>
21 : #include <vcl/builder.hxx>
22 :
23 : namespace svx {
24 :
25 :
26 :
27 : namespace {
28 :
29 0 : inline void* lclEnumToVoid( SvxFrameDirection eDirection )
30 : {
31 0 : return reinterpret_cast< void* >( static_cast< sal_uInt32 >( eDirection ) );
32 : }
33 :
34 0 : inline SvxFrameDirection lclVoidToEnum( void* pDirection )
35 : {
36 0 : return static_cast< SvxFrameDirection >( reinterpret_cast< sal_IntPtr >( pDirection ) );
37 : }
38 :
39 : } // namespace
40 :
41 0 : FrameDirectionListBox::FrameDirectionListBox( vcl::Window* pParent, WinBits nBits )
42 : : ListBox(pParent, nBits)
43 0 : , meSaveValue(FRMDIR_HORI_LEFT_TOP)
44 : {
45 0 : }
46 :
47 0 : FrameDirectionListBox::~FrameDirectionListBox()
48 : {
49 0 : }
50 :
51 0 : extern "C" SAL_DLLPUBLIC_EXPORT vcl::Window* SAL_CALL makeFrameDirectionListBox(vcl::Window *pParent, VclBuilder::stringmap &)
52 : {
53 0 : FrameDirectionListBox* pListBox = new FrameDirectionListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_TABSTOP);
54 0 : pListBox->EnableAutoSize(true);
55 0 : return pListBox;
56 : }
57 :
58 :
59 0 : void FrameDirectionListBox::InsertEntryValue( const OUString& rString, SvxFrameDirection eDirection, sal_Int32 nPos )
60 : {
61 0 : sal_Int32 nRealPos = InsertEntry( rString, nPos );
62 0 : SetEntryData( nRealPos, lclEnumToVoid( eDirection ) );
63 0 : }
64 :
65 0 : void FrameDirectionListBox::RemoveEntryValue( SvxFrameDirection eDirection )
66 : {
67 0 : sal_Int32 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
68 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
69 0 : RemoveEntry( nPos );
70 0 : }
71 :
72 0 : void FrameDirectionListBox::SelectEntryValue( SvxFrameDirection eDirection )
73 : {
74 0 : sal_Int32 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
75 0 : if( nPos == LISTBOX_ENTRY_NOTFOUND )
76 0 : SetNoSelection();
77 : else
78 0 : SelectEntryPos( nPos );
79 0 : }
80 :
81 0 : SvxFrameDirection FrameDirectionListBox::GetSelectEntryValue() const
82 : {
83 0 : sal_Int32 nPos = GetSelectEntryPos();
84 0 : if( nPos == LISTBOX_ENTRY_NOTFOUND )
85 0 : return static_cast< SvxFrameDirection >( 0xFFFF );
86 0 : return lclVoidToEnum( GetEntryData( nPos ) );
87 : }
88 :
89 :
90 :
91 0 : FrameDirListBoxWrapper::FrameDirListBoxWrapper( FrameDirListBox& rListBox ) :
92 0 : SingleControlWrapperType( rListBox )
93 : {
94 0 : }
95 :
96 0 : bool FrameDirListBoxWrapper::IsControlDontKnow() const
97 : {
98 0 : return GetControl().GetSelectEntryCount() == 0;
99 : }
100 :
101 0 : void FrameDirListBoxWrapper::SetControlDontKnow( bool bSet )
102 : {
103 0 : if( bSet )
104 0 : GetControl().SetNoSelection();
105 0 : }
106 :
107 0 : SvxFrameDirection FrameDirListBoxWrapper::GetControlValue() const
108 : {
109 0 : return GetControl().GetSelectEntryValue();
110 : }
111 :
112 0 : void FrameDirListBoxWrapper::SetControlValue( SvxFrameDirection eValue )
113 : {
114 0 : GetControl().SelectEntryValue( eValue );
115 0 : }
116 :
117 :
118 :
119 594 : } // namespace svx
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|