1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SVTOOLS_BRWBOX_HXX
20 #define INCLUDED_SVTOOLS_BRWBOX_HXX
22 #include <svtools/svtdllapi.h>
23 #include <vcl/scrbar.hxx>
24 #include <vcl/ctrl.hxx>
25 #include <vcl/vclptr.hxx>
26 #include <tools/multisel.hxx>
27 #include <svtools/headbar.hxx>
28 #include <svtools/transfer.hxx>
29 #include <svtools/AccessibleBrowseBoxObjType.hxx>
30 #include <svtools/accessibletableprovider.hxx>
36 #include <o3tl/typed_flags_set.hxx>
43 typedef ::std::vector
< BrowserColumn
* > BrowserColumns
;
47 class IAccessibleFactory
;
50 class AccessibleStateSetHelper
;
54 // - BrowseBox-Types -
57 #define BROWSER_INVALIDID SAL_MAX_UINT16
58 #define BROWSER_ENDOFSELECTION (static_cast<long>(SFX_ENDOFSELECTION))
60 enum class BrowserMode
63 COLUMNSELECTION
= 0x000001,
64 MULTISELECTION
= 0x000002,
65 THUMBDRAGGING
= 0x000004,
66 KEEPHIGHLIGHT
= 0x000008,
70 HIDESELECT
= 0x000100, // old => don't use!
71 HIDECURSOR
= 0x000200,
73 NO_HSCROLL
= 0x000400,
74 NO_SCROLLBACK
= 0x000800,
76 AUTO_VSCROLL
= 0x001000,
77 AUTO_HSCROLL
= 0x002000,
79 TRACKING_TIPS
= 0x004000,
81 NO_VSCROLL
= 0x008000,
83 HEADERBAR_NEW
= 0x040000,
84 AUTOSIZE_LASTCOL
= 0x080000,
85 OWN_DATACHANGED
= 0x100000,
87 CURSOR_WO_FOCUS
= 0x200000,
88 // Allows a cursor which is shown even if the control does not have the focus. This does not affect other
89 // situations which require to temporarily hide the cursor (such as scrolling).
91 SMART_HIDECURSOR
= 0x400000,
92 // is an enhanced version of BrowserMode::HIDECURSOR.
93 // When set, BrowserMode::HIDECURSOR is overruled, and the cursor is hidden as long as no selection exists,
94 // but shown otherwise. This does not affect other situations which require to temporarily hide the
95 // cursor (such as scrolling).
99 template<> struct typed_flags
<BrowserMode
> : is_typed_flags
<BrowserMode
, 0x7cff3f> {};
102 #define BROWSER_NONE 0
103 #define BROWSER_SELECT 720
104 #define BROWSER_ENHANCESELECTION 722
105 #define BROWSER_SELECTDOWN 724
106 #define BROWSER_SELECTUP 725
107 #define BROWSER_CURSORDOWN 731
108 #define BROWSER_CURSORUP 732
109 #define BROWSER_CURSORLEFT 733
110 #define BROWSER_CURSORRIGHT 734
111 #define BROWSER_CURSORPAGEDOWN 735
112 #define BROWSER_CURSORPAGEUP 736
113 #define BROWSER_CURSORENDOFFILE 741
114 #define BROWSER_CURSORTOPOFFILE 742
115 #define BROWSER_CURSORENDOFSCREEN 743
116 #define BROWSER_CURSORTOPOFSCREEN 744
117 #define BROWSER_CURSORHOME 745
118 #define BROWSER_CURSOREND 746
119 #define BROWSER_SCROLLDOWN 751
120 #define BROWSER_SCROLLUP 752
121 #define BROWSER_SELECTHOME 753
122 #define BROWSER_SELECTEND 754
123 #define BROWSER_SELECTCOLUMN 755
124 #define BROWSER_MOVECOLUMNLEFT 756
125 #define BROWSER_MOVECOLUMNRIGHT 757
133 VclPtr
<vcl::Window
> pWin
;
141 BrowseEvent( vcl::Window
* pWindow
,
143 sal_uInt16 nColumn
, sal_uInt16 nColumnId
,
144 const Rectangle
& rRect
);
146 vcl::Window
* GetWindow() const { return pWin
; }
147 long GetRow() const { return nRow
; }
148 sal_uInt16
GetColumn() const { return nCol
; }
149 sal_uInt16
GetColumnId() const { return nColId
; }
150 const Rectangle
& GetRect() const { return aRect
; }
154 // - BrowserMouseEvent -
157 class BrowserMouseEvent
: public MouseEvent
, public BrowseEvent
161 BrowserMouseEvent( BrowserDataWin
* pWin
, const MouseEvent
& rEvt
);
162 BrowserMouseEvent( vcl::Window
* pWin
, const MouseEvent
& rEvt
,
163 long nAbsRow
, sal_uInt16 nColumn
, sal_uInt16 nColumnId
,
164 const Rectangle
& rRect
);
168 // - BrowserAcceptDropEvent -
171 class BrowserAcceptDropEvent
: public AcceptDropEvent
, public BrowseEvent
174 BrowserAcceptDropEvent();
175 BrowserAcceptDropEvent( BrowserDataWin
* pWin
, const AcceptDropEvent
& rEvt
);
179 // - BrowserExecuteDropEvent -
182 class BrowserExecuteDropEvent
: public ExecuteDropEvent
, public BrowseEvent
185 BrowserExecuteDropEvent();
186 BrowserExecuteDropEvent( BrowserDataWin
* pWin
, const ExecuteDropEvent
& rEvt
);
194 // The whole selection thingie in this class is somewhat .... suspicious to me.
196 // * method parameters named like members (and used in both semantics within the method!)
197 // * the multi selection flag is sometimes used as if it is for row selection, sometimes as if
198 // it's for column selection, too (and sometimes in an even stranger way :)
199 // * it is not really defined like all these hundreds selection related flags/methods work together
200 // and influence each other. I do not understand it very well, but this may be my fault :)
201 // * There is a GetColumnSelection, but it can't be used to determine the selected columns (at least
202 // not without a const_cast)
204 // We should clearly define this somewhere in the future. Or, even better, we should re-implement this
205 // whole class, which is planned for a long time :)
207 // sorry for the ranting. could not resist
209 class SVT_DLLPUBLIC BrowseBox
211 ,public DragSourceHelper
212 ,public DropTargetHelper
213 ,public svt::IAccessibleTableProvider
215 friend class BrowserDataWin
;
216 friend class ::svt::BrowseBoxImpl
;
219 static const sal_uInt16 HandleColumnId
= 0;
222 VclPtr
<vcl::Window
> pDataWin
; // window to display data rows
223 VclPtr
<ScrollBar
> pVScroll
; // vertical scrollbar
224 VclPtr
<ScrollBar
> aHScroll
; // horizontal scrollbar
226 long nDataRowHeight
; // height of a single data-row
227 sal_uInt16 nTitleLines
; // number of lines in title row
228 sal_uLong nControlAreaWidth
; // width of fixed area beneeth hscroll
229 bool bThumbDragging
; // handle thumb dragging
230 bool bColumnCursor
; // single columns and fields selectable
231 bool bMultiSelection
;// allow multiple selected rows
232 bool bKeepHighlight
; // don't hide selection on LoseFocus
234 bool bHLines
; // draw lines between rows
235 bool bVLines
; // draw lines between columns
236 Color aGridLineColor
; // color for lines, default dark grey
237 bool bBootstrapped
; // child windows resized etc.
238 long nTopRow
; // no. of first visible row (0...)
239 long nCurRow
; // no. of row with cursor
240 long nRowCount
; // total number of rows in model
241 sal_uInt16 nFirstCol
; // no. of first visible scrollable column
242 sal_uInt16 nCurColId
; // column id of cursor
245 bool bRowDividerDrag
;
247 bool mbInteractiveRowHeight
;
251 long nResizeX
; // mouse position at start of resizing
252 long nMinResizeX
; // never drag more left
253 long nDragX
; // last dragged column (MouseMove)
254 sal_uInt16 nResizeCol
; // resize this column in MouseMove
255 bool bResizing
; // mouse captured for column resizing
257 bool bSelect
; /// select or deselect
258 bool bSelectionIsVisible
; // depending on focus
259 bool bScrolling
; // hidden cursor while scrolling
260 bool bNotToggleSel
; // set while in ToggleSelection() etc.
261 bool bHasFocus
; // set/unset in Get/LoseFocus
262 bool bHideSelect
; // hide selection (highlight)
263 TriState bHideCursor
; // hide cursor (frame)
264 Range aSelRange
; // for selection expansion
266 BrowserColumns
* pCols
; // array of column-descriptions
269 MultiSelection
* pSel
; // selected rows for multi-selection
270 long nSel
; // selected row for single-selection
272 MultiSelection
* pColSel
; // selected column-ids
274 //fdo#83943, detect if making the cursor position
275 //visible is impossible to achieve
276 struct CursorMoveAttempt
280 bool m_bScrolledToReachCell
;
281 CursorMoveAttempt(long nCol
, long nRow
, bool bScrolledToReachCell
)
284 , m_bScrolledToReachCell(bScrolledToReachCell
)
287 bool operator==(const CursorMoveAttempt
& r
) const
289 return m_nCol
== r
.m_nCol
&&
290 m_nRow
== r
.m_nRow
&&
291 m_bScrolledToReachCell
== r
.m_bScrolledToReachCell
;
293 bool operator!=(const CursorMoveAttempt
& r
) const { return !(*this == r
); }
295 typedef std::stack
<CursorMoveAttempt
> GotoStack
;
296 GotoStack m_aGotoStack
;
298 ::std::unique_ptr
< ::svt::BrowseBoxImpl
> m_pImpl
; // impl structure of the BrowseBox object
300 bool m_bFocusOnlyCursor
; // hide cursor if we don't have the focus
301 Color m_aCursorColor
; // special color for cursor, COL_TRANSPARENT for usual (VCL-painted) "inverted" cursor
302 BrowserMode m_nCurrentMode
; // last argument of SetMode (redundant, as our other members represent the current settings, too)
305 SVT_DLLPRIVATE
void ConstructImpl(BrowserMode nMode
);
306 SVT_DLLPRIVATE
void ExpandRowSelection( const BrowserMouseEvent
& rEvt
);
307 SVT_DLLPRIVATE
void ToggleSelection( bool bForce
= false );
309 SVT_DLLPRIVATE
void UpdateScrollbars();
310 SVT_DLLPRIVATE
void AutoSizeLastColumn();
312 SVT_DLLPRIVATE
long ImpGetDataRowHeight() const;
313 SVT_DLLPRIVATE Rectangle
ImplFieldRectPixel( long nRow
, sal_uInt16 nColId
) const;
314 SVT_DLLPRIVATE sal_uInt16
FrozenColCount() const;
316 SVT_DLLPRIVATE
void ColumnInserted( sal_uInt16 nPos
);
318 DECL_DLLPRIVATE_LINK( ScrollHdl
, ScrollBar
* );
319 DECL_DLLPRIVATE_LINK( EndScrollHdl
, void * );
320 DECL_DLLPRIVATE_LINK( StartDragHdl
, HeaderBar
* );
322 SVT_DLLPRIVATE
long GetFrozenWidth() const;
324 bool GoToRow(long nRow
, bool bRowColMove
, bool bDoNotModifySelection
= false );
326 bool GoToColumnId( sal_uInt16 nColId
, bool bMakeVisible
, bool bRowColMove
= false);
327 void SelectColumnPos( sal_uInt16 nCol
, bool _bSelect
, bool bMakeVisible
);
328 void SelectColumnId( sal_uInt16 nColId
, bool _bSelect
, bool bMakeVisible
)
329 { SelectColumnPos( GetColumnPos(nColId
), _bSelect
, bMakeVisible
); }
331 void ImplPaintData(OutputDevice
& _rOut
, const Rectangle
& _rRect
, bool _bForeignDevice
, bool _bDrawSelections
);
333 bool PaintCursorIfHiddenOnce() const { return !m_bFocusOnlyCursor
&& !HasFocus(); }
335 sal_uInt16
ToggleSelectedColumn();
336 void SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId
);
339 /// retrieves the XAccessible implementation associated with the BrowseBox instance
340 ::svt::IAccessibleFactory
& getAccessibleFactory();
343 sal_uInt16
ColCount() const;
345 // software plug for database access
346 // RowCount is counted automatically
347 // (with the help of RowInserted and RowRemoved), so overriding of
348 // the method is needless
350 virtual long GetRowCount() const SAL_OVERRIDE
;
353 // for display in VScrollBar set it e.g. on "?"
354 void SetRealRowCount( const OUString
&rRealRowCount
);
356 // Return Value has to be sal_True always - SeekRow *has* to work!
357 // (else ASSERT) MI: who integrated that? It must not be like that!
359 /** seeks for the given row position
363 virtual bool SeekRow( long nRow
) = 0;
365 void PaintData(vcl::Window
& rWin
, vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
);
366 virtual void PaintField(OutputDevice
& rDev
, const Rectangle
& rRect
, sal_uInt16 nColumnId
) const = 0;
367 // Advice for the subclass: the visible scope of rows has changed.
368 // The subclass is able to announce changes of the model with the
369 // help of the methods RowInserted and RowRemoved. Because of the
370 // new status a paint is induced (SeekRow is called etc).
372 // parameters: nNewTopRow: number of the new TopRow (can get changed from
373 // VisibleRowsChanged by request of RowInserted and RowDeleted).
374 // nNumRows: number of visible rows (a partial visible row is counted too)
376 // Possible reason for changing the visible scope:
377 // - in front of the visible scope rows were inserted or removed, so the
378 // numbering of the visible scope has changed
379 // - Scrolling (and thereof resulting in another first visible row)
380 // - Resize the window
381 virtual void VisibleRowsChanged( long nNewTopRow
, sal_uInt16 nNumRows
);
383 // number of visible rows in the window (incl. "truncated" rows)
384 sal_uInt16
GetVisibleRows()
385 { return (sal_uInt16
)((pDataWin
->GetOutputSizePixel().Height() - 1 )/ GetDataRowHeight() + 1); }
386 long GetTopRow() { return nTopRow
; }
387 sal_uInt16
GetFirstVisibleColNumber() const { return nFirstCol
; }
389 // Focus-Rect enable / disable
390 void DoShowCursor( const char *pWhoLog
);
391 void DoHideCursor( const char *pWhoLog
);
392 short GetCursorHideCount() const;
394 virtual VclPtr
<BrowserHeader
> CreateHeaderBar( BrowseBox
* pParent
);
396 // HACK(virtual create is not called in Ctor)
397 void SetHeaderBar( BrowserHeader
* );
399 long CalcReverseZoom(long nVal
);
401 inline const DataFlavorExVector
&
402 GetDataFlavors() const;
404 bool IsDropFormatSupported( SotClipboardFormatId nFormat
); // need this because the base class' IsDropFormatSupported is not const ...
405 bool IsDropFormatSupported( SotClipboardFormatId nFormat
) const;
407 bool IsDropFormatSupported( const css::datatransfer::DataFlavor
& _rFlavor
); // need this because the base class' IsDropFormatSupported is not const ...
408 bool IsDropFormatSupported( const css::datatransfer::DataFlavor
& _rFlavor
) const;
411 void* implGetDataFlavors() const;
412 // with this we can make GetDataFlavors() inline, which is strongly needed as SVTOOLS does not export
413 // any sysbols containing an "_STL", so a non-inlined method would not be exported ....
416 // callbacks for the data window
417 virtual void ImplStartTracking();
418 virtual void ImplTracking();
419 virtual void ImplEndTracking();
422 BrowseBox( vcl::Window
* pParent
, WinBits nBits
= 0,
423 BrowserMode nMode
= BrowserMode::NONE
);
424 BrowseBox( vcl::Window
* pParent
, const ResId
& rId
,
425 BrowserMode nMode
= BrowserMode::NONE
);
426 virtual ~BrowseBox();
427 virtual void dispose() SAL_OVERRIDE
;
429 // override inherited handler
430 virtual void StateChanged( StateChangedType nStateChange
) SAL_OVERRIDE
;
431 virtual void MouseButtonDown( const MouseEvent
& rEvt
) SAL_OVERRIDE
;
432 virtual void MouseMove( const MouseEvent
& rEvt
) SAL_OVERRIDE
;
433 virtual void MouseButtonUp( const MouseEvent
& rEvt
) SAL_OVERRIDE
;
434 virtual void KeyInput( const KeyEvent
& rEvt
) SAL_OVERRIDE
;
435 virtual void LoseFocus() SAL_OVERRIDE
;
436 virtual void GetFocus() SAL_OVERRIDE
;
437 virtual void Resize() SAL_OVERRIDE
;
438 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
439 virtual void Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
, sal_uLong nFlags
) SAL_OVERRIDE
;
440 virtual void Command( const CommandEvent
& rEvt
) SAL_OVERRIDE
;
441 virtual void StartDrag( sal_Int8 _nAction
, const Point
& _rPosPixel
) SAL_OVERRIDE
;
443 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) SAL_OVERRIDE
; // will forward everything got to the second AcceptDrop method
444 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) SAL_OVERRIDE
; // will forward everything got to the second ExecuteDrop method
446 virtual sal_Int8
AcceptDrop( const BrowserAcceptDropEvent
& rEvt
);
447 virtual sal_Int8
ExecuteDrop( const BrowserExecuteDropEvent
& rEvt
);
450 virtual void MouseButtonDown( const BrowserMouseEvent
& rEvt
);
451 virtual void MouseButtonUp( const BrowserMouseEvent
& rEvt
);
453 virtual void EndScroll();
454 virtual void Select();
455 virtual void DoubleClick( const BrowserMouseEvent
& rEvt
);
456 virtual bool IsCursorMoveAllowed( long nNewRow
, sal_uInt16 nNewColId
) const;
457 virtual void CursorMoved();
458 virtual void ColumnMoved( sal_uInt16 nColId
);
459 virtual void ColumnResized( sal_uInt16 nColId
);
460 static long QueryColumnResize( sal_uInt16 nColId
, long nWidth
);
461 /// called when the row height has been changed interactively
462 virtual void RowHeightChanged();
463 virtual long QueryMinimumRowHeight();
465 // Window-Control (pass to DataWindow)
466 void SetUpdateMode( bool bUpdate
);
467 bool GetUpdateMode() const;
469 // map-mode and font control
470 void SetFont( const vcl::Font
& rNewFont
);
471 const vcl::Font
& GetFont() const { return pDataWin
->GetFont(); }
472 void SetTitleFont( const vcl::Font
& rNewFont
)
473 { Control::SetFont( rNewFont
); }
474 const vcl::Font
& GetTitleFont() const { return Control::GetFont(); }
476 // color for line painting
477 void SetGridLineColor(const Color
& rColor
) {aGridLineColor
= rColor
;}
478 const Color
& GetGridLineColor() const {return aGridLineColor
;}
480 // inserting, changing, removing and freezing of columns
481 void InsertHandleColumn( sal_uLong nWidth
);
482 void InsertDataColumn( sal_uInt16 nItemId
, const OUString
& rText
,
483 long nSize
, HeaderBarItemBits nBits
= HeaderBarItemBits::STDSTYLE
,
484 sal_uInt16 nPos
= HEADERBAR_APPEND
);
485 void SetColumnTitle( sal_uInt16 nColumnId
, const OUString
&rTitle
);
486 void SetColumnWidth( sal_uInt16 nColumnId
, sal_uLong nWidth
);
487 void SetColumnPos( sal_uInt16 nColumnId
, sal_uInt16 nPos
);
488 void FreezeColumn( sal_uInt16 nColumnId
, bool bFreeze
= true );
489 void UnfreezeColumns();
490 void RemoveColumn( sal_uInt16 nColumnId
);
491 void RemoveColumns();
493 // control of title and data row height
494 void SetDataRowHeight( long nPixel
);
495 long GetDataRowHeight() const;
496 void SetTitleLines( sal_uInt16 nLines
);
497 sal_uInt16
GetTitleLines() const { return nTitleLines
; }
498 long GetTitleHeight() const;
500 // access to dynamic values of cursor row
501 OUString
GetColumnTitle( sal_uInt16 nColumnId
) const;
502 Rectangle
GetFieldRect( sal_uInt16 nColumnId
) const;
503 sal_uLong
GetColumnWidth( sal_uInt16 nColumnId
) const;
504 sal_uInt16
GetColumnId( sal_uInt16 nPos
) const;
505 sal_uInt16
GetColumnPos( sal_uInt16 nColumnId
) const;
506 bool IsFrozen( sal_uInt16 nColumnId
) const;
508 // movement of visible area
510 long ScrollColumns( long nColumns
);
511 long ScrollRows( long nRows
);
512 bool MakeFieldVisible( long nRow
, sal_uInt16 nColId
, bool bComplete
= false );
514 // access and movement of cursor
515 long GetCurRow() const { return nCurRow
; }
516 sal_uInt16
GetCurColumnId() const { return nCurColId
; }
517 bool GoToRow( long nRow
);
518 bool GoToColumnId( sal_uInt16 nColId
);
519 bool GoToRowColumnId( long nRow
, sal_uInt16 nColId
);
522 virtual void SetNoSelection() SAL_OVERRIDE
;
523 virtual void SelectAll() SAL_OVERRIDE
;
524 virtual void SelectRow( long nRow
, bool _bSelect
= true, bool bExpand
= true ) SAL_OVERRIDE
;
525 void SelectColumnPos( sal_uInt16 nCol
, bool _bSelect
= true )
526 { SelectColumnPos( nCol
, _bSelect
, true); }
527 void SelectColumnId( sal_uInt16 nColId
, bool _bSelect
= true )
528 { SelectColumnPos( GetColumnPos(nColId
), _bSelect
, true); }
529 long GetSelectRowCount() const;
530 sal_uInt16
GetSelectColumnCount() const;
531 virtual bool IsRowSelected( long nRow
) const SAL_OVERRIDE
;
532 bool IsColumnSelected( sal_uInt16 nColumnId
) const;
533 long FirstSelectedRow( bool bInverse
= false );
534 long LastSelectedRow();
535 long NextSelectedRow();
536 const MultiSelection
* GetColumnSelection() const { return pColSel
; }
537 const MultiSelection
* GetSelection() const
538 { return bMultiSelection
? uRow
.pSel
: 0; }
540 long FirstSelectedColumn( ) const;
542 bool IsResizing() const { return bResizing
; }
544 // access to positions of fields, column and rows
545 vcl::Window
& GetDataWindow() const { return *pDataWin
; }
546 Rectangle
GetRowRectPixel( long nRow
,
547 bool bRelToBrowser
= true ) const;
548 Rectangle
GetFieldRectPixel( long nRow
, sal_uInt16 nColId
,
549 bool bRelToBrowser
= true) const;
550 bool IsFieldVisible( long nRow
, sal_uInt16 nColId
,
551 bool bComplete
= false ) const;
552 long GetRowAtYPosPixel( long nY
,
553 bool bRelToBrowser
= true ) const;
554 sal_uInt16
GetColumnAtXPosPixel( long nX
,
555 bool bRelToBrowser
= true ) const;
559 void RowRemoved( long nRow
, long nNumRows
= 1, bool bDoPaint
= true );
560 void RowModified( long nRow
, sal_uInt16 nColId
= BROWSER_INVALIDID
);
561 void RowInserted( long nRow
, long nNumRows
= 1, bool bDoPaint
= true, bool bKeepSelection
= false );
564 void ReserveControlArea( sal_uInt16 nWidth
= USHRT_MAX
);
565 Rectangle
GetControlArea() const;
566 bool ProcessKey( const KeyEvent
& rEvt
);
567 void Dispatch( sal_uInt16 nId
);
568 void SetMode( BrowserMode nMode
= BrowserMode::NONE
);
569 BrowserMode
GetMode( ) const { return m_nCurrentMode
; }
571 void SetCursorColor(const Color
& _rCol
);
572 Color
GetCursorColor() const { return m_aCursorColor
; }
573 void ResetSelecting() { bSelecting
= false; }
575 /** specifies that the user is allowed to interactively change the height of a row,
576 by simply dragging an arbitrary row separator.
578 Note that this works only if there's a handle column, since only in this case,
579 there *is* something for the user to click onto
581 void EnableInteractiveRowHeight( bool _bEnable
= true ) { mbInteractiveRowHeight
= _bEnable
; }
582 bool IsInteractiveRowHeightEnabled( ) const { return mbInteractiveRowHeight
; }
584 /// access to selected methods, to be granted to the BrowserColumn
585 struct BrowserColumnAccess
{ friend class BrowserColumn
; private: BrowserColumnAccess() { } };
586 /** public version of PaintField, with selected access rights for the BrowserColumn
588 void DoPaintField( OutputDevice
& rDev
, const Rectangle
& rRect
, sal_uInt16 nColumnId
, BrowserColumnAccess
) const
589 { PaintField( rDev
, rRect
, nColumnId
); }
591 /** suggests a default width for a column containing a given text
593 The width is calculated so that the text fits completely, plus som margin.
595 sal_uLong
GetDefaultColumnWidth( const OUString
& _rText
) const;
597 /** GetCellText returns the text at the given position
599 the number of the row
603 the text out of the cell
605 virtual OUString
GetCellText(long _nRow
, sal_uInt16 _nColId
) const;
608 the current column count
610 sal_uInt16
GetColumnCount() const SAL_OVERRIDE
{ return ColCount(); }
612 /** commitBrowseBoxEvent commit the event at all listeners of the browsebox
620 void commitBrowseBoxEvent(sal_Int16 nEventId
,
621 const css::uno::Any
& rNewValue
,
622 const css::uno::Any
& rOldValue
);
624 /** commitTableEvent commit the event at all listeners of the table
632 void commitTableEvent(sal_Int16 nEventId
,
633 const css::uno::Any
& rNewValue
,
634 const css::uno::Any
& rOldValue
);
636 /** fires an AccessibleEvent relative to a header bar AccessibleContext
645 void commitHeaderBarEvent(sal_Int16 nEventId
,
646 const css::uno::Any
& rNewValue
,
647 const css::uno::Any
& rOldValue
,
648 bool _bColumnHeaderBar
651 /** returns the Rectangle for either the column header bar ot the row header bar
653 <TRUE/> when column header bar is used
655 <TRUE/> when the rectangle should be calculated OnScreen
659 virtual Rectangle
calcHeaderRect(bool _bIsColumnBar
, bool _bOnScreen
= true) SAL_OVERRIDE
;
661 /** calculates the Rectangle of the table
663 <TRUE/> when the rectangle should be calculated OnScreen
667 virtual Rectangle
calcTableRect(bool _bOnScreen
= true) SAL_OVERRIDE
;
675 <TRUE/> when the rectangle should be calculated OnScreen
679 virtual Rectangle
GetFieldRectPixelAbs(sal_Int32 _nRowId
, sal_uInt16 _nColId
, bool _bIsHeader
, bool _bOnScreen
= true) SAL_OVERRIDE
;
681 /// return <TRUE/> if and only if the accessible object for this instance has been created and is alive
682 bool isAccessibleAlive( ) const;
684 // ACCESSIBILITY ==========================================================
686 /** Creates and returns the accessible object of the whole BrowseBox. */
687 virtual css::uno::Reference
<
688 css::accessibility::XAccessible
> CreateAccessible() SAL_OVERRIDE
;
690 // Children ---------------------------------------------------------------
692 /** Creates the accessible object of a data table cell.
693 @param nRow The row index of the cell.
694 @param nColumnId The column pos of the cell.
695 @return The XAccessible interface of the specified cell. */
696 virtual css::uno::Reference
<
697 css::accessibility::XAccessible
>
698 CreateAccessibleCell( sal_Int32 nRow
, sal_uInt16 nColumnPos
) SAL_OVERRIDE
;
700 /** Creates the accessible object of a row header.
701 @param nRow The row index of the header.
702 @return The XAccessible interface of the specified row header. */
703 virtual css::uno::Reference
<
704 css::accessibility::XAccessible
>
705 CreateAccessibleRowHeader( sal_Int32 nRow
) SAL_OVERRIDE
;
707 /** Creates the accessible object of a column header.
708 @param nColumnId The column ID of the header.
709 @return The XAccessible interface of the specified column header. */
710 virtual css::uno::Reference
<
711 css::accessibility::XAccessible
>
712 CreateAccessibleColumnHeader( sal_uInt16 nColumnPos
) SAL_OVERRIDE
;
714 /** @return The count of additional controls of the control area. */
715 virtual sal_Int32
GetAccessibleControlCount() const SAL_OVERRIDE
;
717 /** Creates the accessible object of an additional control.
718 @param nIndex The 0-based index of the control.
719 @return The XAccessible interface of the specified control. */
720 virtual css::uno::Reference
<
721 css::accessibility::XAccessible
>
722 CreateAccessibleControl( sal_Int32 nIndex
) SAL_OVERRIDE
;
724 // Conversions ------------------------------------------------------------
726 /** Converts a point relative to the data window origin to a cell address.
727 @param rnRow Out-parameter that takes the row index.
728 @param rnColumnId Out-parameter that takes the column ID.
729 @param rPoint The position in pixels relative to the data window.
730 @return <TRUE/>, if the point could be converted to a valid address. */
731 virtual bool ConvertPointToCellAddress(
732 sal_Int32
& rnRow
, sal_uInt16
& rnColumnId
, const Point
& rPoint
) SAL_OVERRIDE
;
734 /** Converts a point relative to the row header bar origin to a row header
736 @param rnRow Out-parameter that takes the row index.
737 @param rPoint The position in pixels relative to the header bar.
738 @return <TRUE/>, if the point could be converted to a valid index. */
739 virtual bool ConvertPointToRowHeader( sal_Int32
& rnRow
, const Point
& rPoint
) SAL_OVERRIDE
;
741 /** Converts a point relative to the column header bar origin to a column
743 @param rnColumnId Out-parameter that takes the column ID.
744 @param rPoint The position in pixels relative to the header bar.
745 @return <TRUE/>, if the point could be converted to a valid index. */
746 virtual bool ConvertPointToColumnHeader( sal_uInt16
& rnColumnPos
, const Point
& rPoint
) SAL_OVERRIDE
;
748 /** Converts a point relative to the BrowseBox origin to the index of an
750 @param rnRow Out-parameter that takes the 0-based control index.
751 @param rPoint The position in pixels relative to the BrowseBox.
752 @return <TRUE/>, if the point could be converted to a valid index. */
753 virtual bool ConvertPointToControlIndex( sal_Int32
& rnIndex
, const Point
& rPoint
) SAL_OVERRIDE
;
755 // Object data and state --------------------------------------------------
757 /** return the name of the specified object.
761 The position of a tablecell (index position), header bar column/row cell
763 The name of the specified object.
765 virtual OUString
GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const SAL_OVERRIDE
;
767 /** return the description of the specified object.
771 The position of a tablecell (index position), header bar column/row cell
773 The description of the specified object.
775 virtual OUString
GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const SAL_OVERRIDE
;
777 /** @return The header text of the specified row. */
778 virtual OUString
GetRowDescription( sal_Int32 nRow
) const SAL_OVERRIDE
;
780 /** @return The header text of the specified column. */
781 virtual OUString
GetColumnDescription( sal_uInt16 _nColumn
) const SAL_OVERRIDE
;
783 /** Fills the StateSet with all states (except DEFUNC and SHOWING, done by
784 the accessible object), depending on the specified object type. */
785 virtual void FillAccessibleStateSet(
786 ::utl::AccessibleStateSetHelper
& rStateSet
,
787 ::svt::AccessibleBrowseBoxObjType eObjType
) const SAL_OVERRIDE
;
789 /** Fills the StateSet with all states for one cell (except DEFUNC and SHOWING, done by
790 the accessible object). */
791 virtual void FillAccessibleStateSetForCell(
792 ::utl::AccessibleStateSetHelper
& _rStateSet
,
793 sal_Int32 _nRow
, sal_uInt16 _nColumn
) const SAL_OVERRIDE
;
795 /** Sets focus to current cell of the data table. */
796 virtual void GrabTableFocus() SAL_OVERRIDE
;
798 // IAccessibleTableProvider
799 virtual sal_Int32
GetCurrRow() const SAL_OVERRIDE
;
800 virtual sal_uInt16
GetCurrColumn() const SAL_OVERRIDE
;
801 virtual bool HasRowHeader() const SAL_OVERRIDE
;
802 virtual bool IsCellFocusable() const SAL_OVERRIDE
;
803 virtual bool GoToCell( sal_Int32 _nRow
, sal_uInt16 _nColumn
) SAL_OVERRIDE
;
804 virtual void SelectColumn( sal_uInt16 _nColumn
, bool _bSelect
= true ) SAL_OVERRIDE
;
805 virtual bool IsColumnSelected( long _nColumn
) const SAL_OVERRIDE
;
806 virtual sal_Int32
GetSelectedRowCount() const SAL_OVERRIDE
;
807 virtual sal_Int32
GetSelectedColumnCount() const SAL_OVERRIDE
;
808 virtual void GetAllSelectedRows( css::uno::Sequence
< sal_Int32
>& _rRows
) const SAL_OVERRIDE
;
809 virtual void GetAllSelectedColumns( css::uno::Sequence
< sal_Int32
>& _rColumns
) const SAL_OVERRIDE
;
810 virtual bool IsCellVisible( sal_Int32 _nRow
, sal_uInt16 _nColumn
) const SAL_OVERRIDE
;
811 virtual OUString
GetAccessibleCellText(long _nRow
, sal_uInt16 _nColPos
) const SAL_OVERRIDE
;
812 virtual bool GetGlyphBoundRects( const Point
& rOrigin
, const OUString
& rStr
, int nIndex
, int nLen
, int nBase
, MetricVector
& rVector
) SAL_OVERRIDE
;
813 virtual Rectangle
GetWindowExtentsRelative( vcl::Window
*pRelativeWindow
) const SAL_OVERRIDE
;
814 virtual void GrabFocus() SAL_OVERRIDE
;
815 virtual css::uno::Reference
< css::accessibility::XAccessible
> GetAccessible( bool bCreate
= true ) SAL_OVERRIDE
;
816 virtual vcl::Window
* GetAccessibleParentWindow() const SAL_OVERRIDE
;
817 virtual vcl::Window
* GetWindowInstance() SAL_OVERRIDE
;
820 // the following declares some Window/OutputDevice methods private. This happened in the course
821 // of CWS warnings01, which pointed out nameclashs in those methods. If the build breaks in some
822 // upper module, you should investigate whether you really wanted to call base class methods,
823 // or the versions at this class. In the latter case, use the renamed versions above.
825 // Set/GetLineColor - superseded by Set/GetGridLineColor
826 using OutputDevice::SetLineColor
;
827 using OutputDevice::GetLineColor
;
829 // ToTop/ToBottom were never property implemented. If you currently call it, this is most probably wrong
830 // and not doing as intended
835 inline const DataFlavorExVector
& BrowseBox::GetDataFlavors() const
837 return *static_cast<DataFlavorExVector
*>(implGetDataFlavors());
842 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */