Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef _SVX_BRWBOX_HXX
20 : #define _SVX_BRWBOX_HXX
21 :
22 : #include "svtools/svtdllapi.h"
23 : #include <vcl/scrbar.hxx>
24 : #include <vcl/ctrl.hxx>
25 : #include <tools/multisel.hxx>
26 : #include <svtools/headbar.hxx>
27 : #include <svtools/transfer.hxx>
28 : #include <svtools/AccessibleBrowseBoxObjType.hxx>
29 : #include <svtools/accessibletableprovider.hxx>
30 : #include <vector>
31 :
32 : #include <limits.h>
33 : #include <memory>
34 :
35 : class BrowserColumn;
36 : class BrowserDataWin;
37 : class MultiSelection;
38 : class BrowserHeader;
39 :
40 : typedef ::std::vector< BrowserColumn* > BrowserColumns;
41 :
42 : namespace svt {
43 : class BrowseBoxImpl;
44 : class IAccessibleFactory;
45 : }
46 : namespace utl {
47 : class AccessibleStateSetHelper;
48 : }
49 :
50 : // -------------------
51 : // - BrowseBox-Types -
52 : // -------------------
53 :
54 : #define BROWSER_INVALIDID SAL_MAX_UINT16
55 : #define BROWSER_ENDOFSELECTION (static_cast<long>(SFX_ENDOFSELECTION))
56 :
57 : typedef sal_uLong BrowserMode;
58 :
59 : #define BROWSER_COLUMNSELECTION 0x0001
60 : #define BROWSER_MULTISELECTION 0x0002
61 : #define BROWSER_THUMBDRAGGING 0x0004
62 : #define BROWSER_KEEPHIGHLIGHT 0x0008
63 : #define BROWSER_KEEPSELECTION BROWSER_KEEPHIGHLIGHT // old, don't use!
64 : #define BROWSER_HLINES 0x0010
65 : #define BROWSER_VLINES 0x0020
66 : #define BROWSER_HLINESFULL BROWSER_HLINES // old, don't use!
67 : #define BROWSER_VLINESFULL BROWSER_VLINES // old, don't use!
68 : #define BROWSER_HLINESDOTS 0x0000 // old => don't use!
69 : #define BROWSER_VLINESDOTS 0x0000 // old => don't use!
70 :
71 : #define BROWSER_HIDESELECT 0x0100 // old => don't use!
72 : #define BROWSER_HIDECURSOR 0x0200
73 :
74 : #define BROWSER_NO_HSCROLL 0x0400
75 : #define BROWSER_NO_SCROLLBACK 0x0800
76 :
77 : #define BROWSER_AUTO_VSCROLL 0x1000
78 : #define BROWSER_AUTO_HSCROLL 0x2000
79 :
80 : #define BROWSER_TRACKING_TIPS 0x4000
81 :
82 : #define BROWSER_NO_VSCROLL 0x8000
83 :
84 : #define BROWSER_HIGHLIGHT_NONE 0x0100 // == BROWSER_HIDESELECT
85 :
86 : #define BROWSER_HEADERBAR_NEW 0x00040000
87 : #define BROWSER_AUTOSIZE_LASTCOL 0x00080000
88 : #define BROWSER_OWN_DATACHANGED 0x00100000
89 :
90 : #define BROWSER_CURSOR_WO_FOCUS 0x00200000
91 : // Allows a cursor which is shown even if the control does not have the focus. This does not affect other
92 : // situations which require to temporarily hide the cursor (such as scrolling).
93 :
94 : #define BROWSER_SMART_HIDECURSOR 0x00400000
95 : // is an enhanced version of BROWSER_HIDECURSOR.
96 : // When set, BROWSER_HIDECURSOR is overruled, and the cursor is hidden as long as no selection exists,
97 : // but shown otherwise. This does not affect other situations which require to temporarily hide the
98 : // cursor (such as scrolling).
99 :
100 : #define BROWSER_NONE 0
101 : #define BROWSER_SELECT 720
102 : #define BROWSER_ENHANCESELECTION 722
103 : #define BROWSER_SELECTDOWN 724
104 : #define BROWSER_SELECTUP 725
105 : #define BROWSER_CURSORDOWN 731
106 : #define BROWSER_CURSORUP 732
107 : #define BROWSER_CURSORLEFT 733
108 : #define BROWSER_CURSORRIGHT 734
109 : #define BROWSER_CURSORPAGEDOWN 735
110 : #define BROWSER_CURSORPAGEUP 736
111 : #define BROWSER_CURSORENDOFFILE 741
112 : #define BROWSER_CURSORTOPOFFILE 742
113 : #define BROWSER_CURSORENDOFSCREEN 743
114 : #define BROWSER_CURSORTOPOFSCREEN 744
115 : #define BROWSER_CURSORHOME 745
116 : #define BROWSER_CURSOREND 746
117 : #define BROWSER_SCROLLDOWN 751
118 : #define BROWSER_SCROLLUP 752
119 : #define BROWSER_SELECTHOME 753
120 : #define BROWSER_SELECTEND 754
121 : #define BROWSER_SELECTCOLUMN 755
122 : #define BROWSER_MOVECOLUMNLEFT 756
123 : #define BROWSER_MOVECOLUMNRIGHT 757
124 :
125 : // ---------------
126 : // - BrowseEvent -
127 : // ---------------
128 :
129 : class BrowseEvent
130 : {
131 : Window* pWin;
132 : long nRow;
133 : Rectangle aRect;
134 : sal_uInt16 nCol;
135 : sal_uInt16 nColId;
136 :
137 : public:
138 : BrowseEvent();
139 : BrowseEvent( Window* pWindow,
140 : long nAbsRow,
141 : sal_uInt16 nColumn, sal_uInt16 nColumnId,
142 : const Rectangle& rRect );
143 :
144 0 : Window* GetWindow() const { return pWin; }
145 0 : long GetRow() const { return nRow; }
146 0 : sal_uInt16 GetColumn() const { return nCol; }
147 0 : sal_uInt16 GetColumnId() const { return nColId; }
148 0 : const Rectangle& GetRect() const { return aRect; }
149 : };
150 :
151 : // ---------------------
152 : // - BrowserMouseEvent -
153 : // ---------------------
154 :
155 : class BrowserMouseEvent: public MouseEvent, public BrowseEvent
156 : {
157 : public:
158 : BrowserMouseEvent();
159 : BrowserMouseEvent( BrowserDataWin* pWin, const MouseEvent& rEvt );
160 : BrowserMouseEvent( Window* pWin, const MouseEvent& rEvt,
161 : long nAbsRow, sal_uInt16 nColumn, sal_uInt16 nColumnId,
162 : const Rectangle& rRect );
163 : };
164 :
165 : // --------------------------
166 : // - BrowserAcceptDropEvent -
167 : // --------------------------
168 :
169 0 : class BrowserAcceptDropEvent : public AcceptDropEvent, public BrowseEvent
170 : {
171 : public:
172 : BrowserAcceptDropEvent();
173 : BrowserAcceptDropEvent( BrowserDataWin* pWin, const AcceptDropEvent& rEvt );
174 : };
175 :
176 : // ---------------------------
177 : // - BrowserExecuteDropEvent -
178 : // ---------------------------
179 :
180 0 : class BrowserExecuteDropEvent : public ExecuteDropEvent, public BrowseEvent
181 : {
182 : public:
183 : BrowserExecuteDropEvent();
184 : BrowserExecuteDropEvent( BrowserDataWin* pWin, const ExecuteDropEvent& rEvt );
185 : };
186 :
187 : // -------------
188 : // - BrowseBox -
189 : // -------------
190 :
191 : // TODO
192 : // The whole selection thingie in this class is somewhat .... suspicious to me.
193 : // some oddities:
194 : // * method parameters named like members (and used in both semantics within the method!)
195 : // * the multi selection flag is sometimes used as if it is for row selection, sometimes as if
196 : // it's for column selection, too (and sometimes in an even stranger way :)
197 : // * it is not really defined like all these hundreds selection related flags/methods work together
198 : // and influence each other. I do not understand it very well, but this may be my fault :)
199 : // * There is a GetColumnSelection, but it can't be used to determine the selected columns (at least
200 : // not without a const_cast)
201 : //
202 : // We should clearly define this somewhere in the future. Or, even better, we should re-implement this
203 : // whole class, which is planned for a long time :)
204 : //
205 : // sorry for the ranting. could not resist
206 :
207 : class SVT_DLLPUBLIC BrowseBox
208 : :public Control
209 : ,public DragSourceHelper
210 : ,public DropTargetHelper
211 : ,public svt::IAccessibleTableProvider
212 : {
213 : #define NO_CURSOR_HIDE 0
214 : #define HARD_CURSOR_HIDE 1
215 : #define SMART_CURSOR_HIDE 2
216 :
217 : friend class BrowserDataWin;
218 : friend class ::svt::BrowseBoxImpl;
219 :
220 : #ifdef DBG_UTIL
221 : friend const char* BrowseBoxCheckInvariants( const void * pVoid );
222 : #endif
223 :
224 : public:
225 : static const sal_uInt16 HandleColumnId = 0;
226 :
227 : private:
228 : Window* pDataWin; // window to display data rows
229 : ScrollBar* pVScroll; // vertical scrollbar
230 : ScrollBar aHScroll; // horizontal scrollbar
231 :
232 : long nDataRowHeight; // height of a single data-row
233 : sal_uInt16 nTitleLines; // number of lines in title row
234 : sal_uLong nControlAreaWidth; // width of fixed area beneeth hscroll
235 : sal_Bool bThumbDragging; // handle thumb dragging
236 : sal_Bool bColumnCursor; // single columns and fields selectable
237 : sal_Bool bMultiSelection;// allow multiple selected rows
238 : sal_Bool bKeepHighlight; // don't hide selection on LoseFocus
239 :
240 : sal_Bool bHLines; // draw lines between rows
241 : sal_Bool bVLines; // draw lines between columns
242 : sal_Bool bHDots; // draw lines between rows dotted
243 : sal_Bool bVDots; // draw lines between columns dotted
244 : Color aGridLineColor; // color for lines, default dark grey
245 : sal_Bool bBootstrapped; // child windows resized etc.
246 : long nTopRow; // no. of first visible row (0...)
247 : long nCurRow; // no. of row with cursor
248 : long nRowCount; // total number of rows in model
249 : sal_uInt16 nFirstCol; // no. of first visible scrollable column
250 : sal_uInt16 nCurColId; // column id of cursor
251 :
252 : sal_Bool bSelecting;
253 : sal_Bool bRowDividerDrag;
254 : sal_Bool bHit;
255 : sal_Bool mbInteractiveRowHeight;
256 : Point a1stPoint;
257 : Point a2ndPoint;
258 :
259 : long nResizeX; // mouse position at start of resizing
260 : long nMinResizeX; // never drag more left
261 : long nDragX; // last dragged column (MouseMove)
262 : sal_uInt16 nResizeCol; // resize this column in MouseMove
263 : sal_Bool bResizing; // mouse captured for column resizing
264 :
265 : bool bSelect; /// select or deselect
266 : sal_Bool bSelectionIsVisible; // depending on focus
267 : sal_Bool bScrolling; // hidden cursor while scrolling
268 : sal_Bool bNotToggleSel; // set while in ToggleSelection() etc.
269 : sal_Bool bHasFocus; // set/unset in Get/LoseFocus
270 : sal_Bool bHideSelect; // hide selection (highlight)
271 : sal_Bool bHideCursor; // hide cursor (frame)
272 : Range aSelRange; // for selection expansion
273 :
274 : BrowserColumns* pCols; // array of column-descriptions
275 : union
276 : {
277 : MultiSelection* pSel; // selected rows for multi-selection
278 : long nSel; // selected row for single-selection
279 : } uRow;
280 : MultiSelection* pColSel; // selected column-ids
281 :
282 : ::std::auto_ptr< ::svt::BrowseBoxImpl > m_pImpl; // impl structure of the BrowseBox object
283 :
284 : sal_Bool m_bFocusOnlyCursor; // hide cursor if we don't have the focus
285 : Color m_aCursorColor; // special color for cursor, COL_TRANSPARENT for usual (VCL-painted) "inverted" cursor
286 : BrowserMode m_nCurrentMode; // last argument of SetMode (redundant, as our other members represent the current settings, too)
287 :
288 : private:
289 : SVT_DLLPRIVATE void ConstructImpl(BrowserMode nMode);
290 : SVT_DLLPRIVATE void ExpandRowSelection( const BrowserMouseEvent& rEvt );
291 : SVT_DLLPRIVATE void ToggleSelection( sal_Bool bForce = sal_False );
292 :
293 : SVT_DLLPRIVATE void UpdateScrollbars();
294 : SVT_DLLPRIVATE void AutoSizeLastColumn();
295 :
296 : SVT_DLLPRIVATE long ImpGetDataRowHeight() const;
297 : SVT_DLLPRIVATE Rectangle ImplFieldRectPixel( long nRow, sal_uInt16 nColId ) const;
298 : SVT_DLLPRIVATE sal_uInt16 FrozenColCount() const;
299 :
300 : SVT_DLLPRIVATE void ColumnInserted( sal_uInt16 nPos );
301 :
302 : DECL_DLLPRIVATE_LINK( ScrollHdl, ScrollBar * );
303 : DECL_DLLPRIVATE_LINK( EndScrollHdl, void * );
304 : DECL_DLLPRIVATE_LINK( StartDragHdl, HeaderBar * );
305 :
306 : SVT_DLLPRIVATE long GetFrozenWidth() const;
307 :
308 : sal_Bool GoToRow(long nRow, sal_Bool bRowColMove, sal_Bool bDoNotModifySelection = sal_False );
309 :
310 : sal_Bool GoToColumnId( sal_uInt16 nColId, sal_Bool bMakeVisible, sal_Bool bRowColMove = sal_False);
311 : void SelectColumnPos( sal_uInt16 nCol, sal_Bool _bSelect, sal_Bool bMakeVisible);
312 0 : void SelectColumnId( sal_uInt16 nColId, sal_Bool _bSelect, sal_Bool bMakeVisible)
313 0 : { SelectColumnPos( GetColumnPos(nColId), _bSelect, bMakeVisible); }
314 :
315 : void ImplPaintData(OutputDevice& _rOut, const Rectangle& _rRect, sal_Bool _bForeignDevice, sal_Bool _bDrawSelections);
316 :
317 810 : sal_Bool PaintCursorIfHiddenOnce() const { return !m_bFocusOnlyCursor && !HasFocus(); }
318 :
319 : sal_uInt16 ToggleSelectedColumn();
320 : void SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId);
321 :
322 : protected:
323 : /// retrieves the XAccessible implementation associated with the BrowseBox instance
324 : ::svt::IAccessibleFactory& getAccessibleFactory();
325 :
326 : protected:
327 : sal_uInt16 ColCount() const;
328 :
329 : // software plug for database access
330 : // Der RowCount wird jetzt intern automatisch gezaehlt
331 : // (ueber RowInserted und RowRemoved), daher ist das Ueberladen
332 : // dieser Methode ueberfluessig!
333 : public:
334 : virtual long GetRowCount() const;
335 :
336 : protected:
337 : // fuer Anzeige im VScrollBar z.B. auf "?" oder setzen
338 : void SetRealRowCount( const String &rRealRowCount );
339 :
340 : // Return Value muss immer sal_True sein - SeekRow *muss* klappen!
341 : // (sonst ASSERT) MI: wer hat das eingebaut? Das darf nicht so sein!
342 :
343 : /** seeks for the given row position
344 : @param nRow
345 : nRow starts at 0
346 : */
347 : virtual sal_Bool SeekRow( long nRow ) = 0;
348 : virtual void DrawCursor();
349 : virtual void PaintRow( OutputDevice &rDev, const Rectangle &rRect );
350 : virtual void PaintData( Window& rWin, const Rectangle& rRect );
351 : virtual void PaintField( OutputDevice& rDev, const Rectangle& rRect,
352 : sal_uInt16 nColumnId ) const = 0;
353 : // Benachrichtigung an die abgeleitete Klasse, dass sich der sichtbare
354 : // Bereich von Rows geaendert hat. Aus dieser Methode heraus darf
355 : // die abgeleitete Klasse Aenderungen des Model mit Hilfe der Methoden
356 : // RowInserted und RowRemoved bekanntgeben. Mit sich daraus ergebenden
357 : // neuen Zustand wird anschliessend ein Paint veranlasst (und entsprechend
358 : // SeekRow etc. gerufen).
359 : //
360 : // Parameter: nNewTopRow: Nr. der neuen TopRow (kann von VisibleRowsChanged
361 : // durch Aufruf von RowInserted und RowDeleted noch veraendert werden).
362 : // nNumRows: Anzahl der sichtbaren Rows (auch eine teilweise sichtbare Row
363 : // wird mitgezaehlt).
364 : //
365 : // Moegliche Ursachen fuer die Aenderung des sichtbaren Bereiches:
366 : // - Vor dem sichtbaren Bereich sind Rows eingefuegt oder geloescht worden,
367 : // dadurch aendert sich nur die Numerierung der sichtbaren Rows
368 : // - Scrollen (und daraus resultierend eine andere erste sichtbare Row)
369 : // - Resize des Fensters
370 : virtual void VisibleRowsChanged( long nNewTopRow, sal_uInt16 nNumRows);
371 :
372 : // Anzahl sichtbarer Rows in dem Fenster (inkl. "angeschnittener" Rows)
373 1 : sal_uInt16 GetVisibleRows()
374 1 : { return (sal_uInt16)((pDataWin->GetOutputSizePixel().Height() - 1 )/ GetDataRowHeight() + 1); }
375 2 : long GetTopRow() { return nTopRow; }
376 0 : sal_uInt16 GetFirstVisibleColNumber() const { return nFirstCol; }
377 :
378 : // Focus-Rect ein-/ausschalten
379 : void DoShowCursor( const char *pWhoLog );
380 : void DoHideCursor( const char *pWhoLog );
381 : short GetCursorHideCount() const;
382 :
383 : virtual BrowserHeader* CreateHeaderBar( BrowseBox* pParent );
384 :
385 : // HACK(virtuelles Create wird im Ctor nicht gerufen)
386 : void SetHeaderBar( BrowserHeader* );
387 :
388 : long CalcReverseZoom(long nVal);
389 :
390 : inline const DataFlavorExVector&
391 : GetDataFlavors() const;
392 :
393 : sal_Bool IsDropFormatSupported( SotFormatStringId nFormat ); // need this because the base class' IsDropFormatSupported is not const ...
394 : sal_Bool IsDropFormatSupported( SotFormatStringId nFormat ) const;
395 :
396 : sal_Bool IsDropFormatSupported( const css::datatransfer::DataFlavor& _rFlavor ); // need this because the base class' IsDropFormatSupported is not const ...
397 : sal_Bool IsDropFormatSupported( const css::datatransfer::DataFlavor& _rFlavor ) const;
398 :
399 : private:
400 : void* implGetDataFlavors() const;
401 : // with this we can make GetDataFlavors() inline, which is strongly needed as SVTOOLS does not export
402 : // any sysbols containing an "_STL", so a non-inlined method would not be exported ....
403 :
404 : protected:
405 : // callbacks for the data window
406 : virtual void ImplStartTracking();
407 : virtual void ImplTracking();
408 : virtual void ImplEndTracking();
409 :
410 : public:
411 : BrowseBox( Window* pParent, WinBits nBits = 0,
412 : BrowserMode nMode = 0 );
413 : BrowseBox( Window* pParent, const ResId& rId,
414 : BrowserMode nMode = 0 );
415 : ~BrowseBox();
416 :
417 : // ererbte ueberladene Handler
418 : virtual void StateChanged( StateChangedType nStateChange );
419 : virtual void MouseButtonDown( const MouseEvent& rEvt );
420 : virtual void MouseMove( const MouseEvent& rEvt );
421 : virtual void MouseButtonUp( const MouseEvent& rEvt );
422 : virtual void KeyInput( const KeyEvent& rEvt );
423 : virtual void LoseFocus();
424 : virtual void GetFocus();
425 : virtual void Resize();
426 : virtual void Paint( const Rectangle& rRect );
427 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
428 : virtual void Command( const CommandEvent& rEvt );
429 : virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel );
430 :
431 : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); // will forward everything got to the second AcceptDrop method
432 : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); // will forward everything got to the second ExecuteDrop method
433 :
434 : virtual sal_Int8 AcceptDrop( const BrowserAcceptDropEvent& rEvt );
435 : virtual sal_Int8 ExecuteDrop( const BrowserExecuteDropEvent& rEvt );
436 :
437 : // neue Handler
438 : virtual void MouseButtonDown( const BrowserMouseEvent& rEvt );
439 : virtual void MouseMove( const BrowserMouseEvent& rEvt );
440 : virtual void MouseButtonUp( const BrowserMouseEvent& rEvt );
441 : virtual void StartScroll();
442 : virtual void EndScroll();
443 : virtual void Select();
444 : virtual void DoubleClick( const BrowserMouseEvent& rEvt );
445 : virtual sal_Bool IsCursorMoveAllowed( long nNewRow, sal_uInt16 nNewColId ) const;
446 : virtual void CursorMoved();
447 : virtual void ColumnMoved( sal_uInt16 nColId );
448 : virtual void ColumnResized( sal_uInt16 nColId );
449 : virtual long QueryColumnResize( sal_uInt16 nColId, long nWidth );
450 : /// called when the row height has been changed interactively
451 : virtual void RowHeightChanged();
452 : virtual long QueryMinimumRowHeight();
453 :
454 : // Window-Control (pass to DataWindow)
455 : void SetUpdateMode( sal_Bool bUpdate );
456 : sal_Bool GetUpdateMode() const;
457 :
458 : // map-mode and font control
459 : void SetFont( const Font& rNewFont );
460 0 : const Font& GetFont() const { return pDataWin->GetFont(); }
461 0 : void SetTitleFont( const Font& rNewFont )
462 0 : { Control::SetFont( rNewFont ); }
463 : const Font& GetTitleFont() const { return Control::GetFont(); }
464 :
465 : // color for line painting
466 21 : void SetGridLineColor(const Color& rColor) {aGridLineColor = rColor;}
467 : const Color& GetGridLineColor() const {return aGridLineColor;}
468 :
469 : // inserting, changing, removing and freezing of columns
470 : void InsertHandleColumn( sal_uLong nWidth );
471 : void InsertDataColumn( sal_uInt16 nItemId, const XubString& rText,
472 : long nSize, HeaderBarItemBits nBits = HIB_STDSTYLE,
473 : sal_uInt16 nPos = HEADERBAR_APPEND );
474 : void SetColumnTitle( sal_uInt16 nColumnId, const String &rTitle );
475 : void SetColumnWidth( sal_uInt16 nColumnId, sal_uLong nWidth );
476 : void SetColumnPos( sal_uInt16 nColumnId, sal_uInt16 nPos );
477 : void FreezeColumn( sal_uInt16 nColumnId, sal_Bool bFreeze = sal_True );
478 : void UnfreezeColumns();
479 : void RemoveColumn( sal_uInt16 nColumnId );
480 : void RemoveColumns();
481 :
482 : // control of title and data row height
483 : void SetDataRowHeight( long nPixel );
484 : long GetDataRowHeight() const;
485 : void SetTitleLines( sal_uInt16 nLines );
486 : sal_uInt16 GetTitleLines() const { return nTitleLines; }
487 : virtual long GetTitleHeight() const;
488 :
489 : // access to dynamic values of cursor row
490 : String GetColumnTitle( sal_uInt16 nColumnId ) const;
491 : Rectangle GetFieldRect( sal_uInt16 nColumnId ) const;
492 : sal_uLong GetColumnWidth( sal_uInt16 nColumnId ) const;
493 : sal_uInt16 GetColumnId( sal_uInt16 nPos ) const;
494 : sal_uInt16 GetColumnPos( sal_uInt16 nColumnId ) const;
495 : sal_Bool IsFrozen( sal_uInt16 nColumnId ) const;
496 :
497 : // movement of visible area
498 : void ResetScroll();
499 : long ScrollColumns( long nColumns );
500 : long ScrollRows( long nRows );
501 : sal_Bool MakeFieldVisible( long nRow, sal_uInt16 nColId, sal_Bool bComplete = sal_False );
502 :
503 : // access and movement of cursor
504 205 : long GetCurRow() const { return nCurRow; }
505 139 : sal_uInt16 GetCurColumnId() const { return nCurColId; }
506 : sal_Bool GoToRow( long nRow );
507 : sal_Bool GoToColumnId( sal_uInt16 nColId );
508 : sal_Bool GoToRowColumnId( long nRow, sal_uInt16 nColId );
509 :
510 : // selections
511 : virtual void SetNoSelection();
512 : virtual void SelectAll();
513 : virtual void SelectRow( long nRow, sal_Bool _bSelect = sal_True, sal_Bool bExpand = sal_True );
514 0 : void SelectColumnPos( sal_uInt16 nCol, sal_Bool _bSelect = sal_True )
515 0 : { SelectColumnPos( nCol, _bSelect, sal_True); }
516 0 : void SelectColumnId( sal_uInt16 nColId, sal_Bool _bSelect = sal_True )
517 0 : { SelectColumnPos( GetColumnPos(nColId), _bSelect, sal_True); }
518 : long GetSelectRowCount() const;
519 : sal_uInt16 GetSelectColumnCount() const;
520 : virtual bool IsRowSelected( long nRow ) const;
521 : bool IsColumnSelected( sal_uInt16 nColumnId ) const;
522 : long FirstSelectedRow( sal_Bool bInverse = sal_False );
523 : long LastSelectedRow();
524 : long NextSelectedRow();
525 23 : const MultiSelection* GetColumnSelection() const { return pColSel; }
526 1 : const MultiSelection* GetSelection() const
527 1 : { return bMultiSelection ? uRow.pSel : 0; }
528 :
529 : long FirstSelectedColumn( ) const;
530 :
531 1 : sal_Bool IsResizing() const { return bResizing; }
532 :
533 : // access to positions of fields, column and rows
534 1582 : Window& GetDataWindow() const { return *pDataWin; }
535 : Rectangle GetRowRectPixel( long nRow,
536 : sal_Bool bRelToBrowser = sal_True ) const;
537 : Rectangle GetFieldRectPixel( long nRow, sal_uInt16 nColId,
538 : sal_Bool bRelToBrowser = sal_True) const;
539 : sal_Bool IsFieldVisible( long nRow, sal_uInt16 nColId,
540 : sal_Bool bComplete = sal_False ) const;
541 : long GetRowAtYPosPixel( long nY,
542 : sal_Bool bRelToBrowser = sal_True ) const;
543 : sal_uInt16 GetColumnAtXPosPixel( long nX,
544 : sal_Bool bRelToBrowser = sal_True ) const;
545 :
546 : // invalidations
547 : void Clear();
548 : void RowRemoved( long nRow, long nNumRows = 1, sal_Bool bDoPaint = sal_True );
549 : void RowModified( long nRow, sal_uInt16 nColId = BROWSER_INVALIDID );
550 : void RowInserted( long nRow, long nNumRows = 1, sal_Bool bDoPaint = sal_True, sal_Bool bKeepSelection = sal_False );
551 :
552 : // miscellanous
553 : void ReserveControlArea( sal_uInt16 nWidth = USHRT_MAX );
554 : Rectangle GetControlArea() const;
555 : sal_Bool ProcessKey( const KeyEvent& rEvt );
556 : void Dispatch( sal_uInt16 nId );
557 : void SetMode( BrowserMode nMode = 0 );
558 56 : BrowserMode GetMode( ) const { return m_nCurrentMode; }
559 :
560 : void SetCursorColor(const Color& _rCol);
561 : Color GetCursorColor() const { return m_aCursorColor; }
562 : void ResetSelecting() { bSelecting = sal_False; }
563 :
564 : /** specifies that the user is allowed to interactively change the height of a row,
565 : by simply dragging an arbitrary row separator.
566 :
567 : Note that this works only if there's a handle column, since only in this case,
568 : there *is* something for the user to click onto
569 : */
570 21 : void EnableInteractiveRowHeight( sal_Bool _bEnable = sal_True ) { mbInteractiveRowHeight = _bEnable; }
571 0 : sal_Bool IsInteractiveRowHeightEnabled( ) const { return mbInteractiveRowHeight; }
572 :
573 : /// access to selected methods, to be granted to the BrowserColumn
574 64 : struct BrowserColumnAccess { friend class BrowserColumn; private: BrowserColumnAccess() { } };
575 : /** public version of PaintField, with selected access rights for the BrowserColumn
576 : */
577 64 : void DoPaintField( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId, BrowserColumnAccess ) const
578 64 : { PaintField( rDev, rRect, nColumnId ); }
579 :
580 : /** suggests a default width for a column containing a given text
581 :
582 : The width is calculated so that the text fits completely, plus som margin.
583 : */
584 : sal_uLong GetDefaultColumnWidth( const String& _rText ) const;
585 :
586 : /** GetCellText returns the text at the given position
587 : @param _nRow
588 : the number of the row
589 : @param _nColId
590 : the ID of the column
591 : @return
592 : the text out of the cell
593 : */
594 : virtual String GetCellText(long _nRow, sal_uInt16 _nColId) const;
595 :
596 : /** @return
597 : the current column count
598 : */
599 0 : sal_uInt16 GetColumnCount() const { return ColCount(); }
600 :
601 : /** commitBrowseBoxEvent commit the event at all listeners of the browsebox
602 : @param nEventId
603 : the event id
604 : @param rNewValue
605 : the new value
606 : @param rOldValue
607 : the old value
608 : */
609 : void commitBrowseBoxEvent(sal_Int16 nEventId,
610 : const css::uno::Any& rNewValue,
611 : const css::uno::Any& rOldValue);
612 :
613 : /** commitTableEvent commit the event at all listeners of the table
614 : @param nEventId
615 : the event id
616 : @param rNewValue
617 : the new value
618 : @param rOldValue
619 : the old value
620 : */
621 : void commitTableEvent(sal_Int16 nEventId,
622 : const css::uno::Any& rNewValue,
623 : const css::uno::Any& rOldValue);
624 :
625 : /** fires an AccessibleEvent relative to a header bar AccessibleContext
626 :
627 : @param nEventId
628 : the event id
629 : @param rNewValue
630 : the new value
631 : @param rOldValue
632 : the old value
633 : */
634 : void commitHeaderBarEvent(sal_Int16 nEventId,
635 : const css::uno::Any& rNewValue,
636 : const css::uno::Any& rOldValue,
637 : sal_Bool _bColumnHeaderBar
638 : );
639 :
640 : /** returns the Rectangle for either the column header bar ot the row header bar
641 : @param _bIsColumnBar
642 : <TRUE/> when column header bar is used
643 : @param _bOnScreen
644 : <TRUE/> when the rectangle should be calculated OnScreen
645 : @return
646 : the Rectangle
647 : */
648 : virtual Rectangle calcHeaderRect(sal_Bool _bIsColumnBar,sal_Bool _bOnScreen = sal_True);
649 :
650 : /** calculates the Rectangle of the table
651 : @param _bOnScreen
652 : <TRUE/> when the rectangle should be calculated OnScreen
653 : @return
654 : the Rectangle
655 : */
656 : virtual Rectangle calcTableRect(sal_Bool _bOnScreen = sal_True);
657 :
658 : /**
659 : @param _nRowId
660 : the current row
661 : @param _nColId
662 : the column id
663 : @param _bOnScreen
664 : <TRUE/> when the rectangle should be calculated OnScreen
665 : @return
666 : the Rectangle
667 : */
668 : virtual Rectangle GetFieldRectPixelAbs(sal_Int32 _nRowId,sal_uInt16 _nColId, sal_Bool _bIsHeader, sal_Bool _bOnScreen = sal_True);
669 :
670 : /// return <TRUE/> if and only if the accessible object for this instance has been created and is alive
671 : sal_Bool isAccessibleAlive( ) const;
672 :
673 : // ACCESSIBILITY ==========================================================
674 : public:
675 : /** Creates and returns the accessible object of the whole BrowseBox. */
676 : virtual css::uno::Reference<
677 : css::accessibility::XAccessible > CreateAccessible();
678 :
679 : // Children ---------------------------------------------------------------
680 :
681 : /** Creates the accessible object of a data table cell.
682 : @param nRow The row index of the cell.
683 : @param nColumnId The column pos of the cell.
684 : @return The XAccessible interface of the specified cell. */
685 : virtual css::uno::Reference<
686 : css::accessibility::XAccessible >
687 : CreateAccessibleCell( sal_Int32 nRow, sal_uInt16 nColumnPos );
688 :
689 : /** Creates the accessible object of a row header.
690 : @param nRow The row index of the header.
691 : @return The XAccessible interface of the specified row header. */
692 : virtual css::uno::Reference<
693 : css::accessibility::XAccessible >
694 : CreateAccessibleRowHeader( sal_Int32 nRow );
695 :
696 : /** Creates the accessible object of a column header.
697 : @param nColumnId The column ID of the header.
698 : @return The XAccessible interface of the specified column header. */
699 : virtual css::uno::Reference<
700 : css::accessibility::XAccessible >
701 : CreateAccessibleColumnHeader( sal_uInt16 nColumnPos );
702 :
703 : /** @return The count of additional controls of the control area. */
704 : virtual sal_Int32 GetAccessibleControlCount() const;
705 :
706 : /** Creates the accessible object of an additional control.
707 : @param nIndex The 0-based index of the control.
708 : @return The XAccessible interface of the specified control. */
709 : virtual css::uno::Reference<
710 : css::accessibility::XAccessible >
711 : CreateAccessibleControl( sal_Int32 nIndex );
712 :
713 : // Conversions ------------------------------------------------------------
714 :
715 : /** Converts a point relative to the data window origin to a cell address.
716 : @param rnRow Out-parameter that takes the row index.
717 : @param rnColumnId Out-parameter that takes the column ID.
718 : @param rPoint The position in pixels relative to the data window.
719 : @return <TRUE/>, if the point could be converted to a valid address. */
720 : virtual sal_Bool ConvertPointToCellAddress(
721 : sal_Int32& rnRow, sal_uInt16& rnColumnId, const Point& rPoint );
722 :
723 : /** Converts a point relative to the row header bar origin to a row header
724 : index.
725 : @param rnRow Out-parameter that takes the row index.
726 : @param rPoint The position in pixels relative to the header bar.
727 : @return <TRUE/>, if the point could be converted to a valid index. */
728 : virtual sal_Bool ConvertPointToRowHeader( sal_Int32& rnRow, const Point& rPoint );
729 :
730 : /** Converts a point relative to the column header bar origin to a column
731 : header index.
732 : @param rnColumnId Out-parameter that takes the column ID.
733 : @param rPoint The position in pixels relative to the header bar.
734 : @return <TRUE/>, if the point could be converted to a valid index. */
735 : virtual sal_Bool ConvertPointToColumnHeader( sal_uInt16& rnColumnPos, const Point& rPoint );
736 :
737 : /** Converts a point relative to the BrowseBox origin to the index of an
738 : existing control.
739 : @param rnRow Out-parameter that takes the 0-based control index.
740 : @param rPoint The position in pixels relative to the BrowseBox.
741 : @return <TRUE/>, if the point could be converted to a valid index. */
742 : virtual sal_Bool ConvertPointToControlIndex( sal_Int32& rnIndex, const Point& rPoint );
743 :
744 : // Object data and state --------------------------------------------------
745 :
746 : /** return the name of the specified object.
747 : @param eObjType
748 : The type to ask for
749 : @param _nPosition
750 : The position of a tablecell (index position), header bar colum/row cell
751 : @return
752 : The name of the specified object.
753 : */
754 : virtual OUString GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
755 :
756 : /** return the description of the specified object.
757 : @param eObjType
758 : The type to ask for
759 : @param _nPosition
760 : The position of a tablecell (index position), header bar colum/row cell
761 : @return
762 : The description of the specified object.
763 : */
764 : virtual OUString GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
765 :
766 : /** @return The header text of the specified row. */
767 : virtual OUString GetRowDescription( sal_Int32 nRow ) const;
768 :
769 : /** @return The header text of the specified column. */
770 : virtual OUString GetColumnDescription( sal_uInt16 _nColumn ) const;
771 :
772 : /** Fills the StateSet with all states (except DEFUNC and SHOWING, done by
773 : the accessible object), depending on the specified object type. */
774 : virtual void FillAccessibleStateSet(
775 : ::utl::AccessibleStateSetHelper& rStateSet,
776 : ::svt::AccessibleBrowseBoxObjType eObjType ) const;
777 :
778 : /** Fills the StateSet with all states for one cell (except DEFUNC and SHOWING, done by
779 : the accessible object). */
780 : virtual void FillAccessibleStateSetForCell(
781 : ::utl::AccessibleStateSetHelper& _rStateSet,
782 : sal_Int32 _nRow, sal_uInt16 _nColumn ) const;
783 :
784 : /** Sets focus to current cell of the data table. */
785 : virtual void GrabTableFocus();
786 :
787 : // IAccessibleTableProvider
788 : virtual sal_Int32 GetCurrRow() const;
789 : virtual sal_uInt16 GetCurrColumn() const;
790 : virtual sal_Bool HasRowHeader() const;
791 : virtual sal_Bool IsCellFocusable() const;
792 : virtual sal_Bool GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn );
793 : virtual void SelectColumn( sal_uInt16 _nColumn, sal_Bool _bSelect = sal_True );
794 : virtual sal_Bool IsColumnSelected( long _nColumn ) const;
795 : virtual sal_Int32 GetSelectedRowCount() const;
796 : virtual sal_Int32 GetSelectedColumnCount() const;
797 : virtual void GetAllSelectedRows( css::uno::Sequence< sal_Int32 >& _rRows ) const;
798 : virtual void GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumns ) const;
799 : virtual sal_Bool IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumn ) const;
800 : virtual String GetAccessibleCellText(long _nRow, sal_uInt16 _nColPos) const;
801 : virtual sal_Bool GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector );
802 : virtual Rectangle GetWindowExtentsRelative( Window *pRelativeWindow ) const;
803 : virtual void GrabFocus();
804 : virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible( sal_Bool bCreate = sal_True );
805 : virtual Window* GetAccessibleParentWindow() const;
806 : virtual Window* GetWindowInstance();
807 :
808 : private:
809 : // the following declares some Window/OutputDevice methods private. This happened in the course
810 : // of CWS warnings01, which pointed out nameclashs in those methods. If the build breaks in some
811 : // upper module, you should investigate whether you really wanted to call base class methods,
812 : // or the versions at this class. In the latter case, use the renamed versions above.
813 :
814 : // Set/GetLineColor - superseded by Set/GetGridLineColor
815 : using OutputDevice::SetLineColor;
816 : using OutputDevice::GetLineColor;
817 :
818 : // ToTop/ToBottom were never property implemented. If you currently call it, this is most probably wrong
819 : // and not doing as intended
820 : using Window::ToTop;
821 : };
822 :
823 : //-------------------------------------------------------------------
824 0 : inline const DataFlavorExVector& BrowseBox::GetDataFlavors() const
825 : {
826 0 : return *reinterpret_cast<DataFlavorExVector*>(implGetDataFlavors());
827 : }
828 :
829 : #endif
830 :
831 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|