xref: /AOO41X/main/svtools/inc/svtools/editbrowsebox.hxx (revision 01aa44aa134af97080e2cf8e8bf3a0a4cd1cffe0)
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
10cdf0e10cSrcweir  *
11*01aa44aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
20*01aa44aaSAndrew Rist  *************************************************************/
21*01aa44aaSAndrew Rist 
22*01aa44aaSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
25cdf0e10cSrcweir #define _SVTOOLS_EDITBROWSEBOX_HXX_
26cdf0e10cSrcweir #define SVTOOLS_IN_EDITBROWSEBOX_HXX
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "svtools/svtdllapi.h"
29cdf0e10cSrcweir #include <tools/ref.hxx>
30cdf0e10cSrcweir #include <tools/rtti.hxx>
31cdf0e10cSrcweir #include <vcl/window.hxx>
32cdf0e10cSrcweir #include <vcl/combobox.hxx>
33cdf0e10cSrcweir #include <vcl/lstbox.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #ifndef _IMAGEBTN_HXX
36cdf0e10cSrcweir #include <vcl/button.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <svtools/brwbox.hxx>
39cdf0e10cSrcweir #include <vcl/timer.hxx>
40cdf0e10cSrcweir #include <svtools/brwhead.hxx>
41cdf0e10cSrcweir #include <svtools/svmedit.hxx>
42cdf0e10cSrcweir #include <vcl/svapp.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir //==================================================================
45cdf0e10cSrcweir // EditBrowseBoxFlags (EBBF)
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #define EBBF_NONE						((sal_Int32)0x0000)
48cdf0e10cSrcweir /** if this bit is _not_ set, the handle column will be invalidated upon
49cdf0e10cSrcweir     changing the row in the browse box.  This is for forcing the row picture to
50cdf0e10cSrcweir     be repainted. If you do not have row pictures or text, you don't need this
51cdf0e10cSrcweir     invalidation, then you would specify this bit to prevent flicker
52cdf0e10cSrcweir */
53cdf0e10cSrcweir #define EBBF_NO_HANDLE_COLUMN_CONTENT	((sal_Int32)0x0001)
54cdf0e10cSrcweir /** set this bit to activate the cell on a MouseButtonDown, not a MouseButtonUp event
55cdf0e10cSrcweir  */
56cdf0e10cSrcweir #define EBBF_ACTIVATE_ON_BUTTONDOWN		((sal_Int32)0x0002)
57cdf0e10cSrcweir /** if this bit is set and EBBF_NO_HANDLE_COLUMN_CONTENT is _not_ set, the handle
58cdf0e10cSrcweir     column is drawn with the text contained in column 0 instead of an image
59cdf0e10cSrcweir */
60cdf0e10cSrcweir #define EBBF_HANDLE_COLUMN_TEXT			((sal_Int32)0x0004)
61cdf0e10cSrcweir 
62cdf0e10cSrcweir /** If this bit is set, tab traveling is somewhat modified<br/>
63cdf0e10cSrcweir 	If the control gets the focus because the user pressed the TAB key, then the
64cdf0e10cSrcweir 	first or last cell (depending on whether the traveling was cycling forward or backward)
65cdf0e10cSrcweir 	gets activated.
66cdf0e10cSrcweir 	@see Window::GetGetFocusFlags
67cdf0e10cSrcweir 	@see GETFOCUS_*
68cdf0e10cSrcweir */
69cdf0e10cSrcweir #define EBBF_SMART_TAB_TRAVEL			((sal_Int32)0x0008)
70cdf0e10cSrcweir 
71cdf0e10cSrcweir /// @deprecated
72cdf0e10cSrcweir #define EBBF_NOROWPICTURE				EBBF_NO_HANDLE_COLUMN_CONTENT
73cdf0e10cSrcweir 
74cdf0e10cSrcweir //==================================================================
75cdf0e10cSrcweir 
76cdf0e10cSrcweir class Edit;
77cdf0e10cSrcweir class ListBoxFrame;
78cdf0e10cSrcweir class ButtonCtrl;
79cdf0e10cSrcweir class SpinField;
80cdf0e10cSrcweir class FormattedField;
81cdf0e10cSrcweir 
82cdf0e10cSrcweir // .......................................................................
83cdf0e10cSrcweir namespace svt
84cdf0e10cSrcweir {
85cdf0e10cSrcweir // .......................................................................
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	class CellControllerRef;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	//==================================================================
90cdf0e10cSrcweir 	//= CellController
91cdf0e10cSrcweir 	//==================================================================
92cdf0e10cSrcweir 	class SVT_DLLPUBLIC CellController : public SvRefBase
93cdf0e10cSrcweir 	{
94cdf0e10cSrcweir 		friend class EditBrowseBox;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	protected:
97cdf0e10cSrcweir 		Control*	pWindow;
98cdf0e10cSrcweir 		sal_Bool	bSuspended;		// <sal_True> if the window is hidden and disabled
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	public:
101cdf0e10cSrcweir 		TYPEINFO();
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 		CellController(Control* pW);
104cdf0e10cSrcweir 		virtual ~CellController();
105cdf0e10cSrcweir 
GetWindow() const106cdf0e10cSrcweir 		Control& GetWindow() const { return *const_cast< CellController* >( this )->pWindow; }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 		virtual void SetModified();
109cdf0e10cSrcweir 		virtual void ClearModified() = 0;
110cdf0e10cSrcweir 		virtual sal_Bool IsModified() const = 0;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 		// commit any current changes. Especially, do any reformatting you need (from input formatting
113cdf0e10cSrcweir 		// to output formatting) here
114cdf0e10cSrcweir 		// 95826 - 2002-10-14 - fs@openoffice.org
115cdf0e10cSrcweir 		virtual void CommitModifications();
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 		// suspending the controller is not culmulative!
118cdf0e10cSrcweir 				void		suspend( );
119cdf0e10cSrcweir 				void		resume( );
isSuspended() const120cdf0e10cSrcweir 		inline	sal_Bool	isSuspended( ) const { return bSuspended; }
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	protected:
123cdf0e10cSrcweir 		virtual sal_Bool MoveAllowed(const KeyEvent& rEvt) const;
124cdf0e10cSrcweir 		virtual void SetModifyHdl(const Link& rLink) = 0;
125cdf0e10cSrcweir 		virtual sal_Bool WantMouseEvent() const;
126cdf0e10cSrcweir 	};
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 	SV_DECL_IMPL_REF(CellController);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	//==================================================================
131cdf0e10cSrcweir 	//= IEditImplementation
132cdf0e10cSrcweir 	//==================================================================
133cdf0e10cSrcweir     class IEditImplementation
134cdf0e10cSrcweir     {
135cdf0e10cSrcweir     public:
136cdf0e10cSrcweir         virtual Control&            GetControl() = 0;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir         virtual String              GetText( LineEnd aSeparator ) const = 0;
139cdf0e10cSrcweir         virtual void                SetText( const String& _rStr ) = 0;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         virtual sal_Bool                IsReadOnly() const = 0;
142cdf0e10cSrcweir         virtual void                SetReadOnly( sal_Bool bReadOnly ) = 0;
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         virtual xub_StrLen          GetMaxTextLen() const = 0;
145cdf0e10cSrcweir         virtual void                SetMaxTextLen( xub_StrLen _nMaxLen ) = 0;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir         virtual Selection           GetSelection() const = 0;
148cdf0e10cSrcweir         virtual void                SetSelection( const Selection& _rSelection ) = 0;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         virtual void                ReplaceSelected( const String& _rStr ) = 0;
151cdf0e10cSrcweir         virtual void                DeleteSelected() = 0;
152cdf0e10cSrcweir         virtual String              GetSelected( LineEnd aSeparator ) const = 0;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         virtual void                SetModified() = 0;
155cdf0e10cSrcweir         virtual sal_Bool            IsModified() const = 0;
156cdf0e10cSrcweir         virtual void                ClearModified() = 0;
157cdf0e10cSrcweir         virtual void                SetModifyHdl( const Link& _rLink ) = 0;
158cdf0e10cSrcweir     };
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     //==================================================================
161cdf0e10cSrcweir 	//= GenericEditImplementation
162cdf0e10cSrcweir 	//==================================================================
163cdf0e10cSrcweir     template <class EDIT>
164cdf0e10cSrcweir     class GenericEditImplementation : public IEditImplementation
165cdf0e10cSrcweir     {
166cdf0e10cSrcweir         EDIT&   m_rEdit;
167cdf0e10cSrcweir 	public:
168cdf0e10cSrcweir 		GenericEditImplementation( EDIT& _rEdit );
169cdf0e10cSrcweir 
GetEditWindow()170cdf0e10cSrcweir         EDIT& GetEditWindow() { return static_cast< EDIT& >( GetControl() ); }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir         virtual Control&            GetControl();
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         virtual String              GetText( LineEnd aSeparator ) const;
175cdf0e10cSrcweir         virtual void                SetText( const String& _rStr );
176cdf0e10cSrcweir 
177cdf0e10cSrcweir         virtual sal_Bool                IsReadOnly() const;
178cdf0e10cSrcweir         virtual void                SetReadOnly( sal_Bool bReadOnly );
179cdf0e10cSrcweir 
180cdf0e10cSrcweir         virtual xub_StrLen          GetMaxTextLen() const;
181cdf0e10cSrcweir         virtual void                SetMaxTextLen( xub_StrLen _nMaxLen );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir         virtual Selection           GetSelection() const;
184cdf0e10cSrcweir         virtual void                SetSelection( const Selection& _rSelection );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir         virtual void                ReplaceSelected( const String& _rStr );
187cdf0e10cSrcweir         virtual void                DeleteSelected();
188cdf0e10cSrcweir         virtual String              GetSelected( LineEnd aSeparator ) const;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir         virtual void                SetModified();
191cdf0e10cSrcweir         virtual sal_Bool            IsModified() const;
192cdf0e10cSrcweir         virtual void                ClearModified();
193cdf0e10cSrcweir         virtual void                SetModifyHdl( const Link& _rLink );
194cdf0e10cSrcweir     };
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     #include <svtools/editimplementation.hxx>
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	//==================================================================
199cdf0e10cSrcweir 	//= MultiLineTextCell
200cdf0e10cSrcweir 	//==================================================================
201cdf0e10cSrcweir     /** a multi line edit which can be used in a cell of a EditBrowseBox
202cdf0e10cSrcweir     */
203cdf0e10cSrcweir     class SVT_DLLPUBLIC MultiLineTextCell : public MultiLineEdit
204cdf0e10cSrcweir     {
205cdf0e10cSrcweir     public:
MultiLineTextCell(Window * _pParent,WinBits _nStyle)206cdf0e10cSrcweir         MultiLineTextCell( Window* _pParent, WinBits _nStyle )
207cdf0e10cSrcweir             :MultiLineEdit( _pParent, _nStyle )
208cdf0e10cSrcweir         {
209cdf0e10cSrcweir         }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     protected:
212cdf0e10cSrcweir         // Window overridables
213cdf0e10cSrcweir         virtual long PreNotify( NotifyEvent& rNEvt );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir         // MultiLineEdit overridables
216cdf0e10cSrcweir         virtual void Modify();
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     private:
219cdf0e10cSrcweir         sal_Bool    dispatchKeyEvent( const KeyEvent& _rEvent );
220cdf0e10cSrcweir     };
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	//==================================================================
223cdf0e10cSrcweir 	//= concrete edit implementations
224cdf0e10cSrcweir 	//==================================================================
225cdf0e10cSrcweir     typedef GenericEditImplementation< Edit >             EditImplementation;
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     typedef GenericEditImplementation< MultiLineTextCell >  MultiLineEditImplementation_Base;
228cdf0e10cSrcweir     class SVT_DLLPUBLIC MultiLineEditImplementation : public MultiLineEditImplementation_Base
229cdf0e10cSrcweir     {
230cdf0e10cSrcweir     public:
MultiLineEditImplementation(MultiLineTextCell & _rEdit)231cdf0e10cSrcweir         MultiLineEditImplementation( MultiLineTextCell& _rEdit ) : MultiLineEditImplementation_Base( _rEdit )
232cdf0e10cSrcweir         {
233cdf0e10cSrcweir         }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir         virtual String GetText( LineEnd aSeparator ) const;
236cdf0e10cSrcweir         virtual String GetSelected( LineEnd aSeparator ) const;
237cdf0e10cSrcweir     };
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     //==================================================================
240cdf0e10cSrcweir 	//= EditCellController
241cdf0e10cSrcweir 	//==================================================================
242cdf0e10cSrcweir     class SVT_DLLPUBLIC EditCellController : public CellController
243cdf0e10cSrcweir     {
244cdf0e10cSrcweir         IEditImplementation*    m_pEditImplementation;
245cdf0e10cSrcweir         sal_Bool                    m_bOwnImplementation;   // did we create m_pEditImplementation?
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	public:
248cdf0e10cSrcweir 		TYPEINFO();
249cdf0e10cSrcweir 		EditCellController( Edit* _pEdit );
250cdf0e10cSrcweir 		EditCellController( MultiLineTextCell* _pEdit );
251cdf0e10cSrcweir 		EditCellController( IEditImplementation* _pImplementation );
252cdf0e10cSrcweir 		~EditCellController( );
253cdf0e10cSrcweir 
GetEditImplementation() const254cdf0e10cSrcweir         const IEditImplementation* GetEditImplementation( ) const { return m_pEditImplementation; }
GetEditImplementation()255cdf0e10cSrcweir               IEditImplementation* GetEditImplementation( )       { return m_pEditImplementation; }
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 		virtual void SetModified();
258cdf0e10cSrcweir 		virtual sal_Bool IsModified() const;
259cdf0e10cSrcweir 		virtual void ClearModified();
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	protected:
262cdf0e10cSrcweir 		virtual sal_Bool MoveAllowed(const KeyEvent& rEvt) const;
263cdf0e10cSrcweir 		virtual void SetModifyHdl(const Link& rLink);
264cdf0e10cSrcweir     };
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 	//==================================================================
267cdf0e10cSrcweir 	//= SpinCellController
268cdf0e10cSrcweir 	//==================================================================
269cdf0e10cSrcweir 	class SVT_DLLPUBLIC SpinCellController : public CellController
270cdf0e10cSrcweir 	{
271cdf0e10cSrcweir 	public:
272cdf0e10cSrcweir 		TYPEINFO();
273cdf0e10cSrcweir 		SpinCellController(SpinField* pSpinField);
GetSpinWindow() const274cdf0e10cSrcweir 		SpinField& GetSpinWindow() const {return (SpinField &)GetWindow();}
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 		virtual void SetModified();
277cdf0e10cSrcweir 		virtual sal_Bool IsModified() const;
278cdf0e10cSrcweir 		virtual void ClearModified();
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 	protected:
281cdf0e10cSrcweir 		virtual sal_Bool MoveAllowed(const KeyEvent& rEvt) const;
282cdf0e10cSrcweir 		virtual void SetModifyHdl(const Link& rLink);
283cdf0e10cSrcweir 	};
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 	//==================================================================
286cdf0e10cSrcweir 	//= CheckBoxControl
287cdf0e10cSrcweir 	//==================================================================
288cdf0e10cSrcweir 	class SVT_DLLPUBLIC CheckBoxControl : public Control
289cdf0e10cSrcweir 	{
290cdf0e10cSrcweir 		CheckBox*	pBox;
291cdf0e10cSrcweir 		Rectangle	aFocusRect;
292cdf0e10cSrcweir 		Link		m_aClickLink,m_aModifyLink;
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	public:
295cdf0e10cSrcweir 		CheckBoxControl(Window* pParent, WinBits nWinStyle = 0);
296cdf0e10cSrcweir 		~CheckBoxControl();
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 		virtual void GetFocus();
299cdf0e10cSrcweir 		virtual long PreNotify(NotifyEvent& rEvt);
300cdf0e10cSrcweir 		virtual void Paint(const Rectangle& rClientRect);
301cdf0e10cSrcweir 		virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
302cdf0e10cSrcweir 		virtual void StateChanged( StateChangedType nStateChange );
303cdf0e10cSrcweir         virtual void DataChanged( const DataChangedEvent& _rEvent );
304cdf0e10cSrcweir 		virtual void Resize();
305cdf0e10cSrcweir 
SetClickHdl(const Link & rHdl)306cdf0e10cSrcweir 		void SetClickHdl(const Link& rHdl) {m_aClickLink = rHdl;}
GetClickHdl() const307cdf0e10cSrcweir 		const Link& GetClickHdl() const {return m_aClickLink;}
308cdf0e10cSrcweir 
SetModifyHdl(const Link & rHdl)309cdf0e10cSrcweir 		void SetModifyHdl(const Link& rHdl) {m_aModifyLink = rHdl;}
GetModifyHdl() const310cdf0e10cSrcweir 		const Link& GetModifyHdl() const {return m_aModifyLink;}
311cdf0e10cSrcweir 
GetBox()312cdf0e10cSrcweir 		CheckBox&	GetBox() {return *pBox;};
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 	private:
315cdf0e10cSrcweir 		DECL_LINK( OnClick, void* );
316cdf0e10cSrcweir 	};
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 	//==================================================================
319cdf0e10cSrcweir 	//= CheckBoxCellController
320cdf0e10cSrcweir 	//==================================================================
321cdf0e10cSrcweir 	class SVT_DLLPUBLIC CheckBoxCellController : public CellController
322cdf0e10cSrcweir 	{
323cdf0e10cSrcweir 	public:
324cdf0e10cSrcweir 		TYPEINFO();
325cdf0e10cSrcweir 
CheckBoxCellController(CheckBoxControl * pWin)326cdf0e10cSrcweir 		CheckBoxCellController(CheckBoxControl* pWin):CellController(pWin){}
327cdf0e10cSrcweir 		CheckBox& GetCheckBox() const;
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 		virtual sal_Bool IsModified() const;
330cdf0e10cSrcweir 		virtual void ClearModified();
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	protected:
333cdf0e10cSrcweir 		virtual void SetModifyHdl(const Link& rLink);
334cdf0e10cSrcweir 		virtual sal_Bool WantMouseEvent() const;
335cdf0e10cSrcweir 	};
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 	//==================================================================
338cdf0e10cSrcweir 	//= ComboBoxControl
339cdf0e10cSrcweir 	//==================================================================
340cdf0e10cSrcweir 	class SVT_DLLPUBLIC ComboBoxControl : public ComboBox
341cdf0e10cSrcweir 	{
342cdf0e10cSrcweir 		friend class ComboBoxCellController;
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 	public:
345cdf0e10cSrcweir 		ComboBoxControl(Window* pParent, WinBits nWinStyle = 0);
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 	protected:
348cdf0e10cSrcweir 		virtual long PreNotify( NotifyEvent& rNEvt );
349cdf0e10cSrcweir 	};
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 	//==================================================================
352cdf0e10cSrcweir 	//= ComboBoxCellController
353cdf0e10cSrcweir 	//==================================================================
354cdf0e10cSrcweir 	class SVT_DLLPUBLIC ComboBoxCellController : public CellController
355cdf0e10cSrcweir 	{
356cdf0e10cSrcweir 	public:
357cdf0e10cSrcweir 		TYPEINFO();
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 		ComboBoxCellController(ComboBoxControl* pParent);
GetComboBox() const360cdf0e10cSrcweir 		ComboBoxControl& GetComboBox() const {return (ComboBoxControl &)GetWindow();}
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 		virtual sal_Bool IsModified() const;
363cdf0e10cSrcweir 		virtual void ClearModified();
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 	protected:
366cdf0e10cSrcweir 		virtual sal_Bool MoveAllowed(const KeyEvent& rEvt) const;
367cdf0e10cSrcweir 		virtual void SetModifyHdl(const Link& rLink);
368cdf0e10cSrcweir 	};
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 	//==================================================================
371cdf0e10cSrcweir 	//= ListBoxControl
372cdf0e10cSrcweir 	//==================================================================
373cdf0e10cSrcweir 	class SVT_DLLPUBLIC ListBoxControl : public ListBox
374cdf0e10cSrcweir 	{
375cdf0e10cSrcweir 		friend class ListBoxCellController;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 	public:
378cdf0e10cSrcweir 		ListBoxControl(Window* pParent, WinBits nWinStyle = 0);
379cdf0e10cSrcweir 
380cdf0e10cSrcweir 	protected:
381cdf0e10cSrcweir 		virtual long PreNotify( NotifyEvent& rNEvt );
382cdf0e10cSrcweir 	};
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 	//==================================================================
385cdf0e10cSrcweir 	//= ListBoxCellController
386cdf0e10cSrcweir 	//==================================================================
387cdf0e10cSrcweir 	class SVT_DLLPUBLIC ListBoxCellController : public CellController
388cdf0e10cSrcweir 	{
389cdf0e10cSrcweir 	public:
390cdf0e10cSrcweir 		TYPEINFO();
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 		ListBoxCellController(ListBoxControl* pParent);
GetListBox() const393cdf0e10cSrcweir 		ListBoxControl& GetListBox() const {return (ListBoxControl &)GetWindow();}
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 		virtual sal_Bool IsModified() const;
396cdf0e10cSrcweir 		virtual void ClearModified();
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 	protected:
399cdf0e10cSrcweir 		virtual sal_Bool MoveAllowed(const KeyEvent& rEvt) const;
400cdf0e10cSrcweir 		virtual void SetModifyHdl(const Link& rLink);
401cdf0e10cSrcweir 	};
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 	//==================================================================
404cdf0e10cSrcweir 	//= FormattedFieldCellController
405cdf0e10cSrcweir 	//==================================================================
406cdf0e10cSrcweir 	class SVT_DLLPUBLIC FormattedFieldCellController : public EditCellController
407cdf0e10cSrcweir 	{
408cdf0e10cSrcweir 	public:
409cdf0e10cSrcweir 		TYPEINFO();
410cdf0e10cSrcweir 		FormattedFieldCellController( FormattedField* _pFormatted );
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 		virtual void CommitModifications();
413cdf0e10cSrcweir 	};
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 	//==================================================================
416cdf0e10cSrcweir 	//= EditBrowserHeader
417cdf0e10cSrcweir 	//==================================================================
418cdf0e10cSrcweir 	class SVT_DLLPUBLIC EditBrowserHeader : public BrowserHeader
419cdf0e10cSrcweir 	{
420cdf0e10cSrcweir 	public:
EditBrowserHeader(BrowseBox * pParent,WinBits nWinBits=WB_BUTTONSTYLE)421cdf0e10cSrcweir 		EditBrowserHeader( BrowseBox* pParent, WinBits nWinBits = WB_BUTTONSTYLE )
422cdf0e10cSrcweir 			:BrowserHeader(pParent, nWinBits){}
423cdf0e10cSrcweir 
424cdf0e10cSrcweir 	protected:
425cdf0e10cSrcweir 		virtual void DoubleClick();
426cdf0e10cSrcweir 	};
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 	//==================================================================
429cdf0e10cSrcweir 	//= EditBrowseBox
430cdf0e10cSrcweir 	//==================================================================
431cdf0e10cSrcweir 	class EditBrowseBoxImpl;
432cdf0e10cSrcweir 	class SVT_DLLPUBLIC EditBrowseBox: public BrowseBox
433cdf0e10cSrcweir 	{
434cdf0e10cSrcweir 		friend class EditBrowserHeader;
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 		enum BrowseInfo
437cdf0e10cSrcweir 		{
438cdf0e10cSrcweir 			COLSELECT	=	1,
439cdf0e10cSrcweir 			ROWSELECT	=	2,
440cdf0e10cSrcweir 			ROWCHANGE	=	4,
441cdf0e10cSrcweir 			COLCHANGE	=	8
442cdf0e10cSrcweir 		};
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 	public:
445cdf0e10cSrcweir 		enum RowStatus
446cdf0e10cSrcweir 		{
447cdf0e10cSrcweir 			CLEAN				=	0,
448cdf0e10cSrcweir 			CURRENT				=	1,
449cdf0e10cSrcweir 			CURRENTNEW			=	2,
450cdf0e10cSrcweir 			MODIFIED			=	3,
451cdf0e10cSrcweir 			NEW					=	4,
452cdf0e10cSrcweir 			DELETED				=	5,
453cdf0e10cSrcweir 			PRIMARYKEY			=	6,
454cdf0e10cSrcweir 			CURRENT_PRIMARYKEY	=	7,
455cdf0e10cSrcweir 			FILTER				=	8,
456cdf0e10cSrcweir 			HEADERFOOTER		=	9
457cdf0e10cSrcweir 		};
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 	private:
460cdf0e10cSrcweir 		// forbid these ones
461cdf0e10cSrcweir 		EditBrowseBox(EditBrowseBox&);
462cdf0e10cSrcweir 		EditBrowseBox& operator=(EditBrowseBox&);
463cdf0e10cSrcweir 
464cdf0e10cSrcweir 		class BrowserMouseEventPtr
465cdf0e10cSrcweir 		{
466cdf0e10cSrcweir 			BrowserMouseEvent* pEvent;
467cdf0e10cSrcweir 			sal_Bool bDown;
468cdf0e10cSrcweir 
469cdf0e10cSrcweir 		public:
BrowserMouseEventPtr()470cdf0e10cSrcweir 			BrowserMouseEventPtr():pEvent(NULL){}
~BrowserMouseEventPtr()471cdf0e10cSrcweir 			~BrowserMouseEventPtr(){Clear();}
472cdf0e10cSrcweir 
Is() const473cdf0e10cSrcweir 			sal_Bool Is() const {return pEvent != NULL;}
IsDown() const474cdf0e10cSrcweir 			sal_Bool IsDown() const {return bDown;}
operator ->() const475cdf0e10cSrcweir 			const BrowserMouseEvent* operator->() const {return pEvent;}
operator *() const476cdf0e10cSrcweir 			const BrowserMouseEvent& operator*() const {return *pEvent;}
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 			SVT_DLLPUBLIC void Clear();
479cdf0e10cSrcweir 			void Set(const BrowserMouseEvent* pEvt, sal_Bool bIsDown);
480cdf0e10cSrcweir 		} aMouseEvent;
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 		const BrowserMouseEvent* pMouseEvent;	// is set during a mouse event
483cdf0e10cSrcweir 		CellControllerRef		 aController,
484cdf0e10cSrcweir 								 aOldController;
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 		sal_uLong	nStartEvent, nEndEvent, nCellModifiedEvent;		// event ids
487cdf0e10cSrcweir 		Window*	m_pFocusWhileRequest;
488cdf0e10cSrcweir 			// In ActivateCell, we grab the focus asynchronously, but if between requesting activation
489cdf0e10cSrcweir 			// and the asynchornous event the focus has changed, we won't grab it for ourself.
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 		long	nPaintRow;	// row beeing painted
492cdf0e10cSrcweir 		long	nEditRow, nOldEditRow;
493cdf0e10cSrcweir 		sal_uInt16	nEditCol, nOldEditCol;
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 		sal_Bool            bHasFocus : 1;
496cdf0e10cSrcweir 		mutable sal_Bool    bPaintStatus : 1;	// paint a status (image) in the handle column
497cdf0e10cSrcweir         sal_Bool            bActiveBeforeTracking;
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 		CheckBoxControl* pCheckBoxPaint;
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 		sal_Int32	m_nBrowserFlags;
502cdf0e10cSrcweir 		ImageList	m_aStatusImages;
503cdf0e10cSrcweir 		::std::auto_ptr< EditBrowseBoxImpl> m_aImpl;
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 	protected:
506cdf0e10cSrcweir 		BrowserHeader*  pHeader;
507cdf0e10cSrcweir 
isGetCellFocusPending() const508cdf0e10cSrcweir 		sal_Bool isGetCellFocusPending() const { return nStartEvent != 0; }
cancelGetCellFocus()509cdf0e10cSrcweir 		void cancelGetCellFocus() { if (nStartEvent) Application::RemoveUserEvent(nStartEvent); nStartEvent = 0; }
forceGetCellFocus()510cdf0e10cSrcweir 		void forceGetCellFocus() { cancelGetCellFocus(); LINK(this, EditBrowseBox, StartEditHdl).Call((void*)NULL); }
511cdf0e10cSrcweir 
getMouseEvent()512cdf0e10cSrcweir 		BrowserMouseEventPtr& getMouseEvent() { return aMouseEvent; }
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 	protected:
GetHeaderBar() const515cdf0e10cSrcweir 		BrowserHeader*	GetHeaderBar() const {return pHeader;}
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 		virtual BrowserHeader* CreateHeaderBar(BrowseBox* pParent);
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 		// if you want to have an own header ...
520cdf0e10cSrcweir 		virtual BrowserHeader* imp_CreateHeaderBar(BrowseBox* pParent);
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 		virtual void ColumnMoved(sal_uInt16 nId);
523cdf0e10cSrcweir 		virtual void ColumnResized(sal_uInt16 nColId);
524cdf0e10cSrcweir 		virtual void Resize();
525cdf0e10cSrcweir 		virtual void ArrangeControls(sal_uInt16& nX, sal_uInt16 nY);
526cdf0e10cSrcweir 		virtual sal_Bool SeekRow(long nRow);
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 		virtual void GetFocus();
529cdf0e10cSrcweir 		virtual void LoseFocus();
530cdf0e10cSrcweir 		virtual void KeyInput(const KeyEvent& rEvt);
531cdf0e10cSrcweir 		virtual void MouseButtonDown(const BrowserMouseEvent& rEvt);
532cdf0e10cSrcweir 		virtual void MouseButtonUp(const BrowserMouseEvent& rEvt);
533cdf0e10cSrcweir 		virtual void StateChanged( StateChangedType nType );
534cdf0e10cSrcweir 		virtual void DataChanged( const DataChangedEvent& rDCEvt );
535cdf0e10cSrcweir 
536cdf0e10cSrcweir         using BrowseBox::MouseButtonUp;
537cdf0e10cSrcweir         using BrowseBox::MouseButtonDown;
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 		virtual long PreNotify(NotifyEvent& rNEvt );
540cdf0e10cSrcweir 		virtual long Notify(NotifyEvent& rNEvt);
541cdf0e10cSrcweir 
542cdf0e10cSrcweir 		virtual void EndScroll();
543cdf0e10cSrcweir 
544cdf0e10cSrcweir 		// should be used instead of GetFieldRectPixel, 'cause this method here takes into account the borders
545cdf0e10cSrcweir 		Rectangle GetCellRect(long nRow, sal_uInt16 nColId, sal_Bool bRelToBrowser = sal_True) const;
546cdf0e10cSrcweir 		virtual sal_uInt32 GetTotalCellWidth(long nRow, sal_uInt16 nColId);
547cdf0e10cSrcweir 		virtual sal_uInt32 GetAutoColumnWidth(sal_uInt16 nColId);
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 		virtual void PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const;
550cdf0e10cSrcweir 		virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId) const = 0;
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 		virtual RowStatus GetRowStatus(long nRow) const;
553cdf0e10cSrcweir 
554cdf0e10cSrcweir         virtual void    RowHeightChanged();
555cdf0e10cSrcweir 
556cdf0e10cSrcweir         // callbacks for the data window
557cdf0e10cSrcweir         virtual void    ImplStartTracking();
558cdf0e10cSrcweir         virtual void    ImplTracking();
559cdf0e10cSrcweir         virtual void    ImplEndTracking();
560cdf0e10cSrcweir 
561cdf0e10cSrcweir         // when changing a row:
562cdf0e10cSrcweir 		// CursorMoving:	cursor is beeing moved, but GetCurRow() still provides the old row
563cdf0e10cSrcweir 		virtual sal_Bool CursorMoving(long nNewRow, sal_uInt16 nNewCol);
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 		// cursor has been moved
566cdf0e10cSrcweir 		virtual void CursorMoved();
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 		virtual void CellModified();		// called whenever a cell has been modified
569cdf0e10cSrcweir 		virtual sal_Bool SaveModified();	// called whenever a cell should be left, and it's content should be saved
570cdf0e10cSrcweir 											// return sal_False prevents leaving the cell
571cdf0e10cSrcweir 		virtual sal_Bool SaveRow();			// commit the current row
572cdf0e10cSrcweir 
IsModified() const573cdf0e10cSrcweir 		virtual sal_Bool IsModified() const {return aController.Is() && aController->IsModified();}
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 		virtual CellController* GetController(long nRow, sal_uInt16 nCol);
576cdf0e10cSrcweir 		virtual void InitController(CellControllerRef& rController, long nRow, sal_uInt16 nCol);
577cdf0e10cSrcweir 		virtual void ResizeController(CellControllerRef& rController, const Rectangle&);
578cdf0e10cSrcweir 		virtual void ReleaseController(CellControllerRef& pController, long nRow, sal_uInt16 nCol);
579cdf0e10cSrcweir 		virtual void DoubleClick(const BrowserMouseEvent&);
580cdf0e10cSrcweir 
ActivateCell()581cdf0e10cSrcweir 		void ActivateCell() { ActivateCell(GetCurRow(), GetCurColumnId()); }
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 		// retrieve the image for the row status
584cdf0e10cSrcweir 		virtual Image GetImage(RowStatus) const;
585cdf0e10cSrcweir 
586cdf0e10cSrcweir 		// inserting columns
587cdf0e10cSrcweir 		// if you don't set a width, this will be calculated automatically
588cdf0e10cSrcweir 		// if the id isn't set the smallest unused will do it ...
589cdf0e10cSrcweir 		virtual sal_uInt16 AppendColumn(const String& rName, sal_uInt16 nWidth = 0, sal_uInt16 nPos = HEADERBAR_APPEND, sal_uInt16 nId = (sal_uInt16)-1);
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 		// called whenever (Shift)Tab or Enter is pressed. If true is returned, these keys
592cdf0e10cSrcweir 		// result in traveling to the next or to th previous cell
593cdf0e10cSrcweir 		virtual sal_Bool IsTabAllowed(sal_Bool bForward) const;
594cdf0e10cSrcweir 
595cdf0e10cSrcweir 		virtual sal_Bool IsCursorMoveAllowed(long nNewRow, sal_uInt16 nNewColId) const;
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 		void	PaintTristate(OutputDevice& rDev, const Rectangle& rRect,const TriState& eState,sal_Bool _bEnabled=sal_True) const;
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 		void AsynchGetFocus();
600cdf0e10cSrcweir 			// secure starting of StartEditHdl
601cdf0e10cSrcweir 
602cdf0e10cSrcweir 	public:
603cdf0e10cSrcweir 		EditBrowseBox(Window* pParent, sal_Int32 nBrowserFlags = EBBF_NONE, WinBits nBits = WB_TABSTOP, BrowserMode nMode = 0 );
604cdf0e10cSrcweir 		EditBrowseBox(Window* pParent, const ResId& rId, sal_Int32 nBrowserFlags = EBBF_NONE, BrowserMode nMode = 0 );
605cdf0e10cSrcweir 		~EditBrowseBox();
606cdf0e10cSrcweir 
IsEditing() const607cdf0e10cSrcweir 		sal_Bool IsEditing() const {return aController.Is();}
InvalidateStatusCell(long nRow)608cdf0e10cSrcweir 		void InvalidateStatusCell(long nRow) {RowModified(nRow, 0);}
609cdf0e10cSrcweir 		void InvalidateHandleColumn();
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 		// late construction
612cdf0e10cSrcweir 		virtual void Init();
613cdf0e10cSrcweir 		virtual void RemoveRows();
614cdf0e10cSrcweir 		virtual void Dispatch(sal_uInt16 nId);
615cdf0e10cSrcweir 
Controller() const616cdf0e10cSrcweir 		CellControllerRef Controller() const { return aController; }
GetBrowserFlags() const617cdf0e10cSrcweir 		sal_Int32	GetBrowserFlags() const { return m_nBrowserFlags; }
618cdf0e10cSrcweir 		void	SetBrowserFlags(sal_Int32 nFlags);
619cdf0e10cSrcweir 
620cdf0e10cSrcweir 		virtual void ActivateCell(long nRow, sal_uInt16	nCol, sal_Bool bSetCellFocus = sal_True);
621cdf0e10cSrcweir 		virtual void DeactivateCell(sal_Bool bUpdate = sal_True);
622cdf0e10cSrcweir 		// Children ---------------------------------------------------------------
623cdf0e10cSrcweir 
624cdf0e10cSrcweir 		/** Creates the accessible object of a data table cell.
625cdf0e10cSrcweir         @param nRow
626cdf0e10cSrcweir 			The row index of the cell.
627cdf0e10cSrcweir         @param nColumnId
628cdf0e10cSrcweir 			The column ID of the cell.
629cdf0e10cSrcweir         @return
630cdf0e10cSrcweir 			The XAccessible interface of the specified cell. */
631cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference<
632cdf0e10cSrcweir 			::com::sun::star::accessibility::XAccessible >
633cdf0e10cSrcweir 		CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnPos );
634cdf0e10cSrcweir 
635cdf0e10cSrcweir 		/** @return  The count of additional controls of the control area. */
636cdf0e10cSrcweir 		virtual sal_Int32 GetAccessibleControlCount() const;
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 		/** Creates the accessible object of an additional control.
639cdf0e10cSrcweir 			@param nIndex
640cdf0e10cSrcweir 				The 0-based index of the control.
641cdf0e10cSrcweir 			@return
642cdf0e10cSrcweir 				The XAccessible interface of the specified control. */
643cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference<
644cdf0e10cSrcweir 			::com::sun::star::accessibility::XAccessible >
645cdf0e10cSrcweir 		CreateAccessibleControl( sal_Int32 nIndex );
646cdf0e10cSrcweir 
647cdf0e10cSrcweir 		/** Creates the accessible object of a column header.
648cdf0e10cSrcweir 			@param nColumnId
649cdf0e10cSrcweir 				The column ID of the header.
650cdf0e10cSrcweir 			@return
651cdf0e10cSrcweir 				The XAccessible interface of the specified column header. */
652cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference<
653cdf0e10cSrcweir 			::com::sun::star::accessibility::XAccessible >
654cdf0e10cSrcweir 		CreateAccessibleRowHeader( sal_Int32 _nRow );
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 		/** Sets focus to current cell of the data table. */
657cdf0e10cSrcweir 		virtual void GrabTableFocus();
658cdf0e10cSrcweir 
659cdf0e10cSrcweir 		virtual Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex);
660cdf0e10cSrcweir 		virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint);
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 		::com::sun::star::uno::Reference<
663cdf0e10cSrcweir 			::com::sun::star::accessibility::XAccessible > CreateAccessibleCheckBoxCell(long _nRow, sal_uInt16 _nColumnPos,const TriState& eState,sal_Bool _bEnabled=sal_True);
664cdf0e10cSrcweir 	protected:
665cdf0e10cSrcweir 		// creates the accessible which wraps the active cell
666cdf0e10cSrcweir 		void	implCreateActiveAccessible( );
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 	private:
669cdf0e10cSrcweir 		virtual void PaintField(OutputDevice& rDev, const Rectangle& rRect,
670cdf0e10cSrcweir 								sal_uInt16 nColumnId ) const;
671cdf0e10cSrcweir         using Control::ImplInitSettings;
672cdf0e10cSrcweir 		SVT_DLLPRIVATE void ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
673cdf0e10cSrcweir 		SVT_DLLPRIVATE void DetermineFocus( const sal_uInt16 _nGetFocusFlags = 0);
674cdf0e10cSrcweir 		inline void HideAndDisable(CellControllerRef& rController);
675cdf0e10cSrcweir 		inline void EnableAndShow() const;
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 		SVT_DLLPRIVATE void implActivateCellOnMouseEvent(const BrowserMouseEvent& _rEvt, sal_Bool _bUp);
678cdf0e10cSrcweir 		SVT_DLLPRIVATE void impl_construct();
679cdf0e10cSrcweir 
680cdf0e10cSrcweir 		DECL_DLLPRIVATE_LINK(ModifyHdl, void* );
681cdf0e10cSrcweir 		DECL_DLLPRIVATE_LINK(StartEditHdl, void* );
682cdf0e10cSrcweir 		DECL_DLLPRIVATE_LINK(EndEditHdl, void* );
683cdf0e10cSrcweir 		DECL_DLLPRIVATE_LINK(CellModifiedHdl, void* );
684cdf0e10cSrcweir 	};
685cdf0e10cSrcweir 
686cdf0e10cSrcweir // .......................................................................
687cdf0e10cSrcweir }	// namespace svt
688cdf0e10cSrcweir // .......................................................................
689cdf0e10cSrcweir 
690cdf0e10cSrcweir #undef SVTOOLS_IN_EDITBROWSEBOX_HXX
691cdf0e10cSrcweir #endif // _SVTOOLS_EDITBROWSEBOX_HXX_
692cdf0e10cSrcweir 
693