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 .
22 #include <tools/string.hxx>
23 #include <vcl/lstbox.hxx>
24 #include <vcl/combobox.hxx>
25 #include <svtools/svtdllapi.h>
27 // forward ---------------------------------------------------------------
31 typedef std::vector
<SvxBoxEntry
*> SvxEntryLst
;
33 // class SvxBoxEntry -----------------------------------------------------
35 class SVT_DLLPUBLIC SvxBoxEntry
37 friend class SvxListBox
;
38 friend class SvxComboBox
;
41 SvxBoxEntry( const String
& aName
, sal_uInt16 nId
=0 );
42 SvxBoxEntry( const SvxBoxEntry
& rOrg
);
53 // class SvxListBox ------------------------------------------------------
55 class SVT_DLLPUBLIC SvxListBox
: public ListBox
57 using ListBox::InsertEntry
;
58 using ListBox::RemoveEntry
;
59 using ListBox::GetEntryPos
;
60 using ListBox::IsEntrySelected
;
61 using ListBox::SelectEntry
;
64 SvxListBox( Window
* pParent
, WinBits nBits
= WB_BORDER
);
65 SvxListBox( Window
* pParent
, const ResId
& rId
);
68 void InsertNewEntry( const SvxBoxEntry
& rEntry
);
69 void InsertEntry( const SvxBoxEntry
& rEntry
,
70 sal_uInt16 nId
= LISTBOX_ENTRY_NOTFOUND
);
72 void RemoveEntry( sal_uInt16 nPos
);
73 void RemoveEntry( const SvxBoxEntry
& rEntry
);
77 sal_uInt16
GetEntryPos( const SvxBoxEntry
& rEntry
) const;
78 const SvxBoxEntry
& GetSvxBoxEntry( sal_uInt16 nIdx
) const;
80 inline sal_Bool
IsEntrySelected( const SvxBoxEntry
& rEntry
) const;
81 const SvxBoxEntry
& GetSelectSvxBoxEntry( sal_uInt16 nIdx
= 0 ) const;
82 inline void SelectEntry( const SvxBoxEntry
& rEntry
,
83 sal_Bool bSelect
= sal_True
);
85 void ModifyEntry( sal_uInt16 nPos
, const String
& aName
);
86 sal_uInt16
GetModifiedCount() const;
87 const SvxBoxEntry
& GetModifiedEntry( sal_uInt16 nPos
) const;
89 sal_uInt16
GetRemovedCount() const;
90 const SvxBoxEntry
& GetRemovedEntry( sal_uInt16 nPos
) const;
92 sal_uInt16
GetNewCount() const;
93 const SvxBoxEntry
& GetNewEntry( sal_uInt16 nPos
) const;
96 SvxEntryLst aEntryLst
;
97 SvxEntryLst aDelEntryLst
;
101 void InsertSorted( SvxBoxEntry
* pEntry
);
104 // inlines ---------------------------------------------------------------
106 inline sal_Bool
SvxListBox::IsEntrySelected( const SvxBoxEntry
& aEntry
) const
107 { return ListBox::IsEntrySelected( aEntry
.aName
); }
109 inline void SvxListBox::SelectEntry( const SvxBoxEntry
& aEntry
, sal_Bool bSelect
)
110 { ListBox::SelectEntry( aEntry
.aName
, bSelect
); }
112 // enum SvxComboBoxStyle -------------------------------------------------
114 enum SvxComboBoxStyle
116 SVX_CBS_UPPER
= 0x01,
117 SVX_CBS_LOWER
= 0x02,
119 SVX_CBS_FILENAME
= 0x08,
120 SVX_CBS_SW_FILENAME
= SVX_CBS_FILENAME
123 // class SvxComboBox -----------------------------------------------------
125 class SVT_DLLPUBLIC SvxComboBox
: public ComboBox
127 using ComboBox::InsertEntry
;
128 using ComboBox::RemoveEntry
;
129 using ComboBox::GetEntryPos
;
130 using Window::SetStyle
;
133 SvxComboBox( Window
* pParent
,
134 WinBits nBits
= WB_BORDER
, sal_uInt16 nStyleBits
= SVX_CBS_ALL
);
135 SvxComboBox( Window
* pParent
, const ResId
& rId
, sal_uInt16 nStyleBits
= SVX_CBS_ALL
);
138 void InsertNewEntry( const SvxBoxEntry
& );
139 void InsertEntry( const SvxBoxEntry
& );
141 void RemoveEntry( sal_uInt16 nPos
);
142 void RemoveEntry( const SvxBoxEntry
& rEntry
);
146 sal_uInt16
GetEntryPos( const SvxBoxEntry
& rEntry
) const;
147 const SvxBoxEntry
& GetEntry( sal_uInt16 nIdx
) const;
149 void ModifyEntry( sal_uInt16 nPos
, const String
& aName
);
150 sal_uInt16
GetModifiedCount() const;
151 const SvxBoxEntry
& GetModifiedEntry( sal_uInt16 nPos
) const;
153 sal_uInt16
GetRemovedCount() const;
154 const SvxBoxEntry
& GetRemovedEntry( sal_uInt16 nPos
) const;
156 sal_uInt16
GetNewCount() const;
157 const SvxBoxEntry
& GetNewEntry( sal_uInt16 nPos
) const;
159 sal_uInt16
GetStyle() const { return nStyle
; }
160 void SetStyle( const sal_uInt16 nSt
) { nStyle
= nSt
; }
162 OUString
GetText() const;
165 SvxEntryLst aEntryLst
;
166 SvxEntryLst aDelEntryLst
;
167 SvxBoxEntry aDefault
;
170 virtual void KeyInput( const KeyEvent
& rKEvt
);
173 void InsertSorted( SvxBoxEntry
* pEntry
);
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */