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