GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / svtools / source / inc / svimpbox.hxx
blobb821873d6f51c11e7771235a5b898a79a9fcc1e7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_SVTOOLS_SOURCE_INC_SVIMPBOX_HXX
21 #define INCLUDED_SVTOOLS_SOURCE_INC_SVIMPBOX_HXX
23 #include <vcl/seleng.hxx>
24 #include <vcl/scrbar.hxx>
25 #include <vcl/vclevent.hxx>
26 // #102891# ----------------
27 #include <unotools/intlwrapper.hxx>
28 // #97680# -----------------
29 #include <vector>
30 #include "svtaccessiblefactory.hxx"
32 class SvTreeListBox;
33 class Point;
34 class SvTreeList;
35 class SvImpLBox;
36 class SvTreeListEntry;
37 class SvLBoxTab;
38 namespace comphelper
40 namespace string
42 class NaturalStringSorter;
46 class ImpLBSelEng : public FunctionSet
48 SvImpLBox* pImp;
49 SelectionEngine* pSelEng;
50 SvTreeListBox* pView;
52 public:
53 ImpLBSelEng( SvImpLBox* pImp, SelectionEngine* pSelEng,
54 SvTreeListBox* pView );
55 virtual ~ImpLBSelEng();
56 void BeginDrag();
57 void CreateAnchor();
58 void DestroyAnchor();
59 sal_Bool SetCursorAtPoint( const Point& rPoint,
60 sal_Bool bDontSelectAtCursor=sal_False );
61 sal_Bool IsSelectionAtPoint( const Point& rPoint );
62 void DeselectAtPoint( const Point& rPoint );
63 void DeselectAll();
66 // Flags fuer nFlag
67 #define F_VER_SBARSIZE_WITH_HBAR 0x0001
68 #define F_HOR_SBARSIZE_WITH_VBAR 0x0002
69 #define F_IGNORE_NEXT_MOUSEMOVE 0x0004 // OS/2 only
70 #define F_IN_SCROLLING 0x0008
71 #define F_DESEL_ALL 0x0010
72 #define F_START_EDITTIMER 0x0020 // MAC only
73 #define F_IGNORE_SELECT 0x0040
74 #define F_IN_RESIZE 0x0080
75 #define F_REMOVED_ENTRY_INVISIBLE 0x0100
76 #define F_REMOVED_RECALC_MOST_RIGHT 0x0200
77 #define F_IGNORE_CHANGED_TABS 0x0400
78 #define F_PAINTED 0x0800
79 #define F_IN_PAINT 0x1000
80 #define F_ENDSCROLL_SET_VIS_SIZE 0x2000
81 #define F_FILLING 0x4000
84 class SvImpLBox
86 friend class ImpLBSelEng;
87 friend class SvTreeListBox;
88 private:
89 SvTreeListBox* pView;
90 SvTreeList* pTree;
91 SvTreeListEntry* pCursor;
92 SvTreeListEntry* pStartEntry;
93 SvTreeListEntry* pAnchor;
94 SvTreeListEntry* pMostRightEntry;
95 SvLBoxButton* pActiveButton;
96 SvTreeListEntry* pActiveEntry;
97 SvLBoxTab* pActiveTab;
99 ScrollBar aVerSBar;
100 ScrollBar aHorSBar;
101 ScrollBarBox aScrBarBox;
103 ::svt::AccessibleFactoryAccess
104 m_aFactoryAccess;
106 static Image* s_pDefCollapsed;
107 static Image* s_pDefExpanded;
108 static oslInterlockedCount s_nImageRefCount; /// When 0 all static images will be destroyed
110 // Node Bitmaps
111 enum ImageType
113 itNodeExpanded = 0, // node is expanded ( usually a bitmap showing a minus )
114 itNodeCollapsed, // node is collapsed ( usually a bitmap showing a plus )
115 itNodeDontKnow, // don't know the node state
116 itEntryDefExpanded, // default for expanded entries
117 itEntryDefCollapsed, // default for collapsed entries
119 IT_IMAGE_COUNT
122 // all our images
123 Image m_aNodeAndEntryImages[ IT_IMAGE_COUNT ];
125 // wg. kompat. hier
126 Size aOutputSize;
127 SelectionEngine aSelEng;
128 ImpLBSelEng aFctSet;
129 Timer aAsyncBeginDragTimer;
130 Point aAsyncBeginDragPos;
132 long nYoffsNodeBmp;
133 long nNodeBmpTabDistance; // typisch kleiner 0
134 long nNodeBmpWidth;
135 long nNextVerVisSize;
136 long nMostRight;
137 sal_uLong nVisibleCount; // Anzahl Zeilen im Control
138 sal_uLong nCurUserEvent; //-1 == kein Userevent amn Laufen
139 short nHorSBarHeight, nVerSBarWidth;
140 sal_uInt16 nFlags;
141 sal_uInt16 nCurTabPos;
143 WinBits m_nStyle;
144 ExtendedWinBits nExtendedWinBits;
145 bool bSimpleTravel : 1; // ist true bei SINGLE_SELECTION
146 bool bUpdateMode : 1;
147 bool bInVScrollHdl : 1;
148 bool bAsyncBeginDrag : 1;
149 bool bSubLstOpRet : 1; // open/close sublist with return/enter, defaulted with false
150 bool bSubLstOpLR : 1; // open/close sublist with cursor left/right, defaulted with false
151 bool bContextMenuHandling : 1;
152 bool bIsCellFocusEnabled : 1;
154 bool bAreChildrenTransient;
156 Point aEditClickPos;
157 Timer aEditTimer;
159 // #102891# -------------------
160 comphelper::string::NaturalStringSorter *m_pStringSorter;
162 // #97680# --------------------
163 std::vector< short > aContextBmpWidthVector;
165 DECL_LINK(EditTimerCall, void *);
167 DECL_LINK( BeginDragHdl, void* );
168 DECL_LINK( MyUserEvent,void*);
169 void StopUserEvent();
171 void InvalidateEntriesFrom( long nY ) const;
172 void InvalidateEntry( long nY ) const;
173 void ShowVerSBar();
174 // setzt Thumb auf FirstEntryToDraw
175 void SyncVerThumb();
176 bool IsLineVisible( long nY ) const;
177 long GetEntryLine( SvTreeListEntry* pEntry ) const;
178 void FillView();
179 void CursorDown();
180 void CursorUp();
181 void KeyLeftRight( long nDiff );
182 void PageDown( sal_uInt16 nDelta );
183 void PageUp( sal_uInt16 nDelta );
185 void SetCursor( SvTreeListEntry* pEntry, bool bForceNoSelect = false );
187 void DrawNet();
189 // ScrollBar-Handler
190 DECL_LINK( ScrollUpDownHdl, ScrollBar * );
191 DECL_LINK( ScrollLeftRightHdl, ScrollBar * );
192 DECL_LINK( EndScrollHdl, void * );
194 void SetNodeBmpYOffset( const Image& );
195 void SetNodeBmpTabDistance();
197 // Selection-Engine
198 SvTreeListEntry* MakePointVisible( const Point& rPoint, bool bNotifyScroll=true );
200 void SetAnchorSelection( SvTreeListEntry* pOld,
201 SvTreeListEntry* pNewCursor );
202 void BeginDrag();
203 bool ButtonDownCheckCtrl( const MouseEvent& rMEvt, SvTreeListEntry* pEntry, long nY );
204 bool MouseMoveCheckCtrl( const MouseEvent& rMEvt, SvTreeListEntry* pEntry );
205 bool ButtonUpCheckCtrl( const MouseEvent& rMEvt );
206 bool ButtonDownCheckExpand( const MouseEvent&, SvTreeListEntry*,long nY );
208 void PositionScrollBars( Size& rOSize, sal_uInt16 nMask );
209 sal_uInt16 AdjustScrollBars( Size& rSize );
211 void BeginScroll();
212 void EndScroll();
213 bool InScroll() const { return (nFlags & F_IN_SCROLLING) != 0; }
214 Rectangle GetVisibleArea() const;
215 bool EntryReallyHit(SvTreeListEntry* pEntry, const Point& rPos, long nLine);
216 void InitScrollBarBox();
217 SvLBoxTab* NextTab( SvLBoxTab* );
219 bool SetMostRight( SvTreeListEntry* pEntry );
220 void FindMostRight( SvTreeListEntry* EntryToIgnore );
221 void FindMostRight( SvTreeListEntry* pParent, SvTreeListEntry* EntryToIgnore );
222 void FindMostRight_Impl( SvTreeListEntry* pParent,SvTreeListEntry* EntryToIgnore );
223 void NotifyTabsChanged();
225 // if element at cursor can be expanded in general
226 bool IsExpandable() const;
228 // if element at cursor can be expanded at this moment
229 bool IsNowExpandable() const;
231 static void implInitDefaultNodeImages();
233 void UpdateStringSorter();
235 // #97680# --------------------
236 short UpdateContextBmpWidthVector( SvTreeListEntry* pEntry, short nWidth );
237 void UpdateContextBmpWidthMax( SvTreeListEntry* pEntry );
238 void UpdateContextBmpWidthVectorFromMovedEntry( SvTreeListEntry* pEntry );
240 void CalcCellFocusRect( SvTreeListEntry* pEntry, Rectangle& rRect );
242 bool AreChildrenTransient() const { return bAreChildrenTransient; }
243 inline void SetChildrenNotTransient() { bAreChildrenTransient = false; }
245 public:
246 SvImpLBox( SvTreeListBox* pView, SvTreeList*, WinBits nWinStyle );
247 ~SvImpLBox();
249 void Clear();
250 void SetStyle( WinBits i_nWinStyle );
251 void SetExtendedWindowBits( ExtendedWinBits _nBits );
252 ExtendedWinBits GetExtendedWindowBits() const { return nExtendedWinBits; }
253 void SetModel( SvTreeList* pModel ) { pTree = pModel;}
255 void EntryInserted( SvTreeListEntry*);
256 void RemovingEntry( SvTreeListEntry* pEntry );
257 void EntryRemoved();
258 void MovingEntry( SvTreeListEntry* pEntry );
259 void EntryMoved( SvTreeListEntry* pEntry );
260 void TreeInserted( SvTreeListEntry* pEntry );
262 void EntryExpanded( SvTreeListEntry* pEntry );
263 void EntryCollapsed( SvTreeListEntry* pEntry );
264 void CollapsingEntry( SvTreeListEntry* pEntry );
265 void EntrySelected( SvTreeListEntry* pEntry, bool bSelect );
267 void Paint( const Rectangle& rRect );
268 void MouseButtonDown( const MouseEvent& );
269 void MouseButtonUp( const MouseEvent& );
270 void MouseMove( const MouseEvent&);
271 bool KeyInput( const KeyEvent& );
272 void Resize();
273 void GetFocus();
274 void LoseFocus();
275 void UpdateAll( bool bInvalidateCompleteView= true, bool bUpdateVerSBar = true );
276 void SetEntryHeight( short nHeight );
277 void PaintEntry( SvTreeListEntry* pEntry );
278 void InvalidateEntry( SvTreeListEntry* );
279 void RecalcFocusRect();
281 void SelectEntry( SvTreeListEntry* pEntry, bool bSelect );
282 void SetDragDropMode( DragDropMode eDDMode );
283 void SetSelectionMode( SelectionMode eSelMode );
285 SvTreeListEntry* GetCurrentEntry() const { return pCursor; }
286 bool IsEntryInView( SvTreeListEntry* pEntry ) const;
287 SvTreeListEntry* GetEntry( const Point& rPos ) const;
288 // gibt letzten Eintrag zurueck, falls Pos unter letztem Eintrag
289 SvTreeListEntry* GetClickedEntry( const Point& ) const;
290 SvTreeListEntry* GetCurEntry() const { return pCursor; }
291 void SetCurEntry( SvTreeListEntry* );
292 Point GetEntryPosition( SvTreeListEntry* ) const;
293 void MakeVisible( SvTreeListEntry* pEntry, bool bMoveToTop = false );
294 void ScrollToAbsPos( long nPos );
296 void PaintDDCursor( SvTreeListEntry* );
298 // Images
299 inline Image& implGetImageLocation( const ImageType _eType );
301 inline void SetExpandedNodeBmp( const Image& _rImg );
302 inline void SetCollapsedNodeBmp( const Image& _rImg );
304 inline const Image& GetExpandedNodeBmp( );
305 inline const Image& GetCollapsedNodeBmp( );
306 inline const Image& GetDontKnowNodeBmp( );
308 inline void SetDefaultEntryExpBmp( const Image& _rImg );
309 inline void SetDefaultEntryColBmp( const Image& _rImg );
310 inline const Image& GetDefaultEntryExpBmp( );
311 inline const Image& GetDefaultEntryColBmp( );
313 static const Image& GetDefaultExpandedNodeImage( );
314 static const Image& GetDefaultCollapsedNodeImage( );
316 const Size& GetOutputSize() const { return aOutputSize;}
317 void KeyUp( bool bPageUp, bool bNotifyScroll = true );
318 void KeyDown( bool bPageDown, bool bNotifyScroll = true );
319 void Command( const CommandEvent& rCEvt );
321 void Invalidate();
322 void DestroyAnchor() { pAnchor=0; aSelEng.Reset(); }
323 void SelAllDestrAnch( bool bSelect, bool bDestroyAnchor = true, bool bSingleSelToo = false );
324 void ShowCursor( bool bShow );
326 bool RequestHelp( const HelpEvent& rHEvt );
327 void EndSelection();
328 bool IsNodeButton( const Point& rPosPixel, SvTreeListEntry* pEntry ) const;
329 void RepaintScrollBars();
330 void EnableAsyncDrag( bool b ) { bAsyncBeginDrag = b; }
331 void SetUpdateMode( bool bMode );
332 bool GetUpdateMode() const { return bUpdateMode; }
333 Rectangle GetClipRegionRect() const;
334 bool HasHorScrollBar() const { return aHorSBar.IsVisible(); }
335 void ShowFocusRect( const SvTreeListEntry* pEntry );
336 void CallEventListeners( sal_uLong nEvent, void* pData = NULL );
338 /** Enables, that one cell of a tablistbox entry can be focused */
339 bool IsCellFocusEnabled() const { return bIsCellFocusEnabled; }
340 inline void EnableCellFocus() { bIsCellFocusEnabled = true; }
341 bool SetCurrentTabPos( sal_uInt16 _nNewPos );
342 inline sal_uInt16 GetCurrentTabPos() const { return nCurTabPos; }
344 bool IsSelectable( const SvTreeListEntry* pEntry );
347 inline Image& SvImpLBox::implGetImageLocation( const ImageType _eType )
349 DBG_ASSERT( ( _eType >= 0 ) && ( _eType < IT_IMAGE_COUNT ),
350 "SvImpLBox::implGetImageLocation: invalid image index (will crash)!" );
352 Image* _pSet = m_aNodeAndEntryImages;
353 return *( _pSet + (sal_Int32)_eType );
356 inline void SvImpLBox::SetExpandedNodeBmp( const Image& rImg )
358 implGetImageLocation( itNodeExpanded ) = rImg;
359 SetNodeBmpYOffset( rImg );
362 inline void SvImpLBox::SetCollapsedNodeBmp( const Image& rImg )
364 implGetImageLocation( itNodeCollapsed ) = rImg;
365 SetNodeBmpYOffset( rImg );
368 inline const Image& SvImpLBox::GetDontKnowNodeBmp( )
370 return implGetImageLocation( itNodeDontKnow );
373 inline const Image& SvImpLBox::GetExpandedNodeBmp( )
375 return implGetImageLocation( itNodeExpanded );
378 inline const Image& SvImpLBox::GetCollapsedNodeBmp( )
380 return implGetImageLocation( itNodeCollapsed );
383 inline void SvImpLBox::SetDefaultEntryExpBmp( const Image& _rImg )
385 implGetImageLocation( itEntryDefExpanded ) = _rImg;
388 inline void SvImpLBox::SetDefaultEntryColBmp( const Image& _rImg )
390 implGetImageLocation( itEntryDefCollapsed ) = _rImg;
393 inline const Image& SvImpLBox::GetDefaultEntryExpBmp( )
395 return implGetImageLocation( itEntryDefExpanded );
398 inline const Image& SvImpLBox::GetDefaultEntryColBmp( )
400 return implGetImageLocation( itEntryDefCollapsed );
403 inline Point SvImpLBox::GetEntryPosition( SvTreeListEntry* pEntry ) const
405 return Point( 0, GetEntryLine( pEntry ) );
408 inline void SvImpLBox::PaintEntry( SvTreeListEntry* pEntry )
410 long nY = GetEntryLine( pEntry );
411 pView->PaintEntry( pEntry, nY );
414 inline bool SvImpLBox::IsLineVisible( long nY ) const
416 bool bRet = true;
417 if ( nY < 0 || nY >= aOutputSize.Height() )
418 bRet = false;
419 return bRet;
422 inline void SvImpLBox::TreeInserted( SvTreeListEntry* pInsTree )
424 EntryInserted( pInsTree );
427 #endif // INCLUDED_SVTOOLS_SOURCE_INC_SVIMPBOX_HXX
429 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */