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 : #ifndef _SWLBOX_HXX
20 : #define _SWLBOX_HXX
21 :
22 : #include <vcl/lstbox.hxx>
23 : #include <vcl/combobox.hxx>
24 : #include "swdllapi.h"
25 : #include <boost/ptr_container/ptr_vector.hpp>
26 :
27 : class SwBoxEntry;
28 : class Window;
29 :
30 : typedef boost::ptr_vector<SwBoxEntry> SwEntryLst;
31 :
32 : /*--------------------------------------------------------------------
33 : Description: SwBoxEntry
34 : --------------------------------------------------------------------*/
35 0 : class SW_DLLPUBLIC SwBoxEntry
36 : {
37 : friend class SwComboBox;
38 :
39 : sal_Bool bModified : 1;
40 : sal_Bool bNew : 1;
41 :
42 : String aName;
43 : sal_uInt16 nId;
44 :
45 : public:
46 : SwBoxEntry(const String& aName, sal_uInt16 nId=0);
47 : SwBoxEntry(const SwBoxEntry& rOrg);
48 : SwBoxEntry();
49 :
50 0 : const String& GetName() const { return aName;}
51 : };
52 :
53 : /*--------------------------------------------------------------------
54 : Description: for combo boxes
55 : --------------------------------------------------------------------*/
56 : typedef sal_uInt16 SwComboBoxStyle;
57 :
58 : namespace nsSwComboBoxStyle
59 : {
60 : const SwComboBoxStyle CBS_UPPER = 0x01;
61 : const SwComboBoxStyle CBS_LOWER = 0x02;
62 : const SwComboBoxStyle CBS_ALL = 0x04;
63 : const SwComboBoxStyle CBS_FILENAME = 0x08;
64 : const SwComboBoxStyle CBS_SW_FILENAME = CBS_FILENAME;
65 : }
66 :
67 : class SW_DLLPUBLIC SwComboBox : public ComboBox
68 : {
69 : SwEntryLst aEntryLst;
70 : SwEntryLst aDelEntryLst;
71 : SwBoxEntry aDefault;
72 : sal_uInt16 nStyle;
73 :
74 : SW_DLLPRIVATE void InitComboBox();
75 : SW_DLLPRIVATE void InsertSorted(SwBoxEntry* pEntry);
76 : SW_DLLPRIVATE void Init();
77 :
78 : using ComboBox::InsertEntry;
79 : using ComboBox::RemoveEntry;
80 : using Window::SetStyle;
81 :
82 : public:
83 :
84 : using ComboBox::GetEntryPos;
85 :
86 : SwComboBox(Window* pParent,
87 : sal_uInt16 nStyleBits = nsSwComboBoxStyle::CBS_ALL);
88 : SwComboBox(Window* pParent, const ResId& rId,
89 : sal_uInt16 nStyleBits = nsSwComboBoxStyle::CBS_ALL);
90 : ~SwComboBox();
91 :
92 : virtual void KeyInput( const KeyEvent& rKEvt );
93 :
94 : void InsertEntry(const SwBoxEntry&);
95 0 : sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 = 0)
96 0 : { InsertEntry( SwBoxEntry( rStr ) ); return 0; }
97 :
98 : void RemoveEntry(sal_uInt16 nPos);
99 :
100 : sal_uInt16 GetEntryPos(const SwBoxEntry& rEntry) const;
101 : const SwBoxEntry& GetEntry(sal_uInt16) const;
102 :
103 : sal_uInt16 GetRemovedCount() const;
104 : const SwBoxEntry& GetRemovedEntry(sal_uInt16 nPos) const;
105 :
106 : sal_uInt16 GetStyle() const { return nStyle; }
107 : void SetStyle(const sal_uInt16 nSt) { nStyle = nSt; }
108 :
109 : String GetText() const;
110 : };
111 :
112 : #endif /* _SWLBOX_HXX */
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|