Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "datwin.hxx"
31 : :
32 : : #include <vcl/svapp.hxx>
33 : :
34 : : #include <vcl/help.hxx>
35 : : #include <vcl/image.hxx>
36 : :
37 : : #include <tools/debug.hxx>
38 : :
39 : : //===================================================================
40 : 94 : void ButtonFrame::Draw( OutputDevice& rDev )
41 : : {
42 : 94 : Color aOldFillColor = rDev.GetFillColor();
43 : 94 : Color aOldLineColor = rDev.GetLineColor();
44 : :
45 : 94 : const StyleSettings &rSettings = rDev.GetSettings().GetStyleSettings();
46 : 94 : Color aColLight( rSettings.GetLightColor() );
47 : 94 : Color aColShadow( rSettings.GetShadowColor() );
48 : 94 : Color aColFace( rSettings.GetFaceColor() );
49 : :
50 [ + - ]: 94 : rDev.SetLineColor( aColFace );
51 [ + - ]: 94 : rDev.SetFillColor( aColFace );
52 [ + - ]: 94 : rDev.DrawRect( aRect );
53 : :
54 [ + - ]: 94 : if( rDev.GetOutDevType() == OUTDEV_WINDOW )
55 : : {
56 : 94 : Window *pWin = (Window*) &rDev;
57 [ - + ]: 94 : if( bPressed )
58 [ # # ]: 0 : pWin->DrawSelectionBackground( aRect, 0, sal_True, sal_False, sal_False );
59 : : }
60 : : else
61 : : {
62 [ # # ][ # # ]: 0 : rDev.SetLineColor( bPressed ? aColShadow : aColLight );
63 [ # # ]: 0 : rDev.DrawLine( aRect.TopLeft(), Point( aRect.Right(), aRect.Top() ) );
64 [ # # ]: 0 : rDev.DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom() - 1 ) );
65 [ # # ][ # # ]: 0 : rDev.SetLineColor( bPressed ? aColLight : aColShadow );
66 [ # # ][ # # ]: 0 : rDev.DrawLine( aRect.BottomRight(), Point( aRect.Right(), aRect.Top() ) );
67 [ # # ][ # # ]: 0 : rDev.DrawLine( aRect.BottomRight(), Point( aRect.Left(), aRect.Bottom() ) );
68 : : }
69 : :
70 [ - + ]: 94 : if ( aText.Len() )
71 : : {
72 [ # # ][ # # ]: 0 : String aVal = rDev.GetEllipsisString(aText,aInnerRect.GetWidth() - 2*MIN_COLUMNWIDTH);
73 : :
74 [ # # ]: 0 : Font aFont( rDev.GetFont() );
75 [ # # ]: 0 : sal_Bool bOldTransp = aFont.IsTransparent();
76 [ # # ]: 0 : if ( !bOldTransp )
77 : : {
78 [ # # ]: 0 : aFont.SetTransparent( sal_True );
79 [ # # ]: 0 : rDev.SetFont( aFont );
80 : : }
81 : :
82 : 0 : Color aOldColor = rDev.GetTextColor();
83 [ # # ]: 0 : if (m_bDrawDisabled)
84 [ # # ]: 0 : rDev.SetTextColor(rSettings.GetDisableColor());
85 : :
86 : : rDev.DrawText( Point(
87 [ # # ]: 0 : ( aInnerRect.Left() + aInnerRect.Right() ) / 2 - ( rDev.GetTextWidth(aVal) / 2 ),
88 [ # # ]: 0 : aInnerRect.Top() ), aVal );
89 : :
90 : : // restore settings
91 [ # # ]: 0 : if ( !bOldTransp )
92 : : {
93 [ # # ]: 0 : aFont.SetTransparent(sal_False);
94 [ # # ]: 0 : rDev.SetFont( aFont );
95 : : }
96 [ # # ]: 0 : if (m_bDrawDisabled)
97 [ # # ][ # # ]: 0 : rDev.SetTextColor(aOldColor);
[ # # ]
98 : : }
99 : :
100 [ - + ]: 94 : if ( bCurs )
101 : : {
102 [ # # ]: 0 : rDev.SetLineColor( Color( COL_BLACK ) );
103 [ # # ]: 0 : rDev.SetFillColor();
104 : : rDev.DrawRect( Rectangle(
105 [ # # ][ # # ]: 0 : Point( aRect.Left(), aRect.Top() ), Point( aRect.Right(), aRect.Bottom() ) ) );
106 : : }
107 : :
108 [ + - ]: 94 : rDev.SetLineColor( aOldLineColor );
109 [ + - ]: 94 : rDev.SetFillColor( aOldFillColor );
110 : 94 : }
111 : :
112 : : //-------------------------------------------------------------------
113 : :
114 : 204 : BrowserColumn::BrowserColumn( sal_uInt16 nItemId, const class Image &rImage,
115 : : const String& rTitle, sal_uLong nWidthPixel, const Fraction& rCurrentZoom )
116 : : : _nId( nItemId ),
117 : : _nWidth( nWidthPixel ),
118 : : _aImage( rImage ),
119 : : _aTitle( rTitle ),
120 [ + - ]: 204 : _bFrozen( sal_False )
121 : : {
122 : 204 : double n = (double)_nWidth;
123 : 204 : n *= (double)rCurrentZoom.GetDenominator();
124 : 204 : n /= (double)rCurrentZoom.GetNumerator();
125 [ + + ]: 204 : _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
126 : 204 : }
127 : :
128 [ + - ]: 204 : BrowserColumn::~BrowserColumn()
129 : : {
130 [ - + ]: 408 : }
131 : :
132 : : //-------------------------------------------------------------------
133 : :
134 : 0 : void BrowserColumn::SetWidth(sal_uLong nNewWidthPixel, const Fraction& rCurrentZoom)
135 : : {
136 : 0 : _nWidth = nNewWidthPixel;
137 : 0 : double n = (double)_nWidth;
138 : 0 : n *= (double)rCurrentZoom.GetDenominator();
139 : 0 : n /= (double)rCurrentZoom.GetNumerator();
140 [ # # ]: 0 : _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
141 : 0 : }
142 : :
143 : : //-------------------------------------------------------------------
144 : :
145 : 128 : void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, sal_Bool bCurs )
146 : : {
147 [ + + ]: 128 : if ( _nId == 0 )
148 : : {
149 : : // paint handle column
150 [ + - ]: 16 : ButtonFrame( rPos, Size( Width()-1, rBox.GetDataRowHeight()-1 ),
151 [ + - + - ]: 32 : String(), sal_False, bCurs, false ).Draw( rDev );
[ + - ][ + - ]
[ + - ]
152 : 16 : Color aOldLineColor = rDev.GetLineColor();
153 [ + - ]: 16 : rDev.SetLineColor( Color( COL_BLACK ) );
154 : : rDev.DrawLine(
155 [ + - ]: 16 : Point( rPos.X(), rPos.Y()+rBox.GetDataRowHeight()-1 ),
156 [ + - ][ + - ]: 32 : Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
157 : : rDev.DrawLine(
158 : 16 : Point( rPos.X() + Width() - 1, rPos.Y() ),
159 [ + - ][ + - ]: 32 : Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
160 [ + - ]: 16 : rDev.SetLineColor( aOldLineColor );
161 : :
162 : : rBox.DoPaintField( rDev,
163 : : Rectangle(
164 : 16 : Point( rPos.X() + 2, rPos.Y() + 2 ),
165 [ + - ]: 16 : Size( Width()-1, rBox.GetDataRowHeight()-1 ) ),
166 : 16 : GetId(),
167 [ + - ][ + - ]: 48 : BrowseBox::BrowserColumnAccess() );
168 : : }
169 : : else
170 : : {
171 : : // paint data column
172 [ - + ][ # # ]: 112 : long nWidth = Width() == LONG_MAX ? rBox.GetDataWindow().GetSizePixel().Width() : Width();
[ - + ][ # # ]
173 : :
174 : : rBox.DoPaintField( rDev,
175 : : Rectangle(
176 : 112 : Point( rPos.X() + MIN_COLUMNWIDTH, rPos.Y() ),
177 [ + - ]: 112 : Size( nWidth-2*MIN_COLUMNWIDTH, rBox.GetDataRowHeight()-1 ) ),
178 : 112 : GetId(),
179 [ + - ][ + - ]: 336 : BrowseBox::BrowserColumnAccess() );
180 : : }
181 : 128 : }
182 : :
183 : : //-------------------------------------------------------------------
184 : :
185 : 0 : void BrowserColumn::ZoomChanged(const Fraction& rNewZoom)
186 : : {
187 : 0 : double n = (double)_nOriginalWidth;
188 : 0 : n *= (double)rNewZoom.GetNumerator();
189 : 0 : n /= (double)rNewZoom.GetDenominator();
190 : :
191 [ # # ]: 0 : _nWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
192 : 0 : }
193 : :
194 : : //-------------------------------------------------------------------
195 : :
196 : 40 : BrowserDataWin::BrowserDataWin( BrowseBox* pParent )
197 : : :Control( pParent, WinBits(WB_CLIPCHILDREN) )
198 : : ,DragSourceHelper( this )
199 : : ,DropTargetHelper( this )
200 : : ,pHeaderBar( 0 )
201 : : ,pEventWin( pParent )
202 : : ,pCornerWin( 0 )
203 : : ,pDtorNotify( 0 )
204 : : ,bInPaint( sal_False )
205 : : ,bInCommand( sal_False )
206 : : ,bNoScrollBack( sal_False )
207 : : ,bNoHScroll( sal_False )
208 : : ,bNoVScroll( sal_False )
209 : : ,bUpdateMode( sal_True )
210 : : ,bResizeOnPaint( sal_False )
211 : : ,bUpdateOnUnlock( sal_False )
212 : : ,bInUpdateScrollbars( sal_False )
213 : : ,bHadRecursion( sal_False )
214 : : ,bOwnDataChangedHdl( sal_False )
215 : : ,bCallingDropCallback( sal_False )
216 : : ,nUpdateLock( 0 )
217 : : ,nCursorHidden( 0 )
218 : : ,m_nDragRowDividerLimit( 0 )
219 [ + - ][ + - ]: 40 : ,m_nDragRowDividerOffset( 0 )
[ + - ][ + - ]
[ + - ][ + - ]
220 : : {
221 [ + - ]: 40 : aMouseTimer.SetTimeoutHdl( LINK( this, BrowserDataWin, RepeatedMouseMove ) );
222 [ + - ]: 40 : aMouseTimer.SetTimeout( 100 );
223 : 40 : }
224 : :
225 : : //-------------------------------------------------------------------
226 [ + - ][ + - ]: 40 : BrowserDataWin::~BrowserDataWin()
[ + - ][ + - ]
227 : : {
228 [ - + ]: 40 : if( pDtorNotify )
229 : 0 : *pDtorNotify = sal_True;
230 : :
231 [ - + ]: 40 : for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i )
232 [ # # ]: 0 : delete aInvalidRegion[ i ];
233 : 40 : aInvalidRegion.clear();
234 [ - + ]: 80 : }
235 : :
236 : : //-------------------------------------------------------------------
237 : 2 : void BrowserDataWin::LeaveUpdateLock()
238 : : {
239 [ + - ]: 2 : if ( !--nUpdateLock )
240 : : {
241 : 2 : DoOutstandingInvalidations();
242 [ - + ]: 2 : if (bUpdateOnUnlock )
243 : : {
244 : 0 : Control::Update();
245 : 0 : bUpdateOnUnlock = sal_False;
246 : : }
247 : : }
248 : 2 : }
249 : :
250 : : //-------------------------------------------------------------------
251 : 208 : void InitSettings_Impl( Window *pWin,
252 : : sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
253 : : {
254 : : const StyleSettings& rStyleSettings =
255 : 208 : pWin->GetSettings().GetStyleSettings();
256 : :
257 [ + - ]: 208 : if ( bFont )
258 : : {
259 [ + - ]: 208 : Font aFont = rStyleSettings.GetFieldFont();
260 [ + - ][ + + ]: 208 : if ( pWin->IsControlFont() )
261 [ + - ][ + - ]: 84 : aFont.Merge( pWin->GetControlFont() );
[ + - ]
262 [ + - ][ + - ]: 208 : pWin->SetZoomedPointFont( aFont );
263 : : }
264 : :
265 [ - + ][ # # ]: 208 : if ( bFont || bForeground )
266 : : {
267 : 208 : Color aTextColor = rStyleSettings.GetWindowTextColor();
268 [ - + ][ + - ]: 208 : if ( pWin->IsControlForeground() )
269 [ # # ]: 0 : aTextColor = pWin->GetControlForeground();
270 [ + - ]: 208 : pWin->SetTextColor( aTextColor );
271 : : }
272 : :
273 [ + - ]: 208 : if ( bBackground )
274 : : {
275 [ - + ]: 208 : if( pWin->IsControlBackground() )
276 [ # # ][ # # ]: 0 : pWin->SetBackground( pWin->GetControlBackground() );
[ # # ]
277 : : else
278 [ + - ]: 208 : pWin->SetBackground( rStyleSettings.GetWindowColor() );
279 : : }
280 : 208 : }
281 : :
282 : : //-------------------------------------------------------------------
283 : 0 : void BrowserDataWin::Update()
284 : : {
285 [ # # ]: 0 : if ( !nUpdateLock )
286 : 0 : Control::Update();
287 : : else
288 : 0 : bUpdateOnUnlock = sal_True;
289 : 0 : }
290 : :
291 : : //-------------------------------------------------------------------
292 : 64 : void BrowserDataWin::DataChanged( const DataChangedEvent& rDCEvt )
293 : : {
294 [ + - + - ]: 128 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
[ + - ]
295 : 64 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
296 : : {
297 [ + - ]: 64 : if( !bOwnDataChangedHdl )
298 : : {
299 : 64 : InitSettings_Impl( this, sal_True, sal_True, sal_True );
300 : 64 : Invalidate();
301 : 64 : InitSettings_Impl( GetParent(), sal_True, sal_True, sal_True );
302 : 64 : GetParent()->Invalidate();
303 : 64 : GetParent()->Resize();
304 : : }
305 : : }
306 : : else
307 : 0 : Control::DataChanged( rDCEvt );
308 : 64 : }
309 : :
310 : : //-------------------------------------------------------------------
311 : 166 : void BrowserDataWin::Paint( const Rectangle& rRect )
312 : : {
313 [ + - ][ + - ]: 166 : if ( !nUpdateLock && GetUpdateMode() )
[ + - ]
314 : : {
315 [ + + ]: 166 : if ( bInPaint )
316 : : {
317 [ + - ]: 48 : aInvalidRegion.push_back( new Rectangle( rRect ) );
318 : 166 : return;
319 : : }
320 : 118 : bInPaint = sal_True;
321 : 118 : ( (BrowseBox*) GetParent() )->PaintData( *this, rRect );
322 : 118 : bInPaint = sal_False;
323 : 118 : DoOutstandingInvalidations();
324 : : }
325 : : else
326 [ # # ]: 0 : aInvalidRegion.push_back( new Rectangle( rRect ) );
327 : : }
328 : :
329 : : //-------------------------------------------------------------------
330 : :
331 : 0 : BrowseEvent BrowserDataWin::CreateBrowseEvent( const Point& rPosPixel )
332 : : {
333 [ # # ]: 0 : BrowseBox *pBox = GetParent();
334 : :
335 : : // seek to row under mouse
336 : 0 : long nRelRow = rPosPixel.Y() < 0
337 : : ? -1
338 [ # # ][ # # ]: 0 : : rPosPixel.Y() / pBox->GetDataRowHeight();
339 [ # # ]: 0 : long nRow = nRelRow < 0 ? -1 : nRelRow + pBox->nTopRow;
340 : :
341 : : // find column under mouse
342 : 0 : long nMouseX = rPosPixel.X();
343 : 0 : long nColX = 0;
344 : : size_t nCol;
345 [ # # # # ]: 0 : for ( nCol = 0;
[ # # ]
346 [ # # ][ # # ]: 0 : nCol < pBox->pCols->size() && nColX < GetSizePixel().Width();
[ # # ]
347 : : ++nCol )
348 [ # # ][ # # ]: 0 : if ( (*pBox->pCols)[ nCol ]->IsFrozen() || nCol >= pBox->nFirstCol )
[ # # ]
349 : : {
350 : 0 : nColX += (*pBox->pCols)[ nCol ]->Width();
351 [ # # ]: 0 : if ( nMouseX < nColX )
352 : 0 : break;
353 : : }
354 : 0 : sal_uInt16 nColId = BROWSER_INVALIDID;
355 [ # # ]: 0 : if ( nCol < pBox->pCols->size() )
356 : 0 : nColId = (*pBox->pCols)[ nCol ]->GetId();
357 : :
358 : : // compute the field rectangle and field relative MouseEvent
359 [ # # ]: 0 : Rectangle aFieldRect;
360 [ # # ]: 0 : if ( nCol < pBox->pCols->size() )
361 : : {
362 : 0 : nColX -= (*pBox->pCols)[ nCol ]->Width();
363 : : aFieldRect = Rectangle(
364 [ # # ]: 0 : Point( nColX, nRelRow * pBox->GetDataRowHeight() ),
365 : 0 : Size( (*pBox->pCols)[ nCol ]->Width(),
366 [ # # ][ # # ]: 0 : pBox->GetDataRowHeight() ) );
367 : : }
368 : :
369 : : // assemble and return the BrowseEvent
370 : 0 : return BrowseEvent( this, nRow, nCol, nColId, aFieldRect );
371 : : }
372 : :
373 : : //-------------------------------------------------------------------
374 : 0 : sal_Int8 BrowserDataWin::AcceptDrop( const AcceptDropEvent& _rEvt )
375 : : {
376 : 0 : bCallingDropCallback = sal_True;
377 : 0 : sal_Int8 nReturn = DND_ACTION_NONE;
378 [ # # ]: 0 : nReturn = GetParent()->AcceptDrop( BrowserAcceptDropEvent( this, _rEvt ) );
379 : 0 : bCallingDropCallback = sal_False;
380 : 0 : return nReturn;
381 : : }
382 : :
383 : : //-------------------------------------------------------------------
384 : 0 : sal_Int8 BrowserDataWin::ExecuteDrop( const ExecuteDropEvent& _rEvt )
385 : : {
386 : 0 : bCallingDropCallback = sal_True;
387 : 0 : sal_Int8 nReturn = DND_ACTION_NONE;
388 [ # # ]: 0 : nReturn = GetParent()->ExecuteDrop( BrowserExecuteDropEvent( this, _rEvt ) );
389 : 0 : bCallingDropCallback = sal_False;
390 : 0 : return nReturn;
391 : : }
392 : :
393 : : //-------------------------------------------------------------------
394 : 0 : void BrowserDataWin::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
395 : : {
396 [ # # ]: 0 : if ( !GetParent()->bRowDividerDrag )
397 : : {
398 : 0 : Point aEventPos( _rPosPixel );
399 [ # # ][ # # ]: 0 : aEventPos.Y() += GetParent()->GetTitleHeight();
400 [ # # ][ # # ]: 0 : GetParent()->StartDrag( _nAction, aEventPos );
401 : : }
402 : 0 : }
403 : :
404 : : //-------------------------------------------------------------------
405 : 0 : void BrowserDataWin::Command( const CommandEvent& rEvt )
406 : : {
407 : : // scroll mouse event?
408 [ # # ]: 0 : BrowseBox *pBox = GetParent();
409 [ # # # # : 0 : if ( ( (rEvt.GetCommand() == COMMAND_WHEEL) ||
# # ][ # # ]
[ # # ]
410 : 0 : (rEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
411 : 0 : (rEvt.GetCommand() == COMMAND_AUTOSCROLL) ) &&
412 [ # # ]: 0 : ( HandleScrollCommand( rEvt, &pBox->aHScroll, pBox->pVScroll ) ) )
413 : : return;
414 : :
415 : 0 : Point aEventPos( rEvt.GetMousePosPixel() );
416 [ # # ]: 0 : long nRow = pBox->GetRowAtYPosPixel( aEventPos.Y(), sal_False);
417 [ # # ]: 0 : MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT );
418 [ # # ][ # # ]: 0 : if ( COMMAND_CONTEXTMENU == rEvt.GetCommand() && rEvt.IsMouseEvent() &&
[ # # ][ # # ]
[ # # ]
419 [ # # ][ # # ]: 0 : nRow < pBox->GetRowCount() && !pBox->IsRowSelected(nRow) )
420 : : {
421 : 0 : sal_Bool bDeleted = sal_False;
422 : 0 : pDtorNotify = &bDeleted;
423 : 0 : bInCommand = sal_True;
424 [ # # ]: 0 : MouseButtonDown( aMouseEvt );
425 [ # # ]: 0 : if( bDeleted )
426 : : return;
427 [ # # ]: 0 : MouseButtonUp( aMouseEvt );
428 [ # # ]: 0 : if( bDeleted )
429 : : return;
430 : 0 : pDtorNotify = 0;
431 : 0 : bInCommand = sal_False;
432 : : }
433 : :
434 [ # # ][ # # ]: 0 : aEventPos.Y() += GetParent()->GetTitleHeight();
435 : 0 : CommandEvent aEvt( aEventPos, rEvt.GetCommand(),
436 [ # # ]: 0 : rEvt.IsMouseEvent(), rEvt.GetData() );
437 : 0 : bInCommand = sal_True;
438 : 0 : sal_Bool bDeleted = sal_False;
439 : 0 : pDtorNotify = &bDeleted;
440 [ # # ][ # # ]: 0 : GetParent()->Command( aEvt );
441 [ # # ]: 0 : if( bDeleted )
442 : : return;
443 : 0 : pDtorNotify = 0;
444 : 0 : bInCommand = sal_False;
445 : :
446 [ # # ]: 0 : if ( COMMAND_STARTDRAG == rEvt.GetCommand() )
447 [ # # ]: 0 : MouseButtonUp( aMouseEvt );
448 : :
449 [ # # ]: 0 : Control::Command( rEvt );
450 : : }
451 : :
452 : : //-------------------------------------------------------------------
453 : :
454 : 0 : sal_Bool BrowserDataWin::ImplRowDividerHitTest( const BrowserMouseEvent& _rEvent )
455 : : {
456 [ # # ]: 0 : if ( ! ( GetParent()->IsInteractiveRowHeightEnabled()
457 : 0 : && ( _rEvent.GetRow() >= 0 )
458 : 0 : && ( _rEvent.GetRow() < GetParent()->GetRowCount() )
459 : 0 : && ( _rEvent.GetColumnId() == BrowseBox::HandleColumnId )
460 [ # # # # : 0 : )
# # # # ]
461 : : )
462 : 0 : return sal_False;
463 : :
464 : 0 : long nDividerDistance = GetParent()->GetDataRowHeight() - ( _rEvent.GetPosPixel().Y() % GetParent()->GetDataRowHeight() );
465 : 0 : return ( nDividerDistance <= 4 );
466 : : }
467 : :
468 : : //-------------------------------------------------------------------
469 : :
470 : 0 : void BrowserDataWin::MouseButtonDown( const MouseEvent& rEvt )
471 : : {
472 [ # # ]: 0 : aLastMousePos = OutputToScreenPixel( rEvt.GetPosPixel() );
473 : :
474 [ # # ]: 0 : BrowserMouseEvent aBrowserEvent( this, rEvt );
475 [ # # ][ # # ]: 0 : if ( ( aBrowserEvent.GetClicks() == 1 ) && ImplRowDividerHitTest( aBrowserEvent ) )
[ # # ][ # # ]
476 : : {
477 [ # # ]: 0 : StartRowDividerDrag( aBrowserEvent.GetPosPixel() );
478 : 0 : return;
479 : : }
480 : :
481 [ # # ][ # # ]: 0 : GetParent()->MouseButtonDown( BrowserMouseEvent( this, rEvt ) );
[ # # ]
482 : : }
483 : :
484 : : //-------------------------------------------------------------------
485 : :
486 : 0 : void BrowserDataWin::MouseMove( const MouseEvent& rEvt )
487 : : {
488 : : // avoid pseudo MouseMoves
489 [ # # ]: 0 : Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
490 [ # # ]: 0 : if ( ( aNewPos == aLastMousePos ) )
491 : 0 : return;
492 : 0 : aLastMousePos = aNewPos;
493 : :
494 : : // transform to a BrowseEvent
495 [ # # ]: 0 : BrowserMouseEvent aBrowserEvent( this, rEvt );
496 [ # # ][ # # ]: 0 : GetParent()->MouseMove( aBrowserEvent );
497 : :
498 : : // pointer shape
499 : 0 : PointerStyle ePointerStyle = POINTER_ARROW;
500 [ # # ][ # # ]: 0 : if ( ImplRowDividerHitTest( aBrowserEvent ) )
501 : 0 : ePointerStyle = POINTER_VSIZEBAR;
502 [ # # ]: 0 : SetPointer( Pointer( ePointerStyle ) );
503 : :
504 : : // dragging out of the visible area?
505 [ # # # # : 0 : if ( rEvt.IsLeft() &&
# # ][ # # ]
506 [ # # ][ # # ]: 0 : ( rEvt.GetPosPixel().Y() > GetSizePixel().Height() ||
[ # # ]
507 : 0 : rEvt.GetPosPixel().Y() < 0 ) )
508 : : {
509 : : // repeat the event
510 : 0 : aRepeatEvt = rEvt;
511 [ # # ]: 0 : aMouseTimer.Start();
512 : : }
513 : : else
514 : : // killing old repeat-event
515 [ # # ]: 0 : if ( aMouseTimer.IsActive() )
516 [ # # ]: 0 : aMouseTimer.Stop();
517 : : }
518 : :
519 : : //-------------------------------------------------------------------
520 : :
521 : 0 : IMPL_LINK_NOARG_INLINE_START(BrowserDataWin, RepeatedMouseMove)
522 : : {
523 [ # # ]: 0 : GetParent()->MouseMove( BrowserMouseEvent( this, aRepeatEvt ) );
524 : 0 : return 0;
525 : : }
526 : 0 : IMPL_LINK_NOARG_INLINE_END(BrowserDataWin, RepeatedMouseMove)
527 : :
528 : : //-------------------------------------------------------------------
529 : :
530 : 0 : void BrowserDataWin::MouseButtonUp( const MouseEvent& rEvt )
531 : : {
532 : : // avoid pseudo MouseMoves
533 [ # # ]: 0 : Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
534 : 0 : aLastMousePos = aNewPos;
535 : :
536 : : // simulate a move to the current position
537 [ # # ]: 0 : MouseMove( rEvt );
538 : :
539 : : // actual button up handling
540 [ # # ]: 0 : ReleaseMouse();
541 [ # # ]: 0 : if ( aMouseTimer.IsActive() )
542 [ # # ]: 0 : aMouseTimer.Stop();
543 [ # # ][ # # ]: 0 : GetParent()->MouseButtonUp( BrowserMouseEvent( this, rEvt ) );
[ # # ]
544 : 0 : }
545 : :
546 : : //-------------------------------------------------------------------
547 : :
548 : 0 : void BrowserDataWin::StartRowDividerDrag( const Point& _rStartPos )
549 : : {
550 [ # # ][ # # ]: 0 : long nDataRowHeight = GetParent()->GetDataRowHeight();
551 : : // the exact separation pos of the two rows
552 : 0 : long nDragRowDividerCurrentPos = _rStartPos.Y();
553 [ # # ]: 0 : if ( ( nDragRowDividerCurrentPos % nDataRowHeight ) > nDataRowHeight / 2 )
554 : 0 : nDragRowDividerCurrentPos += nDataRowHeight;
555 : 0 : nDragRowDividerCurrentPos /= nDataRowHeight;
556 : 0 : nDragRowDividerCurrentPos *= nDataRowHeight;
557 : :
558 : 0 : m_nDragRowDividerOffset = nDragRowDividerCurrentPos - _rStartPos.Y();
559 : :
560 : 0 : m_nDragRowDividerLimit = nDragRowDividerCurrentPos - nDataRowHeight;
561 : :
562 [ # # ]: 0 : GetParent()->bRowDividerDrag = sal_True;
563 [ # # ][ # # ]: 0 : GetParent()->ImplStartTracking();
564 : :
565 [ # # ]: 0 : Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos );
566 [ # # ]: 0 : ShowTracking( aDragSplitRect, SHOWTRACK_SMALL );
567 : :
568 [ # # ]: 0 : StartTracking();
569 : 0 : }
570 : :
571 : : //-------------------------------------------------------------------
572 : :
573 : 0 : void BrowserDataWin::Tracking( const TrackingEvent& rTEvt )
574 : : {
575 [ # # ][ # # ]: 0 : if ( !GetParent()->bRowDividerDrag )
576 : 0 : return;
577 : :
578 : 0 : Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
579 : : // stop resizing at our bottom line
580 [ # # ]: 0 : if ( aMousePos.Y() > GetOutputSizePixel().Height() )
581 : 0 : aMousePos.Y() = GetOutputSizePixel().Height();
582 : :
583 [ # # ]: 0 : if ( rTEvt.IsTrackingEnded() )
584 : : {
585 [ # # ]: 0 : HideTracking();
586 [ # # ]: 0 : GetParent()->bRowDividerDrag = sal_False;
587 [ # # ][ # # ]: 0 : GetParent()->ImplEndTracking();
588 : :
589 [ # # ]: 0 : if ( !rTEvt.IsTrackingCanceled() )
590 : : {
591 : 0 : long nNewRowHeight = aMousePos.Y() + m_nDragRowDividerOffset - m_nDragRowDividerLimit;
592 : :
593 : : // care for minimum row height
594 [ # # ][ # # ]: 0 : if ( nNewRowHeight < GetParent()->QueryMinimumRowHeight() )
[ # # ]
595 [ # # ][ # # ]: 0 : nNewRowHeight = GetParent()->QueryMinimumRowHeight();
596 : :
597 [ # # ][ # # ]: 0 : GetParent()->SetDataRowHeight( nNewRowHeight );
598 [ # # ][ # # ]: 0 : GetParent()->RowHeightChanged();
599 : : }
600 : : }
601 : : else
602 : : {
603 [ # # ][ # # ]: 0 : GetParent()->ImplTracking();
604 : :
605 : 0 : long nDragRowDividerCurrentPos = aMousePos.Y() + m_nDragRowDividerOffset;
606 : :
607 : : // care for minimum row height
608 [ # # ][ # # ]: 0 : if ( nDragRowDividerCurrentPos < m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight() )
[ # # ]
609 [ # # ][ # # ]: 0 : nDragRowDividerCurrentPos = m_nDragRowDividerLimit + GetParent()->QueryMinimumRowHeight();
610 : :
611 [ # # ]: 0 : Rectangle aDragSplitRect( 0, m_nDragRowDividerLimit, GetOutputSizePixel().Width(), nDragRowDividerCurrentPos );
612 [ # # ]: 0 : ShowTracking( aDragSplitRect, SHOWTRACK_SMALL );
613 : : }
614 : : }
615 : :
616 : : //-------------------------------------------------------------------
617 : :
618 : 0 : void BrowserDataWin::KeyInput( const KeyEvent& rEvt )
619 : : {
620 : : // pass to parent window
621 [ # # ]: 0 : if ( !GetParent()->ProcessKey( rEvt ) )
622 : 0 : Control::KeyInput( rEvt );
623 : 0 : }
624 : :
625 : : //-------------------------------------------------------------------
626 : :
627 : 0 : void BrowserDataWin::RequestHelp( const HelpEvent& rHEvt )
628 : : {
629 : 0 : pEventWin = this;
630 : 0 : GetParent()->RequestHelp( rHEvt );
631 : 0 : pEventWin = GetParent();
632 : 0 : }
633 : :
634 : : //===================================================================
635 : :
636 : 0 : BrowseEvent::BrowseEvent( Window* pWindow,
637 : : long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
638 : : const Rectangle& rRect ):
639 : : pWin(pWindow),
640 : : nRow(nAbsRow),
641 : : aRect(rRect),
642 : : nCol(nColumn),
643 : 0 : nColId(nColumnId)
644 : : {
645 : 0 : }
646 : :
647 : : //===================================================================
648 : 0 : BrowserMouseEvent::BrowserMouseEvent( BrowserDataWin *pWindow,
649 : : const MouseEvent& rEvt ):
650 : : MouseEvent(rEvt),
651 : 0 : BrowseEvent( pWindow->CreateBrowseEvent( rEvt.GetPosPixel() ) )
652 : : {
653 : 0 : }
654 : :
655 : : //-------------------------------------------------------------------
656 : :
657 : 0 : BrowserMouseEvent::BrowserMouseEvent( Window *pWindow, const MouseEvent& rEvt,
658 : : long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
659 : : const Rectangle& rRect ):
660 : : MouseEvent(rEvt),
661 : 0 : BrowseEvent( pWindow, nAbsRow, nColumn, nColumnId, rRect )
662 : : {
663 : 0 : }
664 : :
665 : : //===================================================================
666 : :
667 : 0 : BrowserAcceptDropEvent::BrowserAcceptDropEvent( BrowserDataWin *pWindow, const AcceptDropEvent& rEvt )
668 : : :AcceptDropEvent(rEvt)
669 [ # # ]: 0 : ,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
670 : : {
671 : 0 : }
672 : :
673 : : //===================================================================
674 : :
675 : 0 : BrowserExecuteDropEvent::BrowserExecuteDropEvent( BrowserDataWin *pWindow, const ExecuteDropEvent& rEvt )
676 : : :ExecuteDropEvent(rEvt)
677 [ # # ]: 0 : ,BrowseEvent( pWindow->CreateBrowseEvent( rEvt.maPosPixel ) )
678 : : {
679 : 0 : }
680 : :
681 : : //===================================================================
682 : :
683 : : //-------------------------------------------------------------------
684 : :
685 : 84 : void BrowserDataWin::SetUpdateMode( sal_Bool bMode )
686 : : {
687 : : DBG_ASSERT( !bUpdateMode || aInvalidRegion.empty(), "invalid region not empty" );
688 [ - + ]: 84 : if ( (bool) bMode == bUpdateMode )
689 : 84 : return;
690 : :
691 : 84 : bUpdateMode = bMode;
692 [ + + ]: 84 : if ( bMode )
693 : 42 : DoOutstandingInvalidations();
694 : : }
695 : :
696 : : //-------------------------------------------------------------------
697 : 162 : void BrowserDataWin::DoOutstandingInvalidations()
698 : : {
699 [ + + ]: 252 : for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i ) {
700 : 90 : Control::Invalidate( *aInvalidRegion[ i ] );
701 : 90 : delete aInvalidRegion[ i ];
702 : : }
703 : 162 : aInvalidRegion.clear();
704 : 162 : }
705 : :
706 : : //-------------------------------------------------------------------
707 : :
708 : 602 : void BrowserDataWin::Invalidate( sal_uInt16 nFlags )
709 : : {
710 [ + + ]: 602 : if ( !GetUpdateMode() )
711 : : {
712 [ + + ]: 48 : for ( size_t i = 0, n = aInvalidRegion.size(); i < n; ++i )
713 : 4 : delete aInvalidRegion[ i ];
714 : 44 : aInvalidRegion.clear();
715 [ + - ][ + - ]: 44 : aInvalidRegion.push_back( new Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
[ + - ]
716 : : }
717 : : else
718 : 558 : Window::Invalidate( nFlags );
719 : 602 : }
720 : :
721 : : //-------------------------------------------------------------------
722 : :
723 : 72 : void BrowserDataWin::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
724 : : {
725 [ + + ]: 72 : if ( !GetUpdateMode() )
726 [ + - ]: 2 : aInvalidRegion.push_back( new Rectangle( rRect ) );
727 : : else
728 : 70 : Window::Invalidate( rRect, nFlags );
729 : 72 : }
730 : :
731 : : //===================================================================
732 : :
733 : 0 : void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt )
734 : : {
735 : 0 : sal_uLong nPos = GetThumbPos();
736 [ # # ]: 0 : if ( nPos != _nLastPos )
737 : : {
738 [ # # ]: 0 : String aTip( rtl::OUString::valueOf(static_cast<sal_Int32>(nPos)) );
739 [ # # ]: 0 : aTip += '/';
740 [ # # ]: 0 : if ( _pDataWin->GetRealRowCount().Len() )
741 [ # # ]: 0 : aTip += _pDataWin->GetRealRowCount();
742 : : else
743 [ # # ]: 0 : aTip += rtl::OUString::valueOf(static_cast<sal_Int32>(GetRangeMax()));
744 : :
745 [ # # ][ # # ]: 0 : Rectangle aRect( GetPointerPosPixel(), Size( GetTextHeight(), GetTextWidth( aTip ) ) );
[ # # ][ # # ]
746 [ # # ]: 0 : if ( _nTip )
747 [ # # ]: 0 : Help::UpdateTip( _nTip, this, aRect, aTip );
748 : : else
749 [ # # ]: 0 : _nTip = Help::ShowTip( this, aRect, aTip );
750 [ # # ]: 0 : _nLastPos = nPos;
751 : : }
752 : :
753 : 0 : ScrollBar::Tracking( rTEvt );
754 : 0 : }
755 : :
756 : : //-------------------------------------------------------------------
757 : :
758 : 0 : void BrowserScrollBar::EndScroll()
759 : : {
760 [ # # ]: 0 : if ( _nTip )
761 : 0 : Help::HideTip( _nTip );
762 : 0 : _nTip = 0;
763 : 0 : ScrollBar::EndScroll();
764 : 0 : }
765 : :
766 : :
767 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|