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