Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SWLBOX_HXX
29 : : #define _SWLBOX_HXX
30 : :
31 : : #include <vcl/lstbox.hxx>
32 : : #include <vcl/combobox.hxx>
33 : : #include "swdllapi.h"
34 : : #include <boost/ptr_container/ptr_vector.hpp>
35 : :
36 : : class SwBoxEntry;
37 : : class Window;
38 : :
39 : : typedef boost::ptr_vector<SwBoxEntry> SwEntryLst;
40 : :
41 : : /*--------------------------------------------------------------------
42 : : Description: SwBoxEntry
43 : : --------------------------------------------------------------------*/
44 : 0 : class SW_DLLPUBLIC SwBoxEntry
45 : : {
46 : : friend class SwComboBox;
47 : :
48 : : sal_Bool bModified : 1;
49 : : sal_Bool bNew : 1;
50 : :
51 : : String aName;
52 : : sal_uInt16 nId;
53 : :
54 : : public:
55 : : SwBoxEntry(const String& aName, sal_uInt16 nId=0);
56 : : SwBoxEntry(const SwBoxEntry& rOrg);
57 : : SwBoxEntry();
58 : :
59 : 0 : const String& GetName() const { return aName;}
60 : : };
61 : :
62 : : /*--------------------------------------------------------------------
63 : : Description: for combo boxes
64 : : --------------------------------------------------------------------*/
65 : : typedef sal_uInt16 SwComboBoxStyle;
66 : :
67 : : namespace nsSwComboBoxStyle
68 : : {
69 : : const SwComboBoxStyle CBS_UPPER = 0x01;
70 : : const SwComboBoxStyle CBS_LOWER = 0x02;
71 : : const SwComboBoxStyle CBS_ALL = 0x04;
72 : : const SwComboBoxStyle CBS_FILENAME = 0x08;
73 : : const SwComboBoxStyle CBS_SW_FILENAME = CBS_FILENAME;
74 : : }
75 : :
76 : : class SW_DLLPUBLIC SwComboBox : public ComboBox
77 : : {
78 : : SwEntryLst aEntryLst;
79 : : SwEntryLst aDelEntryLst;
80 : : SwBoxEntry aDefault;
81 : : sal_uInt16 nStyle;
82 : :
83 : : SW_DLLPRIVATE void InitComboBox();
84 : : SW_DLLPRIVATE void InsertSorted(SwBoxEntry* pEntry);
85 : :
86 : : using ComboBox::InsertEntry;
87 : : using ComboBox::RemoveEntry;
88 : : using Window::SetStyle;
89 : :
90 : : public:
91 : :
92 : : using ComboBox::GetEntryPos;
93 : :
94 : : SwComboBox(Window* pParent, const ResId& rId,
95 : : sal_uInt16 nStyleBits = nsSwComboBoxStyle::CBS_ALL);
96 : : ~SwComboBox();
97 : :
98 : : virtual void KeyInput( const KeyEvent& rKEvt );
99 : :
100 : : void InsertEntry(const SwBoxEntry&);
101 : 0 : sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 = 0)
102 : 0 : { InsertEntry( SwBoxEntry( rStr ) ); return 0; }
103 : :
104 : : void RemoveEntry(sal_uInt16 nPos);
105 : :
106 : : sal_uInt16 GetEntryPos(const SwBoxEntry& rEntry) const;
107 : : const SwBoxEntry& GetEntry(sal_uInt16) const;
108 : :
109 : : sal_uInt16 GetRemovedCount() const;
110 : : const SwBoxEntry& GetRemovedEntry(sal_uInt16 nPos) const;
111 : :
112 : : sal_uInt16 GetStyle() const { return nStyle; }
113 : : void SetStyle(const sal_uInt16 nSt) { nStyle = nSt; }
114 : :
115 : : String GetText() const;
116 : : };
117 : :
118 : : #endif /* _SWLBOX_HXX */
119 : :
120 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|