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