1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5900e8ecSAndrew Rist * distributed with this work for additional information
6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at
10*5900e8ecSAndrew Rist *
11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5900e8ecSAndrew Rist *
13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the
17*5900e8ecSAndrew Rist * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist * under the License.
19*5900e8ecSAndrew Rist *
20*5900e8ecSAndrew Rist *************************************************************/
21*5900e8ecSAndrew Rist
22*5900e8ecSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir #include <tools/debug.hxx>
27cdf0e10cSrcweir #include <svtools/brwbox.hxx>
28cdf0e10cSrcweir #include "datwin.hxx"
29cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
30cdf0e10cSrcweir #include <vcl/salgtype.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #ifndef GCC
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include <tools/multisel.hxx>
35cdf0e10cSrcweir #include <algorithm>
36cdf0e10cSrcweir
37cdf0e10cSrcweir using namespace ::com::sun::star::datatransfer;
38cdf0e10cSrcweir
39cdf0e10cSrcweir #define getDataWindow() ((BrowserDataWin*)pDataWin)
40cdf0e10cSrcweir
41cdf0e10cSrcweir
42cdf0e10cSrcweir //===================================================================
43cdf0e10cSrcweir
44cdf0e10cSrcweir DBG_NAMEEX(BrowseBox)
45cdf0e10cSrcweir
46cdf0e10cSrcweir //===================================================================
47cdf0e10cSrcweir
48cdf0e10cSrcweir extern const char* BrowseBoxCheckInvariants( const void * pVoid );
49cdf0e10cSrcweir
DECLARE_LIST(BrowserColumns,BrowserColumn *)50cdf0e10cSrcweir DECLARE_LIST( BrowserColumns, BrowserColumn* )
51cdf0e10cSrcweir
52cdf0e10cSrcweir //===================================================================
53cdf0e10cSrcweir
54cdf0e10cSrcweir void BrowseBox::StartDrag( sal_Int8 /* _nAction */, const Point& /* _rPosPixel */ )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
57cdf0e10cSrcweir // not interested in this event
58cdf0e10cSrcweir }
59cdf0e10cSrcweir
60cdf0e10cSrcweir //===================================================================
61cdf0e10cSrcweir
AcceptDrop(const AcceptDropEvent & _rEvt)62cdf0e10cSrcweir sal_Int8 BrowseBox::AcceptDrop( const AcceptDropEvent& _rEvt )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir BrowserDataWin* pDataWindow = static_cast<BrowserDataWin*>(pDataWin);
65cdf0e10cSrcweir AcceptDropEvent aTransformed( _rEvt );
66cdf0e10cSrcweir aTransformed.maPosPixel = pDataWindow->ScreenToOutputPixel( OutputToScreenPixel( _rEvt.maPosPixel ) );
67cdf0e10cSrcweir return pDataWindow->AcceptDrop( aTransformed );
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
70cdf0e10cSrcweir //===================================================================
71cdf0e10cSrcweir
ExecuteDrop(const ExecuteDropEvent & _rEvt)72cdf0e10cSrcweir sal_Int8 BrowseBox::ExecuteDrop( const ExecuteDropEvent& _rEvt )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir BrowserDataWin* pDataWindow = static_cast<BrowserDataWin*>(pDataWin);
75cdf0e10cSrcweir ExecuteDropEvent aTransformed( _rEvt );
76cdf0e10cSrcweir aTransformed.maPosPixel = pDataWindow->ScreenToOutputPixel( OutputToScreenPixel( _rEvt.maPosPixel ) );
77cdf0e10cSrcweir return pDataWindow->ExecuteDrop( aTransformed );
78cdf0e10cSrcweir }
79cdf0e10cSrcweir
80cdf0e10cSrcweir //===================================================================
81cdf0e10cSrcweir
AcceptDrop(const BrowserAcceptDropEvent &)82cdf0e10cSrcweir sal_Int8 BrowseBox::AcceptDrop( const BrowserAcceptDropEvent& )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
85cdf0e10cSrcweir // not interested in this event
86cdf0e10cSrcweir return DND_ACTION_NONE;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
89cdf0e10cSrcweir //===================================================================
90cdf0e10cSrcweir
ExecuteDrop(const BrowserExecuteDropEvent &)91cdf0e10cSrcweir sal_Int8 BrowseBox::ExecuteDrop( const BrowserExecuteDropEvent& )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
94cdf0e10cSrcweir // not interested in this event
95cdf0e10cSrcweir return DND_ACTION_NONE;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
98cdf0e10cSrcweir //===================================================================
99cdf0e10cSrcweir
implGetDataFlavors() const100cdf0e10cSrcweir void* BrowseBox::implGetDataFlavors() const
101cdf0e10cSrcweir {
102cdf0e10cSrcweir if (static_cast<BrowserDataWin*>(pDataWin)->bCallingDropCallback)
103cdf0e10cSrcweir return &static_cast<BrowserDataWin*>(pDataWin)->GetDataFlavorExVector();
104cdf0e10cSrcweir return &GetDataFlavorExVector();
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
107cdf0e10cSrcweir //===================================================================
108cdf0e10cSrcweir
IsDropFormatSupported(SotFormatStringId _nFormat)109cdf0e10cSrcweir sal_Bool BrowseBox::IsDropFormatSupported( SotFormatStringId _nFormat )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir if ( static_cast< BrowserDataWin* >( pDataWin )->bCallingDropCallback )
112cdf0e10cSrcweir return static_cast< BrowserDataWin* >( pDataWin )->IsDropFormatSupported( _nFormat );
113cdf0e10cSrcweir
114cdf0e10cSrcweir return DropTargetHelper::IsDropFormatSupported( _nFormat );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir //===================================================================
118cdf0e10cSrcweir
IsDropFormatSupported(SotFormatStringId _nFormat) const119cdf0e10cSrcweir sal_Bool BrowseBox::IsDropFormatSupported( SotFormatStringId _nFormat ) const
120cdf0e10cSrcweir {
121cdf0e10cSrcweir return const_cast< BrowseBox* >( this )->IsDropFormatSupported( _nFormat );
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir //===================================================================
125cdf0e10cSrcweir
IsDropFormatSupported(const DataFlavor & _rFlavor)126cdf0e10cSrcweir sal_Bool BrowseBox::IsDropFormatSupported( const DataFlavor& _rFlavor )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir if ( static_cast< BrowserDataWin* >( pDataWin )->bCallingDropCallback )
129cdf0e10cSrcweir return static_cast< BrowserDataWin* >( pDataWin )->IsDropFormatSupported( _rFlavor );
130cdf0e10cSrcweir
131cdf0e10cSrcweir return DropTargetHelper::IsDropFormatSupported( _rFlavor );
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
134cdf0e10cSrcweir //===================================================================
135cdf0e10cSrcweir
IsDropFormatSupported(const DataFlavor & _rFlavor) const136cdf0e10cSrcweir sal_Bool BrowseBox::IsDropFormatSupported( const DataFlavor& _rFlavor ) const
137cdf0e10cSrcweir {
138cdf0e10cSrcweir return const_cast< BrowseBox* >( this )->IsDropFormatSupported( _rFlavor );
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
141cdf0e10cSrcweir //===================================================================
142cdf0e10cSrcweir
Command(const CommandEvent & rEvt)143cdf0e10cSrcweir void BrowseBox::Command( const CommandEvent& rEvt )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir if ( !getDataWindow()->bInCommand )
146cdf0e10cSrcweir Control::Command( rEvt );
147cdf0e10cSrcweir }
148cdf0e10cSrcweir
149cdf0e10cSrcweir //===================================================================
150cdf0e10cSrcweir
IsInCommandEvent() const151cdf0e10cSrcweir bool BrowseBox::IsInCommandEvent() const
152cdf0e10cSrcweir {
153cdf0e10cSrcweir return getDataWindow()->bInCommand;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir //===================================================================
157cdf0e10cSrcweir
StateChanged(StateChangedType nStateChange)158cdf0e10cSrcweir void BrowseBox::StateChanged( StateChangedType nStateChange )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir Control::StateChanged( nStateChange );
161cdf0e10cSrcweir
162cdf0e10cSrcweir if ( STATE_CHANGE_MIRRORING == nStateChange )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir getDataWindow()->EnableRTL( IsRTLEnabled() );
165cdf0e10cSrcweir
166cdf0e10cSrcweir HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar;
167cdf0e10cSrcweir if ( pHeaderBar )
168cdf0e10cSrcweir pHeaderBar->EnableRTL( IsRTLEnabled() );
169cdf0e10cSrcweir aHScroll.EnableRTL( IsRTLEnabled() );
170cdf0e10cSrcweir if( pVScroll )
171cdf0e10cSrcweir pVScroll->EnableRTL( IsRTLEnabled() );
172cdf0e10cSrcweir Resize();
173cdf0e10cSrcweir }
174cdf0e10cSrcweir else if ( STATE_CHANGE_INITSHOW == nStateChange )
175cdf0e10cSrcweir {
176cdf0e10cSrcweir bBootstrapped = sal_True; // muss zuerst gesetzt werden!
177cdf0e10cSrcweir
178cdf0e10cSrcweir Resize();
179cdf0e10cSrcweir if ( bMultiSelection )
180cdf0e10cSrcweir uRow.pSel->SetTotalRange( Range( 0, nRowCount - 1 ) );
181cdf0e10cSrcweir if ( nRowCount == 0 )
182cdf0e10cSrcweir nCurRow = BROWSER_ENDOFSELECTION;
183cdf0e10cSrcweir else if ( nCurRow == BROWSER_ENDOFSELECTION )
184cdf0e10cSrcweir nCurRow = 0;
185cdf0e10cSrcweir
186cdf0e10cSrcweir
187cdf0e10cSrcweir if ( HasFocus() )
188cdf0e10cSrcweir {
189cdf0e10cSrcweir bSelectionIsVisible = sal_True;
190cdf0e10cSrcweir bHasFocus = sal_True;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir UpdateScrollbars();
193cdf0e10cSrcweir AutoSizeLastColumn();
194cdf0e10cSrcweir CursorMoved();
195cdf0e10cSrcweir }
196cdf0e10cSrcweir else if (STATE_CHANGE_ZOOM == nStateChange)
197cdf0e10cSrcweir {
198cdf0e10cSrcweir pDataWin->SetZoom(GetZoom());
199cdf0e10cSrcweir HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar;
200cdf0e10cSrcweir if (pHeaderBar)
201cdf0e10cSrcweir pHeaderBar->SetZoom(GetZoom());
202cdf0e10cSrcweir
203cdf0e10cSrcweir // let the cols calc their new widths and adjust the header bar
204cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < pCols->Count(); ++nPos )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir pCols->GetObject(nPos)->ZoomChanged(GetZoom());
207cdf0e10cSrcweir if ( pHeaderBar )
208cdf0e10cSrcweir pHeaderBar->SetItemSize( pCols->GetObject(nPos)->GetId(), pCols->GetObject(nPos)->Width() );
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir // all our controls have to be repositioned
212cdf0e10cSrcweir Resize();
213cdf0e10cSrcweir }
214cdf0e10cSrcweir else if (STATE_CHANGE_ENABLE == nStateChange)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir // do we have a handle column?
217cdf0e10cSrcweir sal_Bool bHandleCol = pCols->Count() && (0 == pCols->GetObject(0)->GetId());
218cdf0e10cSrcweir // do we have a header bar
219cdf0e10cSrcweir sal_Bool bHeaderBar = (NULL != static_cast<BrowserDataWin&>(GetDataWindow()).pHeaderBar);
220cdf0e10cSrcweir
221cdf0e10cSrcweir if ( nTitleLines
222cdf0e10cSrcweir && ( !bHeaderBar
223cdf0e10cSrcweir || bHandleCol
224cdf0e10cSrcweir )
225cdf0e10cSrcweir )
226cdf0e10cSrcweir // we draw the text in our header bar in a color dependent on the enabled state. So if this state changed
227cdf0e10cSrcweir // -> redraw
228cdf0e10cSrcweir Invalidate(Rectangle(Point(0, 0), Size(GetOutputSizePixel().Width(), GetTitleHeight() - 1)));
229cdf0e10cSrcweir }
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
232cdf0e10cSrcweir //===================================================================
233cdf0e10cSrcweir
Select()234cdf0e10cSrcweir void BrowseBox::Select()
235cdf0e10cSrcweir {
236cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
239cdf0e10cSrcweir //-------------------------------------------------------------------
240cdf0e10cSrcweir
DoubleClick(const BrowserMouseEvent &)241cdf0e10cSrcweir void BrowseBox::DoubleClick( const BrowserMouseEvent & )
242cdf0e10cSrcweir {
243cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
244cdf0e10cSrcweir }
245cdf0e10cSrcweir
246cdf0e10cSrcweir //-------------------------------------------------------------------
247cdf0e10cSrcweir
QueryMinimumRowHeight()248cdf0e10cSrcweir long BrowseBox::QueryMinimumRowHeight()
249cdf0e10cSrcweir {
250cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
251cdf0e10cSrcweir return CalcZoom( 5 );
252cdf0e10cSrcweir }
253cdf0e10cSrcweir
254cdf0e10cSrcweir //-------------------------------------------------------------------
255cdf0e10cSrcweir
ImplStartTracking()256cdf0e10cSrcweir void BrowseBox::ImplStartTracking()
257cdf0e10cSrcweir {
258cdf0e10cSrcweir DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants );
259cdf0e10cSrcweir }
260cdf0e10cSrcweir
261cdf0e10cSrcweir //-------------------------------------------------------------------
262cdf0e10cSrcweir
ImplTracking()263cdf0e10cSrcweir void BrowseBox::ImplTracking()
264cdf0e10cSrcweir {
265cdf0e10cSrcweir DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants );
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
268cdf0e10cSrcweir //-------------------------------------------------------------------
269cdf0e10cSrcweir
ImplEndTracking()270cdf0e10cSrcweir void BrowseBox::ImplEndTracking()
271cdf0e10cSrcweir {
272cdf0e10cSrcweir DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants );
273cdf0e10cSrcweir }
274cdf0e10cSrcweir
275cdf0e10cSrcweir //-------------------------------------------------------------------
276cdf0e10cSrcweir
RowHeightChanged()277cdf0e10cSrcweir void BrowseBox::RowHeightChanged()
278cdf0e10cSrcweir {
279cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
282cdf0e10cSrcweir //-------------------------------------------------------------------
283cdf0e10cSrcweir
QueryColumnResize(sal_uInt16,long nWidth)284cdf0e10cSrcweir long BrowseBox::QueryColumnResize( sal_uInt16, long nWidth )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
287cdf0e10cSrcweir return nWidth;
288cdf0e10cSrcweir }
289cdf0e10cSrcweir
290cdf0e10cSrcweir //-------------------------------------------------------------------
291cdf0e10cSrcweir
ColumnResized(sal_uInt16)292cdf0e10cSrcweir void BrowseBox::ColumnResized( sal_uInt16 )
293cdf0e10cSrcweir {
294cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
295cdf0e10cSrcweir }
296cdf0e10cSrcweir
297cdf0e10cSrcweir //-------------------------------------------------------------------
298cdf0e10cSrcweir
ColumnMoved(sal_uInt16)299cdf0e10cSrcweir void BrowseBox::ColumnMoved( sal_uInt16 )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
302cdf0e10cSrcweir }
303cdf0e10cSrcweir
304cdf0e10cSrcweir //-------------------------------------------------------------------
305cdf0e10cSrcweir
StartScroll()306cdf0e10cSrcweir void BrowseBox::StartScroll()
307cdf0e10cSrcweir {
308cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
309cdf0e10cSrcweir //((Control*)pDataWin)->HideFocus();
310cdf0e10cSrcweir DoHideCursor( "StartScroll" );
311cdf0e10cSrcweir }
312cdf0e10cSrcweir
313cdf0e10cSrcweir //-------------------------------------------------------------------
314cdf0e10cSrcweir
EndScroll()315cdf0e10cSrcweir void BrowseBox::EndScroll()
316cdf0e10cSrcweir {
317cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
318cdf0e10cSrcweir UpdateScrollbars();
319cdf0e10cSrcweir AutoSizeLastColumn();
320cdf0e10cSrcweir DoShowCursor( "EndScroll" );
321cdf0e10cSrcweir }
322cdf0e10cSrcweir
323cdf0e10cSrcweir //-------------------------------------------------------------------
324cdf0e10cSrcweir
325cdf0e10cSrcweir #ifdef _MSC_VER
326cdf0e10cSrcweir #pragma optimize( "", off )
327cdf0e10cSrcweir #endif
328cdf0e10cSrcweir
ToggleSelection(sal_Bool bForce)329cdf0e10cSrcweir void BrowseBox::ToggleSelection( sal_Bool bForce )
330cdf0e10cSrcweir {
331cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
332cdf0e10cSrcweir
333cdf0e10cSrcweir // selection highlight-toggling allowed?
334cdf0e10cSrcweir if ( bHideSelect )
335cdf0e10cSrcweir return;
336cdf0e10cSrcweir if ( !bForce &&
337cdf0e10cSrcweir ( bNotToggleSel || !IsUpdateMode() || !bSelectionIsVisible ) )
338cdf0e10cSrcweir return;
339cdf0e10cSrcweir
340cdf0e10cSrcweir // only highlight painted areas!
341cdf0e10cSrcweir bNotToggleSel = sal_True;
342cdf0e10cSrcweir if ( sal_False && !getDataWindow()->bInPaint )
343cdf0e10cSrcweir pDataWin->Update();
344cdf0e10cSrcweir
345cdf0e10cSrcweir // accumulate areas of rows to highlight
346cdf0e10cSrcweir RectangleList aHighlightList;
347cdf0e10cSrcweir long nLastRowInRect = 0; // fuer den CFront
348cdf0e10cSrcweir
349cdf0e10cSrcweir // Handle-Column nicht highlighten
350cdf0e10cSrcweir BrowserColumn *pFirstCol = pCols->GetObject(0);
351cdf0e10cSrcweir long nOfsX = (!pFirstCol || pFirstCol->GetId()) ? 0 : pFirstCol->Width();
352cdf0e10cSrcweir
353cdf0e10cSrcweir // accumulate old row selection
354cdf0e10cSrcweir long nBottomRow = nTopRow +
355cdf0e10cSrcweir pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight();
356cdf0e10cSrcweir if ( nBottomRow > GetRowCount() && GetRowCount() )
357cdf0e10cSrcweir nBottomRow = GetRowCount();
358cdf0e10cSrcweir for ( long nRow = bMultiSelection ? uRow.pSel->FirstSelected() : uRow.nSel;
359cdf0e10cSrcweir nRow != BROWSER_ENDOFSELECTION && nRow <= nBottomRow;
360cdf0e10cSrcweir nRow = bMultiSelection ? uRow.pSel->NextSelected() : BROWSER_ENDOFSELECTION )
361cdf0e10cSrcweir {
362cdf0e10cSrcweir if ( nRow < nTopRow )
363cdf0e10cSrcweir continue;
364cdf0e10cSrcweir
365cdf0e10cSrcweir Rectangle aAddRect(
366cdf0e10cSrcweir Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ),
367cdf0e10cSrcweir Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
368cdf0e10cSrcweir if ( aHighlightList.Count() && nLastRowInRect == ( nRow - 1 ) )
369cdf0e10cSrcweir aHighlightList.First()->Union( aAddRect );
370cdf0e10cSrcweir else
371cdf0e10cSrcweir aHighlightList.Insert( new Rectangle( aAddRect ), (sal_uLong) 0 );
372cdf0e10cSrcweir nLastRowInRect = nRow;
373cdf0e10cSrcweir }
374cdf0e10cSrcweir
375cdf0e10cSrcweir // unhighlight the old selection (if any)
376cdf0e10cSrcweir while ( aHighlightList.Count() )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir Rectangle *pRect = aHighlightList.Remove( aHighlightList.Count() - 1 );
379cdf0e10cSrcweir pDataWin->Invalidate( *pRect );
380cdf0e10cSrcweir delete pRect;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir // unhighlight old column selection (if any)
384cdf0e10cSrcweir for ( long nColId = pColSel ? pColSel->FirstSelected() : BROWSER_ENDOFSELECTION;
385cdf0e10cSrcweir nColId != BROWSER_ENDOFSELECTION;
386cdf0e10cSrcweir nColId = pColSel->NextSelected() )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir Rectangle aRect( GetFieldRectPixel(nCurRow,
389cdf0e10cSrcweir pCols->GetObject(nColId)->GetId(),
390cdf0e10cSrcweir sal_False ) );
391cdf0e10cSrcweir aRect.Left() -= MIN_COLUMNWIDTH;
392cdf0e10cSrcweir aRect.Right() += MIN_COLUMNWIDTH;
393cdf0e10cSrcweir aRect.Top() = 0;
394cdf0e10cSrcweir aRect.Bottom() = pDataWin->GetOutputSizePixel().Height();
395cdf0e10cSrcweir pDataWin->Invalidate( aRect );
396cdf0e10cSrcweir }
397cdf0e10cSrcweir
398cdf0e10cSrcweir bNotToggleSel = sal_False;
399cdf0e10cSrcweir }
400cdf0e10cSrcweir
401cdf0e10cSrcweir #ifdef _MSC_VER
402cdf0e10cSrcweir #pragma optimize( "", on )
403cdf0e10cSrcweir #endif
404cdf0e10cSrcweir
405cdf0e10cSrcweir //-------------------------------------------------------------------
406cdf0e10cSrcweir
DrawCursor()407cdf0e10cSrcweir void BrowseBox::DrawCursor()
408cdf0e10cSrcweir {
409cdf0e10cSrcweir sal_Bool bReallyHide = sal_False;
410cdf0e10cSrcweir if ( SMART_CURSOR_HIDE == bHideCursor )
411cdf0e10cSrcweir {
412cdf0e10cSrcweir if ( !GetSelectRowCount() && !GetSelectColumnCount() )
413cdf0e10cSrcweir bReallyHide = sal_True;
414cdf0e10cSrcweir }
415cdf0e10cSrcweir else if ( HARD_CURSOR_HIDE == bHideCursor )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir bReallyHide = sal_True;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
420cdf0e10cSrcweir bReallyHide |= !bSelectionIsVisible || !IsUpdateMode() || bScrolling || nCurRow < 0;
421cdf0e10cSrcweir
422cdf0e10cSrcweir if (PaintCursorIfHiddenOnce())
423cdf0e10cSrcweir bReallyHide |= ( GetCursorHideCount() > 1 );
424cdf0e10cSrcweir else
425cdf0e10cSrcweir bReallyHide |= ( GetCursorHideCount() > 0 );
426cdf0e10cSrcweir
427cdf0e10cSrcweir // keine Cursor auf Handle-Column
428cdf0e10cSrcweir if ( nCurColId == 0 )
429cdf0e10cSrcweir nCurColId = GetColumnId(1);
430cdf0e10cSrcweir
431cdf0e10cSrcweir // Cursor-Rechteck berechnen
432cdf0e10cSrcweir Rectangle aCursor;
433cdf0e10cSrcweir if ( bColumnCursor )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir aCursor = GetFieldRectPixel( nCurRow, nCurColId, sal_False );
436cdf0e10cSrcweir //! --aCursor.Bottom();
437cdf0e10cSrcweir aCursor.Left() -= MIN_COLUMNWIDTH;
438cdf0e10cSrcweir aCursor.Right() += 1;
439cdf0e10cSrcweir aCursor.Bottom() += 1;
440cdf0e10cSrcweir }
441cdf0e10cSrcweir else
442cdf0e10cSrcweir aCursor = Rectangle(
443cdf0e10cSrcweir Point( ( pCols->Count() && pCols->GetObject(0)->GetId() == 0 ) ?
444cdf0e10cSrcweir pCols->GetObject(0)->Width() : 0,
445cdf0e10cSrcweir (nCurRow - nTopRow) * GetDataRowHeight() + 1 ),
446cdf0e10cSrcweir Size( pDataWin->GetOutputSizePixel().Width() + 1,
447cdf0e10cSrcweir GetDataRowHeight() - 2 ) );
448cdf0e10cSrcweir if ( bHLines )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir if ( !bMultiSelection )
451cdf0e10cSrcweir --aCursor.Top();
452cdf0e10cSrcweir --aCursor.Bottom();
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir //!mi_mac pDataWin->Update();
456cdf0e10cSrcweir
457cdf0e10cSrcweir if (m_aCursorColor == COL_TRANSPARENT)
458cdf0e10cSrcweir {
459cdf0e10cSrcweir // auf diesem Plattformen funktioniert der StarView-Focus richtig
460cdf0e10cSrcweir if ( bReallyHide )
461cdf0e10cSrcweir ((Control*)pDataWin)->HideFocus();
462cdf0e10cSrcweir else
463cdf0e10cSrcweir ((Control*)pDataWin)->ShowFocus( aCursor );
464cdf0e10cSrcweir }
465cdf0e10cSrcweir else
466cdf0e10cSrcweir {
467cdf0e10cSrcweir Color rCol = bReallyHide ? pDataWin->GetFillColor() : m_aCursorColor;
468cdf0e10cSrcweir Color aOldFillColor = pDataWin->GetFillColor();
469cdf0e10cSrcweir Color aOldLineColor = pDataWin->GetLineColor();
470cdf0e10cSrcweir pDataWin->SetFillColor();
471cdf0e10cSrcweir pDataWin->SetLineColor( rCol );
472cdf0e10cSrcweir pDataWin->DrawRect( aCursor );
473cdf0e10cSrcweir pDataWin->SetLineColor( aOldLineColor );
474cdf0e10cSrcweir pDataWin->SetFillColor( aOldFillColor );
475cdf0e10cSrcweir }
476cdf0e10cSrcweir }
477cdf0e10cSrcweir
478cdf0e10cSrcweir //-------------------------------------------------------------------
479cdf0e10cSrcweir
GetColumnWidth(sal_uInt16 nId) const480cdf0e10cSrcweir sal_uLong BrowseBox::GetColumnWidth( sal_uInt16 nId ) const
481cdf0e10cSrcweir {
482cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
483cdf0e10cSrcweir
484cdf0e10cSrcweir sal_uInt16 nItemPos = GetColumnPos( nId );
485cdf0e10cSrcweir if ( nItemPos >= pCols->Count() )
486cdf0e10cSrcweir return 0;
487cdf0e10cSrcweir return pCols->GetObject(nItemPos)->Width();
488cdf0e10cSrcweir }
489cdf0e10cSrcweir
490cdf0e10cSrcweir //-------------------------------------------------------------------
491cdf0e10cSrcweir
GetColumnId(sal_uInt16 nPos) const492cdf0e10cSrcweir sal_uInt16 BrowseBox::GetColumnId( sal_uInt16 nPos ) const
493cdf0e10cSrcweir {
494cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
495cdf0e10cSrcweir
496cdf0e10cSrcweir if ( nPos >= pCols->Count() )
497cdf0e10cSrcweir return 0;
498cdf0e10cSrcweir return pCols->GetObject(nPos)->GetId();
499cdf0e10cSrcweir }
500cdf0e10cSrcweir
501cdf0e10cSrcweir //-------------------------------------------------------------------
502cdf0e10cSrcweir
GetColumnPos(sal_uInt16 nId) const503cdf0e10cSrcweir sal_uInt16 BrowseBox::GetColumnPos( sal_uInt16 nId ) const
504cdf0e10cSrcweir {
505cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
506cdf0e10cSrcweir
507cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < pCols->Count(); ++nPos )
508cdf0e10cSrcweir if ( pCols->GetObject(nPos)->GetId() == nId )
509cdf0e10cSrcweir return nPos;
510cdf0e10cSrcweir return BROWSER_INVALIDID;
511cdf0e10cSrcweir }
512cdf0e10cSrcweir
513cdf0e10cSrcweir //-------------------------------------------------------------------
514cdf0e10cSrcweir
IsFrozen(sal_uInt16 nColumnId) const515cdf0e10cSrcweir sal_Bool BrowseBox::IsFrozen( sal_uInt16 nColumnId ) const
516cdf0e10cSrcweir {
517cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
518cdf0e10cSrcweir
519cdf0e10cSrcweir for ( sal_uInt16 nPos = 0; nPos < pCols->Count(); ++nPos )
520cdf0e10cSrcweir if ( pCols->GetObject(nPos)->GetId() == nColumnId )
521cdf0e10cSrcweir return pCols->GetObject(nPos)->IsFrozen();
522cdf0e10cSrcweir return sal_False;
523cdf0e10cSrcweir }
524cdf0e10cSrcweir
525cdf0e10cSrcweir //-------------------------------------------------------------------
526cdf0e10cSrcweir
ExpandRowSelection(const BrowserMouseEvent & rEvt)527cdf0e10cSrcweir void BrowseBox::ExpandRowSelection( const BrowserMouseEvent& rEvt )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
530cdf0e10cSrcweir
531cdf0e10cSrcweir DoHideCursor( "ExpandRowSelection" );
532cdf0e10cSrcweir
533cdf0e10cSrcweir // expand the last selection
534cdf0e10cSrcweir if ( bMultiSelection )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir Range aJustifiedRange( aSelRange );
537cdf0e10cSrcweir aJustifiedRange.Justify();
538cdf0e10cSrcweir
539cdf0e10cSrcweir sal_Bool bSelectThis = ( bSelect != aJustifiedRange.IsInside( rEvt.GetRow() ) );
540cdf0e10cSrcweir
541cdf0e10cSrcweir if ( aJustifiedRange.IsInside( rEvt.GetRow() ) )
542cdf0e10cSrcweir {
543cdf0e10cSrcweir // down and up
544cdf0e10cSrcweir while ( rEvt.GetRow() < aSelRange.Max() )
545cdf0e10cSrcweir { // ZTC/Mac bug - dont put these statemants together!
546cdf0e10cSrcweir SelectRow( aSelRange.Max(), bSelectThis, sal_True );
547cdf0e10cSrcweir --aSelRange.Max();
548cdf0e10cSrcweir }
549cdf0e10cSrcweir while ( rEvt.GetRow() > aSelRange.Max() )
550cdf0e10cSrcweir { // ZTC/Mac bug - dont put these statemants together!
551cdf0e10cSrcweir SelectRow( aSelRange.Max(), bSelectThis, sal_True );
552cdf0e10cSrcweir ++aSelRange.Max();
553cdf0e10cSrcweir }
554cdf0e10cSrcweir }
555cdf0e10cSrcweir else
556cdf0e10cSrcweir {
557cdf0e10cSrcweir // up and down
558cdf0e10cSrcweir sal_Bool bOldSelecting = bSelecting;
559cdf0e10cSrcweir bSelecting = sal_True;
560cdf0e10cSrcweir while ( rEvt.GetRow() < aSelRange.Max() )
561cdf0e10cSrcweir { // ZTC/Mac bug - dont put these statemants together!
562cdf0e10cSrcweir --aSelRange.Max();
563cdf0e10cSrcweir if ( !IsRowSelected( aSelRange.Max() ) )
564cdf0e10cSrcweir {
565cdf0e10cSrcweir SelectRow( aSelRange.Max(), bSelectThis, sal_True );
566cdf0e10cSrcweir bSelect = sal_True;
567cdf0e10cSrcweir }
568cdf0e10cSrcweir }
569cdf0e10cSrcweir while ( rEvt.GetRow() > aSelRange.Max() )
570cdf0e10cSrcweir { // ZTC/Mac bug - dont put these statemants together!
571cdf0e10cSrcweir ++aSelRange.Max();
572cdf0e10cSrcweir if ( !IsRowSelected( aSelRange.Max() ) )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir SelectRow( aSelRange.Max(), bSelectThis, sal_True );
575cdf0e10cSrcweir bSelect = sal_True;
576cdf0e10cSrcweir }
577cdf0e10cSrcweir }
578cdf0e10cSrcweir bSelecting = bOldSelecting;
579cdf0e10cSrcweir if ( bSelect )
580cdf0e10cSrcweir Select();
581cdf0e10cSrcweir }
582cdf0e10cSrcweir }
583cdf0e10cSrcweir else
584cdf0e10cSrcweir if ( !bMultiSelection || !IsRowSelected( rEvt.GetRow() ) )
585cdf0e10cSrcweir SelectRow( rEvt.GetRow(), sal_True );
586cdf0e10cSrcweir
587cdf0e10cSrcweir GoToRow( rEvt.GetRow(), sal_False );
588cdf0e10cSrcweir DoShowCursor( "ExpandRowSelection" );
589cdf0e10cSrcweir }
590cdf0e10cSrcweir
591cdf0e10cSrcweir //-------------------------------------------------------------------
592cdf0e10cSrcweir
Resize()593cdf0e10cSrcweir void BrowseBox::Resize()
594cdf0e10cSrcweir {
595cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
596cdf0e10cSrcweir if ( !bBootstrapped && IsReallyVisible() )
597cdf0e10cSrcweir BrowseBox::StateChanged( STATE_CHANGE_INITSHOW );
598cdf0e10cSrcweir if ( !pCols->Count() )
599cdf0e10cSrcweir {
600cdf0e10cSrcweir getDataWindow()->bResizeOnPaint = sal_True;
601cdf0e10cSrcweir return;
602cdf0e10cSrcweir }
603cdf0e10cSrcweir getDataWindow()->bResizeOnPaint = sal_False;
604cdf0e10cSrcweir
605cdf0e10cSrcweir // calc the size of the scrollbars
606cdf0e10cSrcweir // (we can't ask the scrollbars for their widths cause if we're zoomed they still have to be
607cdf0e10cSrcweir // resized - which is done in UpdateScrollbars)
608cdf0e10cSrcweir sal_uLong nSBSize = GetSettings().GetStyleSettings().GetScrollBarSize();
609cdf0e10cSrcweir if (IsZoom())
610cdf0e10cSrcweir nSBSize = (sal_uLong)(nSBSize * (double)GetZoom());
611cdf0e10cSrcweir
612cdf0e10cSrcweir DoHideCursor( "Resize" );
613cdf0e10cSrcweir sal_uInt16 nOldVisibleRows =
614cdf0e10cSrcweir (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
615cdf0e10cSrcweir
616cdf0e10cSrcweir // did we need a horiz. scroll bar oder gibt es eine Control Area?
617cdf0e10cSrcweir if ( !getDataWindow()->bNoHScroll &&
618cdf0e10cSrcweir ( ( pCols->Count() - FrozenColCount() ) > 1 ) )
619cdf0e10cSrcweir aHScroll.Show();
620cdf0e10cSrcweir else
621cdf0e10cSrcweir aHScroll.Hide();
622cdf0e10cSrcweir
623cdf0e10cSrcweir // calculate the size of the data window
624cdf0e10cSrcweir long nDataHeight = GetOutputSizePixel().Height() - GetTitleHeight();
625cdf0e10cSrcweir if ( aHScroll.IsVisible() || ( nControlAreaWidth != USHRT_MAX ) )
626cdf0e10cSrcweir nDataHeight -= nSBSize;
627cdf0e10cSrcweir
628cdf0e10cSrcweir long nDataWidth = GetOutputSizePixel().Width();
629cdf0e10cSrcweir if ( pVScroll->IsVisible() )
630cdf0e10cSrcweir nDataWidth -= nSBSize;
631cdf0e10cSrcweir
632cdf0e10cSrcweir // adjust position and size of data window
633cdf0e10cSrcweir pDataWin->SetPosSizePixel(
634cdf0e10cSrcweir Point( 0, GetTitleHeight() ),
635cdf0e10cSrcweir Size( nDataWidth, nDataHeight ) );
636cdf0e10cSrcweir
637cdf0e10cSrcweir sal_uInt16 nVisibleRows =
638cdf0e10cSrcweir (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
639cdf0e10cSrcweir
640cdf0e10cSrcweir // TopRow ist unveraendert, aber die Anzahl sichtbarer Zeilen hat sich
641cdf0e10cSrcweir // geaendert
642cdf0e10cSrcweir if ( nVisibleRows != nOldVisibleRows )
643cdf0e10cSrcweir VisibleRowsChanged(nTopRow, nVisibleRows);
644cdf0e10cSrcweir
645cdf0e10cSrcweir UpdateScrollbars();
646cdf0e10cSrcweir
647cdf0e10cSrcweir // Control-Area
648cdf0e10cSrcweir Rectangle aInvalidArea( GetControlArea() );
649cdf0e10cSrcweir aInvalidArea.Right() = GetOutputSizePixel().Width();
650cdf0e10cSrcweir aInvalidArea.Left() = 0;
651cdf0e10cSrcweir Invalidate( aInvalidArea );
652cdf0e10cSrcweir
653cdf0e10cSrcweir // external header-bar
654cdf0e10cSrcweir HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar;
655cdf0e10cSrcweir if ( pHeaderBar )
656cdf0e10cSrcweir {
657cdf0e10cSrcweir // Handle-Column beruecksichtigen
658cdf0e10cSrcweir BrowserColumn *pFirstCol = pCols->GetObject(0);
659cdf0e10cSrcweir long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width();
660cdf0e10cSrcweir pHeaderBar->SetPosSizePixel( Point( nOfsX, 0 ), Size( GetOutputSizePixel().Width() - nOfsX, GetTitleHeight() ) );
661cdf0e10cSrcweir }
662cdf0e10cSrcweir
663cdf0e10cSrcweir AutoSizeLastColumn(); // adjust last column width
664cdf0e10cSrcweir DoShowCursor( "Resize" );
665cdf0e10cSrcweir }
666cdf0e10cSrcweir
667cdf0e10cSrcweir //-------------------------------------------------------------------
668cdf0e10cSrcweir
Paint(const Rectangle & rRect)669cdf0e10cSrcweir void BrowseBox::Paint( const Rectangle& rRect )
670cdf0e10cSrcweir {
671cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
672cdf0e10cSrcweir
673cdf0e10cSrcweir // initializations
674cdf0e10cSrcweir if ( !bBootstrapped && IsReallyVisible() )
675cdf0e10cSrcweir BrowseBox::StateChanged( STATE_CHANGE_INITSHOW );
676cdf0e10cSrcweir if ( !pCols->Count() )
677cdf0e10cSrcweir return;
678cdf0e10cSrcweir
679cdf0e10cSrcweir BrowserColumn *pFirstCol = pCols->GetObject(0);
680cdf0e10cSrcweir sal_Bool bHandleCol = pFirstCol && pFirstCol->GetId() == 0;
681cdf0e10cSrcweir sal_Bool bHeaderBar = getDataWindow()->pHeaderBar != NULL;
682cdf0e10cSrcweir
683cdf0e10cSrcweir // draw delimitational lines
684cdf0e10cSrcweir if ( !getDataWindow()->bNoHScroll )
685cdf0e10cSrcweir DrawLine( Point( 0, aHScroll.GetPosPixel().Y() ),
686cdf0e10cSrcweir Point( GetOutputSizePixel().Width(),
687cdf0e10cSrcweir aHScroll.GetPosPixel().Y() ) );
688cdf0e10cSrcweir
689cdf0e10cSrcweir if ( nTitleLines )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir if ( !bHeaderBar )
692cdf0e10cSrcweir DrawLine( Point( 0, GetTitleHeight() - 1 ),
693cdf0e10cSrcweir Point( GetOutputSizePixel().Width(),
694cdf0e10cSrcweir GetTitleHeight() - 1 ) );
695cdf0e10cSrcweir else if ( bHandleCol )
696cdf0e10cSrcweir DrawLine( Point( 0, GetTitleHeight() - 1 ),
697cdf0e10cSrcweir Point( pFirstCol->Width(), GetTitleHeight() - 1 ) );
698cdf0e10cSrcweir }
699cdf0e10cSrcweir
700cdf0e10cSrcweir // Title Bar
701cdf0e10cSrcweir // Wenn es eine Handle Column gibt und die Headerbar verfuegbar ist, dann nur
702cdf0e10cSrcweir // die HandleColumn
703cdf0e10cSrcweir // Handle-Column beruecksichtigen
704cdf0e10cSrcweir if ( nTitleLines && (!bHeaderBar || bHandleCol) )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir // iterate through columns to redraw
707cdf0e10cSrcweir long nX = 0;
708cdf0e10cSrcweir sal_uInt16 nCol;
709cdf0e10cSrcweir for ( nCol = 0;
710cdf0e10cSrcweir nCol < pCols->Count() && nX < rRect.Right();
711cdf0e10cSrcweir ++nCol )
712cdf0e10cSrcweir {
713cdf0e10cSrcweir // skip invisible colums between frozen and scrollable area
714cdf0e10cSrcweir if ( nCol < nFirstCol && !pCols->GetObject(nCol)->IsFrozen() )
715cdf0e10cSrcweir nCol = nFirstCol;
716cdf0e10cSrcweir
717cdf0e10cSrcweir // nur die HandleCol ?
718cdf0e10cSrcweir if (bHeaderBar && bHandleCol && nCol > 0)
719cdf0e10cSrcweir break;
720cdf0e10cSrcweir
721cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol);
722cdf0e10cSrcweir
723cdf0e10cSrcweir // draw the column and increment position
724cdf0e10cSrcweir if ( pCol->Width() > 4 )
725cdf0e10cSrcweir {
726cdf0e10cSrcweir ButtonFrame aButtonFrame( Point( nX, 0 ),
727cdf0e10cSrcweir Size( pCol->Width()-1, GetTitleHeight()-1 ),
728cdf0e10cSrcweir pCol->Title(), sal_False, sal_False,
729cdf0e10cSrcweir 0 != (BROWSER_COLUMN_TITLEABBREVATION&pCol->Flags()),
730cdf0e10cSrcweir !IsEnabled());
731cdf0e10cSrcweir aButtonFrame.Draw( *this );
732cdf0e10cSrcweir DrawLine( Point( nX + pCol->Width() - 1, 0 ),
733cdf0e10cSrcweir Point( nX + pCol->Width() - 1, GetTitleHeight()-1 ) );
734cdf0e10cSrcweir }
735cdf0e10cSrcweir else
736cdf0e10cSrcweir {
737cdf0e10cSrcweir Color aOldFillColor = GetFillColor();
738cdf0e10cSrcweir SetFillColor( Color( COL_BLACK ) );
739cdf0e10cSrcweir DrawRect( Rectangle( Point( nX, 0 ), Size( pCol->Width(), GetTitleHeight() - 1 ) ) );
740cdf0e10cSrcweir SetFillColor( aOldFillColor );
741cdf0e10cSrcweir }
742cdf0e10cSrcweir
743cdf0e10cSrcweir // skip column
744cdf0e10cSrcweir nX += pCol->Width();
745cdf0e10cSrcweir }
746cdf0e10cSrcweir
747cdf0e10cSrcweir // retouching
748cdf0e10cSrcweir if ( !bHeaderBar && nCol == pCols->Count() )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir const StyleSettings &rSettings = GetSettings().GetStyleSettings();
751cdf0e10cSrcweir Color aColFace( rSettings.GetFaceColor() );
752cdf0e10cSrcweir Color aOldFillColor = GetFillColor();
753cdf0e10cSrcweir Color aOldLineColor = GetLineColor();
754cdf0e10cSrcweir SetFillColor( aColFace );
755cdf0e10cSrcweir SetLineColor( aColFace );
756cdf0e10cSrcweir DrawRect( Rectangle(
757cdf0e10cSrcweir Point( nX, 0 ),
758cdf0e10cSrcweir Point( rRect.Right(), GetTitleHeight() - 2 ) ) );
759cdf0e10cSrcweir SetFillColor( aOldFillColor); // aOldLineColor ); oj 09.02.00 seems to be a copy&paste bug
760cdf0e10cSrcweir SetLineColor( aOldLineColor); // aOldFillColor );
761cdf0e10cSrcweir }
762cdf0e10cSrcweir }
763cdf0e10cSrcweir }
764cdf0e10cSrcweir
765cdf0e10cSrcweir //-------------------------------------------------------------------
766cdf0e10cSrcweir
PaintRow(OutputDevice &,const Rectangle &)767cdf0e10cSrcweir void BrowseBox::PaintRow( OutputDevice&, const Rectangle& )
768cdf0e10cSrcweir {
769cdf0e10cSrcweir }
770cdf0e10cSrcweir
771cdf0e10cSrcweir //-------------------------------------------------------------------
772cdf0e10cSrcweir
Draw(OutputDevice * pDev,const Point & rPos,const Size & rSize,sal_uLong nFlags)773cdf0e10cSrcweir void BrowseBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
774cdf0e10cSrcweir {
775cdf0e10cSrcweir sal_Bool bDrawSelection = (nFlags & WINDOW_DRAW_NOSELECTION) == 0;
776cdf0e10cSrcweir
777cdf0e10cSrcweir // we need pixel coordinates
778cdf0e10cSrcweir Size aRealSize = pDev->LogicToPixel(rSize);
779cdf0e10cSrcweir Point aRealPos = pDev->LogicToPixel(rPos);
780cdf0e10cSrcweir
781cdf0e10cSrcweir if ((rSize.Width() < 3) || (rSize.Height() < 3))
782cdf0e10cSrcweir // we want to have two pixels frame ...
783cdf0e10cSrcweir return;
784cdf0e10cSrcweir
785cdf0e10cSrcweir Font aFont = GetDataWindow().GetDrawPixelFont( pDev );
786cdf0e10cSrcweir // the 'normal' painting uses always the data window as device to output to, so we have to calc the new font
787cdf0e10cSrcweir // relative to the data wins current settings
788cdf0e10cSrcweir
789cdf0e10cSrcweir pDev->Push();
790cdf0e10cSrcweir pDev->SetMapMode();
791cdf0e10cSrcweir pDev->SetFont( aFont );
792cdf0e10cSrcweir
793cdf0e10cSrcweir // draw a frame
794cdf0e10cSrcweir const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
795cdf0e10cSrcweir pDev->SetLineColor(rStyleSettings.GetDarkShadowColor());
796cdf0e10cSrcweir pDev->DrawLine(Point(aRealPos.X(), aRealPos.Y()),
797cdf0e10cSrcweir Point(aRealPos.X(), aRealPos.Y() + aRealSize.Height() - 1));
798cdf0e10cSrcweir pDev->DrawLine(Point(aRealPos.X(), aRealPos.Y()),
799cdf0e10cSrcweir Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y()));
800cdf0e10cSrcweir pDev->SetLineColor(rStyleSettings.GetShadowColor());
801cdf0e10cSrcweir pDev->DrawLine(Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + 1),
802cdf0e10cSrcweir Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + aRealSize.Height() - 1));
803cdf0e10cSrcweir pDev->DrawLine(Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + aRealSize.Height() - 1),
804cdf0e10cSrcweir Point(aRealPos.X() + 1, aRealPos.Y() + aRealSize.Height() - 1));
805cdf0e10cSrcweir
806cdf0e10cSrcweir HeaderBar* pBar = getDataWindow()->pHeaderBar;
807cdf0e10cSrcweir
808cdf0e10cSrcweir // we're drawing onto a foreign device, so we have to fake the DataRowHeight for the subsequent ImplPaintData
809cdf0e10cSrcweir // (as it is based on the settings of our data window, not the foreign device)
810cdf0e10cSrcweir if (!nDataRowHeight)
811cdf0e10cSrcweir ImpGetDataRowHeight();
812cdf0e10cSrcweir long nHeightLogic = PixelToLogic(Size(0, nDataRowHeight), MAP_10TH_MM).Height();
813cdf0e10cSrcweir long nForeignHeightPixel = pDev->LogicToPixel(Size(0, nHeightLogic), MAP_10TH_MM).Height();
814cdf0e10cSrcweir
815cdf0e10cSrcweir long nOriginalHeight = nDataRowHeight;
816cdf0e10cSrcweir nDataRowHeight = nForeignHeightPixel;
817cdf0e10cSrcweir
818cdf0e10cSrcweir // this counts for the column widths, too
819cdf0e10cSrcweir sal_uInt16 nPos;
820cdf0e10cSrcweir for ( nPos = 0; nPos < pCols->Count(); ++nPos )
821cdf0e10cSrcweir {
822cdf0e10cSrcweir BrowserColumn* pCurrent = pCols->GetObject(nPos);
823cdf0e10cSrcweir
824cdf0e10cSrcweir long nWidthLogic = PixelToLogic(Size(pCurrent->Width(), 0), MAP_10TH_MM).Width();
825cdf0e10cSrcweir long nForeignWidthPixel = pDev->LogicToPixel(Size(nWidthLogic, 0), MAP_10TH_MM).Width();
826cdf0e10cSrcweir
827cdf0e10cSrcweir pCurrent->SetWidth(nForeignWidthPixel, GetZoom());
828cdf0e10cSrcweir if ( pBar )
829cdf0e10cSrcweir pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() );
830cdf0e10cSrcweir }
831cdf0e10cSrcweir
832cdf0e10cSrcweir // a smaller area for the content
833cdf0e10cSrcweir ++aRealPos.X();
834cdf0e10cSrcweir ++aRealPos.Y();
835cdf0e10cSrcweir aRealSize.Width() -= 2;
836cdf0e10cSrcweir aRealSize.Height() -= 2;
837cdf0e10cSrcweir
838cdf0e10cSrcweir // let the header bar draw itself
839cdf0e10cSrcweir if ( pBar )
840cdf0e10cSrcweir {
841cdf0e10cSrcweir // the title height with respect to the font set for the given device
842cdf0e10cSrcweir long nTitleHeight = PixelToLogic(Size(0, GetTitleHeight()), MAP_10TH_MM).Height();
843cdf0e10cSrcweir nTitleHeight = pDev->LogicToPixel(Size(0, nTitleHeight), MAP_10TH_MM).Height();
844cdf0e10cSrcweir
845cdf0e10cSrcweir BrowserColumn* pFirstCol = pCols->Count() ? pCols->GetObject(0) : NULL;
846cdf0e10cSrcweir
847cdf0e10cSrcweir Point aHeaderPos(pFirstCol && (pFirstCol->GetId() == 0) ? pFirstCol->Width() : 0, 0);
848cdf0e10cSrcweir Size aHeaderSize(aRealSize.Width() - aHeaderPos.X(), nTitleHeight);
849cdf0e10cSrcweir
850cdf0e10cSrcweir aHeaderPos += aRealPos;
851cdf0e10cSrcweir // do this before converting to logics !
852cdf0e10cSrcweir
853cdf0e10cSrcweir // the header's draw expects logic coordinates, again
854cdf0e10cSrcweir aHeaderPos = pDev->PixelToLogic(aHeaderPos);
855cdf0e10cSrcweir aHeaderSize = pDev->PixelToLogic(aHeaderSize);
856cdf0e10cSrcweir
857cdf0e10cSrcweir pBar->Draw(pDev, aHeaderPos, aHeaderSize, nFlags);
858cdf0e10cSrcweir
859cdf0e10cSrcweir // draw the "upper left cell" (the intersection between the header bar and the handle column)
860cdf0e10cSrcweir if (( pFirstCol->GetId() == 0 ) && ( pFirstCol->Width() > 4 ))
861cdf0e10cSrcweir {
862cdf0e10cSrcweir ButtonFrame aButtonFrame( aRealPos,
863cdf0e10cSrcweir Size( pFirstCol->Width()-1, nTitleHeight-1 ),
864cdf0e10cSrcweir pFirstCol->Title(), sal_False, sal_False, sal_False, !IsEnabled());
865cdf0e10cSrcweir aButtonFrame.Draw( *pDev );
866cdf0e10cSrcweir
867cdf0e10cSrcweir pDev->Push( PUSH_LINECOLOR );
868cdf0e10cSrcweir pDev->SetLineColor( Color( COL_BLACK ) );
869cdf0e10cSrcweir
870cdf0e10cSrcweir pDev->DrawLine( Point( aRealPos.X(), aRealPos.Y() + nTitleHeight-1 ),
871cdf0e10cSrcweir Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) );
872cdf0e10cSrcweir pDev->DrawLine( Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() ),
873cdf0e10cSrcweir Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) );
874cdf0e10cSrcweir
875cdf0e10cSrcweir pDev->Pop();
876cdf0e10cSrcweir }
877cdf0e10cSrcweir
878cdf0e10cSrcweir aRealPos.Y() += aHeaderSize.Height();
879cdf0e10cSrcweir aRealSize.Height() -= aHeaderSize.Height();
880cdf0e10cSrcweir }
881cdf0e10cSrcweir
882cdf0e10cSrcweir // draw our own content (with clipping)
883cdf0e10cSrcweir Region aRegion(Rectangle(aRealPos, aRealSize));
884cdf0e10cSrcweir pDev->SetClipRegion( pDev->PixelToLogic( aRegion ) );
885cdf0e10cSrcweir
886cdf0e10cSrcweir // do we have to paint the background
887cdf0e10cSrcweir sal_Bool bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && GetDataWindow().IsControlBackground();
888cdf0e10cSrcweir if ( bBackground )
889cdf0e10cSrcweir {
890cdf0e10cSrcweir Rectangle aRect( aRealPos, aRealSize );
891cdf0e10cSrcweir pDev->SetFillColor( GetDataWindow().GetControlBackground() );
892cdf0e10cSrcweir pDev->DrawRect( aRect );
893cdf0e10cSrcweir }
894cdf0e10cSrcweir
895cdf0e10cSrcweir ImplPaintData( *pDev, Rectangle( aRealPos, aRealSize ), sal_True, bDrawSelection );
896cdf0e10cSrcweir
897cdf0e10cSrcweir // restore the column widths/data row height
898cdf0e10cSrcweir nDataRowHeight = nOriginalHeight;
899cdf0e10cSrcweir for ( nPos = 0; nPos < pCols->Count(); ++nPos )
900cdf0e10cSrcweir {
901cdf0e10cSrcweir BrowserColumn* pCurrent = pCols->GetObject(nPos);
902cdf0e10cSrcweir
903cdf0e10cSrcweir long nForeignWidthLogic = pDev->PixelToLogic(Size(pCurrent->Width(), 0), MAP_10TH_MM).Width();
904cdf0e10cSrcweir long nWidthPixel = LogicToPixel(Size(nForeignWidthLogic, 0), MAP_10TH_MM).Width();
905cdf0e10cSrcweir
906cdf0e10cSrcweir pCurrent->SetWidth(nWidthPixel, GetZoom());
907cdf0e10cSrcweir if ( pBar )
908cdf0e10cSrcweir pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() );
909cdf0e10cSrcweir }
910cdf0e10cSrcweir
911cdf0e10cSrcweir pDev->Pop();
912cdf0e10cSrcweir }
913cdf0e10cSrcweir
914cdf0e10cSrcweir //-------------------------------------------------------------------
915cdf0e10cSrcweir
ImplPaintData(OutputDevice & _rOut,const Rectangle & _rRect,sal_Bool _bForeignDevice,sal_Bool _bDrawSelections)916cdf0e10cSrcweir void BrowseBox::ImplPaintData(OutputDevice& _rOut, const Rectangle& _rRect, sal_Bool _bForeignDevice, sal_Bool _bDrawSelections)
917cdf0e10cSrcweir {
918cdf0e10cSrcweir Point aOverallAreaPos = _bForeignDevice ? _rRect.TopLeft() : Point(0,0);
919cdf0e10cSrcweir Size aOverallAreaSize = _bForeignDevice ? _rRect.GetSize() : GetDataWindow().GetOutputSizePixel();
920cdf0e10cSrcweir Point aOverallAreaBRPos = _bForeignDevice ? _rRect.BottomRight() : Point( aOverallAreaSize.Width(), aOverallAreaSize.Height() );
921cdf0e10cSrcweir
922cdf0e10cSrcweir long nDataRowHeigt = GetDataRowHeight();
923cdf0e10cSrcweir
924cdf0e10cSrcweir // compute relative rows to redraw
925cdf0e10cSrcweir sal_uLong nRelTopRow = _bForeignDevice ? 0 : ((sal_uLong)_rRect.Top() / nDataRowHeigt);
926cdf0e10cSrcweir sal_uLong nRelBottomRow = (sal_uLong)(_bForeignDevice ? aOverallAreaSize.Height() : _rRect.Bottom()) / nDataRowHeigt;
927cdf0e10cSrcweir
928cdf0e10cSrcweir // cache frequently used values
929cdf0e10cSrcweir Point aPos( aOverallAreaPos.X(), nRelTopRow * nDataRowHeigt + aOverallAreaPos.Y() );
930cdf0e10cSrcweir _rOut.SetLineColor( Color( COL_WHITE ) );
931cdf0e10cSrcweir const AllSettings& rAllSets = _rOut.GetSettings();
932cdf0e10cSrcweir const StyleSettings &rSettings = rAllSets.GetStyleSettings();
933cdf0e10cSrcweir const Color &rHighlightTextColor = rSettings.GetHighlightTextColor();
934cdf0e10cSrcweir const Color &rHighlightFillColor = rSettings.GetHighlightColor();
935cdf0e10cSrcweir Color aOldTextColor = _rOut.GetTextColor();
936cdf0e10cSrcweir Color aOldFillColor = _rOut.GetFillColor();
937cdf0e10cSrcweir Color aOldLineColor = _rOut.GetLineColor();
938cdf0e10cSrcweir long nHLineX = 0 == pCols->GetObject(0)->GetId()
939cdf0e10cSrcweir ? pCols->GetObject(0)->Width()
940cdf0e10cSrcweir : 0;
941cdf0e10cSrcweir nHLineX += aOverallAreaPos.X();
942cdf0e10cSrcweir
943cdf0e10cSrcweir Color aDelimiterLineColor( ::svtools::ColorConfig().GetColorValue( ::svtools::CALCGRID ).nColor );
944cdf0e10cSrcweir
945cdf0e10cSrcweir // redraw the invalid fields
946cdf0e10cSrcweir sal_Bool bRetouching = sal_False;
947cdf0e10cSrcweir for ( sal_uLong nRelRow = nRelTopRow;
948cdf0e10cSrcweir nRelRow <= nRelBottomRow && (sal_uLong)nTopRow+nRelRow < (sal_uLong)nRowCount;
949cdf0e10cSrcweir ++nRelRow, aPos.Y() += nDataRowHeigt )
950cdf0e10cSrcweir {
951cdf0e10cSrcweir // get row
952cdf0e10cSrcweir // Zur Sicherheit auf zul"assigen Bereich abfragen:
953cdf0e10cSrcweir DBG_ASSERT( (sal_uInt16)(nTopRow+nRelRow) < nRowCount, "BrowseBox::ImplPaintData: invalid seek" );
954cdf0e10cSrcweir if ( (nTopRow+long(nRelRow)) < 0 || (sal_uInt16)(nTopRow+nRelRow) >= nRowCount )
955cdf0e10cSrcweir continue;
956cdf0e10cSrcweir
957cdf0e10cSrcweir // prepare row
958cdf0e10cSrcweir sal_uLong nRow = nTopRow+nRelRow;
959cdf0e10cSrcweir if ( !SeekRow( nRow) ) {
960cdf0e10cSrcweir DBG_ERROR("BrowseBox::ImplPaintData: SeekRow gescheitert");
961cdf0e10cSrcweir }
962cdf0e10cSrcweir _rOut.SetClipRegion();
963cdf0e10cSrcweir aPos.X() = aOverallAreaPos.X();
964cdf0e10cSrcweir
965cdf0e10cSrcweir
966cdf0e10cSrcweir // #73325# don't paint the row outside the painting rectangle (DG)
967cdf0e10cSrcweir // prepare auto-highlight
968cdf0e10cSrcweir Rectangle aRowRect( Point( _rRect.TopLeft().X(), aPos.Y() ),
969cdf0e10cSrcweir Size( _rRect.GetSize().Width(), nDataRowHeigt ) );
970cdf0e10cSrcweir PaintRow( _rOut, aRowRect );
971cdf0e10cSrcweir
972cdf0e10cSrcweir sal_Bool bRowSelected = _bDrawSelections
973cdf0e10cSrcweir && !bHideSelect
974cdf0e10cSrcweir && IsRowSelected( nRow );
975cdf0e10cSrcweir if ( bRowSelected )
976cdf0e10cSrcweir {
977cdf0e10cSrcweir _rOut.SetTextColor( rHighlightTextColor );
978cdf0e10cSrcweir _rOut.SetFillColor( rHighlightFillColor );
979cdf0e10cSrcweir _rOut.SetLineColor();
980cdf0e10cSrcweir _rOut.DrawRect( aRowRect );
981cdf0e10cSrcweir }
982cdf0e10cSrcweir
983cdf0e10cSrcweir // iterate through columns to redraw
984cdf0e10cSrcweir sal_uInt16 nCol;
985cdf0e10cSrcweir for ( nCol = 0; nCol < pCols->Count(); ++nCol )
986cdf0e10cSrcweir {
987cdf0e10cSrcweir // get column
988cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol);
989cdf0e10cSrcweir
990cdf0e10cSrcweir // at end of invalid area
991cdf0e10cSrcweir if ( aPos.X() >= _rRect.Right() )
992cdf0e10cSrcweir break;
993cdf0e10cSrcweir
994cdf0e10cSrcweir // skip invisible colums between frozen and scrollable area
995cdf0e10cSrcweir if ( nCol < nFirstCol && !pCol->IsFrozen() )
996cdf0e10cSrcweir {
997cdf0e10cSrcweir nCol = nFirstCol;
998cdf0e10cSrcweir pCol = pCols->GetObject(nCol);
999cdf0e10cSrcweir if (!pCol)
1000cdf0e10cSrcweir { // FS - 21.05.99 - 66325
1001cdf0e10cSrcweir // ist zwar eigentlich woanders (an der richtigen Stelle) gefixt, aber sicher ist sicher ...
1002cdf0e10cSrcweir DBG_ERROR("BrowseBox::PaintData : nFirstCol is probably invalid !");
1003cdf0e10cSrcweir break;
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir // prepare Column-AutoHighlight
1008cdf0e10cSrcweir sal_Bool bColAutoHighlight = _bDrawSelections
1009cdf0e10cSrcweir && bColumnCursor
1010cdf0e10cSrcweir && IsColumnSelected( pCol->GetId() );
1011cdf0e10cSrcweir if ( bColAutoHighlight )
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir _rOut.SetClipRegion();
1014cdf0e10cSrcweir _rOut.SetTextColor( rHighlightTextColor );
1015cdf0e10cSrcweir _rOut.SetFillColor( rHighlightFillColor );
1016cdf0e10cSrcweir _rOut.SetLineColor();
1017cdf0e10cSrcweir Rectangle aFieldRect( aPos,
1018cdf0e10cSrcweir Size( pCol->Width(), nDataRowHeigt ) );
1019cdf0e10cSrcweir _rOut.DrawRect( aFieldRect );
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir if (!m_bFocusOnlyCursor && (pCol->GetId() == GetCurColumnId()) && (nRow == (sal_uLong)GetCurRow()))
1023cdf0e10cSrcweir DrawCursor();
1024cdf0e10cSrcweir
1025cdf0e10cSrcweir // draw a single field
1026cdf0e10cSrcweir // #63864#, Sonst wird auch etwas gezeichnet, bsp Handle Column
1027cdf0e10cSrcweir if (pCol->Width())
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir // clip the column's output to the field area
1030cdf0e10cSrcweir if (_bForeignDevice)
1031cdf0e10cSrcweir { // (not neccessary if painting onto the data window)
1032cdf0e10cSrcweir Size aFieldSize(pCol->Width(), nDataRowHeigt);
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir if (aPos.X() + aFieldSize.Width() > aOverallAreaBRPos.X())
1035cdf0e10cSrcweir aFieldSize.Width() = aOverallAreaBRPos.X() - aPos.X();
1036cdf0e10cSrcweir
1037cdf0e10cSrcweir if (aPos.Y() + aFieldSize.Height() > aOverallAreaBRPos.Y() + 1)
1038cdf0e10cSrcweir {
1039cdf0e10cSrcweir // for non-handle cols we don't clip vertically : we just don't draw the cell if the line isn't completely visible
1040cdf0e10cSrcweir if (pCol->GetId() != 0)
1041cdf0e10cSrcweir continue;
1042cdf0e10cSrcweir aFieldSize.Height() = aOverallAreaBRPos.Y() + 1 - aPos.Y();
1043cdf0e10cSrcweir }
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir Region aClipToField(Rectangle(aPos, aFieldSize));
1046cdf0e10cSrcweir _rOut.SetClipRegion(aClipToField);
1047cdf0e10cSrcweir }
1048cdf0e10cSrcweir pCol->Draw( *this, _rOut, aPos, sal_False );
1049cdf0e10cSrcweir if (_bForeignDevice)
1050cdf0e10cSrcweir _rOut.SetClipRegion();
1051cdf0e10cSrcweir }
1052cdf0e10cSrcweir
1053cdf0e10cSrcweir // reset Column-auto-highlight
1054cdf0e10cSrcweir if ( bColAutoHighlight )
1055cdf0e10cSrcweir {
1056cdf0e10cSrcweir _rOut.SetTextColor( aOldTextColor );
1057cdf0e10cSrcweir _rOut.SetFillColor( aOldFillColor );
1058cdf0e10cSrcweir _rOut.SetLineColor( aOldLineColor );
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir // skip column
1062cdf0e10cSrcweir aPos.X() += pCol->Width();
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir if ( nCol == pCols->Count() )
1066cdf0e10cSrcweir bRetouching = sal_True;
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir // reset auto-highlight
1069cdf0e10cSrcweir if ( bRowSelected )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir _rOut.SetTextColor( aOldTextColor );
1072cdf0e10cSrcweir _rOut.SetFillColor( aOldFillColor );
1073cdf0e10cSrcweir _rOut.SetLineColor( aOldLineColor );
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir if ( bHLines )
1077cdf0e10cSrcweir {
1078cdf0e10cSrcweir // draw horizontal delimitation lines
1079cdf0e10cSrcweir _rOut.SetClipRegion();
1080cdf0e10cSrcweir _rOut.Push( PUSH_LINECOLOR );
1081cdf0e10cSrcweir _rOut.SetLineColor( aDelimiterLineColor );
1082cdf0e10cSrcweir long nY = aPos.Y() + nDataRowHeigt - 1;
1083cdf0e10cSrcweir if (nY <= aOverallAreaBRPos.Y())
1084cdf0e10cSrcweir _rOut.DrawLine( Point( nHLineX, nY ),
1085cdf0e10cSrcweir Point( bVLines
1086cdf0e10cSrcweir ? std::min(long(long(aPos.X()) - 1), aOverallAreaBRPos.X())
1087cdf0e10cSrcweir : aOverallAreaBRPos.X(),
1088cdf0e10cSrcweir nY ) );
1089cdf0e10cSrcweir _rOut.Pop();
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir }
1092cdf0e10cSrcweir
1093cdf0e10cSrcweir if (aPos.Y() > aOverallAreaBRPos.Y() + 1)
1094cdf0e10cSrcweir aPos.Y() = aOverallAreaBRPos.Y() + 1;
1095cdf0e10cSrcweir // needed for some of the following drawing
1096cdf0e10cSrcweir
1097cdf0e10cSrcweir // retouching
1098cdf0e10cSrcweir _rOut.SetClipRegion();
1099cdf0e10cSrcweir aOldLineColor = _rOut.GetLineColor();
1100cdf0e10cSrcweir aOldFillColor = _rOut.GetFillColor();
1101cdf0e10cSrcweir _rOut.SetFillColor( rSettings.GetFaceColor() );
1102cdf0e10cSrcweir if ( pCols->Count() && ( pCols->GetObject(0)->GetId() == 0 ) && ( aPos.Y() <= _rRect.Bottom() ) )
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir // fill rectangle gray below handle column
1105cdf0e10cSrcweir // DG: fill it only until the end of the drawing rect and not to the end, as this may overpaint handle columns
1106cdf0e10cSrcweir _rOut.SetLineColor( Color( COL_BLACK ) );
1107cdf0e10cSrcweir _rOut.DrawRect( Rectangle(
1108cdf0e10cSrcweir Point( aOverallAreaPos.X() - 1, aPos.Y() - 1 ),
1109cdf0e10cSrcweir Point( aOverallAreaPos.X() + pCols->GetObject(0)->Width() - 1,
1110cdf0e10cSrcweir _rRect.Bottom() + 1) ) );
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir _rOut.SetFillColor( aOldFillColor );
1113cdf0e10cSrcweir
1114cdf0e10cSrcweir // draw vertical delimitational line between frozen and scrollable cols
1115cdf0e10cSrcweir _rOut.SetLineColor( COL_BLACK );
1116cdf0e10cSrcweir long nFrozenWidth = GetFrozenWidth()-1;
1117cdf0e10cSrcweir _rOut.DrawLine( Point( aOverallAreaPos.X() + nFrozenWidth, aPos.Y() ),
1118cdf0e10cSrcweir Point( aOverallAreaPos.X() + nFrozenWidth, bHLines
1119cdf0e10cSrcweir ? aPos.Y() - 1
1120cdf0e10cSrcweir : aOverallAreaBRPos.Y() ) );
1121cdf0e10cSrcweir
1122cdf0e10cSrcweir // draw vertical delimitational lines?
1123cdf0e10cSrcweir if ( bVLines )
1124cdf0e10cSrcweir {
1125cdf0e10cSrcweir _rOut.SetLineColor( aDelimiterLineColor );
1126cdf0e10cSrcweir Point aVertPos( aOverallAreaPos.X() - 1, aOverallAreaPos.Y() );
1127cdf0e10cSrcweir long nDeltaY = aOverallAreaBRPos.Y();
1128cdf0e10cSrcweir for ( sal_uInt16 nCol = 0; nCol < pCols->Count(); ++nCol )
1129cdf0e10cSrcweir {
1130cdf0e10cSrcweir // get column
1131cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol);
1132cdf0e10cSrcweir
1133cdf0e10cSrcweir // skip invisible colums between frozen and scrollable area
1134cdf0e10cSrcweir if ( nCol < nFirstCol && !pCol->IsFrozen() )
1135cdf0e10cSrcweir {
1136cdf0e10cSrcweir nCol = nFirstCol;
1137cdf0e10cSrcweir pCol = pCols->GetObject(nCol);
1138cdf0e10cSrcweir }
1139cdf0e10cSrcweir
1140cdf0e10cSrcweir // skip column
1141cdf0e10cSrcweir aVertPos.X() += pCol->Width();
1142cdf0e10cSrcweir
1143cdf0e10cSrcweir // at end of invalid area
1144cdf0e10cSrcweir // invalid area is first reached when X > Right
1145cdf0e10cSrcweir // and not >=
1146cdf0e10cSrcweir if ( aVertPos.X() > _rRect.Right() )
1147cdf0e10cSrcweir break;
1148cdf0e10cSrcweir
1149cdf0e10cSrcweir // draw a single line
1150cdf0e10cSrcweir if ( pCol->GetId() != 0 )
1151cdf0e10cSrcweir _rOut.DrawLine( aVertPos, Point( aVertPos.X(),
1152cdf0e10cSrcweir bHLines
1153cdf0e10cSrcweir ? aPos.Y() - 1
1154cdf0e10cSrcweir : aPos.Y() + nDeltaY ) );
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir
1158cdf0e10cSrcweir _rOut.SetLineColor( aOldLineColor );
1159cdf0e10cSrcweir }
1160cdf0e10cSrcweir
1161cdf0e10cSrcweir //-------------------------------------------------------------------
1162cdf0e10cSrcweir
PaintData(Window & rWin,const Rectangle & rRect)1163cdf0e10cSrcweir void BrowseBox::PaintData( Window& rWin, const Rectangle& rRect )
1164cdf0e10cSrcweir {
1165cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1166cdf0e10cSrcweir if ( !bBootstrapped && IsReallyVisible() )
1167cdf0e10cSrcweir BrowseBox::StateChanged( STATE_CHANGE_INITSHOW );
1168cdf0e10cSrcweir
1169cdf0e10cSrcweir // initializations
1170cdf0e10cSrcweir if ( !pCols || !pCols->Count() || !rWin.IsUpdateMode() )
1171cdf0e10cSrcweir return;
1172cdf0e10cSrcweir if ( getDataWindow()->bResizeOnPaint )
1173cdf0e10cSrcweir Resize();
1174cdf0e10cSrcweir // MI: wer war das denn? Window::Update();
1175cdf0e10cSrcweir
1176cdf0e10cSrcweir ImplPaintData(rWin, rRect, sal_False, sal_True);
1177cdf0e10cSrcweir }
1178cdf0e10cSrcweir
1179cdf0e10cSrcweir //-------------------------------------------------------------------
1180cdf0e10cSrcweir
UpdateScrollbars()1181cdf0e10cSrcweir void BrowseBox::UpdateScrollbars()
1182cdf0e10cSrcweir {
1183cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1184cdf0e10cSrcweir
1185cdf0e10cSrcweir if ( !bBootstrapped || !IsUpdateMode() )
1186cdf0e10cSrcweir return;
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir // Rekursionsschutz
1189cdf0e10cSrcweir BrowserDataWin *pBDW = (BrowserDataWin*) pDataWin;
1190cdf0e10cSrcweir if ( pBDW->bInUpdateScrollbars )
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir pBDW->bHadRecursion = sal_True;
1193cdf0e10cSrcweir return;
1194cdf0e10cSrcweir }
1195cdf0e10cSrcweir pBDW->bInUpdateScrollbars = sal_True;
1196cdf0e10cSrcweir
1197cdf0e10cSrcweir // the size of the corner window (and the width of the VSB/height of the HSB)
1198cdf0e10cSrcweir sal_uLong nCornerSize = GetSettings().GetStyleSettings().GetScrollBarSize();
1199cdf0e10cSrcweir if (IsZoom())
1200cdf0e10cSrcweir nCornerSize = (sal_uLong)(nCornerSize * (double)GetZoom());
1201cdf0e10cSrcweir
1202cdf0e10cSrcweir // needs VScroll?
1203cdf0e10cSrcweir long nMaxRows = (pDataWin->GetSizePixel().Height()) / GetDataRowHeight();
1204cdf0e10cSrcweir sal_Bool bNeedsVScroll = getDataWindow()->bAutoVScroll
1205cdf0e10cSrcweir ? nTopRow || ( nRowCount > nMaxRows )
1206cdf0e10cSrcweir : !getDataWindow()->bNoVScroll;
1207cdf0e10cSrcweir Size aDataWinSize = pDataWin->GetSizePixel();
1208cdf0e10cSrcweir if ( !bNeedsVScroll )
1209cdf0e10cSrcweir {
1210cdf0e10cSrcweir if ( pVScroll->IsVisible() )
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir pVScroll->Hide();
1213cdf0e10cSrcweir Size aNewSize( aDataWinSize );
1214cdf0e10cSrcweir aNewSize.Width() = GetOutputSizePixel().Width();
1215cdf0e10cSrcweir aDataWinSize = aNewSize;
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir }
1218cdf0e10cSrcweir else if ( !pVScroll->IsVisible() )
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir Size aNewSize( aDataWinSize );
1221cdf0e10cSrcweir aNewSize.Width() = GetOutputSizePixel().Width() - nCornerSize;
1222cdf0e10cSrcweir aDataWinSize = aNewSize;
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir
1225cdf0e10cSrcweir // needs HScroll?
1226cdf0e10cSrcweir sal_uLong nLastCol = GetColumnAtXPosPixel( aDataWinSize.Width() - 1 );
1227cdf0e10cSrcweir
1228cdf0e10cSrcweir sal_uInt16 nFrozenCols = FrozenColCount();
1229cdf0e10cSrcweir sal_Bool bNeedsHScroll = getDataWindow()->bAutoHScroll
1230cdf0e10cSrcweir ? ( nFirstCol > nFrozenCols ) || ( nLastCol <= pCols->Count() )
1231cdf0e10cSrcweir : !getDataWindow()->bNoHScroll;
1232cdf0e10cSrcweir if ( !bNeedsHScroll )
1233cdf0e10cSrcweir {
1234cdf0e10cSrcweir if ( aHScroll.IsVisible() )
1235cdf0e10cSrcweir {
1236cdf0e10cSrcweir aHScroll.Hide();
1237cdf0e10cSrcweir }
1238cdf0e10cSrcweir aDataWinSize.Height() = GetOutputSizePixel().Height() - GetTitleHeight();
1239cdf0e10cSrcweir if ( nControlAreaWidth != USHRT_MAX )
1240cdf0e10cSrcweir aDataWinSize.Height() -= nCornerSize;
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir else if ( !aHScroll.IsVisible() )
1243cdf0e10cSrcweir {
1244cdf0e10cSrcweir Size aNewSize( aDataWinSize );
1245cdf0e10cSrcweir aNewSize.Height() = GetOutputSizePixel().Height() - GetTitleHeight() - nCornerSize;
1246cdf0e10cSrcweir aDataWinSize = aNewSize;
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir
1249cdf0e10cSrcweir // adjust position and Width of horizontal scrollbar
1250cdf0e10cSrcweir sal_uLong nHScrX = nControlAreaWidth == USHRT_MAX
1251cdf0e10cSrcweir ? 0
1252cdf0e10cSrcweir : nControlAreaWidth;
1253cdf0e10cSrcweir
1254cdf0e10cSrcweir aHScroll.SetPosSizePixel(
1255cdf0e10cSrcweir Point( nHScrX, GetOutputSizePixel().Height() - nCornerSize ),
1256cdf0e10cSrcweir Size( aDataWinSize.Width() - nHScrX, nCornerSize ) );
1257cdf0e10cSrcweir
1258cdf0e10cSrcweir // Scrollable Columns insgesamt
1259cdf0e10cSrcweir short nScrollCols = short(pCols->Count()) - (short)nFrozenCols;
1260cdf0e10cSrcweir /*short nVisibleHSize= std::max(nLastCol == BROWSER_INVALIDID
1261cdf0e10cSrcweir ? pCols->Count() - nFirstCol -1
1262cdf0e10cSrcweir : nLastCol - nFirstCol - 1, 0);
1263cdf0e10cSrcweir
1264cdf0e10cSrcweir aHScroll.SetVisibleSize( nVisibleHSize );
1265cdf0e10cSrcweir aHScroll.SetRange( Range( 0, Max( std::min(nScrollCols, nVisibleHSize), (short)0 ) ) );
1266cdf0e10cSrcweir if ( bNeedsHScroll && !aHScroll.IsVisible() )
1267cdf0e10cSrcweir aHScroll.Show();*/
1268cdf0e10cSrcweir
1269cdf0e10cSrcweir // Sichtbare Columns
1270cdf0e10cSrcweir short nVisibleHSize = nLastCol == BROWSER_INVALIDID
1271cdf0e10cSrcweir ? (short)( pCols->Count() - nFirstCol )
1272cdf0e10cSrcweir : (short)( nLastCol - nFirstCol );
1273cdf0e10cSrcweir
1274cdf0e10cSrcweir short nRange = Max( nScrollCols, (short)0 );
1275cdf0e10cSrcweir aHScroll.SetVisibleSize( nVisibleHSize );
1276cdf0e10cSrcweir aHScroll.SetRange( Range( 0, nRange ));
1277cdf0e10cSrcweir if ( bNeedsHScroll && !aHScroll.IsVisible() )
1278cdf0e10cSrcweir aHScroll.Show();
1279cdf0e10cSrcweir
1280cdf0e10cSrcweir // adjust position and height of vertical scrollbar
1281cdf0e10cSrcweir pVScroll->SetPageSize( nMaxRows );
1282cdf0e10cSrcweir
1283cdf0e10cSrcweir if ( nTopRow > nRowCount )
1284cdf0e10cSrcweir {
1285cdf0e10cSrcweir nTopRow = nRowCount - 1;
1286cdf0e10cSrcweir DBG_ERROR("BrowseBox: nTopRow > nRowCount");
1287cdf0e10cSrcweir }
1288cdf0e10cSrcweir
1289cdf0e10cSrcweir if ( pVScroll->GetThumbPos() != nTopRow )
1290cdf0e10cSrcweir pVScroll->SetThumbPos( nTopRow );
1291cdf0e10cSrcweir long nVisibleSize = Min( Min( nRowCount, nMaxRows ), long(nRowCount-nTopRow) );
1292cdf0e10cSrcweir pVScroll->SetVisibleSize( nVisibleSize ? nVisibleSize : 1 );
1293cdf0e10cSrcweir pVScroll->SetRange( Range( 0, nRowCount ) );
1294cdf0e10cSrcweir pVScroll->SetPosSizePixel(
1295cdf0e10cSrcweir Point( aDataWinSize.Width(), GetTitleHeight() ),
1296cdf0e10cSrcweir Size( nCornerSize, aDataWinSize.Height()) );
1297cdf0e10cSrcweir if ( nRowCount <
1298cdf0e10cSrcweir long( aDataWinSize.Height() / GetDataRowHeight() ) )
1299cdf0e10cSrcweir ScrollRows( -nTopRow );
1300cdf0e10cSrcweir if ( bNeedsVScroll && !pVScroll->IsVisible() )
1301cdf0e10cSrcweir pVScroll->Show();
1302cdf0e10cSrcweir
1303cdf0e10cSrcweir pDataWin->SetPosSizePixel(
1304cdf0e10cSrcweir Point( 0, GetTitleHeight() ),
1305cdf0e10cSrcweir aDataWinSize );
1306cdf0e10cSrcweir
1307cdf0e10cSrcweir // needs corner-window?
1308cdf0e10cSrcweir // (do that AFTER positioning BOTH scrollbars)
1309cdf0e10cSrcweir sal_uLong nActualCorderWidth = 0;
1310cdf0e10cSrcweir if (aHScroll.IsVisible() && pVScroll && pVScroll->IsVisible() )
1311cdf0e10cSrcweir {
1312cdf0e10cSrcweir // if we have both scrollbars, the corner window fills the point of intersection of these two
1313cdf0e10cSrcweir nActualCorderWidth = nCornerSize;
1314cdf0e10cSrcweir }
1315cdf0e10cSrcweir else if ( !aHScroll.IsVisible() && ( nControlAreaWidth != USHRT_MAX ) )
1316cdf0e10cSrcweir {
1317cdf0e10cSrcweir // if we have no horizontal scrollbar, but a control area, we need the corner window to
1318cdf0e10cSrcweir // fill the space between the control are and the right border
1319cdf0e10cSrcweir nActualCorderWidth = GetOutputSizePixel().Width() - nControlAreaWidth;
1320cdf0e10cSrcweir }
1321cdf0e10cSrcweir if ( nActualCorderWidth )
1322cdf0e10cSrcweir {
1323cdf0e10cSrcweir if ( !getDataWindow()->pCornerWin )
1324cdf0e10cSrcweir getDataWindow()->pCornerWin = new ScrollBarBox( this, 0 );
1325cdf0e10cSrcweir getDataWindow()->pCornerWin->SetPosSizePixel(
1326cdf0e10cSrcweir Point( GetOutputSizePixel().Width() - nActualCorderWidth, aHScroll.GetPosPixel().Y() ),
1327cdf0e10cSrcweir Size( nActualCorderWidth, nCornerSize ) );
1328cdf0e10cSrcweir getDataWindow()->pCornerWin->Show();
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir else
1331cdf0e10cSrcweir DELETEZ( getDataWindow()->pCornerWin );
1332cdf0e10cSrcweir
1333cdf0e10cSrcweir // ggf. Headerbar mitscrollen
1334cdf0e10cSrcweir if ( getDataWindow()->pHeaderBar )
1335cdf0e10cSrcweir {
1336cdf0e10cSrcweir long nWidth = 0;
1337cdf0e10cSrcweir for ( sal_uInt16 nCol = 0;
1338cdf0e10cSrcweir nCol < pCols->Count() && nCol < nFirstCol;
1339cdf0e10cSrcweir ++nCol )
1340cdf0e10cSrcweir {
1341cdf0e10cSrcweir // HandleColumn nicht
1342cdf0e10cSrcweir if ( pCols->GetObject(nCol)->GetId() )
1343cdf0e10cSrcweir nWidth += pCols->GetObject(nCol)->Width();
1344cdf0e10cSrcweir }
1345cdf0e10cSrcweir
1346cdf0e10cSrcweir getDataWindow()->pHeaderBar->SetOffset( nWidth );
1347cdf0e10cSrcweir }
1348cdf0e10cSrcweir
1349cdf0e10cSrcweir pBDW->bInUpdateScrollbars = sal_False;
1350cdf0e10cSrcweir if ( pBDW->bHadRecursion )
1351cdf0e10cSrcweir {
1352cdf0e10cSrcweir pBDW->bHadRecursion = sal_False;
1353cdf0e10cSrcweir UpdateScrollbars();
1354cdf0e10cSrcweir }
1355cdf0e10cSrcweir }
1356cdf0e10cSrcweir
1357cdf0e10cSrcweir //-------------------------------------------------------------------
1358cdf0e10cSrcweir
SetUpdateMode(sal_Bool bUpdate)1359cdf0e10cSrcweir void BrowseBox::SetUpdateMode( sal_Bool bUpdate )
1360cdf0e10cSrcweir {
1361cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1362cdf0e10cSrcweir
1363cdf0e10cSrcweir sal_Bool bWasUpdate = IsUpdateMode();
1364cdf0e10cSrcweir if ( bWasUpdate == bUpdate )
1365cdf0e10cSrcweir return;
1366cdf0e10cSrcweir
1367cdf0e10cSrcweir Control::SetUpdateMode( bUpdate );
1368cdf0e10cSrcweir // OV
1369cdf0e10cSrcweir // Wenn an der BrowseBox WB_CLIPCHILDREN gesetzt ist (wg. Flackerminimierung),
1370cdf0e10cSrcweir // wird das Datenfenster nicht von SetUpdateMode invalidiert.
1371cdf0e10cSrcweir if( bUpdate )
1372cdf0e10cSrcweir getDataWindow()->Invalidate();
1373cdf0e10cSrcweir getDataWindow()->SetUpdateMode( bUpdate );
1374cdf0e10cSrcweir
1375cdf0e10cSrcweir
1376cdf0e10cSrcweir if ( bUpdate )
1377cdf0e10cSrcweir {
1378cdf0e10cSrcweir if ( bBootstrapped )
1379cdf0e10cSrcweir {
1380cdf0e10cSrcweir UpdateScrollbars();
1381cdf0e10cSrcweir AutoSizeLastColumn();
1382cdf0e10cSrcweir }
1383cdf0e10cSrcweir DoShowCursor( "SetUpdateMode" );
1384cdf0e10cSrcweir }
1385cdf0e10cSrcweir else
1386cdf0e10cSrcweir DoHideCursor( "SetUpdateMode" );
1387cdf0e10cSrcweir }
1388cdf0e10cSrcweir
1389cdf0e10cSrcweir //-------------------------------------------------------------------
1390cdf0e10cSrcweir
GetUpdateMode() const1391cdf0e10cSrcweir sal_Bool BrowseBox::GetUpdateMode() const
1392cdf0e10cSrcweir {
1393cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1394cdf0e10cSrcweir
1395cdf0e10cSrcweir return getDataWindow()->IsUpdateMode();
1396cdf0e10cSrcweir }
1397cdf0e10cSrcweir
1398cdf0e10cSrcweir //-------------------------------------------------------------------
1399cdf0e10cSrcweir
GetFrozenWidth() const1400cdf0e10cSrcweir long BrowseBox::GetFrozenWidth() const
1401cdf0e10cSrcweir {
1402cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1403cdf0e10cSrcweir
1404cdf0e10cSrcweir long nWidth = 0;
1405cdf0e10cSrcweir for ( sal_uInt16 nCol = 0;
1406cdf0e10cSrcweir nCol < pCols->Count() && pCols->GetObject(nCol)->IsFrozen();
1407cdf0e10cSrcweir ++nCol )
1408cdf0e10cSrcweir nWidth += pCols->GetObject(nCol)->Width();
1409cdf0e10cSrcweir return nWidth;
1410cdf0e10cSrcweir }
1411cdf0e10cSrcweir
1412cdf0e10cSrcweir //-------------------------------------------------------------------
1413cdf0e10cSrcweir
ColumnInserted(sal_uInt16 nPos)1414cdf0e10cSrcweir void BrowseBox::ColumnInserted( sal_uInt16 nPos )
1415cdf0e10cSrcweir {
1416cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1417cdf0e10cSrcweir
1418cdf0e10cSrcweir if ( pColSel )
1419cdf0e10cSrcweir pColSel->Insert( nPos );
1420cdf0e10cSrcweir UpdateScrollbars();
1421cdf0e10cSrcweir }
1422cdf0e10cSrcweir
1423cdf0e10cSrcweir //-------------------------------------------------------------------
1424cdf0e10cSrcweir
FrozenColCount() const1425cdf0e10cSrcweir sal_uInt16 BrowseBox::FrozenColCount() const
1426cdf0e10cSrcweir {
1427cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1428cdf0e10cSrcweir sal_uInt16 nCol;
1429cdf0e10cSrcweir for ( nCol = 0;
1430cdf0e10cSrcweir nCol < pCols->Count() && pCols->GetObject(nCol)->IsFrozen();
1431cdf0e10cSrcweir ++nCol )
1432cdf0e10cSrcweir /* empty loop */;
1433cdf0e10cSrcweir return nCol;
1434cdf0e10cSrcweir }
1435cdf0e10cSrcweir
1436cdf0e10cSrcweir //-------------------------------------------------------------------
1437cdf0e10cSrcweir
IMPL_LINK(BrowseBox,ScrollHdl,ScrollBar *,pBar)1438cdf0e10cSrcweir IMPL_LINK(BrowseBox,ScrollHdl,ScrollBar*,pBar)
1439cdf0e10cSrcweir {
1440cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1441cdf0e10cSrcweir
1442cdf0e10cSrcweir if ( pBar->GetDelta() == 0 )
1443cdf0e10cSrcweir return 0;
1444cdf0e10cSrcweir
1445cdf0e10cSrcweir if ( pBar->GetDelta() < 0 && getDataWindow()->bNoScrollBack )
1446cdf0e10cSrcweir {
1447cdf0e10cSrcweir UpdateScrollbars();
1448cdf0e10cSrcweir return 0;
1449cdf0e10cSrcweir }
1450cdf0e10cSrcweir
1451cdf0e10cSrcweir if ( pBar == &aHScroll )
1452cdf0e10cSrcweir ScrollColumns( aHScroll.GetDelta() );
1453cdf0e10cSrcweir if ( pBar == pVScroll )
1454cdf0e10cSrcweir ScrollRows( pVScroll->GetDelta() );
1455cdf0e10cSrcweir
1456cdf0e10cSrcweir return 0;
1457cdf0e10cSrcweir }
1458cdf0e10cSrcweir
1459cdf0e10cSrcweir //-------------------------------------------------------------------
1460cdf0e10cSrcweir
IMPL_LINK(BrowseBox,EndScrollHdl,ScrollBar *,EMPTYARG)1461cdf0e10cSrcweir IMPL_LINK( BrowseBox,EndScrollHdl,ScrollBar*, EMPTYARG )
1462cdf0e10cSrcweir {
1463cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1464cdf0e10cSrcweir
1465cdf0e10cSrcweir // kein Focus grabben!
1466cdf0e10cSrcweir /// GrabFocus();
1467cdf0e10cSrcweir
1468cdf0e10cSrcweir if ( /*pBar->GetDelta() <= 0 &&*/ getDataWindow()->bNoScrollBack )
1469cdf0e10cSrcweir {
1470cdf0e10cSrcweir // UpdateScrollbars();
1471cdf0e10cSrcweir EndScroll();
1472cdf0e10cSrcweir return 0;
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir
1475cdf0e10cSrcweir return 0;
1476cdf0e10cSrcweir }
1477cdf0e10cSrcweir
1478cdf0e10cSrcweir //-------------------------------------------------------------------
1479cdf0e10cSrcweir
IMPL_LINK(BrowseBox,StartDragHdl,HeaderBar *,pBar)1480cdf0e10cSrcweir IMPL_LINK( BrowseBox, StartDragHdl, HeaderBar*, pBar )
1481cdf0e10cSrcweir {
1482cdf0e10cSrcweir pBar->SetDragSize( pDataWin->GetOutputSizePixel().Height() );
1483cdf0e10cSrcweir return 0;
1484cdf0e10cSrcweir }
1485cdf0e10cSrcweir
1486cdf0e10cSrcweir //-------------------------------------------------------------------
1487cdf0e10cSrcweir // MI: es wurde immer nur die 1. Spalte resized
1488cdf0e10cSrcweir #ifdef _MSC_VER
1489cdf0e10cSrcweir #pragma optimize("",off)
1490cdf0e10cSrcweir #endif
1491cdf0e10cSrcweir
MouseButtonDown(const MouseEvent & rEvt)1492cdf0e10cSrcweir void BrowseBox::MouseButtonDown( const MouseEvent& rEvt )
1493cdf0e10cSrcweir {
1494cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1495cdf0e10cSrcweir
1496cdf0e10cSrcweir GrabFocus();
1497cdf0e10cSrcweir
1498cdf0e10cSrcweir // onl< mouse events in the title-line are supported
1499cdf0e10cSrcweir const Point &rEvtPos = rEvt.GetPosPixel();
1500cdf0e10cSrcweir if ( rEvtPos.Y() >= GetTitleHeight() )
1501cdf0e10cSrcweir return;
1502cdf0e10cSrcweir
1503cdf0e10cSrcweir long nX = 0;
1504cdf0e10cSrcweir long nWidth = GetOutputSizePixel().Width();
1505cdf0e10cSrcweir for ( sal_uInt16 nCol = 0; nCol < pCols->Count() && nX < nWidth; ++nCol )
1506cdf0e10cSrcweir {
1507cdf0e10cSrcweir // is this column visible?
1508cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol);
1509cdf0e10cSrcweir if ( pCol->IsFrozen() || nCol >= nFirstCol )
1510cdf0e10cSrcweir {
1511cdf0e10cSrcweir // compute right end of column
1512cdf0e10cSrcweir long nR = nX + pCol->Width() - 1;
1513cdf0e10cSrcweir
1514cdf0e10cSrcweir // at the end of a column (and not handle column)?
1515cdf0e10cSrcweir if ( pCol->GetId() && Abs( nR - rEvtPos.X() ) < 2 )
1516cdf0e10cSrcweir {
1517cdf0e10cSrcweir // start resizing the column
1518cdf0e10cSrcweir bResizing = sal_True;
1519cdf0e10cSrcweir nResizeCol = nCol;
1520cdf0e10cSrcweir nDragX = nResizeX = rEvtPos.X();
1521cdf0e10cSrcweir SetPointer( Pointer( POINTER_HSPLIT ) );
1522cdf0e10cSrcweir CaptureMouse();
1523cdf0e10cSrcweir pDataWin->DrawLine( Point( nDragX, 0 ),
1524cdf0e10cSrcweir Point( nDragX, pDataWin->GetSizePixel().Height() ) );
1525cdf0e10cSrcweir nMinResizeX = nX + MIN_COLUMNWIDTH;
1526cdf0e10cSrcweir return;
1527cdf0e10cSrcweir }
1528cdf0e10cSrcweir else if ( nX < rEvtPos.X() && nR > rEvtPos.X() )
1529cdf0e10cSrcweir {
1530cdf0e10cSrcweir MouseButtonDown( BrowserMouseEvent(
1531cdf0e10cSrcweir this, rEvt, -1, nCol, pCol->GetId(), Rectangle() ) );
1532cdf0e10cSrcweir return;
1533cdf0e10cSrcweir }
1534cdf0e10cSrcweir nX = nR + 1;
1535cdf0e10cSrcweir }
1536cdf0e10cSrcweir }
1537cdf0e10cSrcweir
1538cdf0e10cSrcweir // event occured out of data area
1539cdf0e10cSrcweir if ( rEvt.IsRight() )
1540cdf0e10cSrcweir pDataWin->Command(
1541cdf0e10cSrcweir CommandEvent( Point( 1, LONG_MAX ), COMMAND_CONTEXTMENU, sal_True ) );
1542cdf0e10cSrcweir else
1543cdf0e10cSrcweir SetNoSelection();
1544cdf0e10cSrcweir }
1545cdf0e10cSrcweir
1546cdf0e10cSrcweir #ifdef _MSC_VER
1547cdf0e10cSrcweir #pragma optimize("",on)
1548cdf0e10cSrcweir #endif
1549cdf0e10cSrcweir
1550cdf0e10cSrcweir //-------------------------------------------------------------------
1551cdf0e10cSrcweir
MouseMove(const MouseEvent & rEvt)1552cdf0e10cSrcweir void BrowseBox::MouseMove( const MouseEvent& rEvt )
1553cdf0e10cSrcweir {
1554cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1555cdf0e10cSrcweir DBG_TRACE( "BrowseBox::MouseMove( MouseEvent )" );
1556cdf0e10cSrcweir
1557cdf0e10cSrcweir Pointer aNewPointer;
1558cdf0e10cSrcweir
1559cdf0e10cSrcweir sal_uInt16 nX = 0;
1560cdf0e10cSrcweir for ( sal_uInt16 nCol = 0;
1561cdf0e10cSrcweir nCol < sal_uInt16(pCols->Count()) &&
1562cdf0e10cSrcweir ( nX + pCols->GetObject(nCol)->Width() ) < sal_uInt16(GetOutputSizePixel().Width());
1563cdf0e10cSrcweir ++nCol )
1564cdf0e10cSrcweir // is this column visible?
1565cdf0e10cSrcweir if ( pCols->GetObject(nCol)->IsFrozen() || nCol >= nFirstCol )
1566cdf0e10cSrcweir {
1567cdf0e10cSrcweir // compute right end of column
1568cdf0e10cSrcweir BrowserColumn *pCol = pCols->GetObject(nCol);
1569cdf0e10cSrcweir sal_uInt16 nR = (sal_uInt16)(nX + pCol->Width() - 1);
1570cdf0e10cSrcweir
1571cdf0e10cSrcweir // show resize-pointer?
1572cdf0e10cSrcweir if ( bResizing || ( pCol->GetId() &&
1573cdf0e10cSrcweir Abs( ((long) nR ) - rEvt.GetPosPixel().X() ) < MIN_COLUMNWIDTH ) )
1574cdf0e10cSrcweir {
1575cdf0e10cSrcweir aNewPointer = Pointer( POINTER_HSPLIT );
1576cdf0e10cSrcweir if ( bResizing )
1577cdf0e10cSrcweir {
1578cdf0e10cSrcweir // alte Hilfslinie loeschen
1579cdf0e10cSrcweir pDataWin->HideTracking() ;
1580cdf0e10cSrcweir
1581cdf0e10cSrcweir // erlaubte breite abholen und neues Delta
1582cdf0e10cSrcweir nDragX = Max( rEvt.GetPosPixel().X(), nMinResizeX );
1583cdf0e10cSrcweir long nDeltaX = nDragX - nResizeX;
1584cdf0e10cSrcweir sal_uInt16 nId = GetColumnId(nResizeCol);
1585cdf0e10cSrcweir sal_uLong nOldWidth = GetColumnWidth(nId);
1586cdf0e10cSrcweir nDragX = QueryColumnResize( GetColumnId(nResizeCol),
1587cdf0e10cSrcweir nOldWidth + nDeltaX )
1588cdf0e10cSrcweir + nResizeX - nOldWidth;
1589cdf0e10cSrcweir
1590cdf0e10cSrcweir // neue Hilfslinie zeichnen
1591cdf0e10cSrcweir pDataWin->ShowTracking( Rectangle( Point( nDragX, 0 ),
1592cdf0e10cSrcweir Size( 1, pDataWin->GetSizePixel().Height() ) ),
1593cdf0e10cSrcweir SHOWTRACK_SPLIT|SHOWTRACK_WINDOW );
1594cdf0e10cSrcweir }
1595cdf0e10cSrcweir
1596cdf0e10cSrcweir }
1597cdf0e10cSrcweir
1598cdf0e10cSrcweir nX = nR + 1;
1599cdf0e10cSrcweir }
1600cdf0e10cSrcweir
1601cdf0e10cSrcweir SetPointer( aNewPointer );
1602cdf0e10cSrcweir }
1603cdf0e10cSrcweir
1604cdf0e10cSrcweir //-------------------------------------------------------------------
1605cdf0e10cSrcweir
MouseButtonUp(const MouseEvent & rEvt)1606cdf0e10cSrcweir void BrowseBox::MouseButtonUp( const MouseEvent & rEvt )
1607cdf0e10cSrcweir {
1608cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1609cdf0e10cSrcweir
1610cdf0e10cSrcweir if ( bResizing )
1611cdf0e10cSrcweir {
1612cdf0e10cSrcweir // Hilfslinie loeschen
1613cdf0e10cSrcweir pDataWin->HideTracking();
1614cdf0e10cSrcweir
1615cdf0e10cSrcweir // width changed?
1616cdf0e10cSrcweir nDragX = Max( rEvt.GetPosPixel().X(), nMinResizeX );
1617cdf0e10cSrcweir if ( (nDragX - nResizeX) != (long)pCols->GetObject(nResizeCol)->Width() )
1618cdf0e10cSrcweir {
1619cdf0e10cSrcweir // resize column
1620cdf0e10cSrcweir long nMaxX = pDataWin->GetSizePixel().Width();
1621cdf0e10cSrcweir nDragX = Min( nDragX, nMaxX );
1622cdf0e10cSrcweir long nDeltaX = nDragX - nResizeX;
1623cdf0e10cSrcweir sal_uInt16 nId = GetColumnId(nResizeCol);
1624cdf0e10cSrcweir SetColumnWidth( GetColumnId(nResizeCol), GetColumnWidth(nId) + nDeltaX );
1625cdf0e10cSrcweir ColumnResized( nId );
1626cdf0e10cSrcweir }
1627cdf0e10cSrcweir
1628cdf0e10cSrcweir // end action
1629cdf0e10cSrcweir SetPointer( Pointer() );
1630cdf0e10cSrcweir ReleaseMouse();
1631cdf0e10cSrcweir bResizing = sal_False;
1632cdf0e10cSrcweir }
1633cdf0e10cSrcweir else
1634cdf0e10cSrcweir MouseButtonUp( BrowserMouseEvent( (BrowserDataWin*)pDataWin,
1635cdf0e10cSrcweir MouseEvent( Point( rEvt.GetPosPixel().X(),
1636cdf0e10cSrcweir rEvt.GetPosPixel().Y() - pDataWin->GetPosPixel().Y() ),
1637cdf0e10cSrcweir rEvt.GetClicks(), rEvt.GetMode(), rEvt.GetButtons(),
1638cdf0e10cSrcweir rEvt.GetModifier() ) ) );
1639cdf0e10cSrcweir }
1640cdf0e10cSrcweir
1641cdf0e10cSrcweir //-------------------------------------------------------------------
1642cdf0e10cSrcweir
1643cdf0e10cSrcweir sal_Bool bExtendedMode = sal_False;
1644cdf0e10cSrcweir sal_Bool bFieldMode = sal_False;
1645cdf0e10cSrcweir
MouseButtonDown(const BrowserMouseEvent & rEvt)1646cdf0e10cSrcweir void BrowseBox::MouseButtonDown( const BrowserMouseEvent& rEvt )
1647cdf0e10cSrcweir {
1648cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1649cdf0e10cSrcweir
1650cdf0e10cSrcweir GrabFocus();
1651cdf0e10cSrcweir
1652cdf0e10cSrcweir // adjust selection while and after double-click
1653cdf0e10cSrcweir if ( rEvt.GetClicks() == 2 )
1654cdf0e10cSrcweir {
1655cdf0e10cSrcweir SetNoSelection();
1656cdf0e10cSrcweir if ( rEvt.GetRow() >= 0 )
1657cdf0e10cSrcweir {
1658cdf0e10cSrcweir GoToRow( rEvt.GetRow() );
1659cdf0e10cSrcweir SelectRow( rEvt.GetRow(), sal_True, sal_False );
1660cdf0e10cSrcweir }
1661cdf0e10cSrcweir else
1662cdf0e10cSrcweir {
1663cdf0e10cSrcweir if ( bColumnCursor && rEvt.GetColumn() != 0 )
1664cdf0e10cSrcweir {
1665cdf0e10cSrcweir if ( rEvt.GetColumn() < pCols->Count() )
1666cdf0e10cSrcweir SelectColumnPos( rEvt.GetColumn(), sal_True, sal_False);
1667cdf0e10cSrcweir }
1668cdf0e10cSrcweir }
1669cdf0e10cSrcweir DoubleClick( rEvt );
1670cdf0e10cSrcweir }
1671cdf0e10cSrcweir // selections
1672cdf0e10cSrcweir else if ( ( rEvt.GetMode() & ( MOUSE_SELECT | MOUSE_SIMPLECLICK ) ) &&
1673cdf0e10cSrcweir ( bColumnCursor || rEvt.GetRow() >= 0 ) )
1674cdf0e10cSrcweir {
1675cdf0e10cSrcweir if ( rEvt.GetClicks() == 1 )
1676cdf0e10cSrcweir {
1677cdf0e10cSrcweir // initialise flags
1678cdf0e10cSrcweir bHit = sal_False;
1679cdf0e10cSrcweir a1stPoint =
1680cdf0e10cSrcweir a2ndPoint = PixelToLogic( rEvt.GetPosPixel() );
1681cdf0e10cSrcweir
1682cdf0e10cSrcweir // selection out of range?
1683cdf0e10cSrcweir if ( rEvt.GetRow() >= nRowCount ||
1684cdf0e10cSrcweir rEvt.GetColumnId() == BROWSER_INVALIDID )
1685cdf0e10cSrcweir {
1686cdf0e10cSrcweir SetNoSelection();
1687cdf0e10cSrcweir return;
1688cdf0e10cSrcweir }
1689cdf0e10cSrcweir
1690cdf0e10cSrcweir // while selecting, no cursor
1691cdf0e10cSrcweir bSelecting = sal_True;
1692cdf0e10cSrcweir DoHideCursor( "MouseButtonDown" );
1693cdf0e10cSrcweir
1694cdf0e10cSrcweir // DataRow?
1695cdf0e10cSrcweir if ( rEvt.GetRow() >= 0 )
1696cdf0e10cSrcweir {
1697cdf0e10cSrcweir // Zeilenselektion?
1698cdf0e10cSrcweir if ( rEvt.GetColumnId() == 0 || !bColumnCursor )
1699cdf0e10cSrcweir {
1700cdf0e10cSrcweir if ( bMultiSelection )
1701cdf0e10cSrcweir {
1702cdf0e10cSrcweir // remove column-selection, if exists
1703cdf0e10cSrcweir if ( pColSel && pColSel->GetSelectCount() )
1704cdf0e10cSrcweir {
1705cdf0e10cSrcweir ToggleSelection();
1706cdf0e10cSrcweir if ( bMultiSelection )
1707cdf0e10cSrcweir uRow.pSel->SelectAll(sal_False);
1708cdf0e10cSrcweir else
1709cdf0e10cSrcweir uRow.nSel = BROWSER_ENDOFSELECTION;
1710cdf0e10cSrcweir if ( pColSel )
1711cdf0e10cSrcweir pColSel->SelectAll(sal_False);
1712cdf0e10cSrcweir bSelect = sal_True;
1713cdf0e10cSrcweir }
1714cdf0e10cSrcweir
1715cdf0e10cSrcweir // expanding mode?
1716cdf0e10cSrcweir if ( rEvt.GetMode() & MOUSE_RANGESELECT )
1717cdf0e10cSrcweir {
1718cdf0e10cSrcweir // select the further touched rows too
1719cdf0e10cSrcweir bSelect = sal_True;
1720cdf0e10cSrcweir ExpandRowSelection( rEvt );
1721cdf0e10cSrcweir return;
1722cdf0e10cSrcweir }
1723cdf0e10cSrcweir
1724cdf0e10cSrcweir // click in the selected area?
1725cdf0e10cSrcweir else if ( IsRowSelected( rEvt.GetRow() ) )
1726cdf0e10cSrcweir {
1727cdf0e10cSrcweir // auf Drag&Drop warten
1728cdf0e10cSrcweir bHit = sal_True;
1729cdf0e10cSrcweir bExtendedMode = MOUSE_MULTISELECT ==
1730cdf0e10cSrcweir ( rEvt.GetMode() & MOUSE_MULTISELECT );
1731cdf0e10cSrcweir return;
1732cdf0e10cSrcweir }
1733cdf0e10cSrcweir
1734cdf0e10cSrcweir // extension mode?
1735cdf0e10cSrcweir else if ( rEvt.GetMode() & MOUSE_MULTISELECT )
1736cdf0e10cSrcweir {
1737cdf0e10cSrcweir // determine the new selection range
1738cdf0e10cSrcweir // and selection/deselection
1739cdf0e10cSrcweir aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() );
1740cdf0e10cSrcweir SelectRow( rEvt.GetRow(),
1741cdf0e10cSrcweir !uRow.pSel->IsSelected( rEvt.GetRow() ) );
1742cdf0e10cSrcweir bSelect = sal_True;
1743cdf0e10cSrcweir return;
1744cdf0e10cSrcweir }
1745cdf0e10cSrcweir }
1746cdf0e10cSrcweir
1747cdf0e10cSrcweir // select directly
1748cdf0e10cSrcweir SetNoSelection();
1749cdf0e10cSrcweir GoToRow( rEvt.GetRow() );
1750cdf0e10cSrcweir SelectRow( rEvt.GetRow(), sal_True );
1751cdf0e10cSrcweir aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() );
1752cdf0e10cSrcweir bSelect = sal_True;
1753cdf0e10cSrcweir }
1754cdf0e10cSrcweir else // Column/Field-Selection
1755cdf0e10cSrcweir {
1756cdf0e10cSrcweir // click in selected column
1757cdf0e10cSrcweir if ( IsColumnSelected( rEvt.GetColumn() ) ||
1758cdf0e10cSrcweir IsRowSelected( rEvt.GetRow() ) )
1759cdf0e10cSrcweir {
1760cdf0e10cSrcweir bHit = sal_True;
1761cdf0e10cSrcweir bFieldMode = sal_True;
1762cdf0e10cSrcweir return;
1763cdf0e10cSrcweir }
1764cdf0e10cSrcweir
1765cdf0e10cSrcweir SetNoSelection();
1766cdf0e10cSrcweir GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() );
1767cdf0e10cSrcweir bSelect = sal_True;
1768cdf0e10cSrcweir }
1769cdf0e10cSrcweir }
1770cdf0e10cSrcweir else
1771cdf0e10cSrcweir {
1772cdf0e10cSrcweir if ( bMultiSelection && rEvt.GetColumnId() == 0 )
1773cdf0e10cSrcweir {
1774cdf0e10cSrcweir // toggle all-selection
1775cdf0e10cSrcweir if ( uRow.pSel->GetSelectCount() > ( GetRowCount() / 2 ) )
1776cdf0e10cSrcweir SetNoSelection();
1777cdf0e10cSrcweir else
1778cdf0e10cSrcweir SelectAll();
1779cdf0e10cSrcweir }
1780cdf0e10cSrcweir else
1781cdf0e10cSrcweir SelectColumnId( rEvt.GetColumnId(), sal_True, sal_False );
1782cdf0e10cSrcweir }
1783cdf0e10cSrcweir
1784cdf0e10cSrcweir // ggf. Cursor wieder an
1785cdf0e10cSrcweir bSelecting = sal_False;
1786cdf0e10cSrcweir DoShowCursor( "MouseButtonDown" );
1787cdf0e10cSrcweir if ( bSelect )
1788cdf0e10cSrcweir Select();
1789cdf0e10cSrcweir }
1790cdf0e10cSrcweir }
1791cdf0e10cSrcweir }
1792cdf0e10cSrcweir
1793cdf0e10cSrcweir //-------------------------------------------------------------------
1794cdf0e10cSrcweir
MouseMove(const BrowserMouseEvent &)1795cdf0e10cSrcweir void BrowseBox::MouseMove( const BrowserMouseEvent& )
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1798cdf0e10cSrcweir }
1799cdf0e10cSrcweir
1800cdf0e10cSrcweir //-------------------------------------------------------------------
1801cdf0e10cSrcweir
MouseButtonUp(const BrowserMouseEvent & rEvt)1802cdf0e10cSrcweir void BrowseBox::MouseButtonUp( const BrowserMouseEvent &rEvt )
1803cdf0e10cSrcweir {
1804cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1805cdf0e10cSrcweir
1806cdf0e10cSrcweir // D&D was possible, but did not occur
1807cdf0e10cSrcweir if ( bHit )
1808cdf0e10cSrcweir {
1809cdf0e10cSrcweir aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() );
1810cdf0e10cSrcweir if ( bExtendedMode )
1811cdf0e10cSrcweir SelectRow( rEvt.GetRow(), sal_False );
1812cdf0e10cSrcweir else
1813cdf0e10cSrcweir {
1814cdf0e10cSrcweir SetNoSelection();
1815cdf0e10cSrcweir if ( bFieldMode )
1816cdf0e10cSrcweir GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() );
1817cdf0e10cSrcweir else
1818cdf0e10cSrcweir {
1819cdf0e10cSrcweir GoToRow( rEvt.GetRow() );
1820cdf0e10cSrcweir SelectRow( rEvt.GetRow(), sal_True );
1821cdf0e10cSrcweir }
1822cdf0e10cSrcweir }
1823cdf0e10cSrcweir bSelect = sal_True;
1824cdf0e10cSrcweir bExtendedMode = sal_False;
1825cdf0e10cSrcweir bFieldMode = sal_False;
1826cdf0e10cSrcweir bHit = sal_False;
1827cdf0e10cSrcweir }
1828cdf0e10cSrcweir
1829cdf0e10cSrcweir // activate cursor
1830cdf0e10cSrcweir if ( bSelecting )
1831cdf0e10cSrcweir {
1832cdf0e10cSrcweir bSelecting = sal_False;
1833cdf0e10cSrcweir DoShowCursor( "MouseButtonUp" );
1834cdf0e10cSrcweir if ( bSelect )
1835cdf0e10cSrcweir Select();
1836cdf0e10cSrcweir }
1837cdf0e10cSrcweir }
1838cdf0e10cSrcweir
1839cdf0e10cSrcweir //-------------------------------------------------------------------
1840cdf0e10cSrcweir
KeyInput(const KeyEvent & rEvt)1841cdf0e10cSrcweir void BrowseBox::KeyInput( const KeyEvent& rEvt )
1842cdf0e10cSrcweir {
1843cdf0e10cSrcweir if ( !ProcessKey( rEvt ) )
1844cdf0e10cSrcweir Control::KeyInput( rEvt );
1845cdf0e10cSrcweir }
1846cdf0e10cSrcweir
1847cdf0e10cSrcweir //-------------------------------------------------------------------
1848cdf0e10cSrcweir
ProcessKey(const KeyEvent & rEvt)1849cdf0e10cSrcweir sal_Bool BrowseBox::ProcessKey( const KeyEvent& rEvt )
1850cdf0e10cSrcweir {
1851cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1852cdf0e10cSrcweir
1853cdf0e10cSrcweir sal_uInt16 nCode = rEvt.GetKeyCode().GetCode();
1854cdf0e10cSrcweir sal_Bool bShift = rEvt.GetKeyCode().IsShift();
1855cdf0e10cSrcweir sal_Bool bCtrl = rEvt.GetKeyCode().IsMod1();
1856cdf0e10cSrcweir sal_Bool bAlt = rEvt.GetKeyCode().IsMod2();
1857cdf0e10cSrcweir
1858cdf0e10cSrcweir sal_uInt16 nId = BROWSER_NONE;
1859cdf0e10cSrcweir
1860cdf0e10cSrcweir if ( !bAlt && !bCtrl && !bShift )
1861cdf0e10cSrcweir {
1862cdf0e10cSrcweir switch ( nCode )
1863cdf0e10cSrcweir {
1864cdf0e10cSrcweir case KEY_DOWN: nId = BROWSER_CURSORDOWN; break;
1865cdf0e10cSrcweir case KEY_UP: nId = BROWSER_CURSORUP; break;
1866cdf0e10cSrcweir case KEY_HOME: nId = BROWSER_CURSORHOME; break;
1867cdf0e10cSrcweir case KEY_END: nId = BROWSER_CURSOREND; break;
1868cdf0e10cSrcweir case KEY_TAB:
1869cdf0e10cSrcweir if ( !bColumnCursor )
1870cdf0e10cSrcweir break;
1871cdf0e10cSrcweir case KEY_RIGHT: nId = BROWSER_CURSORRIGHT; break;
1872cdf0e10cSrcweir case KEY_LEFT: nId = BROWSER_CURSORLEFT; break;
1873cdf0e10cSrcweir case KEY_SPACE: nId = BROWSER_SELECT; break;
1874cdf0e10cSrcweir }
1875cdf0e10cSrcweir if ( BROWSER_NONE != nId )
1876cdf0e10cSrcweir SetNoSelection();
1877cdf0e10cSrcweir
1878cdf0e10cSrcweir switch ( nCode )
1879cdf0e10cSrcweir {
1880cdf0e10cSrcweir case KEY_PAGEDOWN: nId = BROWSER_CURSORPAGEDOWN; break;
1881cdf0e10cSrcweir case KEY_PAGEUP: nId = BROWSER_CURSORPAGEUP; break;
1882cdf0e10cSrcweir }
1883cdf0e10cSrcweir }
1884cdf0e10cSrcweir
1885cdf0e10cSrcweir if ( !bAlt && !bCtrl && bShift )
1886cdf0e10cSrcweir switch ( nCode )
1887cdf0e10cSrcweir {
1888cdf0e10cSrcweir case KEY_DOWN: nId = BROWSER_SELECTDOWN; break;
1889cdf0e10cSrcweir case KEY_UP: nId = BROWSER_SELECTUP; break;
1890cdf0e10cSrcweir case KEY_TAB:
1891cdf0e10cSrcweir if ( !bColumnCursor )
1892cdf0e10cSrcweir break;
1893cdf0e10cSrcweir nId = BROWSER_CURSORLEFT; break;
1894cdf0e10cSrcweir case KEY_HOME: nId = BROWSER_SELECTHOME; break;
1895cdf0e10cSrcweir case KEY_END: nId = BROWSER_SELECTEND; break;
1896cdf0e10cSrcweir }
1897cdf0e10cSrcweir
1898cdf0e10cSrcweir
1899cdf0e10cSrcweir if ( !bAlt && bCtrl && !bShift )
1900cdf0e10cSrcweir switch ( nCode )
1901cdf0e10cSrcweir {
1902cdf0e10cSrcweir case KEY_DOWN: nId = BROWSER_CURSORDOWN; break;
1903cdf0e10cSrcweir case KEY_UP: nId = BROWSER_CURSORUP; break;
1904cdf0e10cSrcweir case KEY_PAGEDOWN: nId = BROWSER_CURSORENDOFFILE; break;
1905cdf0e10cSrcweir case KEY_PAGEUP: nId = BROWSER_CURSORTOPOFFILE; break;
1906cdf0e10cSrcweir case KEY_HOME: nId = BROWSER_CURSORTOPOFSCREEN; break;
1907cdf0e10cSrcweir case KEY_END: nId = BROWSER_CURSORENDOFSCREEN; break;
1908cdf0e10cSrcweir case KEY_SPACE: nId = BROWSER_ENHANCESELECTION; break;
1909cdf0e10cSrcweir case KEY_LEFT: nId = BROWSER_MOVECOLUMNLEFT; break;
1910cdf0e10cSrcweir case KEY_RIGHT: nId = BROWSER_MOVECOLUMNRIGHT; break;
1911cdf0e10cSrcweir }
1912cdf0e10cSrcweir
1913cdf0e10cSrcweir if ( nId != BROWSER_NONE )
1914cdf0e10cSrcweir Dispatch( nId );
1915cdf0e10cSrcweir return nId != BROWSER_NONE;
1916cdf0e10cSrcweir }
1917cdf0e10cSrcweir
1918cdf0e10cSrcweir //-------------------------------------------------------------------
1919cdf0e10cSrcweir
Dispatch(sal_uInt16 nId)1920cdf0e10cSrcweir void BrowseBox::Dispatch( sal_uInt16 nId )
1921cdf0e10cSrcweir {
1922cdf0e10cSrcweir DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
1923cdf0e10cSrcweir
1924cdf0e10cSrcweir long nRowsOnPage = pDataWin->GetSizePixel().Height() / GetDataRowHeight();
1925cdf0e10cSrcweir sal_Bool bDone = sal_False;
1926cdf0e10cSrcweir
1927cdf0e10cSrcweir switch ( nId )
1928cdf0e10cSrcweir {
1929cdf0e10cSrcweir case BROWSER_SELECTCOLUMN:
1930cdf0e10cSrcweir if ( ColCount() )
1931cdf0e10cSrcweir SelectColumnId( GetCurColumnId() );
1932cdf0e10cSrcweir break;
1933cdf0e10cSrcweir
1934cdf0e10cSrcweir case BROWSER_CURSORDOWN:
1935cdf0e10cSrcweir if ( ( GetCurRow() + 1 ) < nRowCount )
1936cdf0e10cSrcweir bDone = GoToRow( GetCurRow() + 1, sal_False );
1937cdf0e10cSrcweir break;
1938cdf0e10cSrcweir case BROWSER_CURSORUP:
1939cdf0e10cSrcweir if ( GetCurRow() > 0 )
1940cdf0e10cSrcweir bDone = GoToRow( GetCurRow() - 1, sal_False );
1941cdf0e10cSrcweir break;
1942cdf0e10cSrcweir case BROWSER_SELECTHOME:
1943cdf0e10cSrcweir if ( GetRowCount() )
1944cdf0e10cSrcweir {
1945cdf0e10cSrcweir DoHideCursor( "BROWSER_SELECTHOME" );
1946cdf0e10cSrcweir for ( long nRow = GetCurRow(); nRow >= 0; --nRow )
1947cdf0e10cSrcweir SelectRow( nRow );
1948cdf0e10cSrcweir GoToRow( 0, sal_True );
1949cdf0e10cSrcweir DoShowCursor( "BROWSER_SELECTHOME" );
1950cdf0e10cSrcweir }
1951cdf0e10cSrcweir break;
1952cdf0e10cSrcweir case BROWSER_SELECTEND:
1953cdf0e10cSrcweir if ( GetRowCount() )
1954cdf0e10cSrcweir {
1955cdf0e10cSrcweir DoHideCursor( "BROWSER_SELECTEND" );
1956cdf0e10cSrcweir long nRows = GetRowCount();
1957cdf0e10cSrcweir for ( long nRow = GetCurRow(); nRow < nRows; ++nRow )
1958cdf0e10cSrcweir SelectRow( nRow );
1959cdf0e10cSrcweir GoToRow( GetRowCount() - 1, sal_True );
1960cdf0e10cSrcweir DoShowCursor( "BROWSER_SELECTEND" );
1961cdf0e10cSrcweir }
1962cdf0e10cSrcweir break;
1963cdf0e10cSrcweir case BROWSER_SELECTDOWN:
1964cdf0e10cSrcweir {
1965cdf0e10cSrcweir if ( GetRowCount() && ( GetCurRow() + 1 ) < nRowCount )
1966cdf0e10cSrcweir {
1967cdf0e10cSrcweir // deselect the current row, if it isn't the first
1968cdf0e10cSrcweir // and there is no other selected row above
1969cdf0e10cSrcweir long nRow = GetCurRow();
1970cdf0e10cSrcweir sal_Bool bLocalSelect = ( !IsRowSelected( nRow ) ||
1971cdf0e10cSrcweir GetSelectRowCount() == 1 || IsRowSelected( nRow - 1 ) );
1972cdf0e10cSrcweir SelectRow( nRow, bLocalSelect, sal_True );
1973cdf0e10cSrcweir bDone = GoToRow( GetCurRow() + 1 , sal_False );
1974cdf0e10cSrcweir if ( bDone )
1975cdf0e10cSrcweir SelectRow( GetCurRow(), sal_True, sal_True );
1976cdf0e10cSrcweir }
1977cdf0e10cSrcweir else
1978cdf0e10cSrcweir bDone = ScrollRows( 1 ) != 0;
1979cdf0e10cSrcweir break;
1980cdf0e10cSrcweir }
1981cdf0e10cSrcweir case BROWSER_SELECTUP:
1982cdf0e10cSrcweir if ( GetRowCount() )
1983cdf0e10cSrcweir {
1984cdf0e10cSrcweir // deselect the current row, if it isn't the first
1985cdf0e10cSrcweir // and there is no other selected row under
1986cdf0e10cSrcweir long nRow = GetCurRow();
1987cdf0e10cSrcweir sal_Bool bLocalSelect = ( !IsRowSelected( nRow ) ||
1988cdf0e10cSrcweir GetSelectRowCount() == 1 || IsRowSelected( nRow + 1 ) );
1989cdf0e10cSrcweir SelectRow( nCurRow, bLocalSelect, sal_True );
1990cdf0e10cSrcweir bDone = GoToRow( nRow - 1 , sal_False );
1991cdf0e10cSrcweir if ( bDone )
1992cdf0e10cSrcweir SelectRow( GetCurRow(), sal_True, sal_True );
1993cdf0e10cSrcweir }
1994cdf0e10cSrcweir break;
1995cdf0e10cSrcweir case BROWSER_CURSORPAGEDOWN:
1996cdf0e10cSrcweir bDone = (sal_Bool)ScrollRows( nRowsOnPage );
1997cdf0e10cSrcweir break;
1998cdf0e10cSrcweir case BROWSER_CURSORPAGEUP:
1999cdf0e10cSrcweir bDone = (sal_Bool)ScrollRows( -nRowsOnPage );
2000cdf0e10cSrcweir break;
2001cdf0e10cSrcweir case BROWSER_CURSOREND:
2002cdf0e10cSrcweir if ( bColumnCursor )
2003cdf0e10cSrcweir {
2004cdf0e10cSrcweir sal_uInt16 nNewId = GetColumnId(ColCount() -1);
2005cdf0e10cSrcweir bDone = (nNewId != 0) && GoToColumnId( nNewId );
2006cdf0e10cSrcweir break;
2007cdf0e10cSrcweir }
2008cdf0e10cSrcweir case BROWSER_CURSORENDOFFILE:
2009cdf0e10cSrcweir bDone = GoToRow( nRowCount - 1, sal_False );
2010cdf0e10cSrcweir break;
2011cdf0e10cSrcweir case BROWSER_CURSORRIGHT:
2012cdf0e10cSrcweir if ( bColumnCursor )
2013cdf0e10cSrcweir {
2014cdf0e10cSrcweir sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) + 1;
2015cdf0e10cSrcweir sal_uInt16 nNewId = GetColumnId( nNewPos );
2016cdf0e10cSrcweir if (nNewId != 0) // Am Zeilenende ?
2017cdf0e10cSrcweir bDone = GoToColumnId( nNewId );
2018cdf0e10cSrcweir else
2019cdf0e10cSrcweir {
2020cdf0e10cSrcweir sal_uInt16 nColId = ( GetColumnId(0) == 0 ) ? GetColumnId(1) : GetColumnId(0);
2021cdf0e10cSrcweir if ( GetRowCount() )
2022cdf0e10cSrcweir bDone = ( nCurRow < GetRowCount() - 1 ) && GoToRowColumnId( nCurRow + 1, nColId );
2023cdf0e10cSrcweir else if ( ColCount() )
2024cdf0e10cSrcweir GoToColumnId( nColId );
2025cdf0e10cSrcweir }
2026cdf0e10cSrcweir }
2027cdf0e10cSrcweir else
2028cdf0e10cSrcweir bDone = ScrollColumns( 1 ) != 0;
2029cdf0e10cSrcweir break;
2030cdf0e10cSrcweir case BROWSER_CURSORHOME:
2031cdf0e10cSrcweir if ( bColumnCursor )
2032cdf0e10cSrcweir {
2033cdf0e10cSrcweir sal_uInt16 nNewId = GetColumnId(1);
2034cdf0e10cSrcweir bDone = (nNewId != 0) && GoToColumnId( nNewId );
2035cdf0e10cSrcweir break;
2036cdf0e10cSrcweir }
2037cdf0e10cSrcweir case BROWSER_CURSORTOPOFFILE:
2038cdf0e10cSrcweir bDone = GoToRow( 0, sal_False );
2039cdf0e10cSrcweir break;
2040cdf0e10cSrcweir case BROWSER_CURSORLEFT:
2041cdf0e10cSrcweir if ( bColumnCursor )
2042cdf0e10cSrcweir {
2043cdf0e10cSrcweir sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) - 1;
2044cdf0e10cSrcweir sal_uInt16 nNewId = GetColumnId( nNewPos );
2045cdf0e10cSrcweir if (nNewId != 0)
2046cdf0e10cSrcweir bDone = GoToColumnId( nNewId );
2047cdf0e10cSrcweir else
2048cdf0e10cSrcweir {
2049cdf0e10cSrcweir if ( GetRowCount() )
2050cdf0e10cSrcweir bDone = (nCurRow > 0) && GoToRowColumnId(nCurRow - 1, GetColumnId(ColCount() -1));
2051cdf0e10cSrcweir else if ( ColCount() )
2052cdf0e10cSrcweir GoToColumnId( GetColumnId(ColCount() -1) );
2053cdf0e10cSrcweir }
2054cdf0e10cSrcweir }
2055cdf0e10cSrcweir else
2056cdf0e10cSrcweir bDone = ScrollColumns( -1 ) != 0;
2057cdf0e10cSrcweir break;
2058cdf0e10cSrcweir case BROWSER_ENHANCESELECTION:
2059cdf0e10cSrcweir if ( GetRowCount() )
2060cdf0e10cSrcweir SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), sal_True );
2061cdf0e10cSrcweir bDone = sal_True;
2062cdf0e10cSrcweir break;
2063cdf0e10cSrcweir case BROWSER_SELECT:
2064cdf0e10cSrcweir if ( GetRowCount() )
2065cdf0e10cSrcweir SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), sal_False );
2066cdf0e10cSrcweir bDone = sal_True;
2067cdf0e10cSrcweir break;
2068cdf0e10cSrcweir case BROWSER_MOVECOLUMNLEFT:
2069cdf0e10cSrcweir case BROWSER_MOVECOLUMNRIGHT:
2070cdf0e10cSrcweir { // check if column moving is allowed
2071cdf0e10cSrcweir BrowserHeader* pHeaderBar = getDataWindow()->pHeaderBar;
2072cdf0e10cSrcweir if ( pHeaderBar && pHeaderBar->IsDragable() )
2073cdf0e10cSrcweir {
2074cdf0e10cSrcweir sal_uInt16 nColId = GetCurColumnId();
2075cdf0e10cSrcweir sal_Bool bColumnSelected = IsColumnSelected(nColId);
2076cdf0e10cSrcweir sal_uInt16 nNewPos = GetColumnPos(nColId);
2077cdf0e10cSrcweir sal_Bool bMoveAllowed = sal_False;
2078cdf0e10cSrcweir if ( BROWSER_MOVECOLUMNLEFT == nId && nNewPos > 1 )
2079cdf0e10cSrcweir --nNewPos,bMoveAllowed = sal_True;
2080cdf0e10cSrcweir else if ( BROWSER_MOVECOLUMNRIGHT == nId && nNewPos < (ColCount()-1) )
2081cdf0e10cSrcweir ++nNewPos,bMoveAllowed = sal_True;
2082cdf0e10cSrcweir
2083cdf0e10cSrcweir if ( bMoveAllowed )
2084cdf0e10cSrcweir {
2085cdf0e10cSrcweir SetColumnPos( nColId, nNewPos );
2086cdf0e10cSrcweir ColumnMoved( nColId );
2087cdf0e10cSrcweir MakeFieldVisible(GetCurRow(),nColId,sal_True);
2088cdf0e10cSrcweir if ( bColumnSelected )
2089cdf0e10cSrcweir SelectColumnId(nColId);
2090cdf0e10cSrcweir }
2091cdf0e10cSrcweir }
2092cdf0e10cSrcweir }
2093cdf0e10cSrcweir break;
2094cdf0e10cSrcweir }
2095cdf0e10cSrcweir
2096cdf0e10cSrcweir //! return bDone;
2097cdf0e10cSrcweir }
2098cdf0e10cSrcweir
2099cdf0e10cSrcweir //-------------------------------------------------------------------
2100cdf0e10cSrcweir
SetCursorColor(const Color & _rCol)2101cdf0e10cSrcweir void BrowseBox::SetCursorColor(const Color& _rCol)
2102cdf0e10cSrcweir {
2103cdf0e10cSrcweir if (_rCol == m_aCursorColor)
2104cdf0e10cSrcweir return;
2105cdf0e10cSrcweir
2106cdf0e10cSrcweir // ensure the cursor is hidden
2107cdf0e10cSrcweir DoHideCursor("SetCursorColor");
2108cdf0e10cSrcweir if (!m_bFocusOnlyCursor)
2109cdf0e10cSrcweir DoHideCursor("SetCursorColor - force");
2110cdf0e10cSrcweir
2111cdf0e10cSrcweir m_aCursorColor = _rCol;
2112cdf0e10cSrcweir
2113cdf0e10cSrcweir if (!m_bFocusOnlyCursor)
2114cdf0e10cSrcweir DoShowCursor("SetCursorColor - force");
2115cdf0e10cSrcweir DoShowCursor("SetCursorColor");
2116cdf0e10cSrcweir }
2117cdf0e10cSrcweir // -----------------------------------------------------------------------------
calcHeaderRect(sal_Bool _bIsColumnBar,sal_Bool _bOnScreen)2118cdf0e10cSrcweir Rectangle BrowseBox::calcHeaderRect(sal_Bool _bIsColumnBar,sal_Bool _bOnScreen)
2119cdf0e10cSrcweir {
2120cdf0e10cSrcweir Window* pParent = NULL;
2121cdf0e10cSrcweir if ( !_bOnScreen )
2122cdf0e10cSrcweir pParent = GetAccessibleParentWindow();
2123cdf0e10cSrcweir
2124cdf0e10cSrcweir Point aTopLeft;
2125cdf0e10cSrcweir long nWidth;
2126cdf0e10cSrcweir long nHeight;
2127cdf0e10cSrcweir if ( _bIsColumnBar )
2128cdf0e10cSrcweir {
2129cdf0e10cSrcweir nWidth = GetDataWindow().GetOutputSizePixel().Width();
2130cdf0e10cSrcweir nHeight = GetDataRowHeight();
2131cdf0e10cSrcweir }
2132cdf0e10cSrcweir else
2133cdf0e10cSrcweir {
2134cdf0e10cSrcweir aTopLeft.Y() = GetDataRowHeight();
2135cdf0e10cSrcweir nWidth = GetColumnWidth(0);
2136cdf0e10cSrcweir nHeight = GetWindowExtentsRelative( pParent ).GetHeight() - aTopLeft.Y() - GetControlArea().GetSize().B();
2137cdf0e10cSrcweir }
2138cdf0e10cSrcweir aTopLeft += GetWindowExtentsRelative( pParent ).TopLeft();
2139cdf0e10cSrcweir return Rectangle(aTopLeft,Size(nWidth,nHeight));
2140cdf0e10cSrcweir }
2141cdf0e10cSrcweir // -----------------------------------------------------------------------------
calcTableRect(sal_Bool _bOnScreen)2142cdf0e10cSrcweir Rectangle BrowseBox::calcTableRect(sal_Bool _bOnScreen)
2143cdf0e10cSrcweir {
2144cdf0e10cSrcweir Window* pParent = NULL;
2145cdf0e10cSrcweir if ( !_bOnScreen )
2146cdf0e10cSrcweir pParent = GetAccessibleParentWindow();
2147cdf0e10cSrcweir
2148cdf0e10cSrcweir Rectangle aRect( GetWindowExtentsRelative( pParent ) );
2149cdf0e10cSrcweir Rectangle aRowBar = calcHeaderRect(sal_False,pParent == NULL);
2150cdf0e10cSrcweir
2151cdf0e10cSrcweir long nX = aRowBar.Right() - aRect.Left();
2152cdf0e10cSrcweir long nY = aRowBar.Top() - aRect.Top();
2153cdf0e10cSrcweir Size aSize(aRect.GetSize());
2154cdf0e10cSrcweir
2155cdf0e10cSrcweir return Rectangle(aRowBar.TopRight(), Size(aSize.A() - nX, aSize.B() - nY - aHScroll.GetSizePixel().Height()) );
2156cdf0e10cSrcweir }
2157cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetFieldRectPixelAbs(sal_Int32 _nRowId,sal_uInt16 _nColId,sal_Bool,sal_Bool _bOnScreen)2158cdf0e10cSrcweir Rectangle BrowseBox::GetFieldRectPixelAbs( sal_Int32 _nRowId,sal_uInt16 _nColId, sal_Bool /*_bIsHeader*/, sal_Bool _bOnScreen )
2159cdf0e10cSrcweir {
2160cdf0e10cSrcweir Window* pParent = NULL;
2161cdf0e10cSrcweir if ( !_bOnScreen )
2162cdf0e10cSrcweir pParent = GetAccessibleParentWindow();
2163cdf0e10cSrcweir
2164cdf0e10cSrcweir Rectangle aRect = GetFieldRectPixel(_nRowId,_nColId,_bOnScreen);
2165cdf0e10cSrcweir
2166cdf0e10cSrcweir Point aTopLeft = aRect.TopLeft();
2167cdf0e10cSrcweir aTopLeft += GetWindowExtentsRelative( pParent ).TopLeft();
2168cdf0e10cSrcweir
2169cdf0e10cSrcweir return Rectangle(aTopLeft,aRect.GetSize());
2170cdf0e10cSrcweir }
2171cdf0e10cSrcweir
2172cdf0e10cSrcweir // ------------------------------------------------------------------------- EOF
2173cdf0e10cSrcweir
2174