xref: /AOO41X/main/svtools/source/brwbox/datwin.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 _SFXDATWIN_HXX
25cdf0e10cSrcweir #define _SFXDATWIN_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _BRWBOX_HXX
28cdf0e10cSrcweir #include <svtools/brwbox.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <svtools/brwhead.hxx>
31cdf0e10cSrcweir #include <vcl/timer.hxx>
32cdf0e10cSrcweir #ifndef _IMAGE_HXX //autogen
33cdf0e10cSrcweir #include <vcl/image.hxx>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #include <tools/list.hxx>
36cdf0e10cSrcweir #include <svtools/transfer.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //===================================================================
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #define MIN_COLUMNWIDTH  2
41cdf0e10cSrcweir #define DRAG_CRITICAL    4
42cdf0e10cSrcweir 
43cdf0e10cSrcweir DECLARE_LIST( RectangleList, Rectangle* )
44cdf0e10cSrcweir 
45cdf0e10cSrcweir //===================================================================
46cdf0e10cSrcweir 
47cdf0e10cSrcweir class ButtonFrame
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 	Rectangle	aRect;
50cdf0e10cSrcweir 	Rectangle	aInnerRect;
51cdf0e10cSrcweir 	String		aText;
52cdf0e10cSrcweir 	sal_Bool		bPressed;
53cdf0e10cSrcweir 	sal_Bool		bCurs;
54cdf0e10cSrcweir 	sal_Bool		bAbbr;
55cdf0e10cSrcweir 	sal_Bool		m_bDrawDisabled;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir public:
ButtonFrame(const Point & rPt,const Size & rSz,const String & rText,sal_Bool bPress=sal_False,sal_Bool bCursor=sal_False,sal_Bool bAbbreviate=sal_True,sal_Bool _bDrawDisabled=sal_False)58cdf0e10cSrcweir 			   ButtonFrame( const Point& rPt, const Size& rSz,
59cdf0e10cSrcweir 							const String &rText,
60cdf0e10cSrcweir 							sal_Bool bPress = sal_False,
61cdf0e10cSrcweir 							sal_Bool bCursor = sal_False,
62cdf0e10cSrcweir 							sal_Bool bAbbreviate = sal_True,
63cdf0e10cSrcweir 							sal_Bool _bDrawDisabled = sal_False)
64cdf0e10cSrcweir 				:aRect( rPt, rSz )
65cdf0e10cSrcweir 				,aInnerRect( Point( aRect.Left()+1, aRect.Top()+1 ),
66cdf0e10cSrcweir 							Size( aRect.GetWidth()-2, aRect.GetHeight()-2 ) )
67cdf0e10cSrcweir 				,aText(rText)
68cdf0e10cSrcweir 				,bPressed(bPress)
69cdf0e10cSrcweir 				,bCurs(bCursor)
70cdf0e10cSrcweir 				,bAbbr(bAbbreviate)
71cdf0e10cSrcweir 				,m_bDrawDisabled(_bDrawDisabled)
72cdf0e10cSrcweir 			{
73cdf0e10cSrcweir 			}
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	void    Draw( OutputDevice& rDev );
76cdf0e10cSrcweir };
77cdf0e10cSrcweir 
78cdf0e10cSrcweir //===================================================================
79cdf0e10cSrcweir 
80cdf0e10cSrcweir class BrowserColumn
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 	sal_uInt16      		_nId;
83cdf0e10cSrcweir 	sal_uLong				_nOriginalWidth;
84cdf0e10cSrcweir 	sal_uLong       		_nWidth;
85cdf0e10cSrcweir 	Image       		_aImage;
86cdf0e10cSrcweir 	String      		_aTitle;
87cdf0e10cSrcweir 	sal_Bool        		_bFrozen;
88cdf0e10cSrcweir 	HeaderBarItemBits	_nFlags;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir public:
91cdf0e10cSrcweir 						BrowserColumn( sal_uInt16 nItemId, const Image &rImage,
92cdf0e10cSrcweir 										const String& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom,
93cdf0e10cSrcweir 										HeaderBarItemBits nFlags );
94cdf0e10cSrcweir     virtual            ~BrowserColumn();
95cdf0e10cSrcweir 
GetId() const96cdf0e10cSrcweir 	sal_uInt16				GetId() const { return _nId; }
97cdf0e10cSrcweir 
Width()98cdf0e10cSrcweir 	sal_uLong				Width() { return _nWidth; }
GetImage()99cdf0e10cSrcweir 	Image&  			GetImage() { return _aImage; }
Title()100cdf0e10cSrcweir 	String& 			Title() { return _aTitle; }
Flags()101cdf0e10cSrcweir 	HeaderBarItemBits&	Flags() { return _nFlags; }
102cdf0e10cSrcweir 
IsFrozen() const103cdf0e10cSrcweir 	sal_Bool				IsFrozen() const { return _bFrozen; }
Freeze(sal_Bool bFreeze=sal_True)104cdf0e10cSrcweir 	void				Freeze( sal_Bool bFreeze = sal_True ) { _bFrozen = bFreeze; }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 	virtual void		Draw( BrowseBox& rBox, OutputDevice& rDev,
107cdf0e10cSrcweir 							  const Point& rPos, sal_Bool bCurs  );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	void				SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom);
110cdf0e10cSrcweir 	void				ZoomChanged(const Fraction& rNewZoom);
111cdf0e10cSrcweir };
112cdf0e10cSrcweir 
113cdf0e10cSrcweir //===================================================================
114cdf0e10cSrcweir 
115cdf0e10cSrcweir class BrowserDataWin
116cdf0e10cSrcweir 			:public Control
117cdf0e10cSrcweir 			,public DragSourceHelper
118cdf0e10cSrcweir 			,public DropTargetHelper
119cdf0e10cSrcweir {
120cdf0e10cSrcweir public:
121cdf0e10cSrcweir 	BrowserHeader*	pHeaderBar;		// only for BROWSER_HEADERBAR_NEW
122cdf0e10cSrcweir 	Window*			pEventWin;		// Window of forwarded events
123cdf0e10cSrcweir 	ScrollBarBox*	pCornerWin;		// Window in the corner btw the ScrollBars
124cdf0e10cSrcweir 	sal_Bool*			pDtorNotify;
125cdf0e10cSrcweir 	AutoTimer       aMouseTimer;    // recalls MouseMove on dragging out
126cdf0e10cSrcweir 	MouseEvent      aRepeatEvt;     // a MouseEvent to repeat
127cdf0e10cSrcweir 	Point			aLastMousePos;	// verhindert pseudo-MouseMoves
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	String			aRealRowCount;	// zur Anzeige im VScrollBar
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	RectangleList   aInvalidRegion; // invalidated Rectangles during !UpdateMode
132cdf0e10cSrcweir 	FASTBOOL		bInPaint;		// sal_True while in Paint
133cdf0e10cSrcweir 	FASTBOOL		bInCommand;		// sal_True while in Command
134cdf0e10cSrcweir 	FASTBOOL        bNoScrollBack;  // nur vorwaerts scrollen
135cdf0e10cSrcweir 	FASTBOOL        bNoHScroll;     // kein horizontaler Scrollbar
136cdf0e10cSrcweir 	FASTBOOL        bNoVScroll;     // no vertical scrollbar
137cdf0e10cSrcweir 	FASTBOOL		bAutoHScroll;	// autohide horizontaler Scrollbar
138cdf0e10cSrcweir 	FASTBOOL		bAutoVScroll;	// autohide horizontaler Scrollbar
139cdf0e10cSrcweir 	FASTBOOL		bUpdateMode;	// nicht SV-UpdateMode wegen Invalidate()
140cdf0e10cSrcweir 	FASTBOOL		bAutoSizeLastCol;// last column always fills up window
141cdf0e10cSrcweir 	FASTBOOL		bResizeOnPaint; // outstanding resize-event
142cdf0e10cSrcweir 	FASTBOOL		bUpdateOnUnlock;	// Update() while locked
143cdf0e10cSrcweir 	FASTBOOL		bInUpdateScrollbars;	// Rekursionsschutz
144cdf0e10cSrcweir 	FASTBOOL		bHadRecursion;			// Rekursion war aufgetreten
145cdf0e10cSrcweir 	FASTBOOL		bOwnDataChangedHdl;		// dont change colors in DataChanged
146cdf0e10cSrcweir 	FASTBOOL		bCallingDropCallback;	// we're in a callback to AcceptDrop or ExecuteDrop curently
147cdf0e10cSrcweir 	sal_uInt16			nUpdateLock;	// lock count, dont call Control::Update()!
148cdf0e10cSrcweir 	short			nCursorHidden;	// new conuter for DoHide/ShowCursor
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     long            m_nDragRowDividerLimit;
151cdf0e10cSrcweir     long            m_nDragRowDividerOffset;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir public:
154cdf0e10cSrcweir 					BrowserDataWin( BrowseBox* pParent );
155cdf0e10cSrcweir 					~BrowserDataWin();
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	virtual void	DataChanged( const DataChangedEvent& rDCEvt );
158cdf0e10cSrcweir 	virtual void    Paint( const Rectangle& rRect );
159cdf0e10cSrcweir 	virtual void	RequestHelp( const HelpEvent& rHEvt );
160cdf0e10cSrcweir 	virtual void    Command( const CommandEvent& rEvt );
161cdf0e10cSrcweir 	virtual void    MouseButtonDown( const MouseEvent& rEvt );
162cdf0e10cSrcweir 	virtual void    MouseMove( const MouseEvent& rEvt );
163cdf0e10cSrcweir 					DECL_LINK( RepeatedMouseMove, void * );
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	virtual void    MouseButtonUp( const MouseEvent& rEvt );
166cdf0e10cSrcweir 	virtual void    KeyInput( const KeyEvent& rEvt );
167cdf0e10cSrcweir     virtual void    Tracking( const TrackingEvent& rTEvt );
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	// DropTargetHelper overridables
170cdf0e10cSrcweir 	virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
171cdf0e10cSrcweir 	virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 	// DragSourceHelper overridables
174cdf0e10cSrcweir 	virtual void	StartDrag( sal_Int8 _nAction, const Point& _rPosPixel );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	BrowseEvent 	CreateBrowseEvent( const Point& rPosPixel );
178cdf0e10cSrcweir 	void            Repaint();
GetParent() const179cdf0e10cSrcweir 	BrowseBox*      GetParent() const
180cdf0e10cSrcweir 						 { return (BrowseBox*) Window::GetParent(); }
GetRealRowCount() const181cdf0e10cSrcweir 	const String&	GetRealRowCount() const { return aRealRowCount; }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir 	void            SetUpdateMode( sal_Bool bMode );
GetUpdateMode() const184cdf0e10cSrcweir 	FASTBOOL        GetUpdateMode() const { return bUpdateMode; }
EnterUpdateLock()185cdf0e10cSrcweir 	void			EnterUpdateLock() { ++nUpdateLock; }
186cdf0e10cSrcweir 	void			LeaveUpdateLock();
187cdf0e10cSrcweir 	void            Update();
188cdf0e10cSrcweir 	void            DoOutstandingInvalidations();
189cdf0e10cSrcweir 	void            Invalidate( sal_uInt16 nFlags = 0 );
190cdf0e10cSrcweir 	void            Invalidate( const Rectangle& rRect, sal_uInt16 nFlags = 0 );
Invalidate(const Region & rRegion,sal_uInt16 nFlags=0)191cdf0e10cSrcweir     void            Invalidate( const Region& rRegion, sal_uInt16 nFlags = 0 )
192cdf0e10cSrcweir                     { Control::Invalidate( rRegion, nFlags ); }
193cdf0e10cSrcweir 
194cdf0e10cSrcweir protected:
195cdf0e10cSrcweir     void            StartRowDividerDrag( const Point& _rStartPos );
196cdf0e10cSrcweir     sal_Bool            ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent );
197cdf0e10cSrcweir };
198cdf0e10cSrcweir 
199cdf0e10cSrcweir //-------------------------------------------------------------------
200cdf0e10cSrcweir 
Repaint()201cdf0e10cSrcweir inline void BrowserDataWin::Repaint()
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	if ( GetUpdateMode() )
204cdf0e10cSrcweir 		Update();
205cdf0e10cSrcweir 	Paint( Rectangle( Point(), GetOutputSizePixel() ) );
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir //===================================================================
209cdf0e10cSrcweir 
210cdf0e10cSrcweir class BrowserScrollBar: public ScrollBar
211cdf0e10cSrcweir {
212cdf0e10cSrcweir 	sal_uLong			_nTip;
213cdf0e10cSrcweir 	sal_uLong			_nLastPos;
214cdf0e10cSrcweir 	BrowserDataWin*	_pDataWin;
215cdf0e10cSrcweir 
216cdf0e10cSrcweir public:
BrowserScrollBar(Window * pParent,WinBits nStyle,BrowserDataWin * pDataWin)217cdf0e10cSrcweir 					BrowserScrollBar( Window* pParent, WinBits nStyle,
218cdf0e10cSrcweir 									  BrowserDataWin *pDataWin )
219cdf0e10cSrcweir 					:	ScrollBar( pParent, nStyle ),
220cdf0e10cSrcweir 						_nTip( 0 ),
221cdf0e10cSrcweir 						_nLastPos( ULONG_MAX ),
222cdf0e10cSrcweir 						_pDataWin( pDataWin )
223cdf0e10cSrcweir 					{}
224cdf0e10cSrcweir 					//ScrollBar( Window* pParent, const ResId& rResId );
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	virtual void    Tracking( const TrackingEvent& rTEvt );
227cdf0e10cSrcweir 	virtual void	EndScroll();
228cdf0e10cSrcweir };
229cdf0e10cSrcweir 
230cdf0e10cSrcweir //===================================================================
231cdf0e10cSrcweir 
232cdf0e10cSrcweir void InitSettings_Impl( Window *pWin,
233cdf0e10cSrcweir 		 sal_Bool bFont = sal_True, sal_Bool bForeground = sal_True, sal_Bool bBackground = sal_True );
234cdf0e10cSrcweir 
235cdf0e10cSrcweir //===================================================================
236cdf0e10cSrcweir 
237cdf0e10cSrcweir #ifdef DBG_MI
238cdf0e10cSrcweir 
239cdf0e10cSrcweir void DoLog_Impl( const BrowseBox *pThis, const char *pWhat, const char *pWho );
240cdf0e10cSrcweir #define LOG(pThis,what,who) DoLog_Impl(pThis,what,who)
241cdf0e10cSrcweir 
242cdf0e10cSrcweir #else
243cdf0e10cSrcweir 
244cdf0e10cSrcweir #define LOG(pThis,what,who)
245cdf0e10cSrcweir 
246cdf0e10cSrcweir #endif
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 
249cdf0e10cSrcweir #endif
250cdf0e10cSrcweir 
251