xref: /aoo41x/main/svtools/inc/svtools/svxbox.hxx (revision 01aa44aa)
1*01aa44aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*01aa44aaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*01aa44aaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*01aa44aaSAndrew Rist  * distributed with this work for additional information
6*01aa44aaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*01aa44aaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*01aa44aaSAndrew Rist  * "License"); you may not use this file except in compliance
9*01aa44aaSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*01aa44aaSAndrew Rist  *
11*01aa44aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*01aa44aaSAndrew Rist  *
13*01aa44aaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*01aa44aaSAndrew Rist  * software distributed under the License is distributed on an
15*01aa44aaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*01aa44aaSAndrew Rist  * KIND, either express or implied.  See the License for the
17*01aa44aaSAndrew Rist  * specific language governing permissions and limitations
18*01aa44aaSAndrew Rist  * under the License.
19*01aa44aaSAndrew Rist  *
20*01aa44aaSAndrew Rist  *************************************************************/
21*01aa44aaSAndrew Rist 
22*01aa44aaSAndrew Rist 
23cdf0e10cSrcweir #ifndef _SVX_BOX_HXX
24cdf0e10cSrcweir #define _SVX_BOX_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // include ---------------------------------------------------------------
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <svl/svarray.hxx>
29cdf0e10cSrcweir #include <tools/string.hxx>
30cdf0e10cSrcweir #include <vcl/lstbox.hxx>
31cdf0e10cSrcweir #include <vcl/combobox.hxx>
32cdf0e10cSrcweir #include <svtools/svtdllapi.h>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir // forward ---------------------------------------------------------------
35cdf0e10cSrcweir 
36cdf0e10cSrcweir class SvxBoxEntry;
37cdf0e10cSrcweir class SvxListBase;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir SV_DECL_PTRARR( SvxEntryLst, SvxBoxEntry*, 10, 10 )
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // class SvxBoxEntry -----------------------------------------------------
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class SVT_DLLPUBLIC SvxBoxEntry
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 	friend class SvxListBox;
46cdf0e10cSrcweir 	friend class SvxComboBox;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir public:
49cdf0e10cSrcweir 	SvxBoxEntry( const String& aName, sal_uInt16 nId=0 );
50cdf0e10cSrcweir 	SvxBoxEntry( const SvxBoxEntry& rOrg );
51cdf0e10cSrcweir 	SvxBoxEntry();
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	String 				aName;
54cdf0e10cSrcweir 	sal_uInt16 				nId;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir private:
57cdf0e10cSrcweir 	sal_Bool   				bModified;
58cdf0e10cSrcweir 	sal_Bool   				bNew;
59cdf0e10cSrcweir };
60cdf0e10cSrcweir 
61cdf0e10cSrcweir // class SvxListBox ------------------------------------------------------
62cdf0e10cSrcweir 
63cdf0e10cSrcweir class SVT_DLLPUBLIC SvxListBox : public ListBox
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	using ListBox::InsertEntry;
66cdf0e10cSrcweir 	using ListBox::RemoveEntry;
67cdf0e10cSrcweir 	using ListBox::GetEntryPos;
68cdf0e10cSrcweir 	using ListBox::IsEntrySelected;
69cdf0e10cSrcweir 	using ListBox::SelectEntry;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir public:
72cdf0e10cSrcweir 	SvxListBox( Window* pParent, WinBits nBits = WB_BORDER );
73cdf0e10cSrcweir 	SvxListBox( Window* pParent, const ResId& rId );
74cdf0e10cSrcweir 	~SvxListBox();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	void				InsertNewEntry( const SvxBoxEntry& rEntry );
77cdf0e10cSrcweir 	void				InsertEntry( const SvxBoxEntry& rEntry,
78cdf0e10cSrcweir 									 sal_uInt16 nId = LISTBOX_ENTRY_NOTFOUND );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 	void				RemoveEntry( sal_uInt16 nPos );
81cdf0e10cSrcweir 	void				RemoveEntry( const SvxBoxEntry& rEntry );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	void				Clear();
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	sal_uInt16 				GetEntryPos( const SvxBoxEntry& rEntry ) const;
86cdf0e10cSrcweir 	const SvxBoxEntry&  GetSvxBoxEntry( sal_uInt16 nIdx ) const;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	inline sal_Bool			IsEntrySelected( const SvxBoxEntry& rEntry ) const;
89cdf0e10cSrcweir 	const SvxBoxEntry&  GetSelectSvxBoxEntry( sal_uInt16 nIdx = 0 ) const;
90cdf0e10cSrcweir 	inline void			SelectEntry( const SvxBoxEntry& rEntry,
91cdf0e10cSrcweir 									 sal_Bool bSelect = sal_True );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	void				ModifyEntry( sal_uInt16 nPos, const String& aName );
94cdf0e10cSrcweir 	sal_uInt16				GetModifiedCount() const;
95cdf0e10cSrcweir 	const SvxBoxEntry&	GetModifiedEntry( sal_uInt16 nPos ) const;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	sal_uInt16				GetRemovedCount() const;
98cdf0e10cSrcweir 	const SvxBoxEntry&	GetRemovedEntry( sal_uInt16 nPos ) const;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	sal_uInt16				GetNewCount() const;
101cdf0e10cSrcweir 	const SvxBoxEntry&	GetNewEntry( sal_uInt16 nPos ) const;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir private:
104cdf0e10cSrcweir 	SvxEntryLst			aEntryLst;
105cdf0e10cSrcweir 	SvxEntryLst			aDelEntryLst;
106cdf0e10cSrcweir 	SvxBoxEntry 		aDefault;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	void				InitListBox();
109cdf0e10cSrcweir 	void				InsertSorted( SvxBoxEntry* pEntry );
110cdf0e10cSrcweir };
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // inlines ---------------------------------------------------------------
113cdf0e10cSrcweir 
IsEntrySelected(const SvxBoxEntry & aEntry) const114cdf0e10cSrcweir inline sal_Bool	SvxListBox::IsEntrySelected( const SvxBoxEntry& aEntry ) const
115cdf0e10cSrcweir 	{ return ListBox::IsEntrySelected( aEntry.aName ); }
116cdf0e10cSrcweir 
SelectEntry(const SvxBoxEntry & aEntry,sal_Bool bSelect)117cdf0e10cSrcweir inline void SvxListBox::SelectEntry( const SvxBoxEntry& aEntry, sal_Bool bSelect )
118cdf0e10cSrcweir 	{ ListBox::SelectEntry( aEntry.aName, bSelect ); }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir // enum SvxComboBoxStyle -------------------------------------------------
121cdf0e10cSrcweir 
122cdf0e10cSrcweir enum SvxComboBoxStyle
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	SVX_CBS_UPPER 	 	= 0x01,
125cdf0e10cSrcweir 	SVX_CBS_LOWER	 	= 0x02,
126cdf0e10cSrcweir 	SVX_CBS_ALL	  	 	= 0x04,
127cdf0e10cSrcweir 	SVX_CBS_FILENAME 	= 0x08,
128cdf0e10cSrcweir 	SVX_CBS_SW_FILENAME = SVX_CBS_FILENAME
129cdf0e10cSrcweir };
130cdf0e10cSrcweir 
131cdf0e10cSrcweir // class SvxComboBox -----------------------------------------------------
132cdf0e10cSrcweir 
133cdf0e10cSrcweir class SVT_DLLPUBLIC SvxComboBox : public ComboBox
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	using ComboBox::InsertEntry;
136cdf0e10cSrcweir 	using ComboBox::RemoveEntry;
137cdf0e10cSrcweir 	using ComboBox::GetEntryPos;
138cdf0e10cSrcweir 	using Window::SetStyle;
139cdf0e10cSrcweir 
140cdf0e10cSrcweir public:
141cdf0e10cSrcweir 	SvxComboBox( Window* pParent,
142cdf0e10cSrcweir 				 WinBits nBits = WB_BORDER, sal_uInt16 nStyleBits = SVX_CBS_ALL );
143cdf0e10cSrcweir 	SvxComboBox( Window* pParent, const ResId& rId, sal_uInt16 nStyleBits = SVX_CBS_ALL );
144cdf0e10cSrcweir 	~SvxComboBox();
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	void				InsertNewEntry( const SvxBoxEntry& );
147cdf0e10cSrcweir 	void				InsertEntry( const SvxBoxEntry& );
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	void				RemoveEntry( sal_uInt16 nPos );
150cdf0e10cSrcweir 	void				RemoveEntry( const SvxBoxEntry& rEntry );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	void				Clear();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	sal_uInt16 				GetEntryPos( const SvxBoxEntry& rEntry ) const;
155cdf0e10cSrcweir 	const SvxBoxEntry&  GetEntry( sal_uInt16 nIdx ) const;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	void				ModifyEntry( sal_uInt16 nPos, const String& aName );
158cdf0e10cSrcweir 	sal_uInt16				GetModifiedCount() const;
159cdf0e10cSrcweir 	const SvxBoxEntry&	GetModifiedEntry( sal_uInt16 nPos ) const;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	sal_uInt16				GetRemovedCount() const;
162cdf0e10cSrcweir 	const SvxBoxEntry&	GetRemovedEntry( sal_uInt16 nPos ) const;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	sal_uInt16				GetNewCount() const;
165cdf0e10cSrcweir 	const SvxBoxEntry&	GetNewEntry( sal_uInt16 nPos ) const;
166cdf0e10cSrcweir 
GetStyle() const167cdf0e10cSrcweir 	sal_uInt16 				GetStyle() const 			 { return nStyle; }
SetStyle(const sal_uInt16 nSt)168cdf0e10cSrcweir 	void				SetStyle( const sal_uInt16 nSt ) { nStyle = nSt; }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	String				GetText() const;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir private:
173cdf0e10cSrcweir 	SvxEntryLst			aEntryLst;
174cdf0e10cSrcweir 	SvxEntryLst			aDelEntryLst;
175cdf0e10cSrcweir 	SvxBoxEntry 		aDefault;
176cdf0e10cSrcweir 	sal_uInt16 				nStyle;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	virtual void 		KeyInput( const KeyEvent& rKEvt );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	void				InitComboBox();
181cdf0e10cSrcweir 	void				InsertSorted( SvxBoxEntry* pEntry );
182cdf0e10cSrcweir };
183cdf0e10cSrcweir 
184cdf0e10cSrcweir #endif
185cdf0e10cSrcweir 
186