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 _SVX_BOX_HXX 28 #define _SVX_BOX_HXX 29 30 // include --------------------------------------------------------------- 31 32 #include <svl/svarray.hxx> 33 #include <tools/string.hxx> 34 #include <vcl/lstbox.hxx> 35 #include <vcl/combobox.hxx> 36 #include <svtools/svtdllapi.h> 37 38 // forward --------------------------------------------------------------- 39 40 class SvxBoxEntry; 41 class SvxListBase; 42 43 SV_DECL_PTRARR( SvxEntryLst, SvxBoxEntry*, 10, 10 ) 44 45 // class SvxBoxEntry ----------------------------------------------------- 46 47 class SVT_DLLPUBLIC SvxBoxEntry 48 { 49 friend class SvxListBox; 50 friend class SvxComboBox; 51 52 public: 53 SvxBoxEntry( const String& aName, sal_uInt16 nId=0 ); 54 SvxBoxEntry( const SvxBoxEntry& rOrg ); 55 SvxBoxEntry(); 56 57 String aName; 58 sal_uInt16 nId; 59 60 private: 61 sal_Bool bModified; 62 sal_Bool bNew; 63 }; 64 65 // class SvxListBox ------------------------------------------------------ 66 67 class SVT_DLLPUBLIC SvxListBox : public ListBox 68 { 69 using ListBox::InsertEntry; 70 using ListBox::RemoveEntry; 71 using ListBox::GetEntryPos; 72 using ListBox::IsEntrySelected; 73 using ListBox::SelectEntry; 74 75 public: 76 SvxListBox( Window* pParent, WinBits nBits = WB_BORDER ); 77 SvxListBox( Window* pParent, const ResId& rId ); 78 ~SvxListBox(); 79 80 void InsertNewEntry( const SvxBoxEntry& rEntry ); 81 void InsertEntry( const SvxBoxEntry& rEntry, 82 sal_uInt16 nId = LISTBOX_ENTRY_NOTFOUND ); 83 84 void RemoveEntry( sal_uInt16 nPos ); 85 void RemoveEntry( const SvxBoxEntry& rEntry ); 86 87 void Clear(); 88 89 sal_uInt16 GetEntryPos( const SvxBoxEntry& rEntry ) const; 90 const SvxBoxEntry& GetSvxBoxEntry( sal_uInt16 nIdx ) const; 91 92 inline sal_Bool IsEntrySelected( const SvxBoxEntry& rEntry ) const; 93 const SvxBoxEntry& GetSelectSvxBoxEntry( sal_uInt16 nIdx = 0 ) const; 94 inline void SelectEntry( const SvxBoxEntry& rEntry, 95 sal_Bool bSelect = sal_True ); 96 97 void ModifyEntry( sal_uInt16 nPos, const String& aName ); 98 sal_uInt16 GetModifiedCount() const; 99 const SvxBoxEntry& GetModifiedEntry( sal_uInt16 nPos ) const; 100 101 sal_uInt16 GetRemovedCount() const; 102 const SvxBoxEntry& GetRemovedEntry( sal_uInt16 nPos ) const; 103 104 sal_uInt16 GetNewCount() const; 105 const SvxBoxEntry& GetNewEntry( sal_uInt16 nPos ) const; 106 107 private: 108 SvxEntryLst aEntryLst; 109 SvxEntryLst aDelEntryLst; 110 SvxBoxEntry aDefault; 111 112 void InitListBox(); 113 void InsertSorted( SvxBoxEntry* pEntry ); 114 }; 115 116 // inlines --------------------------------------------------------------- 117 118 inline sal_Bool SvxListBox::IsEntrySelected( const SvxBoxEntry& aEntry ) const 119 { return ListBox::IsEntrySelected( aEntry.aName ); } 120 121 inline void SvxListBox::SelectEntry( const SvxBoxEntry& aEntry, sal_Bool bSelect ) 122 { ListBox::SelectEntry( aEntry.aName, bSelect ); } 123 124 // enum SvxComboBoxStyle ------------------------------------------------- 125 126 enum SvxComboBoxStyle 127 { 128 SVX_CBS_UPPER = 0x01, 129 SVX_CBS_LOWER = 0x02, 130 SVX_CBS_ALL = 0x04, 131 SVX_CBS_FILENAME = 0x08, 132 SVX_CBS_SW_FILENAME = SVX_CBS_FILENAME 133 }; 134 135 // class SvxComboBox ----------------------------------------------------- 136 137 class SVT_DLLPUBLIC SvxComboBox : public ComboBox 138 { 139 using ComboBox::InsertEntry; 140 using ComboBox::RemoveEntry; 141 using ComboBox::GetEntryPos; 142 using Window::SetStyle; 143 144 public: 145 SvxComboBox( Window* pParent, 146 WinBits nBits = WB_BORDER, sal_uInt16 nStyleBits = SVX_CBS_ALL ); 147 SvxComboBox( Window* pParent, const ResId& rId, sal_uInt16 nStyleBits = SVX_CBS_ALL ); 148 ~SvxComboBox(); 149 150 void InsertNewEntry( const SvxBoxEntry& ); 151 void InsertEntry( const SvxBoxEntry& ); 152 153 void RemoveEntry( sal_uInt16 nPos ); 154 void RemoveEntry( const SvxBoxEntry& rEntry ); 155 156 void Clear(); 157 158 sal_uInt16 GetEntryPos( const SvxBoxEntry& rEntry ) const; 159 const SvxBoxEntry& GetEntry( sal_uInt16 nIdx ) const; 160 161 void ModifyEntry( sal_uInt16 nPos, const String& aName ); 162 sal_uInt16 GetModifiedCount() const; 163 const SvxBoxEntry& GetModifiedEntry( sal_uInt16 nPos ) const; 164 165 sal_uInt16 GetRemovedCount() const; 166 const SvxBoxEntry& GetRemovedEntry( sal_uInt16 nPos ) const; 167 168 sal_uInt16 GetNewCount() const; 169 const SvxBoxEntry& GetNewEntry( sal_uInt16 nPos ) const; 170 171 sal_uInt16 GetStyle() const { return nStyle; } 172 void SetStyle( const sal_uInt16 nSt ) { nStyle = nSt; } 173 174 String GetText() const; 175 176 private: 177 SvxEntryLst aEntryLst; 178 SvxEntryLst aDelEntryLst; 179 SvxBoxEntry aDefault; 180 sal_uInt16 nStyle; 181 182 virtual void KeyInput( const KeyEvent& rKEvt ); 183 184 void InitComboBox(); 185 void InsertSorted( SvxBoxEntry* pEntry ); 186 }; 187 188 #endif 189 190