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 : // ============================================================================
42 :
43 0 : FrameDirectionListBox::FrameDirectionListBox( Window* pParent, const ResId& rResId ) :
44 0 : ListBox( pParent, rResId )
45 : {
46 0 : }
47 :
48 0 : FrameDirectionListBox::FrameDirectionListBox( Window* pParent, WinBits nBits ) :
49 0 : ListBox( pParent, nBits )
50 : {
51 0 : }
52 :
53 0 : FrameDirectionListBox::~FrameDirectionListBox()
54 : {
55 0 : }
56 :
57 0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeFrameDirectionListBox(Window *pParent, VclBuilder::stringmap &)
58 : {
59 0 : FrameDirectionListBox* pListBox = new FrameDirectionListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_TABSTOP);
60 0 : pListBox->EnableAutoSize(true);
61 0 : return pListBox;
62 : }
63 :
64 :
65 0 : void FrameDirectionListBox::InsertEntryValue( const String& rString, SvxFrameDirection eDirection, sal_uInt16 nPos )
66 : {
67 0 : sal_uInt16 nRealPos = InsertEntry( rString, nPos );
68 0 : SetEntryData( nRealPos, lclEnumToVoid( eDirection ) );
69 0 : }
70 :
71 0 : void FrameDirectionListBox::RemoveEntryValue( SvxFrameDirection eDirection )
72 : {
73 0 : sal_uInt16 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
74 0 : if( nPos != LISTBOX_ENTRY_NOTFOUND )
75 0 : RemoveEntry( nPos );
76 0 : }
77 :
78 0 : void FrameDirectionListBox::SelectEntryValue( SvxFrameDirection eDirection )
79 : {
80 0 : sal_uInt16 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
81 0 : if( nPos == LISTBOX_ENTRY_NOTFOUND )
82 0 : SetNoSelection();
83 : else
84 0 : SelectEntryPos( nPos );
85 0 : }
86 :
87 0 : SvxFrameDirection FrameDirectionListBox::GetSelectEntryValue() const
88 : {
89 0 : sal_uInt16 nPos = GetSelectEntryPos();
90 0 : if( nPos == LISTBOX_ENTRY_NOTFOUND )
91 0 : return static_cast< SvxFrameDirection >( 0xFFFF );
92 0 : return lclVoidToEnum( GetEntryData( nPos ) );
93 : }
94 :
95 : // ============================================================================
96 :
97 0 : FrameDirListBoxWrapper::FrameDirListBoxWrapper( FrameDirListBox& rListBox ) :
98 0 : SingleControlWrapperType( rListBox )
99 : {
100 0 : }
101 :
102 0 : bool FrameDirListBoxWrapper::IsControlDontKnow() const
103 : {
104 0 : return GetControl().GetSelectEntryCount() == 0;
105 : }
106 :
107 0 : void FrameDirListBoxWrapper::SetControlDontKnow( bool bSet )
108 : {
109 0 : if( bSet )
110 0 : GetControl().SetNoSelection();
111 0 : }
112 :
113 0 : SvxFrameDirection FrameDirListBoxWrapper::GetControlValue() const
114 : {
115 0 : return GetControl().GetSelectEntryValue();
116 : }
117 :
118 0 : void FrameDirListBoxWrapper::SetControlValue( SvxFrameDirection eValue )
119 : {
120 0 : GetControl().SelectEntryValue( eValue );
121 0 : }
122 :
123 : // ============================================================================
124 :
125 216 : } // namespace svx
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|