xref: /trunk/main/sw/source/ui/inc/swlbox.hxx (revision 4d7c9de0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SWLBOX_HXX
24 #define _SWLBOX_HXX
25 
26 #include <svl/svarray.hxx>
27 
28 #ifndef _LSTBOX_HXX //autogen
29 #include <vcl/lstbox.hxx>
30 #endif
31 
32 #ifndef _COMBOBOX_HXX //autogen
33 #include <vcl/combobox.hxx>
34 #endif
35 #include "swdllapi.h"
36 
37 class SwBoxEntry;
38 class Window;
39 
40 SV_DECL_PTRARR_DEL(SwEntryLst, SwBoxEntry*, 10, 10)
41 
42 /*--------------------------------------------------------------------
43 	 Beschreibung: SwBoxEntry
44  --------------------------------------------------------------------*/
45 
46 class SW_DLLPUBLIC SwBoxEntry
47 {
48 	friend class SwComboBox;
49 
50 	sal_Bool   	bModified : 1;
51 	sal_Bool   	bNew : 1;
52 
53     String  aName;
54     sal_uInt16  nId;
55 
56 public:
57 	SwBoxEntry(const String& aName, sal_uInt16 nId=0);
58 	SwBoxEntry(const SwBoxEntry& rOrg);
59 	SwBoxEntry();
60 
GetName() const61     const String& GetName() const { return aName;}
62 };
63 
64 /*--------------------------------------------------------------------
65 	 Beschreibung: fuer ComboBoxen
66  --------------------------------------------------------------------*/
67 
68 typedef sal_uInt16 SwComboBoxStyle;
69 namespace nsSwComboBoxStyle
70 {
71 	const SwComboBoxStyle CBS_UPPER 		= 0x01;
72 	const SwComboBoxStyle CBS_LOWER	 		= 0x02;
73 	const SwComboBoxStyle CBS_ALL	  		= 0x04;
74 	const SwComboBoxStyle CBS_FILENAME 		= 0x08;
75 	const SwComboBoxStyle CBS_SW_FILENAME 	= CBS_FILENAME;
76 }
77 
78 class SW_DLLPUBLIC SwComboBox : public ComboBox
79 {
80 	SwEntryLst				aEntryLst;
81 	SwEntryLst				aDelEntryLst;
82 	SwBoxEntry 				aDefault;
83 	sal_uInt16 					nStyle;
84 
85 	SW_DLLPRIVATE void					InitComboBox();
86 	SW_DLLPRIVATE void					InsertSorted(SwBoxEntry* pEntry);
87 
88     using ComboBox::InsertEntry;
89     using ComboBox::RemoveEntry;
90     using Window::SetStyle;
91 
92 public:
93 
94     using ComboBox::GetEntryPos;
95 
96 	SwComboBox(Window* pParent, const ResId& rId,
97 			   sal_uInt16 nStyleBits = nsSwComboBoxStyle::CBS_ALL);
98 	~SwComboBox();
99 
100 	virtual void 			KeyInput( const KeyEvent& rKEvt );
101 
102     void                    InsertEntry(const SwBoxEntry&);
InsertEntry(const XubString & rStr,sal_uInt16=0)103     sal_uInt16                  InsertEntry( const XubString& rStr, sal_uInt16 = 0)
104                             {        InsertEntry( SwBoxEntry( rStr ) ); return 0;    }
105 
106 	void					RemoveEntry(sal_uInt16 nPos);
107 
108 	sal_uInt16 					GetEntryPos(const SwBoxEntry& rEntry) const;
109 	const SwBoxEntry&   	GetEntry(sal_uInt16) const;
110 
111 	sal_uInt16					GetRemovedCount() const;
112 	const SwBoxEntry&		GetRemovedEntry(sal_uInt16 nPos) const;
113 
GetStyle() const114 	sal_uInt16 					GetStyle() const 			{ return nStyle; 	}
SetStyle(const sal_uInt16 nSt)115 	void					SetStyle(const sal_uInt16 nSt) 	{ nStyle = nSt; 	}
116 
117 	String					GetText() const;
118 	void					SetText( const XubString& rStr );
SetText(const XubString & rStr,const Selection & rNewSelection)119 	void					SetText( const XubString& rStr, const Selection& rNewSelection ) { ComboBox::SetText( rStr, rNewSelection ); };
120 };
121 
122 #endif /* _SWLBOX_HXX */
123